Merge branch 'master' into cherry_pick_conditional_sdk_rewrite
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index e85490f..23afda7 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -24,7 +24,7 @@
matrix:
sdk: [dev]
steps:
- - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
+ - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b
- uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d
with:
sdk: ${{ matrix.sdk }}
@@ -52,7 +52,7 @@
sdk: [dev]
shard: [0, 1, 2, 3, 4, 5, 6]
steps:
- - uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
+ - uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b
- uses: dart-lang/setup-dart@6a218f2413a3e78e9087f638a238f6b40893203d
with:
sdk: ${{ matrix.sdk }}
diff --git a/analysis_options.yaml b/analysis_options.yaml
index 2dc5e37..85fbba9 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -29,6 +29,7 @@
- prefer_const_declarations
- prefer_relative_imports
- prefer_single_quotes
+ - require_trailing_commas
- sort_pub_dependencies
- test_types_in_equals
- throw_in_finally
diff --git a/bin/dependency_services.dart b/bin/dependency_services.dart
index 90e528a..e9d76ac 100644
--- a/bin/dependency_services.dart
+++ b/bin/dependency_services.dart
@@ -36,16 +36,24 @@
final a = _argResults;
if (a == null) {
throw StateError(
- 'argResults cannot be used before Command.run is called.');
+ 'argResults cannot be used before Command.run is called.',
+ );
}
return a;
}
_DependencyServicesCommandRunner()
- : super('dependency_services', 'Support for automatic upgrades',
- usageLineLength: lineLength) {
- argParser.addFlag('verbose',
- abbr: 'v', negatable: false, help: 'Shortcut for "--verbosity=all".');
+ : super(
+ 'dependency_services',
+ 'Support for automatic upgrades',
+ usageLineLength: lineLength,
+ ) {
+ argParser.addFlag(
+ 'verbose',
+ abbr: 'v',
+ negatable: false,
+ help: 'Shortcut for "--verbosity=all".',
+ );
PubTopLevel.addColorFlag(argParser);
argParser.addOption(
'directory',
diff --git a/lib/pub.dart b/lib/pub.dart
index 71de9d6..631d5bc 100644
--- a/lib/pub.dart
+++ b/lib/pub.dart
@@ -21,8 +21,10 @@
///
/// [isVerbose] should return `true` (after argument resolution) if the
/// embedding top-level is in verbose mode.
-Command<int> pubCommand(
- {PubAnalytics? analytics, required bool Function() isVerbose}) =>
+Command<int> pubCommand({
+ PubAnalytics? analytics,
+ required bool Function() isVerbose,
+}) =>
PubEmbeddableCommand(analytics, isVerbose);
/// Support for the `pub` toplevel command.
diff --git a/lib/src/ascii_tree.dart b/lib/src/ascii_tree.dart
index a63d623..818be80 100644
--- a/lib/src/ascii_tree.dart
+++ b/lib/src/ascii_tree.dart
@@ -154,9 +154,14 @@
void drawChild(bool isLastChild, String child) {
var childPrefix = _getPrefix(name == null, isLast);
- _draw(buffer, '$prefix$childPrefix', child,
- children[child] as Map<String, Map>,
- showAllChildren: showAllChildren, isLast: isLastChild);
+ _draw(
+ buffer,
+ '$prefix$childPrefix',
+ child,
+ children[child] as Map<String, Map>,
+ showAllChildren: showAllChildren,
+ isLast: isLastChild,
+ );
}
for (var i = 0; i < childNames.length; i++) {
diff --git a/lib/src/authentication/client.dart b/lib/src/authentication/client.dart
index 787f394..c36e529 100644
--- a/lib/src/authentication/client.dart
+++ b/lib/src/authentication/client.dart
@@ -68,11 +68,13 @@
if (response.headers.containsKey(HttpHeaders.wwwAuthenticateHeader)) {
try {
final header = response.headers[HttpHeaders.wwwAuthenticateHeader]!;
- final challenge = AuthenticationChallenge.parseHeader(header)
- .firstWhereOrNull((challenge) =>
- challenge.scheme == 'bearer' &&
- challenge.parameters['realm'] == 'pub' &&
- challenge.parameters['message'] != null);
+ final challenge =
+ AuthenticationChallenge.parseHeader(header).firstWhereOrNull(
+ (challenge) =>
+ challenge.scheme == 'bearer' &&
+ challenge.parameters['realm'] == 'pub' &&
+ challenge.parameters['message'] != null,
+ );
if (challenge != null) {
serverMessage = challenge.parameters['message'];
}
@@ -83,9 +85,9 @@
if (serverMessage != null) {
// Only allow printable ASCII, map anything else to whitespace, take
// at-most 1024 characters.
- serverMessage = String.fromCharCodes(serverMessage.runes
- .map((r) => 32 <= r && r <= 127 ? r : 32)
- .take(1024));
+ serverMessage = String.fromCharCodes(
+ serverMessage.runes.map((r) => 32 <= r && r <= 127 ? r : 32).take(1024),
+ );
}
throw AuthenticationException(response.statusCode, serverMessage);
}
diff --git a/lib/src/authentication/credential.dart b/lib/src/authentication/credential.dart
index 010d3f3..9f7ce0d 100644
--- a/lib/src/authentication/credential.dart
+++ b/lib/src/authentication/credential.dart
@@ -52,7 +52,8 @@
const knownKeys = {'url', 'token', 'env'};
final unknownFields = Map.fromEntries(
- json.entries.where((kv) => !knownKeys.contains(kv.key)));
+ json.entries.where((kv) => !knownKeys.contains(kv.key)),
+ );
/// Returns [String] value from [json] at [key] index or `null` if [json]
/// doesn't contains [key].
diff --git a/lib/src/authentication/token_store.dart b/lib/src/authentication/token_store.dart
index fbb208a..a5ceba0 100644
--- a/lib/src/authentication/token_store.dart
+++ b/lib/src/authentication/token_store.dart
@@ -103,11 +103,12 @@
}
ensureDir(path.dirname(tokensFile));
writeTextFile(
- tokensFile,
- jsonEncode(<String, dynamic>{
- 'version': 1,
- 'hosted': credentials.map((it) => it.toJson()).toList(),
- }));
+ tokensFile,
+ jsonEncode(<String, dynamic>{
+ 'version': 1,
+ 'hosted': credentials.map((it) => it.toJson()).toList(),
+ }),
+ );
}
/// Adds [token] into store and writes into disk.
diff --git a/lib/src/command.dart b/lib/src/command.dart
index 90f920d..41f8343 100644
--- a/lib/src/command.dart
+++ b/lib/src/command.dart
@@ -50,7 +50,8 @@
final a = super.argResults;
if (a == null) {
throw StateError(
- 'argResults cannot be used before Command.run is called.');
+ 'argResults cannot be used before Command.run is called.',
+ );
}
return a;
}
@@ -92,7 +93,9 @@
// it but we want to initialize it based on [allowTrailingOptions].
@override
late final ArgParser argParser = ArgParser(
- allowTrailingOptions: allowTrailingOptions, usageLineLength: lineLength);
+ allowTrailingOptions: allowTrailingOptions,
+ usageLineLength: lineLength,
+ );
/// Override this to use offline-only sources instead of hitting the network.
///
@@ -187,8 +190,10 @@
var crashed = false;
try {
- await captureErrors<void>(() async => runProtected(),
- captureStackChains: _pubTopLevel.captureStackChains);
+ await captureErrors<void>(
+ () async => runProtected(),
+ captureStackChains: _pubTopLevel.captureStackChains,
+ );
if (_exitCodeOverride != null) {
return _exitCodeOverride!;
}
@@ -323,7 +328,8 @@
if (list.isEmpty) {
// this is a top-level command
final rootCommand = pubCommandAliases.entries.singleWhereOrNull(
- (element) => element.value.contains(command!.name));
+ (element) => element.value.contains(command!.name),
+ );
if (rootCommand != null) {
commandName = rootCommand.key;
}
diff --git a/lib/src/command/add.dart b/lib/src/command/add.dart
index 844f389..b490535 100644
--- a/lib/src/command/add.dart
+++ b/lib/src/command/add.dart
@@ -10,6 +10,7 @@
import 'package:yaml_edit/yaml_edit.dart';
import '../command.dart';
+import '../command_runner.dart';
import '../entrypoint.dart';
import '../exceptions.dart';
import '../git.dart';
@@ -40,7 +41,7 @@
@override
String get name => 'add';
@override
- String get description => r'''
+ String get description => '''
Add dependencies to `pubspec.yaml`.
Invoking `dart pub add foo bar` will add `foo` and `bar` to `pubspec.yaml`
@@ -69,7 +70,7 @@
* Add a git dependency:
`$topLevelProgram pub add 'foo{"git":"https://github.com/foo/foo"}'`
* Add a git dependency with a path and ref specified:
- `$topLevelProgram pub add \
+ `$topLevelProgram pub add \\
'foo{"git":{"url":"../foo.git","ref":"branch","path":"subdir"}}'`''';
@override
@@ -123,18 +124,28 @@
hide: true,
);
- argParser.addFlag('offline',
- help: 'Use cached packages instead of accessing the network.');
+ argParser.addFlag(
+ 'offline',
+ help: 'Use cached packages instead of accessing the network.',
+ );
- argParser.addFlag('dry-run',
- abbr: 'n',
- negatable: false,
- help: "Report what dependencies would change but don't change any.");
+ argParser.addFlag(
+ 'dry-run',
+ abbr: 'n',
+ negatable: false,
+ help: "Report what dependencies would change but don't change any.",
+ );
- argParser.addFlag('precompile',
- help: 'Build executables in immediate dependencies.');
- argParser.addOption('directory',
- abbr: 'C', help: 'Run this in the directory <dir>.', valueHelp: 'dir');
+ argParser.addFlag(
+ 'precompile',
+ help: 'Build executables in immediate dependencies.',
+ );
+ argParser.addOption(
+ 'directory',
+ abbr: 'C',
+ help: 'Run this in the directory <dir>.',
+ valueHelp: 'dir',
+ );
argParser.addFlag(
'example',
help:
@@ -182,7 +193,10 @@
/// that a resolution exists before we update pubspec.yaml.
// TODO(sigurdm): We should really use a spinner here.
solveResult = await resolveVersions(
- SolveType.upgrade, cache, Package.inMemory(updatedPubSpec));
+ SolveType.upgrade,
+ cache,
+ Package.inMemory(updatedPubSpec),
+ );
} on GitException {
final name = updates.first.ref.name;
dataError('Unable to resolve package "$name" with the given '
@@ -218,9 +232,12 @@
/// to this new dependency.
final newRoot = Package.inMemory(updatedPubSpec);
- await Entrypoint.inMemory(newRoot, cache,
- solveResult: solveResult, lockFile: entrypoint.lockFile)
- .acquireDependencies(
+ await Entrypoint.inMemory(
+ newRoot,
+ cache,
+ solveResult: solveResult,
+ lockFile: entrypoint.lockFile,
+ ).acquireDependencies(
SolveType.get,
dryRun: true,
precompile: argResults.shouldPrecompile,
@@ -249,7 +266,7 @@
await entrypoint.example!.acquireDependencies(
SolveType.get,
precompile: argResults.shouldPrecompile,
- onlyReportSuccessOrFailure: true,
+ summaryOnly: true,
analytics: analytics,
);
}
@@ -296,7 +313,8 @@
} else {
if (dependencyNames.contains(name)) {
log.message(
- '"$name" is already in "dependencies". Will try to update the constraint.');
+ '"$name" is already in "dependencies". Will try to update the constraint.',
+ );
dependencies.removeWhere((element) => element.name == name);
}
@@ -425,7 +443,8 @@
}
if (couldParseAsNewStyle) {
usageException(
- '--dev, --path, --sdk, --git-url, --git-path and --git-ref cannot be combined with a descriptor.');
+ '--dev, --path, --sdk, --git-url, --git-path and --git-ref cannot be combined with a descriptor.',
+ );
} else {
usageException('Invalid version constraint: ${e.message}');
}
@@ -460,7 +479,9 @@
);
} else if (path != null) {
ref = PackageRef(
- packageName, PathDescription(p.absolute(path), p.isRelative(path)));
+ packageName,
+ PathDescription(p.absolute(path), p.isRelative(path)),
+ );
} else if (argResults.sdk != null) {
ref = cache.sdk.parseRef(packageName, argResults.sdk);
} else {
@@ -538,13 +559,16 @@
// Use the pubspec parsing mechanism for parsing the descriptor.
final Pubspec dummyPubspec;
try {
- dummyPubspec = Pubspec.fromMap({
- 'dependencies': {
- packageName: parsedDescriptor,
- }
- }, cache.sources,
- // Resolve relative paths relative to current, not where the pubspec.yaml is.
- location: p.toUri(p.join(p.current, 'descriptor')));
+ dummyPubspec = Pubspec.fromMap(
+ {
+ 'dependencies': {
+ packageName: parsedDescriptor,
+ }
+ },
+ cache.sources,
+ // Resolve relative paths relative to current, not where the pubspec.yaml is.
+ location: p.toUri(p.join(p.current, 'descriptor')),
+ );
} on FormatException catch (e) {
usageException('Failed parsing package specification: ${e.message}');
}
@@ -603,8 +627,9 @@
} else {
pubspecInformation = {
ref.source.name: ref.description.serializeForPubspec(
- containingDir: entrypoint.root.dir,
- languageVersion: entrypoint.root.pubspec.languageVersion),
+ containingDir: entrypoint.root.dir,
+ languageVersion: entrypoint.root.pubspec.languageVersion,
+ ),
if (description is HostedDescription || constraint != null)
'version': versionConstraintString
};
@@ -618,9 +643,12 @@
// Handle the case where [dependencyKey] does not already exist.
// We ensure it is in Block-style by default.
yamlEditor.update(
- [dependencyKey],
- wrapAsYamlNode({name: pubspecInformation},
- collectionStyle: CollectionStyle.BLOCK));
+ [dependencyKey],
+ wrapAsYamlNode(
+ {name: pubspecInformation},
+ collectionStyle: CollectionStyle.BLOCK,
+ ),
+ );
} else {
final packagePath = [dependencyKey, name];
diff --git a/lib/src/command/barback.dart b/lib/src/command/barback.dart
index d058015..9d52aa9 100644
--- a/lib/src/command/barback.dart
+++ b/lib/src/command/barback.dart
@@ -22,8 +22,10 @@
log.json.enabled =
argResults.options.contains('format') && argResults['format'] == 'json';
- fail(log.red('Dart 2 has a new build system. Learn how to migrate '
- "from ${log.bold('pub build')} and\n"
- "${log.bold('pub serve')}: https://dart.dev/web/dart-2\n"));
+ fail(
+ log.red('Dart 2 has a new build system. Learn how to migrate '
+ "from ${log.bold('pub build')} and\n"
+ "${log.bold('pub serve')}: https://dart.dev/web/dart-2\n"),
+ );
}
}
diff --git a/lib/src/command/cache_add.dart b/lib/src/command/cache_add.dart
index ea8a8c1..763856e 100644
--- a/lib/src/command/cache_add.dart
+++ b/lib/src/command/cache_add.dart
@@ -23,8 +23,11 @@
String get docUrl => 'https://dart.dev/tools/pub/cmd/pub-cache';
CacheAddCommand() {
- argParser.addFlag('all',
- help: 'Install all matching versions.', negatable: false);
+ argParser.addFlag(
+ 'all',
+ help: 'Install all matching versions.',
+ negatable: false,
+ );
argParser.addOption('version', abbr: 'v', help: 'Version constraint.');
}
diff --git a/lib/src/command/cache_repair.dart b/lib/src/command/cache_repair.dart
index a4dccab..1c3cd8c 100644
--- a/lib/src/command/cache_repair.dart
+++ b/lib/src/command/cache_repair.dart
@@ -26,11 +26,12 @@
// Delete any eventual temp-files left in the cache.
cache.deleteTempDir();
// Repair every cached source.
- final repairResults =
- (await Future.wait(<CachedSource>[cache.hosted, cache.git].map(
- (source) => source.repairCachedPackages(cache),
- )))
- .expand((x) => x);
+ final repairResults = (await Future.wait(
+ <CachedSource>[cache.hosted, cache.git].map(
+ (source) => source.repairCachedPackages(cache),
+ ),
+ ))
+ .expand((x) => x);
final successes = repairResults.where((result) => result.success);
final failures = repairResults.where((result) => !result.success);
@@ -43,7 +44,8 @@
if (failures.isNotEmpty) {
var packages = pluralize('package', failures.length);
var buffer = StringBuffer(
- 'Failed to reinstall ${log.red(failures.length)} $packages:\n');
+ 'Failed to reinstall ${log.red(failures.length)} $packages:\n',
+ );
for (var failure in failures) {
buffer.write('- ${log.bold(failure.packageName)} ${failure.version}');
@@ -60,16 +62,20 @@
if (globalRepairResults.first.isNotEmpty) {
var packages = pluralize('package', globalRepairResults.first.length);
log.message(
- 'Reactivated ${log.green(globalRepairResults.first.length)} $packages.');
+ 'Reactivated ${log.green(globalRepairResults.first.length)} $packages.',
+ );
}
if (globalRepairResults.last.isNotEmpty) {
var packages = pluralize('package', globalRepairResults.last.length);
log.message(
- 'Failed to reactivate ${log.red(globalRepairResults.last.length)} $packages:');
- log.message(globalRepairResults.last
- .map((name) => '- ${log.bold(name)}')
- .join('\n'));
+ 'Failed to reactivate ${log.red(globalRepairResults.last.length)} $packages:',
+ );
+ log.message(
+ globalRepairResults.last
+ .map((name) => '- ${log.bold(name)}')
+ .join('\n'),
+ );
}
if (successes.isEmpty && failures.isEmpty) {
diff --git a/lib/src/command/dependency_services.dart b/lib/src/command/dependency_services.dart
index 13c6e70..6815b0b 100644
--- a/lib/src/command/dependency_services.dart
+++ b/lib/src/command/dependency_services.dart
@@ -41,8 +41,12 @@
bool get takesArguments => false;
DependencyServicesReportCommand() {
- argParser.addOption('directory',
- abbr: 'C', help: 'Run this in the directory<dir>.', valueHelp: 'dir');
+ argParser.addOption(
+ 'directory',
+ abbr: 'C',
+ help: 'Run this in the directory<dir>.',
+ valueHelp: 'dir',
+ );
}
@override
@@ -163,8 +167,10 @@
'previousVersion':
currentPackages[oldPackageName]?.versionOrHash(),
'previousConstraint': null,
- 'previous': _source(currentPackages[oldPackageName]!,
- containingDir: directory)
+ 'previous': _source(
+ currentPackages[oldPackageName]!,
+ containingDir: directory,
+ )
},
];
}
@@ -205,15 +211,23 @@
'constraint':
_constraintOf(compatiblePubspec, package.name)?.toString(),
'compatible': await computeUpgradeSet(
- compatiblePubspec, compatibleVersion,
- upgradeType: _UpgradeType.compatible),
+ compatiblePubspec,
+ compatibleVersion,
+ upgradeType: _UpgradeType.compatible,
+ ),
'singleBreaking': kind != 'transitive' && singleBreakingVersion == null
? []
- : await computeUpgradeSet(compatiblePubspec, singleBreakingVersion,
- upgradeType: _UpgradeType.singleBreaking),
+ : await computeUpgradeSet(
+ compatiblePubspec,
+ singleBreakingVersion,
+ upgradeType: _UpgradeType.singleBreaking,
+ ),
'multiBreaking': kind != 'transitive' && multiBreakingVersion != null
- ? await computeUpgradeSet(compatiblePubspec, multiBreakingVersion,
- upgradeType: _UpgradeType.multiBreaking)
+ ? await computeUpgradeSet(
+ compatiblePubspec,
+ multiBreakingVersion,
+ upgradeType: _UpgradeType.multiBreaking,
+ )
: [],
});
}
@@ -267,8 +281,12 @@
bool get takesArguments => false;
DependencyServicesListCommand() {
- argParser.addOption('directory',
- abbr: 'C', help: 'Run this in the directory<dir>.', valueHelp: 'dir');
+ argParser.addOption(
+ 'directory',
+ abbr: 'C',
+ help: 'Run this in the directory<dir>.',
+ valueHelp: 'dir',
+ );
}
@override
@@ -330,8 +348,12 @@
bool get takesArguments => true;
DependencyServicesApplyCommand() {
- argParser.addOption('directory',
- abbr: 'C', help: 'Run this in the directory <dir>.', valueHelp: 'dir');
+ argParser.addOption(
+ 'directory',
+ abbr: 'C',
+ help: 'Run this in the directory <dir>.',
+ valueHelp: 'dir',
+ );
}
@override
@@ -376,10 +398,13 @@
.update([section, targetPackage], targetConstraint.toString());
} else if (packageConfig is Map) {
pubspecEditor.update(
- [section, targetPackage, 'version'], targetConstraint.toString());
+ [section, targetPackage, 'version'],
+ targetConstraint.toString(),
+ );
} else {
fail(
- 'The dependency $targetPackage does not have a map or string as a description');
+ 'The dependency $targetPackage does not have a map or string as a description',
+ );
}
} else if (targetVersion != null) {
final constraint = _constraintOf(pubspec, targetPackage);
@@ -387,15 +412,19 @@
final section = pubspec.dependencies[targetPackage] != null
? 'dependencies'
: 'dev_dependencies';
- pubspecEditor.update([section, targetPackage],
- VersionConstraint.compatibleWith(targetVersion).toString());
+ pubspecEditor.update(
+ [section, targetPackage],
+ VersionConstraint.compatibleWith(targetVersion).toString(),
+ );
}
}
if (lockFileEditor != null) {
if (targetVersion != null &&
lockFileYaml['packages'].containsKey(targetPackage)) {
lockFileEditor.update(
- ['packages', targetPackage, 'version'], targetVersion.toString());
+ ['packages', targetPackage, 'version'],
+ targetVersion.toString(),
+ );
// Remove the now outdated content-hash - it will be restored below
// after resolution.
if (lockFileEditor
@@ -411,22 +440,27 @@
final ref = entrypoint.lockFile.packages[targetPackage]!.toRef();
final currentDescription = ref.description as GitDescription;
final updatedRef = PackageRef(
- targetPackage,
- GitDescription(
- url: currentDescription.url,
- path: currentDescription.path,
- ref: targetRevision,
- containingDir: directory));
+ targetPackage,
+ GitDescription(
+ url: currentDescription.url,
+ path: currentDescription.path,
+ ref: targetRevision,
+ containingDir: directory,
+ ),
+ );
final versions = await cache.getVersions(updatedRef);
if (versions.isEmpty) {
dataError(
- 'Found no versions of $targetPackage with git revision `$targetRevision`.');
+ 'Found no versions of $targetPackage with git revision `$targetRevision`.',
+ );
}
// GitSource can only return a single version.
assert(versions.length == 1);
- lockFileEditor.update(['packages', targetPackage, 'version'],
- versions.single.version.toString());
+ lockFileEditor.update(
+ ['packages', targetPackage, 'version'],
+ versions.single.version.toString(),
+ );
lockFileEditor.update(
['packages', targetPackage, 'description', 'resolved-ref'],
targetRevision,
@@ -448,7 +482,7 @@
cache.sources,
filePath: entrypoint.lockFilePath,
);
- await log.warningsOnlyUnlessTerminal(
+ await log.errorsOnlyUnlessTerminal(
() async {
final updatedPubspec = pubspecEditor.toString();
// Resolve versions, this will update transitive dependencies that were
@@ -461,8 +495,13 @@
final solveResult = await resolveVersions(
SolveType.get,
cache,
- Package.inMemory(Pubspec.parse(updatedPubspec, cache.sources,
- location: toUri(entrypoint.pubspecPath))),
+ Package.inMemory(
+ Pubspec.parse(
+ updatedPubspec,
+ cache.sources,
+ location: toUri(entrypoint.pubspecPath),
+ ),
+ ),
lockFile: updatedLockfile,
);
if (pubspecEditor.edits.isNotEmpty) {
@@ -557,7 +596,9 @@
}
Map<String, PackageRange>? _dependencySetOfPackage(
- Pubspec pubspec, PackageId package) {
+ Pubspec pubspec,
+ PackageId package,
+) {
return pubspec.dependencies.containsKey(package.name)
? pubspec.dependencies
: pubspec.devDependencies.containsKey(package.name)
@@ -566,7 +607,9 @@
}
VersionConstraint _widenConstraint(
- VersionConstraint original, Version newVersion) {
+ VersionConstraint original,
+ Version newVersion,
+) {
if (original.allows(newVersion)) return original;
if (original is VersionRange) {
final min = original.min;
@@ -583,17 +626,21 @@
if (min != null && newVersion <= min) {
return _compatibleWithIfPossible(
VersionRange(
- min: newVersion,
- includeMin: true,
- max: max,
- includeMax: original.includeMax),
+ min: newVersion,
+ includeMin: true,
+ max: max,
+ includeMax: original.includeMax,
+ ),
);
}
}
if (original.isEmpty) return newVersion;
throw ArgumentError.value(
- original, 'original', 'Must be a Version range or empty');
+ original,
+ 'original',
+ 'Must be a Version range or empty',
+ );
}
VersionConstraint _compatibleWithIfPossible(VersionRange versionRange) {
diff --git a/lib/src/command/deps.dart b/lib/src/command/deps.dart
index d34c868..8b4514d 100644
--- a/lib/src/command/deps.dart
+++ b/lib/src/command/deps.dart
@@ -38,24 +38,38 @@
bool get _includeDev => argResults['dev'];
DepsCommand() {
- argParser.addOption('style',
- abbr: 's',
- help: 'How output should be displayed.',
- allowed: ['compact', 'tree', 'list'],
- defaultsTo: 'tree');
+ argParser.addOption(
+ 'style',
+ abbr: 's',
+ help: 'How output should be displayed.',
+ allowed: ['compact', 'tree', 'list'],
+ defaultsTo: 'tree',
+ );
- argParser.addFlag('dev',
- help: 'Whether to include dev dependencies.', defaultsTo: true);
+ argParser.addFlag(
+ 'dev',
+ help: 'Whether to include dev dependencies.',
+ defaultsTo: true,
+ );
- argParser.addFlag('executables',
- negatable: false, help: 'List all available executables.');
+ argParser.addFlag(
+ 'executables',
+ negatable: false,
+ help: 'List all available executables.',
+ );
- argParser.addFlag('json',
- negatable: false,
- help: 'Output dependency information in a json format.');
+ argParser.addFlag(
+ 'json',
+ negatable: false,
+ help: 'Output dependency information in a json format.',
+ );
- argParser.addOption('directory',
- abbr: 'C', help: 'Run this in the directory<dir>.', valueHelp: 'dir');
+ argParser.addOption(
+ 'directory',
+ abbr: 'C',
+ help: 'Run this in the directory<dir>.',
+ valueHelp: 'dir',
+ );
}
@override
@@ -67,11 +81,13 @@
if (argResults['json']) {
if (argResults.wasParsed('dev')) {
usageException(
- 'Cannot combine --json and --dev.\nThe json output contains the dependency type in the output.');
+ 'Cannot combine --json and --dev.\nThe json output contains the dependency type in the output.',
+ );
}
if (argResults.wasParsed('executables')) {
usageException(
- 'Cannot combine --json and --executables.\nThe json output always lists available executables.');
+ 'Cannot combine --json and --executables.\nThe json output always lists available executables.',
+ );
}
if (argResults.wasParsed('style')) {
usageException('Cannot combine --json and --style.');
@@ -114,9 +130,11 @@
...entrypoint.root.immediateDependencies.keys
.map((name) => entrypoint.packageGraph.packages[name])
])
- ...package!.executableNames.map((name) => package == entrypoint.root
- ? ':$name'
- : (package.name == name ? name : '${package.name}:$name'))
+ ...package!.executableNames.map(
+ (name) => package == entrypoint.root
+ ? ':$name'
+ : (package.name == name ? name : '${package.name}:$name'),
+ )
];
_buffer.writeln(
@@ -174,7 +192,9 @@
_outputCompactPackages('dev dependencies', root.devDependencies.keys);
}
_outputCompactPackages(
- 'dependency overrides', root.dependencyOverrides.keys);
+ 'dependency overrides',
+ root.dependencyOverrides.keys,
+ );
var transitive = _getTransitiveDependencies();
_outputCompactPackages('transitive dependencies', transitive);
diff --git a/lib/src/command/downgrade.dart b/lib/src/command/downgrade.dart
index 274ab48..8a71c6a 100644
--- a/lib/src/command/downgrade.dart
+++ b/lib/src/command/downgrade.dart
@@ -24,13 +24,17 @@
bool get isOffline => argResults['offline'];
DowngradeCommand() {
- argParser.addFlag('offline',
- help: 'Use cached packages instead of accessing the network.');
+ argParser.addFlag(
+ 'offline',
+ help: 'Use cached packages instead of accessing the network.',
+ );
- argParser.addFlag('dry-run',
- abbr: 'n',
- negatable: false,
- help: "Report what dependencies would change but don't change any.");
+ argParser.addFlag(
+ 'dry-run',
+ abbr: 'n',
+ negatable: false,
+ help: "Report what dependencies would change but don't change any.",
+ );
argParser.addFlag('packages-dir', hide: true);
@@ -40,15 +44,22 @@
hide: true,
);
- argParser.addOption('directory',
- abbr: 'C', help: 'Run this in the directory<dir>.', valueHelp: 'dir');
+ argParser.addOption(
+ 'directory',
+ abbr: 'C',
+ help: 'Run this in the directory<dir>.',
+ valueHelp: 'dir',
+ );
}
@override
Future<void> runProtected() async {
if (argResults.wasParsed('packages-dir')) {
- log.warning(log.yellow(
- 'The --packages-dir flag is no longer used and does nothing.'));
+ log.warning(
+ log.yellow(
+ 'The --packages-dir flag is no longer used and does nothing.',
+ ),
+ );
}
var dryRun = argResults['dry-run'];
@@ -64,7 +75,7 @@
SolveType.get,
unlock: argResults.rest,
dryRun: dryRun,
- onlyReportSuccessOrFailure: true,
+ summaryOnly: true,
analytics: analytics,
);
}
diff --git a/lib/src/command/get.dart b/lib/src/command/get.dart
index 96cf525..9294a28 100644
--- a/lib/src/command/get.dart
+++ b/lib/src/command/get.dart
@@ -20,13 +20,17 @@
bool get isOffline => argResults['offline'];
GetCommand() {
- argParser.addFlag('offline',
- help: 'Use cached packages instead of accessing the network.');
+ argParser.addFlag(
+ 'offline',
+ help: 'Use cached packages instead of accessing the network.',
+ );
- argParser.addFlag('dry-run',
- abbr: 'n',
- negatable: false,
- help: "Report what dependencies would change but don't change any.");
+ argParser.addFlag(
+ 'dry-run',
+ abbr: 'n',
+ negatable: false,
+ help: "Report what dependencies would change but don't change any.",
+ );
argParser.addFlag(
'enforce-lockfile',
@@ -35,8 +39,10 @@
'Enforce pubspec.lock. Fail resolution if pubspec.lock does not satisfy pubspec.yaml',
);
- argParser.addFlag('precompile',
- help: 'Build executables in immediate dependencies.');
+ argParser.addFlag(
+ 'precompile',
+ help: 'Build executables in immediate dependencies.',
+ );
argParser.addFlag('packages-dir', hide: true);
@@ -46,15 +52,22 @@
hide: true,
);
- argParser.addOption('directory',
- abbr: 'C', help: 'Run this in the directory<dir>.', valueHelp: 'dir');
+ argParser.addOption(
+ 'directory',
+ abbr: 'C',
+ help: 'Run this in the directory<dir>.',
+ valueHelp: 'dir',
+ );
}
@override
Future<void> runProtected() async {
if (argResults.wasParsed('packages-dir')) {
- log.warning(log.yellow(
- 'The --packages-dir flag is no longer used and does nothing.'));
+ log.warning(
+ log.yellow(
+ 'The --packages-dir flag is no longer used and does nothing.',
+ ),
+ );
}
await entrypoint.acquireDependencies(
@@ -72,7 +85,7 @@
dryRun: argResults['dry-run'],
precompile: argResults['precompile'],
analytics: analytics,
- onlyReportSuccessOrFailure: true,
+ summaryOnly: true,
enforceLockfile: argResults['enforce-lockfile'],
);
}
diff --git a/lib/src/command/global_activate.dart b/lib/src/command/global_activate.dart
index 53353ae..050139d 100644
--- a/lib/src/command/global_activate.dart
+++ b/lib/src/command/global_activate.dart
@@ -20,37 +20,59 @@
String get argumentsDescription => '<package> [version-constraint]';
GlobalActivateCommand() {
- argParser.addOption('source',
- abbr: 's',
- help: 'The source used to find the package.',
- allowed: ['git', 'hosted', 'path'],
- defaultsTo: 'hosted');
+ argParser.addOption(
+ 'source',
+ abbr: 's',
+ help: 'The source used to find the package.',
+ allowed: ['git', 'hosted', 'path'],
+ defaultsTo: 'hosted',
+ );
argParser.addOption('git-path', help: 'Path of git package in repository');
- argParser.addOption('git-ref',
- help: 'Git branch or commit to be retrieved');
+ argParser.addOption(
+ 'git-ref',
+ help: 'Git branch or commit to be retrieved',
+ );
- argParser.addMultiOption('features',
- abbr: 'f', help: 'Feature(s) to enable.', hide: true);
+ argParser.addMultiOption(
+ 'features',
+ abbr: 'f',
+ help: 'Feature(s) to enable.',
+ hide: true,
+ );
- argParser.addMultiOption('omit-features',
- abbr: 'F', help: 'Feature(s) to disable.', hide: true);
+ argParser.addMultiOption(
+ 'omit-features',
+ abbr: 'F',
+ help: 'Feature(s) to disable.',
+ hide: true,
+ );
- argParser.addFlag('no-executables',
- negatable: false, help: 'Do not put executables on PATH.');
+ argParser.addFlag(
+ 'no-executables',
+ negatable: false,
+ help: 'Do not put executables on PATH.',
+ );
- argParser.addMultiOption('executable',
- abbr: 'x', help: 'Executable(s) to place on PATH.');
+ argParser.addMultiOption(
+ 'executable',
+ abbr: 'x',
+ help: 'Executable(s) to place on PATH.',
+ );
- argParser.addFlag('overwrite',
- negatable: false,
- help: 'Overwrite executables from other packages with the same name.');
+ argParser.addFlag(
+ 'overwrite',
+ negatable: false,
+ help: 'Overwrite executables from other packages with the same name.',
+ );
- argParser.addOption('hosted-url',
- abbr: 'u',
- help:
- 'A custom pub server URL for the package. Only applies when using the `hosted` source.');
+ argParser.addOption(
+ 'hosted-url',
+ abbr: 'u',
+ help:
+ 'A custom pub server URL for the package. Only applies when using the `hosted` source.',
+ );
}
@override
@@ -97,7 +119,8 @@
if (argResults['source'] != 'git' &&
(argResults['git-path'] != null || argResults['git-ref'] != null)) {
usageException(
- 'Options `--git-path` and `--git-ref` can only be used with --source=git.');
+ 'Options `--git-path` and `--git-ref` can only be used with --source=git.',
+ );
}
switch (argResults['source']) {
diff --git a/lib/src/command/global_run.dart b/lib/src/command/global_run.dart
index 71e0a9d..c7e615b 100644
--- a/lib/src/command/global_run.dart
+++ b/lib/src/command/global_run.dart
@@ -28,12 +28,17 @@
GlobalRunCommand({this.alwaysUseSubprocess = false}) {
argParser.addFlag('enable-asserts', help: 'Enable assert statements.');
argParser.addFlag('checked', abbr: 'c', hide: true);
- argParser.addMultiOption('enable-experiment',
- help: 'Runs the executable in a VM with the given experiments enabled. '
- '(Will disable snapshotting, resulting in slower startup).',
- valueHelp: 'experiment');
- argParser.addFlag('sound-null-safety',
- help: 'Override the default null safety execution mode.');
+ argParser.addMultiOption(
+ 'enable-experiment',
+ help: 'Runs the executable in a VM with the given experiments enabled. '
+ '(Will disable snapshotting, resulting in slower startup).',
+ valueHelp: 'experiment',
+ );
+ argParser.addFlag(
+ 'sound-null-safety',
+ help: 'Override the default null safety execution mode.',
+ hide: true,
+ );
argParser.addOption('mode', help: 'Deprecated option', hide: true);
}
@@ -42,6 +47,9 @@
if (argResults.rest.isEmpty) {
usageException('Must specify an executable to run.');
}
+ if (argResults.wasParsed('sound-null-safety')) {
+ dataError('The --(no-)sound-null-safety flag is no longer supported.');
+ }
String package;
var executable = argResults.rest[0];
@@ -72,8 +80,9 @@
args,
vmArgs: vmArgs,
enableAsserts: argResults['enable-asserts'] || argResults['checked'],
- recompile: (executable) => log.warningsOnlyUnlessTerminal(
- () => globalEntrypoint.precompileExecutable(executable)),
+ recompile: (executable) => log.errorsOnlyUnlessTerminal(
+ () => globalEntrypoint.precompileExecutable(executable),
+ ),
alwaysUseSubprocess: alwaysUseSubprocess,
);
overrideExitCode(exitCode);
diff --git a/lib/src/command/lish.dart b/lib/src/command/lish.dart
index 7090412..edee17f 100644
--- a/lib/src/command/lish.dart
+++ b/lib/src/command/lish.dart
@@ -69,20 +69,30 @@
bool get force => argResults['force'];
LishCommand() {
- argParser.addFlag('dry-run',
- abbr: 'n',
- negatable: false,
- help: 'Validate but do not publish the package.');
- argParser.addFlag('force',
- abbr: 'f',
- negatable: false,
- help: 'Publish without confirmation if there are no errors.');
- argParser.addOption('server',
- help: 'The package server to which to upload this package.',
- hide: true);
+ argParser.addFlag(
+ 'dry-run',
+ abbr: 'n',
+ negatable: false,
+ help: 'Validate but do not publish the package.',
+ );
+ argParser.addFlag(
+ 'force',
+ abbr: 'f',
+ negatable: false,
+ help: 'Publish without confirmation if there are no errors.',
+ );
+ argParser.addOption(
+ 'server',
+ help: 'The package server to which to upload this package.',
+ hide: true,
+ );
- argParser.addOption('directory',
- abbr: 'C', help: 'Run this in the directory<dir>.', valueHelp: 'dir');
+ argParser.addOption(
+ 'directory',
+ abbr: 'C',
+ help: 'Run this in the directory<dir>.',
+ valueHelp: 'dir',
+ );
}
Future<void> _publishUsingClient(
@@ -122,8 +132,13 @@
});
request.followRedirects = false;
- request.files.add(http.MultipartFile.fromBytes('file', packageBytes,
- filename: 'package.tar.gz'));
+ request.files.add(
+ http.MultipartFile.fromBytes(
+ 'file',
+ packageBytes,
+ filename: 'package.tar.gz',
+ ),
+ );
return await client.fetch(request);
});
@@ -219,7 +234,7 @@
@override
Future runProtected() async {
if (argResults.wasParsed('server')) {
- await log.warningsOnlyUnlessTerminal(() {
+ await log.errorsOnlyUnlessTerminal(() {
log.message(
'''
The --server option is deprecated. Use `publish_to` in your pubspec.yaml or set
@@ -255,7 +270,9 @@
// Validate the package.
var isValid = await _validate(
- packageBytesFuture.then((bytes) => bytes.length), files);
+ packageBytesFuture.then((bytes) => bytes.length),
+ files,
+ );
if (!isValid) {
overrideExitCode(exit_codes.DATA);
return;
diff --git a/lib/src/command/list_package_dirs.dart b/lib/src/command/list_package_dirs.dart
index c18eae0..0922811 100644
--- a/lib/src/command/list_package_dirs.dart
+++ b/lib/src/command/list_package_dirs.dart
@@ -25,10 +25,17 @@
bool get hidden => true;
ListPackageDirsCommand() {
- argParser.addOption('format',
- help: 'How output should be displayed.', allowed: ['json']);
- argParser.addOption('directory',
- abbr: 'C', help: 'Run this in the directory<dir>.', valueHelp: 'dir');
+ argParser.addOption(
+ 'format',
+ help: 'How output should be displayed.',
+ allowed: ['json'],
+ );
+ argParser.addOption(
+ 'directory',
+ abbr: 'C',
+ help: 'Run this in the directory<dir>.',
+ valueHelp: 'dir',
+ );
}
@override
@@ -37,19 +44,22 @@
if (!fileExists(entrypoint.lockFilePath)) {
dataError(
- 'Package "myapp" has no lockfile. Please run "$topLevelProgram pub get" first.');
+ 'Package "myapp" has no lockfile. Please run "$topLevelProgram pub get" first.',
+ );
}
var output = {};
// Include the local paths to all locked packages.
- var packages = mapMap(entrypoint.lockFile.packages,
- value: (String name, PackageId package) {
- var packageDir = cache.getDirectory(package);
- // Normalize paths and make them absolute for backwards compatibility
- // with the protocol used by the analyzer.
- return p.normalize(p.absolute(p.join(packageDir, 'lib')));
- });
+ var packages = mapMap(
+ entrypoint.lockFile.packages,
+ value: (String name, PackageId package) {
+ var packageDir = cache.getDirectory(package);
+ // Normalize paths and make them absolute for backwards compatibility
+ // with the protocol used by the analyzer.
+ return p.normalize(p.absolute(p.join(packageDir, 'lib')));
+ },
+ );
// Include the self link.
packages[entrypoint.root.name] =
diff --git a/lib/src/command/login.dart b/lib/src/command/login.dart
index 0743845..f140317 100644
--- a/lib/src/command/login.dart
+++ b/lib/src/command/login.dart
@@ -57,12 +57,14 @@
return _UserInfo(name, email);
} else {
log.fine(
- 'Bad response from $userInfoEndpoint: ${userInfoRequest.body}');
+ 'Bad response from $userInfoEndpoint: ${userInfoRequest.body}',
+ );
return null;
}
} on FormatException catch (e) {
log.fine(
- 'Bad response from $userInfoEndpoint ($e): ${userInfoRequest.body}');
+ 'Bad response from $userInfoEndpoint ($e): ${userInfoRequest.body}',
+ );
return null;
}
});
diff --git a/lib/src/command/outdated.dart b/lib/src/command/outdated.dart
index e35fa9c..ad4343d 100644
--- a/lib/src/command/outdated.dart
+++ b/lib/src/command/outdated.dart
@@ -4,11 +4,9 @@
import 'dart:async';
import 'dart:convert';
-import 'dart:io';
import 'dart:math';
-import 'package:collection/collection.dart'
- show IterableExtension, IterableNullableExtension;
+import 'package:collection/collection.dart' show IterableExtension;
import 'package:path/path.dart' as path;
import '../command.dart';
@@ -40,7 +38,7 @@
/// Avoid showing spinning progress messages when not in a terminal, and
/// when we are outputting machine-readable json.
- bool get _shouldShowSpinner => stdout.hasTerminal && !argResults['json'];
+ bool get _shouldShowSpinner => terminalOutputForStdout && !argResults['json'];
@override
bool get takesArguments => false;
@@ -58,8 +56,11 @@
help: 'Take dev dependencies into account.',
);
- argParser.addFlag('json',
- help: 'Output the results using a json format.', negatable: false);
+ argParser.addFlag(
+ 'json',
+ help: 'Output the results using a json format.',
+ negatable: false,
+ );
argParser.addOption(
'mode',
@@ -69,12 +70,12 @@
valueHelp: 'PROPERTY',
allowed: ['outdated', 'null-safety'],
defaultsTo: 'outdated',
+ hide: true,
);
argParser.addFlag(
'prereleases',
- help: 'Include prereleases in latest version.\n'
- '(defaults to on in --mode=null-safety).',
+ help: 'Include prereleases in latest version.',
);
// Preserve for backwards compatibility.
@@ -98,20 +99,23 @@
);
argParser.addFlag(
'transitive',
- help: 'Show transitive dependencies.\n'
- '(defaults to off in --mode=null-safety).',
+ help: 'Show transitive dependencies.',
);
- argParser.addOption('directory',
- abbr: 'C', help: 'Run this in the directory<dir>.', valueHelp: 'dir');
+ argParser.addOption(
+ 'directory',
+ abbr: 'C',
+ help: 'Run this in the directory<dir>.',
+ valueHelp: 'dir',
+ );
}
@override
Future<void> runProtected() async {
- final mode = <String, _Mode>{
- 'outdated': _OutdatedMode(),
- 'null-safety': _NullSafetyMode(cache, entrypoint,
- shouldShowSpinner: _shouldShowSpinner),
- }[argResults['mode']]!;
+ if (argResults['mode'] == 'null-safety') {
+ dataError('''The `--mode=null-safety` option is no longer supported.
+Consider using the Dart 2.19 sdk to migrate to null safety.''');
+ }
+ final mode = _OutdatedMode();
final includeDevDependencies = argResults['dev-dependencies'];
final includeDependencyOverrides = argResults['dependency-overrides'];
@@ -135,17 +139,21 @@
late bool hasUpgradableResolution;
late bool hasResolvableResolution;
- await log.spinner('Resolving', () async {
- final upgradablePackagesResult =
- await _tryResolve(upgradablePubspec, cache);
- hasUpgradableResolution = upgradablePackagesResult != null;
- upgradablePackages = upgradablePackagesResult ?? [];
+ await log.spinner(
+ 'Resolving',
+ () async {
+ final upgradablePackagesResult =
+ await _tryResolve(upgradablePubspec, cache);
+ hasUpgradableResolution = upgradablePackagesResult != null;
+ upgradablePackages = upgradablePackagesResult ?? [];
- final resolvablePackagesResult =
- await _tryResolve(resolvablePubspec, cache);
- hasResolvableResolution = resolvablePackagesResult != null;
- resolvablePackages = resolvablePackagesResult ?? [];
- }, condition: _shouldShowSpinner);
+ final resolvablePackagesResult =
+ await _tryResolve(resolvablePubspec, cache);
+ hasResolvableResolution = resolvablePackagesResult != null;
+ resolvablePackages = resolvablePackagesResult ?? [];
+ },
+ condition: _shouldShowSpinner,
+ );
// This list will be empty if there is no lock file.
final currentPackages = entrypoint.lockFile.packages.values;
@@ -173,24 +181,36 @@
PackageId? latest;
// If not overridden in current resolution we can use this
if (!entrypoint.root.pubspec.dependencyOverrides.containsKey(name)) {
- latest ??= await cache.getLatest(current?.toRef(),
- version: current?.version, allowPrereleases: prereleases);
+ latest ??= await cache.getLatest(
+ current?.toRef(),
+ version: current?.version,
+ allowPrereleases: prereleases,
+ );
}
// If present as a dependency or dev_dependency we use this
- latest ??= await cache.getLatest(rootPubspec.dependencies[name]?.toRef(),
- allowPrereleases: prereleases);
latest ??= await cache.getLatest(
- rootPubspec.devDependencies[name]?.toRef(),
- allowPrereleases: prereleases);
+ rootPubspec.dependencies[name]?.toRef(),
+ allowPrereleases: prereleases,
+ );
+ latest ??= await cache.getLatest(
+ rootPubspec.devDependencies[name]?.toRef(),
+ allowPrereleases: prereleases,
+ );
// If not overridden and present in either upgradable or resolvable we
// use this reference to find the latest
if (!upgradablePubspec.dependencyOverrides.containsKey(name)) {
- latest ??= await cache.getLatest(upgradable?.toRef(),
- version: upgradable?.version, allowPrereleases: prereleases);
+ latest ??= await cache.getLatest(
+ upgradable?.toRef(),
+ version: upgradable?.version,
+ allowPrereleases: prereleases,
+ );
}
if (!resolvablePubspec.dependencyOverrides.containsKey(name)) {
- latest ??= await cache.getLatest(resolvable?.toRef(),
- version: resolvable?.version, allowPrereleases: prereleases);
+ latest ??= await cache.getLatest(
+ resolvable?.toRef(),
+ version: resolvable?.version,
+ allowPrereleases: prereleases,
+ );
}
// Otherwise, we might simply not have a latest, when a transitive
// dependency is overridden the source can depend on which versions we
@@ -199,8 +219,11 @@
// to fallback to using the overridden source for latest.
if (latest == null) {
final id = current ?? upgradable ?? resolvable;
- latest ??= await cache.getLatest(id?.toRef(),
- version: id?.version, allowPrereleases: prereleases);
+ latest ??= await cache.getLatest(
+ id?.toRef(),
+ version: id?.version,
+ allowPrereleases: prereleases,
+ );
latestIsOverridden = true;
}
@@ -267,32 +290,31 @@
includeDevDependencies: includeDevDependencies,
);
} else {
- await _outputHuman(rows, mode,
- useColors: canUseAnsiCodes,
- showAll: showAll,
- includeDevDependencies: includeDevDependencies,
- lockFileExists: fileExists(entrypoint.lockFilePath),
- hasDirectDependencies: rootPubspec.dependencies.values.any(
- // Test if it contains non-SDK dependencies
- (c) => c.source is! SdkSource,
- ),
- hasDevDependencies: rootPubspec.devDependencies.values.any(
- // Test if it contains non-SDK dependencies
- (c) => c.source is! SdkSource,
- ),
- showTransitiveDependencies: showTransitiveDependencies,
- hasUpgradableResolution: hasUpgradableResolution,
- hasResolvableResolution: hasResolvableResolution,
- directory: path.normalize(directory));
+ await _outputHuman(
+ rows,
+ mode,
+ useColors: canUseAnsiCodes,
+ showAll: showAll,
+ includeDevDependencies: includeDevDependencies,
+ lockFileExists: fileExists(entrypoint.lockFilePath),
+ hasDirectDependencies: rootPubspec.dependencies.values.any(
+ // Test if it contains non-SDK dependencies
+ (c) => c.source is! SdkSource,
+ ),
+ hasDevDependencies: rootPubspec.devDependencies.values.any(
+ // Test if it contains non-SDK dependencies
+ (c) => c.source is! SdkSource,
+ ),
+ showTransitiveDependencies: showTransitiveDependencies,
+ hasUpgradableResolution: hasUpgradableResolution,
+ hasResolvableResolution: hasResolvableResolution,
+ directory: path.normalize(directory),
+ );
}
}
bool get showTransitiveDependencies {
- if (argResults.wasParsed('transitive')) {
- return argResults['transitive'];
- }
- // We default to hidding transitive dependencies in --mode=null-safety
- return argResults['mode'] != 'null-safety';
+ return argResults['transitive'];
}
late final bool prereleases = () {
@@ -306,7 +328,7 @@
if (argResults.wasParsed('pre-releases')) {
return argResults['pre-releases'];
}
- return argResults['mode'] == 'null-safety';
+ return false;
}();
/// Retrieves the pubspec of package [name] in [version] from [source].
@@ -392,19 +414,30 @@
element.kind == _DependencyKind.devTransitive,
);
}
+
+ String kindString(_DependencyKind kind) {
+ return {
+ _DependencyKind.direct: 'direct',
+ _DependencyKind.dev: 'dev',
+ }[kind] ??
+ 'transitive';
+ }
+
log.message(
JsonEncoder.withIndent(' ').convert(
{
'packages': [
- ...(rows..sort((a, b) => a.name.compareTo(b.name)))
- .map((packageDetails) => {
- 'package': packageDetails.name,
- 'isDiscontinued': packageDetails.isDiscontinued,
- 'current': markedRows[packageDetails]![0].toJson(),
- 'upgradable': markedRows[packageDetails]![1].toJson(),
- 'resolvable': markedRows[packageDetails]![2].toJson(),
- 'latest': markedRows[packageDetails]![3].toJson(),
- })
+ ...(rows..sort((a, b) => a.name.compareTo(b.name))).map(
+ (packageDetails) => {
+ 'package': packageDetails.name,
+ 'kind': kindString(packageDetails.kind),
+ 'isDiscontinued': packageDetails.isDiscontinued,
+ 'current': markedRows[packageDetails]![0].toJson(),
+ 'upgradable': markedRows[packageDetails]![1].toJson(),
+ 'resolvable': markedRows[packageDetails]![2].toJson(),
+ 'latest': markedRows[packageDetails]![3].toJson(),
+ },
+ )
]
},
),
@@ -493,8 +526,9 @@
for (var j = 0; j < formattedRows[i].length; j++) {
final currentMaxWidth = columnWidths[j] ?? 0;
columnWidths[j] = max(
- formattedRows[i][j].computeLength(useColors: useColors),
- currentMaxWidth);
+ formattedRows[i][j].computeLength(useColors: useColors),
+ currentMaxWidth,
+ );
}
}
}
@@ -503,33 +537,39 @@
final b = StringBuffer();
for (var j = 0; j < row.length; j++) {
b.write(row[j].formatted(useColors: useColors));
- b.write(' ' *
- ((columnWidths[j]! + 2) -
- row[j].computeLength(useColors: useColors)));
+ b.write(
+ ' ' *
+ ((columnWidths[j]! + 2) -
+ row[j].computeLength(useColors: useColors)),
+ );
}
log.message(b.toString());
}
var upgradable = rows
- .where((row) =>
- row.current != null &&
- row.upgradable != null &&
- row.current != row.upgradable &&
- // Include transitive only, if we show them
- (showTransitiveDependencies ||
- hasKind(_DependencyKind.direct)(row) ||
- hasKind(_DependencyKind.dev)(row)))
+ .where(
+ (row) =>
+ row.current != null &&
+ row.upgradable != null &&
+ row.current != row.upgradable &&
+ // Include transitive only, if we show them
+ (showTransitiveDependencies ||
+ hasKind(_DependencyKind.direct)(row) ||
+ hasKind(_DependencyKind.dev)(row)),
+ )
.length;
var notAtResolvable = rows
- .where((row) =>
- (row.current != null || !lockFileExists) &&
- row.resolvable != null &&
- row.upgradable != row.resolvable &&
- // Include transitive only, if we show them
- (showTransitiveDependencies ||
- hasKind(_DependencyKind.direct)(row) ||
- hasKind(_DependencyKind.dev)(row)))
+ .where(
+ (row) =>
+ (row.current != null || !lockFileExists) &&
+ row.resolvable != null &&
+ row.upgradable != row.resolvable &&
+ // Include transitive only, if we show them
+ (showTransitiveDependencies ||
+ hasKind(_DependencyKind.direct)(row) ||
+ hasKind(_DependencyKind.dev)(row)),
+ )
.length;
if (!hasUpgradableResolution || !hasResolvableResolution) {
@@ -582,7 +622,8 @@
? ', replaced by ${package.discontinuedReplacedBy}.'
: '.';
log.message(
- ' Package ${package.name} has been discontinued$replacedByText');
+ ' Package ${package.name} has been discontinued$replacedByText',
+ );
}
}
}
@@ -592,7 +633,8 @@
/// corresponding list of the versions
/// [current, upgradable, resolvable, latest].
Future<List<List<_MarkedVersionDetails>>> markVersionDetails(
- List<_PackageDetails> packageDetails);
+ List<_PackageDetails> packageDetails,
+ );
String explanation(String directoryDescription);
String get foundNoBadText;
@@ -630,7 +672,8 @@
@override
Future<List<List<_MarkedVersionDetails>>> markVersionDetails(
- List<_PackageDetails> packages) async {
+ List<_PackageDetails> packages,
+ ) async {
final rows = <List<_MarkedVersionDetails>>[];
for (final packageDetails in packages) {
final cols = <_MarkedVersionDetails>[];
@@ -681,115 +724,6 @@
}
}
-class _NullSafetyMode implements _Mode {
- final SystemCache cache;
- final Entrypoint entrypoint;
- final bool shouldShowSpinner;
-
- final _compliantEmoji = emoji('✓', '+');
- final _notCompliantEmoji = emoji('✗', 'x');
-
- _NullSafetyMode(this.cache, this.entrypoint,
- {required this.shouldShowSpinner});
-
- @override
- String explanation(String directoryDescription) => '''
-Showing dependencies$directoryDescription that are currently not opted in to null-safety.
-[${log.red(_notCompliantEmoji)}] indicates versions without null safety support.
-[${log.green(_compliantEmoji)}] indicates versions opting in to null safety.
-''';
-
- @override
- String get foundNoBadText =>
- 'All your dependencies declare support for null-safety.';
-
- @override
- String get allGood => 'all support null safety.';
-
- @override
- String get noResolutionText =>
- '''No resolution was found. Try running `$topLevelProgram pub upgrade --null-safety --dry-run` to explore why.''';
-
- @override
- String get upgradeConstrained =>
- 'edit pubspec.yaml, or run `$topLevelProgram pub upgrade --null-safety`';
-
- @override
- String get allSafe => 'All dependencies opt in to null-safety.';
-
- @override
- Future<List<List<_MarkedVersionDetails>>> markVersionDetails(
- List<_PackageDetails> packages) async {
- final nullSafetyMap =
- await log.spinner('Computing null safety support', () async {
- /// Find all unique ids.
- final ids = {
- for (final packageDetails in packages) ...[
- packageDetails.current?._id,
- packageDetails.upgradable?._id,
- packageDetails.resolvable?._id,
- packageDetails.latest?._id,
- ]
- }.whereNotNull();
-
- return Map.fromEntries(
- await Future.wait(
- ids.map(
- (id) async => MapEntry(id,
- (await cache.describe(id)).languageVersion.supportsNullSafety),
- ),
- ),
- );
- }, condition: shouldShowSpinner);
- return [
- for (final packageDetails in packages)
- [
- packageDetails.current,
- packageDetails.upgradable,
- packageDetails.resolvable,
- packageDetails.latest
- ].map(
- (versionDetails) {
- String Function(String)? color;
- String? prefix;
- String? suffix;
- MapEntry<String, Object>? jsonExplanation;
- var asDesired = false;
- if (versionDetails != null) {
- if (packageDetails.isDiscontinued &&
- identical(versionDetails, packageDetails.latest)) {
- suffix = ' (discontinued)';
- }
- if (nullSafetyMap[versionDetails._id]!) {
- color = log.green;
- prefix = _compliantEmoji;
- jsonExplanation = MapEntry('nullSafety', true);
- asDesired = true;
- } else {
- color = log.red;
- prefix = _notCompliantEmoji;
- jsonExplanation = MapEntry('nullSafety', false);
- }
- }
- return _MarkedVersionDetails(
- versionDetails,
- asDesired: asDesired,
- format: color,
- prefix: prefix,
- suffix: suffix,
- jsonExplanation: jsonExplanation,
- );
- },
- ).toList()
- ];
- }
-
- @override
- Future<Pubspec> resolvablePubspec(Pubspec pubspec) async {
- return constrainedToAtLeastNullSafetyPubspec(pubspec, cache);
- }
-}
-
/// Details about a single version of a package.
class _VersionDetails {
final Pubspec _pubspec;
@@ -843,8 +777,16 @@
final bool isDiscontinued;
final String? discontinuedReplacedBy;
- _PackageDetails(this.name, this.current, this.upgradable, this.resolvable,
- this.latest, this.kind, this.isDiscontinued, this.discontinuedReplacedBy);
+ _PackageDetails(
+ this.name,
+ this.current,
+ this.upgradable,
+ this.resolvable,
+ this.latest,
+ this.kind,
+ this.isDiscontinued,
+ this.discontinuedReplacedBy,
+ );
@override
int compareTo(_PackageDetails other) {
@@ -868,7 +810,10 @@
}
_DependencyKind _kind(
- String name, Entrypoint entrypoint, Set<String> nonDevTransitive) {
+ String name,
+ Entrypoint entrypoint,
+ Set<String> nonDevTransitive,
+) {
if (entrypoint.root.dependencies.containsKey(name)) {
return _DependencyKind.direct;
} else if (entrypoint.root.devDependencies.containsKey(name)) {
@@ -896,8 +841,11 @@
devTransitive,
}
-_FormattedString _format(String value, String Function(String) format,
- {prefix = ''}) {
+_FormattedString _format(
+ String value,
+ String Function(String) format, {
+ prefix = '',
+}) {
return _FormattedString(value, format: format, prefix: prefix);
}
@@ -955,9 +903,12 @@
final String _suffix;
- _FormattedString(this.value,
- {String Function(String)? format, prefix, suffix})
- : _format = format ?? _noFormat,
+ _FormattedString(
+ this.value, {
+ String Function(String)? format,
+ prefix,
+ suffix,
+ }) : _format = format ?? _noFormat,
_prefix = prefix ?? '',
_suffix = suffix ?? '';
diff --git a/lib/src/command/remove.dart b/lib/src/command/remove.dart
index 7e7b17d..e277dec 100644
--- a/lib/src/command/remove.dart
+++ b/lib/src/command/remove.dart
@@ -31,16 +31,22 @@
bool get isDryRun => argResults['dry-run'];
RemoveCommand() {
- argParser.addFlag('offline',
- help: 'Use cached packages instead of accessing the network.');
+ argParser.addFlag(
+ 'offline',
+ help: 'Use cached packages instead of accessing the network.',
+ );
- argParser.addFlag('dry-run',
- abbr: 'n',
- negatable: false,
- help: "Report what dependencies would change but don't change any.");
+ argParser.addFlag(
+ 'dry-run',
+ abbr: 'n',
+ negatable: false,
+ help: "Report what dependencies would change but don't change any.",
+ );
- argParser.addFlag('precompile',
- help: 'Precompile executables in immediate dependencies.');
+ argParser.addFlag(
+ 'precompile',
+ help: 'Precompile executables in immediate dependencies.',
+ );
argParser.addFlag(
'example',
@@ -48,8 +54,12 @@
hide: true,
);
- argParser.addOption('directory',
- abbr: 'C', help: 'Run this in the directory<dir>.', valueHelp: 'dir');
+ argParser.addOption(
+ 'directory',
+ abbr: 'C',
+ help: 'Run this in the directory<dir>.',
+ valueHelp: 'dir',
+ );
}
@override
@@ -90,7 +100,7 @@
await example.acquireDependencies(
SolveType.get,
precompile: argResults['precompile'],
- onlyReportSuccessOrFailure: true,
+ summaryOnly: true,
analytics: analytics,
);
}
diff --git a/lib/src/command/run.dart b/lib/src/command/run.dart
index e223c5a..7d48a67 100644
--- a/lib/src/command/run.dart
+++ b/lib/src/command/run.dart
@@ -35,28 +35,39 @@
}) {
argParser.addFlag('enable-asserts', help: 'Enable assert statements.');
argParser.addFlag('checked', abbr: 'c', hide: true);
- argParser.addMultiOption('enable-experiment',
- help:
- 'Runs the executable in a VM with the given experiments enabled.\n'
- '(Will disable snapshotting, resulting in slower startup).',
- valueHelp: 'experiment');
- argParser.addFlag('sound-null-safety',
- help: 'Override the default null safety execution mode.');
+ argParser.addMultiOption(
+ 'enable-experiment',
+ help: 'Runs the executable in a VM with the given experiments enabled.\n'
+ '(Will disable snapshotting, resulting in slower startup).',
+ valueHelp: 'experiment',
+ );
+ argParser.addFlag(
+ 'sound-null-safety',
+ help: 'Override the default null safety execution mode.',
+ hide: true,
+ );
argParser.addOption('mode', help: 'Deprecated option', hide: true);
- argParser.addOption('directory',
- abbr: 'C', help: 'Run this in the directory<dir>.', valueHelp: 'dir');
+ argParser.addOption(
+ 'directory',
+ abbr: 'C',
+ help: 'Run this in the directory<dir>.',
+ valueHelp: 'dir',
+ );
}
@override
Future<void> runProtected() async {
if (deprecated) {
- await log.warningsOnlyUnlessTerminal(() {
+ await log.errorsOnlyUnlessTerminal(() {
log.message('Deprecated. Use `dart run` instead.');
});
}
if (argResults.rest.isEmpty) {
usageException('Must specify an executable to run.');
}
+ if (argResults.wasParsed('sound-null-safety')) {
+ dataError('The --(no-)sound-null-safety flag is no longer supported.');
+ }
var package = entrypoint.root.name;
var executable = argResults.rest[0];
@@ -71,7 +82,8 @@
if (p.split(executable).length > 1) {
usageException(
- 'Cannot run an executable in a subdirectory of a dependency.');
+ 'Cannot run an executable in a subdirectory of a dependency.',
+ );
}
} else if (onlyIdentifierRegExp.hasMatch(executable)) {
// "pub run foo" means the same thing as "pub run foo:foo" as long as
@@ -90,8 +102,9 @@
Executable.adaptProgramName(package, executable),
args,
enableAsserts: argResults['enable-asserts'] || argResults['checked'],
- recompile: (executable) => log.warningsOnlyUnlessTerminal(
- () => entrypoint.precompileExecutable(executable)),
+ recompile: (executable) => log.errorsOnlyUnlessTerminal(
+ () => entrypoint.precompileExecutable(executable),
+ ),
vmArgs: vmArgs,
alwaysUseSubprocess: alwaysUseSubprocess,
);
diff --git a/lib/src/command/token_add.dart b/lib/src/command/token_add.dart
index caf3b8b..be9d406 100644
--- a/lib/src/command/token_add.dart
+++ b/lib/src/command/token_add.dart
@@ -27,16 +27,19 @@
String? get envVar => argResults['env-var'];
TokenAddCommand() {
- argParser.addOption('env-var',
- help: 'Read the secret token from this environment variable when '
- 'making requests.');
+ argParser.addOption(
+ 'env-var',
+ help: 'Read the secret token from this environment variable when '
+ 'making requests.',
+ );
}
@override
Future<void> runProtected() async {
if (argResults.rest.isEmpty) {
usageException(
- 'The [hosted-url] for a package repository must be given.');
+ 'The [hosted-url] for a package repository must be given.',
+ );
} else if (argResults.rest.length > 1) {
usageException('Takes only a single argument.');
}
diff --git a/lib/src/command/token_remove.dart b/lib/src/command/token_remove.dart
index 1b08127..1af2e18 100644
--- a/lib/src/command/token_remove.dart
+++ b/lib/src/command/token_remove.dart
@@ -39,7 +39,8 @@
if (argResults.rest.isEmpty) {
usageException(
- 'The [hosted-url] for a package repository must be specified.');
+ 'The [hosted-url] for a package repository must be specified.',
+ );
} else if (argResults.rest.length > 1) {
usageException('Takes only a single argument.');
}
@@ -52,7 +53,8 @@
log.message('Removed secret token for package repository: $hostedUrl');
} else {
throw DataException(
- 'No secret token for package repository "$hostedUrl" was found.');
+ 'No secret token for package repository "$hostedUrl" was found.',
+ );
}
} on FormatException catch (e) {
usageException('Invalid [hosted-url]: "${argResults.rest.first}"\n'
diff --git a/lib/src/command/upgrade.dart b/lib/src/command/upgrade.dart
index a83d129..2d21e33 100644
--- a/lib/src/command/upgrade.dart
+++ b/lib/src/command/upgrade.dart
@@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'dart:async';
-import 'dart:io';
import 'package:pub_semver/pub_semver.dart';
import 'package:yaml_edit/yaml_edit.dart';
@@ -11,16 +10,15 @@
import '../command.dart';
import '../command_runner.dart';
import '../entrypoint.dart';
-import '../exceptions.dart';
import '../io.dart';
import '../log.dart' as log;
-import '../null_safety_analysis.dart';
import '../package.dart';
import '../package_name.dart';
import '../pubspec.dart';
import '../pubspec_utils.dart';
import '../solver.dart';
import '../source/hosted.dart';
+import '../utils.dart';
/// Handles the `upgrade` pub command.
class UpgradeCommand extends PubCommand {
@@ -38,20 +36,29 @@
bool get isOffline => argResults['offline'];
UpgradeCommand() {
- argParser.addFlag('offline',
- help: 'Use cached packages instead of accessing the network.');
+ argParser.addFlag(
+ 'offline',
+ help: 'Use cached packages instead of accessing the network.',
+ );
- argParser.addFlag('dry-run',
- abbr: 'n',
- negatable: false,
- help: "Report what dependencies would change but don't change any.");
+ argParser.addFlag(
+ 'dry-run',
+ abbr: 'n',
+ negatable: false,
+ help: "Report what dependencies would change but don't change any.",
+ );
- argParser.addFlag('precompile',
- help: 'Precompile executables in immediate dependencies.');
+ argParser.addFlag(
+ 'precompile',
+ help: 'Precompile executables in immediate dependencies.',
+ );
- argParser.addFlag('null-safety',
- negatable: false,
- help: 'Upgrade constraints in pubspec.yaml to null-safety versions');
+ argParser.addFlag(
+ 'null-safety',
+ hide: true,
+ negatable: false,
+ help: 'Upgrade constraints in pubspec.yaml to null-safety versions',
+ );
argParser.addFlag('nullsafety', negatable: false, hide: true);
argParser.addFlag('packages-dir', hide: true);
@@ -69,12 +76,16 @@
hide: true,
);
- argParser.addOption('directory',
- abbr: 'C', help: 'Run this in the directory<dir>.', valueHelp: 'dir');
+ argParser.addOption(
+ 'directory',
+ abbr: 'C',
+ help: 'Run this in the directory<dir>.',
+ valueHelp: 'dir',
+ );
}
/// Avoid showing spinning progress messages when not in a terminal.
- bool get _shouldShowSpinner => stdout.hasTerminal;
+ bool get _shouldShowSpinner => terminalOutputForStdout;
bool get _dryRun => argResults['dry-run'];
@@ -87,25 +98,23 @@
@override
Future<void> runProtected() async {
- if (argResults.wasParsed('packages-dir')) {
- log.warning(log.yellow(
- 'The --packages-dir flag is no longer used and does nothing.'));
- }
-
- if (_upgradeNullSafety && _upgradeMajorVersions) {
- usageException('--major-versions and --null-safety cannot be combined');
- }
-
if (_upgradeNullSafety) {
+ dataError('''The `--null-safety` flag is no longer supported.
+Consider using the Dart 2.19 sdk to migrate to null safety.''');
+ }
+ if (argResults.wasParsed('packages-dir')) {
+ log.warning(
+ log.yellow(
+ 'The --packages-dir flag is no longer used and does nothing.',
+ ),
+ );
+ }
+
+ if (_upgradeMajorVersions) {
if (argResults['example'] && entrypoint.example != null) {
log.warning(
- 'Running `upgrade --null-safety` only in `${entrypoint.root.dir}`. Run `$topLevelProgram pub upgrade --null-safety --directory example/` separately.');
- }
- await _runUpgradeNullSafety();
- } else if (_upgradeMajorVersions) {
- if (argResults['example'] && entrypoint.example != null) {
- log.warning(
- 'Running `upgrade --major-versions` only in `${entrypoint.root.dir}`. Run `$topLevelProgram pub upgrade --major-versions --directory example/` separately.');
+ 'Running `upgrade --major-versions` only in `${entrypoint.root.dir}`. Run `$topLevelProgram pub upgrade --major-versions --directory example/` separately.',
+ );
}
await _runUpgradeMajorVersions();
} else {
@@ -125,7 +134,7 @@
unlock: argResults.rest,
dryRun: _dryRun,
precompile: _precompile,
- onlyReportSuccessOrFailure: onlySummary,
+ summaryOnly: onlySummary,
analytics: analytics,
);
_showOfflineWarning();
@@ -136,7 +145,7 @@
///
/// This assumes that either `--major-versions` or `--null-safety` was passed.
List<String> _directDependenciesToUpgrade() {
- assert(_upgradeNullSafety || _upgradeMajorVersions);
+ assert(_upgradeMajorVersions);
final directDeps = [
...entrypoint.root.pubspec.dependencies.keys,
@@ -148,9 +157,6 @@
final notInDeps = toUpgrade.where((n) => !directDeps.contains(n));
if (toUpgrade.any(notInDeps.contains)) {
var modeFlag = '';
- if (_upgradeNullSafety) {
- modeFlag = '--null-safety';
- }
if (_upgradeMajorVersions) {
modeFlag = '--major-versions';
}
@@ -177,13 +183,17 @@
// Solve [resolvablePubspec] in-memory and consolidate the resolved
// versions of the packages into a map for quick searching.
final resolvedPackages = <String, PackageId>{};
- final solveResult = await log.spinner('Resolving dependencies', () async {
- return await resolveVersions(
- SolveType.upgrade,
- cache,
- Package.inMemory(resolvablePubspec),
- );
- }, condition: _shouldShowSpinner);
+ final solveResult = await log.spinner(
+ 'Resolving dependencies',
+ () async {
+ return await resolveVersions(
+ SolveType.upgrade,
+ cache,
+ Package.inMemory(resolvablePubspec),
+ );
+ },
+ condition: _shouldShowSpinner,
+ );
for (final resolvedPackage in solveResult.packages) {
resolvedPackages[resolvedPackage.name] = resolvedPackage;
}
@@ -276,124 +286,6 @@
_showOfflineWarning();
}
- Future<void> _runUpgradeNullSafety() async {
- final toUpgrade = _directDependenciesToUpgrade();
-
- final nullsafetyPubspec = await _upgradeToNullSafetyConstraints(
- entrypoint.root.pubspec,
- toUpgrade,
- );
-
- /// Solve [nullsafetyPubspec] in-memory and consolidate the resolved
- /// versions of the packages into a map for quick searching.
- final resolvedPackages = <String, PackageId>{};
- final solveResult = await log.spinner('Resolving dependencies', () async {
- return await resolveVersions(
- SolveType.upgrade,
- cache,
- Package.inMemory(nullsafetyPubspec),
- );
- }, condition: _shouldShowSpinner);
- for (final resolvedPackage in solveResult.packages) {
- resolvedPackages[resolvedPackage.name] = resolvedPackage;
- }
-
- /// Changes to be made to `pubspec.yaml`.
- /// Mapping from original to changed value.
- final changes = <PackageRange, PackageRange>{};
- final declaredHostedDependencies = [
- ...entrypoint.root.pubspec.dependencies.values,
- ...entrypoint.root.pubspec.devDependencies.values,
- ].where((dep) => dep.source is HostedSource);
- for (final dep in declaredHostedDependencies) {
- final resolvedPackage = resolvedPackages[dep.name]!;
- if (!toUpgrade.contains(dep.name)) {
- // If we're not to upgrade this package, or it wasn't in the
- // resolution somehow, then we ignore it.
- continue;
- }
-
- final constraint = VersionConstraint.compatibleWith(
- resolvedPackage.version,
- );
- if (dep.constraint.allowsAll(constraint) &&
- constraint.allowsAll(dep.constraint)) {
- // If constraint allows the same as the existing constraint then
- // there is no need to make changes.
- continue;
- }
-
- changes[dep] = dep.toRef().withConstraint(constraint);
- }
-
- final newPubspecText = _updatePubspec(changes);
- if (_dryRun) {
- // Even if it is a dry run, run `acquireDependencies` so that the user
- // gets a report on changes.
- // TODO(jonasfj): Stop abusing Entrypoint.global for dry-run output
- await Entrypoint.inMemory(
- Package.inMemory(Pubspec.parse(newPubspecText, cache.sources)),
- cache,
- lockFile: entrypoint.lockFile,
- solveResult: solveResult,
- ).acquireDependencies(
- SolveType.upgrade,
- dryRun: true,
- precompile: _precompile,
- analytics: null,
- );
- } else {
- if (changes.isNotEmpty) {
- writeTextFile(entrypoint.pubspecPath, newPubspecText);
- }
- // TODO: Allow Entrypoint to be created with in-memory pubspec, so that
- // we can show the changes in --dry-run mode. For now we only show
- // the changes made to pubspec.yaml in dry-run mode.
- await Entrypoint(directory, cache).acquireDependencies(
- SolveType.upgrade,
- precompile: _precompile,
- analytics: analytics,
- );
- }
-
- _outputChangeSummary(changes);
-
- // Warn if not all dependencies were migrated to a null-safety compatible
- // version. This can happen because:
- // - `upgradeOnly` was given,
- // - root has SDK dependencies,
- // - root has git or path dependencies,
- // - root has dependency_overrides
- final nonMigratedDirectDeps = <String>[];
- final directDeps = [
- ...entrypoint.root.pubspec.dependencies.keys,
- ...entrypoint.root.pubspec.devDependencies.keys
- ];
- await Future.wait(directDeps.map((name) async {
- final resolvedPackage = resolvedPackages[name]!;
-
- final pubspec = await cache.describe(resolvedPackage);
- if (!pubspec.languageVersion.supportsNullSafety) {
- nonMigratedDirectDeps.add(name);
- }
- }));
- if (nonMigratedDirectDeps.isNotEmpty) {
- log.warning('''
-\nFollowing direct 'dependencies' and 'dev_dependencies' are not migrated to
-null-safety yet:
- - ${nonMigratedDirectDeps.join('\n - ')}
-
-You may have to:
- * Upgrade git and path dependencies manually,
- * Upgrade to a newer SDK for newer SDK dependencies,
- * Remove dependency_overrides, and/or,
- * Find other packages to use.
-''');
- }
-
- _showOfflineWarning();
- }
-
/// Updates `pubspec.yaml` with given [changes].
String _updatePubspec(
Map<PackageRange, PackageRange> changes,
@@ -448,80 +340,4 @@
'latest versions of your dependencies.');
}
}
-
- /// Returns new pubspec with the same dependencies as [original], but with:
- /// * the lower-bound of hosted package constraint set to first null-safety
- /// compatible version, and,
- /// * the upper-bound of hosted package constraints removed.
- ///
- /// Only changes listed in [upgradeOnly] will have their constraints touched.
- ///
- /// Throws [ApplicationException] if one of the dependencies does not have
- /// a null-safety compatible version.
- Future<Pubspec> _upgradeToNullSafetyConstraints(
- Pubspec original,
- List<String> upgradeOnly,
- ) async {
- ArgumentError.checkNotNull(original, 'original');
- ArgumentError.checkNotNull(upgradeOnly, 'upgradeOnly');
-
- final hasNoNullSafetyVersions = <String>{};
- final hasNullSafetyVersions = <String>{};
-
- Future<Iterable<PackageRange>> removeUpperConstraints(
- Iterable<PackageRange> dependencies,
- ) async =>
- await Future.wait(dependencies.map((dep) async {
- if (dep.source is! HostedSource) {
- return dep;
- }
- if (!upgradeOnly.contains(dep.name)) {
- return dep;
- }
-
- final packages = await cache.getVersions(dep.toRef());
- packages.sort((a, b) => a.version.compareTo(b.version));
-
- for (final package in packages) {
- final pubspec = await cache.describe(package);
- if (pubspec.languageVersion.supportsNullSafety) {
- hasNullSafetyVersions.add(dep.name);
- return dep.toRef().withConstraint(
- VersionRange(min: package.version, includeMin: true),
- );
- }
- }
-
- hasNoNullSafetyVersions.add(dep.name);
- // This value is never used. We will throw an exception because
- //`hasNonNullSafetyVersions` is not empty.
- return dep.toRef().withConstraint(VersionConstraint.empty);
- }));
-
- final deps = removeUpperConstraints(original.dependencies.values);
- final devDeps = removeUpperConstraints(original.devDependencies.values);
- await Future.wait([deps, devDeps]);
-
- if (hasNoNullSafetyVersions.isNotEmpty) {
- throw ApplicationException('''
-null-safety compatible versions do not exist for:
- - ${hasNoNullSafetyVersions.join('\n - ')}
-
-You can choose to upgrade only some dependencies to null-safety using:
- $topLevelProgram pub upgrade --nullsafety ${hasNullSafetyVersions.join(' ')}
-
-Warning: Using null-safety features before upgrading all dependencies is
-discouraged. For more details see: ${NullSafetyAnalysis.guideUrl}
-''');
- }
-
- return Pubspec(
- original.name,
- version: original.version,
- sdkConstraints: original.sdkConstraints,
- dependencies: await deps,
- devDependencies: await devDeps,
- dependencyOverrides: original.dependencyOverrides.values,
- );
- }
}
diff --git a/lib/src/command/uploader.dart b/lib/src/command/uploader.dart
index 4b6406d..56bfc71 100644
--- a/lib/src/command/uploader.dart
+++ b/lib/src/command/uploader.dart
@@ -26,15 +26,23 @@
Uri get server => Uri.parse(argResults['server']);
UploaderCommand() {
- argParser.addOption('server',
- defaultsTo: Platform.environment['PUB_HOSTED_URL'] ?? 'https://pub.dev',
- help: 'The package server on which the package is hosted.\n',
- hide: true);
- argParser.addOption('package',
- help: 'The package whose uploaders will be modified.\n'
- '(defaults to the current package)');
- argParser.addOption('directory',
- abbr: 'C', help: 'Run this in the directory<dir>.', valueHelp: 'dir');
+ argParser.addOption(
+ 'server',
+ defaultsTo: Platform.environment['PUB_HOSTED_URL'] ?? 'https://pub.dev',
+ help: 'The package server on which the package is hosted.\n',
+ hide: true,
+ );
+ argParser.addOption(
+ 'package',
+ help: 'The package whose uploaders will be modified.\n'
+ '(defaults to the current package)',
+ );
+ argParser.addOption(
+ 'directory',
+ abbr: 'C',
+ help: 'Run this in the directory<dir>.',
+ valueHelp: 'dir',
+ );
}
@override
diff --git a/lib/src/command_runner.dart b/lib/src/command_runner.dart
index 150de16..e45e057 100644
--- a/lib/src/command_runner.dart
+++ b/lib/src/command_runner.dart
@@ -88,7 +88,8 @@
final a = _argResults;
if (a == null) {
throw StateError(
- 'argResults cannot be used before Command.run is called.');
+ 'argResults cannot be used before Command.run is called.',
+ );
}
return a;
}
@@ -98,29 +99,35 @@
'See https://dart.dev/tools/pub/cmd for detailed documentation.';
PubCommandRunner()
- : super('pub', 'Pub is a package manager for Dart.',
- usageLineLength: lineLength) {
+ : super(
+ 'pub',
+ 'Pub is a package manager for Dart.',
+ usageLineLength: lineLength,
+ ) {
argParser.addFlag('version', negatable: false, help: 'Print pub version.');
- argParser.addFlag('trace',
- help: 'Print debugging information when an error occurs.');
- argParser
- .addOption('verbosity', help: 'Control output verbosity.', allowed: [
- 'error',
- 'warning',
- 'normal',
- 'io',
- 'solver',
- 'all'
- ], allowedHelp: {
- 'error': 'Show only errors.',
- 'warning': 'Show only errors and warnings.',
- 'normal': 'Show errors, warnings, and user messages.',
- 'io': 'Also show IO operations.',
- 'solver': 'Show steps during version resolution.',
- 'all': 'Show all output including internal tracing messages.'
- });
- argParser.addFlag('verbose',
- abbr: 'v', negatable: false, help: 'Shortcut for "--verbosity=all".');
+ argParser.addFlag(
+ 'trace',
+ help: 'Print debugging information when an error occurs.',
+ );
+ argParser.addOption(
+ 'verbosity',
+ help: 'Control output verbosity.',
+ allowed: ['error', 'warning', 'normal', 'io', 'solver', 'all'],
+ allowedHelp: {
+ 'error': 'Show only errors.',
+ 'warning': 'Show only errors and warnings.',
+ 'normal': 'Show errors, warnings, and user messages.',
+ 'io': 'Also show IO operations.',
+ 'solver': 'Show steps during version resolution.',
+ 'all': 'Show all output including internal tracing messages.'
+ },
+ );
+ argParser.addFlag(
+ 'verbose',
+ abbr: 'v',
+ negatable: false,
+ help: 'Shortcut for "--verbosity=all".',
+ );
PubTopLevel.addColorFlag(argParser);
argParser.addOption(
'directory',
diff --git a/lib/src/dart.dart b/lib/src/dart.dart
index d846916..b149c83 100644
--- a/lib/src/dart.dart
+++ b/lib/src/dart.dart
@@ -26,7 +26,9 @@
final AnalysisSession _session;
factory AnalysisContextManager(String packagePath) => sessions.putIfAbsent(
- packagePath, () => AnalysisContextManager._(packagePath));
+ packagePath,
+ () => AnalysisContextManager._(packagePath),
+ );
AnalysisContextManager._(this.packagePath)
: _session = ContextBuilder()
@@ -166,8 +168,9 @@
tryDeleteEntry(outputPath);
throw ApplicationException(
- log.yellow('Failed to build $highlightedName:\n') +
- result.compilerOutputLines.join('\n'));
+ log.yellow('Failed to build $highlightedName:\n') +
+ result.compilerOutputLines.join('\n'),
+ );
}
} finally {
client?.kill();
diff --git a/lib/src/entrypoint.dart b/lib/src/entrypoint.dart
index bc9e4f9..2416edc 100644
--- a/lib/src/entrypoint.dart
+++ b/lib/src/entrypoint.dart
@@ -127,7 +127,8 @@
packageConfigRaw = readTextFile(packageConfigPath);
} on FileException {
dataError(
- 'The "$packageConfigPath" file does not exist, please run "$topLevelProgram pub get".');
+ 'The "$packageConfigPath" file does not exist, please run "$topLevelProgram pub get".',
+ );
}
late PackageConfig result;
try {
@@ -185,7 +186,8 @@
/// The path to the entrypoint's ".dart_tool/package_config.json" file
/// relative to the current working directory .
late String packageConfigPath = p.relative(
- p.normalize(p.join(_configRoot!, '.dart_tool', 'package_config.json')));
+ p.normalize(p.join(_configRoot!, '.dart_tool', 'package_config.json')),
+ );
/// The path to the entrypoint package's pubspec.
String get pubspecPath => p.normalize(root.path('pubspec.yaml'));
@@ -232,17 +234,24 @@
String rootDir,
this.cache, {
bool withPubspecOverrides = true,
- }) : root = Package.load(null, rootDir, cache.sources,
- withPubspecOverrides: withPubspecOverrides),
+ }) : root = Package.load(
+ null,
+ rootDir,
+ cache.sources,
+ withPubspecOverrides: withPubspecOverrides,
+ ),
globalDir = null {
if (p.isWithin(cache.rootDir, rootDir)) {
fail('Cannot operate on packages inside the cache.');
}
}
- Entrypoint.inMemory(this.root, this.cache,
- {required LockFile? lockFile, SolveResult? solveResult})
- : _lockFile = lockFile,
+ Entrypoint.inMemory(
+ this.root,
+ this.cache, {
+ required LockFile? lockFile,
+ SolveResult? solveResult,
+ }) : _lockFile = lockFile,
globalDir = null {
if (solveResult != null) {
_packageGraph = PackageGraph.fromSolveResult(this, solveResult);
@@ -251,8 +260,13 @@
/// Creates an entrypoint given package and lockfile objects.
/// If a SolveResult is already created it can be passed as an optimization.
- Entrypoint.global(this.globalDir, this.root, this._lockFile, this.cache,
- {SolveResult? solveResult}) {
+ Entrypoint.global(
+ this.globalDir,
+ this.root,
+ this._lockFile,
+ this.cache, {
+ SolveResult? solveResult,
+ }) {
if (solveResult != null) {
_packageGraph = PackageGraph.fromSolveResult(this, solveResult);
}
@@ -305,7 +319,7 @@
/// If [precompile] is `true` (the default), this snapshots dependencies'
/// executables.
///
- /// if [onlyReportSuccessOrFailure] is `true` only success or failure will be
+ /// if [summaryOnly] is `true` only success or failure will be
/// shown --- in case of failure, a reproduction command is shown.
///
/// Updates [lockFile] and [packageRoot] accordingly.
@@ -319,13 +333,14 @@
bool dryRun = false,
bool precompile = false,
required PubAnalytics? analytics,
- bool onlyReportSuccessOrFailure = false,
+ bool summaryOnly = false,
bool enforceLockfile = false,
}) async {
+ summaryOnly = summaryOnly || _summaryOnlyEnvironment;
final suffix = root.isInMemory || root.dir == '.' ? '' : ' in ${root.dir}';
String forDetails() {
- if (!onlyReportSuccessOrFailure) return '';
+ if (!summaryOnly) return '';
final enforceLockfileOption =
enforceLockfile ? ' --enforce-lockfile' : '';
final directoryOption =
@@ -341,11 +356,6 @@
Try running `$topLevelProgram pub get` to create `$lockFilePath`.''');
}
- if (!onlyReportSuccessOrFailure && hasPubspecOverrides) {
- log.warning(
- 'Warning: pubspec.yaml has overrides from $pubspecOverridesPath');
- }
-
SolveResult result;
try {
result = await log.progress('Resolving dependencies$suffix', () async {
@@ -359,9 +369,10 @@
);
});
} catch (e) {
- if (onlyReportSuccessOrFailure && (e is ApplicationException)) {
+ if (summaryOnly && (e is ApplicationException)) {
throw ApplicationException(
- 'Resolving dependencies$suffix failed.${forDetails()}');
+ 'Resolving dependencies$suffix failed.${forDetails()}',
+ );
} else {
rethrow;
}
@@ -380,13 +391,13 @@
cache,
dryRun: dryRun,
enforceLockfile: enforceLockfile,
- quiet: onlyReportSuccessOrFailure,
+ quiet: summaryOnly,
);
final hasChanges = await report.show();
await report.summarize();
if (enforceLockfile && hasChanges) {
- var suggestion = onlyReportSuccessOrFailure
+ var suggestion = summaryOnly
? ''
: '''
\n\nTo update `$lockFilePath` run `$topLevelProgram pub get`$suffix without
@@ -470,11 +481,13 @@
// Don't do more than `Platform.numberOfProcessors - 1` compilations
// concurrently. Though at least one.
final pool = Pool(max(Platform.numberOfProcessors - 1, 1));
- return waitAndPrintErrors(executables.map((executable) async {
- await pool.withResource(() async {
- return _precompileExecutable(executable);
- });
- }));
+ return waitAndPrintErrors(
+ executables.map((executable) async {
+ await pool.withResource(() async {
+ return _precompileExecutable(executable);
+ });
+ }),
+ );
});
}
@@ -532,19 +545,29 @@
assert(p.isRelative(executable.relativePath));
final versionSuffix = sdk.version;
return isGlobal
- ? p.join(_snapshotPath,
- '${p.basename(executable.relativePath)}-$versionSuffix.snapshot')
- : p.join(_snapshotPath, executable.package,
- '${p.basename(executable.relativePath)}-$versionSuffix.snapshot');
+ ? p.join(
+ _snapshotPath,
+ '${p.basename(executable.relativePath)}-$versionSuffix.snapshot',
+ )
+ : p.join(
+ _snapshotPath,
+ executable.package,
+ '${p.basename(executable.relativePath)}-$versionSuffix.snapshot',
+ );
}
String incrementalDillPathOfExecutable(Executable executable) {
assert(p.isRelative(executable.relativePath));
return isGlobal
- ? p.join(_incrementalDillsPath,
- '${p.basename(executable.relativePath)}.incremental.dill')
- : p.join(_incrementalDillsPath, executable.package,
- '${p.basename(executable.relativePath)}.incremental.dill');
+ ? p.join(
+ _incrementalDillsPath,
+ '${p.basename(executable.relativePath)}.incremental.dill',
+ )
+ : p.join(
+ _incrementalDillsPath,
+ executable.package,
+ '${p.basename(executable.relativePath)}.incremental.dill',
+ );
}
/// The absolute path of [executable] resolved relative to [this].
@@ -611,7 +634,8 @@
if (!entryExists(lockFilePath)) {
dataError(
- 'No $lockFilePath file found, please run "$topLevelProgram pub get" first.');
+ 'No $lockFilePath file found, please run "$topLevelProgram pub get" first.',
+ );
}
if (!entryExists(packageConfigPath)) {
dataError(
@@ -722,8 +746,10 @@
if (source is CachedSource) continue;
try {
- if (cache.load(id).dependencies.values.every((dep) =>
- overrides.contains(dep.name) || _isDependencyUpToDate(dep))) {
+ if (cache.load(id).dependencies.values.every(
+ (dep) =>
+ overrides.contains(dep.name) || _isDependencyUpToDate(dep),
+ )) {
continue;
}
} on FileException {
@@ -934,13 +960,10 @@
void _checkSdkConstraint(Pubspec pubspec) {
final dartSdkConstraint = pubspec.dartSdkConstraint.effectiveConstraint;
if (dartSdkConstraint is! VersionRange || dartSdkConstraint.min == null) {
- // Suggest version range '>=2.12.0 <3.0.0', we avoid using:
- // [CompatibleWithVersionRange] because some pub versions don't support
- // caret syntax (e.g. '^2.12.0')
- var suggestedConstraint = VersionRange(
- min: Version.parse('2.12.0'),
- max: Version.parse('2.12.0').nextBreaking,
- includeMin: true,
+ // Suggest an sdk constraint giving the same language version as the
+ // current sdk.
+ var suggestedConstraint = VersionConstraint.compatibleWith(
+ Version(sdk.version.major, sdk.version.minor, 0),
);
// But if somehow that doesn't work, we fallback to safe sanity, mostly
// important for tests, or if we jump to 3.x without patching this code.
@@ -967,7 +990,8 @@
final keyNode = environment.nodes.entries
.firstWhere((e) => (e.key as YamlNode).value == sdk)
.key as YamlNode;
- throw SourceSpanApplicationException('''
+ throw SourceSpanApplicationException(
+ '''
$pubspecPath refers to an unknown sdk '$sdk'.
Did you mean to add it as a dependency?
@@ -976,7 +1000,9 @@
given sdk.
See https://dart.dev/go/sdk-constraint
-''', keyNode.span);
+''',
+ keyNode.span,
+ );
}
}
}
@@ -985,4 +1011,10 @@
dataError('The "$packageConfigPath" file is not recognized by '
'"pub" version, please run "$topLevelProgram pub get".');
}
+
+ /// Setting the `PUB_SUMMARY_ONLY` environment variable to anything but '0'
+ /// will result in [acquireDependencies] to only print a summary of the
+ /// results.
+ bool get _summaryOnlyEnvironment =>
+ (Platform.environment['PUB_SUMMARY_ONLY'] ?? '0') != '0';
}
diff --git a/lib/src/error_group.dart b/lib/src/error_group.dart
index 11607bb..560d806 100644
--- a/lib/src/error_group.dart
+++ b/lib/src/error_group.dart
@@ -280,19 +280,30 @@
_stream = inner.isBroadcast
? _controller.stream.asBroadcastStream(onCancel: (sub) => sub.cancel())
: _controller.stream;
- _subscription =
- inner.listen(_controller.add, onError: _group._signalError, onDone: () {
- _isDone = true;
- _group._signalStreamComplete(this);
- _controller.close();
- });
+ _subscription = inner.listen(
+ _controller.add,
+ onError: _group._signalError,
+ onDone: () {
+ _isDone = true;
+ _group._signalStreamComplete(this);
+ _controller.close();
+ },
+ );
}
@override
- StreamSubscription<T> listen(void Function(T)? onData,
- {Function? onError, void Function()? onDone, bool? cancelOnError}) {
- return _stream.listen(onData,
- onError: onError, onDone: onDone, cancelOnError: true);
+ StreamSubscription<T> listen(
+ void Function(T)? onData, {
+ Function? onError,
+ void Function()? onDone,
+ bool? cancelOnError,
+ }) {
+ return _stream.listen(
+ onData,
+ onError: onError,
+ onDone: onDone,
+ cancelOnError: true,
+ );
}
/// Signal that an error from [_group] should be propagated through [this],
diff --git a/lib/src/exceptions.dart b/lib/src/exceptions.dart
index 90c9d1a..c70c53d 100644
--- a/lib/src/exceptions.dart
+++ b/lib/src/exceptions.dart
@@ -142,9 +142,12 @@
final String? explanation;
final String? hint;
- SourceSpanApplicationException(String message, SourceSpan? span,
- {this.hint, this.explanation})
- : super(message, span);
+ SourceSpanApplicationException(
+ String message,
+ SourceSpan? span, {
+ this.hint,
+ this.explanation,
+ }) : super(message, span);
@override
String toString({color}) {
diff --git a/lib/src/executable.dart b/lib/src/executable.dart
index fe8f1db..a80437a 100644
--- a/lib/src/executable.dart
+++ b/lib/src/executable.dart
@@ -27,10 +27,6 @@
final experiments = argResults['enable-experiment'] as List;
return [
if (experiments.isNotEmpty) "--enable-experiment=${experiments.join(',')}",
- if (argResults.wasParsed('sound-null-safety'))
- argResults['sound-null-safety']
- ? '--sound-null-safety'
- : '--no-sound-null-safety',
];
}
@@ -48,11 +44,14 @@
///
/// Returns the exit code of the spawned app.
Future<int> runExecutable(
- Entrypoint entrypoint, Executable executable, List<String> args,
- {bool enableAsserts = false,
- required Future<void> Function(Executable) recompile,
- List<String> vmArgs = const [],
- required bool alwaysUseSubprocess}) async {
+ Entrypoint entrypoint,
+ Executable executable,
+ List<String> args, {
+ bool enableAsserts = false,
+ required Future<void> Function(Executable) recompile,
+ List<String> vmArgs = const [],
+ required bool alwaysUseSubprocess,
+}) async {
final package = executable.package;
// Make sure the package is an immediate dependency of the entrypoint or the
@@ -151,10 +150,13 @@
/// otherwise starts new vm in a subprocess. If [alwaysUseSubprocess] is `true`
/// a new process will always be started.
Future<int> _runDartProgram(
- String path, List<String> args, String packageConfig,
- {bool enableAsserts = false,
- List<String> vmArgs = const <String>[],
- required bool alwaysUseSubprocess}) async {
+ String path,
+ List<String> args,
+ String packageConfig, {
+ bool enableAsserts = false,
+ List<String> vmArgs = const <String>[],
+ required bool alwaysUseSubprocess,
+}) async {
path = p.absolute(path);
packageConfig = p.absolute(packageConfig);
@@ -162,8 +164,13 @@
// That provides better signal handling, and possibly faster startup.
if ((!alwaysUseSubprocess) && vmArgs.isEmpty) {
var argList = args.toList();
- return await isolate.runUri(p.toUri(path), argList, '',
- enableAsserts: enableAsserts, packageConfig: p.toUri(packageConfig));
+ return await isolate.runUri(
+ p.toUri(path),
+ argList,
+ '',
+ enableAsserts: enableAsserts,
+ packageConfig: p.toUri(packageConfig),
+ );
} else {
// By ignoring sigint, only the child process will get it when
// they are sent to the current process group. That is what happens when
@@ -304,8 +311,9 @@
}
if (!fileExists(p.join(root, 'pubspec.yaml'))) {
throw CommandResolutionFailedException._(
- 'Could not find file `$descriptor`',
- CommandResolutionIssue.fileNotFound);
+ 'Could not find file `$descriptor`',
+ CommandResolutionIssue.fileNotFound,
+ );
}
final entrypoint = Entrypoint(root, SystemCache(rootDir: pubCacheDir));
try {
@@ -314,7 +322,7 @@
} on DataException catch (e) {
log.fine('Resolution not up to date: ${e.message}. Redoing.');
try {
- await warningsOnlyUnlessTerminal(
+ await errorsOnlyUnlessTerminal(
() => entrypoint.acquireDependencies(
SolveType.get,
analytics: analytics,
@@ -322,7 +330,9 @@
);
} on ApplicationException catch (e) {
throw CommandResolutionFailedException._(
- e.toString(), CommandResolutionIssue.pubGetFailed);
+ e.toString(),
+ CommandResolutionIssue.pubGetFailed,
+ );
}
}
@@ -372,7 +382,7 @@
if (!fileExists(snapshotPath) ||
entrypoint.packageGraph.isPackageMutable(package)) {
try {
- await warningsOnlyUnlessTerminal(
+ await errorsOnlyUnlessTerminal(
() => entrypoint.precompileExecutable(
executable,
additionalSources: additionalSources,
diff --git a/lib/src/git.dart b/lib/src/git.dart
index ded45e9..f6fea7d 100644
--- a/lib/src/git.dart
+++ b/lib/src/git.dart
@@ -49,8 +49,11 @@
///
/// Returns the stdout as a list of strings if it succeeded. Completes to an
/// exception if it failed.
-Future<List<String>> run(List<String> args,
- {String? workingDir, Map<String, String>? environment}) async {
+Future<List<String>> run(
+ List<String> args, {
+ String? workingDir,
+ Map<String, String>? environment,
+}) async {
if (!isInstalled) {
fail('Cannot find a Git executable.\n'
'Please ensure Git is correctly installed.');
@@ -58,12 +61,19 @@
log.muteProgress();
try {
- final result = await runProcess(command!, args,
- workingDir: workingDir,
- environment: {...?environment, 'LANG': 'en_GB'});
+ final result = await runProcess(
+ command!,
+ args,
+ workingDir: workingDir,
+ environment: {...?environment, 'LANG': 'en_GB'},
+ );
if (!result.success) {
- throw GitException(args, result.stdout.join('\n'),
- result.stderr.join('\n'), result.exitCode);
+ throw GitException(
+ args,
+ result.stdout.join('\n'),
+ result.stderr.join('\n'),
+ result.exitCode,
+ );
}
return result.stdout;
} finally {
@@ -72,18 +82,29 @@
}
/// Like [run], but synchronous.
-List<String> runSync(List<String> args,
- {String? workingDir, Map<String, String>? environment}) {
+List<String> runSync(
+ List<String> args, {
+ String? workingDir,
+ Map<String, String>? environment,
+}) {
if (!isInstalled) {
fail('Cannot find a Git executable.\n'
'Please ensure Git is correctly installed.');
}
- final result = runProcessSync(command!, args,
- workingDir: workingDir, environment: environment);
+ final result = runProcessSync(
+ command!,
+ args,
+ workingDir: workingDir,
+ environment: environment,
+ );
if (!result.success) {
- throw GitException(args, result.stdout.join('\n'), result.stderr.join('\n'),
- result.exitCode);
+ throw GitException(
+ args,
+ result.stdout.join('\n'),
+ result.stderr.join('\n'),
+ result.exitCode,
+ );
}
return result.stdout;
diff --git a/lib/src/global_packages.dart b/lib/src/global_packages.dart
index 089016a..bfb04d2 100644
--- a/lib/src/global_packages.dart
+++ b/lib/src/global_packages.dart
@@ -108,13 +108,14 @@
PackageRef packageRef;
try {
packageRef = cache.git.parseRef(
- name,
- {
- 'url': repo,
- if (path != null) 'path': path,
- if (ref != null) 'ref': ref,
- },
- containingDir: '.');
+ name,
+ {
+ 'url': repo,
+ if (path != null) 'path': path,
+ if (ref != null) 'ref': ref,
+ },
+ containingDir: '.',
+ );
} on FormatException catch (e) {
throw ApplicationException(e.message);
}
@@ -146,9 +147,10 @@
String? url,
}) async {
await _installInCache(
- cache.hosted.refFor(name, url: url).withConstraint(constraint),
- executables,
- overwriteBinStubs: overwriteBinStubs);
+ cache.hosted.refFor(name, url: url).withConstraint(constraint),
+ executables,
+ overwriteBinStubs: overwriteBinStubs,
+ );
}
/// Makes the local package at [path] globally active.
@@ -160,9 +162,12 @@
/// if [overwriteBinStubs] is `true`, any binstubs that collide with
/// existing binstubs in other packages will be overwritten by this one's.
/// Otherwise, the previous ones will be preserved.
- Future<void> activatePath(String path, List<String>? executables,
- {required bool overwriteBinStubs,
- required PubAnalytics? analytics}) async {
+ Future<void> activatePath(
+ String path,
+ List<String>? executables, {
+ required bool overwriteBinStubs,
+ required PubAnalytics? analytics,
+ }) async {
var entrypoint = Entrypoint(path, cache);
// Get the package's dependencies.
@@ -190,22 +195,35 @@
tryDeleteEntry(_packageDir(name));
tryRenameDir(tempDir, _packageDir(name));
- _updateBinStubs(entrypoint, entrypoint.root, executables,
- overwriteBinStubs: overwriteBinStubs);
+ _updateBinStubs(
+ entrypoint,
+ entrypoint.root,
+ executables,
+ overwriteBinStubs: overwriteBinStubs,
+ );
log.message('Activated ${_formatPackage(id)}.');
}
/// Installs the package [dep] and its dependencies into the system cache.
///
/// If [silent] less logging will be printed.
- Future<void> _installInCache(PackageRange dep, List<String>? executables,
- {required bool overwriteBinStubs, bool silent = false}) async {
+ Future<void> _installInCache(
+ PackageRange dep,
+ List<String>? executables, {
+ required bool overwriteBinStubs,
+ bool silent = false,
+ }) async {
final name = dep.name;
LockFile? originalLockFile = _describeActive(name, cache);
// Create a dummy package with just [dep] so we can do resolution on it.
- var root = Package.inMemory(Pubspec('pub global activate',
- dependencies: [dep], sources: cache.sources));
+ var root = Package.inMemory(
+ Pubspec(
+ 'pub global activate',
+ dependencies: [dep],
+ sources: cache.sources,
+ ),
+ );
// Resolve it and download its dependencies.
//
@@ -360,12 +378,18 @@
// For cached sources, the package itself is in the cache and the
// lockfile is the one we just loaded.
entrypoint = Entrypoint.global(
- _packageDir(id.name), cache.loadCached(id), lockFile, cache);
+ _packageDir(id.name),
+ cache.loadCached(id),
+ lockFile,
+ cache,
+ );
} else {
// For uncached sources (i.e. path), the ID just points to the real
// directory for the package.
entrypoint = Entrypoint(
- (id.description.description as PathDescription).path, cache);
+ (id.description.description as PathDescription).path,
+ cache,
+ );
}
entrypoint.root.pubspec.sdkConstraints.forEach((sdkName, constraint) {
@@ -414,11 +438,14 @@
///
/// Returns the exit code from the executable.
Future<int> runExecutable(
- Entrypoint entrypoint, exec.Executable executable, List<String> args,
- {bool enableAsserts = false,
- required Future<void> Function(exec.Executable) recompile,
- List<String> vmArgs = const [],
- required bool alwaysUseSubprocess}) async {
+ Entrypoint entrypoint,
+ exec.Executable executable,
+ List<String> args, {
+ bool enableAsserts = false,
+ required Future<void> Function(exec.Executable) recompile,
+ List<String> vmArgs = const [],
+ required bool alwaysUseSubprocess,
+ }) async {
return await exec.runExecutable(
entrypoint,
executable,
@@ -504,10 +531,11 @@
executables.putIfAbsent(package, () => []).add(executable);
} catch (error, stackTrace) {
log.error(
- 'Error reading binstub for '
- '"${p.basenameWithoutExtension(entry)}"',
- error,
- stackTrace);
+ 'Error reading binstub for '
+ '"${p.basenameWithoutExtension(entry)}"',
+ error,
+ stackTrace,
+ );
tryDeleteEntry(entry);
}
@@ -596,8 +624,12 @@
log.fine('Replacing old binstub $file');
deleteEntry(file);
_createBinStub(
- entrypoint.root, p.basenameWithoutExtension(file), binStubScript,
- overwrite: true, snapshot: entrypoint.pathOfExecutable(executable));
+ entrypoint.root,
+ p.basenameWithoutExtension(file),
+ binStubScript,
+ overwrite: true,
+ snapshot: entrypoint.pathOfExecutable(executable),
+ );
}
}
}
@@ -621,8 +653,12 @@
/// If [suggestIfNotOnPath] is `true` (the default), this will warn the user if
/// the bin directory isn't on their path.
void _updateBinStubs(
- Entrypoint entrypoint, Package package, List<String>? executables,
- {required bool overwriteBinStubs, bool suggestIfNotOnPath = true}) {
+ Entrypoint entrypoint,
+ Package package,
+ List<String>? executables, {
+ required bool overwriteBinStubs,
+ bool suggestIfNotOnPath = true,
+ }) {
// Remove any previously activated binstubs for this package, in case the
// list of executables has changed.
_deleteBinStubs(package.name);
@@ -685,8 +721,10 @@
// Show errors for any unknown executables.
if (executables != null) {
- var unknown = ordered(executables
- .where((exe) => !package.pubspec.executables.keys.contains(exe)));
+ var unknown = ordered(
+ executables
+ .where((exe) => !package.pubspec.executables.keys.contains(exe)),
+ );
if (unknown.isNotEmpty) {
dataError("Unknown ${namedSequence('executable', unknown)}.");
}
@@ -878,7 +916,9 @@
var binDir = _binStubDir;
if (binDir.startsWith(Platform.environment['HOME']!)) {
binDir = p.join(
- r'$HOME', p.relative(binDir, from: Platform.environment['HOME']));
+ r'$HOME',
+ p.relative(binDir, from: Platform.environment['HOME']),
+ );
}
log.warning("${log.yellow('Warning:')} Pub installs executables into "
diff --git a/lib/src/http.dart b/lib/src/http.dart
index ccd5146..00f5a7f 100644
--- a/lib/src/http.dart
+++ b/lib/src/http.dart
@@ -67,7 +67,8 @@
requestLog.writeln();
requestLog.writeln('Body fields:');
request.fields.forEach(
- (name, value) => requestLog.writeln(_logField(name, value)));
+ (name, value) => requestLog.writeln(_logField(name, value)),
+ );
// TODO(nweiz): make MultipartRequest.files readable, and log them?
} else if (request is http.Request) {
@@ -75,7 +76,8 @@
requestLog.writeln();
requestLog.writeln('Body fields:');
request.bodyFields.forEach(
- (name, value) => requestLog.writeln(_logField(name, value)));
+ (name, value) => requestLog.writeln(_logField(name, value)),
+ );
} else if (contentType.value == 'text/plain' ||
contentType.value == 'application/json') {
requestLog.write(request.body);
@@ -241,9 +243,11 @@
class PubHttpResponseException extends PubHttpException {
final http.BaseResponse response;
- PubHttpResponseException(this.response,
- {String message = '', bool isIntermittent = false})
- : super(message, isIntermittent: isIntermittent);
+ PubHttpResponseException(
+ this.response, {
+ String message = '',
+ bool isIntermittent = false,
+ }) : super(message, isIntermittent: isIntermittent);
@override
String toString() {
@@ -280,17 +284,18 @@
/// Each attempt is run within a [Pool] configured with 16 maximum resources.
Future<T> retryForHttp<T>(String operation, FutureOr<T> Function() fn) async {
return await retry(
- () async => await _httpPool.withResource(() async => await fn()),
- retryIf: (e) async =>
- (e is PubHttpException && e.isIntermittent) ||
- e is TimeoutException ||
- isHttpIOException(e),
- onRetry: (exception, attemptNumber) async =>
- log.io('Attempt #$attemptNumber for $operation'),
- maxAttempts: math.max(
- 1, // Having less than 1 attempt doesn't make sense.
- int.tryParse(Platform.environment['PUB_MAX_HTTP_RETRIES'] ?? '') ?? 7,
- ));
+ () async => await _httpPool.withResource(() async => await fn()),
+ retryIf: (e) async =>
+ (e is PubHttpException && e.isIntermittent) ||
+ e is TimeoutException ||
+ isHttpIOException(e),
+ onRetry: (exception, attemptNumber) async =>
+ log.io('Attempt #$attemptNumber for $operation'),
+ maxAttempts: math.max(
+ 1, // Having less than 1 attempt doesn't make sense.
+ int.tryParse(Platform.environment['PUB_MAX_HTTP_RETRIES'] ?? '') ?? 7,
+ ),
+ );
}
extension Throwing on http.BaseResponse {
@@ -344,8 +349,10 @@
///
/// If false is passed for [throwIfNotOk], the response will not be validated.
/// See [http.BaseResponse.throwIfNotOk] extension for validation details.
- Future<http.Response> fetch(http.BaseRequest request,
- {bool throwIfNotOk = true}) async {
+ Future<http.Response> fetch(
+ http.BaseRequest request, {
+ bool throwIfNotOk = true,
+ }) async {
final streamedResponse = await send(request);
final response = await http.Response.fromStream(streamedResponse);
if (throwIfNotOk) {
@@ -359,8 +366,10 @@
///
/// If false is passed for [throwIfNotOk], the response will not be validated.
/// See [http.BaseResponse.throwIfNotOk] extension for validation details.
- Future<http.StreamedResponse> fetchAsStream(http.BaseRequest request,
- {bool throwIfNotOk = true}) async {
+ Future<http.StreamedResponse> fetchAsStream(
+ http.BaseRequest request, {
+ bool throwIfNotOk = true,
+ }) async {
final streamedResponse = await send(request);
if (throwIfNotOk) {
streamedResponse.throwIfNotOk();
diff --git a/lib/src/ignore.dart b/lib/src/ignore.dart
index 34e51fb..8b7aff1 100644
--- a/lib/src/ignore.dart
+++ b/lib/src/ignore.dart
@@ -228,7 +228,10 @@
beneath.startsWith('./') ||
beneath.startsWith('../')) {
throw ArgumentError.value(
- 'must be relative and normalized', 'beneath', beneath);
+ 'must be relative and normalized',
+ 'beneath',
+ beneath,
+ );
}
if (beneath.endsWith('/')) {
throw ArgumentError.value('must not end with /', beneath);
@@ -256,7 +259,8 @@
return <String>[];
}
final ignore = ignoreForDir(
- partial == '/' ? '.' : partial.substring(1, partial.length - 1));
+ partial == '/' ? '.' : partial.substring(1, partial.length - 1),
+ );
ignoreStack
.add(ignore == null ? null : _IgnorePrefixPair(ignore, partial));
}
@@ -285,10 +289,14 @@
}
if (currentIsDir) {
final ignore = ignoreForDir(normalizedCurrent);
- ignoreStack.add(ignore == null
- ? null
- : _IgnorePrefixPair(
- ignore, current == '/' ? current : '$current/'));
+ ignoreStack.add(
+ ignore == null
+ ? null
+ : _IgnorePrefixPair(
+ ignore,
+ current == '/' ? current : '$current/',
+ ),
+ );
// Put all entities in current on the stack to be processed.
toVisit.add(listDir(normalizedCurrent).map((x) => '/$x').toList());
if (includeDirs) {
@@ -486,9 +494,10 @@
return _IgnoreParseResult.invalid(
pattern,
FormatException(
- 'Pattern "$pattern" had an invalid `[a-b]` style character range',
- pattern,
- current),
+ 'Pattern "$pattern" had an invalid `[a-b]` style character range',
+ pattern,
+ current,
+ ),
);
}
expr += '[$characterRange]';
@@ -499,9 +508,10 @@
return _IgnoreParseResult.invalid(
pattern,
FormatException(
- 'Pattern "$pattern" end of pattern inside character escape.',
- pattern,
- current),
+ 'Pattern "$pattern" end of pattern inside character escape.',
+ pattern,
+ current,
+ ),
);
}
expr += RegExp.escape(escaped);
@@ -531,12 +541,17 @@
}
try {
return _IgnoreParseResult(
+ pattern,
+ _IgnoreRule(
+ RegExp(expr, caseSensitive: !ignoreCase),
+ negative,
pattern,
- _IgnoreRule(
- RegExp(expr, caseSensitive: !ignoreCase), negative, pattern));
+ ),
+ );
} on FormatException catch (e) {
throw AssertionError(
- 'Created broken expression "$expr" from ignore pattern "$pattern" -> $e');
+ 'Created broken expression "$expr" from ignore pattern "$pattern" -> $e',
+ );
}
}
diff --git a/lib/src/io.dart b/lib/src/io.dart
index 46d910c..c9230ca 100644
--- a/lib/src/io.dart
+++ b/lib/src/io.dart
@@ -27,6 +27,30 @@
export 'package:http/http.dart' show ByteStream;
+/// Environment variable names that are recognized by pub.
+class EnvironmentKeys {
+ /// Overrides terminal detection for stdout.
+ ///
+ /// Supported values:
+ /// * missing or `''` (empty string): dart:io terminal detection is used.
+ /// * `"0"`: output as if no terminal is attached
+ /// - no animations
+ /// - no ANSI colors
+ /// - use unicode characters
+ /// - silent inside [log.errorsOnlyUnlessTerminal]).
+ /// * `"1"`: output as if a terminal is attached
+ /// - animations
+ /// - ANSI colors (can be overriden again with NO_COLOR)
+ /// - no unicode on Windows
+ /// - normal verbosity in output inside
+ /// [log.errorsOnlyUnlessTerminal]).
+ ///
+ /// This variable is mainly for testing, and no forward compatibility
+ /// guarantees are given.
+ static const forceTerminalOutput = '_PUB_FORCE_TERMINAL_OUTPUT';
+ // TODO(sigurdm): Add other environment keys here.
+}
+
/// The pool used for restricting access to asynchronous operations that consume
/// file descriptors.
///
@@ -299,11 +323,13 @@
///
/// The returned paths are guaranteed to begin with [dir]. Broken symlinks won't
/// be returned.
-List<String> listDir(String dir,
- {bool recursive = false,
- bool includeHidden = false,
- bool includeDirs = true,
- Iterable<String> allowed = const <String>[]}) {
+List<String> listDir(
+ String dir, {
+ bool recursive = false,
+ bool includeHidden = false,
+ bool includeDirs = true,
+ Iterable<String> allowed = const <String>[],
+}) {
var allowlistFilter = createFileFilter(allowed);
// This is used in some performance-sensitive paths and can list many, many
@@ -365,8 +391,11 @@
///
/// For some operations it makes sense to handle ERROR_DIR_NOT_EMPTY
/// differently. They can pass [ignoreEmptyDir] = `true`.
-void _attempt(String description, void Function() operation,
- {bool ignoreEmptyDir = false}) {
+void _attempt(
+ String description,
+ void Function() operation, {
+ bool ignoreEmptyDir = false,
+}) {
if (!Platform.isWindows) {
operation();
return;
@@ -453,10 +482,14 @@
/// Renames (i.e. moves) the directory [from] to [to].
void renameDir(String from, String to) {
- _attempt('rename directory', () {
- log.io('Renaming directory $from to $to.');
- Directory(from).renameSync(to);
- }, ignoreEmptyDir: true);
+ _attempt(
+ 'rename directory',
+ () {
+ log.io('Renaming directory $from to $to.');
+ Directory(from).renameSync(to);
+ },
+ ignoreEmptyDir: true,
+ );
}
/// Renames directory [from] to [to].
@@ -541,8 +574,13 @@
///
/// If [relative] is true, creates a symlink with a relative path from the
/// symlink to the target. Otherwise, uses the [target] path unmodified.
-void createPackageSymlink(String name, String target, String symlink,
- {bool isSelfLink = false, bool relative = false}) {
+void createPackageSymlink(
+ String name,
+ String target,
+ String symlink, {
+ bool isSelfLink = false,
+ bool relative = false,
+}) {
// See if the package has a "lib" directory. If not, there's nothing to
// symlink to.
target = path.join(target, 'lib');
@@ -639,6 +677,26 @@
}
}
+/// Returns `true` if [stdout] should be treated as a terminal.
+///
+/// The detected behaviour can be overridden with the environment variable
+/// [EnvironmentKeys.forceTerminalOutput].
+bool get terminalOutputForStdout {
+ final environmentValue =
+ Platform.environment[EnvironmentKeys.forceTerminalOutput];
+ if (environmentValue == null || environmentValue == '') {
+ return stdout.hasTerminal;
+ } else if (environmentValue == '0') {
+ return false;
+ } else if (environmentValue == '1') {
+ return true;
+ } else {
+ throw DataException(
+ 'Environment variable ${EnvironmentKeys.forceTerminalOutput} has unsupported value: $environmentValue.',
+ );
+ }
+}
+
/// Flushes the stdout and stderr streams, then exits the program with the given
/// status code.
///
@@ -679,13 +737,18 @@
return _descriptorPool.withResource(() async {
ProcessResult result;
try {
- result = await _doProcess(Process.run, executable, args,
- workingDir: workingDir,
- environment: environment,
- runInShell: runInShell);
+ result = await _doProcess(
+ Process.run,
+ executable,
+ args,
+ workingDir: workingDir,
+ environment: environment,
+ runInShell: runInShell,
+ );
} on IOException catch (e) {
throw RunProcessException(
- 'Pub failed to run subprocess `$executable`: $e');
+ 'Pub failed to run subprocess `$executable`: $e',
+ );
}
var pubResult =
@@ -714,13 +777,18 @@
return _descriptorPool.request().then((resource) async {
Process ioProcess;
try {
- ioProcess = await _doProcess(Process.start, executable, args,
- workingDir: workingDir,
- environment: environment,
- runInShell: runInShell);
+ ioProcess = await _doProcess(
+ Process.start,
+ executable,
+ args,
+ workingDir: workingDir,
+ environment: environment,
+ runInShell: runInShell,
+ );
} on IOException catch (e) {
throw RunProcessException(
- 'Pub failed to run subprocess `$executable`: $e');
+ 'Pub failed to run subprocess `$executable`: $e',
+ );
}
var process = PubProcess(ioProcess);
@@ -740,10 +808,14 @@
ArgumentError.checkNotNull(executable, 'executable');
ProcessResult result;
try {
- result = _doProcess(Process.runSync, executable, args,
- workingDir: workingDir,
- environment: environment,
- runInShell: runInShell);
+ result = _doProcess(
+ Process.runSync,
+ executable,
+ args,
+ workingDir: workingDir,
+ environment: environment,
+ runInShell: runInShell,
+ );
} on IOException catch (e) {
throw RunProcessException('Pub failed to run subprocess `$executable`: $e');
}
@@ -864,10 +936,13 @@
log.process(executable, args, workingDir ?? '.');
- return fn(executable, args,
- workingDirectory: workingDir,
- environment: environment,
- runInShell: runInShell);
+ return fn(
+ executable,
+ args,
+ workingDirectory: workingDir,
+ environment: environment,
+ runInShell: runInShell,
+ );
}
/// Updates [path]'s modification time.
@@ -960,7 +1035,8 @@
case TypeFlag.symlink:
// Link to another file in this tar, relative from this entry.
final resolvedTarget = path.joinAll(
- [parentDirectory, ...path.posix.split(entry.header.linkName!)]);
+ [parentDirectory, ...path.posix.split(entry.header.linkName!)],
+ );
if (!checkValidTarget(resolvedTarget)) {
// Don't allow links to files outside of this tar.
break;
@@ -968,7 +1044,9 @@
ensureDir(parentDirectory);
createSymlink(
- path.relative(resolvedTarget, from: parentDirectory), filePath);
+ path.relative(resolvedTarget, from: parentDirectory),
+ filePath,
+ );
break;
case TypeFlag.link:
// We generate hardlinks as symlinks too, but their linkName is relative
@@ -1011,41 +1089,45 @@
ArgumentError.checkNotNull(baseDir, 'baseDir');
baseDir = path.normalize(path.absolute(baseDir));
- final tarContents = Stream.fromIterable(contents.map((entry) {
- entry = path.normalize(path.absolute(entry));
- if (!path.isWithin(baseDir, entry)) {
- throw ArgumentError('Entry $entry is not inside $baseDir.');
- }
+ final tarContents = Stream.fromIterable(
+ contents.map((entry) {
+ entry = path.normalize(path.absolute(entry));
+ if (!path.isWithin(baseDir, entry)) {
+ throw ArgumentError('Entry $entry is not inside $baseDir.');
+ }
- final relative = path.relative(entry, from: baseDir);
- // On Windows, we can't open some files without normalizing them
- final file = File(path.normalize(entry));
- final stat = file.statSync();
+ final relative = path.relative(entry, from: baseDir);
+ // On Windows, we can't open some files without normalizing them
+ final file = File(path.normalize(entry));
+ final stat = file.statSync();
- if (stat.type == FileSystemEntityType.link) {
- log.message('$entry is a link locally, but will be uploaded as a '
- 'duplicate file.');
- }
+ if (stat.type == FileSystemEntityType.link) {
+ log.message('$entry is a link locally, but will be uploaded as a '
+ 'duplicate file.');
+ }
- return TarEntry(
- TarHeader(
- // Ensure paths in tar files use forward slashes
- name: path.url.joinAll(path.split(relative)),
- // We want to keep executable bits, but otherwise use the default
- // file mode
- mode: _defaultMode | (stat.mode & _executableMask),
- size: stat.size,
- modified: stat.changed,
- userName: 'pub',
- groupName: 'pub',
- ),
- file.openRead(),
- );
- }));
+ return TarEntry(
+ TarHeader(
+ // Ensure paths in tar files use forward slashes
+ name: path.url.joinAll(path.split(relative)),
+ // We want to keep executable bits, but otherwise use the default
+ // file mode
+ mode: _defaultMode | (stat.mode & _executableMask),
+ size: stat.size,
+ modified: stat.changed,
+ userName: 'pub',
+ groupName: 'pub',
+ ),
+ file.openRead(),
+ );
+ }),
+ );
- return ByteStream(tarContents
- .transform(tarWriterWith(format: OutputFormat.gnuLongName))
- .transform(gzip.encoder));
+ return ByteStream(
+ tarContents
+ .transform(tarWriterWith(format: OutputFormat.gnuLongName))
+ .transform(gzip.encoder),
+ );
}
/// Contains the results of invoking a [Process] and waiting for it to complete.
diff --git a/lib/src/isolate.dart b/lib/src/isolate.dart
index 6c46199..57871da 100644
--- a/lib/src/isolate.dart
+++ b/lib/src/isolate.dart
@@ -14,20 +14,28 @@
/// the [exitCode] variable is set to 255.
///
/// If [buffered] is `true`, this uses [spawnBufferedUri] to spawn the isolate.
-Future<int> runUri(Uri url, List<String> args, Object message,
- {bool buffered = false,
- bool? enableAsserts,
- bool automaticPackageResolution = false,
- Uri? packageConfig}) async {
+Future<int> runUri(
+ Uri url,
+ List<String> args,
+ Object message, {
+ bool buffered = false,
+ bool? enableAsserts,
+ bool automaticPackageResolution = false,
+ Uri? packageConfig,
+}) async {
var errorPort = ReceivePort();
var exitPort = ReceivePort();
- await Isolate.spawnUri(url, args, message,
- checked: enableAsserts,
- automaticPackageResolution: automaticPackageResolution,
- packageConfig: packageConfig,
- onError: errorPort.sendPort,
- onExit: exitPort.sendPort);
+ await Isolate.spawnUri(
+ url,
+ args,
+ message,
+ checked: enableAsserts,
+ automaticPackageResolution: automaticPackageResolution,
+ packageConfig: packageConfig,
+ onError: errorPort.sendPort,
+ onExit: exitPort.sendPort,
+ );
final subscription = errorPort.listen((list) {
stderr.writeln('Unhandled exception:');
diff --git a/lib/src/language_version.dart b/lib/src/language_version.dart
index 46254d0..31dff9a 100644
--- a/lib/src/language_version.dart
+++ b/lib/src/language_version.dart
@@ -64,7 +64,8 @@
/// The language version implied by a Dart sdk version.
factory LanguageVersion.fromLanguageVersionToken(
- LanguageVersionToken version) =>
+ LanguageVersionToken version,
+ ) =>
LanguageVersion(version.major, version.minor);
bool get supportsNullSafety => this >= firstVersionWithNullSafety;
diff --git a/lib/src/levenshtein.dart b/lib/src/levenshtein.dart
index 6ee7359..1c1f974 100644
--- a/lib/src/levenshtein.dart
+++ b/lib/src/levenshtein.dart
@@ -37,11 +37,12 @@
var holder = i - 1;
for (var j = 1; j <= b.length; j++) {
final newDistance = _min3(
- 1 + distances[j], // Deletion
- 1 + distances[j - 1], // Insertion
+ 1 + distances[j], // Deletion
+ 1 + distances[j - 1], // Insertion
- // Substitution
- holder + (a.codeUnitAt(i - 1) == b.codeUnitAt(j - 1) ? 0 : 1));
+ // Substitution
+ holder + (a.codeUnitAt(i - 1) == b.codeUnitAt(j - 1) ? 0 : 1),
+ );
holder = distances[j];
distances[j] = newDistance;
}
diff --git a/lib/src/lock_file.dart b/lib/src/lock_file.dart
index 343388d..bdafe4e 100644
--- a/lib/src/lock_file.dart
+++ b/lib/src/lock_file.dart
@@ -47,22 +47,30 @@
/// being listed in the main package's `dependencies`, `dev_dependencies`, and
/// `dependency_overrides` sections, respectively. These are consumed by the
/// analysis server to provide better auto-completion.
- LockFile(Iterable<PackageId> ids,
- {Map<String, VersionConstraint>? sdkConstraints,
- Set<String>? mainDependencies,
- Set<String>? devDependencies,
- Set<String>? overriddenDependencies})
- : this._(
- Map.fromIterable(ids.where((id) => !id.isRoot),
- key: (id) => id.name),
- sdkConstraints ?? {'dart': VersionConstraint.any},
- mainDependencies ?? const UnmodifiableSetView.empty(),
- devDependencies ?? const UnmodifiableSetView.empty(),
- overriddenDependencies ?? const UnmodifiableSetView.empty());
+ LockFile(
+ Iterable<PackageId> ids, {
+ Map<String, VersionConstraint>? sdkConstraints,
+ Set<String>? mainDependencies,
+ Set<String>? devDependencies,
+ Set<String>? overriddenDependencies,
+ }) : this._(
+ Map.fromIterable(
+ ids.where((id) => !id.isRoot),
+ key: (id) => id.name,
+ ),
+ sdkConstraints ?? {'dart': VersionConstraint.any},
+ mainDependencies ?? const UnmodifiableSetView.empty(),
+ devDependencies ?? const UnmodifiableSetView.empty(),
+ overriddenDependencies ?? const UnmodifiableSetView.empty(),
+ );
- LockFile._(Map<String, PackageId> packages, this.sdkConstraints,
- this.mainDependencies, this.devDependencies, this.overriddenDependencies)
- : packages = UnmodifiableMapView(packages);
+ LockFile._(
+ Map<String, PackageId> packages,
+ this.sdkConstraints,
+ this.mainDependencies,
+ this.devDependencies,
+ this.overriddenDependencies,
+ ) : packages = UnmodifiableMapView(packages);
LockFile.empty()
: packages = const {},
@@ -80,8 +88,11 @@
///
/// If [filePath] is given, path-dependencies will be interpreted relative to
/// that.
- factory LockFile.parse(String contents, SourceRegistry sources,
- {String? filePath}) {
+ factory LockFile.parse(
+ String contents,
+ SourceRegistry sources, {
+ String? filePath,
+ }) {
return LockFile._parse(filePath, contents, sources);
}
@@ -90,7 +101,10 @@
/// [filePath] is the system-native path to the lockfile on disc. It may be
/// `null`.
static LockFile _parse(
- String? filePath, String contents, SourceRegistry sources) {
+ String? filePath,
+ String contents,
+ SourceRegistry sources,
+ ) {
if (contents.trim() == '') return LockFile.empty();
Uri? sourceUrl;
@@ -114,9 +128,14 @@
_getEntry<YamlMap?>(parsed, 'sdks', 'map', required: false);
if (sdksField != null) {
- _parseEachEntry<String, YamlScalar>(sdksField, (name, constraint) {
- sdkConstraints[name] = _parseVersionConstraint(constraint);
- }, 'string', 'string');
+ _parseEachEntry<String, YamlScalar>(
+ sdksField,
+ (name, constraint) {
+ sdkConstraints[name] = _parseVersionConstraint(constraint);
+ },
+ 'string',
+ 'string',
+ );
}
final packages = <String, PackageId>{};
@@ -129,58 +148,68 @@
_getEntry<YamlMap?>(parsed, 'packages', 'map', required: false);
if (packageEntries != null) {
- _parseEachEntry<String, YamlMap>(packageEntries, (name, spec) {
- // Parse the version.
- final versionEntry = _getStringEntry(spec, 'version');
- final version = Version.parse(versionEntry);
+ _parseEachEntry<String, YamlMap>(
+ packageEntries,
+ (name, spec) {
+ // Parse the version.
+ final versionEntry = _getStringEntry(spec, 'version');
+ final version = Version.parse(versionEntry);
- // Parse the source.
- final sourceName = _getStringEntry(spec, 'source');
+ // Parse the source.
+ final sourceName = _getStringEntry(spec, 'source');
- var descriptionNode =
- _getEntry<YamlNode>(spec, 'description', 'description');
+ var descriptionNode =
+ _getEntry<YamlNode>(spec, 'description', 'description');
- dynamic description = descriptionNode is YamlScalar
- ? descriptionNode.value
- : descriptionNode;
+ dynamic description = descriptionNode is YamlScalar
+ ? descriptionNode.value
+ : descriptionNode;
- // Let the source parse the description.
- var source = sources(sourceName);
- PackageId id;
- try {
- id = source.parseId(name, version, description,
- containingDir: filePath == null ? null : p.dirname(filePath));
- } on FormatException catch (ex) {
- _failAt(ex.message, spec.nodes['description']!);
- }
-
- // Validate the name.
- if (name != id.name) {
- _failAt("Package name $name doesn't match ${id.name}.", spec);
- }
-
- packages[name] = id;
- if (spec.containsKey('dependency')) {
- final dependencyKind = _getStringEntry(spec, 'dependency');
- switch (dependencyKind) {
- case _directMain:
- mainDependencies.add(name);
- break;
- case _directDev:
- devDependencies.add(name);
- break;
- case _directOverridden:
- overriddenDependencies.add(name);
+ // Let the source parse the description.
+ var source = sources(sourceName);
+ PackageId id;
+ try {
+ id = source.parseId(
+ name,
+ version,
+ description,
+ containingDir: filePath == null ? null : p.dirname(filePath),
+ );
+ } on FormatException catch (ex) {
+ _failAt(ex.message, spec.nodes['description']!);
}
- }
- }, 'string', 'map');
+
+ // Validate the name.
+ if (name != id.name) {
+ _failAt("Package name $name doesn't match ${id.name}.", spec);
+ }
+
+ packages[name] = id;
+ if (spec.containsKey('dependency')) {
+ final dependencyKind = _getStringEntry(spec, 'dependency');
+ switch (dependencyKind) {
+ case _directMain:
+ mainDependencies.add(name);
+ break;
+ case _directDev:
+ devDependencies.add(name);
+ break;
+ case _directOverridden:
+ overriddenDependencies.add(name);
+ }
+ }
+ },
+ 'string',
+ 'map',
+ );
}
return LockFile._(
- packages,
- sdkConstraints,
- const UnmodifiableSetView.empty(),
- const UnmodifiableSetView.empty(),
- const UnmodifiableSetView.empty());
+ packages,
+ sdkConstraints,
+ const UnmodifiableSetView.empty(),
+ const UnmodifiableSetView.empty(),
+ const UnmodifiableSetView.empty(),
+ );
}
/// Runs [fn] and wraps any [FormatException] it throws in a
@@ -190,27 +219,40 @@
/// parsed or processed by [fn]. [span] should be the location of whatever's
/// being processed within the pubspec.
static T _wrapFormatException<T>(
- String description, SourceSpan span, T Function() fn) {
+ String description,
+ SourceSpan span,
+ T Function() fn,
+ ) {
try {
return fn();
} on FormatException catch (e) {
throw SourceSpanFormatException(
- 'Invalid $description: ${e.message}', span);
+ 'Invalid $description: ${e.message}',
+ span,
+ );
}
}
static VersionConstraint _parseVersionConstraint(YamlNode node) {
- return _parseNode(node, 'version constraint',
- parse: VersionConstraint.parse);
+ return _parseNode(
+ node,
+ 'version constraint',
+ parse: VersionConstraint.parse,
+ );
}
static String _getStringEntry(YamlMap map, String key) {
return _parseNode<String>(
- _getEntry<YamlScalar>(map, key, 'string'), 'string');
+ _getEntry<YamlScalar>(map, key, 'string'),
+ 'string',
+ );
}
- static T _parseNode<T>(YamlNode node, String typeDescription,
- {T Function(String)? parse}) {
+ static T _parseNode<T>(
+ YamlNode node,
+ String typeDescription, {
+ T Function(String)? parse,
+ }) {
if (node is T) {
return node as T;
} else if (node is YamlScalar) {
@@ -220,7 +262,10 @@
_failAt('Expected a $typeDescription.', node);
}
return _wrapFormatException(
- 'Expected a $typeDescription.', node.span, () => parse(node.value));
+ 'Expected a $typeDescription.',
+ node.span,
+ () => parse(node.value),
+ );
} else if (value is T) {
return value;
}
@@ -230,13 +275,16 @@
}
static void _parseEachEntry<K, V>(
- YamlMap map,
- void Function(K key, V value) f,
- String keyTypeDescription,
- String valueTypeDescription) {
+ YamlMap map,
+ void Function(K key, V value) f,
+ String keyTypeDescription,
+ String valueTypeDescription,
+ ) {
map.nodes.forEach((key, value) {
- f(_parseNode(key, keyTypeDescription),
- _parseNode(value, valueTypeDescription));
+ f(
+ _parseNode(key, keyTypeDescription),
+ _parseNode(value, valueTypeDescription),
+ );
});
}
@@ -308,23 +356,27 @@
rootUri = p.toUri(rootPath);
}
final pubspec = await cache.describe(id);
- entries.add(PackageConfigEntry(
- name: name,
- rootUri: rootUri,
- packageUri: p.toUri('lib/'),
- languageVersion: pubspec.languageVersion,
- ));
+ entries.add(
+ PackageConfigEntry(
+ name: name,
+ rootUri: rootUri,
+ packageUri: p.toUri('lib/'),
+ languageVersion: pubspec.languageVersion,
+ ),
+ );
}
if (entrypoint != null) {
- entries.add(PackageConfigEntry(
- name: entrypoint,
- rootUri: p.toUri('../'),
- packageUri: p.toUri('lib/'),
- languageVersion: LanguageVersion.fromSdkConstraint(
- entrypointSdkConstraint,
+ entries.add(
+ PackageConfigEntry(
+ name: entrypoint,
+ rootUri: p.toUri('../'),
+ packageUri: p.toUri('lib/'),
+ languageVersion: LanguageVersion.fromSdkConstraint(
+ entrypointSdkConstraint,
+ ),
),
- ));
+ );
}
final packageConfig = PackageConfig(
@@ -357,8 +409,10 @@
}
var data = {
- 'sdks': mapMap(sdkConstraints,
- value: (_, constraint) => constraint.toString()),
+ 'sdks': mapMap(
+ sdkConstraints,
+ value: (_, constraint) => constraint.toString(),
+ ),
'packages': packageMap
};
return '''
@@ -379,8 +433,10 @@
detectWindowsLineEndings(readTextFile(lockFilePath));
final serialized = serialize(p.dirname(lockFilePath), cache);
- writeTextFile(lockFilePath,
- windowsLineEndings ? serialized.replaceAll('\n', '\r\n') : serialized);
+ writeTextFile(
+ lockFilePath,
+ windowsLineEndings ? serialized.replaceAll('\n', '\r\n') : serialized,
+ );
}
static const _directMain = 'direct main';
diff --git a/lib/src/log.dart b/lib/src/log.dart
index 61c6768..5a1299d 100644
--- a/lib/src/log.dart
+++ b/lib/src/log.dart
@@ -251,7 +251,10 @@
/// Logs the spawning of an [executable] process with [arguments] at [io]
/// level.
void process(
- String executable, List<String> arguments, String workingDirectory) {
+ String executable,
+ List<String> arguments,
+ String workingDirectory,
+) {
io("Spawning \"$executable ${arguments.join(' ')}\" in "
'${p.absolute(workingDirectory)}');
}
@@ -410,10 +413,10 @@
/// Unless the user has overriden the verbosity,
///
/// This is useful to not pollute stdout when the output is piped somewhere.
-Future<T> warningsOnlyUnlessTerminal<T>(FutureOr<T> Function() callback) async {
+Future<T> errorsOnlyUnlessTerminal<T>(FutureOr<T> Function() callback) async {
final oldVerbosity = verbosity;
- if (verbosity == Verbosity.normal && !stdout.hasTerminal) {
- verbosity = Verbosity.warning;
+ if (verbosity == Verbosity.normal && !terminalOutputForStdout) {
+ verbosity = Verbosity.error;
}
final result = await callback();
verbosity = oldVerbosity;
@@ -436,8 +439,11 @@
}
/// Like [progress] but erases the message once done.
-Future<T> spinner<T>(String message, Future<T> Function() callback,
- {bool condition = true}) {
+Future<T> spinner<T>(
+ String message,
+ Future<T> Function() callback, {
+ bool condition = true,
+}) {
if (condition) {
_stopProgress();
diff --git a/lib/src/null_safety_analysis.dart b/lib/src/null_safety_analysis.dart
deleted file mode 100644
index 284e845..0000000
--- a/lib/src/null_safety_analysis.dart
+++ /dev/null
@@ -1,262 +0,0 @@
-// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'dart:async';
-
-import 'package:analyzer/dart/analysis/analysis_context_collection.dart';
-import 'package:analyzer/dart/analysis/results.dart';
-import 'package:analyzer/file_system/physical_file_system.dart';
-import 'package:cli_util/cli_util.dart';
-import 'package:path/path.dart' as path;
-import 'package:source_span/source_span.dart';
-import 'package:yaml/yaml.dart';
-
-import 'io.dart';
-import 'language_version.dart';
-import 'package.dart';
-import 'package_name.dart';
-import 'pubspec.dart';
-import 'solver.dart';
-import 'source.dart';
-import 'source/cached.dart';
-import 'system_cache.dart';
-
-enum NullSafetyCompliance {
- /// This package and all dependencies opted into null safety.
- compliant,
-
- /// This package opted into null safety, but some file or dependency is not
- /// opted in.
- mixed,
-
- /// This package did not opt-in to null safety yet.
- notCompliant,
-
- /// The resolution failed. Or some dart file in a dependency
- /// doesn't parse.
- analysisFailed,
-}
-
-class NullSafetyAnalysis {
- static const String guideUrl = 'https://dart.dev/null-safety/migration-guide';
- final SystemCache _systemCache;
-
- /// A cache of the analysis done for a single package-version, not taking
- /// dependencies into account. (Only the sdk constraint and no-files-opt-out).
- ///
- /// This allows us to reuse the analysis of the same package-version when
- /// used as a dependency from different packages.
- ///
- /// Furthermore by awaiting the Future stored here, we avoid race-conditions
- /// from downloading the same package-version into [_systemCache]
- /// simultaneously when doing concurrent analyses.
- final Map<PackageId, Future<NullSafetyAnalysisResult>>
- _packageInternallyGoodCache = {};
-
- NullSafetyAnalysis(SystemCache systemCache) : _systemCache = systemCache;
-
- /// Decides if package version [packageId] and all its non-dev
- /// dependencies (transitively) have a language version opting in to
- /// null-safety and no files in lib/ of these packages opt out to a
- /// pre-null-safety language version.
- ///
- /// This will do a full resolution of that package's import graph, and also
- /// download the package and all dependencies into [cache].
- ///
- /// To avoid race conditions on downloading to the cache, only one instance
- /// should be computing nullSafetyCompliance simultaneously with the same
- /// cache.
- ///
- /// If [packageId] is a relative path dependency [containingPath] must be
- /// provided with an absolute path to resolve it against.
- Future<NullSafetyAnalysisResult> nullSafetyCompliance(
- PackageId packageId,
- ) async {
- final description = packageId.description.description;
- final rootPubspec = await _systemCache.describe(packageId);
-
- // A space in the name prevents clashes with other package names.
- final fakeRootName = '${packageId.name} importer';
- final fakeRoot = Package.inMemory(Pubspec(fakeRootName,
- fields: {
- 'dependencies': {
- packageId.name: {
- packageId.source.name: description.serializeForPubspec(
- containingDir: null,
- languageVersion:
- LanguageVersion.firstVersionWithShorterHostedSyntax),
- 'version': packageId.version.toString(),
- }
- }
- },
- sources: _systemCache.sources,
- sdkConstraints: {'dart': rootPubspec.dartSdkConstraint}));
-
- final rootLanguageVersion = rootPubspec.languageVersion;
- if (!rootLanguageVersion.supportsNullSafety) {
- final span =
- _tryGetSpanFromYamlMap(rootPubspec.fields['environment'], 'sdk');
- final where = span == null
- ? 'in the sdk constraint in the enviroment key in pubspec.yaml.'
- : 'in pubspec.yaml: \n${span.highlight()}';
- return NullSafetyAnalysisResult(
- NullSafetyCompliance.notCompliant,
- 'Is not opting in to null safety $where',
- );
- }
-
- SolveResult result;
- try {
- result = await resolveVersions(
- SolveType.get,
- _systemCache,
- fakeRoot,
- );
- } on SolveFailure catch (e) {
- return NullSafetyAnalysisResult(NullSafetyCompliance.analysisFailed,
- 'Could not resolve constraints: $e');
- }
- return nullSafetyComplianceOfPackages(
- result.packages.where((id) => id.name != fakeRootName),
- Package(
- rootPubspec,
- _systemCache.getDirectory(packageId),
- ),
- );
- }
-
- /// Decides if all dependendencies (transitively) have a language version
- /// opting in to null safety, and no files in lib/ of these packages, nor the
- /// root package opt out to a pre-null-safety language version.
- ///
- /// [rootPubspec] is the pubspec of the root package.
- // TODO(sigurdm): make a source for the root package. Then we should not need
- // to pass this.
- ///
- /// This will download all dependencies into [cache].
- ///
- /// Assumes the root package is opted in.
- Future<NullSafetyAnalysisResult> nullSafetyComplianceOfPackages(
- Iterable<PackageId> packages,
- Package rootPackage,
- ) async {
- NullSafetyAnalysisResult? firstBadPackage;
- for (final dependencyId in packages) {
- final packageInternalAnalysis =
- await _packageInternallyGoodCache.putIfAbsent(dependencyId, () async {
- Pubspec pubspec;
- Source? source;
- String packageDir;
- if (dependencyId.isRoot) {
- pubspec = rootPackage.pubspec;
- packageDir = rootPackage.dir;
- } else {
- source = dependencyId.source;
- pubspec = await _systemCache.describe(dependencyId);
- packageDir = _systemCache.getDirectory(dependencyId);
- }
-
- if (!pubspec.languageVersion.supportsNullSafety) {
- final span =
- _tryGetSpanFromYamlMap(pubspec.fields['environment'], 'sdk');
- final where = span == null
- ? 'in the sdk constraint in the environment key in its pubspec.yaml.'
- : 'in its pubspec.yaml:\n${span.highlight()}';
- return NullSafetyAnalysisResult(
- NullSafetyCompliance.notCompliant,
- 'package:${dependencyId.name} is not opted into null safety $where',
- );
- }
-
- if (source is CachedSource) {
- // TODO(sigurdm): Consider using withDependencyType here.
- await source.downloadToSystemCache(dependencyId, _systemCache);
- }
-
- final libDir =
- path.absolute(path.normalize(path.join(packageDir, 'lib')));
- if (dirExists(libDir)) {
- var contextCollection = AnalysisContextCollection(
- includedPaths: [path.normalize(packageDir)],
- resourceProvider: PhysicalResourceProvider.INSTANCE,
- sdkPath: getSdkPath(),
- );
- var analysisContext = contextCollection.contexts.first;
- var analysisSession = analysisContext.currentSession;
-
- for (final file in listDir(libDir,
- recursive: true, includeDirs: false, includeHidden: true)) {
- if (file.endsWith('.dart')) {
- final fileUrl =
- 'package:${dependencyId.name}/${path.relative(file, from: libDir)}';
- final someUnitResult =
- analysisSession.getParsedUnit(path.normalize(file));
- ParsedUnitResult unitResult;
- if (someUnitResult is ParsedUnitResult) {
- unitResult = someUnitResult;
- } else {
- return NullSafetyAnalysisResult(
- NullSafetyCompliance.analysisFailed,
- 'Could not analyze $fileUrl.');
- }
- if (unitResult.errors.isNotEmpty) {
- return NullSafetyAnalysisResult(
- NullSafetyCompliance.analysisFailed,
- 'Could not analyze $fileUrl.');
- }
- if (unitResult.isPart) continue;
- final languageVersionToken = unitResult.unit.languageVersionToken;
- if (languageVersionToken == null) continue;
- final languageVersion = LanguageVersion.fromLanguageVersionToken(
- languageVersionToken);
- if (!languageVersion.supportsNullSafety) {
- final sourceFile =
- SourceFile.fromString(readTextFile(file), url: fileUrl);
- final span = sourceFile.span(languageVersionToken.offset,
- languageVersionToken.offset + languageVersionToken.length);
- return NullSafetyAnalysisResult(
- NullSafetyCompliance.notCompliant,
- '$fileUrl is opting out of null safety:\n${span.highlight()}');
- }
- }
- }
- }
- return NullSafetyAnalysisResult(NullSafetyCompliance.compliant, null);
- });
- if (packageInternalAnalysis.compliance ==
- NullSafetyCompliance.analysisFailed) {
- return packageInternalAnalysis;
- }
- if (packageInternalAnalysis.compliance ==
- NullSafetyCompliance.notCompliant) {
- firstBadPackage ??= packageInternalAnalysis;
- }
- }
-
- if (firstBadPackage == null) {
- return NullSafetyAnalysisResult(NullSafetyCompliance.compliant, null);
- }
- if (firstBadPackage.compliance == NullSafetyCompliance.analysisFailed) {
- return firstBadPackage;
- }
- return NullSafetyAnalysisResult(
- NullSafetyCompliance.mixed, firstBadPackage.reason);
- }
-}
-
-class NullSafetyAnalysisResult {
- final NullSafetyCompliance compliance;
-
- /// `null` if compliance == [NullSafetyCompliance.compliant].
- final String? reason;
-
- NullSafetyAnalysisResult(this.compliance, this.reason);
-}
-
-SourceSpan? _tryGetSpanFromYamlMap(Object? map, String key) {
- if (map is YamlMap) {
- return map.nodes[key]?.span;
- }
- return null;
-}
diff --git a/lib/src/oauth2.dart b/lib/src/oauth2.dart
index 4715014..b51fdfb 100644
--- a/lib/src/oauth2.dart
+++ b/lib/src/oauth2.dart
@@ -23,9 +23,11 @@
/// The global HTTP client with basic retries. Used instead of retryForHttp for
/// OAuth calls because the OAuth2 package requires a client to be passed. While
/// the retry logic is more basic, this is fine for the publishing process.
-final _retryHttpClient = RetryClient(globalHttpClient,
- when: (response) => response.statusCode >= 500,
- whenError: (e, _) => isHttpIOException(e));
+final _retryHttpClient = RetryClient(
+ globalHttpClient,
+ when: (response) => response.statusCode >= 500,
+ whenError: (e, _) => isHttpIOException(e),
+);
/// The pub client's OAuth2 identifier.
const _identifier = '818368855108-8grd2eg9tj9f38os6f1urbcvsq399u8n.apps.'
@@ -105,7 +107,8 @@
}
} else {
log.message(
- 'No existing credentials file $credentialsFile. Cannot log out.');
+ 'No existing credentials file $credentialsFile. Cannot log out.',
+ );
}
}
@@ -153,12 +156,14 @@
var credentials = loadCredentials(cache);
if (credentials == null) return await _authorize();
- var client = Client(credentials,
- identifier: _identifier,
- secret: _secret,
- // Google's OAuth2 API doesn't support basic auth.
- basicAuth: false,
- httpClient: _retryHttpClient);
+ var client = Client(
+ credentials,
+ identifier: _identifier,
+ secret: _secret,
+ // Google's OAuth2 API doesn't support basic auth.
+ basicAuth: false,
+ httpClient: _retryHttpClient,
+ );
_saveCredentials(cache, client.credentials);
return client;
}
@@ -232,12 +237,13 @@
///
/// Returns a Future that completes to a fully-authorized [Client].
Future<Client> _authorize() async {
- var grant =
- AuthorizationCodeGrant(_identifier, _authorizationEndpoint, tokenEndpoint,
- secret: _secret,
- // Google's OAuth2 API doesn't support basic auth.
- basicAuth: false,
- httpClient: _retryHttpClient);
+ var grant = AuthorizationCodeGrant(
+ _identifier, _authorizationEndpoint, tokenEndpoint,
+ secret: _secret,
+ // Google's OAuth2 API doesn't support basic auth.
+ basicAuth: false,
+ httpClient: _retryHttpClient,
+ );
// Spin up a one-shot HTTP server to receive the authorization code from the
// Google OAuth2 server via redirect. This server will close itself as soon as
@@ -261,8 +267,9 @@
});
var authUrl = grant.getAuthorizationUrl(
- Uri.parse('http://localhost:${server.port}'),
- scopes: _scopes);
+ Uri.parse('http://localhost:${server.port}'),
+ scopes: _scopes,
+ );
log.message(
'Pub needs your authorization to upload packages on your behalf.\n'
diff --git a/lib/src/package.dart b/lib/src/package.dart
index f1e9c1d..4c1efe9 100644
--- a/lib/src/package.dart
+++ b/lib/src/package.dart
@@ -39,7 +39,8 @@
String get dir {
if (isInMemory) {
throw UnsupportedError(
- 'Package directory cannot be used for an in-memory package');
+ 'Package directory cannot be used for an in-memory package',
+ );
}
return _dir!;
@@ -105,8 +106,10 @@
// git repo. `git check-ignore` will return a status code of 0 for
// ignored, 1 for not ignored, and 128 for not a Git repo.
var result = runProcessSync(
- git.command!, ['check-ignore', '--quiet', '.'],
- workingDir: dir);
+ git.command!,
+ ['check-ignore', '--quiet', '.'],
+ workingDir: dir,
+ );
return result.exitCode == 1;
}
}
@@ -125,8 +128,12 @@
SourceRegistry sources, {
bool withPubspecOverrides = false,
}) {
- final pubspec = Pubspec.load(dir, sources,
- expectedName: name, allowOverridesFile: withPubspecOverrides);
+ final pubspec = Pubspec.load(
+ dir,
+ sources,
+ expectedName: name,
+ allowOverridesFile: withPubspecOverrides,
+ );
return Package._(dir, pubspec);
}
@@ -148,13 +155,15 @@
/// This is similar to `p.join(dir, part1, ...)`, except that subclasses may
/// override it to report that certain paths exist elsewhere than within
/// [dir].
- String path(String? part1,
- [String? part2,
- String? part3,
- String? part4,
- String? part5,
- String? part6,
- String? part7]) {
+ String path(
+ String? part1, [
+ String? part2,
+ String? part3,
+ String? part4,
+ String? part5,
+ String? part6,
+ String? part7,
+ ]) {
if (isInMemory) {
throw StateError("Package $name is in-memory and doesn't have paths "
'on disk.');
@@ -220,8 +229,11 @@
var packageDir = dir;
var root = git.repoRoot(packageDir) ?? packageDir;
beneath = p
- .toUri(p.normalize(
- p.relative(p.join(packageDir, beneath ?? '.'), from: root)))
+ .toUri(
+ p.normalize(
+ p.relative(p.join(packageDir, beneath ?? '.'), from: root),
+ ),
+ )
.path;
if (beneath == './') beneath = '.';
String resolve(String path) {
@@ -243,11 +255,13 @@
final target = Link(entity.path).targetSync();
if (dirExists(entity.path)) {
throw DataException(
- '''Pub does not support publishing packages with directory symlinks: `${entity.path}`.''');
+ '''Pub does not support publishing packages with directory symlinks: `${entity.path}`.''',
+ );
}
if (!fileExists(entity.path)) {
throw DataException(
- '''Pub does not support publishing packages with non-resolving symlink: `${entity.path}` => `$target`.''');
+ '''Pub does not support publishing packages with non-resolving symlink: `${entity.path}` => `$target`.''',
+ );
}
}
final relative = p.relative(entity.path, from: root);
@@ -274,7 +288,8 @@
rules,
onInvalidPattern: (pattern, exception) {
log.warning(
- '$ignoreFile had invalid pattern $pattern. ${exception.message}');
+ '$ignoreFile had invalid pattern $pattern. ${exception.message}',
+ );
},
// Ignore case on MacOs and Windows, because `git clone` and
// `git init` will set `core.ignoreCase = true` in the local
diff --git a/lib/src/package_config.dart b/lib/src/package_config.dart
index dec8b5c..f5ef0b0 100644
--- a/lib/src/package_config.dart
+++ b/lib/src/package_config.dart
@@ -64,7 +64,8 @@
void throwFormatException(String property, String mustBe) =>
throw FormatException(
- '"$property" in .dart_tool/package_config.json $mustBe');
+ '"$property" in .dart_tool/package_config.json $mustBe',
+ );
/// Read the 'configVersion' property
final configVersion = root['configVersion'];
@@ -73,7 +74,9 @@
}
if (configVersion != 2) {
throwFormatException(
- 'configVersion', 'must be 2 (the only supported version)');
+ 'configVersion',
+ 'must be 2 (the only supported version)',
+ );
}
final packagesRaw = root['packages'];
@@ -99,7 +102,8 @@
final generator = root['generator'];
if (generator != null && generator is! String) {
throw FormatException(
- '"generator" in package_config.json must be a string, if given');
+ '"generator" in package_config.json must be a string, if given',
+ );
}
// Read the 'generatorVersion' property
@@ -112,24 +116,31 @@
try {
generatorVersion = Version.parse(generatorVersionRaw);
} on FormatException catch (e) {
- throwFormatException('generatorVersion',
- 'must be a semver version, if given, error: ${e.message}');
+ throwFormatException(
+ 'generatorVersion',
+ 'must be a semver version, if given, error: ${e.message}',
+ );
}
}
return PackageConfig(
- configVersion: configVersion as int,
- packages: packages,
- generated: generated,
- generator: generator,
- generatorVersion: generatorVersion,
- additionalProperties: Map.fromEntries(root.entries.where((e) => !{
- 'configVersion',
- 'packages',
- 'generated',
- 'generator',
- 'generatorVersion',
- }.contains(e.key))));
+ configVersion: configVersion as int,
+ packages: packages,
+ generated: generated,
+ generator: generator,
+ generatorVersion: generatorVersion,
+ additionalProperties: Map.fromEntries(
+ root.entries.where(
+ (e) => !{
+ 'configVersion',
+ 'packages',
+ 'generated',
+ 'generator',
+ 'generatorVersion',
+ }.contains(e.key),
+ ),
+ ),
+ );
}
/// Convert to JSON structure.
@@ -196,13 +207,15 @@
factory PackageConfigEntry.fromJson(Object data) {
if (data is! Map<String, dynamic>) {
throw FormatException(
- 'packages[] entries in package_config.json must be JSON objects');
+ 'packages[] entries in package_config.json must be JSON objects',
+ );
}
final root = data;
Never throwFormatException(String property, String mustBe) =>
throw FormatException(
- '"packages[].$property" in .dart_tool/package_config.json $mustBe');
+ '"packages[].$property" in .dart_tool/package_config.json $mustBe',
+ );
final name = root['name'];
if (name is! String) {
@@ -246,7 +259,9 @@
languageVersion = LanguageVersion.parse(languageVersionRaw);
} on FormatException {
throwFormatException(
- 'languageVersion', 'must be on the form <major>.<minor>');
+ 'languageVersion',
+ 'must be on the form <major>.<minor>',
+ );
}
}
diff --git a/lib/src/package_graph.dart b/lib/src/package_graph.dart
index 6c736e6..db2b02d 100644
--- a/lib/src/package_graph.dart
+++ b/lib/src/package_graph.dart
@@ -32,7 +32,9 @@
/// This is generally faster than loading a package graph from scratch, since
/// the packages' pubspecs are already fully-parsed.
factory PackageGraph.fromSolveResult(
- Entrypoint entrypoint, SolveResult result) {
+ Entrypoint entrypoint,
+ SolveResult result,
+ ) {
final packages = {
for (final id in result.packages)
id.name: id.name == entrypoint.root.name
@@ -56,15 +58,20 @@
if (_transitiveDependencies == null) {
var closure = transitiveClosure(
- mapMap<String, Package, String, Iterable<String>>(packages,
- value: (_, package) => package.dependencies.keys));
+ mapMap<String, Package, String, Iterable<String>>(
+ packages,
+ value: (_, package) => package.dependencies.keys,
+ ),
+ );
_transitiveDependencies =
- mapMap<String, Set<String>, String, Set<Package>>(closure,
- value: (depender, names) {
- var set = names.map((name) => packages[name]!).toSet();
- set.add(packages[depender]!);
- return set;
- });
+ mapMap<String, Set<String>, String, Set<Package>>(
+ closure,
+ value: (depender, names) {
+ var set = names.map((name) => packages[name]!).toSet();
+ set.add(packages[depender]!);
+ return set;
+ },
+ );
}
return _transitiveDependencies![package]!;
}
diff --git a/lib/src/package_name.dart b/lib/src/package_name.dart
index 58f12dd..af1a24c 100644
--- a/lib/src/package_name.dart
+++ b/lib/src/package_name.dart
@@ -85,8 +85,11 @@
PackageId(this.name, this.version, this.description);
/// Creates an ID for the given root package.
- static PackageId root(Package package) => PackageId(package.name,
- package.version, ResolvedRootDescription(RootDescription(package)));
+ static PackageId root(Package package) => PackageId(
+ package.name,
+ package.version,
+ ResolvedRootDescription(RootDescription(package)),
+ );
@override
int get hashCode => Object.hash(name, version, description);
@@ -235,15 +238,18 @@
/// This defaults to `false`.
final bool showDescription;
- const PackageDetail(
- {this.showVersion, bool? showSource, bool? showDescription})
- : showSource = showDescription == true ? true : showSource,
+ const PackageDetail({
+ this.showVersion,
+ bool? showSource,
+ bool? showDescription,
+ }) : showSource = showDescription == true ? true : showSource,
showDescription = showDescription ?? false;
/// Returns a [PackageDetail] with the maximum amount of detail between [this]
/// and [other].
PackageDetail max(PackageDetail other) => PackageDetail(
- showVersion: showVersion! || other.showVersion!,
- showSource: showSource! || other.showSource!,
- showDescription: showDescription || other.showDescription);
+ showVersion: showVersion! || other.showVersion!,
+ showSource: showSource! || other.showSource!,
+ showDescription: showDescription || other.showDescription,
+ );
}
diff --git a/lib/src/progress.dart b/lib/src/progress.dart
index d29a9fb..a127ae5 100644
--- a/lib/src/progress.dart
+++ b/lib/src/progress.dart
@@ -5,6 +5,7 @@
import 'dart:async';
import 'dart:io';
+import 'io.dart';
import 'log.dart' as log;
import 'utils.dart';
@@ -39,7 +40,7 @@
// The animation is only shown when it would be meaningful to a human.
// That means we're writing a visible message to a TTY at normal log levels
// with non-JSON output.
- if (!canAnimateOutput ||
+ if (terminalOutputForStdout ||
!log.verbosity.isLevelVisible(level) ||
fine ||
log.verbosity.isLevelVisible(log.Level.fine)) {
diff --git a/lib/src/pub_embeddable_command.dart b/lib/src/pub_embeddable_command.dart
index c7c7f87..a12efe4 100644
--- a/lib/src/pub_embeddable_command.dart
+++ b/lib/src/pub_embeddable_command.dart
@@ -64,8 +64,12 @@
// This flag was never honored in the embedding but since it was accepted we
// leave it as a hidden flag to avoid breaking clients that pass it.
argParser.addFlag('trace', hide: true);
- argParser.addFlag('verbose',
- abbr: 'v', negatable: false, help: 'Print detailed logging.');
+ argParser.addFlag(
+ 'verbose',
+ abbr: 'v',
+ negatable: false,
+ help: 'Print detailed logging.',
+ );
PubTopLevel.addColorFlag(argParser);
argParser.addOption(
'directory',
diff --git a/lib/src/pubspec.dart b/lib/src/pubspec.dart
index f14133e..fba6887 100644
--- a/lib/src/pubspec.dart
+++ b/lib/src/pubspec.dart
@@ -41,6 +41,8 @@
String? get _packageName => fields['name'] != null ? name : null;
+ final bool dependencyOverridesFromOverridesFile;
+
/// The name of the manifest file.
static const pubspecYamlFilename = 'pubspec.yaml';
@@ -65,12 +67,13 @@
/// The additional packages this package depends on.
Map<String, PackageRange> get dependencies =>
_dependencies ??= _parseDependencies(
- 'dependencies',
- fields.nodes['dependencies'],
- _sources,
- languageVersion,
- _packageName,
- _location);
+ 'dependencies',
+ fields.nodes['dependencies'],
+ _sources,
+ languageVersion,
+ _packageName,
+ _location,
+ );
Map<String, PackageRange>? _dependencies;
@@ -152,7 +155,8 @@
constraint.max == null &&
defaultUpperBoundConstraint.allowsAny(constraint)) {
constraint = VersionConstraint.intersection(
- [constraint, defaultUpperBoundConstraint]);
+ [constraint, defaultUpperBoundConstraint],
+ );
}
// If a package is null safe it should also be compatible with dart 3.
// Therefore we rewrite a null-safety enabled constraint with the upper
@@ -201,8 +205,10 @@
? _defaultUpperBoundSdkConstraint
: VersionConstraint.any;
} else if (yaml is! YamlMap) {
- _error('"environment" field must be a map.',
- parent.nodes['environment']!.span);
+ _error(
+ '"environment" field must be a map.',
+ parent.nodes['environment']!.span,
+ );
} else {
originalDartSdkConstraint = _parseVersionConstraint(
yaml.nodes['sdk'],
@@ -257,17 +263,22 @@
///
/// If [allowOverridesFile] is `true` [pubspecOverridesFilename] is loaded and
/// is allowed to override dependency_overrides from `pubspec.yaml`.
- factory Pubspec.load(String packageDir, SourceRegistry sources,
- {String? expectedName, bool allowOverridesFile = false}) {
+ factory Pubspec.load(
+ String packageDir,
+ SourceRegistry sources, {
+ String? expectedName,
+ bool allowOverridesFile = false,
+ }) {
var pubspecPath = path.join(packageDir, pubspecYamlFilename);
var overridesPath = path.join(packageDir, pubspecOverridesFilename);
if (!fileExists(pubspecPath)) {
throw FileException(
- // Make the package dir absolute because for the entrypoint it'll just
- // be ".", which may be confusing.
- 'Could not find a file named "pubspec.yaml" in '
- '"${canonicalize(packageDir)}".',
- pubspecPath);
+ // Make the package dir absolute because for the entrypoint it'll just
+ // be ".", which may be confusing.
+ 'Could not find a file named "pubspec.yaml" in '
+ '"${canonicalize(packageDir)}".',
+ pubspecPath,
+ );
}
String? overridesFileContents =
allowOverridesFile && fileExists(overridesPath)
@@ -293,6 +304,7 @@
Map? fields,
SourceRegistry? sources,
Map<String, SdkConstraint>? sdkConstraints,
+ this.dependencyOverridesFromOverridesFile = false,
}) : _dependencies = dependencies == null
? null
: Map.fromIterable(dependencies, key: (range) => range.name),
@@ -330,18 +342,23 @@
}) : _overridesFileFields = overridesFields,
_includeDefaultSdkConstraint = true,
_givenSdkConstraints = null,
- super(fields is YamlMap
- ? fields
- : YamlMap.wrap(fields, sourceUrl: location)) {
+ dependencyOverridesFromOverridesFile = overridesFields != null &&
+ overridesFields.containsKey('dependency_overrides'),
+ super(
+ fields is YamlMap
+ ? fields
+ : YamlMap.wrap(fields, sourceUrl: location),
+ ) {
// If [expectedName] is passed, ensure that the actual 'name' field exists
// and matches the expectation.
if (expectedName == null) return;
if (name == expectedName) return;
throw SourceSpanApplicationException(
- '"name" field doesn\'t match expected name '
- '"$expectedName".',
- this.fields.nodes['name']!.span);
+ '"name" field doesn\'t match expected name '
+ '"$expectedName".',
+ this.fields.nodes['name']!.span,
+ );
}
/// Parses the pubspec stored at [location] whose text is [contents].
@@ -362,7 +379,8 @@
pubspecMap = _ensureMap(loadYamlNode(contents, sourceUrl: location));
if (overridesFileContents != null) {
overridesFileMap = _ensureMap(
- loadYamlNode(overridesFileContents, sourceUrl: overridesLocation));
+ loadYamlNode(overridesFileContents, sourceUrl: overridesLocation),
+ );
}
} on YamlException catch (error) {
throw SourceSpanApplicationException(error.message, error.span);
@@ -389,7 +407,9 @@
return node;
} else {
throw SourceSpanApplicationException(
- 'The pubspec must be a YAML mapping.', node.span);
+ 'The pubspec must be a YAML mapping.',
+ node.span,
+ );
}
}
@@ -486,30 +506,41 @@
sourceName ??= sourceNames.single;
if (sourceName is! String) {
- _error('A source name must be a string.',
- specMap.nodes.keys.single.span);
+ _error(
+ 'A source name must be a string.',
+ specMap.nodes.keys.single.span,
+ );
}
descriptionNode ??= specMap.nodes[sourceName];
} else {
- _error('A dependency specification must be a string or a mapping.',
- specNode.span);
+ _error(
+ 'A dependency specification must be a string or a mapping.',
+ specNode.span,
+ );
}
// Let the source validate the description.
- var ref = _wrapFormatException('description', descriptionNode?.span, () {
- String? pubspecDir;
- if (location != null && _isFileUri(location)) {
- pubspecDir = path.dirname(path.fromUri(location));
- }
+ var ref = _wrapFormatException(
+ 'description',
+ descriptionNode?.span,
+ () {
+ String? pubspecDir;
+ if (location != null && _isFileUri(location)) {
+ pubspecDir = path.dirname(path.fromUri(location));
+ }
- return sources(sourceName).parseRef(
- name,
- descriptionNode?.value,
- containingDir: pubspecDir,
- languageVersion: languageVersion,
- );
- }, packageName, fileType, targetPackage: name);
+ return sources(sourceName).parseRef(
+ name,
+ descriptionNode?.value,
+ containingDir: pubspecDir,
+ languageVersion: languageVersion,
+ );
+ },
+ packageName,
+ fileType,
+ targetPackage: name,
+ );
dependencies[name] = ref.withConstraint(versionConstraint);
},
@@ -530,7 +561,10 @@
/// max constraint if the original constraint doesn't have an upper bound and it
/// is compatible with [defaultUpperBoundConstraint].
VersionConstraint _parseVersionConstraint(
- YamlNode? node, String? packageName, _FileType fileType) {
+ YamlNode? node,
+ String? packageName,
+ _FileType fileType,
+) {
if (node?.value == null) {
return VersionConstraint.any;
}
@@ -538,10 +572,16 @@
_error('A version constraint must be a string.', node.span);
}
- return _wrapFormatException('version constraint', node.span, () {
- var constraint = VersionConstraint.parse(node.value);
- return constraint;
- }, packageName, fileType);
+ return _wrapFormatException(
+ 'version constraint',
+ node.span,
+ () {
+ var constraint = VersionConstraint.parse(node.value);
+ return constraint;
+ },
+ packageName,
+ fileType,
+ );
}
/// Runs [fn] and wraps any [FormatException] it throws in a
@@ -606,9 +646,10 @@
/// The constraint as interpreted by pub.
final VersionConstraint effectiveConstraint;
- SdkConstraint(this.effectiveConstraint,
- {VersionConstraint? originalConstraint})
- : originalConstraint = originalConstraint ?? effectiveConstraint;
+ SdkConstraint(
+ this.effectiveConstraint, {
+ VersionConstraint? originalConstraint,
+ }) : originalConstraint = originalConstraint ?? effectiveConstraint;
/// The language version of a constraint is determined from how it is written.
LanguageVersion get languageVersion =>
diff --git a/lib/src/pubspec_parse.dart b/lib/src/pubspec_parse.dart
index c6babfb..1ce064c 100644
--- a/lib/src/pubspec_parse.dart
+++ b/lib/src/pubspec_parse.dart
@@ -43,18 +43,24 @@
final name = fields['name'];
if (name == null) {
throw SourceSpanApplicationException(
- 'Missing the required "name" field.', fields.span);
+ 'Missing the required "name" field.',
+ fields.span,
+ );
} else if (name is! String) {
throw SourceSpanApplicationException(
- '"name" field must be a string.', fields.nodes['name']?.span);
+ '"name" field must be a string.',
+ fields.nodes['name']?.span,
+ );
} else if (!packageNameRegExp.hasMatch(name)) {
throw SourceSpanApplicationException(
- '"name" field must be a valid Dart identifier.',
- fields.nodes['name']?.span);
+ '"name" field must be a valid Dart identifier.',
+ fields.nodes['name']?.span,
+ );
} else if (reservedWords.contains(name)) {
throw SourceSpanApplicationException(
- '"name" field may not be a Dart reserved word.',
- fields.nodes['name']?.span);
+ '"name" field may not be a Dart reserved word.',
+ fields.nodes['name']?.span,
+ );
}
return name;
@@ -79,16 +85,20 @@
fixed = '$fixed.0';
}
_error(
- '"version" field must have three numeric components: major, '
- 'minor, and patch. Instead of "$version", consider "$fixed".',
- span);
+ '"version" field must have three numeric components: major, '
+ 'minor, and patch. Instead of "$version", consider "$fixed".',
+ span,
+ );
}
if (version is! String) {
_error('"version" field must be a string.', span);
}
_version = _wrapFormatException(
- 'version number', span, () => Version.parse(version));
+ 'version number',
+ span,
+ () => Version.parse(version),
+ );
return _version!;
}
@@ -183,8 +193,10 @@
if (yaml == null) return _executables!;
if (yaml is! Map) {
- _error('"executables" field must be a map.',
- fields.nodes['executables']?.span);
+ _error(
+ '"executables" field must be a map.',
+ fields.nodes['executables']?.span,
+ );
}
yaml.nodes.forEach((key, value) {
@@ -195,9 +207,10 @@
final keyPattern = RegExp(r'^[a-zA-Z0-9_-]+$');
if (!keyPattern.hasMatch(key.value)) {
_error(
- '"executables" keys may only contain letters, '
- 'numbers, hyphens and underscores.',
- key.span);
+ '"executables" keys may only contain letters, '
+ 'numbers, hyphens and underscores.',
+ key.span,
+ );
}
if (value.value == null) {
@@ -208,8 +221,10 @@
final valuePattern = RegExp(r'[/\\]');
if (valuePattern.hasMatch(value.value)) {
- _error('"executables" values may not contain path separators.',
- value.span);
+ _error(
+ '"executables" values may not contain path separators.',
+ value.span,
+ );
}
_executables![key.value] = value.value;
@@ -235,8 +250,11 @@
/// If [targetPackage] is provided, the value is used to describe the
/// dependency that caused the problem.
T _wrapFormatException<T>(
- String description, SourceSpan? span, T Function() fn,
- {String? targetPackage}) {
+ String description,
+ SourceSpan? span,
+ T Function() fn, {
+ String? targetPackage,
+ }) {
try {
return fn();
} on FormatException catch (e) {
diff --git a/lib/src/pubspec_utils.dart b/lib/src/pubspec_utils.dart
index 71e30c4..c46573a 100644
--- a/lib/src/pubspec_utils.dart
+++ b/lib/src/pubspec_utils.dart
@@ -2,14 +2,10 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'dart:async';
-
import 'package:pub_semver/pub_semver.dart';
import 'package_name.dart';
import 'pubspec.dart';
-import 'source/hosted.dart';
-import 'system_cache.dart';
/// Returns a new [Pubspec] without [original]'s dev_dependencies.
Pubspec stripDevDependencies(Pubspec original) {
@@ -39,63 +35,6 @@
);
}
-Future<Pubspec> constrainedToAtLeastNullSafetyPubspec(
- Pubspec original, SystemCache cache) async {
- /// Get the first version of [package] opting in to null-safety.
- Future<VersionConstraint> constrainToFirstWithNullSafety(
- PackageRange packageRange) async {
- final ref = packageRange.toRef();
- final available = await cache.getVersions(ref);
- if (available.isEmpty) {
- return stripUpperBound(packageRange.constraint);
- }
-
- available.sort((x, y) => x.version.compareTo(y.version));
-
- for (final p in available) {
- final pubspec = await cache.describe(p);
- if (pubspec.languageVersion.supportsNullSafety) {
- return VersionRange(min: p.version, includeMin: true);
- }
- }
- return stripUpperBound(packageRange.constraint);
- }
-
- Future<List<PackageRange>> allConstrainedToAtLeastNullSafety(
- Map<String, PackageRange> constrained,
- ) async {
- final result = await Future.wait(constrained.keys.map((name) async {
- final packageRange = constrained[name]!;
- var unconstrainedRange = packageRange;
-
- /// We only need to remove the upper bound if it is a hosted package.
- if (packageRange.description is HostedDescription) {
- unconstrainedRange = PackageRange(
- packageRange.toRef(),
- await constrainToFirstWithNullSafety(packageRange),
- );
- }
- return unconstrainedRange;
- }));
-
- return result;
- }
-
- final constrainedLists = await Future.wait([
- allConstrainedToAtLeastNullSafety(original.dependencies),
- allConstrainedToAtLeastNullSafety(original.devDependencies),
- ]);
-
- return Pubspec(
- original.name,
- version: original.version,
- sdkConstraints: original.sdkConstraints,
- dependencies: constrainedLists[0],
- devDependencies: constrainedLists[1],
- dependencyOverrides: original.dependencyOverrides.values,
- );
-}
-
/// Returns new pubspec with the same dependencies as [original] but with the
/// upper bounds of the constraints removed.
///
@@ -103,8 +42,10 @@
/// [stripOnly] will have their upper bounds removed. If [stripOnly] is
/// not specified or empty, then all packages will have their upper bounds
/// removed.
-Pubspec stripVersionUpperBounds(Pubspec original,
- {Iterable<String>? stripOnly}) {
+Pubspec stripVersionUpperBounds(
+ Pubspec original, {
+ Iterable<String>? stripOnly,
+}) {
ArgumentError.checkNotNull(original, 'original');
stripOnly ??= [];
diff --git a/lib/src/rate_limited_scheduler.dart b/lib/src/rate_limited_scheduler.dart
index 078acbb..0480b82 100644
--- a/lib/src/rate_limited_scheduler.dart
+++ b/lib/src/rate_limited_scheduler.dart
@@ -60,9 +60,10 @@
/// Jobs that have started running.
final Set<J> _started = {};
- RateLimitedScheduler(Future<V> Function(J) runJob,
- {required int maxConcurrentOperations})
- : _runJob = runJob,
+ RateLimitedScheduler(
+ Future<V> Function(J) runJob, {
+ required int maxConcurrentOperations,
+ }) : _runJob = runJob,
_pool = Pool(maxConcurrentOperations);
/// Pick the next task in [_queue] and run it.
diff --git a/lib/src/sdk.dart b/lib/src/sdk.dart
index 3962648..7da78c1 100644
--- a/lib/src/sdk.dart
+++ b/lib/src/sdk.dart
@@ -13,6 +13,9 @@
/// An SDK that can provide packages and on which pubspecs can express version
/// constraints.
abstract class Sdk {
+ /// Is this the Dart sdk?
+ bool get isDartSdk => identifier == 'dart';
+
/// This SDK's human-readable name.
String get name;
@@ -50,7 +53,8 @@
/// A map from SDK identifiers that appear in pubspecs to the implementations of
/// those SDKs.
final sdks = UnmodifiableMapView<String, Sdk>(
- {'dart': sdk, 'flutter': FlutterSdk(), 'fuchsia': FuchsiaSdk()});
+ {'dart': sdk, 'flutter': FlutterSdk(), 'fuchsia': FuchsiaSdk()},
+);
/// The core Dart SDK.
final sdk = DartSdk();
diff --git a/lib/src/solver/assignment.dart b/lib/src/solver/assignment.dart
index d4c7bdf..ecd244c 100644
--- a/lib/src/solver/assignment.dart
+++ b/lib/src/solver/assignment.dart
@@ -29,7 +29,11 @@
/// Creates a derivation: an assignment that's automatically propagated from
/// incompatibilities.
- Assignment.derivation(PackageRange package, bool isPositive, this.cause,
- this.decisionLevel, this.index)
- : super(package, isPositive);
+ Assignment.derivation(
+ PackageRange package,
+ bool isPositive,
+ this.cause,
+ this.decisionLevel,
+ this.index,
+ ) : super(package, isPositive);
}
diff --git a/lib/src/solver/failure.dart b/lib/src/solver/failure.dart
index 5af4015..ba4e69f 100644
--- a/lib/src/solver/failure.dart
+++ b/lib/src/solver/failure.dart
@@ -36,8 +36,10 @@
}
SolveFailure(this.incompatibility)
- : assert(incompatibility.terms.isEmpty ||
- incompatibility.terms.single.package.isRoot);
+ : assert(
+ incompatibility.terms.isEmpty ||
+ incompatibility.terms.single.package.isRoot,
+ );
/// Describes how [incompatibility] was derived, and thus why version solving
/// failed.
@@ -79,14 +81,18 @@
/// Populates [_derivations] for [incompatibility] and its transitive causes.
void _countDerivations(Incompatibility incompatibility) {
- _derivations.update(incompatibility, (value) => value + 1, ifAbsent: () {
- var cause = incompatibility.cause;
- if (cause is ConflictCause) {
- _countDerivations(cause.conflict);
- _countDerivations(cause.other);
- }
- return 1;
- });
+ _derivations.update(
+ incompatibility,
+ (value) => value + 1,
+ ifAbsent: () {
+ var cause = incompatibility.cause;
+ if (cause is ConflictCause) {
+ _countDerivations(cause.conflict);
+ _countDerivations(cause.other);
+ }
+ return 1;
+ },
+ );
}
String write() {
@@ -164,8 +170,11 @@
/// applicable). If [numbered] is true, this will associate a line number with
/// [incompatibility] and [message] so that the message can be easily referred
/// to later.
- void _write(Incompatibility incompatibility, String message,
- {bool numbered = false}) {
+ void _write(
+ Incompatibility incompatibility,
+ String message, {
+ bool numbered = false,
+ }) {
if (numbered) {
var number = _lineNumbers.length + 1;
_lineNumbers[incompatibility] = number;
@@ -183,9 +192,11 @@
///
/// The [detailsForIncompatibility] controls the amount of detail that should
/// be written for each package when converting [incompatibility] to a string.
- void _visit(Incompatibility incompatibility,
- Map<String, PackageDetail> detailsForIncompatibility,
- {bool conclusion = false}) {
+ void _visit(
+ Incompatibility incompatibility,
+ Map<String, PackageDetail> detailsForIncompatibility, {
+ bool conclusion = false,
+ }) {
// Add explicit numbers for incompatibilities that are written far away
// from their successors or that are used for multiple derivations.
var numbered = conclusion || _derivations[incompatibility]! > 1;
@@ -201,9 +212,11 @@
var conflictLine = _lineNumbers[conflictClause.conflict];
var otherLine = _lineNumbers[conflictClause.other];
if (conflictLine != null && otherLine != null) {
- _write(incompatibility,
- 'Because ${conflictClause.conflict.andToString(conflictClause.other, detailsForCause, conflictLine, otherLine)}, $incompatibilityString.',
- numbered: numbered);
+ _write(
+ incompatibility,
+ 'Because ${conflictClause.conflict.andToString(conflictClause.other, detailsForCause, conflictLine, otherLine)}, $incompatibilityString.',
+ numbered: numbered,
+ );
} else if (conflictLine != null || otherLine != null) {
Incompatibility withLine;
Incompatibility withoutLine;
@@ -220,10 +233,11 @@
_visit(withoutLine, detailsForCause);
_write(
- incompatibility,
- '$conjunction because ${withLine.toString(detailsForCause)} '
- '($line), $incompatibilityString.',
- numbered: numbered);
+ incompatibility,
+ '$conjunction because ${withLine.toString(detailsForCause)} '
+ '($line), $incompatibilityString.',
+ numbered: numbered,
+ );
} else {
var singleLineConflict = _isSingleLine(cause);
var singleLineOther = _isSingleLine(otherCause);
@@ -234,20 +248,24 @@
singleLineOther ? conflictClause.other : conflictClause.conflict;
_visit(first, detailsForCause);
_visit(second, detailsForCause);
- _write(incompatibility, 'Thus, $incompatibilityString.',
- numbered: numbered);
+ _write(
+ incompatibility,
+ 'Thus, $incompatibilityString.',
+ numbered: numbered,
+ );
} else {
_visit(conflictClause.conflict, {}, conclusion: true);
_lines.add(Pair('', null));
_visit(conflictClause.other, detailsForCause);
_write(
- incompatibility,
- '$conjunction because '
- '${conflictClause.conflict.toString(detailsForCause)} '
- '(${_lineNumbers[conflictClause.conflict]}), '
- '$incompatibilityString.',
- numbered: numbered);
+ incompatibility,
+ '$conjunction because '
+ '${conflictClause.conflict.toString(detailsForCause)} '
+ '(${_lineNumbers[conflictClause.conflict]}), '
+ '$incompatibilityString.',
+ numbered: numbered,
+ );
}
}
} else if (cause is ConflictCause || otherCause is ConflictCause) {
@@ -260,9 +278,11 @@
var derivedLine = _lineNumbers[derived];
if (derivedLine != null) {
- _write(incompatibility,
- 'Because ${ext.andToString(derived, detailsForCause, null, derivedLine)}, $incompatibilityString.',
- numbered: numbered);
+ _write(
+ incompatibility,
+ 'Because ${ext.andToString(derived, detailsForCause, null, derivedLine)}, $incompatibilityString.',
+ numbered: numbered,
+ );
} else if (_isCollapsible(derived)) {
var derivedCause = derived.cause as ConflictCause;
var collapsedDerived = derivedCause.conflict.cause is ConflictCause
@@ -273,31 +293,36 @@
: derivedCause.conflict;
detailsForCause = mergeMaps(
- detailsForCause, _detailsForCause(derivedCause),
- value: (detail1, detail2) => detail1.max(detail2));
+ detailsForCause,
+ _detailsForCause(derivedCause),
+ value: (detail1, detail2) => detail1.max(detail2),
+ );
_visit(collapsedDerived, detailsForCause);
_write(
- incompatibility,
- '$conjunction because '
- '${collapsedExt.andToString(ext, detailsForCause)}, '
- '$incompatibilityString.',
- numbered: numbered);
+ incompatibility,
+ '$conjunction because '
+ '${collapsedExt.andToString(ext, detailsForCause)}, '
+ '$incompatibilityString.',
+ numbered: numbered,
+ );
} else {
_visit(derived, detailsForCause);
_write(
- incompatibility,
- '$conjunction because ${ext.toString(detailsForCause)}, '
- '$incompatibilityString.',
- numbered: numbered);
+ incompatibility,
+ '$conjunction because ${ext.toString(detailsForCause)}, '
+ '$incompatibilityString.',
+ numbered: numbered,
+ );
}
} else {
_write(
- incompatibility,
- 'Because '
- '${conflictClause.conflict.andToString(conflictClause.other, detailsForCause)}, '
- '$incompatibilityString.',
- numbered: numbered);
+ incompatibility,
+ 'Because '
+ '${conflictClause.conflict.andToString(conflictClause.other, detailsForCause)}, '
+ '$incompatibilityString.',
+ numbered: numbered,
+ );
}
}
diff --git a/lib/src/solver/incompatibility.dart b/lib/src/solver/incompatibility.dart
index dbaf5bd..8b81501 100644
--- a/lib/src/solver/incompatibility.dart
+++ b/lib/src/solver/incompatibility.dart
@@ -77,16 +77,17 @@
}
return Incompatibility._(
- byName.values.expand((byRef) {
- // If there are any positive terms for a given package, we can discard
- // any negative terms.
- var positiveTerms =
- byRef.values.where((term) => term.isPositive).toList();
- if (positiveTerms.isNotEmpty) return positiveTerms;
+ byName.values.expand((byRef) {
+ // If there are any positive terms for a given package, we can discard
+ // any negative terms.
+ var positiveTerms =
+ byRef.values.where((term) => term.isPositive).toList();
+ if (positiveTerms.isNotEmpty) return positiveTerms;
- return byRef.values;
- }).toList(),
- cause);
+ return byRef.values;
+ }).toList(),
+ cause,
+ );
}
Incompatibility._(this.terms, this.cause);
@@ -121,13 +122,17 @@
assert(terms.first.isPositive);
var cause = this.cause as SdkCause;
- var buffer = StringBuffer(
- '${_terse(terms.first, details, allowEvery: true)} requires ');
- if (!cause.sdk.isAvailable) {
- buffer.write('the ${cause.sdk.name} SDK');
+ var buffer = StringBuffer(_terse(terms.first, details, allowEvery: true));
+ if (cause.noNullSafetyCause) {
+ buffer.write(' doesn\'t support null safety');
} else {
- if (cause.sdk.name != 'Dart') buffer.write('${cause.sdk.name} ');
- buffer.write('SDK version ${cause.constraint}');
+ buffer.write(' requires ');
+ if (!cause.sdk.isAvailable) {
+ buffer.write('the ${cause.sdk.name} SDK');
+ } else {
+ if (cause.sdk.name != 'Dart') buffer.write('${cause.sdk.name} ');
+ buffer.write('SDK version ${cause.constraint}');
+ }
}
return buffer.toString();
} else if (cause == IncompatibilityCause.noVersions) {
@@ -218,8 +223,12 @@
///
/// If [thisLine] and/or [otherLine] are passed, they indicate line numbers
/// that should be associated with [this] and [other], respectively.
- String andToString(Incompatibility other,
- [Map<String, PackageDetail>? details, int? thisLine, int? otherLine]) {
+ String andToString(
+ Incompatibility other, [
+ Map<String, PackageDetail>? details,
+ int? thisLine,
+ int? otherLine,
+ ]) {
var requiresBoth = _tryRequiresBoth(other, details, thisLine, otherLine);
if (requiresBoth != null) return requiresBoth;
@@ -242,8 +251,12 @@
/// and Y", this returns that expression.
///
/// Otherwise, this returns `null`.
- String? _tryRequiresBoth(Incompatibility other,
- [Map<String, PackageDetail>? details, int? thisLine, int? otherLine]) {
+ String? _tryRequiresBoth(
+ Incompatibility other, [
+ Map<String, PackageDetail>? details,
+ int? thisLine,
+ int? otherLine,
+ ]) {
if (terms.length == 1 || other.terms.length == 1) return null;
var thisPositive = _singleTermWhere((term) => term.isPositive);
@@ -277,8 +290,12 @@
/// Z", this returns that expression.
///
/// Otherwise, this returns `null`.
- String? _tryRequiresThrough(Incompatibility other,
- [Map<String, PackageDetail>? details, int? thisLine, int? otherLine]) {
+ String? _tryRequiresThrough(
+ Incompatibility other, [
+ Map<String, PackageDetail>? details,
+ int? thisLine,
+ int? otherLine,
+ ]) {
if (terms.length == 1 || other.terms.length == 1) return null;
var thisNegative = _singleTermWhere((term) => !term.isPositive);
@@ -340,10 +357,12 @@
buffer.write('requires ');
}
- buffer.write(latter.terms
- .where((term) => !term.isPositive)
- .map((term) => _terse(term, details))
- .join(' or '));
+ buffer.write(
+ latter.terms
+ .where((term) => !term.isPositive)
+ .map((term) => _terse(term, details))
+ .join(' or '),
+ );
if (latterLine != null) buffer.write(' ($latterLine)');
@@ -354,8 +373,12 @@
/// forbidden", this returns that expression.
///
/// Otherwise, this returns `null`.
- String? _tryRequiresForbidden(Incompatibility other,
- [Map<String, PackageDetail>? details, int? thisLine, int? otherLine]) {
+ String? _tryRequiresForbidden(
+ Incompatibility other, [
+ Map<String, PackageDetail>? details,
+ int? thisLine,
+ int? otherLine,
+ ]) {
if (terms.length != 1 && other.terms.length != 1) return null;
Incompatibility prior;
@@ -387,9 +410,11 @@
buffer.write('if $priorString then ');
} else {
buffer.write(_terse(positives.first, details, allowEvery: true));
- buffer.write(prior.cause == IncompatibilityCause.dependency
- ? ' depends on '
- : ' requires ');
+ buffer.write(
+ prior.cause == IncompatibilityCause.dependency
+ ? ' depends on '
+ : ' requires ',
+ );
}
if (latter.cause == IncompatibilityCause.unknownSource) {
@@ -410,12 +435,16 @@
buffer.write('but the latest version ($latest) is required');
} else if (latter.cause is SdkCause) {
var cause = latter.cause as SdkCause;
- buffer.write('which requires ');
- if (!cause.sdk.isAvailable) {
- buffer.write('the ${cause.sdk.name} SDK');
+ if (cause.noNullSafetyCause) {
+ buffer.write('which doesn\'t support null safety');
} else {
- if (cause.sdk.name != 'Dart') buffer.write('${cause.sdk.name} ');
- buffer.write('SDK version ${cause.constraint}');
+ buffer.write('which requires ');
+ if (!cause.sdk.isAvailable) {
+ buffer.write('the ${cause.sdk.name} SDK');
+ } else {
+ if (cause.sdk.name != 'Dart') buffer.write('${cause.sdk.name} ');
+ buffer.write('SDK version ${cause.constraint}');
+ }
}
} else if (latter.cause == IncompatibilityCause.noVersions) {
buffer.write("which doesn't match any versions");
@@ -455,8 +484,11 @@
///
/// If [allowEvery] is `true`, this will return "every version of foo" instead
/// of "foo any".
- String _terse(Term? term, Map<String, PackageDetail>? details,
- {bool allowEvery = false}) {
+ String _terse(
+ Term? term,
+ Map<String, PackageDetail>? details, {
+ bool allowEvery = false,
+ }) {
if (allowEvery && term!.constraint.isAny) {
return 'every version of ${_terseRef(term, details)}';
} else {
diff --git a/lib/src/solver/incompatibility_cause.dart b/lib/src/solver/incompatibility_cause.dart
index a2a2327..c8f2db8 100644
--- a/lib/src/solver/incompatibility_cause.dart
+++ b/lib/src/solver/incompatibility_cause.dart
@@ -5,6 +5,7 @@
import 'package:pub_semver/pub_semver.dart';
import '../exceptions.dart';
+import '../language_version.dart';
import '../sdk.dart';
import 'incompatibility.dart';
@@ -80,6 +81,11 @@
/// The SDK with which the package was incompatible.
final Sdk sdk;
+ bool get noNullSafetyCause =>
+ sdk.isDartSdk &&
+ !LanguageVersion.fromSdkConstraint(constraint).supportsNullSafety &&
+ sdk.version! >= Version(3, 0, 0).firstPreRelease;
+
@override
String? get notice {
// If the SDK is not available, then we have an actionable [hint] printed
@@ -96,6 +102,11 @@
@override
String? get hint {
+ if (noNullSafetyCause) {
+ return 'The lower bound of "sdk: \'$constraint\'" must be 2.12.0'
+ ' or higher to enable null safety.'
+ '\nFor details, see https://dart.dev/null-safety';
+ }
// If the SDK is available, then installing it won't help
if (sdk.isAvailable) {
return null;
diff --git a/lib/src/solver/package_lister.dart b/lib/src/solver/package_lister.dart
index f3b63b6..3dccd37 100644
--- a/lib/src/solver/package_lister.dart
+++ b/lib/src/solver/package_lister.dart
@@ -80,9 +80,12 @@
/// All versions of the package, sorted by [Version.compareTo].
Future<List<PackageId>> get _versions => _versionsMemo.runOnce(() async {
var cachedVersions = (await withDependencyType(
- _dependencyType,
- () => _systemCache.getVersions(_ref,
- allowedRetractedVersion: _allowedRetractedVersion)))
+ _dependencyType,
+ () => _systemCache.getVersions(
+ _ref,
+ allowedRetractedVersion: _allowedRetractedVersion,
+ ),
+ ))
..sort((id1, id2) => id1.version.compareTo(id2.version));
_cachedVersions = cachedVersions;
return cachedVersions;
@@ -97,14 +100,14 @@
/// Creates a package lister for the dependency identified by [_ref].
PackageLister(
- this._systemCache,
- this._ref,
- this._locked,
- this._dependencyType,
- this._overriddenPackages,
- this._allowedRetractedVersion,
- {bool downgrade = false})
- : _isDowngrade = downgrade;
+ this._systemCache,
+ this._ref,
+ this._locked,
+ this._dependencyType,
+ this._overriddenPackages,
+ this._allowedRetractedVersion, {
+ bool downgrade = false,
+ }) : _isDowngrade = downgrade;
/// Creates a package lister for the root [package].
PackageLister.root(Package package, this._systemCache)
@@ -189,14 +192,18 @@
Pubspec pubspec;
try {
pubspec = await withDependencyType(
- _dependencyType, () => _systemCache.describe(id));
+ _dependencyType,
+ () => _systemCache.describe(id),
+ );
} on SourceSpanApplicationException catch (error) {
// The lockfile for the pubspec couldn't be parsed,
log.fine('Failed to parse pubspec for $id:\n$error');
_knownInvalidVersions = _knownInvalidVersions.union(id.version);
return [
Incompatibility(
- [Term(id.toRange(), true)], IncompatibilityCause.noVersions)
+ [Term(id.toRange(), true)],
+ IncompatibilityCause.noVersions,
+ )
];
} on PackageNotFoundException {
// We can only get here if the lockfile refers to a specific package
@@ -204,7 +211,9 @@
_knownInvalidVersions = _knownInvalidVersions.union(id.version);
return [
Incompatibility(
- [Term(id.toRange(), true)], IncompatibilityCause.noVersions)
+ [Term(id.toRange(), true)],
+ IncompatibilityCause.noVersions,
+ )
];
}
@@ -219,10 +228,12 @@
if (!_matchesSdkConstraint(pubspec, sdk)) {
return [
Incompatibility(
- [Term(depender, true)],
- SdkCause(
- pubspec.sdkConstraints[sdk.identifier]?.effectiveConstraint,
- sdk))
+ [Term(depender, true)],
+ SdkCause(
+ pubspec.sdkConstraints[sdk.identifier]?.effectiveConstraint,
+ sdk,
+ ),
+ )
];
}
}
@@ -254,9 +265,11 @@
}
var versions = await _versions;
- var index = lowerBound(versions, id,
- compare: (dynamic id1, dynamic id2) =>
- id1.version.compareTo(id2.version));
+ var index = lowerBound(
+ versions,
+ id,
+ compare: (dynamic id1, dynamic id2) => id1.version.compareTo(id2.version),
+ );
assert(index < versions.length);
assert(versions[index].version == id.version);
@@ -284,24 +297,30 @@
return ordered(dependencies.keys).map((package) {
var constraint = VersionRange(
- min: lower[package],
- includeMin: true,
- max: upper[package],
- alwaysIncludeMaxPreRelease: true);
+ min: lower[package],
+ includeMin: true,
+ max: upper[package],
+ alwaysIncludeMaxPreRelease: true,
+ );
_alreadyListedDependencies[package] = constraint.union(
- _alreadyListedDependencies[package] ?? VersionConstraint.empty);
+ _alreadyListedDependencies[package] ?? VersionConstraint.empty,
+ );
return _dependency(
- _ref.withConstraint(constraint), dependencies[package]!);
+ _ref.withConstraint(constraint),
+ dependencies[package]!,
+ );
}).toList();
}
/// Returns an [Incompatibility] that represents a dependency from [depender]
/// onto [target].
Incompatibility _dependency(PackageRange depender, PackageRange target) =>
- Incompatibility([Term(depender, true), Term(target, false)],
- IncompatibilityCause.dependency);
+ Incompatibility(
+ [Term(depender, true), Term(target, false)],
+ IncompatibilityCause.dependency,
+ );
/// If the version at [index] in [_versions] isn't compatible with the current
/// version of [sdk], returns an [Incompatibility] indicating that.
@@ -316,12 +335,13 @@
var bounds = await _findBounds(index, (pubspec) => !allowsSdk(pubspec));
var incompatibleVersions = VersionRange(
- min: bounds.first == 0 ? null : versions[bounds.first].version,
- includeMin: true,
- max: bounds.last == versions.length - 1
- ? null
- : versions[bounds.last + 1].version,
- alwaysIncludeMaxPreRelease: true);
+ min: bounds.first == 0 ? null : versions[bounds.first].version,
+ includeMin: true,
+ max: bounds.last == versions.length - 1
+ ? null
+ : versions[bounds.last + 1].version,
+ alwaysIncludeMaxPreRelease: true,
+ );
_knownInvalidVersions = incompatibleVersions.union(_knownInvalidVersions);
var sdkConstraint = await foldAsync<VersionConstraint, PackageId>(
@@ -329,13 +349,15 @@
(previous, version) async {
var pubspec = await _describeSafe(version);
return previous.union(
- pubspec.sdkConstraints[sdk.identifier]?.effectiveConstraint ??
- VersionConstraint.any);
+ pubspec.sdkConstraints[sdk.identifier]?.effectiveConstraint ??
+ VersionConstraint.any,
+ );
});
return Incompatibility(
- [Term(_ref.withConstraint(incompatibleVersions), true)],
- SdkCause(sdkConstraint, sdk));
+ [Term(_ref.withConstraint(incompatibleVersions), true)],
+ SdkCause(sdkConstraint, sdk),
+ );
}
/// Returns the first and last indices in [_versions] of the contiguous set of
@@ -343,7 +365,9 @@
///
/// Assumes [match] returns true for the pubspec whose version is at [index].
Future<Pair<int, int>> _findBounds(
- int start, bool Function(Pubspec) match) async {
+ int start,
+ bool Function(Pubspec) match,
+ ) async {
var versions = await _versions;
var first = start - 1;
@@ -370,8 +394,10 @@
/// all versions above or below [index] (according to [upper]) have the same
/// dependency.
Future<Map<String, Version?>> _dependencyBounds(
- Map<String, PackageRange> dependencies, int index,
- {bool upper = true}) async {
+ Map<String, PackageRange> dependencies,
+ int index, {
+ bool upper = true,
+ }) async {
var versions = await _versions;
var bounds = <String, Version>{};
var previous = versions[index];
@@ -418,7 +444,9 @@
Future<Pubspec> _describeSafe(PackageId id) async {
try {
return await withDependencyType(
- _dependencyType, () => _systemCache.describe(id));
+ _dependencyType,
+ () => _systemCache.describe(id),
+ );
} catch (_) {
return Pubspec(id.name, version: id.version);
}
diff --git a/lib/src/solver/partial_solution.dart b/lib/src/solver/partial_solution.dart
index db36417..cc3aeaa 100644
--- a/lib/src/solver/partial_solution.dart
+++ b/lib/src/solver/partial_solution.dart
@@ -69,8 +69,15 @@
/// Adds an assignment of [package] as a derivation.
void derive(PackageRange package, bool isPositive, Incompatibility cause) {
- _assign(Assignment.derivation(
- package, isPositive, cause, decisionLevel, _assignments.length));
+ _assign(
+ Assignment.derivation(
+ package,
+ isPositive,
+ cause,
+ decisionLevel,
+ _assignments.length,
+ ),
+ );
}
/// Adds [assignment] to [_assignments] and [_positive] or [_negative].
diff --git a/lib/src/solver/reformat_ranges.dart b/lib/src/solver/reformat_ranges.dart
index 2229536..bcdde84 100644
--- a/lib/src/solver/reformat_ranges.dart
+++ b/lib/src/solver/reformat_ranges.dart
@@ -140,9 +140,12 @@
///
/// Otherwise, returns it as-is.
IncompatibilityCause _reformatCause(
- Map<PackageRef, PackageLister> packageListers,
- IncompatibilityCause cause) =>
+ Map<PackageRef, PackageLister> packageListers,
+ IncompatibilityCause cause,
+) =>
cause is ConflictCause
- ? ConflictCause(reformatRanges(packageListers, cause.conflict),
- reformatRanges(packageListers, cause.other))
+ ? ConflictCause(
+ reformatRanges(packageListers, cause.conflict),
+ reformatRanges(packageListers, cause.other),
+ )
: cause;
diff --git a/lib/src/solver/report.dart b/lib/src/solver/report.dart
index e9cd00e..1f57423 100644
--- a/lib/src/solver/report.dart
+++ b/lib/src/solver/report.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:path/path.dart' as p;
import 'package:pub_semver/pub_semver.dart';
import '../command_runner.dart';
@@ -9,6 +10,7 @@
import '../log.dart' as log;
import '../package.dart';
import '../package_name.dart';
+import '../pubspec.dart';
import '../source/hosted.dart';
import '../source/root.dart';
import '../system_cache.dart';
@@ -64,7 +66,6 @@
Future<bool> show() async {
final hasChanges = await _reportChanges();
_checkContentHashesMatchOldLockfile();
- await _reportOverrides();
return hasChanges;
}
@@ -239,22 +240,6 @@
return hasChanges;
}
- /// Displays a warning about the overrides currently in effect.
- Future<void> _reportOverrides() async {
- final output = StringBuffer();
-
- if (_root.dependencyOverrides.isNotEmpty) {
- output.writeln('Warning: You are using these overridden dependencies:');
-
- for (var name in ordered(_root.dependencyOverrides.keys)) {
- await _reportPackage(name, output,
- alwaysShow: true, highlightOverride: false);
- }
-
- warning(output.toString());
- }
- }
-
/// Displays a single-line message, number of discontinued packages
/// if discontinued packages are detected.
Future<void> reportDiscontinued() async {
@@ -288,8 +273,9 @@
// version is also not a pre-release or,
// - if the current version is pre-release then any upgraded version is
// considered.
- return versions.any((v) =>
- v > id.version && (id.version.isPreRelease || !v.isPreRelease));
+ return versions.any(
+ (v) => v > id.version && (id.version.isPreRelease || !v.isPreRelease),
+ );
}).length;
if (outdatedPackagesCount > 0) {
@@ -311,8 +297,11 @@
/// "(override)" next to overridden packages.
///
/// Returns true if the package had changed.
- Future<bool> _reportPackage(String name, StringBuffer output,
- {bool alwaysShow = false, bool highlightOverride = true}) async {
+ Future<bool> _reportPackage(
+ String name,
+ StringBuffer output, {
+ bool alwaysShow = false,
+ }) async {
var newId = _newLockFile.packages[name];
var oldId = _previousLockFile.packages[name];
var id = newId ?? oldId!;
@@ -417,7 +406,11 @@
}
if (_type == SolveType.get &&
- !(alwaysShow || changed || addedOrRemoved || message != null)) {
+ !(alwaysShow ||
+ changed ||
+ addedOrRemoved ||
+ message != null ||
+ isOverridden)) {
return changed || addedOrRemoved;
}
@@ -434,8 +427,11 @@
}
// Highlight overridden packages.
- if (isOverridden && highlightOverride) {
- output.write(" ${log.magenta('(overridden)')}");
+ if (isOverridden) {
+ final location = _root.pubspec.dependencyOverridesFromOverridesFile
+ ? ' in ${p.join(_root.dir, Pubspec.pubspecOverridesFilename)}'
+ : '';
+ output.write(' ${log.magenta('(overridden$location)')}');
}
if (message != null) output.write(' ${log.cyan(message)}');
diff --git a/lib/src/solver/result.dart b/lib/src/solver/result.dart
index d958b13..2be099e 100644
--- a/lib/src/solver/result.dart
+++ b/lib/src/solver/result.dart
@@ -83,7 +83,8 @@
// accept those packages even if their constraints don't match.
var nonOverrides = pubspecs.values
.where(
- (pubspec) => !_root.dependencyOverrides.containsKey(pubspec.name))
+ (pubspec) => !_root.dependencyOverrides.containsKey(pubspec.name),
+ )
.toList();
var sdkConstraints = <String, VersionConstraint>{};
@@ -113,13 +114,22 @@
.map((id) => id.name)
.toSet();
- return changed.union(_previousLockFile.packages.keys
- .where((package) => !availableVersions.containsKey(package))
- .toSet());
+ return changed.union(
+ _previousLockFile.packages.keys
+ .where((package) => !availableVersions.containsKey(package))
+ .toSet(),
+ );
}
- SolveResult(this._root, this._previousLockFile, this.packages, this.pubspecs,
- this.availableVersions, this.attemptedSolutions, this.resolutionTime);
+ SolveResult(
+ this._root,
+ this._previousLockFile,
+ this.packages,
+ this.pubspecs,
+ this.availableVersions,
+ this.attemptedSolutions,
+ this.resolutionTime,
+ );
/// Send analytics about the package resolution.
void sendAnalytics(PubAnalytics pubAnalytics) {
@@ -155,7 +165,8 @@
},
);
log.fine(
- 'Sending analytics hit for "pub-get" of ${package.name} version ${package.version} as dependency-kind $dependencyKind');
+ 'Sending analytics hit for "pub-get" of ${package.name} version ${package.version} as dependency-kind $dependencyKind',
+ );
}
analytics.sendTiming(
@@ -164,7 +175,8 @@
category: 'pub-get',
);
log.fine(
- 'Sending analytics timing "pub-get" took ${resolutionTime.inMilliseconds} miliseconds');
+ 'Sending analytics timing "pub-get" took ${resolutionTime.inMilliseconds} miliseconds',
+ );
}
@override
diff --git a/lib/src/solver/term.dart b/lib/src/solver/term.dart
index 48133f5..ac20cdc 100644
--- a/lib/src/solver/term.dart
+++ b/lib/src/solver/term.dart
@@ -45,7 +45,10 @@
SetRelation relation(Term other) {
if (package.name != other.package.name) {
throw ArgumentError.value(
- other, 'other', 'should refer to package ${package.name}');
+ other,
+ 'other',
+ 'should refer to package ${package.name}',
+ );
}
var otherConstraint = other.constraint;
@@ -115,7 +118,10 @@
Term? intersect(Term other) {
if (package.name != other.package.name) {
throw ArgumentError.value(
- other, 'other', 'should refer to package ${package.name}');
+ other,
+ 'other',
+ 'should refer to package ${package.name}',
+ );
}
if (_compatiblePackage(other.package)) {
@@ -124,7 +130,9 @@
var positive = isPositive ? this : other;
var negative = isPositive ? other : this;
return _nonEmptyTerm(
- positive.constraint.difference(negative.constraint), true);
+ positive.constraint.difference(negative.constraint),
+ true,
+ );
} else if (isPositive) {
// foo ^1.0.0 ∩ foo >=1.5.0 <3.0.0 → foo ^1.5.0
return _nonEmptyTerm(constraint.intersect(other.constraint), true);
diff --git a/lib/src/solver/version_solver.dart b/lib/src/solver/version_solver.dart
index 68e0dbf..1b341d4 100644
--- a/lib/src/solver/version_solver.dart
+++ b/lib/src/solver/version_solver.dart
@@ -77,17 +77,25 @@
final _stopwatch = Stopwatch();
- VersionSolver(this._type, this._systemCache, this._root, this._lockFile,
- Iterable<String> unlock)
- : _dependencyOverrides = _root.dependencyOverrides,
+ VersionSolver(
+ this._type,
+ this._systemCache,
+ this._root,
+ this._lockFile,
+ Iterable<String> unlock,
+ ) : _dependencyOverrides = _root.dependencyOverrides,
_unlock = {...unlock};
/// Finds a set of dependencies that match the root package's constraints, or
/// throws an error if no such set is available.
Future<SolveResult> solve() async {
_stopwatch.start();
- _addIncompatibility(Incompatibility(
- [Term(PackageRange.root(_root), false)], IncompatibilityCause.root));
+ _addIncompatibility(
+ Incompatibility(
+ [Term(PackageRange.root(_root), false)],
+ IncompatibilityCause.root,
+ ),
+ );
try {
return await _systemCache.hosted.withPrefetching(() async {
@@ -153,7 +161,8 @@
/// [incompatibility] is almost satisfied by [_solution], returns the
/// unsatisfied term's package name. Otherwise, returns `#none`.
dynamic /* String | #none | #conflict */ _propagateIncompatibility(
- Incompatibility incompatibility) {
+ Incompatibility incompatibility,
+ ) {
// The first entry in `incompatibility.terms` that's not yet satisfied by
// [_solution], if one exists. If we find more than one, [_solution] is
// inconclusive for [incompatibility] and we can't deduce anything.
@@ -187,7 +196,10 @@
_log("derived:${unsatisfied.isPositive ? ' not' : ''} "
'${unsatisfied.package}');
_solution.derive(
- unsatisfied.package, !unsatisfied.isPositive, incompatibility);
+ unsatisfied.package,
+ !unsatisfied.isPositive,
+ incompatibility,
+ );
return unsatisfied.package.name;
}
@@ -236,7 +248,9 @@
mostRecentSatisfier = satisfier;
} else if (mostRecentSatisfier.index < satisfier.index) {
previousSatisfierLevel = math.max(
- previousSatisfierLevel, mostRecentSatisfier.decisionLevel);
+ previousSatisfierLevel,
+ mostRecentSatisfier.decisionLevel,
+ );
mostRecentTerm = term;
mostRecentSatisfier = satisfier;
difference = null;
@@ -251,8 +265,10 @@
// satisfies the remainder.
difference = mostRecentSatisfier.difference(mostRecentTerm!);
if (difference != null) {
- previousSatisfierLevel = math.max(previousSatisfierLevel,
- _solution.satisfier(difference.inverse).decisionLevel);
+ previousSatisfierLevel = math.max(
+ previousSatisfierLevel,
+ _solution.satisfier(difference.inverse).decisionLevel,
+ );
}
}
}
@@ -297,7 +313,9 @@
if (difference != null) newTerms.add(difference.inverse);
incompatibility = Incompatibility(
- newTerms, ConflictCause(incompatibility, mostRecentSatisfier.cause!));
+ newTerms,
+ ConflictCause(incompatibility, mostRecentSatisfier.cause!),
+ );
newIncompatibility = true;
var partially = difference == null ? '' : ' partially';
@@ -324,9 +342,12 @@
// that will force a conflict for that package.
for (var candidate in unsatisfied) {
if (candidate.source is! UnknownSource) continue;
- _addIncompatibility(Incompatibility(
+ _addIncompatibility(
+ Incompatibility(
[Term(candidate.toRef().withConstraint(VersionConstraint.any), true)],
- IncompatibilityCause.unknownSource));
+ IncompatibilityCause.unknownSource,
+ ),
+ );
return candidate.name;
}
@@ -343,9 +364,12 @@
try {
version = await _packageLister(package).bestVersion(package.constraint);
} on PackageNotFoundException catch (error) {
- _addIncompatibility(Incompatibility(
+ _addIncompatibility(
+ Incompatibility(
[Term(package.toRef().withConstraint(VersionConstraint.any), true)],
- PackageNotFoundCause(error)));
+ PackageNotFoundCause(error),
+ ),
+ );
return package.name;
}
@@ -360,8 +384,12 @@
} else {
// If there are no versions that satisfy [package.constraint], add an
// incompatibility that indicates that.
- _addIncompatibility(Incompatibility(
- [Term(package, true)], IncompatibilityCause.noVersions));
+ _addIncompatibility(
+ Incompatibility(
+ [Term(package, true)],
+ IncompatibilityCause.noVersions,
+ ),
+ );
return package.name;
}
}
@@ -376,8 +404,10 @@
// back to unit propagation which will guide us to choose a better
// version.
conflict = conflict ||
- incompatibility.terms.every((term) =>
- term.package.name == package.name || _solution.satisfies(term));
+ incompatibility.terms.every(
+ (term) =>
+ term.package.name == package.name || _solution.satisfies(term),
+ );
}
if (!conflict) {
@@ -435,7 +465,8 @@
///
/// The version list will not contain any retracted package versions.
Future<Map<String, List<Version>>> _getAvailableVersions(
- List<PackageId> packages) async {
+ List<PackageId> packages,
+ ) async {
var availableVersions = <String, List<Version>>{};
for (var package in packages) {
// If the version list was never requested, use versions from cached
@@ -446,8 +477,10 @@
List<PackageId> ids;
try {
ids = package.source is HostedSource
- ? await _systemCache.getVersions(package.toRef(),
- maxAge: Duration(days: 3))
+ ? await _systemCache.getVersions(
+ package.toRef(),
+ maxAge: Duration(days: 3),
+ )
: [package];
} on Exception {
ids = <PackageId>[package];
@@ -476,13 +509,14 @@
};
return PackageLister(
- _systemCache,
- ref,
- locked,
- _root.dependencyType(package.name),
- overridden,
- _getAllowedRetracted(ref.name),
- downgrade: _type == SolveType.downgrade);
+ _systemCache,
+ ref,
+ locked,
+ _root.dependencyType(package.name),
+ overridden,
+ _getAllowedRetracted(ref.name),
+ downgrade: _type == SolveType.downgrade,
+ );
});
}
diff --git a/lib/src/source.dart b/lib/src/source.dart
index e7714eb..e5063d3 100644
--- a/lib/src/source.dart
+++ b/lib/src/source.dart
@@ -93,8 +93,12 @@
/// some in-memory source.
///
/// Throws a [FormatException] if the description is not valid.
- PackageId parseId(String name, Version version, description,
- {String? containingDir});
+ PackageId parseId(
+ String name,
+ Version version,
+ description, {
+ String? containingDir,
+ });
/// Returns the source's name.
@override
@@ -110,7 +114,10 @@
/// By default, this assumes that each description has a single version and
/// uses [describe] to get that version.
Future<List<PackageId>> doGetVersions(
- PackageRef ref, Duration? maxAge, SystemCache cache);
+ PackageRef ref,
+ Duration? maxAge,
+ SystemCache cache,
+ );
/// Loads the (possibly remote) pubspec for the package version identified by
/// [id].
@@ -130,8 +137,11 @@
///
/// If id is a relative path id, the directory will be relative from
/// [relativeFrom]. Returns an absolute path if [relativeFrom] is not passed.
- String doGetDirectory(PackageId id, SystemCache cache,
- {String? relativeFrom});
+ String doGetDirectory(
+ PackageId id,
+ SystemCache cache, {
+ String? relativeFrom,
+ });
/// Returns metadata about a given package-version.
///
@@ -162,9 +172,10 @@
/// with a version constraint.
abstract class Description {
Source get source;
- Object? serializeForPubspec(
- {required String? containingDir,
- required LanguageVersion languageVersion});
+ Object? serializeForPubspec({
+ required String? containingDir,
+ required LanguageVersion languageVersion,
+ });
/// Converts `this` into a human-friendly form to show the user.
///
diff --git a/lib/src/source/cached.dart b/lib/src/source/cached.dart
index f847c87..9818146 100644
--- a/lib/src/source/cached.dart
+++ b/lib/src/source/cached.dart
@@ -36,8 +36,11 @@
}
@override
- String doGetDirectory(PackageId id, SystemCache cache,
- {String? relativeFrom}) =>
+ String doGetDirectory(
+ PackageId id,
+ SystemCache cache, {
+ String? relativeFrom,
+ }) =>
getDirectoryInCache(id, cache);
String getDirectoryInCache(PackageId id, SystemCache cache);
diff --git a/lib/src/source/git.dart b/lib/src/source/git.dart
index d4015b3..1c4b2ac 100644
--- a/lib/src/source/git.dart
+++ b/lib/src/source/git.dart
@@ -50,7 +50,8 @@
final descriptionUrl = description['url'];
if (descriptionUrl is! String) {
throw FormatException(
- "The 'url' field of a description must be a string.");
+ "The 'url' field of a description must be a string.",
+ );
}
url = descriptionUrl;
@@ -81,8 +82,12 @@
}
@override
- PackageId parseId(String name, Version version, description,
- {String? containingDir}) {
+ PackageId parseId(
+ String name,
+ Version version,
+ description, {
+ String? containingDir,
+ }) {
if (description is! Map) {
throw FormatException("The description must be a map with a 'url' "
'key.');
@@ -102,17 +107,20 @@
final url = description['url'];
return PackageId(
- name,
- version,
- GitResolvedDescription(
- GitDescription(
- url: url,
- ref: ref ?? 'HEAD',
- path: _validatedPath(
- description['path'],
- ),
- containingDir: containingDir),
- resolvedRef));
+ name,
+ version,
+ GitResolvedDescription(
+ GitDescription(
+ url: url,
+ ref: ref ?? 'HEAD',
+ path: _validatedPath(
+ description['path'],
+ ),
+ containingDir: containingDir,
+ ),
+ resolvedRef,
+ ),
+ );
}
/// Throws a [FormatException] if [url] isn't a valid Git URL.
@@ -169,7 +177,8 @@
parsed.hasFragment ||
parsed.hasQuery) {
throw FormatException(
- "The 'path' field of the description must be a relative path URL.");
+ "The 'path' field of the description must be a relative path URL.",
+ );
}
if (!p.url.isWithin('.', path) && !p.url.equals('.', path)) {
throw FormatException(
@@ -276,8 +285,11 @@
var pubspec = await _describeUncached(ref, revision, cache);
return [
- PackageId(ref.name, pubspec.version,
- GitResolvedDescription(description, revision))
+ PackageId(
+ ref.name,
+ pubspec.version,
+ GitResolvedDescription(description, revision),
+ )
];
});
}
@@ -290,11 +302,13 @@
if (description is! GitResolvedDescription) {
throw StateError('Called with wrong ref');
}
- return _pool.withResource(() => _describeUncached(
- id.toRef(),
- description.resolvedRef,
- cache,
- ));
+ return _pool.withResource(
+ () => _describeUncached(
+ id.toRef(),
+ description.resolvedRef,
+ cache,
+ ),
+ );
}
/// Like [describeUncached], but takes a separate [ref] and Git [revision]
@@ -386,7 +400,8 @@
List<Package> getCachedPackages(SystemCache cache) {
// TODO(keertip): Implement getCachedPackages().
throw UnimplementedError(
- "The git source doesn't support listing its cached packages yet.");
+ "The git source doesn't support listing its cached packages yet.",
+ );
}
/// Resets all cached packages back to the pristine state of the Git
@@ -444,13 +459,15 @@
await git.run(['reset', '--hard', 'HEAD'], workingDir: package.dir);
result.add(
- RepairResult(package.name, package.version, this, success: true));
+ RepairResult(package.name, package.version, this, success: true),
+ );
} on git.GitException catch (error, stackTrace) {
log.error('Failed to reset ${log.bold(package.name)} '
'${package.version}. Error:\n$error');
log.fine(stackTrace);
result.add(
- RepairResult(package.name, package.version, this, success: false));
+ RepairResult(package.name, package.version, this, success: false),
+ );
// Delete the revision cache path, not the subdirectory that contains the package.
final repoRoot = git.repoRoot(package.dir);
@@ -642,8 +659,9 @@
}
String _revisionCachePath(PackageId id, SystemCache cache) => p.join(
- cache.rootDirForSource(this),
- '${_repoName(id.description.description as GitDescription)}-${(id.description as GitResolvedDescription).resolvedRef}');
+ cache.rootDirForSource(this),
+ '${_repoName(id.description.description as GitDescription)}-${(id.description as GitResolvedDescription).resolvedRef}',
+ );
/// Returns the path to the canonical clone of the repository referred to by
/// [id] (the one in `<system cache>/git/cache`).
@@ -728,8 +746,10 @@
required LanguageVersion languageVersion,
}) {
final relativeUrl = containingDir != null && relative
- ? p.url.relative(url,
- from: p.toUri(p.normalize(p.absolute(containingDir))).toString())
+ ? p.url.relative(
+ url,
+ from: p.toUri(p.normalize(p.absolute(containingDir))).toString(),
+ )
: url;
if (ref == 'HEAD' && path == '.') return relativeUrl;
return {
@@ -792,8 +812,10 @@
@override
Object? serializeForLockfile({required String? containingDir}) {
final url = description.relative && containingDir != null
- ? p.url.relative(description.url,
- from: Uri.file(p.absolute(containingDir)).toString())
+ ? p.url.relative(
+ description.url,
+ from: Uri.file(p.absolute(containingDir)).toString(),
+ )
: description.url;
return {
'url': url,
diff --git a/lib/src/source/hosted.dart b/lib/src/source/hosted.dart
index 2d481e4..f993366 100644
--- a/lib/src/source/hosted.dart
+++ b/lib/src/source/hosted.dart
@@ -168,7 +168,8 @@
).toString();
} on FormatException catch (e) {
throw ConfigException(
- 'Invalid `PUB_HOSTED_URL="${e.source}"`: ${e.message}');
+ 'Invalid `PUB_HOSTED_URL="${e.source}"`: ${e.message}',
+ );
}
}();
@@ -213,15 +214,25 @@
/// 1. With an url and an optional name in a map: `hosted: {url: <url>}`
/// 2. With a direct url: `hosted: <url>`
@override
- PackageRef parseRef(String name, description,
- {String? containingDir, required LanguageVersion languageVersion}) {
+ PackageRef parseRef(
+ String name,
+ description, {
+ String? containingDir,
+ required LanguageVersion languageVersion,
+ }) {
return PackageRef(
- name, _parseDescription(name, description, languageVersion));
+ name,
+ _parseDescription(name, description, languageVersion),
+ );
}
@override
- PackageId parseId(String name, Version version, description,
- {String? containingDir}) {
+ PackageId parseId(
+ String name,
+ Version version,
+ description, {
+ String? containingDir,
+ }) {
// Old pub versions only wrote `description: <pkg>` into the lock file.
if (description is String) {
if (description != name) {
@@ -292,7 +303,9 @@
// used as a package name.
if (canUseShorthandSyntax) {
return HostedDescription(
- packageName, validateAndNormalizeHostedUrl(description).toString());
+ packageName,
+ validateAndNormalizeHostedUrl(description).toString(),
+ );
} else {
if (_looksLikePackageName.hasMatch(description)) {
// Valid use of `hosted: package` dependency with an old SDK
@@ -341,7 +354,11 @@
);
List<_VersionInfo> _versionInfoFromPackageListing(
- Map body, PackageRef ref, Uri location, SystemCache cache) {
+ Map body,
+ PackageRef ref,
+ Uri location,
+ SystemCache cache,
+ ) {
final description = ref.description;
if (description is! HostedDescription) {
throw ArgumentError('Wrong source');
@@ -355,8 +372,12 @@
if (pubspecData is! Map) {
throw FormatException('pubspec must be a map');
}
- var pubspec = Pubspec.fromMap(pubspecData, cache.sources,
- expectedName: ref.name, location: location);
+ var pubspec = Pubspec.fromMap(
+ pubspecData,
+ cache.sources,
+ expectedName: ref.name,
+ location: location,
+ );
final archiveSha256 = map['archive_sha256'];
if (archiveSha256 != null && archiveSha256 is! String) {
throw FormatException('archive_sha256 must be a String');
@@ -381,7 +402,9 @@
}
Future<List<_VersionInfo>> _fetchVersionsNoPrefetching(
- PackageRef ref, SystemCache cache) async {
+ PackageRef ref,
+ SystemCache cache,
+ ) async {
final description = ref.description;
if (description is! HostedDescription) {
@@ -446,20 +469,24 @@
final latestVersion =
maxBy<_VersionInfo, Version>(listing, (e) => e.version)!;
final dependencies = latestVersion.pubspec.dependencies.values;
- unawaited(withDependencyType(DependencyType.none, () async {
- for (final packageRange in dependencies) {
- if (packageRange.source is HostedSource) {
- preschedule!(_RefAndCache(packageRange.toRef(), cache));
+ unawaited(
+ withDependencyType(DependencyType.none, () async {
+ for (final packageRange in dependencies) {
+ if (packageRange.source is HostedSource) {
+ preschedule!(_RefAndCache(packageRange.toRef(), cache));
+ }
}
- }
- }));
+ }),
+ );
}
final cache = refAndCache.cache;
if (preschedule != null) {
/// If we have a cached response - preschedule dependencies of that.
prescheduleDependenciesOfLatest(
- await _cachedVersionListingResponse(ref, cache), cache);
+ await _cachedVersionListingResponse(ref, cache),
+ cache,
+ );
}
final result = await _fetchVersionsNoPrefetching(ref, cache);
@@ -488,8 +515,10 @@
/// If [maxAge] is not given, we will try to get the cached version no matter
/// how old it is.
Future<List<_VersionInfo>?> _cachedVersionListingResponse(
- PackageRef ref, SystemCache cache,
- {Duration? maxAge}) async {
+ PackageRef ref,
+ SystemCache cache, {
+ Duration? maxAge,
+ }) async {
if (_responseCache.containsKey(ref)) {
final cacheAge = DateTime.now().difference(_responseCache[ref]!.first);
if (maxAge == null || maxAge > cacheAge) {
@@ -626,8 +655,12 @@
final dir = _urlToDirectory(description.url);
// Use a dot-dir because older versions of pub won't choke on that
// name when iterating the cache (it is not listed by [listDir]).
- return p.join(cache.rootDirForSource(this), dir, _versionListingDirectory,
- '${ref.name}-versions.json');
+ return p.join(
+ cache.rootDirForSource(this),
+ dir,
+ _versionListingDirectory,
+ '${ref.name}-versions.json',
+ );
}
static const _versionListingDirectory = '.cache';
@@ -729,7 +762,9 @@
/// new version-listings.
@override
Future<DownloadPackageResult> downloadToSystemCache(
- PackageId id, SystemCache cache) async {
+ PackageId id,
+ SystemCache cache,
+ ) async {
var didUpdate = false;
final packageDir = getDirectoryInCache(id, cache);
@@ -757,18 +792,21 @@
if (!fileExists(hashPath(id, cache))) {
if (dirExists(packageDir) && !cache.isOffline) {
log.fine(
- 'Cache entry for ${id.name}-${id.version} has no content-hash - redownloading.');
+ 'Cache entry for ${id.name}-${id.version} has no content-hash - redownloading.',
+ );
deleteEntry(packageDir);
}
} else if (expectedContentHash == null) {
// Can happen with a legacy server combined with a legacy lock file.
log.fine(
- 'Content-hash of ${id.name}-${id.version} not known from resolution.');
+ 'Content-hash of ${id.name}-${id.version} not known from resolution.',
+ );
} else {
final hashFromCache = sha256FromCache(id, cache);
if (!fixedTimeBytesEquals(hashFromCache, expectedContentHash)) {
log.warning(
- 'Cached version of ${id.name}-${id.version} has wrong hash - redownloading.');
+ 'Cached version of ${id.name}-${id.version} has wrong hash - redownloading.',
+ );
if (cache.isOffline) {
fail('Cannot redownload while offline. Try again without --offline.');
}
@@ -783,17 +821,19 @@
didUpdate = true;
if (cache.isOffline) {
fail(
- 'Missing package ${id.name}-${id.version}. Try again without --offline.');
+ 'Missing package ${id.name}-${id.version}. Try again without --offline.',
+ );
}
contentHash = await _download(id, packageDir, cache);
}
return DownloadPackageResult(
- PackageId(
- id.name,
- id.version,
- (id.description as ResolvedHostedDescription).withSha256(contentHash),
- ),
- didUpdate: didUpdate);
+ PackageId(
+ id.name,
+ id.version,
+ (id.description as ResolvedHostedDescription).withSha256(contentHash),
+ ),
+ didUpdate: didUpdate,
+ );
}
/// Determines if the package identified by [id] is already downloaded to the
@@ -803,8 +843,10 @@
if ((id.description as ResolvedHostedDescription).sha256 != null) {
try {
final cachedSha256 = readTextFile(hashPath(id, cache));
- if (!const ListEquality().equals(hexDecode(cachedSha256),
- (id.description as ResolvedHostedDescription).sha256)) {
+ if (!const ListEquality().equals(
+ hexDecode(cachedSha256),
+ (id.description as ResolvedHostedDescription).sha256,
+ )) {
return false;
}
} on io.IOException {
@@ -847,7 +889,11 @@
var serverDir = _urlToDirectory(description.url);
return p.join(
- rootDir, 'hosted-hashes', serverDir, '${id.name}-${id.version}.sha256');
+ rootDir,
+ 'hosted-hashes',
+ serverDir,
+ '${id.name}-${id.version}.sha256',
+ );
}
/// Loads the hash at `hashPath(id)`.
@@ -866,76 +912,85 @@
final rootDir = cache.rootDirForSource(this);
if (!dirExists(rootDir)) return [];
- return (await Future.wait(listDir(rootDir).map((serverDir) async {
- final directory = p.basename(serverDir);
- late final String url;
- try {
- url = _directoryToUrl(directory);
- } on FormatException {
- log.error('Unable to detect hosted url from directory: $directory');
- // If _directoryToUrl can't intepret a directory name, we just silently
- // ignore it and hope it's because it comes from a newer version of pub.
- //
- // This is most likely because someone manually modified PUB_CACHE.
- return <RepairResult>[];
- }
-
- final results = <RepairResult>[];
- var packages = <Package>[];
- for (var entry in listDir(serverDir)) {
+ return (await Future.wait(
+ listDir(rootDir).map((serverDir) async {
+ final directory = p.basename(serverDir);
+ late final String url;
try {
- packages.add(Package.load(null, entry, cache.sources));
- } catch (error, stackTrace) {
- log.error('Failed to load package', error, stackTrace);
- final id = _idForBasename(
- p.basename(entry),
- url,
- );
- results.add(
- RepairResult(
- id.name,
- id.version,
- this,
- success: false,
- ),
- );
- tryDeleteEntry(entry);
+ url = _directoryToUrl(directory);
+ } on FormatException {
+ log.error('Unable to detect hosted url from directory: $directory');
+ // If _directoryToUrl can't intepret a directory name, we just silently
+ // ignore it and hope it's because it comes from a newer version of pub.
+ //
+ // This is most likely because someone manually modified PUB_CACHE.
+ return <RepairResult>[];
}
- }
- // Delete the cached package listings.
- tryDeleteEntry(p.join(serverDir, _versionListingDirectory));
-
- packages.sort(Package.orderByNameAndVersion);
-
- return results
- ..addAll(await Future.wait(
- packages.map((package) async {
- var id = PackageId(
- package.name,
- package.version,
- ResolvedHostedDescription(
- HostedDescription(package.name, url),
- sha256: null,
+ final results = <RepairResult>[];
+ var packages = <Package>[];
+ for (var entry in listDir(serverDir)) {
+ try {
+ packages.add(Package.load(null, entry, cache.sources));
+ } catch (error, stackTrace) {
+ log.error('Failed to load package', error, stackTrace);
+ final id = _idForBasename(
+ p.basename(entry),
+ url,
+ );
+ results.add(
+ RepairResult(
+ id.name,
+ id.version,
+ this,
+ success: false,
),
);
- try {
- deleteEntry(package.dir);
- await _download(id, package.dir, cache);
- return RepairResult(id.name, id.version, this, success: true);
- } catch (error, stackTrace) {
- var message = 'Failed to repair ${log.bold(package.name)} '
- '${package.version}';
- if (url != defaultUrl) message += ' from $url';
- log.error('$message. Error:\n$error');
- log.fine(stackTrace);
+ tryDeleteEntry(entry);
+ }
+ }
- tryDeleteEntry(package.dir);
- return RepairResult(id.name, id.version, this, success: false);
- }
- }),
- ));
- })))
+ // Delete the cached package listings.
+ tryDeleteEntry(p.join(serverDir, _versionListingDirectory));
+
+ packages.sort(Package.orderByNameAndVersion);
+
+ return results
+ ..addAll(
+ await Future.wait(
+ packages.map((package) async {
+ var id = PackageId(
+ package.name,
+ package.version,
+ ResolvedHostedDescription(
+ HostedDescription(package.name, url),
+ sha256: null,
+ ),
+ );
+ try {
+ deleteEntry(package.dir);
+ await _download(id, package.dir, cache);
+ return RepairResult(id.name, id.version, this, success: true);
+ } catch (error, stackTrace) {
+ var message = 'Failed to repair ${log.bold(package.name)} '
+ '${package.version}';
+ if (url != defaultUrl) message += ' from $url';
+ log.error('$message. Error:\n$error');
+ log.fine(stackTrace);
+
+ tryDeleteEntry(package.dir);
+ return RepairResult(
+ id.name,
+ id.version,
+ this,
+ success: false,
+ );
+ }
+ }),
+ ),
+ );
+ }),
+ ))
.expand((x) => x);
}
@@ -1029,7 +1084,8 @@
late final Uint8List contentHash;
if (versionInfo == null) {
throw PackageNotFoundException(
- 'Package $packageName has no version $version');
+ 'Package $packageName has no version $version',
+ );
}
final archiveUrl = versionInfo.archiveUrl;
@@ -1055,7 +1111,8 @@
final actualHash = output.value;
if (expectedHash != null && output.value != expectedHash) {
log.fine(
- 'Expected content-hash for ${id.name}-${id.version} $expectedHash actual: ${output.value}.');
+ 'Expected content-hash for ${id.name}-${id.version} $expectedHash actual: ${output.value}.',
+ );
throw PackageIntegrityException('''
Downloaded archive for ${id.name}-${id.version} had wrong content-hash.
@@ -1088,10 +1145,16 @@
final expectedCrc32c = _parseCrc32c(response.headers, fileName);
if (expectedCrc32c != null) {
stream = _validateCrc32c(
- response.stream, expectedCrc32c, id, archiveUrl);
+ response.stream,
+ expectedCrc32c,
+ id,
+ archiveUrl,
+ );
}
stream = validateSha256(
- stream, (expectedSha256 == null) ? null : Digest(expectedSha256));
+ stream,
+ (expectedSha256 == null) ? null : Digest(expectedSha256),
+ );
// We download the archive to disk instead of streaming it directly
// into the tar unpacking. This simplifies stream handling.
@@ -1138,7 +1201,9 @@
/// The name, version and repository are decided from the pubspec.yaml that
/// must be present in the archive.
Future<PackageId> preloadPackage(
- String archivePath, SystemCache cache) async {
+ String archivePath,
+ SystemCache cache,
+ ) async {
// Extract to a temp-folder and do atomic rename to preserve the integrity
// of the cache.
late final Uint8List contentHash;
@@ -1153,15 +1218,16 @@
// It would be desirable to read the file only once, but the tar
// extraction closes the stream early making things tricky to get right.
contentHash = Uint8List.fromList(
- (await sha256.bind(readBinaryFileAsStream(archivePath)).first)
- .bytes);
+ (await sha256.bind(readBinaryFileAsStream(archivePath)).first).bytes,
+ );
await extractTarGz(readBinaryFileAsStream(archivePath), tempDir);
} on FormatException catch (e) {
dataError('Failed to extract `$archivePath`: ${e.message}.');
}
if (!fileExists(p.join(tempDir, 'pubspec.yaml'))) {
fail(
- 'Found no `pubspec.yaml` in $archivePath. Is it a valid pub package archive?');
+ 'Found no `pubspec.yaml` in $archivePath. Is it a valid pub package archive?',
+ );
}
final Pubspec pubspec;
try {
@@ -1192,7 +1258,8 @@
final packageDir = getDirectoryInCache(id, cache);
if (dirExists(packageDir)) {
log.fine(
- 'Cache entry for ${id.name}-${id.version} already exists. Replacing.');
+ 'Cache entry for ${id.name}-${id.version} already exists. Replacing.',
+ );
deleteEntry(packageDir);
}
tryRenameDir(tempDir, packageDir);
@@ -1213,22 +1280,30 @@
if (error is PubHttpResponseException) {
if (error.response.statusCode == 404) {
throw PackageNotFoundException(
- 'could not find package $package at $hostedUrl',
- innerError: error,
- innerTrace: stackTrace);
+ 'could not find package $package at $hostedUrl',
+ innerError: error,
+ innerTrace: stackTrace,
+ );
}
fail(
- '${error.response.statusCode} ${error.response.reasonPhrase} trying '
- 'to find package $package at $hostedUrl.',
- error,
- stackTrace);
+ '${error.response.statusCode} ${error.response.reasonPhrase} trying '
+ 'to find package $package at $hostedUrl.',
+ error,
+ stackTrace,
+ );
} else if (error is io.SocketException) {
- fail('Got socket error trying to find package $package at $hostedUrl.',
- error, stackTrace);
+ fail(
+ 'Got socket error trying to find package $package at $hostedUrl.',
+ error,
+ stackTrace,
+ );
} else if (error is io.TlsException) {
- fail('Got TLS error trying to find package $package at $hostedUrl.',
- error, stackTrace);
+ fail(
+ 'Got TLS error trying to find package $package at $hostedUrl.',
+ error,
+ stackTrace,
+ );
} else if (error is AuthenticationException) {
String? hint;
var message = 'authentication failed';
@@ -1268,8 +1343,10 @@
/// [getVersions].
Future<T> withPrefetching<T>(Future<T> Function() callback) async {
return await _scheduler.withPrescheduling((preschedule) async {
- return await runZoned(callback,
- zoneValues: {_prefetchingKey: preschedule});
+ return await runZoned(
+ callback,
+ zoneValues: {_prefetchingKey: preschedule},
+ );
});
}
@@ -1380,8 +1457,13 @@
final Uint8List? archiveSha256;
final PackageStatus status;
- _VersionInfo(this.version, this.pubspec, this.archiveUrl, this.status,
- this.archiveSha256);
+ _VersionInfo(
+ this.version,
+ this.pubspec,
+ this.archiveUrl,
+ this.status,
+ this.archiveSha256,
+ );
}
/// Given a URL, returns a "normalized" string to be used as a directory name
@@ -1478,8 +1560,12 @@
/// the one present in the checksum response header.
///
/// Throws [PackageIntegrityException] if there is a checksum mismatch.
-Stream<List<int>> _validateCrc32c(Stream<List<int>> stream,
- int expectedChecksum, PackageId id, Uri archiveUrl) async* {
+Stream<List<int>> _validateCrc32c(
+ Stream<List<int>> stream,
+ int expectedChecksum,
+ PackageId id,
+ Uri archiveUrl,
+) async* {
final crc32c = Crc32c();
await for (final chunk in stream) {
diff --git a/lib/src/source/path.dart b/lib/src/source/path.dart
index 68ab31f..aa94dc8 100644
--- a/lib/src/source/path.dart
+++ b/lib/src/source/path.dart
@@ -38,7 +38,11 @@
///
/// If [path] is relative it is resolved relative to [relativeTo]
PackageId idFor(
- String name, Version version, String path, String relativeTo) {
+ String name,
+ Version version,
+ String path,
+ String relativeTo,
+ ) {
return PackageId(
name,
version,
@@ -84,8 +88,12 @@
}
@override
- PackageId parseId(String name, Version version, description,
- {String? containingDir}) {
+ PackageId parseId(
+ String name,
+ Version version,
+ description, {
+ String? containingDir,
+ }) {
if (description is! Map) {
throw FormatException('The description must be a map.');
}
@@ -130,7 +138,10 @@
@override
Future<List<PackageId>> doGetVersions(
- PackageRef ref, Duration? maxAge, SystemCache cache) async {
+ PackageRef ref,
+ Duration? maxAge,
+ SystemCache cache,
+ ) async {
final description = ref.description;
if (description is! PathDescription) {
throw ArgumentError('Wrong source');
@@ -139,7 +150,10 @@
// version.
var pubspec = _loadPubspec(ref, cache);
var id = PackageId(
- ref.name, pubspec.version, ResolvedPathDescription(description));
+ ref.name,
+ pubspec.version,
+ ResolvedPathDescription(description),
+ );
// Store the pubspec in memory if we need to refer to it again.
cache.cachedPubspecs[id] = pubspec;
return [id];
@@ -212,7 +226,8 @@
}) {
return relative
? PathSource.relativePathWithPosixSeparators(
- p.relative(path, from: containingDir))
+ p.relative(path, from: containingDir),
+ )
: path;
}
diff --git a/lib/src/source/root.dart b/lib/src/source/root.dart
index 2c02e69..425b9a4 100644
--- a/lib/src/source/root.dart
+++ b/lib/src/source/root.dart
@@ -33,7 +33,10 @@
@override
Future<List<PackageId>> doGetVersions(
- PackageRef ref, Duration? maxAge, SystemCache cache) async {
+ PackageRef ref,
+ Duration? maxAge,
+ SystemCache cache,
+ ) async {
final description = ref.description;
if (description is! RootDescription) {
throw ArgumentError('Wrong source');
@@ -42,21 +45,32 @@
}
@override
- String doGetDirectory(PackageId id, SystemCache cache,
- {String? relativeFrom}) {
+ String doGetDirectory(
+ PackageId id,
+ SystemCache cache, {
+ String? relativeFrom,
+ }) {
// TODO(sigurdm): Should we support this.
throw UnsupportedError('Cannot get the directory of the root package');
}
@override
- PackageId parseId(String name, Version version, description,
- {String? containingDir}) {
+ PackageId parseId(
+ String name,
+ Version version,
+ description, {
+ String? containingDir,
+ }) {
throw UnsupportedError('Trying to parse a root package description.');
}
@override
- PackageRef parseRef(String name, description,
- {String? containingDir, required LanguageVersion languageVersion}) {
+ PackageRef parseRef(
+ String name,
+ description, {
+ String? containingDir,
+ required LanguageVersion languageVersion,
+ }) {
throw UnsupportedError('Trying to parse a root package description.');
}
}
diff --git a/lib/src/source/sdk.dart b/lib/src/source/sdk.dart
index da492f5..e0c005e 100644
--- a/lib/src/source/sdk.dart
+++ b/lib/src/source/sdk.dart
@@ -26,8 +26,12 @@
/// Parses an SDK dependency.
@override
- PackageRef parseRef(String name, description,
- {String? containingDir, LanguageVersion? languageVersion}) {
+ PackageRef parseRef(
+ String name,
+ description, {
+ String? containingDir,
+ LanguageVersion? languageVersion,
+ }) {
if (description is! String) {
throw FormatException('The description must be an SDK name.');
}
@@ -36,8 +40,12 @@
}
@override
- PackageId parseId(String name, Version version, description,
- {String? containingDir}) {
+ PackageId parseId(
+ String name,
+ Version version,
+ description, {
+ String? containingDir,
+ }) {
if (description is! String) {
throw FormatException('The description must be an SDK name.');
}
@@ -51,7 +59,10 @@
@override
Future<List<PackageId>> doGetVersions(
- PackageRef ref, Duration? maxAge, SystemCache cache) async {
+ PackageRef ref,
+ Duration? maxAge,
+ SystemCache cache,
+ ) async {
final description = ref.description;
if (description is! SdkDescription) {
throw ArgumentError('Wrong source');
@@ -78,9 +89,11 @@
///
/// Throws a [PackageNotFoundException] if [ref]'s SDK is unavailable or
/// doesn't contain the package.
- Pubspec _loadPubspec(PackageRef ref, SystemCache cache) =>
- Pubspec.load(_verifiedPackagePath(ref), cache.sources,
- expectedName: ref.name);
+ Pubspec _loadPubspec(PackageRef ref, SystemCache cache) => Pubspec.load(
+ _verifiedPackagePath(ref),
+ cache.sources,
+ expectedName: ref.name,
+ );
/// Returns the path for the given [ref].
///
@@ -106,12 +119,16 @@
if (path != null) return path;
throw PackageNotFoundException(
- 'could not find package ${ref.name} in the ${sdk.name} SDK');
+ 'could not find package ${ref.name} in the ${sdk.name} SDK',
+ );
}
@override
- String doGetDirectory(PackageId id, SystemCache cache,
- {String? relativeFrom}) {
+ String doGetDirectory(
+ PackageId id,
+ SystemCache cache, {
+ String? relativeFrom,
+ }) {
try {
return _verifiedPackagePath(id.toRef());
} on PackageNotFoundException catch (error) {
diff --git a/lib/src/source/unknown.dart b/lib/src/source/unknown.dart
index 55e5018..cfcda29 100644
--- a/lib/src/source/unknown.dart
+++ b/lib/src/source/unknown.dart
@@ -42,21 +42,33 @@
PackageRef(name, UnknownDescription(description, this));
@override
- PackageId parseId(String name, Version version, Object? description,
- {String? containingDir}) =>
- PackageId(name, version,
- ResolvedUnknownDescription(UnknownDescription(description, this)));
+ PackageId parseId(
+ String name,
+ Version version,
+ Object? description, {
+ String? containingDir,
+ }) =>
+ PackageId(
+ name,
+ version,
+ ResolvedUnknownDescription(UnknownDescription(description, this)),
+ );
@override
Future<List<PackageId>> doGetVersions(
- PackageRef ref, Duration? maxAge, SystemCache cache) =>
+ PackageRef ref,
+ Duration? maxAge,
+ SystemCache cache,
+ ) =>
throw UnsupportedError(
- "Cannot get package versions from unknown source '$name'.");
+ "Cannot get package versions from unknown source '$name'.",
+ );
@override
Future<Pubspec> doDescribe(PackageId id, SystemCache cache) =>
throw UnsupportedError(
- "Cannot describe a package from unknown source '$name'.");
+ "Cannot describe a package from unknown source '$name'.",
+ );
/// Returns the directory where this package can be found locally.
@override
@@ -66,7 +78,8 @@
String? relativeFrom,
}) =>
throw UnsupportedError(
- "Cannot find a package from an unknown source '$name'.");
+ "Cannot find a package from an unknown source '$name'.",
+ );
}
class UnknownDescription extends Description {
@@ -86,7 +99,8 @@
required LanguageVersion languageVersion,
}) {
throw UnsupportedError(
- "Cannot serialize a package description from an unknown source '${source.name}'.");
+ "Cannot serialize a package description from an unknown source '${source.name}'.",
+ );
}
@override
@@ -106,7 +120,8 @@
@override
Object? serializeForLockfile({required String? containingDir}) {
throw UnsupportedError(
- "Cannot serialize a package description from an unknown source '${description.source.name}'.");
+ "Cannot serialize a package description from an unknown source '${description.source.name}'.",
+ );
}
@override
diff --git a/lib/src/system_cache.dart b/lib/src/system_cache.dart
index 2956626..02ff9d3 100644
--- a/lib/src/system_cache.dart
+++ b/lib/src/system_cache.dart
@@ -109,7 +109,10 @@
final source = id.description.description.source;
if (source is CachedSource) {
return Package.load(
- id.name, source.getDirectoryInCache(id, this), sources);
+ id.name,
+ source.getDirectoryInCache(id, this),
+ sources,
+ );
} else {
throw ArgumentError('Call only on Cached ids.');
}
@@ -178,25 +181,31 @@
/// If given, the [allowedRetractedVersion] is the only version which can be
/// selected even if it is marked as retracted. Otherwise, all the returned
/// IDs correspond to non-retracted versions.
- Future<List<PackageId>> getVersions(PackageRef ref,
- {Duration? maxAge, Version? allowedRetractedVersion}) async {
+ Future<List<PackageId>> getVersions(
+ PackageRef ref, {
+ Duration? maxAge,
+ Version? allowedRetractedVersion,
+ }) async {
if (ref.isRoot) {
throw ArgumentError('Cannot get versions for the root package.');
}
var versions = await ref.source.doGetVersions(ref, maxAge, this);
- versions = (await Future.wait(versions.map((id) async {
- final packageStatus = await ref.source.status(
- id.toRef(),
- id.version,
- this,
- maxAge: maxAge,
- );
- if (!packageStatus.isRetracted || id.version == allowedRetractedVersion) {
- return id;
- }
- return null;
- })))
+ versions = (await Future.wait(
+ versions.map((id) async {
+ final packageStatus = await ref.source.status(
+ id.toRef(),
+ id.version,
+ this,
+ maxAge: maxAge,
+ );
+ if (!packageStatus.isRetracted ||
+ id.version == allowedRetractedVersion) {
+ return id;
+ }
+ return null;
+ }),
+ ))
.whereNotNull()
.toList();
@@ -266,9 +275,11 @@
return null;
}
- available.sort(allowPrereleases
- ? (x, y) => x.version.compareTo(y.version)
- : (x, y) => Version.prioritize(x.version, y.version));
+ available.sort(
+ allowPrereleases
+ ? (x, y) => x.version.compareTo(y.version)
+ : (x, y) => Version.prioritize(x.version, y.version),
+ );
var latest = available.last;
if (version != null && version.isPreRelease && version > latest.version) {
diff --git a/lib/src/utils.dart b/lib/src/utils.dart
index 82655f1..b339fc9 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -104,8 +104,10 @@
/// [Chain]. By default, this chain will contain only the local stack trace, but
/// if [captureStackChains] is passed, it will contain the full stack chain for
/// the error.
-Future<T> captureErrors<T>(Future<T> Function() callback,
- {bool captureStackChains = false}) {
+Future<T> captureErrors<T>(
+ Future<T> Function() callback, {
+ bool captureStackChains = false,
+}) {
var completer = Completer<T>();
void wrappedCallback() {
Future.sync(callback).then(completer.complete).catchError((e, stackTrace) {
@@ -121,9 +123,12 @@
}
if (captureStackChains) {
- Chain.capture(wrappedCallback, onError: (error, stackTrace) {
- if (!completer.isCompleted) completer.completeError(error, stackTrace);
- });
+ Chain.capture(
+ wrappedCallback,
+ onError: (error, stackTrace) {
+ if (!completer.isCompleted) completer.completeError(error, stackTrace);
+ },
+ );
} else {
runZonedGuarded(wrappedCallback, (e, stackTrace) {
stackTrace = Chain([Trace.from(stackTrace)]);
@@ -140,12 +145,14 @@
///
/// This will wrap the first error thrown in a [SilentException] and rethrow it.
Future<List<T>> waitAndPrintErrors<T>(Iterable<Future<T>> futures) {
- return Future.wait(futures.map((future) {
- return future.catchError((error, stackTrace) {
- log.exception(error, stackTrace);
- throw error;
- });
- })).catchError((error, stackTrace) {
+ return Future.wait(
+ futures.map((future) {
+ return future.catchError((error, stackTrace) {
+ log.exception(error, stackTrace);
+ throw error;
+ });
+ }),
+ ).catchError((error, stackTrace) {
throw SilentException(error, stackTrace);
});
}
@@ -155,10 +162,12 @@
///
/// The stream will be passed through unchanged.
StreamTransformer<T, T> onDoneTransformer<T>(void Function() onDone) {
- return StreamTransformer<T, T>.fromHandlers(handleDone: (sink) {
- onDone();
- sink.close();
- });
+ return StreamTransformer<T, T>.fromHandlers(
+ handleDone: (sink) {
+ onDone();
+ sink.close();
+ },
+ );
}
/// Pads [source] to [length] by adding [char]s at the beginning.
@@ -299,18 +308,27 @@
Iterable<T> slice<T>(Iterable<T> values, int start, int end) {
if (end <= start) {
throw RangeError.range(
- end, start + 1, null, 'end', 'must be greater than start');
+ end,
+ start + 1,
+ null,
+ 'end',
+ 'must be greater than start',
+ );
}
return values.skip(start).take(end - start);
}
/// Like [Iterable.fold], but for an asynchronous [combine] function.
-Future<S> foldAsync<S, T>(Iterable<T> values, S initialValue,
- Future<S> Function(S previous, T element) combine) =>
+Future<S> foldAsync<S, T>(
+ Iterable<T> values,
+ S initialValue,
+ Future<S> Function(S previous, T element) combine,
+) =>
values.fold(
- Future.value(initialValue),
- (previousFuture, element) =>
- previousFuture.then((previous) => combine(previous, element)));
+ Future.value(initialValue),
+ (previousFuture, element) =>
+ previousFuture.then((previous) => combine(previous, element)),
+ );
/// Replace each instance of [matcher] in [source] with the return value of
/// [fn].
@@ -418,7 +436,7 @@
return false;
case ForceColorOption.auto:
return (!Platform.environment.containsKey('NO_COLOR')) &&
- stdout.hasTerminal &&
+ terminalOutputForStdout &&
stdout.supportsAnsiEscapes;
}
}
@@ -426,26 +444,6 @@
/// Gets an ANSI escape if those are supported by stdout (or nothing).
String getAnsi(String ansiCode) => canUseAnsiCodes ? ansiCode : '';
-/// Whether an environment variable overriding the [stdout.hasTerminal] check
-/// was passed.
-bool get forceTerminalOutput =>
- Platform.environment.containsKey('_PUB_FORCE_TERMINAL_OUTPUT');
-
-/// Whether it makes sense to do stdout animation.
-///
-/// Checks if pub is in JSON output mode or if stdout has no terminal attached.
-/// The flutter tool sets an environment variable when running "pub get" that
-/// overrides the terminal check. See [forceTerminalOutput].
-bool get canAnimateOutput {
- if (log.json.enabled) {
- return false;
- }
- if (!stdout.hasTerminal && !forceTerminalOutput) {
- return false;
- }
- return true;
-}
-
/// Gets a emoji special character as unicode, or the [alternative] if unicode
/// charactors are not supported by stdout.
String emoji(String unicode, String alternative) =>
@@ -459,7 +457,7 @@
// The tests support unicode also on windows.
runningFromTest ||
// When not outputting to terminal we can also use unicode.
- !stdout.hasTerminal ||
+ !terminalOutputForStdout ||
!Platform.isWindows ||
Platform.environment.containsKey('WT_SESSION');
diff --git a/lib/src/validator.dart b/lib/src/validator.dart
index a203f0c..5a03d7b 100644
--- a/lib/src/validator.dart
+++ b/lib/src/validator.dart
@@ -19,6 +19,7 @@
import 'validator/deprecated_fields.dart';
import 'validator/directory.dart';
import 'validator/executable.dart';
+import 'validator/file_case.dart';
import 'validator/flutter_constraint.dart';
import 'validator/flutter_plugin_format.dart';
import 'validator/gitignore.dart';
@@ -26,7 +27,6 @@
import 'validator/leak_detection.dart';
import 'validator/license.dart';
import 'validator/name.dart';
-import 'validator/null_safety_mixed_mode.dart';
import 'validator/pubspec.dart';
import 'validator/pubspec_field.dart';
import 'validator/pubspec_typo.dart';
@@ -90,11 +90,12 @@
}
var allowedSdks = VersionRange(
- min: firstSdkVersion,
- includeMin: true,
- max: firstSdkVersion.isPreRelease
- ? firstSdkVersion.nextPatch
- : firstSdkVersion.nextBreaking);
+ min: firstSdkVersion,
+ includeMin: true,
+ max: firstSdkVersion.isPreRelease
+ ? firstSdkVersion.nextPatch
+ : firstSdkVersion.nextBreaking,
+ );
var newSdkConstraint = entrypoint
.root.pubspec.dartSdkConstraint.originalConstraint
@@ -126,12 +127,17 @@
/// [packageSize], if passed, should complete to the size of the tarred
/// package, in bytes. This is used to validate that it's not too big to
/// upload to the server.
- static Future<void> runAll(Entrypoint entrypoint, Future<int> packageSize,
- Uri serverUrl, List<String> files,
- {required List<String> hints,
- required List<String> warnings,
- required List<String> errors}) async {
+ static Future<void> runAll(
+ Entrypoint entrypoint,
+ Future<int> packageSize,
+ Uri serverUrl,
+ List<String> files, {
+ required List<String> hints,
+ required List<String> warnings,
+ required List<String> errors,
+ }) async {
var validators = [
+ FileCaseValidator(),
AnalyzeValidator(),
GitignoreValidator(),
PubspecValidator(),
@@ -152,7 +158,6 @@
FlutterPluginFormatValidator(),
LanguageVersionValidator(),
RelativeVersionNumberingValidator(),
- NullSafetyMixedModeValidator(),
PubspecTypoValidator(),
LeakDetectionValidator(),
SizeValidator(),
@@ -164,10 +169,12 @@
serverUrl,
files,
);
- return await Future.wait(validators.map((validator) async {
- validator.context = context;
- await validator.validate();
- })).then((_) {
+ return await Future.wait(
+ validators.map((validator) async {
+ validator.context = context;
+ await validator.validate();
+ }),
+ ).then((_) {
hints.addAll([for (final validator in validators) ...validator.hints]);
warnings
.addAll([for (final validator in validators) ...validator.warnings]);
@@ -228,5 +235,9 @@
final List<String> files;
ValidationContext(
- this.entrypoint, this.packageSize, this.serverUrl, this.files);
+ this.entrypoint,
+ this.packageSize,
+ this.serverUrl,
+ this.files,
+ );
}
diff --git a/lib/src/validator/changelog.dart b/lib/src/validator/changelog.dart
index bb897a7..aa47b70 100644
--- a/lib/src/validator/changelog.dart
+++ b/lib/src/validator/changelog.dart
@@ -18,7 +18,8 @@
@override
Future<void> validate() async {
final changelog = filesBeneath('.', recursive: false).firstWhereOrNull(
- (entry) => p.basename(entry).contains(_changelogRegexp));
+ (entry) => p.basename(entry).contains(_changelogRegexp),
+ );
if (changelog == null) {
warnings.add('Please add a `CHANGELOG.md` to your package. '
diff --git a/lib/src/validator/dependency.dart b/lib/src/validator/dependency.dart
index fa01b45..939d9be 100644
--- a/lib/src/validator/dependency.dart
+++ b/lib/src/validator/dependency.dart
@@ -39,8 +39,10 @@
return;
}
- validateSdkConstraint(sdk.firstPubVersion,
- "Older versions of pub don't support the ${sdk.name} SDK.");
+ validateSdkConstraint(
+ sdk.firstPubVersion,
+ "Older versions of pub don't support the ${sdk.name} SDK.",
+ );
}
/// Warn that dependencies should use the hosted source.
@@ -196,8 +198,10 @@
final description = dependency.description;
if (description is GitDescription && description.path != '.') {
- validateSdkConstraint(_firstGitPathVersion,
- "Older versions of pub don't support Git path dependencies.");
+ validateSdkConstraint(
+ _firstGitPathVersion,
+ "Older versions of pub don't support Git path dependencies.",
+ );
}
} else {
if (constraint.isAny) {
@@ -222,8 +226,10 @@
await validateDependencies(entrypoint.root.pubspec.dependencies.values);
if (hasCaretDep) {
- validateSdkConstraint(_firstCaretVersion,
- "Older versions of pub don't support ^ version constraints.");
+ validateSdkConstraint(
+ _firstCaretVersion,
+ "Older versions of pub don't support ^ version constraints.",
+ );
}
}
}
diff --git a/lib/src/validator/directory.dart b/lib/src/validator/directory.dart
index ae8ac57..8a3e7f2 100644
--- a/lib/src/validator/directory.dart
+++ b/lib/src/validator/directory.dart
@@ -26,8 +26,10 @@
final visited = <String>{};
for (final file in files) {
// Find the topmost directory name of [file].
- final dir = path.join(entrypoint.root.dir,
- path.split(path.relative(file, from: entrypoint.root.dir)).first);
+ final dir = path.join(
+ entrypoint.root.dir,
+ path.split(path.relative(file, from: entrypoint.root.dir)).first,
+ );
if (!visited.add(dir)) continue;
if (!dirExists(dir)) continue;
diff --git a/lib/src/validator/file_case.dart b/lib/src/validator/file_case.dart
new file mode 100644
index 0000000..ad73d47
--- /dev/null
+++ b/lib/src/validator/file_case.dart
@@ -0,0 +1,32 @@
+// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:async';
+
+import 'package:collection/collection.dart';
+
+import '../validator.dart';
+
+/// Validates that a package files all are unique even after case-normalization.
+class FileCaseValidator extends Validator {
+ @override
+ Future validate() async {
+ final lowerCaseToFile = <String, String>{};
+ for (final file in files.sorted()) {
+ final lowerCase = file.toLowerCase();
+ final existing = lowerCaseToFile[lowerCase];
+ if (existing != null) {
+ errors.add('''
+The file $file and $existing only differ in capitalization.
+
+This is not supported across platforms.
+
+Try renaming one of them.
+''');
+ break;
+ }
+ lowerCaseToFile[lowerCase] = file;
+ }
+ }
+}
diff --git a/lib/src/validator/flutter_plugin_format.dart b/lib/src/validator/flutter_plugin_format.dart
index 00160ca..79f286c 100644
--- a/lib/src/validator/flutter_plugin_format.dart
+++ b/lib/src/validator/flutter_plugin_format.dart
@@ -46,11 +46,13 @@
final flutterConstraint = pubspec.sdkConstraints['flutter'];
if (usesNewPluginFormat &&
(flutterConstraint == null ||
- flutterConstraint.effectiveConstraint.allowsAny(VersionRange(
- min: Version.parse('0.0.0'),
- max: Version.parse('1.10.0'),
- includeMin: true,
- )))) {
+ flutterConstraint.effectiveConstraint.allowsAny(
+ VersionRange(
+ min: Version.parse('0.0.0'),
+ max: Version.parse('1.10.0'),
+ includeMin: true,
+ ),
+ ))) {
errors.add('pubspec.yaml allows Flutter SDK version 1.9.x, which does '
'not support the flutter.plugin.platforms key.\n'
'Please consider increasing the Flutter SDK requirement to '
diff --git a/lib/src/validator/gitignore.dart b/lib/src/validator/gitignore.dart
index 809c537..9a1770a 100644
--- a/lib/src/validator/gitignore.dart
+++ b/lib/src/validator/gitignore.dart
@@ -23,12 +23,15 @@
if (entrypoint.root.inGitRepo) {
late final List<String> checkedIntoGit;
try {
- checkedIntoGit = git.runSync([
- 'ls-files',
- '--cached',
- '--exclude-standard',
- '--recurse-submodules'
- ], workingDir: entrypoint.root.dir);
+ checkedIntoGit = git.runSync(
+ [
+ 'ls-files',
+ '--cached',
+ '--exclude-standard',
+ '--recurse-submodules'
+ ],
+ workingDir: entrypoint.root.dir,
+ );
} on git.GitException catch (e) {
log.fine('Could not run `git ls-files` files in repo (${e.message}).');
// This validation is only a warning.
@@ -38,7 +41,8 @@
}
final root = git.repoRoot(entrypoint.root.dir) ?? entrypoint.root.dir;
var beneath = p.posix.joinAll(
- p.split(p.normalize(p.relative(entrypoint.root.dir, from: root))));
+ p.split(p.normalize(p.relative(entrypoint.root.dir, from: root))),
+ );
if (beneath == './') {
beneath = '';
}
@@ -55,8 +59,10 @@
var contents = Directory(resolve(dir)).listSync();
return contents
.where((e) => !(linkExists(e.path) && dirExists(e.path)))
- .map((entity) => p.posix
- .joinAll(p.split(p.relative(entity.path, from: root))));
+ .map(
+ (entity) => p.posix
+ .joinAll(p.split(p.relative(entity.path, from: root))),
+ );
},
ignoreForDir: (dir) {
final gitIgnore = resolve('$dir/.gitignore');
diff --git a/lib/src/validator/leak_detection.dart b/lib/src/validator/leak_detection.dart
index 03100f8..4c41905 100644
--- a/lib/src/validator/leak_detection.dart
+++ b/lib/src/validator/leak_detection.dart
@@ -34,31 +34,33 @@
);
final pool = Pool(20); // don't read more than 20 files concurrently!
- final leaks = await Future.wait(files.map((f) async {
- final relPath = entrypoint.root.relative(f);
+ final leaks = await Future.wait(
+ files.map((f) async {
+ final relPath = entrypoint.root.relative(f);
- // Skip files matching patterns in `false_secrets`
- final nixPath = p.posix.joinAll(p.split(relPath));
- if (falseSecrets.ignores(nixPath)) {
- return <LeakMatch>[];
- }
+ // Skip files matching patterns in `false_secrets`
+ final nixPath = p.posix.joinAll(p.split(relPath));
+ if (falseSecrets.ignores(nixPath)) {
+ return <LeakMatch>[];
+ }
- String text;
- try {
- // On Windows, we can't open some files without normalizing them
- final file = File(p.normalize(p.absolute(f)));
- text = await pool.withResource(
- () async => await file.readAsString(encoding: _utf8AllowMalformed),
- );
- } on IOException {
- // Pass, ignore files we can't read, let something else error later!
- return <LeakMatch>[];
- }
+ String text;
+ try {
+ // On Windows, we can't open some files without normalizing them
+ final file = File(p.normalize(p.absolute(f)));
+ text = await pool.withResource(
+ () async => await file.readAsString(encoding: _utf8AllowMalformed),
+ );
+ } on IOException {
+ // Pass, ignore files we can't read, let something else error later!
+ return <LeakMatch>[];
+ }
- return leakPatterns
- .map((p) => p.findPossibleLeaks(relPath, text))
- .expand((i) => i);
- })).then((lists) => lists.expand((i) => i).toList());
+ return leakPatterns
+ .map((p) => p.findPossibleLeaks(relPath, text))
+ .expand((i) => i);
+ }),
+ ).then((lists) => lists.expand((i) => i).toList());
// Convert detected leaks to errors, if we have more than 3 then we return
// the first 2 leaks, followed by a general summary of leaks.
@@ -76,14 +78,16 @@
..sort();
final s = files.length > 1 ? 's' : '';
- errors.add([
- '${leaks.length} potential leaks detected in ${files.length} file$s:',
- ...files.take(10).map((f) => '- /$f'),
- if (files.length > 10) '...',
- '',
- 'Add git-ignore style patterns to `false_secrets` in `pubspec.yaml`',
- 'to ignore this. See $_falseSecretsDocumentationLink'
- ].join('\n'));
+ errors.add(
+ [
+ '${leaks.length} potential leaks detected in ${files.length} file$s:',
+ ...files.take(10).map((f) => '- /$f'),
+ if (files.length > 10) '...',
+ '',
+ 'Add git-ignore style patterns to `false_secrets` in `pubspec.yaml`',
+ 'to ignore this. See $_falseSecretsDocumentationLink'
+ ].join('\n'),
+ );
} else if (leaks.isNotEmpty) {
// If we have 3 leaks we return all leaks, but only include the message
// about how ignore them in the last warning.
diff --git a/lib/src/validator/name.dart b/lib/src/validator/name.dart
index bc02031..9574c5b 100644
--- a/lib/src/validator/name.dart
+++ b/lib/src/validator/name.dart
@@ -35,9 +35,11 @@
var libDir = entrypoint.root.path('lib');
return filesBeneath('lib', recursive: true)
.map((file) => path.relative(file, from: path.dirname(libDir)))
- .where((file) =>
- !path.split(file).contains('src') &&
- path.extension(file) == '.dart')
+ .where(
+ (file) =>
+ !path.split(file).contains('src') &&
+ path.extension(file) == '.dart',
+ )
.toList();
}
diff --git a/lib/src/validator/null_safety_mixed_mode.dart b/lib/src/validator/null_safety_mixed_mode.dart
deleted file mode 100644
index b17e0e5..0000000
--- a/lib/src/validator/null_safety_mixed_mode.dart
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'dart:async';
-
-import 'package:path/path.dart' as p;
-
-import '../command_runner.dart';
-import '../null_safety_analysis.dart';
-import '../package_name.dart';
-import '../source/path.dart';
-import '../validator.dart';
-
-/// Gives a warning when publishing a new version, if this package opts into
-/// null safety, but any of the dependencies do not.
-class NullSafetyMixedModeValidator extends Validator {
- @override
- Future<void> validate() async {
- final pubspec = entrypoint.root.pubspec;
- final declaredLanguageVersion = pubspec.languageVersion;
- if (!declaredLanguageVersion.supportsNullSafety) {
- return;
- }
- final analysisResult =
- await NullSafetyAnalysis(entrypoint.cache).nullSafetyCompliance(
- PackageId(
- entrypoint.root.name,
- entrypoint.root.version,
- ResolvedPathDescription(
- PathDescription(p.absolute(entrypoint.root.dir), false),
- ),
- ),
- );
- if (analysisResult.compliance == NullSafetyCompliance.mixed) {
- warnings.add('''
-This package is opting into null-safety, but a dependency or file is not.
-
-${analysisResult.reason}
-
-Note that by publishing with non-migrated dependencies your package may be
-broken at any time if one of your dependencies migrates without a breaking
-change release.
-
-We highly recommend that you wait until all of your dependencies have been
-migrated before publishing.
-
-Run `$topLevelProgram pub outdated --mode=null-safety` for more information about the state
-of dependencies.
-
-See ${NullSafetyAnalysis.guideUrl}
-for more information about migrating.
-''');
- }
- }
-}
diff --git a/lib/src/validator/relative_version_numbering.dart b/lib/src/validator/relative_version_numbering.dart
index 1b99b79..9a5e214 100644
--- a/lib/src/validator/relative_version_numbering.dart
+++ b/lib/src/validator/relative_version_numbering.dart
@@ -7,7 +7,6 @@
import 'package:collection/collection.dart' show IterableExtension;
import '../exceptions.dart';
-import '../null_safety_analysis.dart';
import '../package_name.dart';
import '../validator.dart';
@@ -17,6 +16,9 @@
static const String semverUrl =
'https://dart.dev/tools/pub/versioning#semantic-versions';
+ static const String nullSafetyGuideUrl =
+ 'https://dart.dev/null-safety/migration-guide';
+
@override
Future<void> validate() async {
final hostedSource = entrypoint.cache.hosted;
@@ -43,7 +45,7 @@
hints.add(
'You\'re about to publish a package that opts into null safety.\n'
'The previous version (${previousVersion.version}) isn\'t opted in.\n'
- 'See ${NullSafetyAnalysis.guideUrl} for best practices.');
+ 'See $nullSafetyGuideUrl for best practices.');
} else if (!currentOptedIn && previousOptedIn) {
hints.add(
'You\'re about to publish a package that doesn\'t opt into null safety,\n'
diff --git a/lib/src/validator/sdk_constraint.dart b/lib/src/validator/sdk_constraint.dart
index 9dc084e..a14d179 100644
--- a/lib/src/validator/sdk_constraint.dart
+++ b/lib/src/validator/sdk_constraint.dart
@@ -63,8 +63,10 @@
for (var sdk in sdks.values) {
if (sdk.identifier == 'dart') continue;
if (entrypoint.root.pubspec.sdkConstraints.containsKey(sdk.identifier)) {
- validateSdkConstraint(sdk.firstPubVersion,
- "Older versions of pub don't support ${sdk.name} SDK constraints.");
+ validateSdkConstraint(
+ sdk.firstPubVersion,
+ "Older versions of pub don't support ${sdk.name} SDK constraints.",
+ );
}
}
}
diff --git a/lib/src/validator/strict_dependencies.dart b/lib/src/validator/strict_dependencies.dart
index 17ee609..2fec2f6 100644
--- a/lib/src/validator/strict_dependencies.dart
+++ b/lib/src/validator/strict_dependencies.dart
@@ -53,7 +53,8 @@
(url.pathSegments.length < 2 ||
url.pathSegments.any((s) => s.isEmpty)))) {
errors.add(
- _Usage.errorMessage('Invalid URL.', file, contents, directive));
+ _Usage.errorMessage('Invalid URL.', file, contents, directive),
+ );
} else if (url.scheme == 'package') {
yield _Usage(file, contents, directive, url);
}
@@ -113,8 +114,12 @@
/// A parsed import or export directive in a D source file.
class _Usage {
/// Returns a formatted error message highlighting [directive] in [file].
- static String errorMessage(String message, String file, String contents,
- UriBasedDirective directive) {
+ static String errorMessage(
+ String message,
+ String file,
+ String contents,
+ UriBasedDirective directive,
+ ) {
return SourceFile.fromString(contents, url: file)
.span(directive.offset, directive.offset + directive.length)
.message(message);
diff --git a/test/add/common/add_test.dart b/test/add/common/add_test.dart
index 87ac53b..548f680 100644
--- a/test/add/common/add_test.dart
+++ b/test/add/common/add_test.dart
@@ -16,14 +16,15 @@
test('URL encodes the package name', () async {
await servePackages();
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(
- args: ['bad name!:1.2.3'],
- error: contains('Not a valid package name: "bad name!"'),
- exitCode: exit_codes.USAGE);
+ args: ['bad name!:1.2.3'],
+ error: contains('Not a valid package name: "bad name!"'),
+ exitCode: exit_codes.USAGE,
+ );
- await d.appDir({}).validate();
+ await d.appDir(dependencies: {}).validate();
await d.dir(appPath, [
d.nothing('.dart_tool/package_config.json'),
@@ -37,7 +38,7 @@
final server = await servePackages();
server.serve('foo', '1.2.3');
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(args: ['foo:1.2.3']);
@@ -45,7 +46,7 @@
await d.appPackageConfigFile([
d.packageConfigEntry(name: 'foo', version: '1.2.3'),
]).validate();
- await d.appDir({'foo': '1.2.3'}).validate();
+ await d.appDir(dependencies: {'foo': '1.2.3'}).validate();
});
test('adds multiple package from a pub server', () async {
@@ -54,19 +55,21 @@
server.serve('bar', '1.1.0');
server.serve('baz', '2.5.3');
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(args: ['foo:1.2.3', 'bar:1.1.0', 'baz:2.5.3']);
await d.cacheDir(
- {'foo': '1.2.3', 'bar': '1.1.0', 'baz': '2.5.3'}).validate();
+ {'foo': '1.2.3', 'bar': '1.1.0', 'baz': '2.5.3'},
+ ).validate();
await d.appPackageConfigFile([
d.packageConfigEntry(name: 'foo', version: '1.2.3'),
d.packageConfigEntry(name: 'bar', version: '1.1.0'),
d.packageConfigEntry(name: 'baz', version: '2.5.3'),
]).validate();
- await d
- .appDir({'foo': '1.2.3', 'bar': '1.1.0', 'baz': '2.5.3'}).validate();
+ await d.appDir(
+ dependencies: {'foo': '1.2.3', 'bar': '1.1.0', 'baz': '2.5.3'},
+ ).validate();
});
test(
@@ -84,7 +87,7 @@
dev_dependencies:
environment:
- sdk: '>=0.1.2 <1.0.0'
+ sdk: $defaultSdkConstraint
''')
]).create();
@@ -109,16 +112,16 @@
final server = await servePackages();
server.serve('foo', '1.2.3');
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(
- args: ['foo:1.2.3', '--dry-run'],
- output: allOf([
- contains('Would change 1 dependency'),
- contains('+ foo 1.2.3')
- ]));
+ args: ['foo:1.2.3', '--dry-run'],
+ output: allOf(
+ [contains('Would change 1 dependency'), contains('+ foo 1.2.3')],
+ ),
+ );
- await d.appDir({}).validate();
+ await d.appDir(dependencies: {}).validate();
await d.dir(appPath, [
d.nothing('.dart_tool/package_config.json'),
d.nothing('pubspec.lock'),
@@ -136,22 +139,25 @@
d.file('pubspec.yaml', '''
name: myapp
environment:
- "sdk": ">=0.1.2 <1.0.0"
+ "sdk": "$defaultSdkConstraint"
''')
]).create();
await pubAdd(args: ['foo:1.2.3']);
final yaml = loadYaml(
- File(p.join(d.sandbox, appPath, 'pubspec.yaml')).readAsStringSync());
+ File(p.join(d.sandbox, appPath, 'pubspec.yaml')).readAsStringSync(),
+ );
- expect(((yaml as YamlMap).nodes['dependencies'] as YamlMap).style,
- CollectionStyle.BLOCK,
- reason: 'Should create the mapping with block-style by default');
+ expect(
+ ((yaml as YamlMap).nodes['dependencies'] as YamlMap).style,
+ CollectionStyle.BLOCK,
+ reason: 'Should create the mapping with block-style by default',
+ );
await d.cacheDir({'foo': '1.2.3'}).validate();
await d.appPackageConfigFile([
d.packageConfigEntry(name: 'foo', version: '1.2.3'),
]).validate();
- await d.appDir({'foo': '1.2.3'}).validate();
+ await d.appDir(dependencies: {'foo': '1.2.3'}).validate();
});
test('Inserts correctly when the pubspec is flow-style at top-level',
@@ -160,24 +166,29 @@
server.serve('foo', '1.2.3');
await d.dir(appPath, [
- d.file('pubspec.yaml',
- '{"name":"myapp", "environment": {"sdk": ">=0.1.2 <1.0.0"}}')
+ d.file(
+ 'pubspec.yaml',
+ '{"name":"myapp", "environment": {"sdk": "$defaultSdkConstraint"}}',
+ )
]).create();
await pubAdd(args: ['foo:1.2.3']);
final yaml = loadYaml(
- File(p.join(d.sandbox, appPath, 'pubspec.yaml')).readAsStringSync());
+ File(p.join(d.sandbox, appPath, 'pubspec.yaml')).readAsStringSync(),
+ );
- expect(((yaml as YamlMap).nodes['dependencies'] as YamlMap).style,
- CollectionStyle.FLOW,
- reason: 'Should not break a pubspec in flow-style');
+ expect(
+ ((yaml as YamlMap).nodes['dependencies'] as YamlMap).style,
+ CollectionStyle.FLOW,
+ reason: 'Should not break a pubspec in flow-style',
+ );
await d.cacheDir({'foo': '1.2.3'}).validate();
await d.appPackageConfigFile([
d.packageConfigEntry(name: 'foo', version: '1.2.3'),
]).validate();
- await d.appDir({'foo': '1.2.3'}).validate();
+ await d.appDir(dependencies: {'foo': '1.2.3'}).validate();
});
group('notifies user about existing constraint', () {
@@ -186,7 +197,7 @@
..serve('foo', '1.2.3')
..serve('foo', '1.2.2');
- await d.appDir({'foo': '1.2.2'}).create();
+ await d.appDir(dependencies: {'foo': '1.2.2'}).create();
await pubAdd(
args: ['foo'],
@@ -195,7 +206,7 @@
),
);
- await d.appDir({'foo': '^1.2.3'}).validate();
+ await d.appDir(dependencies: {'foo': '^1.2.3'}).validate();
});
test('if package is added with a specific version constraint', () async {
@@ -203,7 +214,7 @@
..serve('foo', '1.2.3')
..serve('foo', '1.2.2');
- await d.appDir({'foo': '1.2.2'}).create();
+ await d.appDir(dependencies: {'foo': '1.2.2'}).create();
await pubAdd(
args: ['foo:1.2.3'],
@@ -212,7 +223,7 @@
),
);
- await d.appDir({'foo': '1.2.3'}).validate();
+ await d.appDir(dependencies: {'foo': '1.2.3'}).validate();
});
test('if package is added with a version constraint range', () async {
@@ -220,14 +231,16 @@
..serve('foo', '1.2.3')
..serve('foo', '1.2.2');
- await d.appDir({'foo': '1.2.2'}).create();
+ await d.appDir(dependencies: {'foo': '1.2.2'}).create();
await pubAdd(
- args: ['foo:>=1.2.2'],
- output: contains(
- '"foo" is already in "dependencies". Will try to update the constraint.'));
+ args: ['foo:>=1.2.2'],
+ output: contains(
+ '"foo" is already in "dependencies". Will try to update the constraint.',
+ ),
+ );
- await d.appDir({'foo': '>=1.2.2'}).validate();
+ await d.appDir(dependencies: {'foo': '>=1.2.2'}).validate();
});
});
@@ -244,15 +257,16 @@
dev_dependencies:
foo: 1.2.2
environment:
- sdk: '>=0.1.2 <1.0.0'
+ sdk: '$defaultSdkConstraint'
''')
]).create();
await pubAdd(
- args: ['foo:1.2.3'],
- output: contains(
- '"foo" was found in dev_dependencies. Removing "foo" and '
- 'adding it to dependencies instead.'));
+ args: ['foo:1.2.3'],
+ output:
+ contains('"foo" was found in dev_dependencies. Removing "foo" and '
+ 'adding it to dependencies instead.'),
+ );
await d.cacheDir({'foo': '1.2.3'}).validate();
await d.appPackageConfigFile([
@@ -300,8 +314,10 @@
final server = await servePackages();
server.serve('foo', '1.2.3');
- await d.git('foo.git',
- [d.libDir('foo'), d.libPubspec('foo', '1.2.3')]).create();
+ await d.git(
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.2.3')],
+ ).create();
await d.dir(appPath, [
d.pubspec({
@@ -330,7 +346,9 @@
final server = await servePackages();
server.serve('foo', '1.2.2');
await d.dir(
- 'foo', [d.libDir('foo'), d.libPubspec('foo', '1.2.2')]).create();
+ 'foo',
+ [d.libDir('foo'), d.libPubspec('foo', '1.2.2')],
+ ).create();
await d.dir(appPath, [
d.pubspec({
@@ -364,10 +382,11 @@
]).create();
await pubAdd(
- args: ['foo:one-two-three'],
- exitCode: exit_codes.DATA,
- error: contains('Invalid version constraint: Could '
- 'not parse version "one-two-three".'));
+ args: ['foo:one-two-three'],
+ exitCode: exit_codes.DATA,
+ error: contains('Invalid version constraint: Could '
+ 'not parse version "one-two-three".'),
+ );
await d.dir(appPath, [
d.pubspec({'name': 'myapp', 'dependencies': {}}),
@@ -391,11 +410,12 @@
]).create();
await pubAdd(
- args: ['foo:1.2.3'],
- exitCode: exit_codes.DATA,
- error: contains(
- '"foo" resolved to "1.2.2" which does not satisfy constraint '
- '"1.2.3". This could be caused by "dependency_overrides".'));
+ args: ['foo:1.2.3'],
+ exitCode: exit_codes.DATA,
+ error: contains(
+ '"foo" resolved to "1.2.2" which does not satisfy constraint '
+ '"1.2.3". This could be caused by "dependency_overrides".'),
+ );
await d.dir(appPath, [
d.pubspec({
@@ -413,8 +433,10 @@
final server = await servePackages();
server.serve('foo', '1.2.3');
- await d.git('foo.git',
- [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ await d.git(
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
await d.dir(appPath, [
d.pubspec({
@@ -427,11 +449,12 @@
]).create();
await pubAdd(
- args: ['foo:1.2.3'],
- exitCode: exit_codes.DATA,
- error: contains(
- '"foo" resolved to "1.0.0" which does not satisfy constraint '
- '"1.2.3". This could be caused by "dependency_overrides".'));
+ args: ['foo:1.2.3'],
+ exitCode: exit_codes.DATA,
+ error: contains(
+ '"foo" resolved to "1.0.0" which does not satisfy constraint '
+ '"1.2.3". This could be caused by "dependency_overrides".'),
+ );
await d.dir(appPath, [
d.pubspec({
@@ -452,7 +475,9 @@
final server = await servePackages();
server.serve('foo', '1.2.2');
await d.dir(
- 'foo', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ 'foo',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
await d.dir(appPath, [
d.pubspec({
@@ -465,11 +490,12 @@
]).create();
await pubAdd(
- args: ['foo:1.2.2'],
- exitCode: exit_codes.DATA,
- error: contains(
- '"foo" resolved to "1.0.0" which does not satisfy constraint '
- '"1.2.2". This could be caused by "dependency_overrides".'));
+ args: ['foo:1.2.2'],
+ exitCode: exit_codes.DATA,
+ error: contains(
+ '"foo" resolved to "1.0.0" which does not satisfy constraint '
+ '"1.2.2". This could be caused by "dependency_overrides".'),
+ );
await d.dir(appPath, [
d.pubspec({
@@ -614,9 +640,11 @@
]).create();
await pubAdd(
- args: ['foo', '--dev'],
- output: contains(
- '"foo" is already in "dev_dependencies". Will try to update the constraint.'));
+ args: ['foo', '--dev'],
+ output: contains(
+ '"foo" is already in "dev_dependencies". Will try to update the constraint.',
+ ),
+ );
await d.dir(appPath, [
d.pubspec({
@@ -639,9 +667,11 @@
]).create();
await pubAdd(
- args: ['foo:1.2.3', '--dev'],
- output: contains(
- '"foo" is already in "dev_dependencies". Will try to update the constraint.'));
+ args: ['foo:1.2.3', '--dev'],
+ output: contains(
+ '"foo" is already in "dev_dependencies". Will try to update the constraint.',
+ ),
+ );
await d.dir(appPath, [
d.pubspec({
@@ -664,9 +694,11 @@
]).create();
await pubAdd(
- args: ['foo:>=1.2.2', '--dev'],
- output: contains(
- '"foo" is already in "dev_dependencies". Will try to update the constraint.'));
+ args: ['foo:>=1.2.2', '--dev'],
+ output: contains(
+ '"foo" is already in "dev_dependencies". Will try to update the constraint.',
+ ),
+ );
await d.dir(appPath, [
d.pubspec({
@@ -709,8 +741,10 @@
test('passes if constraint is git dependency', () async {
final server = await servePackages();
server.serve('foo', '1.2.3');
- await d.git('foo.git',
- [d.libDir('foo'), d.libPubspec('foo', '1.2.3')]).create();
+ await d.git(
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.2.3')],
+ ).create();
await d.dir(appPath, [
d.pubspec({
@@ -739,7 +773,9 @@
final server = await servePackages();
server.serve('foo', '1.2.2');
await d.dir(
- 'foo', [d.libDir('foo'), d.libPubspec('foo', '1.2.2')]).create();
+ 'foo',
+ [d.libDir('foo'), d.libPubspec('foo', '1.2.2')],
+ ).create();
await d.dir(appPath, [
d.pubspec({
@@ -778,11 +814,12 @@
]).create();
await pubAdd(
- args: ['foo:1.2.3', '--dev'],
- exitCode: exit_codes.DATA,
- error: contains(
- '"foo" resolved to "1.2.2" which does not satisfy constraint '
- '"1.2.3". This could be caused by "dependency_overrides".'));
+ args: ['foo:1.2.3', '--dev'],
+ exitCode: exit_codes.DATA,
+ error: contains(
+ '"foo" resolved to "1.2.2" which does not satisfy constraint '
+ '"1.2.3". This could be caused by "dependency_overrides".'),
+ );
await d.dir(appPath, [
d.pubspec({
@@ -800,8 +837,10 @@
final server = await servePackages();
server.serve('foo', '1.2.3');
- await d.git('foo.git',
- [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ await d.git(
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
await d.dir(appPath, [
d.pubspec({
@@ -814,11 +853,12 @@
]).create();
await pubAdd(
- args: ['foo:1.2.3'],
- exitCode: exit_codes.DATA,
- error: contains(
- '"foo" resolved to "1.0.0" which does not satisfy constraint '
- '"1.2.3". This could be caused by "dependency_overrides".'));
+ args: ['foo:1.2.3'],
+ exitCode: exit_codes.DATA,
+ error: contains(
+ '"foo" resolved to "1.0.0" which does not satisfy constraint '
+ '"1.2.3". This could be caused by "dependency_overrides".'),
+ );
await d.dir(appPath, [
d.pubspec({
@@ -840,7 +880,9 @@
server.serve('foo', '1.2.2');
await d.dir(
- 'foo', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ 'foo',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
await d.dir(appPath, [
d.pubspec({
@@ -853,11 +895,12 @@
]).create();
await pubAdd(
- args: ['foo:1.2.2', '--dev'],
- exitCode: exit_codes.DATA,
- error: contains(
- '"foo" resolved to "1.0.0" which does not satisfy constraint '
- '"1.2.2". This could be caused by "dependency_overrides".'));
+ args: ['foo:1.2.2', '--dev'],
+ exitCode: exit_codes.DATA,
+ error: contains(
+ '"foo" resolved to "1.0.0" which does not satisfy constraint '
+ '"1.2.2". This could be caused by "dependency_overrides".'),
+ );
await d.dir(appPath, [
d.pubspec({
@@ -890,11 +933,12 @@
]).create();
await pubAdd(
- args: ['foo:1.2.3', '--dev'],
- error: contains('"foo" is already in "dependencies". Use '
- '"pub remove foo" to remove it before adding it to '
- '"dev_dependencies"'),
- exitCode: exit_codes.DATA);
+ args: ['foo:1.2.3', '--dev'],
+ error: contains('"foo" is already in "dependencies". Use '
+ '"pub remove foo" to remove it before adding it to '
+ '"dev_dependencies"'),
+ exitCode: exit_codes.DATA,
+ );
await d.dir(appPath, [
d.pubspec({
@@ -919,14 +963,14 @@
name: myapp
dependencies:
environment:
- sdk: '>=0.1.2 <1.0.0'
+ sdk: '$defaultSdkConstraint'
'''),
]).create();
await pubGet();
await pubAdd(args: ['bar']);
- await d.appDir({'bar': '^1.0.0'}).validate();
+ await d.appDir(dependencies: {'bar': '^1.0.0'}).validate();
});
test('preserves comments', () async {
@@ -942,7 +986,7 @@
foo: 1.0.0 # comment C
# comment D
environment:
- sdk: '>=0.1.2 <1.0.0'
+ sdk: '$defaultSdkConstraint'
'''),
]).create();
@@ -950,19 +994,20 @@
await pubAdd(args: ['bar']);
- await d.appDir({'bar': '^1.0.0', 'foo': '1.0.0'}).validate();
+ await d.appDir(dependencies: {'bar': '^1.0.0', 'foo': '1.0.0'}).validate();
final fullPath = p.join(d.sandbox, appPath, 'pubspec.yaml');
expect(File(fullPath).existsSync(), true);
final contents = File(fullPath).readAsStringSync();
expect(
- contents,
- allOf([
- contains('# comment A'),
- contains('# comment B'),
- contains('# comment C'),
- contains('# comment D')
- ]));
+ contents,
+ allOf([
+ contains('# comment A'),
+ contains('# comment B'),
+ contains('# comment C'),
+ contains('# comment D')
+ ]),
+ );
});
}
diff --git a/test/add/common/invalid_options.dart b/test/add/common/invalid_options.dart
index f5bf23d..37c82e8 100644
--- a/test/add/common/invalid_options.dart
+++ b/test/add/common/invalid_options.dart
@@ -13,22 +13,25 @@
ensureGit();
await d.git(
- 'foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
await d
.dir('bar', [d.libDir('bar'), d.libPubspec('foo', '0.0.1')]).create();
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(
- args: ['foo', '--git-url', '../foo.git', '--path', '../bar'],
- error: allOf([
- contains('Packages can only have one source, pub add flags '
- '"--git-url" and "--path" are'),
- contains('conflicting.')
- ]),
- exitCode: exit_codes.USAGE);
+ args: ['foo', '--git-url', '../foo.git', '--path', '../bar'],
+ error: allOf([
+ contains('Packages can only have one source, pub add flags '
+ '"--git-url" and "--path" are'),
+ contains('conflicting.')
+ ]),
+ exitCode: exit_codes.USAGE,
+ );
- await d.appDir({}).validate();
+ await d.appDir(dependencies: {}).validate();
await d.dir(appPath, [
d.nothing('.dart_tool/package_config.json'),
d.nothing('pubspec.lock'),
@@ -46,24 +49,25 @@
await d
.dir('bar', [d.libDir('bar'), d.libPubspec('foo', '0.0.1')]).create();
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(
- args: [
- 'foo',
- '--hosted-url',
- 'http://localhost:${server.port}',
- '--path',
- '../bar'
- ],
- error: allOf([
- contains('Packages can only have one source, pub add flags '
- '"--hosted-url" and "--path" are'),
- contains('conflicting.')
- ]),
- exitCode: exit_codes.USAGE);
+ args: [
+ 'foo',
+ '--hosted-url',
+ 'http://localhost:${server.port}',
+ '--path',
+ '../bar'
+ ],
+ error: allOf([
+ contains('Packages can only have one source, pub add flags '
+ '"--hosted-url" and "--path" are'),
+ contains('conflicting.')
+ ]),
+ exitCode: exit_codes.USAGE,
+ );
- await d.appDir({}).validate();
+ await d.appDir(dependencies: {}).validate();
await d.dir(appPath, [
d.nothing('.dart_tool/package_config.json'),
d.nothing('pubspec.lock'),
@@ -82,25 +86,28 @@
ensureGit();
await d.git(
- 'foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
- await d.appDir({}).create();
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(
- args: [
- 'foo',
- '--hosted-url',
- 'http://localhost:${server.port}',
- '--git-url',
- '../foo.git'
- ],
- error: allOf([
- contains('Packages can only have one source, pub add flags '
- '"--git-url" and "--hosted-url"'),
- contains('are conflicting.')
- ]),
- exitCode: exit_codes.USAGE);
+ args: [
+ 'foo',
+ '--hosted-url',
+ 'http://localhost:${server.port}',
+ '--git-url',
+ '../foo.git'
+ ],
+ error: allOf([
+ contains('Packages can only have one source, pub add flags '
+ '"--git-url" and "--hosted-url"'),
+ contains('are conflicting.')
+ ]),
+ exitCode: exit_codes.USAGE,
+ );
- await d.appDir({}).validate();
+ await d.appDir(dependencies: {}).validate();
await d.dir(appPath, [
d.nothing('.dart_tool/package_config.json'),
d.nothing('pubspec.lock'),
diff --git a/test/add/common/version_constraint_test.dart b/test/add/common/version_constraint_test.dart
index f058082..b0bc2d4 100644
--- a/test/add/common/version_constraint_test.dart
+++ b/test/add/common/version_constraint_test.dart
@@ -17,7 +17,7 @@
..serve('foo', '2.0.0-dev')
..serve('foo', '1.3.4-dev');
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(args: ['foo']);
@@ -25,14 +25,14 @@
await d.appPackageConfigFile([
d.packageConfigEntry(name: 'foo', version: '1.2.3'),
]).validate();
- await d.appDir({'foo': '^1.2.3'}).validate();
+ await d.appDir(dependencies: {'foo': '^1.2.3'}).validate();
});
test('allows specific version constraint', () async {
final server = await servePackages();
server.serve('foo', '1.2.3');
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(args: ['foo:1.2.3']);
@@ -40,14 +40,14 @@
await d.appPackageConfigFile([
d.packageConfigEntry(name: 'foo', version: '1.2.3'),
]).validate();
- await d.appDir({'foo': '1.2.3'}).validate();
+ await d.appDir(dependencies: {'foo': '1.2.3'}).validate();
});
test('allows specific pre-release version constraint', () async {
final server = await servePackages();
server.serve('foo', '1.2.3-dev');
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(args: ['foo:1.2.3-dev']);
@@ -55,7 +55,7 @@
await d.appPackageConfigFile([
d.packageConfigEntry(name: 'foo', version: '1.2.3-dev'),
]).validate();
- await d.appDir({'foo': '1.2.3-dev'}).validate();
+ await d.appDir(dependencies: {'foo': '1.2.3-dev'}).validate();
});
test('allows the "any" version constraint', () async {
@@ -66,7 +66,7 @@
..serve('foo', '2.0.0-dev')
..serve('foo', '1.3.4-dev');
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(args: ['foo:any']);
@@ -74,14 +74,14 @@
await d.appPackageConfigFile([
d.packageConfigEntry(name: 'foo', version: '1.2.3'),
]).validate();
- await d.appDir({'foo': 'any'}).validate();
+ await d.appDir(dependencies: {'foo': 'any'}).validate();
});
test('allows version constraint range', () async {
final server = await servePackages();
server.serve('foo', '1.2.3');
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(args: ['foo:>1.2.0 <2.0.0']);
@@ -89,7 +89,7 @@
await d.appPackageConfigFile([
d.packageConfigEntry(name: 'foo', version: '1.2.3'),
]).validate();
- await d.appDir({'foo': '>1.2.0 <2.0.0'}).validate();
+ await d.appDir(dependencies: {'foo': '>1.2.0 <2.0.0'}).validate();
});
test(
@@ -101,11 +101,11 @@
..serve('bar', '2.0.3')
..serve('bar', '2.0.4');
- await d.appDir({'bar': '2.0.3'}).create();
+ await d.appDir(dependencies: {'bar': '2.0.3'}).create();
await pubAdd(args: ['foo']);
- await d.appDir({'foo': '^0.1.0', 'bar': '2.0.3'}).validate();
+ await d.appDir(dependencies: {'foo': '^0.1.0', 'bar': '2.0.3'}).validate();
await d.cacheDir({'foo': '0.1.0', 'bar': '2.0.3'}).validate();
await d.appPackageConfigFile([
@@ -119,16 +119,17 @@
final server = await servePackages();
server.serve('foo', '1.0.3');
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(
- args: ['foo:>1.2.0 <2.0.0'],
- error: contains(
- "Because myapp depends on foo >1.2.0 <2.0.0 which doesn't "
- 'match any versions, version solving failed.'),
- exitCode: exit_codes.DATA);
+ args: ['foo:>1.2.0 <2.0.0'],
+ error:
+ contains("Because myapp depends on foo >1.2.0 <2.0.0 which doesn't "
+ 'match any versions, version solving failed.'),
+ exitCode: exit_codes.DATA,
+ );
- await d.appDir({}).validate();
+ await d.appDir(dependencies: {}).validate();
await d.dir(appPath, [
// The lockfile should not be created.
d.nothing('pubspec.lock'),
@@ -143,16 +144,17 @@
..serve('bar', '2.0.3')
..serve('bar', '2.0.4');
- await d.appDir({'bar': '2.0.3'}).create();
+ await d.appDir(dependencies: {'bar': '2.0.3'}).create();
await pubAdd(
- args: ['foo:1.2.3'],
- error: contains(
- 'Because every version of foo depends on bar 2.0.4 and myapp '
- 'depends on bar 2.0.3, foo is forbidden.'),
- exitCode: exit_codes.DATA);
+ args: ['foo:1.2.3'],
+ error: contains(
+ 'Because every version of foo depends on bar 2.0.4 and myapp '
+ 'depends on bar 2.0.3, foo is forbidden.'),
+ exitCode: exit_codes.DATA,
+ );
- await d.appDir({'bar': '2.0.3'}).validate();
+ await d.appDir(dependencies: {'bar': '2.0.3'}).validate();
await d.dir(appPath, [
// The lockfile should not be created.
d.nothing('pubspec.lock'),
diff --git a/test/add/common/version_resolution_test.dart b/test/add/common/version_resolution_test.dart
index 0f44d2b..b526dab 100644
--- a/test/add/common/version_resolution_test.dart
+++ b/test/add/common/version_resolution_test.dart
@@ -18,7 +18,7 @@
server.serve('foo', '3.2.1');
server.serve('bar', '1.0.0', deps: {'foo': '^3.2.1'});
- await d.appDir({'bar': '1.0.0'}).create();
+ await d.appDir(dependencies: {'bar': '1.0.0'}).create();
await pubGet();
/// foo's package creator releases a newer version of foo, and we
@@ -30,7 +30,7 @@
await pubAdd(args: ['foo']);
- await d.appDir({'foo': '^3.5.0', 'bar': '1.0.0'}).validate();
+ await d.appDir(dependencies: {'foo': '^3.5.0', 'bar': '1.0.0'}).validate();
await d.cacheDir({'foo': '3.5.0', 'bar': '1.0.0'}).validate();
await d.appPackageConfigFile([
d.packageConfigEntry(name: 'foo', version: '3.5.0'),
@@ -47,7 +47,7 @@
server.serve('foo', '3.2.1');
server.serve('bar', '1.0.0', deps: {'foo': '^3.2.1'});
- await d.appDir({'bar': '1.0.0'}).create();
+ await d.appDir(dependencies: {'bar': '1.0.0'}).create();
await pubGet();
server.serve('foo', '4.0.0');
@@ -55,7 +55,7 @@
await pubAdd(args: ['foo']);
- await d.appDir({'foo': '^3.2.1', 'bar': '1.0.0'}).validate();
+ await d.appDir(dependencies: {'foo': '^3.2.1', 'bar': '1.0.0'}).validate();
await d.cacheDir({'foo': '3.2.1', 'bar': '1.0.0'}).validate();
await d.appPackageConfigFile([
d.packageConfigEntry(name: 'foo', version: '3.2.1'),
@@ -72,7 +72,7 @@
server.serve('foo', '3.2.1');
server.serve('bar', '1.0.0', deps: {'foo': '^3.2.1'});
- await d.appDir({'bar': '^1.0.0'}).create();
+ await d.appDir(dependencies: {'bar': '^1.0.0'}).create();
await pubGet();
server.serve('foo', '5.0.0');
@@ -82,7 +82,7 @@
await pubAdd(args: ['foo']);
- await d.appDir({'foo': '^4.0.0', 'bar': '^1.0.0'}).validate();
+ await d.appDir(dependencies: {'foo': '^4.0.0', 'bar': '^1.0.0'}).validate();
await d.cacheDir({'foo': '4.0.0', 'bar': '1.5.0'}).validate();
await d.appPackageConfigFile([
d.packageConfigEntry(name: 'foo', version: '4.0.0'),
diff --git a/test/add/git/git_test.dart b/test/add/git/git_test.dart
index 9890835..540a219 100644
--- a/test/add/git/git_test.dart
+++ b/test/add/git/git_test.dart
@@ -12,9 +12,11 @@
ensureGit();
await d.git(
- 'foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(args: ['foo', '--git-url', '../foo.git']);
@@ -25,18 +27,22 @@
])
]).validate();
- await d.appDir({
- 'foo': {'git': '../foo.git'}
- }).validate();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'git': '../foo.git'}
+ },
+ ).validate();
});
test('adds a package from git with relative url and --directory', () async {
ensureGit();
await d.git(
- 'foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(
args: ['--directory', appPath, 'foo', '--git-url', 'foo.git'],
@@ -51,18 +57,22 @@
])
]).validate();
- await d.appDir({
- 'foo': {'git': '../foo.git'}
- }).validate();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'git': '../foo.git'}
+ },
+ ).validate();
});
test('fails with invalid --git-url', () async {
ensureGit();
await d.git(
- 'foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(
args: ['foo', '--git-url', ':'],
@@ -76,9 +86,11 @@
ensureGit();
await d.git(
- 'foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(args: ['foo:1.0.0', '--git-url', '../foo.git']);
@@ -89,27 +101,32 @@
])
]).validate();
- await d.appDir({
- 'foo': {'git': '../foo.git', 'version': '1.0.0'}
- }).validate();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'git': '../foo.git', 'version': '1.0.0'}
+ },
+ ).validate();
});
test('fails when adding with an invalid version constraint', () async {
ensureGit();
await d.git(
- 'foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(
- args: ['foo:2.0.0', '--git-url', '../foo.git'],
- error: equalsIgnoringWhitespace(
- 'Because myapp depends on foo 2.0.0 from git which doesn\'t match '
- 'any versions, version solving failed.'),
- exitCode: exit_codes.DATA);
+ args: ['foo:2.0.0', '--git-url', '../foo.git'],
+ error: equalsIgnoringWhitespace(
+ 'Because myapp depends on foo 2.0.0 from git which doesn\'t match '
+ 'any versions, version solving failed.'),
+ exitCode: exit_codes.DATA,
+ );
- await d.appDir({}).validate();
+ await d.appDir(dependencies: {}).validate();
await d.dir(appPath, [
d.nothing('.dart_tool/package_config.json'),
d.nothing('pubspec.lock'),
@@ -120,15 +137,16 @@
test('fails when adding from an non-existing url', () async {
ensureGit();
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(
- args: ['foo', '--git-url', '../foo.git'],
- error: contains('Unable to resolve package "foo" with the given '
- 'git parameters'),
- exitCode: exit_codes.DATA);
+ args: ['foo', '--git-url', '../foo.git'],
+ error: contains('Unable to resolve package "foo" with the given '
+ 'git parameters'),
+ exitCode: exit_codes.DATA,
+ );
- await d.appDir({}).validate();
+ await d.appDir(dependencies: {}).validate();
await d.dir(appPath, [
d.nothing('.dart_tool/package_config.json'),
d.nothing('pubspec.lock'),
@@ -139,14 +157,15 @@
test('fails if git-url is not declared', () async {
ensureGit();
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(
- args: ['foo', '--git-ref', 'master'],
- error: contains('The `--git-url` is required for git dependencies.'),
- exitCode: exit_codes.USAGE);
+ args: ['foo', '--git-ref', 'master'],
+ error: contains('The `--git-url` is required for git dependencies.'),
+ exitCode: exit_codes.USAGE,
+ );
- await d.appDir({}).validate();
+ await d.appDir(dependencies: {}).validate();
await d.dir(appPath, [
d.nothing('.dart_tool/package_config.json'),
d.nothing('pubspec.lock'),
@@ -159,7 +178,9 @@
server.serve('foo', '1.2.2');
await d.git(
- 'foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
await d.dir(appPath, [
d.pubspec({
@@ -189,19 +210,20 @@
test('fails if multiple packages passed for git source', () async {
ensureGit();
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(
- args: ['foo', 'bar', 'baz', '--git-url', '../foo.git'],
- exitCode: exit_codes.USAGE,
- error: contains('Specify multiple git packages with descriptors.'));
+ args: ['foo', 'bar', 'baz', '--git-url', '../foo.git'],
+ exitCode: exit_codes.USAGE,
+ error: contains('Specify multiple git packages with descriptors.'),
+ );
});
test('Can add a package with a git descriptor and relative path', () async {
await d.git('foo.git', [
d.dir('subdir', [d.libPubspec('foo', '1.2.3')])
]).create();
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(
args: [
'--directory',
@@ -212,27 +234,35 @@
output: contains('Changed 1 dependency in myapp!'),
);
- await d.appDir({
- 'foo': {
- 'git': {'url': '../foo.git', 'path': 'subdir'}
- }
- }).validate();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'git': {'url': '../foo.git', 'path': 'subdir'}
+ }
+ },
+ ).validate();
});
test('Can add multiple git packages using descriptors', () async {
ensureGit();
await d.git(
- 'foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
await d.git(
- 'bar.git', [d.libDir('foo'), d.libPubspec('bar', '1.0.0')]).create();
+ 'bar.git',
+ [d.libDir('foo'), d.libPubspec('bar', '1.0.0')],
+ ).create();
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
- await pubAdd(args: [
- 'foo:{"git":"../foo.git"}',
- 'bar:{"git":"../bar.git"}',
- ]);
+ await pubAdd(
+ args: [
+ 'foo:{"git":"../foo.git"}',
+ 'bar:{"git":"../bar.git"}',
+ ],
+ );
await d.dir(appPath, [
d.pubspec({
diff --git a/test/add/git/ref_test.dart b/test/add/git/ref_test.dart
index 11dfc0b..5db6d1a 100644
--- a/test/add/git/ref_test.dart
+++ b/test/add/git/ref_test.dart
@@ -13,14 +13,18 @@
ensureGit();
final repo = d.git(
- 'foo.git', [d.libDir('foo', 'foo 1'), d.libPubspec('foo', '1.0.0')]);
+ 'foo.git',
+ [d.libDir('foo', 'foo 1'), d.libPubspec('foo', '1.0.0')],
+ );
await repo.create();
await repo.runGit(['branch', 'old']);
- await d.git('foo.git',
- [d.libDir('foo', 'foo 2'), d.libPubspec('foo', '1.0.0')]).commit();
+ await d.git(
+ 'foo.git',
+ [d.libDir('foo', 'foo 2'), d.libPubspec('foo', '1.0.0')],
+ ).commit();
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(args: ['foo', '--git-url', '../foo.git', '--git-ref', 'old']);
@@ -33,33 +37,40 @@
])
]).validate();
- await d.appDir({
- 'foo': {
- 'git': {'url': '../foo.git', 'ref': 'old'}
- }
- }).validate();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'git': {'url': '../foo.git', 'ref': 'old'}
+ }
+ },
+ ).validate();
});
test('fails when adding from an invalid ref', () async {
ensureGit();
final repo = d.git(
- 'foo.git', [d.libDir('foo', 'foo 1'), d.libPubspec('foo', '1.0.0')]);
+ 'foo.git',
+ [d.libDir('foo', 'foo 1'), d.libPubspec('foo', '1.0.0')],
+ );
await repo.create();
await repo.runGit(['branch', 'new']);
- await d.git('foo.git',
- [d.libDir('foo', 'foo 2'), d.libPubspec('foo', '1.0.0')]).commit();
+ await d.git(
+ 'foo.git',
+ [d.libDir('foo', 'foo 2'), d.libPubspec('foo', '1.0.0')],
+ ).commit();
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(
- args: ['foo', '--git-url', '../foo.git', '--git-ref', 'old'],
- error: contains('Unable to resolve package "foo" with the given '
- 'git parameters'),
- exitCode: exit_codes.DATA);
+ args: ['foo', '--git-url', '../foo.git', '--git-ref', 'old'],
+ error: contains('Unable to resolve package "foo" with the given '
+ 'git parameters'),
+ exitCode: exit_codes.DATA,
+ );
- await d.appDir({}).validate();
+ await d.appDir(dependencies: {}).validate();
await d.dir(appPath, [
d.nothing('.dart_tool/package_config.json'),
d.nothing('pubspec.lock'),
diff --git a/test/add/git/subdir_test.dart b/test/add/git/subdir_test.dart
index 8e8c39c..8d3146f 100644
--- a/test/add/git/subdir_test.dart
+++ b/test/add/git/subdir_test.dart
@@ -17,10 +17,11 @@
await repo.create();
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(
- args: ['sub', '--git-url', '../foo.git', '--git-path', 'subdir']);
+ args: ['sub', '--git-url', '../foo.git', '--git-path', 'subdir'],
+ );
await d.dir(cachePath, [
d.dir('git', [
@@ -32,15 +33,18 @@
]).validate();
await d.appPackageConfigFile([
d.packageConfigEntry(
- name: 'sub',
- path: pathInCache('git/foo-${await repo.revParse('HEAD')}/subdir')),
+ name: 'sub',
+ path: pathInCache('git/foo-${await repo.revParse('HEAD')}/subdir'),
+ ),
]).validate();
- await d.appDir({
- 'sub': {
- 'git': {'url': '../foo.git', 'path': 'subdir'}
- }
- }).validate();
+ await d.appDir(
+ dependencies: {
+ 'sub': {
+ 'git': {'url': '../foo.git', 'path': 'subdir'}
+ }
+ },
+ ).validate();
});
test('adds a package in a deep subdirectory', () async {
@@ -53,10 +57,11 @@
]);
await repo.create();
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(
- args: ['sub', '--git-url', '../foo.git', '--git-path', 'sub/dir']);
+ args: ['sub', '--git-url', '../foo.git', '--git-path', 'sub/dir'],
+ );
await d.dir(cachePath, [
d.dir('git', [
@@ -71,14 +76,17 @@
await d.appPackageConfigFile([
d.packageConfigEntry(
- name: 'sub',
- path: pathInCache('git/foo-${await repo.revParse('HEAD')}/sub/dir')),
+ name: 'sub',
+ path: pathInCache('git/foo-${await repo.revParse('HEAD')}/sub/dir'),
+ ),
]).validate();
- await d.appDir({
- 'sub': {
- 'git': {'url': '../foo.git', 'path': 'sub/dir'}
- }
- }).validate();
+ await d.appDir(
+ dependencies: {
+ 'sub': {
+ 'git': {'url': '../foo.git', 'path': 'sub/dir'}
+ }
+ },
+ ).validate();
});
}
diff --git a/test/add/hosted/non_default_pub_server_test.dart b/test/add/hosted/non_default_pub_server_test.dart
index f93f292..f6767a0 100644
--- a/test/add/hosted/non_default_pub_server_test.dart
+++ b/test/add/hosted/non_default_pub_server_test.dart
@@ -19,7 +19,7 @@
server.serve('foo', '1.1.0');
server.serve('foo', '1.2.3');
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
final url = server.url;
@@ -31,12 +31,14 @@
d.packageConfigEntry(name: 'foo', version: '1.2.3', server: server),
]).validate();
- await d.appDir({
- 'foo': {
- 'version': '1.2.3',
- 'hosted': {'name': 'foo', 'url': url}
- }
- }).validate();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'version': '1.2.3',
+ 'hosted': {'name': 'foo', 'url': url}
+ }
+ },
+ ).validate();
});
test('adds multiple packages from a non-default pub server', () async {
@@ -52,15 +54,18 @@
server.serve('baz', '0.1.3');
server.serve('baz', '1.3.5');
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
final url = server.url;
await pubAdd(
- args: ['foo:1.2.3', 'bar:3.2.3', 'baz:1.3.5', '--hosted-url', url]);
+ args: ['foo:1.2.3', 'bar:3.2.3', 'baz:1.3.5', '--hosted-url', url],
+ );
- await d.cacheDir({'foo': '1.2.3', 'bar': '3.2.3', 'baz': '1.3.5'},
- port: server.port).validate();
+ await d.cacheDir(
+ {'foo': '1.2.3', 'bar': '3.2.3', 'baz': '1.3.5'},
+ port: server.port,
+ ).validate();
await d.appPackageConfigFile([
d.packageConfigEntry(name: 'foo', version: '1.2.3', server: server),
@@ -68,26 +73,28 @@
d.packageConfigEntry(name: 'baz', version: '1.3.5', server: server),
]).validate();
- await d.appDir({
- 'foo': {
- 'version': '1.2.3',
- 'hosted': {'name': 'foo', 'url': url}
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'version': '1.2.3',
+ 'hosted': {'name': 'foo', 'url': url}
+ },
+ 'bar': {
+ 'version': '3.2.3',
+ 'hosted': {'name': 'bar', 'url': url}
+ },
+ 'baz': {
+ 'version': '1.3.5',
+ 'hosted': {'name': 'baz', 'url': url}
+ }
},
- 'bar': {
- 'version': '3.2.3',
- 'hosted': {'name': 'bar', 'url': url}
- },
- 'baz': {
- 'version': '1.3.5',
- 'hosted': {'name': 'baz', 'url': url}
- }
- }).validate();
+ ).validate();
});
test('fails when adding from an invalid url', () async {
ensureGit();
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(
args: ['foo', '--hosted-url', 'https://invalid-url.foo'],
@@ -100,7 +107,7 @@
},
);
- await d.appDir({}).validate();
+ await d.appDir(dependencies: {}).validate();
await d.dir(appPath, [
d.nothing('.dart_tool/package_config.json'),
d.nothing('pubspec.lock'),
@@ -120,7 +127,7 @@
server.serve('foo', '1.1.0');
server.serve('foo', '1.2.3');
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
final url = server.url;
@@ -130,12 +137,14 @@
await d.appPackageConfigFile([
d.packageConfigEntry(name: 'foo', version: '1.2.3', server: server),
]).validate();
- await d.appDir({
- 'foo': {
- 'version': '^1.2.3',
- 'hosted': {'name': 'foo', 'url': url}
- }
- }).validate();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'version': '^1.2.3',
+ 'hosted': {'name': 'foo', 'url': url}
+ }
+ },
+ ).validate();
});
test('adds a package from a non-default pub server with a version constraint',
@@ -149,7 +158,7 @@
server.serve('foo', '1.1.0');
server.serve('foo', '1.2.3');
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
final url = server.url;
@@ -159,12 +168,14 @@
await d.appPackageConfigFile([
d.packageConfigEntry(name: 'foo', version: '1.2.3', server: server),
]).validate();
- await d.appDir({
- 'foo': {
- 'version': '^1.2.3',
- 'hosted': {'name': 'foo', 'url': url}
- }
- }).validate();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'version': '^1.2.3',
+ 'hosted': {'name': 'foo', 'url': url}
+ }
+ },
+ ).validate();
});
test(
@@ -179,7 +190,7 @@
server.serve('foo', '1.1.0');
server.serve('foo', '1.2.3');
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
final url = server.url;
@@ -189,11 +200,13 @@
await d.appPackageConfigFile([
d.packageConfigEntry(name: 'foo', version: '1.2.3', server: server),
]).validate();
- await d.appDir({
- 'foo': {
- 'version': 'any',
- 'hosted': {'name': 'foo', 'url': url}
- }
- }).validate();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'version': 'any',
+ 'hosted': {'name': 'foo', 'url': url}
+ }
+ },
+ ).validate();
});
}
diff --git a/test/add/path/absolute_path_test.dart b/test/add/path/absolute_path_test.dart
index afdc3f7..9999b81 100644
--- a/test/add/path/absolute_path_test.dart
+++ b/test/add/path/absolute_path_test.dart
@@ -14,7 +14,7 @@
await d
.dir('foo', [d.libDir('foo'), d.libPubspec('foo', '0.0.1')]).create();
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
final absolutePath = path.join(d.sandbox, 'foo');
@@ -24,40 +24,47 @@
d.packageConfigEntry(name: 'foo', path: absolutePath),
]).validate();
- await d.appDir({
- 'foo': {'path': absolutePath}
- }).validate();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'path': absolutePath}
+ },
+ ).validate();
});
test('adds a package from absolute path with version constraint', () async {
await d
.dir('foo', [d.libDir('foo'), d.libPubspec('foo', '0.0.1')]).create();
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
final absolutePath = path.join(d.sandbox, 'foo');
await pubAdd(args: ['foo:0.0.1', '--path', absolutePath]);
- await d.appDir({
- 'foo': {'path': absolutePath, 'version': '0.0.1'}
- }).validate();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'path': absolutePath, 'version': '0.0.1'}
+ },
+ ).validate();
});
test('fails when adding multiple packages through local path', () async {
ensureGit();
await d.git(
- 'foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
final absolutePath = path.join(d.sandbox, 'foo');
await pubAdd(
- args: ['foo:2.0.0', 'bar:0.1.3', 'baz:1.3.1', '--path', absolutePath],
- error: contains('--path cannot be used with multiple packages.'),
- exitCode: exit_codes.USAGE);
+ args: ['foo:2.0.0', 'bar:0.1.3', 'baz:1.3.1', '--path', absolutePath],
+ error: contains('--path cannot be used with multiple packages.'),
+ exitCode: exit_codes.USAGE,
+ );
- await d.appDir({}).validate();
+ await d.appDir(dependencies: {}).validate();
await d.dir(appPath, [
d.nothing('.dart_tool/package_config.json'),
d.nothing('pubspec.lock'),
@@ -69,20 +76,23 @@
ensureGit();
await d.git(
- 'foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
final absolutePath = path.join(d.sandbox, 'foo');
await pubAdd(
- args: ['foo:2.0.0', '--path', absolutePath],
- error: equalsIgnoringWhitespace(
- 'Because myapp depends on foo from path which doesn\'t exist '
- '(could not find package foo at "$absolutePath"), version solving '
- 'failed.'),
- exitCode: exit_codes.DATA);
+ args: ['foo:2.0.0', '--path', absolutePath],
+ error: equalsIgnoringWhitespace(
+ 'Because myapp depends on foo from path which doesn\'t exist '
+ '(could not find package foo at "$absolutePath"), version solving '
+ 'failed.'),
+ exitCode: exit_codes.DATA,
+ );
- await d.appDir({}).validate();
+ await d.appDir(dependencies: {}).validate();
await d.dir(appPath, [
d.nothing('.dart_tool/package_config.json'),
d.nothing('pubspec.lock'),
@@ -91,19 +101,20 @@
});
test('fails if path does not exist', () async {
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
final absolutePath = path.join(d.sandbox, 'foo');
await pubAdd(
- args: ['foo', '--path', absolutePath],
- error: equalsIgnoringWhitespace(
- 'Because myapp depends on foo from path which doesn\'t exist '
- '(could not find package foo at "$absolutePath"), version solving '
- 'failed.'),
- exitCode: exit_codes.DATA);
+ args: ['foo', '--path', absolutePath],
+ error: equalsIgnoringWhitespace(
+ 'Because myapp depends on foo from path which doesn\'t exist '
+ '(could not find package foo at "$absolutePath"), version solving '
+ 'failed.'),
+ exitCode: exit_codes.DATA,
+ );
- await d.appDir({}).validate();
+ await d.appDir(dependencies: {}).validate();
await d.dir(appPath, [
d.nothing('.dart_tool/package_config.json'),
d.nothing('pubspec.lock'),
diff --git a/test/add/path/relative_path_test.dart b/test/add/path/relative_path_test.dart
index a25e557..7da10f8 100644
--- a/test/add/path/relative_path_test.dart
+++ b/test/add/path/relative_path_test.dart
@@ -15,7 +15,7 @@
await d
.dir('foo', [d.libDir('foo'), d.libPubspec('foo', '0.0.1')]).create();
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(args: ['foo', '--path', '../foo']);
@@ -23,9 +23,11 @@
d.packageConfigEntry(name: 'foo', path: '../foo'),
]).validate();
- await d.appDir({
- 'foo': {'path': '../foo'}
- }).validate();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'path': '../foo'}
+ },
+ ).validate();
});
test('can use relative path with a path descriptor', () async {
@@ -52,7 +54,7 @@
await d
.dir('foo', [d.libDir('foo'), d.libPubspec('foo', '0.0.1')]).create();
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(
args: ['--directory', appPath, 'foo', '--path', 'foo'],
@@ -64,23 +66,26 @@
d.packageConfigEntry(name: 'foo', path: '../foo'),
]).validate();
- await d.appDir({
- 'foo': {'path': '../foo'}
- }).validate();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'path': '../foo'}
+ },
+ ).validate();
});
test('fails if path does not exist', () async {
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(
- args: ['foo', '--path', '../foo'],
- error: equalsIgnoringWhitespace(
- 'Because myapp depends on foo from path which doesn\'t exist '
- '(could not find package foo at "..${Platform.pathSeparator}foo"), '
- 'version solving failed.'),
- exitCode: exit_codes.DATA);
+ args: ['foo', '--path', '../foo'],
+ error: equalsIgnoringWhitespace(
+ 'Because myapp depends on foo from path which doesn\'t exist '
+ '(could not find package foo at "..${Platform.pathSeparator}foo"), '
+ 'version solving failed.'),
+ exitCode: exit_codes.DATA,
+ );
- await d.appDir({}).validate();
+ await d.appDir(dependencies: {}).validate();
await d.dir(appPath, [
d.nothing('.dart_tool/package_config.json'),
d.nothing('pubspec.lock'),
@@ -92,32 +97,37 @@
await d
.dir('foo', [d.libDir('foo'), d.libPubspec('foo', '0.0.1')]).create();
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(args: ['foo:0.0.1', '--path', '../foo']);
- await d.appDir({
- 'foo': {'path': '../foo', 'version': '0.0.1'}
- }).validate();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'path': '../foo', 'version': '0.0.1'}
+ },
+ ).validate();
});
test('fails when adding with an invalid version constraint', () async {
ensureGit();
await d.git(
- 'foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(
- args: ['foo:2.0.0', '--path', '../foo'],
- error: equalsIgnoringWhitespace(
- 'Because myapp depends on foo from path which doesn\'t exist '
- '(could not find package foo at "..${Platform.pathSeparator}foo"), '
- 'version solving failed.'),
- exitCode: exit_codes.DATA);
+ args: ['foo:2.0.0', '--path', '../foo'],
+ error: equalsIgnoringWhitespace(
+ 'Because myapp depends on foo from path which doesn\'t exist '
+ '(could not find package foo at "..${Platform.pathSeparator}foo"), '
+ 'version solving failed.'),
+ exitCode: exit_codes.DATA,
+ );
- await d.appDir({}).validate();
+ await d.appDir(dependencies: {}).validate();
await d.dir(appPath, [
d.nothing('.dart_tool/package_config.json'),
d.nothing('pubspec.lock'),
@@ -162,7 +172,7 @@
await d
.dir('bar', [d.libDir('bar'), d.libPubspec('bar', '0.0.1')]).create();
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(
args: [
@@ -180,9 +190,11 @@
d.packageConfigEntry(name: 'bar', path: '../bar'),
]).validate();
- await d.appDir({
- 'foo': {'path': '../foo'},
- 'bar': {'path': '../bar'},
- }).validate();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'path': '../foo'},
+ 'bar': {'path': '../bar'},
+ },
+ ).validate();
});
}
diff --git a/test/add/sdk/sdk_test.dart b/test/add/sdk/sdk_test.dart
index 7c81727..144f02d 100644
--- a/test/add/sdk/sdk_test.dart
+++ b/test/add/sdk/sdk_test.dart
@@ -23,17 +23,20 @@
]),
d.dir('bin/cache/pkg', [
d.dir(
- 'baz', [d.libDir('baz', 'foo 0.0.1'), d.libPubspec('baz', '0.0.1')])
+ 'baz',
+ [d.libDir('baz', 'foo 0.0.1'), d.libPubspec('baz', '0.0.1')],
+ )
]),
d.file('version', '1.2.3')
]).create();
});
test("adds an SDK dependency's dependencies", () async {
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(
- args: ['foo', '--sdk', 'flutter'],
- environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')});
+ args: ['foo', '--sdk', 'flutter'],
+ environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
+ );
await d.dir(appPath, [
d.pubspec({
@@ -46,7 +49,9 @@
await d.appPackageConfigFile([
d.packageConfigEntry(
- name: 'foo', path: p.join(d.sandbox, 'flutter', 'packages', 'foo')),
+ name: 'foo',
+ path: p.join(d.sandbox, 'flutter', 'packages', 'foo'),
+ ),
d.packageConfigEntry(name: 'bar', version: '1.0.0'),
]).validate();
});
@@ -54,10 +59,11 @@
test(
"adds an SDK dependency's dependencies with version constraint specified",
() async {
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(
- args: ['foo:0.0.1', '--sdk', 'flutter'],
- environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')});
+ args: ['foo:0.0.1', '--sdk', 'flutter'],
+ environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
+ );
await d.dir(appPath, [
d.pubspec({
@@ -69,36 +75,41 @@
]).validate();
await d.appPackageConfigFile([
d.packageConfigEntry(
- name: 'foo', path: p.join(d.sandbox, 'flutter', 'packages', 'foo')),
+ name: 'foo',
+ path: p.join(d.sandbox, 'flutter', 'packages', 'foo'),
+ ),
d.packageConfigEntry(name: 'bar', version: '1.0.0'),
]).validate();
});
test('adds an SDK dependency from bin/cache/pkg', () async {
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(
- args: ['baz', '--sdk', 'flutter'],
- environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')});
+ args: ['baz', '--sdk', 'flutter'],
+ environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
+ );
await d.appPackageConfigFile([
d.packageConfigEntry(
- name: 'baz',
- path: p.join(d.sandbox, 'flutter', 'bin', 'cache', 'pkg', 'baz'))
+ name: 'baz',
+ path: p.join(d.sandbox, 'flutter', 'bin', 'cache', 'pkg', 'baz'),
+ )
]).validate();
});
test("fails if the version constraint doesn't match", () async {
- await d.appDir({}).create();
+ await d.appDir(dependencies: {}).create();
await pubAdd(
- args: ['foo:^1.0.0', '--sdk', 'flutter'],
- environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
- error: equalsIgnoringWhitespace("""
+ args: ['foo:^1.0.0', '--sdk', 'flutter'],
+ environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
+ error: equalsIgnoringWhitespace("""
Because myapp depends on foo ^1.0.0 from sdk which doesn't match
any versions, version solving failed.
"""),
- exitCode: exit_codes.DATA);
+ exitCode: exit_codes.DATA,
+ );
- await d.appDir({}).validate();
+ await d.appDir(dependencies: {}).validate();
await d.dir(appPath, [
d.nothing('.dart_tool/package_config.json'),
d.nothing('pubspec.lock'),
diff --git a/test/ascii_tree_test.dart b/test/ascii_tree_test.dart
index a4b0163..5a775e8 100644
--- a/test/ascii_tree_test.dart
+++ b/test/ascii_tree_test.dart
@@ -67,7 +67,8 @@
(name) => throw UnimplementedError(),
).listFiles();
ctx.expectNextSection(
- tree.fromFiles(files, baseDir: path(appPath), showFileSizes: true));
+ tree.fromFiles(files, baseDir: path(appPath), showFileSizes: true),
+ );
});
test('tree.fromMap empty map', () {
expect(tree.fromMap({}), equals(''));
diff --git a/test/cache/add/adds_latest_matching_version_test.dart b/test/cache/add/adds_latest_matching_version_test.dart
index 9e06bf7..420a1cc 100644
--- a/test/cache/add/adds_latest_matching_version_test.dart
+++ b/test/cache/add/adds_latest_matching_version_test.dart
@@ -20,15 +20,16 @@
..serve('foo', '2.0.0');
await runPub(
- args: ['cache', 'add', 'foo', '-v', '>=1.0.0 <2.0.0'],
- silent: allOf([
- contains('Downloading foo 1.2.3...'),
- contains('X-Pub-OS: ${Platform.operatingSystem}'),
- contains('X-Pub-Command: cache add'),
- contains('X-Pub-Session-ID:'),
- contains('X-Pub-Environment: test-environment'),
- isNot(contains('X-Pub-Reason')),
- ]));
+ args: ['cache', 'add', 'foo', '-v', '>=1.0.0 <2.0.0'],
+ silent: allOf([
+ contains('Downloading foo 1.2.3...'),
+ contains('X-Pub-OS: ${Platform.operatingSystem}'),
+ contains('X-Pub-Command: cache add'),
+ contains('X-Pub-Session-ID:'),
+ contains('X-Pub-Environment: test-environment'),
+ isNot(contains('X-Pub-Reason')),
+ ]),
+ );
await d.cacheDir({'foo': '1.2.3'}).validate();
await d.hostedCache([
diff --git a/test/cache/add/all_with_some_versions_present_test.dart b/test/cache/add/all_with_some_versions_present_test.dart
index 82d9fd5..3dcb2d1 100644
--- a/test/cache/add/all_with_some_versions_present_test.dart
+++ b/test/cache/add/all_with_some_versions_present_test.dart
@@ -17,23 +17,26 @@
// Install a couple of versions first.
await runPub(
- args: ['cache', 'add', 'foo', '-v', '1.2.1'],
- silent: contains('Downloading foo 1.2.1...'));
+ args: ['cache', 'add', 'foo', '-v', '1.2.1'],
+ silent: contains('Downloading foo 1.2.1...'),
+ );
await runPub(
- args: ['cache', 'add', 'foo', '-v', '1.2.3'],
- silent: contains('Downloading foo 1.2.3...'));
+ args: ['cache', 'add', 'foo', '-v', '1.2.3'],
+ silent: contains('Downloading foo 1.2.3...'),
+ );
// They should show up as already installed now.
await runPub(
- args: ['cache', 'add', 'foo', '--all'],
- silent: allOf([
- contains('Downloading foo 1.2.2...'),
- contains('Downloading foo 2.0.0...')
- ]),
- output: '''
+ args: ['cache', 'add', 'foo', '--all'],
+ silent: allOf([
+ contains('Downloading foo 1.2.2...'),
+ contains('Downloading foo 2.0.0...')
+ ]),
+ output: '''
Already cached foo 1.2.1.
-Already cached foo 1.2.3.''');
+Already cached foo 1.2.3.''',
+ );
await d.cacheDir({'foo': '1.2.1'}).validate();
await d.cacheDir({'foo': '1.2.2'}).validate();
diff --git a/test/cache/add/already_cached_test.dart b/test/cache/add/already_cached_test.dart
index ef9452e..a98cb82 100644
--- a/test/cache/add/already_cached_test.dart
+++ b/test/cache/add/already_cached_test.dart
@@ -14,12 +14,15 @@
// Run once to put it in the cache.
await runPub(
- args: ['cache', 'add', 'foo'],
- silent: contains('Downloading foo 1.2.3...'));
+ args: ['cache', 'add', 'foo'],
+ silent: contains('Downloading foo 1.2.3...'),
+ );
// Should be in the cache now.
await runPub(
- args: ['cache', 'add', 'foo'], output: 'Already cached foo 1.2.3.');
+ args: ['cache', 'add', 'foo'],
+ output: 'Already cached foo 1.2.3.',
+ );
await d.cacheDir({'foo': '1.2.3'}).validate();
});
diff --git a/test/cache/add/no_matching_version_test.dart b/test/cache/add/no_matching_version_test.dart
index a860294..5863cbc 100644
--- a/test/cache/add/no_matching_version_test.dart
+++ b/test/cache/add/no_matching_version_test.dart
@@ -13,8 +13,9 @@
..serve('foo', '1.2.3');
await runPub(
- args: ['cache', 'add', 'foo', '-v', '>2.0.0'],
- error: 'Package foo has no versions that match >2.0.0.',
- exitCode: 1);
+ args: ['cache', 'add', 'foo', '-v', '>2.0.0'],
+ error: 'Package foo has no versions that match >2.0.0.',
+ exitCode: 1,
+ );
});
}
diff --git a/test/cache/add/package_not_found_test.dart b/test/cache/add/package_not_found_test.dart
index caf45f4..e929c7b 100644
--- a/test/cache/add/package_not_found_test.dart
+++ b/test/cache/add/package_not_found_test.dart
@@ -12,10 +12,11 @@
await servePackages();
await runPub(
- args: ['cache', 'add', 'foo'],
- error: RegExp(
- r'Package not available \(could not find package foo at http://.*\)\.',
- ),
- exitCode: exit_codes.UNAVAILABLE);
+ args: ['cache', 'add', 'foo'],
+ error: RegExp(
+ r'Package not available \(could not find package foo at http://.*\)\.',
+ ),
+ exitCode: exit_codes.UNAVAILABLE,
+ );
});
}
diff --git a/test/cache/clean_test.dart b/test/cache/clean_test.dart
index b5909b5..0e4a9e7 100644
--- a/test/cache/clean_test.dart
+++ b/test/cache/clean_test.dart
@@ -20,18 +20,20 @@
await servePackages()
..serve('foo', '1.1.2')
..serve('bar', '1.2.3');
- await d.appDir({'foo': 'any', 'bar': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any', 'bar': 'any'}).create();
await pubGet();
final cache = path.join(d.sandbox, cachePath);
expect(listDir(cache, includeHidden: true), contains(endsWith('hosted')));
await runPub(
- args: ['cache', 'clean', '--force'],
- output: 'Removing pub cache directory $cache.');
+ args: ['cache', 'clean', '--force'],
+ output: 'Removing pub cache directory $cache.',
+ );
expect(
- listDir(cache, includeHidden: true),
- // The README.md will be reconstructed.
- [pathInCache('README.md')]);
+ listDir(cache, includeHidden: true),
+ // The README.md will be reconstructed.
+ [pathInCache('README.md')],
+ );
});
test('running pub cache clean deletes cache only with confirmation',
@@ -39,7 +41,7 @@
await servePackages()
..serve('foo', '1.1.2')
..serve('bar', '1.2.3');
- await d.appDir({'foo': 'any', 'bar': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any', 'bar': 'any'}).create();
await pubGet();
final cache = path.join(d.sandbox, cachePath);
expect(
@@ -66,8 +68,11 @@
expect(await process.exitCode, 0);
}
expect(
- listDir(cache,
- includeHidden: true), // The README.md will be reconstructed.
- [pathInCache('README.md')]);
+ listDir(
+ cache,
+ includeHidden: true,
+ ), // The README.md will be reconstructed.
+ [pathInCache('README.md')],
+ );
});
}
diff --git a/test/cache/create_readme_test.dart b/test/cache/create_readme_test.dart
index 035fd68..70a02a6 100644
--- a/test/cache/create_readme_test.dart
+++ b/test/cache/create_readme_test.dart
@@ -14,7 +14,7 @@
await pubGet();
await d.nothing(cachePath).validate();
- await d.appDir({'foo': '1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '1.0.0'}).create();
await pubGet();
await d.dir(cachePath, [
d.file('README.md', contains('https://dart.dev/go/pub-cache'))
@@ -28,7 +28,7 @@
test('PUB_CACHE/README.md gets created by `dart pub cache clean`', () async {
final server = await servePackages();
server.serve('foo', '1.0.0');
- await d.appDir({'foo': '1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '1.0.0'}).create();
await pubGet();
await d.dir(cachePath, [
d.file('README.md', contains('https://dart.dev/go/pub-cache'))
diff --git a/test/cache/list_test.dart b/test/cache/list_test.dart
index c554c22..c5fd2fb 100644
--- a/test/cache/list_test.dart
+++ b/test/cache/list_test.dart
@@ -37,19 +37,19 @@
])
]).create();
- await runPub(args: [
- 'cache',
- 'list'
- ], outputJson: {
- 'packages': {
- 'bar': {
- '2.0.0': {'location': hostedDir('bar-2.0.0')}
- },
- 'foo': {
- '1.2.3': {'location': hostedDir('foo-1.2.3')}
+ await runPub(
+ args: ['cache', 'list'],
+ outputJson: {
+ 'packages': {
+ 'bar': {
+ '2.0.0': {'location': hostedDir('bar-2.0.0')}
+ },
+ 'foo': {
+ '1.2.3': {'location': hostedDir('foo-1.2.3')}
+ }
}
- }
- });
+ },
+ );
});
test('includes packages containing deps with bad sources', () async {
@@ -58,24 +58,28 @@
d.dir('hosted', [
d.dir('pub.dev', [
d.dir('foo-1.2.3', [
- d.libPubspec('foo', '1.2.3', deps: {
- 'bar': {'bad': 'bar'}
- }),
+ d.libPubspec(
+ 'foo',
+ '1.2.3',
+ deps: {
+ 'bar': {'bad': 'bar'}
+ },
+ ),
d.libDir('foo')
])
])
])
]).create();
- await runPub(args: [
- 'cache',
- 'list'
- ], outputJson: {
- 'packages': {
- 'foo': {
- '1.2.3': {'location': hostedDir('foo-1.2.3')}
+ await runPub(
+ args: ['cache', 'list'],
+ outputJson: {
+ 'packages': {
+ 'foo': {
+ '1.2.3': {'location': hostedDir('foo-1.2.3')}
+ }
}
- }
- });
+ },
+ );
});
}
diff --git a/test/cache/preload_test.dart b/test/cache/preload_test.dart
index 3bf5f64..3796672 100644
--- a/test/cache/preload_test.dart
+++ b/test/cache/preload_test.dart
@@ -19,7 +19,7 @@
server.serve('foo', '1.0.0');
server.serve('foo', '2.0.0');
- await appDir({'foo': '^2.0.0'}).create();
+ await appDir(dependencies: {'foo': '^2.0.0'}).create();
// Do a `pub get` here to create a lock file in order to validate we later can
// `pub get --offline` with packages installed by `preload`.
await pubGet();
@@ -29,10 +29,16 @@
final archivePath1 = p.join(sandbox, 'foo-1.0.0-archive.tar.gz');
final archivePath2 = p.join(sandbox, 'foo-2.0.0-archive.tar.gz');
- File(archivePath1).writeAsBytesSync(await readBytes(
- Uri.parse(server.url).resolve('packages/foo/versions/1.0.0.tar.gz')));
- File(archivePath2).writeAsBytesSync(await readBytes(
- Uri.parse(server.url).resolve('packages/foo/versions/2.0.0.tar.gz')));
+ File(archivePath1).writeAsBytesSync(
+ await readBytes(
+ Uri.parse(server.url).resolve('packages/foo/versions/1.0.0.tar.gz'),
+ ),
+ );
+ File(archivePath2).writeAsBytesSync(
+ await readBytes(
+ Uri.parse(server.url).resolve('packages/foo/versions/2.0.0.tar.gz'),
+ ),
+ );
await runPub(
args: ['cache', 'preload', archivePath1, archivePath2],
environment: {'_PUB_TEST_DEFAULT_HOSTED_URL': server.url},
@@ -65,8 +71,11 @@
final archivePath = p.join(sandbox, 'archive');
- File(archivePath).writeAsBytesSync(await readBytes(
- Uri.parse(server.url).resolve('packages/foo/versions/1.0.0.tar.gz')));
+ File(archivePath).writeAsBytesSync(
+ await readBytes(
+ Uri.parse(server.url).resolve('packages/foo/versions/1.0.0.tar.gz'),
+ ),
+ );
await runPub(
args: ['cache', 'preload', archivePath],
// By having pub.dev be the "official" server the test-server (localhost)
@@ -75,7 +84,8 @@
environment: {'_PUB_TEST_DEFAULT_HOSTED_URL': 'pub.dev'},
output: allOf([
contains(
- 'Installed $archivePath in cache as foo 1.0.0 from ${server.url}.')
+ 'Installed $archivePath in cache as foo 1.0.0 from ${server.url}.',
+ )
]),
);
await d.cacheDir({'foo': '1.0.0'}).validate();
@@ -165,9 +175,10 @@
final archivePath = p.join(sandbox, 'archive');
File(archivePath).writeAsBytesSync(
- await tarFromDescriptors([d.file('pubspec.yaml', '{}')])
- .expand((x) => x)
- .toList());
+ await tarFromDescriptors([d.file('pubspec.yaml', '{}')])
+ .expand((x) => x)
+ .toList(),
+ );
await runPub(
args: ['cache', 'preload', archivePath],
diff --git a/test/cache/repair/empty_cache_test.dart b/test/cache/repair/empty_cache_test.dart
index 13d68cc..29f6843 100644
--- a/test/cache/repair/empty_cache_test.dart
+++ b/test/cache/repair/empty_cache_test.dart
@@ -10,7 +10,8 @@
test('does nothing if the cache is empty', () {
// Repair them.
return runPub(
- args: ['cache', 'repair'],
- output: 'No packages in cache, so nothing to repair.');
+ args: ['cache', 'repair'],
+ output: 'No packages in cache, so nothing to repair.',
+ );
});
}
diff --git a/test/cache/repair/git_test.dart b/test/cache/repair/git_test.dart
index 262343a..0a6fa18 100644
--- a/test/cache/repair/git_test.dart
+++ b/test/cache/repair/git_test.dart
@@ -15,15 +15,21 @@
setUp(() async {
// Create two cached revisions of foo.
await d.git(
- 'foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
- await d.appDir({
- 'foo': {'git': '../foo.git'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'git': '../foo.git'}
+ },
+ ).create();
await pubGet();
await d.git(
- 'foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.1')]).commit();
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.1')],
+ ).commit();
await pubUpgrade();
});
@@ -41,10 +47,13 @@
}
// Repair them.
- await runPub(args: ['cache', 'repair'], output: '''
+ await runPub(
+ args: ['cache', 'repair'],
+ output: '''
Resetting Git repository for foo 1.0.0...
Resetting Git repository for foo 1.0.1...
- Reinstalled 2 packages.''');
+ Reinstalled 2 packages.''',
+ );
// The missing libraries should have been replaced.
var fooLibs = fooDirs.map((dir) {
@@ -68,18 +77,19 @@
}
await runPub(
- args: ['cache', 'repair'],
- error: allOf([
- contains('Failed to load package:'),
- contains('Could not find a file named "pubspec.yaml" in '),
- contains('foo-'),
- ]),
- output: allOf([
- startsWith('Failed to reinstall 2 packages:'),
- contains('- foo 0.0.0 from git'),
- contains('- foo 0.0.0 from git'),
- ]),
- exitCode: exit_codes.UNAVAILABLE);
+ args: ['cache', 'repair'],
+ error: allOf([
+ contains('Failed to load package:'),
+ contains('Could not find a file named "pubspec.yaml" in '),
+ contains('foo-'),
+ ]),
+ output: allOf([
+ startsWith('Failed to reinstall 2 packages:'),
+ contains('- foo 0.0.0 from git'),
+ contains('- foo 0.0.0 from git'),
+ ]),
+ exitCode: exit_codes.UNAVAILABLE,
+ );
await d.dir(cachePath, [
d.dir('git', fooDirs.map((dir) => d.nothing(path.basename(dir))))
@@ -97,18 +107,19 @@
}
await runPub(
- args: ['cache', 'repair'],
- error: allOf([
- contains('Failed to load package:'),
- contains('Error on line 1, column 2 of '),
- contains('foo-'),
- ]),
- output: allOf([
- startsWith('Failed to reinstall 2 packages:'),
- contains('- foo 0.0.0 from git'),
- contains('- foo 0.0.0 from git'),
- ]),
- exitCode: exit_codes.UNAVAILABLE);
+ args: ['cache', 'repair'],
+ error: allOf([
+ contains('Failed to load package:'),
+ contains('Error on line 1, column 2 of '),
+ contains('foo-'),
+ ]),
+ output: allOf([
+ startsWith('Failed to reinstall 2 packages:'),
+ contains('- foo 0.0.0 from git'),
+ contains('- foo 0.0.0 from git'),
+ ]),
+ exitCode: exit_codes.UNAVAILABLE,
+ );
await d.dir(cachePath, [
d.dir('git', fooDirs.map((dir) => d.nothing(path.basename(dir))))
@@ -123,11 +134,13 @@
d.dir('subdir', [d.libDir('sub'), d.libPubspec('sub', '1.0.0')])
]).create();
- await d.appDir({
- 'sub': {
- 'git': {'url': '../foo.git', 'path': 'subdir'}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'sub': {
+ 'git': {'url': '../foo.git', 'path': 'subdir'}
+ }
+ },
+ ).create();
await pubGet();
await d.git('foo.git', [
@@ -150,10 +163,13 @@
}
// Repair them.
- await runPub(args: ['cache', 'repair'], output: '''
+ await runPub(
+ args: ['cache', 'repair'],
+ output: '''
Resetting Git repository for sub 1.0.0...
Resetting Git repository for sub 1.0.1...
- Reinstalled 2 packages.''');
+ Reinstalled 2 packages.''',
+ );
// The missing libraries should have been replaced.
var fooLibs = fooDirs.map((dir) {
@@ -179,19 +195,20 @@
}
await runPub(
- args: ['cache', 'repair'],
- error: allOf([
- contains('Failed to load package:'),
- contains('Could not find a file named "pubspec.yaml" in '),
- contains('foo-'),
- contains('${path.separator}subdir'),
- ]),
- output: allOf([
- startsWith('Failed to reinstall 2 packages:'),
- contains('- foo 0.0.0 from git'),
- contains('- foo 0.0.0 from git'),
- ]),
- exitCode: exit_codes.UNAVAILABLE);
+ args: ['cache', 'repair'],
+ error: allOf([
+ contains('Failed to load package:'),
+ contains('Could not find a file named "pubspec.yaml" in '),
+ contains('foo-'),
+ contains('${path.separator}subdir'),
+ ]),
+ output: allOf([
+ startsWith('Failed to reinstall 2 packages:'),
+ contains('- foo 0.0.0 from git'),
+ contains('- foo 0.0.0 from git'),
+ ]),
+ exitCode: exit_codes.UNAVAILABLE,
+ );
await d.dir(cachePath, [
d.dir('git', fooDirs.map((dir) => d.nothing(path.basename(dir))))
diff --git a/test/cache/repair/handles_corrupted_binstub_test.dart b/test/cache/repair/handles_corrupted_binstub_test.dart
index 0ca169f..86f9f8e 100644
--- a/test/cache/repair/handles_corrupted_binstub_test.dart
+++ b/test/cache/repair/handles_corrupted_binstub_test.dart
@@ -10,9 +10,13 @@
void main() {
test('handles a corrupted binstub script', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', contents: [
- d.dir('bin', [d.file('script.dart', "main(args) => print('ok');")])
- ]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ contents: [
+ d.dir('bin', [d.file('script.dart', "main(args) => print('ok');")])
+ ],
+ );
await runPub(args: ['global', 'activate', 'foo']);
@@ -21,7 +25,8 @@
]).create();
await runPub(
- args: ['cache', 'repair'],
- error: contains('Error reading binstub for "script":'));
+ args: ['cache', 'repair'],
+ error: contains('Error reading binstub for "script":'),
+ );
});
}
diff --git a/test/cache/repair/handles_corrupted_global_lockfile_test.dart b/test/cache/repair/handles_corrupted_global_lockfile_test.dart
index 9a9af05..1681e42 100644
--- a/test/cache/repair/handles_corrupted_global_lockfile_test.dart
+++ b/test/cache/repair/handles_corrupted_global_lockfile_test.dart
@@ -15,10 +15,11 @@
]).create();
await runPub(
- args: ['cache', 'repair'],
- error: contains('Failed to reactivate foo:'),
- output: contains('Failed to reactivate 1 package:\n'
- '- foo'),
- exitCode: exit_codes.UNAVAILABLE);
+ args: ['cache', 'repair'],
+ error: contains('Failed to reactivate foo:'),
+ output: contains('Failed to reactivate 1 package:\n'
+ '- foo'),
+ exitCode: exit_codes.UNAVAILABLE,
+ );
});
}
diff --git a/test/cache/repair/handles_failure_test.dart b/test/cache/repair/handles_failure_test.dart
index f44a42d..d220759 100644
--- a/test/cache/repair/handles_failure_test.dart
+++ b/test/cache/repair/handles_failure_test.dart
@@ -19,12 +19,18 @@
await d.dir(cachePath, [
d.dir('hosted', [
d.dir('localhost%58${server.port}', [
- d.dir('foo-1.2.3',
- [d.libPubspec('foo', '1.2.3'), d.file('broken.txt')]),
- d.dir('foo-1.2.4',
- [d.libPubspec('foo', '1.2.4'), d.file('broken.txt')]),
d.dir(
- 'foo-1.2.5', [d.libPubspec('foo', '1.2.5'), d.file('broken.txt')])
+ 'foo-1.2.3',
+ [d.libPubspec('foo', '1.2.3'), d.file('broken.txt')],
+ ),
+ d.dir(
+ 'foo-1.2.4',
+ [d.libPubspec('foo', '1.2.4'), d.file('broken.txt')],
+ ),
+ d.dir(
+ 'foo-1.2.5',
+ [d.libPubspec('foo', '1.2.5'), d.file('broken.txt')],
+ )
])
])
]).create();
@@ -34,9 +40,10 @@
expect(pub.stderr, emits(startsWith('Failed to repair foo 1.2.4. Error:')));
expect(
- pub.stderr,
- emits('Package not available '
- '(Package foo has no version 1.2.4).'));
+ pub.stderr,
+ emits('Package not available '
+ '(Package foo has no version 1.2.4).'),
+ );
expect(pub.stdout, emits('Reinstalled 2 packages.'));
expect(pub.stdout, emits('Failed to reinstall 1 package:'));
diff --git a/test/cache/repair/handles_orphaned_binstub_test.dart b/test/cache/repair/handles_orphaned_binstub_test.dart
index 0754496..300a3cb 100644
--- a/test/cache/repair/handles_orphaned_binstub_test.dart
+++ b/test/cache/repair/handles_orphaned_binstub_test.dart
@@ -24,10 +24,11 @@
]).create();
await runPub(
- args: ['cache', 'repair'],
- error: allOf([
- contains('Binstubs exist for non-activated packages:'),
- contains('From foo: foo-script')
- ]));
+ args: ['cache', 'repair'],
+ error: allOf([
+ contains('Binstubs exist for non-activated packages:'),
+ contains('From foo: foo-script')
+ ]),
+ );
});
}
diff --git a/test/cache/repair/hosted.dart b/test/cache/repair/hosted.dart
index a826fad..d841399 100644
--- a/test/cache/repair/hosted.dart
+++ b/test/cache/repair/hosted.dart
@@ -25,32 +25,39 @@
await d.dir(cachePath, [
d.dir('hosted', [
d.dir('localhost%58${globalServer.port}', [
- d.dir('foo-1.2.3',
- [d.libPubspec('foo', '1.2.3'), d.file('broken.txt')]),
- d.dir('foo-1.2.5',
- [d.libPubspec('foo', '1.2.5'), d.file('broken.txt')]),
d.dir(
- 'bar-1.2.4', [d.libPubspec('bar', '1.2.4'), d.file('broken.txt')])
+ 'foo-1.2.3',
+ [d.libPubspec('foo', '1.2.3'), d.file('broken.txt')],
+ ),
+ d.dir(
+ 'foo-1.2.5',
+ [d.libPubspec('foo', '1.2.5'), d.file('broken.txt')],
+ ),
+ d.dir(
+ 'bar-1.2.4',
+ [d.libPubspec('bar', '1.2.4'), d.file('broken.txt')],
+ )
])
])
]).create();
// Repair them.
await runPub(
- args: ['cache', 'repair'],
- output: '''
+ args: ['cache', 'repair'],
+ output: '''
Reinstalled 3 packages.''',
- silent: allOf([
- contains('Downloading bar 1.2.4...'),
- contains('Downloading foo 1.2.3...'),
- contains('Downloading foo 1.2.5...'),
- contains('X-Pub-OS: ${Platform.operatingSystem}'),
- contains('X-Pub-Command: cache repair'),
- contains('X-Pub-Session-ID:'),
- contains('X-Pub-Environment: test-environment'),
- isNot(contains('X-Pub-Reason')),
- ]));
+ silent: allOf([
+ contains('Downloading bar 1.2.4...'),
+ contains('Downloading foo 1.2.3...'),
+ contains('Downloading foo 1.2.5...'),
+ contains('X-Pub-OS: ${Platform.operatingSystem}'),
+ contains('X-Pub-Command: cache repair'),
+ contains('X-Pub-Session-ID:'),
+ contains('X-Pub-Environment: test-environment'),
+ isNot(contains('X-Pub-Reason')),
+ ]),
+ );
// The broken versions should have been replaced.
await d.hostedCache([
@@ -73,21 +80,22 @@
]).create();
await runPub(
- args: ['cache', 'repair'],
- error: allOf([
- contains('Failed to load package:'),
- contains('Could not find a file named "pubspec.yaml" in '),
- contains('bar-1.2.4'),
- contains('foo-1.2.3'),
- contains('foo-1.2.5'),
- ]),
- output: allOf([
- startsWith('Failed to reinstall 3 packages:'),
- contains('- bar 1.2.4'),
- contains('- foo 1.2.3'),
- contains('- foo 1.2.5'),
- ]),
- exitCode: exit_codes.UNAVAILABLE);
+ args: ['cache', 'repair'],
+ error: allOf([
+ contains('Failed to load package:'),
+ contains('Could not find a file named "pubspec.yaml" in '),
+ contains('bar-1.2.4'),
+ contains('foo-1.2.3'),
+ contains('foo-1.2.5'),
+ ]),
+ output: allOf([
+ startsWith('Failed to reinstall 3 packages:'),
+ contains('- bar 1.2.4'),
+ contains('- foo 1.2.3'),
+ contains('- foo 1.2.5'),
+ ]),
+ exitCode: exit_codes.UNAVAILABLE,
+ );
await d.hostedCache([
d.nothing('bar-1.2.4'),
@@ -109,21 +117,22 @@
]).create();
await runPub(
- args: ['cache', 'repair'],
- error: allOf([
- contains('Failed to load package:'),
- contains('Error on line 1, column 2 of '),
- contains('bar-1.2.4'),
- contains('foo-1.2.3'),
- contains('foo-1.2.5'),
- ]),
- output: allOf([
- startsWith('Failed to reinstall 3 packages:'),
- contains('- bar 1.2.4'),
- contains('- foo 1.2.3'),
- contains('- foo 1.2.5'),
- ]),
- exitCode: exit_codes.UNAVAILABLE);
+ args: ['cache', 'repair'],
+ error: allOf([
+ contains('Failed to load package:'),
+ contains('Error on line 1, column 2 of '),
+ contains('bar-1.2.4'),
+ contains('foo-1.2.3'),
+ contains('foo-1.2.5'),
+ ]),
+ output: allOf([
+ startsWith('Failed to reinstall 3 packages:'),
+ contains('- bar 1.2.4'),
+ contains('- foo 1.2.3'),
+ contains('- foo 1.2.5'),
+ ]),
+ exitCode: exit_codes.UNAVAILABLE,
+ );
await d.hostedCache([
d.nothing('bar-1.2.4'),
diff --git a/test/cache/repair/recompiles_snapshots_test.dart b/test/cache/repair/recompiles_snapshots_test.dart
index 6fa4ca2..86a27d2 100644
--- a/test/cache/repair/recompiles_snapshots_test.dart
+++ b/test/cache/repair/recompiles_snapshots_test.dart
@@ -10,9 +10,13 @@
void main() {
test('recompiles activated executable snapshots', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', contents: [
- d.dir('bin', [d.file('script.dart', "main(args) => print('ok');")])
- ]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ contents: [
+ d.dir('bin', [d.file('script.dart', "main(args) => print('ok');")])
+ ],
+ );
await runPub(args: ['global', 'activate', 'foo']);
@@ -20,12 +24,15 @@
d.dir('global_packages/foo/bin', [d.file('script.dart.snapshot', 'junk')])
]).create();
- await runPub(args: ['cache', 'repair'], output: '''
+ await runPub(
+ args: ['cache', 'repair'],
+ output: '''
Reinstalled 1 package.
Reactivating foo 1.0.0...
Building package executables...
Built foo:script.
- Reactivated 1 package.''');
+ Reactivated 1 package.''',
+ );
var pub = await pubRun(global: true, args: ['foo:script']);
expect(pub.stdout, emits('ok'));
diff --git a/test/cache/repair/updates_binstubs_test.dart b/test/cache/repair/updates_binstubs_test.dart
index 65a574c..262eab5 100644
--- a/test/cache/repair/updates_binstubs_test.dart
+++ b/test/cache/repair/updates_binstubs_test.dart
@@ -20,11 +20,19 @@
void main() {
test('updates an outdated binstub script', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', pubspec: {
- 'executables': {'foo-script': 'script'}
- }, contents: [
- d.dir('bin', [d.file('script.dart', "main(args) => print('ok \$args');")])
- ]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'executables': {'foo-script': 'script'}
+ },
+ contents: [
+ d.dir(
+ 'bin',
+ [d.file('script.dart', "main(args) => print('ok \$args');")],
+ )
+ ],
+ );
await runPub(args: ['global', 'activate', 'foo']);
@@ -33,19 +41,24 @@
]).create();
// Repair them.
- await runPub(args: ['cache', 'repair'], output: '''
+ await runPub(
+ args: ['cache', 'repair'],
+ output: '''
Reinstalled 1 package.
Reactivating foo 1.0.0...
Building package executables...
Built foo:script.
Installed executable foo-script.
- Reactivated 1 package.''');
+ Reactivated 1 package.''',
+ );
// The broken versions should have been replaced.
await d.dir(cachePath, [
d.dir('bin', [
- d.file(binStubName('foo-script'),
- contains('This file was created by pub v0.1.2+3'))
+ d.file(
+ binStubName('foo-script'),
+ contains('This file was created by pub v3.1.2+3'),
+ )
])
]).validate();
});
diff --git a/test/content_hash_test.dart b/test/content_hash_test.dart
index 2485918..bd106f4 100644
--- a/test/content_hash_test.dart
+++ b/test/content_hash_test.dart
@@ -19,10 +19,11 @@
final server = await servePackages();
server.serve('foo', '1.0.0');
server.serveContentHashes = true;
- await appDir({'foo': 'any'}).create();
+ await appDir(dependencies: {'foo': 'any'}).create();
await pubGet();
final lockfile = loadYaml(
- File(p.join(sandbox, appPath, 'pubspec.lock')).readAsStringSync());
+ File(p.join(sandbox, appPath, 'pubspec.lock')).readAsStringSync(),
+ );
final sha256 = lockfile['packages']['foo']['description']['sha256'];
expect(sha256, hasLength(64));
await hostedHashesCache([
@@ -36,10 +37,11 @@
final server = await servePackages();
server.serveContentHashes = false;
server.serve('foo', '1.0.0');
- await appDir({'foo': 'any'}).create();
+ await appDir(dependencies: {'foo': 'any'}).create();
await pubGet();
final lockfile = loadYaml(
- File(p.join(sandbox, appPath, 'pubspec.lock')).readAsStringSync());
+ File(p.join(sandbox, appPath, 'pubspec.lock')).readAsStringSync(),
+ );
final sha256 = lockfile['packages']['foo']['description']['sha256'];
expect(sha256, hasLength(64));
await hostedHashesCache([
@@ -50,9 +52,12 @@
test('archive_sha256 is checked on download', () async {
final server = await servePackages();
server.serve('foo', '1.0.0');
- server.overrideArchiveSha256('foo', '1.0.0',
- 'e7a7a0f6d9873e4c40cf68cc3cc9ca5b6c8cef6a2220241bdada4b9cb0083279');
- await appDir({'foo': 'any'}).create();
+ server.overrideArchiveSha256(
+ 'foo',
+ '1.0.0',
+ 'e7a7a0f6d9873e4c40cf68cc3cc9ca5b6c8cef6a2220241bdada4b9cb0083279',
+ );
+ await appDir(dependencies: {'foo': 'any'}).create();
await pubGet(
exitCode: exit_codes.TEMP_FAIL,
silent: contains('Attempt #2'),
@@ -69,10 +74,13 @@
final server = await servePackages();
server.serveContentHashes = true;
server.serve('foo', '1.0.0');
- await appDir({'foo': 'any'}).create();
+ await appDir(dependencies: {'foo': 'any'}).create();
await pubGet();
- server.serve('foo', '1.0.0',
- contents: [file('new_file.txt', 'This file could be malicious.')]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ contents: [file('new_file.txt', 'This file could be malicious.')],
+ );
// Pub get will not revisit the file-listing if everything resolves, and only compare with a cached value.
await pubGet();
// Deleting the version-listing cache will cause it to be refetched, and the
@@ -83,13 +91,15 @@
warning: allOf(
contains('Cached version of foo-1.0.0 has wrong hash - redownloading.'),
contains(
- 'The existing content-hash from pubspec.lock doesn\'t match contents for:'),
+ 'The existing content-hash from pubspec.lock doesn\'t match contents for:',
+ ),
contains('* foo-1.0.0 from "${server.url}"\n'),
),
exitCode: exit_codes.SUCCESS,
);
final lockfile = loadYaml(
- File(p.join(sandbox, appPath, 'pubspec.lock')).readAsStringSync());
+ File(p.join(sandbox, appPath, 'pubspec.lock')).readAsStringSync(),
+ );
final newHash = lockfile['packages']['foo']['description']['sha256'];
expect(newHash, await server.peekArchiveSha256('foo', '1.0.0'));
});
@@ -100,10 +110,13 @@
final server = await servePackages();
server.serveContentHashes = false;
server.serve('foo', '1.0.0');
- await appDir({'foo': 'any'}).create();
+ await appDir(dependencies: {'foo': 'any'}).create();
await pubGet();
- server.serve('foo', '1.0.0',
- contents: [file('new_file.txt', 'This file could be malicious.')]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ contents: [file('new_file.txt', 'This file could be malicious.')],
+ );
// Deleting the hash-file cache will cause it to be refetched, and the
// warning will happen.
File(p.join(globalServer.hashesCachingPath, 'foo-1.0.0.sha256'))
@@ -119,7 +132,8 @@
exitCode: exit_codes.SUCCESS,
);
final lockfile = loadYaml(
- File(p.join(sandbox, appPath, 'pubspec.lock')).readAsStringSync());
+ File(p.join(sandbox, appPath, 'pubspec.lock')).readAsStringSync(),
+ );
final newHash = lockfile['packages']['foo']['description']['sha256'];
expect(newHash, await server.peekArchiveSha256('foo', '1.0.0'));
});
@@ -130,19 +144,23 @@
final server = await servePackages();
server.serveContentHashes = false;
server.serve('foo', '1.0.0');
- await appDir({'foo': 'any'}).create();
+ await appDir(dependencies: {'foo': 'any'}).create();
await pubGet();
final lockfile = loadYaml(
- File(p.join(sandbox, appPath, 'pubspec.lock')).readAsStringSync());
+ File(p.join(sandbox, appPath, 'pubspec.lock')).readAsStringSync(),
+ );
final originalHash = lockfile['packages']['foo']['description']['sha256'];
// Create wrong hash on disk.
await hostedHashesCache([
- file('foo-1.0.0.sha256',
- 'e7a7a0f6d9873e4c40cf68cc3cc9ca5b6c8cef6a2220241bdada4b9cb0083279'),
+ file(
+ 'foo-1.0.0.sha256',
+ 'e7a7a0f6d9873e4c40cf68cc3cc9ca5b6c8cef6a2220241bdada4b9cb0083279',
+ ),
]).create();
await pubGet(
- warning: 'Cached version of foo-1.0.0 has wrong hash - redownloading.');
+ warning: 'Cached version of foo-1.0.0 has wrong hash - redownloading.',
+ );
await hostedHashesCache([
file('foo-1.0.0.sha256', originalHash),
]).validate();
@@ -153,18 +171,22 @@
final server = await servePackages();
server.serveContentHashes = true;
server.serve('foo', '1.0.0');
- await appDir({'foo': 'any'}).create();
+ await appDir(dependencies: {'foo': 'any'}).create();
await pubGet();
final lockfile = loadYaml(
- File(p.join(sandbox, appPath, 'pubspec.lock')).readAsStringSync());
+ File(p.join(sandbox, appPath, 'pubspec.lock')).readAsStringSync(),
+ );
final originalHash = lockfile['packages']['foo']['description']['sha256'];
await hostedHashesCache([
- file('foo-1.0.0.sha256',
- 'e7a7a0f6d9873e4c40cf68cc3cc9ca5b6c8cef6a2220241bdada4b9cb0083279'),
+ file(
+ 'foo-1.0.0.sha256',
+ 'e7a7a0f6d9873e4c40cf68cc3cc9ca5b6c8cef6a2220241bdada4b9cb0083279',
+ ),
]).create();
await pubGet(
- warning: 'Cached version of foo-1.0.0 has wrong hash - redownloading.');
+ warning: 'Cached version of foo-1.0.0 has wrong hash - redownloading.',
+ );
await hostedHashesCache([
file('foo-1.0.0.sha256', originalHash),
]).validate();
@@ -176,11 +198,12 @@
final server = await servePackages();
server.serve('foo', '1.0.0');
server.serveContentHashes = false;
- await appDir({'foo': 'any'}).create();
+ await appDir(dependencies: {'foo': 'any'}).create();
await pubGet();
// Pretend we had no hash in the lockfile.
final lockfile = YamlEditor(
- File(p.join(sandbox, appPath, 'pubspec.lock')).readAsStringSync());
+ File(p.join(sandbox, appPath, 'pubspec.lock')).readAsStringSync(),
+ );
final originalContentHash = lockfile
.remove(['packages', 'foo', 'description', 'sha256']).value as String;
File(p.join(sandbox, appPath, 'pubspec.lock')).writeAsStringSync(
@@ -188,7 +211,8 @@
);
await pubGet();
final lockfile2 = YamlEditor(
- File(p.join(sandbox, appPath, 'pubspec.lock')).readAsStringSync());
+ File(p.join(sandbox, appPath, 'pubspec.lock')).readAsStringSync(),
+ );
expect(
lockfile2.parseAt(['packages', 'foo', 'description', 'sha256']).value,
originalContentHash,
@@ -201,11 +225,12 @@
final server = await servePackages();
server.serve('foo', '1.0.0');
server.serveContentHashes = true;
- await appDir({'foo': 'any'}).create();
+ await appDir(dependencies: {'foo': 'any'}).create();
await pubGet();
// Pretend we had no hash in the lockfile.
final lockfile = YamlEditor(
- File(p.join(sandbox, appPath, 'pubspec.lock')).readAsStringSync());
+ File(p.join(sandbox, appPath, 'pubspec.lock')).readAsStringSync(),
+ );
final originalContentHash = lockfile
.remove(['packages', 'foo', 'description', 'sha256']).value as String;
File(p.join(sandbox, appPath, 'pubspec.lock')).writeAsStringSync(
@@ -213,7 +238,8 @@
);
await pubGet();
final lockfile2 = YamlEditor(
- File(p.join(sandbox, appPath, 'pubspec.lock')).readAsStringSync());
+ File(p.join(sandbox, appPath, 'pubspec.lock')).readAsStringSync(),
+ );
expect(
lockfile2.parseAt(['packages', 'foo', 'description', 'sha256']).value,
originalContentHash,
diff --git a/test/dart3_sdk_constraint_hack_test.dart b/test/dart3_sdk_constraint_hack_test.dart
index 1a03ce5..e8e18ab 100644
--- a/test/dart3_sdk_constraint_hack_test.dart
+++ b/test/dart3_sdk_constraint_hack_test.dart
@@ -18,7 +18,8 @@
await pubGet(
error: contains(
- 'Because myapp requires SDK version >=2.11.0 <3.0.0, version solving failed'),
+ 'Because myapp doesn\'t support null safety, version solving failed',
+ ),
environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
);
});
@@ -32,7 +33,8 @@
await pubGet(
error: contains(
- 'Because myapp requires SDK version >=2.12.0 <3.1.0, version solving failed'),
+ 'Because myapp requires SDK version >=2.12.0 <3.1.0, version solving failed',
+ ),
environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
);
});
@@ -47,7 +49,8 @@
await pubGet(
error: contains(
- 'Because myapp requires SDK version >=2.11.0 <2.999.0, version solving failed'),
+ 'Because myapp doesn\'t support null safety, version solving failed',
+ ),
environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
);
});
@@ -62,7 +65,8 @@
await pubGet(
error: contains(
- 'Because myapp requires SDK version >=2.11.0 <3.0.0-0.0, version solving failed'),
+ 'Because myapp doesn\'t support null safety, version solving failed',
+ ),
environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
);
});
@@ -91,6 +95,24 @@
await pubGet(environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'});
});
+ test('The bound of ">=3.0.0-dev <3.0.0" is not modified', () async {
+ // When the lower bound is a dev release of 3.0.0 the upper bound is treated literally, and not
+ // converted to 3.0.0-0, therefore the rewrite to 4.0.0 doesn't happen.
+ await d.dir(appPath, [
+ d.pubspec({
+ 'name': 'myapp',
+ 'environment': {'sdk': '>=3.0.0-dev <3.0.0'}
+ }),
+ ]).create();
+
+ await pubGet(
+ environment: {'_PUB_TEST_SDK_VERSION': '3.5.0'},
+ error: contains(
+ 'Because myapp requires SDK version >=3.0.0-dev <3.0.0, version solving failed.',
+ ),
+ );
+ });
+
test(
'The bound of ">=2.12.0 <3.0.0" is not compatible with prereleases of dart 4',
() async {
@@ -108,6 +130,33 @@
),
);
});
+
+ test('When the constraint is not rewritten, a helpful hint is given',
+ () async {
+ await d.appDir(
+ dependencies: {'foo': 'any'},
+ pubspec: {
+ 'environment': {'sdk': '^2.12.0'}
+ },
+ ).create();
+ final server = await servePackages();
+
+ // foo is not null safe.
+ server.serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'environment': {'sdk': '>=2.10.0 <3.0.0'}
+ },
+ );
+ await pubGet(
+ error: contains(
+ 'The lower bound of "sdk: \'>=2.10.0 <3.0.0\'" must be 2.12.0 or higher to enable null safety.'
+ '\nFor details, see https://dart.dev/null-safety',
+ ),
+ );
+ });
+
test('Rewrite only happens after Dart 3', () async {
await d.dir(appPath, [
d.pubspec({
diff --git a/test/dependency_override_test.dart b/test/dependency_override_test.dart
index 59f59e4..8a263f5 100644
--- a/test/dependency_override_test.dart
+++ b/test/dependency_override_test.dart
@@ -55,9 +55,13 @@
..serve('foo', '1.0.0')
..serve('foo', '2.0.0')
..serve('foo', '3.0.0')
- ..serve('bar', '1.0.0', pubspec: {
- 'dependencies': {'foo': '5.0.0-nonexistent'}
- });
+ ..serve(
+ 'bar',
+ '1.0.0',
+ pubspec: {
+ 'dependencies': {'foo': '5.0.0-nonexistent'}
+ },
+ );
await d.dir(appPath, [
d.pubspec({
@@ -77,9 +81,13 @@
test('ignores SDK constraints', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', pubspec: {
- 'environment': {'sdk': '5.6.7-fblthp'}
- });
+ server.serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'environment': {'sdk': '5.6.7-fblthp'}
+ },
+ );
await d.dir(appPath, [
d.pubspec({
@@ -94,7 +102,7 @@
]).validate();
});
- test('warns about overridden dependencies', () async {
+ test('informs about overridden dependencies', () async {
await servePackages()
..serve('foo', '1.0.0')
..serve('bar', '1.0.0');
@@ -116,14 +124,13 @@
var bazPath = path.join('..', 'baz');
await runPub(
- args: [command.name],
- output: command.success,
- error: '''
- Warning: You are using these overridden dependencies:
- ! bar 1.0.0
- ! baz 0.0.1 from path $bazPath
- ! foo 1.0.0
- ''');
+ args: [command.name],
+ output: contains('''
+! bar 1.0.0 (overridden)
+! baz 0.0.1 from path $bazPath (overridden)
+! foo 1.0.0 (overridden)
+'''),
+ );
});
});
}
diff --git a/test/dependency_services/dependency_services_test.dart b/test/dependency_services/dependency_services_test.dart
index 1451d42..cd77694 100644
--- a/test/dependency_services/dependency_services_test.dart
+++ b/test/dependency_services/dependency_services_test.dart
@@ -43,8 +43,10 @@
extension on GoldenTestContext {
/// Returns the stdout.
- Future<String> runDependencyServices(List<String> args,
- {String? stdin}) async {
+ Future<String> runDependencyServices(
+ List<String> args, {
+ String? stdin,
+ }) async {
final buffer = StringBuffer();
buffer.writeln('## Section ${args.join(' ')}');
final process = await Process.start(
@@ -67,12 +69,14 @@
final exitCode = await process.exitCode;
final pipe = stdin == null ? '' : ' echo ${escapeShellArgument(stdin)} |';
- buffer.writeln([
- '\$$pipe dependency_services ${args.map(escapeShellArgument).join(' ')}',
- ...await outLines,
- ...(await errLines).map((e) => '[STDERR] $e'),
- if (exitCode != 0) '[EXIT CODE] $exitCode',
- ].join('\n'));
+ buffer.writeln(
+ [
+ '\$$pipe dependency_services ${args.map(escapeShellArgument).join(' ')}',
+ ...await outLines,
+ ...(await errLines).map((e) => '[STDERR] $e'),
+ if (exitCode != 0) '[EXIT CODE] $exitCode',
+ ].join('\n'),
+ );
expectNextSection(buffer.toString());
return (await outLines).join('\n');
@@ -136,19 +140,20 @@
]).create();
await pubGet();
server.dontAllowDownloads();
- await _listReportApply(context, [
- _PackageVersion('foo', '2.2.3'),
- _PackageVersion('transitive', null)
- ], reportAssertions: (report) {
- expect(
- findChangeVersion(report, 'singleBreaking', 'foo'),
- '2.2.3',
- );
- expect(
- findChangeVersion(report, 'singleBreaking', 'transitive'),
- null,
- );
- });
+ await _listReportApply(
+ context,
+ [_PackageVersion('foo', '2.2.3'), _PackageVersion('transitive', null)],
+ reportAssertions: (report) {
+ expect(
+ findChangeVersion(report, 'singleBreaking', 'foo'),
+ '2.2.3',
+ );
+ expect(
+ findChangeVersion(report, 'singleBreaking', 'transitive'),
+ null,
+ );
+ },
+ );
});
testWithGolden('No pubspec.lock', (context) async {
@@ -207,14 +212,18 @@
server.dontAllowDownloads();
- await _listReportApply(context, [
- _PackageVersion('foo', '1.2.4'),
- ], reportAssertions: (report) {
- expect(
- findChangeVersion(report, 'compatible', 'foo'),
- '1.2.4',
- );
- });
+ await _listReportApply(
+ context,
+ [
+ _PackageVersion('foo', '1.2.4'),
+ ],
+ reportAssertions: (report) {
+ expect(
+ findChangeVersion(report, 'compatible', 'foo'),
+ '1.2.4',
+ );
+ },
+ );
});
testWithGolden('Preserves no content-hashes', (context) async {
@@ -274,19 +283,20 @@
await pubGet();
server.dontAllowDownloads();
- await _listReportApply(context, [
- _PackageVersion('foo', '2.2.3'),
- _PackageVersion('transitive', '1.0.0')
- ], reportAssertions: (report) {
- expect(
- findChangeVersion(report, 'singleBreaking', 'foo'),
- '2.2.3',
- );
- expect(
- findChangeVersion(report, 'singleBreaking', 'transitive'),
- '1.0.0',
- );
- });
+ await _listReportApply(
+ context,
+ [_PackageVersion('foo', '2.2.3'), _PackageVersion('transitive', '1.0.0')],
+ reportAssertions: (report) {
+ expect(
+ findChangeVersion(report, 'singleBreaking', 'foo'),
+ '2.2.3',
+ );
+ expect(
+ findChangeVersion(report, 'singleBreaking', 'transitive'),
+ '1.0.0',
+ );
+ },
+ );
});
testWithGolden('multibreaking', (context) async {
@@ -318,20 +328,27 @@
server.dontAllowDownloads();
- await _listReportApply(context, [
- _PackageVersion('foo', '3.0.1',
- constraint: VersionConstraint.parse('^3.0.0')),
- _PackageVersion('bar', '2.0.0')
- ], reportAssertions: (report) {
- expect(
- findChangeVersion(report, 'multiBreaking', 'foo'),
- '3.0.1',
- );
- expect(
- findChangeVersion(report, 'multiBreaking', 'bar'),
- '2.0.0',
- );
- });
+ await _listReportApply(
+ context,
+ [
+ _PackageVersion(
+ 'foo',
+ '3.0.1',
+ constraint: VersionConstraint.parse('^3.0.0'),
+ ),
+ _PackageVersion('bar', '2.0.0')
+ ],
+ reportAssertions: (report) {
+ expect(
+ findChangeVersion(report, 'multiBreaking', 'foo'),
+ '3.0.1',
+ );
+ expect(
+ findChangeVersion(report, 'multiBreaking', 'bar'),
+ '2.0.0',
+ );
+ },
+ );
});
testWithGolden('Relative paths are allowed', (context) async {
// We cannot update path-dependencies, but they should be allowed.
@@ -339,37 +356,48 @@
server.serve('foo', '1.0.0');
await d.dir('bar', [d.libPubspec('bar', '1.0.0')]).create();
- await d.appDir({
- 'foo': '^1.0.0',
- 'bar': {'path': '../bar'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': '^1.0.0',
+ 'bar': {'path': '../bar'}
+ },
+ ).create();
await pubGet();
server.serve('foo', '2.0.0');
- await _listReportApply(context, [
- _PackageVersion('foo', '2.0.0',
- constraint: VersionConstraint.parse('^2.0.0')),
- ], reportAssertions: (report) {
- expect(
- findChangeVersion(report, 'multiBreaking', 'foo'),
- '2.0.0',
- );
- });
+ await _listReportApply(
+ context,
+ [
+ _PackageVersion(
+ 'foo',
+ '2.0.0',
+ constraint: VersionConstraint.parse('^2.0.0'),
+ ),
+ ],
+ reportAssertions: (report) {
+ expect(
+ findChangeVersion(report, 'multiBreaking', 'foo'),
+ '2.0.0',
+ );
+ },
+ );
});
testWithGolden('Can update a git package', (context) async {
await d.git('foo.git', [d.libPubspec('foo', '1.0.0')]).create();
await d.git('bar.git', [d.libPubspec('bar', '1.0.0')]).create();
- await d.appDir({
- 'foo': {
- 'git': {'url': '../foo.git'}
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'git': {'url': '../foo.git'}
+ },
+ 'bar': {
+ // A git dependency with a version constraint.
+ 'git': {'url': '../bar.git'},
+ 'version': '^1.0.0',
+ }
},
- 'bar': {
- // A git dependency with a version constraint.
- 'git': {'url': '../bar.git'},
- 'version': '^1.0.0',
- }
- }).create();
+ ).create();
await pubGet();
final secondVersion = d.git('foo.git', [d.libPubspec('foo', '2.0.0')]);
await secondVersion.commit();
@@ -378,14 +406,18 @@
final barSecondVersion = d.git('bar.git', [d.libPubspec('bar', '2.0.0')]);
await barSecondVersion.commit();
- await _listReportApply(context, [
- _PackageVersion('foo', newRef),
- ], reportAssertions: (report) {
- expect(
- findChangeVersion(report, 'multiBreaking', 'foo'),
- newRef,
- );
- });
+ await _listReportApply(
+ context,
+ [
+ _PackageVersion('foo', newRef),
+ ],
+ reportAssertions: (report) {
+ expect(
+ findChangeVersion(report, 'multiBreaking', 'foo'),
+ newRef,
+ );
+ },
+ );
});
}
@@ -417,7 +449,8 @@
// the test becomes useless.
handle(RegExp(r'/.+\.tar\.gz'), (request) {
return shelf.Response.notFound(
- 'This test should not download archives! Requested ${request.url}');
+ 'This test should not download archives! Requested ${request.url}',
+ );
});
}
}
diff --git a/test/deps/executables_test.dart b/test/deps/executables_test.dart
index ea864fd..4eb61ff 100644
--- a/test/deps/executables_test.dart
+++ b/test/deps/executables_test.dart
@@ -62,9 +62,11 @@
]).create();
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': '../foo'}
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': '../foo'}
+ },
+ )
]).create();
await ctx.runExecutablesTest();
@@ -73,15 +75,21 @@
testWithGolden('lists executables only from immediate dependencies',
(ctx) async {
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': '../foo'}
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': '../foo'}
+ },
+ )
]).create();
await d.dir('foo', [
- d.libPubspec('foo', '1.0.0', deps: {
- 'baz': {'path': '../baz'}
- }),
+ d.libPubspec(
+ 'foo',
+ '1.0.0',
+ deps: {
+ 'baz': {'path': '../baz'}
+ },
+ ),
d.dir('bin', [d.file('bar.dart', _validMain)])
]).create();
@@ -95,17 +103,21 @@
testWithGolden('applies formatting before printing executables', (ctx) async {
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': '../foo'},
- 'bar': {'path': '../bar'}
- }),
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': '../foo'},
+ 'bar': {'path': '../bar'}
+ },
+ ),
d.dir('bin', [d.file('myapp.dart', _validMain)])
]).create();
await d.dir('foo', [
d.libPubspec('foo', '1.0.0'),
- d.dir('bin',
- [d.file('baz.dart', _validMain), d.file('foo.dart', _validMain)])
+ d.dir(
+ 'bin',
+ [d.file('baz.dart', _validMain), d.file('foo.dart', _validMain)],
+ )
]).create();
await d.dir('bar', [
@@ -142,8 +154,10 @@
await d.dir('foo-2.0', [
d.libPubspec('foo', '2.0.0'),
- d.dir('bin',
- [d.file('bar.dart', _validMain), d.file('baz.dart', _validMain)])
+ d.dir(
+ 'bin',
+ [d.file('bar.dart', _validMain), d.file('baz.dart', _validMain)],
+ )
]).create();
await d.dir(appPath, [
diff --git a/test/deps_test.dart b/test/deps_test.dart
index b4ded45..b10ceb2 100644
--- a/test/deps_test.dart
+++ b/test/deps_test.dart
@@ -11,8 +11,11 @@
void main() {
setUp(() async {
await servePackages()
- ..serve('normal', '1.2.3',
- deps: {'transitive': 'any', 'circular_a': 'any'})
+ ..serve(
+ 'normal',
+ '1.2.3',
+ deps: {'transitive': 'any', 'circular_a': 'any'},
+ )
..serve('transitive', '1.2.3', deps: {'shared': 'any'})
..serve('shared', '1.2.3', deps: {'other': 'any'})
..serve('dev_only', '1.2.3')
@@ -24,8 +27,10 @@
..serve('circular_a', '1.2.3', deps: {'circular_b': 'any'})
..serve('circular_b', '1.2.3', deps: {'circular_a': 'any'});
- await d.dir('from_path',
- [d.libDir('from_path'), d.libPubspec('from_path', '1.2.3')]).create();
+ await d.dir(
+ 'from_path',
+ [d.libDir('from_path'), d.libPubspec('from_path', '1.2.3')],
+ ).create();
await d.dir(appPath, [
d.pubspec({
@@ -44,8 +49,10 @@
group('lists all dependencies', () {
test('in compact form', () async {
await pubGet();
- await runPub(args: ['deps', '-s', 'compact'], output: '''
- Dart SDK 0.1.2+3
+ await runPub(
+ args: ['deps', '-s', 'compact'],
+ output: '''
+ Dart SDK 3.1.2+3
myapp 0.0.0
dependencies:
@@ -67,13 +74,16 @@
- other 1.0.0 [myapp]
- shared 1.2.3 [other]
- transitive 1.2.3 [shared]
- ''');
+ ''',
+ );
});
test('in list form', () async {
await pubGet();
- await runPub(args: ['deps', '--style', 'list'], output: '''
- Dart SDK 0.1.2+3
+ await runPub(
+ args: ['deps', '--style', 'list'],
+ output: '''
+ Dart SDK 3.1.2+3
myapp 0.0.0
dependencies:
@@ -104,13 +114,16 @@
- other any
- transitive 1.2.3
- shared any
- ''');
+ ''',
+ );
});
test('in tree form', () async {
await pubGet();
- await runPub(args: ['deps'], output: '''
- Dart SDK 0.1.2+3
+ await runPub(
+ args: ['deps'],
+ output: '''
+ Dart SDK 3.1.2+3
myapp 0.0.0
├── from_path 1.2.3
├── normal 1.2.3
@@ -126,11 +139,14 @@
└── shared 1.2.3
└── other 1.0.0
└── myapp...
- ''');
+ ''',
+ );
});
test('in json form', () async {
await pubGet();
- await runPub(args: ['deps', '--json'], output: '''
+ await runPub(
+ args: ['deps', '--json'],
+ output: '''
{
"root": "myapp",
"packages": [
@@ -244,11 +260,12 @@
"sdks": [
{
"name": "Dart",
- "version": "0.1.2+3"
+ "version": "3.1.2+3"
}
],
"executables": []
-}''');
+}''',
+ );
});
test('with the Flutter SDK, if applicable', () async {
@@ -256,9 +273,10 @@
await d.dir('flutter', [d.file('version', '4.3.2+1')]).create();
await runPub(
- args: ['deps'],
- output: contains('Flutter SDK 4.3.2+1'),
- environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')});
+ args: ['deps'],
+ output: contains('Flutter SDK 4.3.2+1'),
+ environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
+ );
});
test('with the Fuchsia SDK, if applicable', () async {
@@ -266,17 +284,20 @@
await d.dir('fuchsia', [d.file('version', '4.3.2+1')]).create();
await runPub(
- args: ['deps'],
- output: contains('Fuchsia SDK 4.3.2+1'),
- environment: {'FUCHSIA_DART_SDK_ROOT': p.join(d.sandbox, 'fuchsia')});
+ args: ['deps'],
+ output: contains('Fuchsia SDK 4.3.2+1'),
+ environment: {'FUCHSIA_DART_SDK_ROOT': p.join(d.sandbox, 'fuchsia')},
+ );
});
});
group('lists non-dev dependencies', () {
test('in compact form', () async {
await pubGet();
- await runPub(args: ['deps', '-s', 'compact', '--no-dev'], output: '''
- Dart SDK 0.1.2+3
+ await runPub(
+ args: ['deps', '-s', 'compact', '--no-dev'],
+ output: '''
+ Dart SDK 3.1.2+3
myapp 0.0.0
dependencies:
@@ -294,13 +315,16 @@
- other 1.0.0 [myapp]
- shared 1.2.3 [other]
- transitive 1.2.3 [shared]
- ''');
+ ''',
+ );
});
test('in list form', () async {
await pubGet();
- await runPub(args: ['deps', '--style', 'list', '--no-dev'], output: '''
- Dart SDK 0.1.2+3
+ await runPub(
+ args: ['deps', '--style', 'list', '--no-dev'],
+ output: '''
+ Dart SDK 3.1.2+3
myapp 0.0.0
dependencies:
@@ -325,13 +349,16 @@
- other any
- transitive 1.2.3
- shared any
- ''');
+ ''',
+ );
});
test('in tree form', () async {
await pubGet();
- await runPub(args: ['deps', '--no-dev'], output: '''
- Dart SDK 0.1.2+3
+ await runPub(
+ args: ['deps', '--no-dev'],
+ output: '''
+ Dart SDK 3.1.2+3
myapp 0.0.0
├── from_path 1.2.3
├── normal 1.2.3
@@ -344,7 +371,8 @@
│ └── myapp...
├── overridden 2.0.0
└── override_only 1.2.3
- ''');
+ ''',
+ );
});
});
}
diff --git a/test/descriptor.dart b/test/descriptor.dart
index ab3a7ec..6a2ec60 100644
--- a/test/descriptor.dart
+++ b/test/descriptor.dart
@@ -33,7 +33,7 @@
/// Describes a package that passes all validation.
DirectoryDescriptor get validPackage => dir(appPath, [
- libPubspec('test_pkg', '1.0.0', sdk: '>=0.1.2 <=0.2.0'),
+ libPubspec('test_pkg', '1.0.0', sdk: '>=3.1.2 <=3.2.0'),
file('LICENSE', 'Eh, do what you want.'),
file('README.md', "This package isn't real."),
file('CHANGELOG.md', '# 1.0.0\nFirst version\n'),
@@ -64,13 +64,13 @@
///
/// [contents] may contain [Future]s that resolve to serializable objects,
/// which may in turn contain [Future]s recursively.
-Descriptor pubspec(Map<String, Object?> contents) => YamlDescriptor(
+FileDescriptor pubspec(Map<String, Object?> contents) => YamlDescriptor(
'pubspec.yaml',
yaml({
...contents,
// TODO: Copy-pasting this into all call-sites, or use d.libPubspec
'environment': {
- 'sdk': '>=0.1.2 <1.0.0',
+ 'sdk': defaultSdkConstraint,
...(contents['environment'] ?? {}) as Map,
},
}),
@@ -81,12 +81,10 @@
/// Describes a file named `pubspec.yaml` for an application package with the
/// given [dependencies].
-Descriptor appPubspec([Map? dependencies]) {
+Descriptor appPubspec({Map? dependencies, Map<String, Object>? extras}) {
var map = <String, Object>{
'name': 'myapp',
- 'environment': {
- 'sdk': '>=0.1.2 <1.0.0',
- },
+ ...?extras,
};
if (dependencies != null) map['dependencies'] = dependencies;
return pubspec(map);
@@ -98,7 +96,7 @@
/// the current SDK version.
///
/// [extras] is additional fields of the pubspec.
-Descriptor libPubspec(
+FileDescriptor libPubspec(
String name,
String version, {
Map? deps,
@@ -109,8 +107,6 @@
var map = packageMap(name, version, deps, devDeps);
if (sdk != null) {
map['environment'] = {'sdk': sdk};
- } else {
- map['environment'] = {'sdk': '>=0.1.2 <1.0.0'};
}
return pubspec({...map, ...extras});
}
@@ -136,7 +132,9 @@
/// Describes a directory whose name ends with a hyphen followed by an
/// alphanumeric hash.
Descriptor hashDir(String name, Iterable<Descriptor> contents) => pattern(
- RegExp("$name${r'-[a-f0-9]+'}"), (dirName) => dir(dirName, contents));
+ RegExp("$name${r'-[a-f0-9]+'}"),
+ (dirName) => dir(dirName, contents),
+ );
/// Describes a directory for a Git repo with a dart package.
/// This directory is of the form found in the revision cache of the global
@@ -219,8 +217,12 @@
/// Describes the file that contains the client's OAuth2
/// credentials. The URL "/token" on [server] will be used as the token
/// endpoint for refreshing the access token.
-Descriptor credentialsFile(PackageServer server, String accessToken,
- {String? refreshToken, DateTime? expiration}) {
+Descriptor credentialsFile(
+ PackageServer server,
+ String accessToken, {
+ String? refreshToken,
+ DateTime? expiration,
+}) {
return dir(
configPath,
[
@@ -237,8 +239,12 @@
);
}
-Descriptor legacyCredentialsFile(PackageServer server, String accessToken,
- {String? refreshToken, DateTime? expiration}) {
+Descriptor legacyCredentialsFile(
+ PackageServer server,
+ String accessToken, {
+ String? refreshToken,
+ DateTime? expiration,
+}) {
return dir(
cachePath,
[
@@ -280,8 +286,8 @@
/// Describes the application directory, containing only a pubspec specifying
/// the given [dependencies].
-DirectoryDescriptor appDir([Map? dependencies]) =>
- dir(appPath, [appPubspec(dependencies)]);
+DirectoryDescriptor appDir({Map? dependencies, Map<String, Object>? pubspec}) =>
+ dir(appPath, [appPubspec(dependencies: dependencies, extras: pubspec)]);
/// Describes a `.dart_tools/package_config.json` file.
///
@@ -292,13 +298,13 @@
/// that matches the `rootUri` of that package.
Descriptor packageConfigFile(
List<PackageConfigEntry> packages, {
- String generatorVersion = '0.1.2+3',
+ String generatorVersion = '3.1.2+3',
}) =>
PackageConfigFileDescriptor(packages, generatorVersion);
Descriptor appPackageConfigFile(
List<PackageConfigEntry> packages, {
- String generatorVersion = '0.1.2+3',
+ String generatorVersion = '3.1.2+3',
}) =>
dir(
appPath,
@@ -324,11 +330,17 @@
}) {
if (version != null && path != null) {
throw ArgumentError.value(
- path, 'path', 'Only one of "version" and "path" can be provided');
+ path,
+ 'path',
+ 'Only one of "version" and "path" can be provided',
+ );
}
if (version == null && path == null) {
throw ArgumentError.value(
- version, 'version', 'Either "version" or "path" must be given');
+ version,
+ 'version',
+ 'Either "version" or "path" must be given',
+ );
}
Uri rootUri;
if (version != null) {
diff --git a/test/descriptor/git.dart b/test/descriptor/git.dart
index 9209815..d092d99 100644
--- a/test/descriptor/git.dart
+++ b/test/descriptor/git.dart
@@ -68,9 +68,11 @@
'GIT_AUTHOR_DATE': DateTime(1970).toIso8601String(),
};
- return git.run(args,
- workingDir: path.join(parent ?? sandbox, name),
- environment: environment);
+ return git.run(
+ args,
+ workingDir: path.join(parent ?? sandbox, name),
+ environment: environment,
+ );
}
Future _runGitCommands(String? parent, List<List<String>> commands) async {
diff --git a/test/descriptor/package_config.dart b/test/descriptor/package_config.dart
index 5c84a82..b508dc6 100644
--- a/test/descriptor/package_config.dart
+++ b/test/descriptor/package_config.dart
@@ -70,10 +70,11 @@
(p) => isA<PackageConfigEntry>()
.having((p0) => p0.name, 'name', p.name)
.having(
- (p0) => p0.languageVersion,
- 'languageVersion',
- // If the expected entry has no language-version we don't check it.
- p.languageVersion ?? anything)
+ (p0) => p0.languageVersion,
+ 'languageVersion',
+ // If the expected entry has no language-version we don't check it.
+ p.languageVersion ?? anything,
+ )
.having((p0) => p0.rootUri, 'rootUri', p.rootUri)
.having((p0) => p0.packageUri, 'packageUri', p.packageUri),
)
@@ -86,8 +87,11 @@
config.generated = null;
expected.packages = []; // Already compared packages (ignoring ordering)
config.packages = [];
- expect(config.toJson(), equals(expected.toJson()),
- reason: '"$packageConfigFile" does not match expected values');
+ expect(
+ config.toJson(),
+ equals(expected.toJson()),
+ reason: '"$packageConfigFile" does not match expected values',
+ );
}
@override
diff --git a/test/descriptor/tar.dart b/test/descriptor/tar.dart
index 2a3488f..c12a662 100644
--- a/test/descriptor/tar.dart
+++ b/test/descriptor/tar.dart
@@ -25,8 +25,12 @@
return withTempDir((tempDir) async {
await Future.wait(contents.map((entry) => entry.create(tempDir)));
- var createdContents = listDir(tempDir,
- recursive: true, includeHidden: true, includeDirs: false);
+ var createdContents = listDir(
+ tempDir,
+ recursive: true,
+ includeHidden: true,
+ includeDirs: false,
+ );
var bytes =
await createTarGz(createdContents, baseDir: tempDir).toBytes();
@@ -49,10 +53,12 @@
@override
Stream<List<int>> readAsBytes() {
- return Stream<List<int>>.fromFuture(withTempDir((tempDir) async {
- await create(tempDir);
- return readBinaryFile(path.join(tempDir, name));
- }));
+ return Stream<List<int>>.fromFuture(
+ withTempDir((tempDir) async {
+ await create(tempDir);
+ return readBinaryFile(path.join(tempDir, name));
+ }),
+ );
}
}
diff --git a/test/dev_dependency_test.dart b/test/dev_dependency_test.dart
index b192444..25bdaa8 100644
--- a/test/dev_dependency_test.dart
+++ b/test/dev_dependency_test.dart
@@ -36,9 +36,13 @@
test("includes dev dependency's transitive dependencies", () async {
await d.dir('foo', [
d.libDir('foo'),
- d.libPubspec('foo', '0.0.1', deps: {
- 'bar': {'path': '../bar'}
- })
+ d.libPubspec(
+ 'foo',
+ '0.0.1',
+ deps: {
+ 'bar': {'path': '../bar'}
+ },
+ )
]).create();
await d
@@ -77,9 +81,11 @@
.dir('bar', [d.libDir('bar'), d.libPubspec('bar', '0.0.1')]).create();
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': '../foo'}
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': '../foo'}
+ },
+ )
]).create();
await pubGet();
diff --git a/test/directory_option_test.dart b/test/directory_option_test.dart
index 5a483d9..ac61887 100644
--- a/test/directory_option_test.dart
+++ b/test/directory_option_test.dart
@@ -23,10 +23,11 @@
RegExp('/api/packages/test_pkg/uploaders'),
(request) {
return shelf.Response.ok(
- jsonEncode({
- 'success': {'message': 'Good job!'}
- }),
- headers: {'content-type': 'application/json'});
+ jsonEncode({
+ 'success': {'message': 'Good job!'}
+ }),
+ headers: {'content-type': 'application/json'},
+ );
},
);
@@ -40,7 +41,6 @@
dir('example', [
pubspec({
'name': 'example',
- 'environment': {'sdk': '>=0.1.2 <0.2.0'},
'dependencies': {
'test_pkg': {'path': '../'}
}
@@ -49,7 +49,6 @@
dir('example2', [
pubspec({
'name': 'example',
- 'environment': {'sdk': '>=0.1.2 <0.2.0'},
'dependencies': {
'myapp': {'path': '../'} // Wrong name of dependency
}
diff --git a/test/downgrade/does_not_show_other_versions_test.dart b/test/downgrade/does_not_show_other_versions_test.dart
index 884bbaf..da3ec19 100644
--- a/test/downgrade/does_not_show_other_versions_test.dart
+++ b/test/downgrade/does_not_show_other_versions_test.dart
@@ -14,12 +14,12 @@
..serve('downgraded', '2.0.0')
..serve('downgraded', '3.0.0-dev');
- await d.appDir({'downgraded': '3.0.0-dev'}).create();
+ await d.appDir(dependencies: {'downgraded': '3.0.0-dev'}).create();
await pubGet();
// Loosen the constraints.
- await d.appDir({'downgraded': '>=2.0.0'}).create();
+ await d.appDir(dependencies: {'downgraded': '>=2.0.0'}).create();
await pubDowngrade(output: contains('downgraded 2.0.0 (was 3.0.0-dev)'));
});
diff --git a/test/downgrade/doesnt_change_git_dependencies_test.dart b/test/downgrade/doesnt_change_git_dependencies_test.dart
index 1450af5..cb77483 100644
--- a/test/downgrade/doesnt_change_git_dependencies_test.dart
+++ b/test/downgrade/doesnt_change_git_dependencies_test.dart
@@ -12,18 +12,24 @@
ensureGit();
await d.git(
- 'foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
- await d.appDir({
- 'foo': {'git': '../foo.git'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'git': '../foo.git'}
+ },
+ ).create();
await pubGet();
var originalFooSpec = packageSpec('foo');
- await d.git('foo.git',
- [d.libDir('foo', 'foo 2'), d.libPubspec('foo', '1.0.0')]).commit();
+ await d.git(
+ 'foo.git',
+ [d.libDir('foo', 'foo 2'), d.libPubspec('foo', '1.0.0')],
+ ).commit();
await pubDowngrade();
diff --git a/test/downgrade/dry_run_does_not_apply_changes_test.dart b/test/downgrade/dry_run_does_not_apply_changes_test.dart
index 38fbebe..5693a78 100644
--- a/test/downgrade/dry_run_does_not_apply_changes_test.dart
+++ b/test/downgrade/dry_run_does_not_apply_changes_test.dart
@@ -16,21 +16,23 @@
..serve('foo', '2.0.0');
// Create the first lockfile.
- await d.appDir({'foo': '2.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '2.0.0'}).create();
await pubGet();
// Change the pubspec.
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
// Also delete the "packages" directory.
deleteEntry(path.join(d.sandbox, appPath, 'packages'));
// Do the dry run.
await pubDowngrade(
- args: ['--dry-run'],
- output: allOf(
- [contains('< foo 1.0.0'), contains('Would change 1 dependency.')]));
+ args: ['--dry-run'],
+ output: allOf(
+ [contains('< foo 1.0.0'), contains('Would change 1 dependency.')],
+ ),
+ );
await d.dir(appPath, [
// The lockfile should be unmodified.
diff --git a/test/downgrade/unlock_if_necessary_test.dart b/test/downgrade/unlock_if_necessary_test.dart
index c8b55af..96d789d 100644
--- a/test/downgrade/unlock_if_necessary_test.dart
+++ b/test/downgrade/unlock_if_necessary_test.dart
@@ -15,7 +15,7 @@
server.serve('foo', '2.0.0', deps: {'foo_dep': 'any'});
server.serve('foo_dep', '2.0.0');
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await pubGet();
diff --git a/test/downgrade/unlock_single_package_test.dart b/test/downgrade/unlock_single_package_test.dart
index 1188e41..cbac548 100644
--- a/test/downgrade/unlock_single_package_test.dart
+++ b/test/downgrade/unlock_single_package_test.dart
@@ -13,7 +13,7 @@
server.serve('foo', '2.1.0', deps: {'bar': '>1.0.0'});
server.serve('bar', '2.1.0');
- await d.appDir({'foo': 'any', 'bar': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any', 'bar': 'any'}).create();
await pubGet();
await d.appPackageConfigFile([
@@ -52,7 +52,7 @@
..serve('foo', '2.0.0')
..serve('foo', '2.1.0');
- await d.appDir({'foo': '^2.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '^2.0.0'}).create();
await pubGet();
await d.appPackageConfigFile([
diff --git a/test/embedding/embedding_test.dart b/test/embedding/embedding_test.dart
index 89b4d08..a234ec2 100644
--- a/test/embedding/embedding_test.dart
+++ b/test/embedding/embedding_test.dart
@@ -7,6 +7,7 @@
import 'package:path/path.dart' as path;
import 'package:path/path.dart' as p;
+import 'package:pub/src/io.dart' show EnvironmentKeys;
import 'package:test/test.dart';
import 'package:test_process/test_process.dart';
@@ -42,13 +43,15 @@
final stdoutLines = await process.stdout.rest.toList();
final stderrLines = await process.stderr.rest.toList();
- buffer.writeln([
- '\$ $_commandRunner ${args.join(' ')}',
- if (stdoutLines.isNotEmpty) _filter(stdoutLines.join('\n')),
- if (stderrLines.isNotEmpty)
- _filter(stderrLines.join('\n'))
- .replaceAll(RegExp('^', multiLine: true), '[E] '),
- ].join('\n'));
+ buffer.writeln(
+ [
+ '\$ $_commandRunner ${args.join(' ')}',
+ if (stdoutLines.isNotEmpty) _filter(stdoutLines.join('\n')),
+ if (stderrLines.isNotEmpty)
+ _filter(stderrLines.join('\n'))
+ .replaceAll(RegExp('^', multiLine: true), '[E] '),
+ ].join('\n'),
+ );
buffer.write('\n');
}
@@ -79,7 +82,9 @@
final tempDir = Directory.systemTemp.createTempSync();
snapshot = path.join(tempDir.path, 'command_runner.dart.snapshot');
final r = Process.runSync(
- Platform.resolvedExecutable, ['--snapshot=$snapshot', _commandRunner]);
+ Platform.resolvedExecutable,
+ ['--snapshot=$snapshot', _commandRunner],
+ );
expect(r.exitCode, 0, reason: r.stderr);
});
@@ -90,12 +95,7 @@
testWithGolden('run works, though hidden', (ctx) async {
await servePackages();
await d.dir(appPath, [
- d.pubspec({
- 'name': 'myapp',
- 'environment': {
- 'sdk': '0.1.2+3',
- },
- }),
+ d.appPubspec(),
d.dir('bin', [
d.file('main.dart', '''
import 'dart:io';
@@ -122,7 +122,7 @@
(context) async {
final server = await servePackages();
server.serve('foo', '1.0.0');
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
// TODO(sigurdm) This logs the entire verbose trace to a golden file.
//
@@ -165,15 +165,17 @@
await d.dir('dep', [
d.pubspec({
'name': 'dep',
- 'environment': {'sdk': '>=0.0.0 <3.0.0'}
+ 'environment': {'sdk': '^3.0.0'}
})
]).create();
final app = d.dir(appPath, [
- d.appPubspec({
- 'foo': '1.0.0',
- // The path dependency should not go to analytics.
- 'dep': {'path': '../dep'}
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': '1.0.0',
+ // The path dependency should not go to analytics.
+ 'dep': {'path': '../dep'}
+ },
+ )
]);
await app.create();
@@ -231,7 +233,7 @@
await servePackages();
final buffer = StringBuffer();
await runEmbeddingToBuffer(['--verbose', 'pub', 'logout'], buffer);
- expect(buffer.toString(), contains('FINE: Pub 0.1.2+3'));
+ expect(buffer.toString(), contains('FINE: Pub 3.1.2+3'));
});
testWithGolden('--help', (context) async {
@@ -246,7 +248,7 @@
final server = await servePackages();
server.serve('foo', '1.0.0');
server.serve('foo', '2.0.0');
- await d.appDir({'foo': '^1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '^1.0.0'}).create();
await context.runEmbedding(
['pub', '--no-color', 'get'],
environment: getPubTestEnvironment(),
@@ -272,18 +274,26 @@
]).create();
final server = await servePackages();
- server.serve('foo', '1.0.0', pubspec: {
- 'environment': {'sdk': '^2.18.0'}
- });
+ server.serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'environment': {'sdk': '^2.18.0'}
+ },
+ );
await pubGet(environment: {'_PUB_TEST_SDK_VERSION': '2.18.3'});
// Deleting the version-listing cache will cause it to be refetched, and the
// warning will happen.
File(p.join(globalServer.cachingPath, '.cache', 'foo-versions.json'))
.deleteSync();
- server.serve('foo', '1.0.1', pubspec: {
- 'environment': {'sdk': '^2.18.0'}
- });
+ server.serve(
+ 'foo',
+ '1.0.1',
+ pubspec: {
+ 'environment': {'sdk': '^2.18.0'}
+ },
+ );
final buffer = StringBuffer();
@@ -319,6 +329,69 @@
),
);
});
+
+ test('`embedding run` does not have output when successful and no terminal',
+ () async {
+ await d.dir(appPath, [
+ d.pubspec({
+ 'name': 'myapp',
+ 'dependencies': {'foo': '^1.0.0'}
+ }),
+ d.dir('bin', [
+ d.file('myapp.dart', 'main() {print(42);}'),
+ ])
+ ]).create();
+
+ final server = await servePackages();
+ server.serve('foo', '1.0.0');
+
+ final buffer = StringBuffer();
+ await runEmbeddingToBuffer(
+ ['run', 'myapp'],
+ buffer,
+ workingDirectory: d.path(appPath),
+ environment: {EnvironmentKeys.forceTerminalOutput: '0'},
+ );
+
+ expect(
+ buffer.toString(),
+ allOf(
+ isNot(contains('Resolving dependencies...')),
+ contains('42'),
+ ),
+ );
+ });
+ test('`embedding run` outputs info when successful and has a terminal',
+ () async {
+ await d.dir(appPath, [
+ d.pubspec({
+ 'name': 'myapp',
+ 'dependencies': {'foo': '^1.0.0'}
+ }),
+ d.dir('bin', [
+ d.file('myapp.dart', 'main() {print(42);}'),
+ ])
+ ]).create();
+
+ final server = await servePackages();
+ server.serve('foo', '1.0.0');
+
+ final buffer = StringBuffer();
+ await runEmbeddingToBuffer(
+ ['run', 'myapp'],
+ buffer,
+ workingDirectory: d.path(appPath),
+ environment: {EnvironmentKeys.forceTerminalOutput: '1'},
+ );
+ expect(
+ buffer.toString(),
+ allOf(
+ contains('Resolving dependencies'),
+ contains('+ foo 1.0.0'),
+ contains('42'),
+ ),
+ );
+ });
}
String _filter(String input) {
@@ -357,8 +430,10 @@
r'Created $FILE from stream',
)
.replaceAll(
- RegExp(r'Renaming directory $SANDBOX/cache/_temp/(.*?) to',
- multiLine: true),
+ RegExp(
+ r'Renaming directory $SANDBOX/cache/_temp/(.*?) to',
+ multiLine: true,
+ ),
r'Renaming directory $SANDBOX/cache/_temp/',
)
.replaceAll(
@@ -402,8 +477,10 @@
r'"generated": "$TIME",',
)
.replaceAll(
- RegExp(r'( |^)(/|[A-Z]:)(.*)/tool/test-bin/pub_command_runner.dart',
- multiLine: true),
+ RegExp(
+ r'( |^)(/|[A-Z]:)(.*)/tool/test-bin/pub_command_runner.dart',
+ multiLine: true,
+ ),
r' tool/test-bin/pub_command_runner.dart',
)
.replaceAll(
@@ -424,9 +501,10 @@
)
.replaceAll(
RegExp(
- r'Computed checksum \d+ for foo 1.0.0 with expected CRC32C of '
- r'\d+\.',
- multiLine: true),
+ r'Computed checksum \d+ for foo 1.0.0 with expected CRC32C of '
+ r'\d+\.',
+ multiLine: true,
+ ),
r'Computed checksum $CRC32C for foo 1.0.0 with expected CRC32C of '
r'$CRC32C.',
)
@@ -434,9 +512,10 @@
/// TODO(sigurdm): This hack suppresses differences in stack-traces
/// between dart 2.17 and 2.18. Remove when 2.18 is stable.
.replaceAllMapped(
- RegExp(
- r'(^(.*)pub/src/command.dart \$LINE:\$COL(.*)$)\n\1',
- multiLine: true,
- ),
- (match) => match[1]!);
+ RegExp(
+ r'(^(.*)pub/src/command.dart \$LINE:\$COL(.*)$)\n\1',
+ multiLine: true,
+ ),
+ (match) => match[1]!,
+ );
}
diff --git a/test/embedding/get_executable_for_command_test.dart b/test/embedding/get_executable_for_command_test.dart
index 7f395a7..8781897 100644
--- a/test/embedding/get_executable_for_command_test.dart
+++ b/test/embedding/get_executable_for_command_test.dart
@@ -65,14 +65,23 @@
]).create();
final dir = d.path('foo');
- await testGetExecutable('bar/bar.dart', dir,
- executable: p.join('bar', 'bar.dart'));
+ await testGetExecutable(
+ 'bar/bar.dart',
+ dir,
+ executable: p.join('bar', 'bar.dart'),
+ );
- await testGetExecutable(p.join('bar', 'bar.dart'), dir,
- executable: p.join('bar', 'bar.dart'));
+ await testGetExecutable(
+ p.join('bar', 'bar.dart'),
+ dir,
+ executable: p.join('bar', 'bar.dart'),
+ );
- await testGetExecutable('${p.toUri(dir)}/bar/bar.dart', dir,
- executable: p.join('bar', 'bar.dart'));
+ await testGetExecutable(
+ '${p.toUri(dir)}/bar/bar.dart',
+ dir,
+ executable: p.join('bar', 'bar.dart'),
+ );
});
test('Looks for file when no pubspec.yaml', () async {
@@ -81,12 +90,18 @@
]).create();
final dir = d.path('foo');
- await testGetExecutable('bar/m.dart', dir,
- errorMessage: contains('Could not find file `bar/m.dart`'),
- issue: CommandResolutionIssue.fileNotFound);
- await testGetExecutable(p.join('bar', 'm.dart'), dir,
- errorMessage: contains('Could not find file `bar${separator}m.dart`'),
- issue: CommandResolutionIssue.fileNotFound);
+ await testGetExecutable(
+ 'bar/m.dart',
+ dir,
+ errorMessage: contains('Could not find file `bar/m.dart`'),
+ issue: CommandResolutionIssue.fileNotFound,
+ );
+ await testGetExecutable(
+ p.join('bar', 'm.dart'),
+ dir,
+ errorMessage: contains('Could not find file `bar${separator}m.dart`'),
+ issue: CommandResolutionIssue.fileNotFound,
+ );
});
test('Error message when pubspec is broken', () async {
@@ -99,7 +114,7 @@
await d.dir(appPath, [
d.pubspec({
'name': 'myapp',
- 'environment': {'sdk': '>=$_currentVersion <3.0.0'},
+ 'environment': {'sdk': '^$_currentVersion'},
'dependencies': {
'foo': {
'path': '../foo',
@@ -108,20 +123,26 @@
}),
]).create();
final dir = d.path(appPath);
- await testGetExecutable('foo:app', dir,
- errorMessage: allOf(
- contains(
- 'Error on line 1, column 9 of ${d.sandbox}${p.separator}foo${p.separator}pubspec.yaml: "name" field must be a valid Dart identifier.'),
- contains(
- '{"name":"broken name","environment":{"sdk":">=0.1.2 <1.0.0"}}')),
- issue: CommandResolutionIssue.pubGetFailed);
+ await testGetExecutable(
+ 'foo:app',
+ dir,
+ errorMessage: allOf(
+ contains(
+ 'Error on line 1, column 9 of ${d.sandbox}${p.separator}foo${p.separator}pubspec.yaml: "name" field must be a valid Dart identifier.',
+ ),
+ contains(
+ '{"name":"broken name","environment":{"sdk":"$defaultSdkConstraint"}}',
+ ),
+ ),
+ issue: CommandResolutionIssue.pubGetFailed,
+ );
});
test('Does `pub get` if there is a pubspec.yaml', () async {
await d.dir(appPath, [
d.pubspec({
'name': 'myapp',
- 'environment': {'sdk': '>=$_currentVersion <3.0.0'},
+ 'environment': {'sdk': '^$_currentVersion'},
'dependencies': {'foo': '^1.0.0'}
}),
d.dir('bin', [
@@ -144,7 +165,7 @@
await d.dir(appPath, [
d.pubspec({
'name': 'myapp',
- 'environment': {'sdk': '>=$_currentVersion <3.0.0'},
+ 'environment': {'sdk': '^$_currentVersion'},
}),
]).create();
await testGetExecutable(
@@ -159,7 +180,7 @@
await d.dir(appPath, [
d.pubspec({
'name': 'myapp',
- 'environment': {'sdk': '>=$_currentVersion <3.0.0'},
+ 'environment': {'sdk': '^$_currentVersion'},
}),
d.dir('bin', [
d.file('foo.dart', 'main() {'),
@@ -179,24 +200,29 @@
test('Finds files', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', pubspec: {
- 'environment': {'sdk': '>=$_currentVersion <3.0.0'}
- }, contents: [
- d.dir('bin', [
- d.file('foo.dart', 'main() {print(42);}'),
- d.file('tool.dart', 'main() {print(42);}')
- ])
- ]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'environment': {'sdk': '^$_currentVersion'}
+ },
+ contents: [
+ d.dir('bin', [
+ d.file('foo.dart', 'main() {print(42);}'),
+ d.file('tool.dart', 'main() {print(42);}')
+ ])
+ ],
+ );
await d.dir(appPath, [
d.pubspec({
'name': 'myapp',
- 'environment': {'sdk': '>=2.0.0 <3.0.0'},
+ 'environment': {'sdk': '^$_currentVersion'},
'dependencies': {
'foo': {
'hosted': {
'name': 'foo',
- 'url': getPubTestEnvironment()['PUB_HOSTED_URL'],
+ 'url': globalServer.url,
},
'version': '^1.0.0',
},
@@ -212,29 +238,49 @@
await testGetExecutable(
'myapp',
dir,
- executable: p.join('.dart_tool', 'pub', 'bin', 'myapp',
- 'myapp.dart-$_currentVersion.snapshot'),
+ executable: p.join(
+ '.dart_tool',
+ 'pub',
+ 'bin',
+ 'myapp',
+ 'myapp.dart-$_currentVersion.snapshot',
+ ),
packageConfig: p.join('.dart_tool', 'package_config.json'),
);
await testGetExecutable(
'myapp:myapp',
dir,
- executable: p.join('.dart_tool', 'pub', 'bin', 'myapp',
- 'myapp.dart-$_currentVersion.snapshot'),
+ executable: p.join(
+ '.dart_tool',
+ 'pub',
+ 'bin',
+ 'myapp',
+ 'myapp.dart-$_currentVersion.snapshot',
+ ),
packageConfig: p.join('.dart_tool', 'package_config.json'),
);
await testGetExecutable(
':myapp',
dir,
- executable: p.join('.dart_tool', 'pub', 'bin', 'myapp',
- 'myapp.dart-$_currentVersion.snapshot'),
+ executable: p.join(
+ '.dart_tool',
+ 'pub',
+ 'bin',
+ 'myapp',
+ 'myapp.dart-$_currentVersion.snapshot',
+ ),
packageConfig: p.join('.dart_tool', 'package_config.json'),
);
await testGetExecutable(
':tool',
dir,
- executable: p.join('.dart_tool', 'pub', 'bin', 'myapp',
- 'tool.dart-$_currentVersion.snapshot'),
+ executable: p.join(
+ '.dart_tool',
+ 'pub',
+ 'bin',
+ 'myapp',
+ 'tool.dart-$_currentVersion.snapshot',
+ ),
packageConfig: p.join('.dart_tool', 'package_config.json'),
);
await testGetExecutable(
diff --git a/test/error_group_test.dart b/test/error_group_test.dart
index 53fb58f..15ffcf4 100644
--- a/test/error_group_test.dart
+++ b/test/error_group_test.dart
@@ -35,8 +35,9 @@
expect(() => errorGroup.registerFuture(Future.value()), throwsStateError);
expect(
- () => errorGroup.registerStream(StreamController(sync: true).stream),
- throwsStateError);
+ () => errorGroup.registerStream(StreamController(sync: true).stream),
+ throwsStateError,
+ );
});
});
@@ -62,13 +63,15 @@
completer.complete('value');
expect(
- completer.future
- .then((_) => errorGroup.registerFuture(Future.value())),
- throwsStateError);
+ completer.future.then((_) => errorGroup.registerFuture(Future.value())),
+ throwsStateError,
+ );
expect(
- completer.future.then((_) =>
- errorGroup.registerStream(StreamController(sync: true).stream)),
- throwsStateError);
+ completer.future.then(
+ (_) => errorGroup.registerStream(StreamController(sync: true).stream),
+ ),
+ throwsStateError,
+ );
});
test(
@@ -130,9 +133,12 @@
completer.completeError(FormatException());
// A listener added afterwards should receive the exception
- expect(errorGroup.done.catchError((_) {
- expect(future, throwsFormatException);
- }), completes);
+ expect(
+ errorGroup.done.catchError((_) {
+ expect(future, throwsFormatException);
+ }),
+ completes,
+ );
});
test(
@@ -142,10 +148,13 @@
errorGroup.signalError(FormatException());
// A listener added afterwards should receive the exception
- expect(errorGroup.done.catchError((_) {
- completer.complete('value'); // should be ignored
- expect(future, throwsFormatException);
- }), completes);
+ expect(
+ errorGroup.done.catchError((_) {
+ completer.complete('value'); // should be ignored
+ expect(future, throwsFormatException);
+ }),
+ completes,
+ );
});
});
@@ -190,10 +199,13 @@
expect(future1, completion(equals('value')));
completer1.complete('value');
- expect(future1.then((_) {
- // shouldn't cause a top-level exception
- completer2.completeError(FormatException());
- }), completes);
+ expect(
+ future1.then((_) {
+ // shouldn't cause a top-level exception
+ completer2.completeError(FormatException());
+ }),
+ completes,
+ );
});
test(
@@ -202,10 +214,13 @@
expect(future1, completion(equals('value')));
completer1.complete('value');
- expect(future1.then((_) {
- // shouldn't cause a top-level exception
- errorGroup.signalError(FormatException());
- }), completes);
+ expect(
+ future1.then((_) {
+ // shouldn't cause a top-level exception
+ errorGroup.signalError(FormatException());
+ }),
+ completes,
+ );
});
});
@@ -281,8 +296,10 @@
// Now that broadcast controllers have been removed a listener should
// see the value that has been put into the controller.
- expect(errorGroup.done.then((_) => stream.toList()),
- completion(equals(['value'])));
+ expect(
+ errorGroup.done.then((_) => stream.toList()),
+ completion(equals(['value'])),
+ );
});
});
@@ -304,8 +321,10 @@
controller.close();
// A listener added afterwards should receive the value
- expect(errorGroup.done.then((_) => stream.toList()),
- completion(equals(['value'])));
+ expect(
+ errorGroup.done.then((_) => stream.toList()),
+ completion(equals(['value'])),
+ );
});
test(
@@ -315,10 +334,13 @@
controller.addError(FormatException());
// A listener added afterwards should receive the exception
- expect(errorGroup.done.catchError((_) {
- controller.add('value'); // should be ignored
- expect(stream.first, throwsFormatException);
- }), completes);
+ expect(
+ errorGroup.done.catchError((_) {
+ controller.add('value'); // should be ignored
+ expect(stream.first, throwsFormatException);
+ }),
+ completes,
+ );
});
test(
@@ -328,10 +350,13 @@
errorGroup.signalError(FormatException());
// A listener added afterwards should receive the exception
- expect(errorGroup.done.catchError((_) {
- controller.add('value'); // should be ignored
- expect(stream.first, throwsFormatException);
- }), completes);
+ expect(
+ errorGroup.done.catchError((_) {
+ controller.add('value'); // should be ignored
+ expect(stream.first, throwsFormatException);
+ }),
+ completes,
+ );
});
});
@@ -377,34 +402,44 @@
"shouldn't throw a top-level exception if a stream receives an error "
'after the other listened stream completes', () {
var signal = Completer();
- expect(stream1.toList().whenComplete(signal.complete),
- completion(equals(['value1', 'value2'])));
+ expect(
+ stream1.toList().whenComplete(signal.complete),
+ completion(equals(['value1', 'value2'])),
+ );
controller1
..add('value1')
..add('value2')
..close();
- expect(signal.future.then((_) {
- // shouldn't cause a top-level exception
- controller2.addError(FormatException());
- }), completes);
+ expect(
+ signal.future.then((_) {
+ // shouldn't cause a top-level exception
+ controller2.addError(FormatException());
+ }),
+ completes,
+ );
});
test(
"shouldn't throw a top-level exception if an error is signaled after "
'one listened stream completes', () {
var signal = Completer();
- expect(stream1.toList().whenComplete(signal.complete),
- completion(equals(['value1', 'value2'])));
+ expect(
+ stream1.toList().whenComplete(signal.complete),
+ completion(equals(['value1', 'value2'])),
+ );
controller1
..add('value1')
..add('value2')
..close();
- expect(signal.future.then((_) {
- // shouldn't cause a top-level exception
- errorGroup.signalError(FormatException());
- }), completes);
+ expect(
+ signal.future.then((_) {
+ // shouldn't cause a top-level exception
+ errorGroup.signalError(FormatException());
+ }),
+ completes,
+ );
});
});
@@ -458,27 +493,35 @@
expect(future, completion(equals('value')));
completer.complete('value');
- expect(future.then((_) {
- // shouldn't cause a top-level exception
- controller.addError(FormatException());
- }), completes);
+ expect(
+ future.then((_) {
+ // shouldn't cause a top-level exception
+ controller.addError(FormatException());
+ }),
+ completes,
+ );
});
test(
"shouldn't throw a top-level exception if the future receives an "
'error after the listened stream completes', () {
var signal = Completer();
- expect(stream.toList().whenComplete(signal.complete),
- completion(equals(['value1', 'value2'])));
+ expect(
+ stream.toList().whenComplete(signal.complete),
+ completion(equals(['value1', 'value2'])),
+ );
controller
..add('value1')
..add('value2')
..close();
- expect(signal.future.then((_) {
- // shouldn't cause a top-level exception
- completer.completeError(FormatException());
- }), completes);
+ expect(
+ signal.future.then((_) {
+ // shouldn't cause a top-level exception
+ completer.completeError(FormatException());
+ }),
+ completes,
+ );
});
});
}
diff --git a/test/get/dry_run_does_not_apply_changes_test.dart b/test/get/dry_run_does_not_apply_changes_test.dart
index 3e44bf9..a223335 100644
--- a/test/get/dry_run_does_not_apply_changes_test.dart
+++ b/test/get/dry_run_does_not_apply_changes_test.dart
@@ -12,12 +12,14 @@
final server = await servePackages();
server.serve('foo', '1.0.0');
- await d.appDir({'foo': '1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '1.0.0'}).create();
await pubGet(
- args: ['--dry-run'],
- output: allOf(
- [contains('+ foo 1.0.0'), contains('Would change 1 dependency.')]));
+ args: ['--dry-run'],
+ output: allOf(
+ [contains('+ foo 1.0.0'), contains('Would change 1 dependency.')],
+ ),
+ );
await d.dir(appPath, [
// The lockfile should not be created.
diff --git a/test/get/enforce_lockfile_test.dart b/test/get/enforce_lockfile_test.dart
index 979db08..ab66ecb 100644
--- a/test/get/enforce_lockfile_test.dart
+++ b/test/get/enforce_lockfile_test.dart
@@ -16,7 +16,7 @@
() async {
final server = await servePackages();
server.serve('foo', '1.0.0');
- await appDir({'foo': 'any'}).create();
+ await appDir(dependencies: {'foo': 'any'}).create();
await pubGet();
final packageConfig =
File(path(p.join(appPath, '.dart_tool', 'package_config.json')));
@@ -31,7 +31,7 @@
});
test('Refuses to get if no lockfile exists', () async {
- await appDir({}).create();
+ await appDir(dependencies: {}).create();
await pubGet(
args: ['--enforce-lockfile'],
error: '''
@@ -49,20 +49,28 @@
server.serve('foo', '1.0.0');
server.serve('bar', '1.0.0');
- await appDir({'foo': '^1.0.0'}).create();
+ await appDir(dependencies: {'foo': '^1.0.0'}).create();
await dir(appPath, [
dir('example', [
- libPubspec('example', '0.0.0', deps: {
- 'bar': '1.0.0',
- 'myapp': {'path': '../'}
- })
+ libPubspec(
+ 'example',
+ '0.0.0',
+ deps: {
+ 'bar': '1.0.0',
+ 'myapp': {'path': '../'}
+ },
+ )
])
]).create();
await pubGet(args: ['--example']);
- server.serve('bar', '1.0.0', contents: [
- file('README.md', 'Including this will change the content-hash.'),
- ]);
+ server.serve(
+ 'bar',
+ '1.0.0',
+ contents: [
+ file('README.md', 'Including this will change the content-hash.'),
+ ],
+ );
// Deleting the version-listing cache will cause it to be refetched, and the
// error will happen.
File(p.join(globalServer.cachingPath, '.cache', 'bar-versions.json'))
@@ -79,7 +87,8 @@
contains('Resolving dependencies in $example...'),
),
error: contains(
- 'Unable to satisfy `$examplePubspec` using `$exampleLockfile` in $example. For details run `dart pub get --directory $example --enforce-lockfile'),
+ 'Unable to satisfy `$examplePubspec` using `$exampleLockfile` in $example. For details run `dart pub get --directory $example --enforce-lockfile',
+ ),
exitCode: DATA,
);
});
@@ -87,9 +96,9 @@
test('Refuses to get if lockfile is missing package', () async {
final server = await servePackages();
server.serve('foo', '1.0.0');
- await appDir({}).create();
+ await appDir(dependencies: {}).create();
await pubGet();
- await appDir({'foo': 'any'}).create();
+ await appDir(dependencies: {'foo': 'any'}).create();
await pubGet(
args: ['--enforce-lockfile'],
@@ -107,9 +116,9 @@
final server = await servePackages();
server.serve('foo', '1.0.0');
server.serve('foo', '2.0.0');
- await appDir({'foo': '^1.0.0'}).create();
+ await appDir(dependencies: {'foo': '^1.0.0'}).create();
await pubGet();
- await appDir({'foo': '^2.0.0'}).create();
+ await appDir(dependencies: {'foo': '^2.0.0'}).create();
await pubGet(
args: ['--enforce-lockfile'],
output: allOf([
@@ -126,11 +135,15 @@
final server = await servePackages();
server.serveContentHashes = true;
server.serve('foo', '1.0.0');
- await appDir({'foo': '^1.0.0'}).create();
+ await appDir(dependencies: {'foo': '^1.0.0'}).create();
await pubGet();
- server.serve('foo', '1.0.0', contents: [
- file('README.md', 'Including this will change the content-hash.'),
- ]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ contents: [
+ file('README.md', 'Including this will change the content-hash.'),
+ ],
+ );
// Deleting the version-listing cache will cause it to be refetched, and the
// error will happen.
File(p.join(globalServer.cachingPath, '.cache', 'foo-versions.json'))
@@ -163,12 +176,16 @@
final server = await servePackages();
server.serveContentHashes = false;
server.serve('foo', '1.0.0');
- await appDir({'foo': '^1.0.0'}).create();
+ await appDir(dependencies: {'foo': '^1.0.0'}).create();
await pubGet();
await runPub(args: ['cache', 'clean', '-f']);
- server.serve('foo', '1.0.0', contents: [
- file('README.md', 'Including this will change the content-hash.'),
- ]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ contents: [
+ file('README.md', 'Including this will change the content-hash.'),
+ ],
+ );
await pubGet(
args: ['--enforce-lockfile'],
diff --git a/test/get/flutter_constraint_upper_bound_ignored_test.dart b/test/get/flutter_constraint_upper_bound_ignored_test.dart
index 7fd2edc..bcfb527 100644
--- a/test/get/flutter_constraint_upper_bound_ignored_test.dart
+++ b/test/get/flutter_constraint_upper_bound_ignored_test.dart
@@ -21,7 +21,8 @@
]).create();
await pubGet(
- exitCode: exit_codes.SUCCESS,
- environment: {'FLUTTER_ROOT': fakeFlutterRoot.io.path});
+ exitCode: exit_codes.SUCCESS,
+ environment: {'FLUTTER_ROOT': fakeFlutterRoot.io.path},
+ );
});
}
diff --git a/test/get/get_inside_cache_fails_test.dart b/test/get/get_inside_cache_fails_test.dart
index a7a6b45..231a371 100644
--- a/test/get/get_inside_cache_fails_test.dart
+++ b/test/get/get_inside_cache_fails_test.dart
@@ -11,17 +11,14 @@
void main() {
test('`pub get` inside the cache fails gracefully', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', pubspec: {
- 'name': 'foo',
- 'version': '1.0.0',
- 'environment': {'sdk': '>=0.1.2+3 <0.2.0'}
- });
- await d.appDir({'foo': 'any'}).create();
+ server.serve('foo', '1.0.0');
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await pubGet();
await pubGet(
- workingDirectory: p.join(d.sandbox, d.hostedCachePath(), 'foo-1.0.0'),
- error: 'Cannot operate on packages inside the cache.');
+ workingDirectory: p.join(d.sandbox, d.hostedCachePath(), 'foo-1.0.0'),
+ error: 'Cannot operate on packages inside the cache.',
+ );
});
}
diff --git a/test/get/gets_in_example_folder_test.dart b/test/get/gets_in_example_folder_test.dart
index 04f9d47..b0aee35 100644
--- a/test/get/gets_in_example_folder_test.dart
+++ b/test/get/gets_in_example_folder_test.dart
@@ -38,19 +38,21 @@
expect(lockFile.existsSync(), true);
expect(exampleLockFile.existsSync(), false);
- await pubCommand(command,
- args: ['--example'],
- output: command.name == 'get'
- ? '''
+ await pubCommand(
+ command,
+ args: ['--example'],
+ output: command.name == 'get'
+ ? '''
Resolving dependencies...
Got dependencies!
Resolving dependencies in $dotExample...
Got dependencies in $dotExample.'''
- : '''
+ : '''
Resolving dependencies...
No dependencies changed.
Resolving dependencies in $dotExample...
-Got dependencies in $dotExample.''');
+Got dependencies in $dotExample.''',
+ );
expect(lockFile.existsSync(), true);
expect(exampleLockFile.existsSync(), true);
});
@@ -70,13 +72,15 @@
await pubGet(
args: ['--example'],
error: contains(
- 'Resolving dependencies in $dotExample failed. For details run `dart pub get --directory $dotExample`'),
+ 'Resolving dependencies in $dotExample failed. For details run `dart pub get --directory $dotExample`',
+ ),
exitCode: 1,
);
await pubGet(
args: ['--directory', dotExample],
error: contains(
- 'Error on line 1, column 9 of example${p.separator}pubspec.yaml'),
+ 'Error on line 1, column 9 of example${p.separator}pubspec.yaml',
+ ),
exitCode: exit_codes.DATA,
);
});
diff --git a/test/get/git/check_out_and_upgrade_test.dart b/test/get/git/check_out_and_upgrade_test.dart
index 42044af..1de2aa6 100644
--- a/test/get/git/check_out_and_upgrade_test.dart
+++ b/test/get/git/check_out_and_upgrade_test.dart
@@ -12,11 +12,15 @@
ensureGit();
await d.git(
- 'foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
- await d.appDir({
- 'foo': {'git': '../foo.git'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'git': '../foo.git'}
+ },
+ ).create();
await pubGet();
@@ -38,8 +42,10 @@
var originalFooSpec = packageSpec('foo');
- await d.git('foo.git',
- [d.libDir('foo', 'foo 2'), d.libPubspec('foo', '1.0.0')]).commit();
+ await d.git(
+ 'foo.git',
+ [d.libDir('foo', 'foo 2'), d.libPubspec('foo', '1.0.0')],
+ ).commit();
await pubUpgrade(output: contains('Changed 1 dependency!'));
diff --git a/test/get/git/check_out_branch_test.dart b/test/get/git/check_out_branch_test.dart
index 104c8b9..7d181fe 100644
--- a/test/get/git/check_out_branch_test.dart
+++ b/test/get/git/check_out_branch_test.dart
@@ -12,18 +12,24 @@
ensureGit();
var repo = d.git(
- 'foo.git', [d.libDir('foo', 'foo 1'), d.libPubspec('foo', '1.0.0')]);
+ 'foo.git',
+ [d.libDir('foo', 'foo 1'), d.libPubspec('foo', '1.0.0')],
+ );
await repo.create();
await repo.runGit(['branch', 'old']);
- await d.git('foo.git',
- [d.libDir('foo', 'foo 2'), d.libPubspec('foo', '1.0.0')]).commit();
+ await d.git(
+ 'foo.git',
+ [d.libDir('foo', 'foo 2'), d.libPubspec('foo', '1.0.0')],
+ ).commit();
- await d.appDir({
- 'foo': {
- 'git': {'url': '../foo.git', 'ref': 'old'}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'git': {'url': '../foo.git', 'ref': 'old'}
+ }
+ },
+ ).create();
await pubGet();
diff --git a/test/get/git/check_out_revision_test.dart b/test/get/git/check_out_revision_test.dart
index 2428d7c..91d71f8 100644
--- a/test/get/git/check_out_revision_test.dart
+++ b/test/get/git/check_out_revision_test.dart
@@ -12,18 +12,24 @@
ensureGit();
var repo = d.git(
- 'foo.git', [d.libDir('foo', 'foo 1'), d.libPubspec('foo', '1.0.0')]);
+ 'foo.git',
+ [d.libDir('foo', 'foo 1'), d.libPubspec('foo', '1.0.0')],
+ );
await repo.create();
var commit = await repo.revParse('HEAD');
- await d.git('foo.git',
- [d.libDir('foo', 'foo 2'), d.libPubspec('foo', '1.0.0')]).commit();
+ await d.git(
+ 'foo.git',
+ [d.libDir('foo', 'foo 2'), d.libPubspec('foo', '1.0.0')],
+ ).commit();
- await d.appDir({
- 'foo': {
- 'git': {'url': '../foo.git', 'ref': commit}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'git': {'url': '../foo.git', 'ref': commit}
+ }
+ },
+ ).create();
await pubGet();
diff --git a/test/get/git/check_out_test.dart b/test/get/git/check_out_test.dart
index ae766a0..09738a8 100644
--- a/test/get/git/check_out_test.dart
+++ b/test/get/git/check_out_test.dart
@@ -19,19 +19,27 @@
ensureGit();
await d.git(
- 'foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
- await d.appDir({
- 'foo': {'git': '../foo.git'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'git': '../foo.git'}
+ },
+ ).create();
await pubGet();
final lockfile = loadYaml(
- File(p.join(d.sandbox, appPath, 'pubspec.lock')).readAsStringSync());
- expect(lockfile['packages']['foo']['description']['url'], '../foo.git',
- reason:
- 'The relative path should be preserved, and be a url (forward slashes on all platforms)');
+ File(p.join(d.sandbox, appPath, 'pubspec.lock')).readAsStringSync(),
+ );
+ expect(
+ lockfile['packages']['foo']['description']['url'],
+ '../foo.git',
+ reason:
+ 'The relative path should be preserved, and be a url (forward slashes on all platforms)',
+ );
await d.dir(cachePath, [
d.dir('git', [
@@ -51,13 +59,15 @@
d.file('pubspec.yaml', '''
name: foo
environment:
- sdk: ^0.1.2
+ sdk: '$defaultSdkConstraint'
'''),
]).create();
- await d.appDir({
- 'foo': {'git': '../foo.git'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'git': '../foo.git'}
+ },
+ ).create();
await pubGet();
});
@@ -71,16 +81,21 @@
d.git('foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]);
await descriptor.create();
- await runProcess('git', ['update-server-info'],
- workingDir: descriptor.io.path);
+ await runProcess(
+ 'git',
+ ['update-server-info'],
+ workingDir: descriptor.io.path,
+ );
const funkyName = '@:+*foo';
final server =
await _serveDirectory(p.join(descriptor.io.path, '.git'), funkyName);
- await d.appDir({
- 'foo': {'git': 'http://localhost:${server.url.port}/$funkyName'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'git': 'http://localhost:${server.url.port}/$funkyName'}
+ },
+ ).create();
await pubGet();
diff --git a/test/get/git/check_out_transitive_test.dart b/test/get/git/check_out_transitive_test.dart
index 0587c58..5cd7ada 100644
--- a/test/get/git/check_out_transitive_test.dart
+++ b/test/get/git/check_out_transitive_test.dart
@@ -15,29 +15,40 @@
await d.git('foo.git', [
d.libDir('foo'),
- d.libPubspec('foo', '1.0.0', deps: {
- 'bar': {
- 'git':
- p.toUri(p.absolute(d.sandbox, appPath, '../bar.git')).toString()
- }
- })
+ d.libPubspec(
+ 'foo',
+ '1.0.0',
+ deps: {
+ 'bar': {
+ 'git':
+ p.toUri(p.absolute(d.sandbox, appPath, '../bar.git')).toString()
+ }
+ },
+ )
]).create();
await d.git(
- 'bar.git', [d.libDir('bar'), d.libPubspec('bar', '1.0.0')]).create();
+ 'bar.git',
+ [d.libDir('bar'), d.libPubspec('bar', '1.0.0')],
+ ).create();
- await d.appDir({
- 'foo': {
- 'git': p.toUri(p.absolute(d.sandbox, appPath, '../foo.git')).toString()
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'git':
+ p.toUri(p.absolute(d.sandbox, appPath, '../foo.git')).toString()
+ }
+ },
+ ).create();
await pubGet();
await d.dir(cachePath, [
d.dir('git', [
- d.dir('cache',
- [d.gitPackageRepoCacheDir('foo'), d.gitPackageRepoCacheDir('bar')]),
+ d.dir(
+ 'cache',
+ [d.gitPackageRepoCacheDir('foo'), d.gitPackageRepoCacheDir('bar')],
+ ),
d.gitPackageRevisionCacheDir('foo'),
d.gitPackageRevisionCacheDir('bar')
])
@@ -52,23 +63,33 @@
await d.git('foo.git', [
d.libDir('foo'),
- d.libPubspec('foo', '1.0.0', deps: {
- 'bar': {'git': '../bar.git'}
- })
+ d.libPubspec(
+ 'foo',
+ '1.0.0',
+ deps: {
+ 'bar': {'git': '../bar.git'}
+ },
+ )
]).create();
await d.git(
- 'bar.git', [d.libDir('bar'), d.libPubspec('bar', '1.0.0')]).create();
+ 'bar.git',
+ [d.libDir('bar'), d.libPubspec('bar', '1.0.0')],
+ ).create();
- await d.appDir({
- 'foo': {
- 'git': p.toUri(p.absolute(d.sandbox, appPath, '../foo.git')).toString()
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'git':
+ p.toUri(p.absolute(d.sandbox, appPath, '../foo.git')).toString()
+ }
+ },
+ ).create();
await pubGet(
error: contains(
- '"../bar.git" is a relative path, but this isn\'t a local pubspec.'),
+ '"../bar.git" is a relative path, but this isn\'t a local pubspec.',
+ ),
exitCode: exit_codes.DATA,
);
});
@@ -79,23 +100,31 @@
await d.git('foo.git', [
d.libDir('foo'),
- d.libPubspec('foo', '1.0.0', deps: {
- 'bar': {'path': '../bar'}
- })
+ d.libPubspec(
+ 'foo',
+ '1.0.0',
+ deps: {
+ 'bar': {'path': '../bar'}
+ },
+ )
]).create();
await d
.dir('bar', [d.libDir('bar'), d.libPubspec('bar', '1.0.0')]).create();
- await d.appDir({
- 'foo': {
- 'git': p.toUri(p.absolute(d.sandbox, appPath, '../foo.git')).toString()
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'git':
+ p.toUri(p.absolute(d.sandbox, appPath, '../foo.git')).toString()
+ }
+ },
+ ).create();
await pubGet(
error: contains(
- '"../bar" is a relative path, but this isn\'t a local pubspec.'),
+ '"../bar" is a relative path, but this isn\'t a local pubspec.',
+ ),
exitCode: exit_codes.DATA,
);
});
diff --git a/test/get/git/check_out_twice_test.dart b/test/get/git/check_out_twice_test.dart
index b6de388..4bcc945 100644
--- a/test/get/git/check_out_twice_test.dart
+++ b/test/get/git/check_out_twice_test.dart
@@ -12,11 +12,15 @@
ensureGit();
await d.git(
- 'foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
- await d.appDir({
- 'foo': {'git': '../foo.git'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'git': '../foo.git'}
+ },
+ ).create();
await pubGet();
diff --git a/test/get/git/check_out_unfetched_revision_of_cached_repo_test.dart b/test/get/git/check_out_unfetched_revision_of_cached_repo_test.dart
index dae234d..f18f5cd 100644
--- a/test/get/git/check_out_unfetched_revision_of_cached_repo_test.dart
+++ b/test/get/git/check_out_unfetched_revision_of_cached_repo_test.dart
@@ -20,11 +20,15 @@
// cache, we'll switch between two caches. First we ensure that the repo is
// in the first cache.
await d.git(
- 'foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
- await d.appDir({
- 'foo': {'git': '../foo.git'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'git': '../foo.git'}
+ },
+ ).create();
await pubGet();
@@ -34,8 +38,10 @@
renameInSandbox(cachePath, '$cachePath.old');
// Make the lockfile point to a new revision of the git repository.
- await d.git('foo.git',
- [d.libDir('foo', 'foo 2'), d.libPubspec('foo', '1.0.0')]).commit();
+ await d.git(
+ 'foo.git',
+ [d.libDir('foo', 'foo 2'), d.libPubspec('foo', '1.0.0')],
+ ).commit();
await pubUpgrade(output: contains('Changed 1 dependency!'));
diff --git a/test/get/git/check_out_with_trailing_slash_test.dart b/test/get/git/check_out_with_trailing_slash_test.dart
index 5838986..43f3d31 100644
--- a/test/get/git/check_out_with_trailing_slash_test.dart
+++ b/test/get/git/check_out_with_trailing_slash_test.dart
@@ -13,11 +13,15 @@
ensureGit();
await d.git(
- 'foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
- await d.appDir({
- 'foo': {'git': '../foo.git/'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'git': '../foo.git/'}
+ },
+ ).create();
await pubGet();
diff --git a/test/get/git/clean_invalid_git_repo_cache_test.dart b/test/get/git/clean_invalid_git_repo_cache_test.dart
index ab386ab..b91cd39 100644
--- a/test/get/git/clean_invalid_git_repo_cache_test.dart
+++ b/test/get/git/clean_invalid_git_repo_cache_test.dart
@@ -28,11 +28,15 @@
ensureGit();
await d.git(
- 'foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
- await d.appDir({
- 'foo': {'git': '../foo.git'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'git': '../foo.git'}
+ },
+ ).create();
await pubGet();
@@ -56,11 +60,13 @@
await repo.create();
await repo.runGit(['branch', 'old']);
- await d.appDir({
- 'foo': {
- 'git': {'url': '../foo.git', 'ref': 'old'}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'git': {'url': '../foo.git', 'ref': 'old'}
+ }
+ },
+ ).create();
await pubGet();
@@ -84,11 +90,13 @@
await repo.create();
var commit = await repo.revParse('HEAD');
- await d.appDir({
- 'foo': {
- 'git': {'url': '../foo.git', 'ref': commit}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'git': {'url': '../foo.git', 'ref': commit}
+ }
+ },
+ ).create();
await pubGet();
diff --git a/test/get/git/dependency_name_match_pubspec_test.dart b/test/get/git/dependency_name_match_pubspec_test.dart
index 1545fca..7d6fc57 100644
--- a/test/get/git/dependency_name_match_pubspec_test.dart
+++ b/test/get/git/dependency_name_match_pubspec_test.dart
@@ -15,17 +15,22 @@
ensureGit();
await d.git(
- 'foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
await d.dir(appPath, [
- d.appPubspec({
- 'weirdname': {'git': '../foo.git'}
- })
+ d.appPubspec(
+ dependencies: {
+ 'weirdname': {'git': '../foo.git'}
+ },
+ )
]).create();
await pubGet(
- error: contains('"name" field doesn\'t match expected name '
- '"weirdname".'),
- exitCode: exit_codes.DATA);
+ error: contains('"name" field doesn\'t match expected name '
+ '"weirdname".'),
+ exitCode: exit_codes.DATA,
+ );
});
}
diff --git a/test/get/git/different_repo_name_test.dart b/test/get/git/different_repo_name_test.dart
index 1d8f9c4..a2e0264 100644
--- a/test/get/git/different_repo_name_test.dart
+++ b/test/get/git/different_repo_name_test.dart
@@ -13,13 +13,17 @@
'pubspec', () async {
ensureGit();
- await d.git('foo.git',
- [d.libDir('weirdname'), d.libPubspec('weirdname', '1.0.0')]).create();
+ await d.git(
+ 'foo.git',
+ [d.libDir('weirdname'), d.libPubspec('weirdname', '1.0.0')],
+ ).create();
await d.dir(appPath, [
- d.appPubspec({
- 'weirdname': {'git': '../foo.git'}
- })
+ d.appPubspec(
+ dependencies: {
+ 'weirdname': {'git': '../foo.git'}
+ },
+ )
]).create();
await pubGet();
diff --git a/test/get/git/doesnt_fetch_if_nothing_changes_test.dart b/test/get/git/doesnt_fetch_if_nothing_changes_test.dart
index 3d9f040..4530198 100644
--- a/test/get/git/doesnt_fetch_if_nothing_changes_test.dart
+++ b/test/get/git/doesnt_fetch_if_nothing_changes_test.dart
@@ -14,13 +14,17 @@
ensureGit();
await d.git(
- 'foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
- await d.appDir({
- 'foo': {
- 'git': {'url': '../foo.git'}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'git': {'url': '../foo.git'}
+ }
+ },
+ ).create();
await pubGet();
diff --git a/test/get/git/git_not_installed_test.dart b/test/get/git/git_not_installed_test.dart
index e590770..d2f2363 100644
--- a/test/get/git/git_not_installed_test.dart
+++ b/test/get/git/git_not_installed_test.dart
@@ -12,16 +12,21 @@
void main() {
test('reports failure if Git is not installed', () async {
- await setUpFakeGitScript(bash: '''
+ await setUpFakeGitScript(
+ bash: '''
#!/bin/bash -e
echo "not git"
exit 1
-''', batch: '''
+''',
+ batch: '''
echo "not git"
-''');
- await d.appDir({
- 'foo': {'git': '../foo.git'}
- }).create();
+''',
+ );
+ await d.appDir(
+ dependencies: {
+ 'foo': {'git': '../foo.git'}
+ },
+ ).create();
await pubGet(
environment: extendedPathEnv(),
@@ -31,7 +36,8 @@
});
test('warns if git version is too old', () async {
- await setUpFakeGitScript(bash: '''
+ await setUpFakeGitScript(
+ bash: '''
#!/bin/bash -e
if [ "\$1" == "--version" ]
then
@@ -40,20 +46,24 @@
else
PATH=${Platform.environment['PATH']} git \$*
fi
-''', batch: '''
+''',
+ batch: '''
if "%1"=="--version" (
echo "git version 2.13.1.616"
) else (
set path="${Platform.environment['PATH']}"
git %*
)
-''');
+''',
+ );
await d.git('foo.git', [d.libPubspec('foo', '1.0.0')]).create();
- await d.appDir({
- 'foo': {'git': '../foo.git'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'git': '../foo.git'}
+ },
+ ).create();
await pubGet(
environment: extendedPathEnv(),
diff --git a/test/get/git/lock_version_test.dart b/test/get/git/lock_version_test.dart
index 40b2708..7185ed7 100644
--- a/test/get/git/lock_version_test.dart
+++ b/test/get/git/lock_version_test.dart
@@ -14,11 +14,15 @@
ensureGit();
await d.git(
- 'foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
- await d.appDir({
- 'foo': {'git': '../foo.git'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'git': '../foo.git'}
+ },
+ ).create();
// This get should lock the foo.git dependency to the current revision.
await pubGet();
@@ -37,8 +41,10 @@
// Delete the package spec to simulate a new checkout of the application.
deleteEntry(path.join(d.sandbox, packageConfigFilePath));
- await d.git('foo.git',
- [d.libDir('foo', 'foo 2'), d.libPubspec('foo', '1.0.0')]).commit();
+ await d.git(
+ 'foo.git',
+ [d.libDir('foo', 'foo 2'), d.libPubspec('foo', '1.0.0')],
+ ).commit();
// This get shouldn't upgrade the foo.git dependency due to the lockfile.
await pubGet();
diff --git a/test/get/git/locked_revision_without_repo_test.dart b/test/get/git/locked_revision_without_repo_test.dart
index c00c730..e18e752 100644
--- a/test/get/git/locked_revision_without_repo_test.dart
+++ b/test/get/git/locked_revision_without_repo_test.dart
@@ -16,11 +16,15 @@
ensureGit();
await d.git(
- 'foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
- await d.appDir({
- 'foo': {'git': '../foo.git'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'git': '../foo.git'}
+ },
+ ).create();
// This get should lock the foo.git dependency to the current revision.
await pubGet();
@@ -41,8 +45,10 @@
deleteEntry(path.join(d.sandbox, packageConfigFilePath));
deleteEntry(path.join(d.sandbox, cachePath));
- await d.git('foo.git',
- [d.libDir('foo', 'foo 2'), d.libPubspec('foo', '1.0.0')]).commit();
+ await d.git(
+ 'foo.git',
+ [d.libDir('foo', 'foo 2'), d.libPubspec('foo', '1.0.0')],
+ ).commit();
// This get shouldn't upgrade the foo.git dependency due to the lockfile.
await pubGet();
diff --git a/test/get/git/path_test.dart b/test/get/git/path_test.dart
index d9c9195..bb36dd9 100644
--- a/test/get/git/path_test.dart
+++ b/test/get/git/path_test.dart
@@ -22,11 +22,13 @@
]);
await repo.create();
- await d.appDir({
- 'sub': {
- 'git': {'url': '../foo.git', 'path': 'subdir'}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'sub': {
+ 'git': {'url': '../foo.git', 'path': 'subdir'}
+ }
+ },
+ ).create();
await pubGet();
@@ -41,8 +43,9 @@
await d.appPackageConfigFile([
d.packageConfigEntry(
- name: 'sub',
- path: pathInCache('git/foo-${await repo.revParse('HEAD')}/subdir')),
+ name: 'sub',
+ path: pathInCache('git/foo-${await repo.revParse('HEAD')}/subdir'),
+ ),
]).validate();
});
@@ -56,11 +59,13 @@
]);
await repo.create();
- await d.appDir({
- 'sub': {
- 'git': {'url': '../foo.git', 'path': 'sub/dir%25'}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'sub': {
+ 'git': {'url': '../foo.git', 'path': 'sub/dir%25'}
+ }
+ },
+ ).create();
await pubGet();
@@ -77,28 +82,33 @@
await d.appPackageConfigFile([
d.packageConfigEntry(
- name: 'sub',
- path:
- pathInCache('git/foo-${await repo.revParse('HEAD')}/sub/dir%25')),
+ name: 'sub',
+ path: pathInCache('git/foo-${await repo.revParse('HEAD')}/sub/dir%25'),
+ ),
]).validate();
final lockFile = LockFile.load(
- p.join(d.sandbox, appPath, 'pubspec.lock'), SystemCache().sources);
+ p.join(d.sandbox, appPath, 'pubspec.lock'),
+ SystemCache().sources,
+ );
expect(
- (lockFile.packages['sub']!.description.description as GitDescription)
- .path,
- 'sub/dir%25',
- reason: 'use uris to specify the path relative to the repo');
+ (lockFile.packages['sub']!.description.description as GitDescription)
+ .path,
+ 'sub/dir%25',
+ reason: 'use uris to specify the path relative to the repo',
+ );
});
group('requires path to be absolute', () {
test('absolute path', () async {
- await d.appDir({
- 'sub': {
- 'git': {'url': '../foo.git', 'path': '/subdir'}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'sub': {
+ 'git': {'url': '../foo.git', 'path': '/subdir'}
+ }
+ },
+ ).create();
await pubGet(
error: contains(
@@ -108,11 +118,13 @@
);
});
test('scheme', () async {
- await d.appDir({
- 'sub': {
- 'git': {'url': '../foo.git', 'path': 'https://subdir'}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'sub': {
+ 'git': {'url': '../foo.git', 'path': 'https://subdir'}
+ }
+ },
+ ).create();
await pubGet(
error: contains(
@@ -122,11 +134,13 @@
);
});
test('fragment', () async {
- await d.appDir({
- 'sub': {
- 'git': {'url': '../foo.git', 'path': 'subdir/dir#fragment'}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'sub': {
+ 'git': {'url': '../foo.git', 'path': 'subdir/dir#fragment'}
+ }
+ },
+ ).create();
await pubGet(
error: contains(
@@ -137,11 +151,13 @@
});
test('query', () async {
- await d.appDir({
- 'sub': {
- 'git': {'url': '../foo.git', 'path': 'subdir/dir?query'}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'sub': {
+ 'git': {'url': '../foo.git', 'path': 'subdir/dir?query'}
+ }
+ },
+ ).create();
await pubGet(
error: contains(
@@ -152,14 +168,16 @@
});
test('authority', () async {
- await d.appDir({
- 'sub': {
- 'git': {
- 'url': '../foo.git',
- 'path': 'bob:pwd@somewhere.example.com/subdir'
+ await d.appDir(
+ dependencies: {
+ 'sub': {
+ 'git': {
+ 'url': '../foo.git',
+ 'path': 'bob:pwd@somewhere.example.com/subdir'
+ }
}
- }
- }).create();
+ },
+ ).create();
await pubGet(
error: contains(
@@ -181,14 +199,16 @@
]);
await repo.create();
- await d.appDir({
- 'sub': {
- 'git': {
- 'url': p.toUri(p.join(d.sandbox, 'foo.git')).toString(),
- 'path': 'sub/dir%25'
+ await d.appDir(
+ dependencies: {
+ 'sub': {
+ 'git': {
+ 'url': p.toUri(p.join(d.sandbox, 'foo.git')).toString(),
+ 'path': 'sub/dir%25'
+ }
}
- }
- }).create();
+ },
+ ).create();
await pubGet();
@@ -205,40 +225,49 @@
await d.appPackageConfigFile([
d.packageConfigEntry(
- name: 'sub',
- path:
- pathInCache('git/foo-${await repo.revParse('HEAD')}/sub/dir%25')),
+ name: 'sub',
+ path: pathInCache('git/foo-${await repo.revParse('HEAD')}/sub/dir%25'),
+ ),
]).validate();
final lockFile = LockFile.load(
- p.join(d.sandbox, appPath, 'pubspec.lock'), SystemCache().sources);
+ p.join(d.sandbox, appPath, 'pubspec.lock'),
+ SystemCache().sources,
+ );
expect(
- (lockFile.packages['sub']!.description.description as GitDescription)
- .path,
- 'sub/dir%25',
- reason: 'use uris to specify the path relative to the repo');
+ (lockFile.packages['sub']!.description.description as GitDescription)
+ .path,
+ 'sub/dir%25',
+ reason: 'use uris to specify the path relative to the repo',
+ );
});
test('depends on multiple packages in subdirectories', () async {
ensureGit();
var repo = d.git('foo.git', [
- d.dir('subdir1',
- [d.libPubspec('sub1', '1.0.0'), d.libDir('sub1', '1.0.0')]),
d.dir(
- 'subdir2', [d.libPubspec('sub2', '1.0.0'), d.libDir('sub2', '1.0.0')])
+ 'subdir1',
+ [d.libPubspec('sub1', '1.0.0'), d.libDir('sub1', '1.0.0')],
+ ),
+ d.dir(
+ 'subdir2',
+ [d.libPubspec('sub2', '1.0.0'), d.libDir('sub2', '1.0.0')],
+ )
]);
await repo.create();
- await d.appDir({
- 'sub1': {
- 'git': {'url': '../foo.git', 'path': 'subdir1'}
+ await d.appDir(
+ dependencies: {
+ 'sub1': {
+ 'git': {'url': '../foo.git', 'path': 'subdir1'}
+ },
+ 'sub2': {
+ 'git': {'url': '../foo.git', 'path': 'subdir2'}
+ }
},
- 'sub2': {
- 'git': {'url': '../foo.git', 'path': 'subdir2'}
- }
- }).create();
+ ).create();
await pubGet();
@@ -254,11 +283,13 @@
await d.appPackageConfigFile([
d.packageConfigEntry(
- name: 'sub1',
- path: pathInCache('git/foo-${await repo.revParse('HEAD')}/subdir1')),
+ name: 'sub1',
+ path: pathInCache('git/foo-${await repo.revParse('HEAD')}/subdir1'),
+ ),
d.packageConfigEntry(
- name: 'sub2',
- path: pathInCache('git/foo-${await repo.revParse('HEAD')}/subdir2')),
+ name: 'sub2',
+ path: pathInCache('git/foo-${await repo.revParse('HEAD')}/subdir2'),
+ ),
]).validate();
});
@@ -268,7 +299,9 @@
var repo = d.git('foo.git', [
d.dir(
- 'subdir', [d.libPubspec('sub1', '1.0.0'), d.libDir('sub1', '1.0.0')])
+ 'subdir',
+ [d.libPubspec('sub1', '1.0.0'), d.libDir('sub1', '1.0.0')],
+ )
]);
await repo.create();
var oldRevision = await repo.revParse('HEAD');
@@ -277,18 +310,22 @@
await d.git('foo.git', [
d.dir(
- 'subdir', [d.libPubspec('sub2', '1.0.0'), d.libDir('sub2', '1.0.0')])
+ 'subdir',
+ [d.libPubspec('sub2', '1.0.0'), d.libDir('sub2', '1.0.0')],
+ )
]).commit();
var newRevision = await repo.revParse('HEAD');
- await d.appDir({
- 'sub1': {
- 'git': {'url': '../foo.git', 'path': 'subdir', 'ref': oldRevision}
+ await d.appDir(
+ dependencies: {
+ 'sub1': {
+ 'git': {'url': '../foo.git', 'path': 'subdir', 'ref': oldRevision}
+ },
+ 'sub2': {
+ 'git': {'url': '../foo.git', 'path': 'subdir'}
+ }
},
- 'sub2': {
- 'git': {'url': '../foo.git', 'path': 'subdir'}
- }
- }).create();
+ ).create();
await pubGet();
@@ -306,9 +343,13 @@
await d.appPackageConfigFile([
d.packageConfigEntry(
- name: 'sub1', path: pathInCache('git/foo-$oldRevision/subdir')),
+ name: 'sub1',
+ path: pathInCache('git/foo-$oldRevision/subdir'),
+ ),
d.packageConfigEntry(
- name: 'sub2', path: pathInCache('git/foo-$newRevision/subdir')),
+ name: 'sub2',
+ path: pathInCache('git/foo-$newRevision/subdir'),
+ ),
]).validate();
});
}
diff --git a/test/get/git/require_pubspec_name_test.dart b/test/get/git/require_pubspec_name_test.dart
index adc31e4..1ae543f 100644
--- a/test/get/git/require_pubspec_name_test.dart
+++ b/test/get/git/require_pubspec_name_test.dart
@@ -16,12 +16,15 @@
await d.git('foo.git', [d.libDir('foo'), d.pubspec({})]).create();
- await d.appDir({
- 'foo': {'git': '../foo.git'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'git': '../foo.git'}
+ },
+ ).create();
await pubGet(
- error: contains('Missing the required "name" field.'),
- exitCode: exit_codes.DATA);
+ error: contains('Missing the required "name" field.'),
+ exitCode: exit_codes.DATA,
+ );
});
}
diff --git a/test/get/git/require_pubspec_test.dart b/test/get/git/require_pubspec_test.dart
index 0f75c75..e4d2a7c 100644
--- a/test/get/git/require_pubspec_test.dart
+++ b/test/get/git/require_pubspec_test.dart
@@ -13,12 +13,15 @@
await d.git('foo.git', [d.libDir('foo')]).create();
- await d.appDir({
- 'foo': {'git': '../foo.git'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'git': '../foo.git'}
+ },
+ ).create();
await pubGet(
- error: RegExp(r'Could not find a file named "pubspec\.yaml" '
- r'in [^\n]\.'));
+ error: RegExp(r'Could not find a file named "pubspec\.yaml" '
+ r'in [^\n]\.'),
+ );
});
}
diff --git a/test/get/git/ssh_url_test.dart b/test/get/git/ssh_url_test.dart
index e38f895..9832024 100644
--- a/test/get/git/ssh_url_test.dart
+++ b/test/get/git/ssh_url_test.dart
@@ -24,8 +24,10 @@
path: 'abc/',
containingDir: null,
);
- expect(description.format(),
- 'git@github.com:dart-lang/pub.git at main in abc/');
+ expect(
+ description.format(),
+ 'git@github.com:dart-lang/pub.git at main in abc/',
+ );
expect(
description.serializeForPubspec(
containingDir: null,
@@ -38,7 +40,9 @@
},
);
final resolvedDescription = GitResolvedDescription(
- description, '7d48f902b0326fc2ce0615c20f1aab6c811fe55b');
+ description,
+ '7d48f902b0326fc2ce0615c20f1aab6c811fe55b',
+ );
expect(
resolvedDescription.format(),
diff --git a/test/get/git/stay_locked_if_compatible_test.dart b/test/get/git/stay_locked_if_compatible_test.dart
index d7f6eb9..bc2adb0 100644
--- a/test/get/git/stay_locked_if_compatible_test.dart
+++ b/test/get/git/stay_locked_if_compatible_test.dart
@@ -13,23 +13,31 @@
'constraint', () async {
ensureGit();
- await d.git('foo.git',
- [d.libDir('foo', 'foo 1.0.0'), d.libPubspec('foo', '1.0.0')]).create();
+ await d.git(
+ 'foo.git',
+ [d.libDir('foo', 'foo 1.0.0'), d.libPubspec('foo', '1.0.0')],
+ ).create();
- await d.appDir({
- 'foo': {'git': '../foo.git'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'git': '../foo.git'}
+ },
+ ).create();
await pubGet();
var originalFooSpec = packageSpec('foo');
- await d.git('foo.git',
- [d.libDir('foo', 'foo 1.0.1'), d.libPubspec('foo', '1.0.1')]).commit();
+ await d.git(
+ 'foo.git',
+ [d.libDir('foo', 'foo 1.0.1'), d.libPubspec('foo', '1.0.1')],
+ ).commit();
- await d.appDir({
- 'foo': {'git': '../foo.git', 'version': '>=1.0.0'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'git': '../foo.git', 'version': '>=1.0.0'}
+ },
+ ).create();
await pubGet();
diff --git a/test/get/git/unlock_if_incompatible_test.dart b/test/get/git/unlock_if_incompatible_test.dart
index 61b60e6..4ef9ecb 100644
--- a/test/get/git/unlock_if_incompatible_test.dart
+++ b/test/get/git/unlock_if_incompatible_test.dart
@@ -14,11 +14,15 @@
ensureGit();
await d.git(
- 'foo.git', [d.libDir('foo'), d.libPubspec('foo', '0.5.0')]).create();
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '0.5.0')],
+ ).create();
- await d.appDir({
- 'foo': {'git': '../foo.git'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'git': '../foo.git'}
+ },
+ ).create();
await pubGet();
@@ -33,12 +37,16 @@
var originalFooSpec = packageSpec('foo');
- await d.git('foo.git',
- [d.libDir('foo', 'foo 2'), d.libPubspec('foo', '1.0.0')]).commit();
+ await d.git(
+ 'foo.git',
+ [d.libDir('foo', 'foo 2'), d.libPubspec('foo', '1.0.0')],
+ ).commit();
- await d.appDir({
- 'foo': {'git': '../foo.git', 'version': '>=1.0.0'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'git': '../foo.git', 'version': '>=1.0.0'}
+ },
+ ).create();
await pubGet();
diff --git a/test/get/hosted/avoid_network_requests_test.dart b/test/get/hosted/avoid_network_requests_test.dart
index c62fa7c..58d4a09 100644
--- a/test/get/hosted/avoid_network_requests_test.dart
+++ b/test/get/hosted/avoid_network_requests_test.dart
@@ -17,7 +17,7 @@
..serve('bar', '1.1.0')
..serve('bar', '1.2.0');
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
// Get once so it gets cached.
await pubGet();
@@ -27,7 +27,7 @@
globalServer.requestedPaths.clear();
// Add "bar" to the dependencies.
- await d.appDir({'foo': 'any', 'bar': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any', 'bar': 'any'}).create();
// Run the solver again.
await pubGet();
@@ -39,12 +39,13 @@
// The get should not have done any network requests since the lock file is
// up to date.
expect(
- globalServer.requestedPaths,
- unorderedEquals([
- // Bar should be requested because it's new, but not foo.
- 'api/packages/bar',
- // Need to download it.
- 'packages/bar/versions/1.2.0.tar.gz'
- ]));
+ globalServer.requestedPaths,
+ unorderedEquals([
+ // Bar should be requested because it's new, but not foo.
+ 'api/packages/bar',
+ // Need to download it.
+ 'packages/bar/versions/1.2.0.tar.gz'
+ ]),
+ );
});
}
diff --git a/test/get/hosted/cached_pubspec_test.dart b/test/get/hosted/cached_pubspec_test.dart
index fa9decc..9f5a091 100644
--- a/test/get/hosted/cached_pubspec_test.dart
+++ b/test/get/hosted/cached_pubspec_test.dart
@@ -12,7 +12,7 @@
final server = await servePackages();
server.serve('foo', '1.2.3');
- await d.appDir({'foo': '1.2.3'}).create();
+ await d.appDir(dependencies: {'foo': '1.2.3'}).create();
// Get once so it gets cached.
await pubGet();
@@ -30,7 +30,9 @@
await pubGet();
// The get should not have requested the pubspec since it's local already.
- expect(server.requestedPaths,
- isNot(contains('packages/foo/versions/1.2.3.yaml')));
+ expect(
+ server.requestedPaths,
+ isNot(contains('packages/foo/versions/1.2.3.yaml')),
+ );
});
}
diff --git a/test/get/hosted/do_not_upgrade_on_removed_constraints_test.dart b/test/get/hosted/do_not_upgrade_on_removed_constraints_test.dart
index 44fe075..09f7b78 100644
--- a/test/get/hosted/do_not_upgrade_on_removed_constraints_test.dart
+++ b/test/get/hosted/do_not_upgrade_on_removed_constraints_test.dart
@@ -17,7 +17,7 @@
..serve('shared_dep', '1.0.0')
..serve('shared_dep', '2.0.0');
- await d.appDir({'foo': 'any', 'bar': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any', 'bar': 'any'}).create();
await pubGet();
@@ -27,7 +27,7 @@
d.packageConfigEntry(name: 'shared_dep', version: '1.0.0'),
]).validate();
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await pubGet();
diff --git a/test/get/hosted/does_no_network_requests_when_possible_test.dart b/test/get/hosted/does_no_network_requests_when_possible_test.dart
index 4324776..0739f19 100644
--- a/test/get/hosted/does_no_network_requests_when_possible_test.dart
+++ b/test/get/hosted/does_no_network_requests_when_possible_test.dart
@@ -14,7 +14,7 @@
..serve('foo', '1.1.0')
..serve('foo', '1.2.0');
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
// Get once so it gets cached.
await pubGet();
diff --git a/test/get/hosted/explain_bad_hosted_url_test.dart b/test/get/hosted/explain_bad_hosted_url_test.dart
index feebf67..fb44e52 100644
--- a/test/get/hosted/explain_bad_hosted_url_test.dart
+++ b/test/get/hosted/explain_bad_hosted_url_test.dart
@@ -9,7 +9,7 @@
void main() {
test('Complains nicely about invalid PUB_HOSTED_URL', () async {
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
// Get once so it gets cached.
await pubGet(
@@ -34,7 +34,7 @@
test('Allows PUB_HOSTED_URL to end with a slash', () async {
final server = await servePackages();
server.serve('foo', '1.0.0');
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await pubGet(
environment: {'PUB_HOSTED_URL': '${globalServer.url}/'},
diff --git a/test/get/hosted/get_stress_test.dart b/test/get/hosted/get_stress_test.dart
index 026c0c1..108c540 100644
--- a/test/get/hosted/get_stress_test.dart
+++ b/test/get/hosted/get_stress_test.dart
@@ -15,10 +15,12 @@
server.serve('pkg$i', '1.$i.0');
}
- await d.appDir({
- 'foo': '1.2.3',
- for (var i = 0; i < 20; i++) 'pkg$i': '^1.$i.0',
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': '1.2.3',
+ for (var i = 0; i < 20; i++) 'pkg$i': '^1.$i.0',
+ },
+ ).create();
await pubGet();
diff --git a/test/get/hosted/get_test.dart b/test/get/hosted/get_test.dart
index 837fb32..73434be 100644
--- a/test/get/hosted/get_test.dart
+++ b/test/get/hosted/get_test.dart
@@ -19,7 +19,7 @@
expect(await server.peekArchiveChecksumHeader('foo', '1.2.3'), isNotNull);
- await d.appDir({'foo': '1.2.3'}).create();
+ await d.appDir(dependencies: {'foo': '1.2.3'}).create();
await pubGet();
@@ -36,18 +36,26 @@
server = await servePackages()
..serveChecksums = false
..serve('foo', '1.2.3')
- ..serve('bar', '1.2.3', headers: {
- 'x-goog-hash': ['']
- })
- ..serve('baz', '1.2.3', headers: {
- 'x-goog-hash': ['md5=loremipsum']
- });
+ ..serve(
+ 'bar',
+ '1.2.3',
+ headers: {
+ 'x-goog-hash': ['']
+ },
+ )
+ ..serve(
+ 'baz',
+ '1.2.3',
+ headers: {
+ 'x-goog-hash': ['md5=loremipsum']
+ },
+ );
});
test('because of omitted checksum header', () async {
expect(await server.peekArchiveChecksumHeader('foo', '1.2.3'), isNull);
- await d.appDir({'foo': '1.2.3'}).create();
+ await d.appDir(dependencies: {'foo': '1.2.3'}).create();
await pubGet();
@@ -60,7 +68,7 @@
test('because of empty checksum header', () async {
expect(await server.peekArchiveChecksumHeader('bar', '1.2.3'), '');
- await d.appDir({'bar': '1.2.3'}).create();
+ await d.appDir(dependencies: {'bar': '1.2.3'}).create();
await pubGet();
@@ -71,10 +79,12 @@
});
test('because of missing CRC32C in checksum header', () async {
- expect(await server.peekArchiveChecksumHeader('baz', '1.2.3'),
- 'md5=loremipsum');
+ expect(
+ await server.peekArchiveChecksumHeader('baz', '1.2.3'),
+ 'md5=loremipsum',
+ );
- await d.appDir({'baz': '1.2.3'}).create();
+ await d.appDir(dependencies: {'baz': '1.2.3'}).create();
await pubGet();
@@ -88,16 +98,17 @@
test('URL encodes the package name', () async {
await servePackages();
- await d.appDir({'bad name!': '1.2.3'}).create();
+ await d.appDir(dependencies: {'bad name!': '1.2.3'}).create();
await pubGet(
- error: allOf([
- contains(
- "Because myapp depends on bad name! any which doesn't exist (could "
- 'not find package bad name! at http://localhost:'),
- contains('), version solving failed.')
- ]),
- exitCode: exit_codes.UNAVAILABLE);
+ error: allOf([
+ contains(
+ "Because myapp depends on bad name! any which doesn't exist (could "
+ 'not find package bad name! at http://localhost:'),
+ contains('), version solving failed.')
+ ]),
+ exitCode: exit_codes.UNAVAILABLE,
+ );
});
test('gets a package from a non-default pub server', () async {
@@ -108,12 +119,14 @@
var server = await startPackageServer();
server.serve('foo', '1.2.3');
- await d.appDir({
- 'foo': {
- 'version': '1.2.3',
- 'hosted': {'name': 'foo', 'url': 'http://localhost:${server.port}'}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'version': '1.2.3',
+ 'hosted': {'name': 'foo', 'url': 'http://localhost:${server.port}'}
+ }
+ },
+ ).create();
await pubGet();
@@ -127,16 +140,22 @@
() async {
var server = await startPackageServer();
- server.serve('foo', '1.2.3', headers: {
- 'x-goog-hash': PackageServer.composeChecksumHeader(crc32c: 3381945770)
- });
+ server.serve(
+ 'foo',
+ '1.2.3',
+ headers: {
+ 'x-goog-hash': PackageServer.composeChecksumHeader(crc32c: 3381945770)
+ },
+ );
- await d.appDir({
- 'foo': {
- 'version': '1.2.3',
- 'hosted': {'name': 'foo', 'url': 'http://localhost:${server.port}'}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'version': '1.2.3',
+ 'hosted': {'name': 'foo', 'url': 'http://localhost:${server.port}'}
+ }
+ },
+ ).create();
await pubGet(
exitCode: exit_codes.TEMP_FAIL,
@@ -156,24 +175,38 @@
setUp(() async {
server = await servePackages()
- ..serve('foo', '1.2.3', headers: {
- 'x-goog-hash': ['crc32c=,md5=']
- })
- ..serve('bar', '1.2.3', headers: {
- 'x-goog-hash': ['crc32c=loremipsum,md5=loremipsum']
- })
- ..serve('baz', '1.2.3', headers: {
- 'x-goog-hash': ['crc32c=MTIzNDU=,md5=NTQzMjE=']
- });
+ ..serve(
+ 'foo',
+ '1.2.3',
+ headers: {
+ 'x-goog-hash': ['crc32c=,md5=']
+ },
+ )
+ ..serve(
+ 'bar',
+ '1.2.3',
+ headers: {
+ 'x-goog-hash': ['crc32c=loremipsum,md5=loremipsum']
+ },
+ )
+ ..serve(
+ 'baz',
+ '1.2.3',
+ headers: {
+ 'x-goog-hash': ['crc32c=MTIzNDU=,md5=NTQzMjE=']
+ },
+ );
});
test('when the CRC32C checksum is empty', () async {
- await d.appDir({
- 'foo': {
- 'version': '1.2.3',
- 'hosted': {'name': 'foo', 'url': 'http://localhost:${server.port}'}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'version': '1.2.3',
+ 'hosted': {'name': 'foo', 'url': 'http://localhost:${server.port}'}
+ }
+ },
+ ).create();
await pubGet(
exitCode: exit_codes.TEMP_FAIL,
@@ -188,12 +221,14 @@
});
test('when the CRC32C checksum has bad encoding', () async {
- await d.appDir({
- 'bar': {
- 'version': '1.2.3',
- 'hosted': {'name': 'bar', 'url': 'http://localhost:${server.port}'}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'bar': {
+ 'version': '1.2.3',
+ 'hosted': {'name': 'bar', 'url': 'http://localhost:${server.port}'}
+ }
+ },
+ ).create();
await pubGet(
exitCode: exit_codes.TEMP_FAIL,
@@ -208,12 +243,14 @@
});
test('when the CRC32C checksum is malformed', () async {
- await d.appDir({
- 'baz': {
- 'version': '1.2.3',
- 'hosted': {'name': 'baz', 'url': 'http://localhost:${server.port}'}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'baz': {
+ 'version': '1.2.3',
+ 'hosted': {'name': 'baz', 'url': 'http://localhost:${server.port}'}
+ }
+ },
+ ).create();
await pubGet(
exitCode: exit_codes.TEMP_FAIL,
@@ -237,7 +274,7 @@
expect(await server.peekArchiveChecksumHeader('foo', '1.2.3'), isNull);
- await d.appDir({'foo': '1.2.3'}).create();
+ await d.appDir(dependencies: {'foo': '1.2.3'}).create();
await pubGet();
@@ -256,7 +293,7 @@
expect(await server.peekArchiveChecksumHeader('foo', '1.2.3'), isNotNull);
- await d.appDir({'foo': '1.2.3'}).create();
+ await d.appDir(dependencies: {'foo': '1.2.3'}).create();
await pubGet();
@@ -290,19 +327,32 @@
await pubGet();
var packages = loadYaml(
- readTextFile(p.join(d.sandbox, appPath, 'pubspec.lock')))['packages'];
- expect(packages,
- containsPair('foo', containsPair('dependency', 'direct main')));
- expect(packages,
- containsPair('bar', containsPair('dependency', 'transitive')));
- expect(packages,
- containsPair('baz', containsPair('dependency', 'direct dev')));
- expect(packages,
- containsPair('qux', containsPair('dependency', 'transitive')));
- expect(packages,
- containsPair('zip', containsPair('dependency', 'direct overridden')));
- expect(packages,
- containsPair('zap', containsPair('dependency', 'transitive')));
+ readTextFile(p.join(d.sandbox, appPath, 'pubspec.lock')),
+ )['packages'];
+ expect(
+ packages,
+ containsPair('foo', containsPair('dependency', 'direct main')),
+ );
+ expect(
+ packages,
+ containsPair('bar', containsPair('dependency', 'transitive')),
+ );
+ expect(
+ packages,
+ containsPair('baz', containsPair('dependency', 'direct dev')),
+ );
+ expect(
+ packages,
+ containsPair('qux', containsPair('dependency', 'transitive')),
+ );
+ expect(
+ packages,
+ containsPair('zip', containsPair('dependency', 'direct overridden')),
+ );
+ expect(
+ packages,
+ containsPair('zap', containsPair('dependency', 'transitive')),
+ );
});
test('for overridden main and dev dependencies', () async {
@@ -318,15 +368,24 @@
await pubGet();
var packages = loadYaml(
- readTextFile(p.join(d.sandbox, appPath, 'pubspec.lock')))['packages'];
- expect(packages,
- containsPair('foo', containsPair('dependency', 'direct main')));
- expect(packages,
- containsPair('bar', containsPair('dependency', 'transitive')));
- expect(packages,
- containsPair('baz', containsPair('dependency', 'direct dev')));
- expect(packages,
- containsPair('qux', containsPair('dependency', 'transitive')));
+ readTextFile(p.join(d.sandbox, appPath, 'pubspec.lock')),
+ )['packages'];
+ expect(
+ packages,
+ containsPair('foo', containsPair('dependency', 'direct main')),
+ );
+ expect(
+ packages,
+ containsPair('bar', containsPair('dependency', 'transitive')),
+ );
+ expect(
+ packages,
+ containsPair('baz', containsPair('dependency', 'direct dev')),
+ );
+ expect(
+ packages,
+ containsPair('qux', containsPair('dependency', 'transitive')),
+ );
});
});
}
diff --git a/test/get/hosted/get_transitive_test.dart b/test/get/hosted/get_transitive_test.dart
index 0ae18ac..0e51e83 100644
--- a/test/get/hosted/get_transitive_test.dart
+++ b/test/get/hosted/get_transitive_test.dart
@@ -15,7 +15,7 @@
..serve('bar', '2.0.4')
..serve('bar', '2.0.5');
- await d.appDir({'foo': '1.2.3'}).create();
+ await d.appDir(dependencies: {'foo': '1.2.3'}).create();
await pubGet();
diff --git a/test/get/hosted/gets_a_package_with_busted_dev_dependencies_test.dart b/test/get/hosted/gets_a_package_with_busted_dev_dependencies_test.dart
index 585cfba..9916bab 100644
--- a/test/get/hosted/gets_a_package_with_busted_dev_dependencies_test.dart
+++ b/test/get/hosted/gets_a_package_with_busted_dev_dependencies_test.dart
@@ -13,13 +13,17 @@
'gets a dependency with broken dev dependencies from a pub '
'server', () async {
final server = await servePackages();
- server.serve('foo', '1.2.3', pubspec: {
- 'dev_dependencies': {
- 'busted': {'not a real source': null}
- }
- });
+ server.serve(
+ 'foo',
+ '1.2.3',
+ pubspec: {
+ 'dev_dependencies': {
+ 'busted': {'not a real source': null}
+ }
+ },
+ );
- await d.appDir({'foo': '1.2.3'}).create();
+ await d.appDir(dependencies: {'foo': '1.2.3'}).create();
await pubGet();
diff --git a/test/get/hosted/resolve_constraints_test.dart b/test/get/hosted/resolve_constraints_test.dart
index 466902e..6eed388 100644
--- a/test/get/hosted/resolve_constraints_test.dart
+++ b/test/get/hosted/resolve_constraints_test.dart
@@ -16,7 +16,7 @@
..serve('baz', '2.0.4')
..serve('baz', '3.0.1');
- await d.appDir({'foo': 'any', 'bar': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any', 'bar': 'any'}).create();
await pubGet();
diff --git a/test/get/hosted/resolve_with_retracted_package_versions_test.dart b/test/get/hosted/resolve_with_retracted_package_versions_test.dart
index d9b33a4..9e1e227 100644
--- a/test/get/hosted/resolve_with_retracted_package_versions_test.dart
+++ b/test/get/hosted/resolve_with_retracted_package_versions_test.dart
@@ -17,7 +17,7 @@
..serve('foo', '1.0.0', deps: {'bar': '^1.0.0'})
..serve('bar', '1.0.0')
..serve('bar', '1.1.0');
- await d.appDir({'foo': '1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '1.0.0'}).create();
server.retractPackageVersion('bar', '1.1.0');
await pubGet();
@@ -33,13 +33,14 @@
final server = await servePackages()
..serve('foo', '1.0.0', deps: {'bar': '^1.0.0'})
..serve('bar', '1.0.0');
- await d.appDir({'foo': '1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '1.0.0'}).create();
server.retractPackageVersion('bar', '1.0.0');
await pubGet(
- error:
- '''Because every version of foo depends on bar ^1.0.0 which doesn't match any versions, foo is forbidden.
- So, because myapp depends on foo 1.0.0, version solving failed.''');
+ error:
+ '''Because every version of foo depends on bar ^1.0.0 which doesn't match any versions, foo is forbidden.
+ So, because myapp depends on foo 1.0.0, version solving failed.''',
+ );
});
// Currently retraction does not affect prioritization. I.e., if
@@ -52,7 +53,7 @@
..serve('foo', '1.0.0', deps: {'bar': '^1.0.0'})
..serve('bar', '1.0.0')
..serve('bar', '1.1.0');
- await d.appDir({'foo': '1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '1.0.0'}).create();
await pubGet();
await d.cacheDir({'foo': '1.0.0', 'bar': '1.1.0'}).validate();
@@ -89,10 +90,13 @@
test('Offline versions of pub commands also handle retracted packages',
() async {
final server = await servePackages();
- await populateCache({
- 'foo': ['1.0.0'],
- 'bar': ['1.0.0', '1.1.0']
- }, server);
+ await populateCache(
+ {
+ 'foo': ['1.0.0'],
+ 'bar': ['1.0.0', '1.1.0']
+ },
+ server,
+ );
await d.cacheDir({
'foo': '1.0.0',
@@ -112,7 +116,7 @@
// Now serve only errors - to validate we are truly offline.
server.serveErrors();
- await d.appDir({'foo': '1.0.0', 'bar': '^1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '1.0.0', 'bar': '^1.0.0'}).create();
await pubUpgrade(args: ['--offline']);
@@ -163,7 +167,7 @@
..serve('foo', '2.0.0')
..serve('foo', '3.0.0');
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await pubGet();
server.retractPackageVersion('foo', '2.0.0');
diff --git a/test/get/hosted/stay_locked_if_compatible_test.dart b/test/get/hosted/stay_locked_if_compatible_test.dart
index df04579..4adc728 100644
--- a/test/get/hosted/stay_locked_if_compatible_test.dart
+++ b/test/get/hosted/stay_locked_if_compatible_test.dart
@@ -14,7 +14,7 @@
final server = await servePackages();
server.serve('foo', '1.0.0');
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await pubGet();
await d.appPackageConfigFile([
@@ -23,7 +23,7 @@
server.serve('foo', '1.0.1');
- await d.appDir({'foo': '>=1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '>=1.0.0'}).create();
await pubGet();
diff --git a/test/get/hosted/stay_locked_if_new_is_satisfied_test.dart b/test/get/hosted/stay_locked_if_new_is_satisfied_test.dart
index c75c435..cb431f0 100644
--- a/test/get/hosted/stay_locked_if_new_is_satisfied_test.dart
+++ b/test/get/hosted/stay_locked_if_new_is_satisfied_test.dart
@@ -16,7 +16,7 @@
server.serve('bar', '1.0.0', deps: {'baz': '<2.0.0'});
server.serve('baz', '1.0.0');
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await pubGet();
await d.appPackageConfigFile([
@@ -30,7 +30,7 @@
server.serve('baz', '2.0.0');
server.serve('newdep', '2.0.0', deps: {'baz': '>=1.0.0'});
- await d.appDir({'foo': 'any', 'newdep': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any', 'newdep': 'any'}).create();
await pubGet();
diff --git a/test/get/hosted/stay_locked_test.dart b/test/get/hosted/stay_locked_test.dart
index 8b819ea..223e06d 100644
--- a/test/get/hosted/stay_locked_test.dart
+++ b/test/get/hosted/stay_locked_test.dart
@@ -16,7 +16,7 @@
final server = await servePackages();
server.serve('foo', '1.0.0');
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
// This should lock the foo dependency to version 1.0.0.
await pubGet();
diff --git a/test/get/hosted/unlock_if_incompatible_test.dart b/test/get/hosted/unlock_if_incompatible_test.dart
index 007231e..a560ea7 100644
--- a/test/get/hosted/unlock_if_incompatible_test.dart
+++ b/test/get/hosted/unlock_if_incompatible_test.dart
@@ -14,7 +14,7 @@
final server = await servePackages();
server.serve('foo', '1.0.0');
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await pubGet();
@@ -22,7 +22,7 @@
d.packageConfigEntry(name: 'foo', version: '1.0.0'),
]).validate();
server.serve('foo', '1.0.1');
- await d.appDir({'foo': '>1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '>1.0.0'}).create();
await pubGet();
diff --git a/test/get/hosted/unlock_if_new_is_unsatisfied_test.dart b/test/get/hosted/unlock_if_new_is_unsatisfied_test.dart
index ae6a4e6..ce46e2b 100644
--- a/test/get/hosted/unlock_if_new_is_unsatisfied_test.dart
+++ b/test/get/hosted/unlock_if_new_is_unsatisfied_test.dart
@@ -18,7 +18,7 @@
server.serve('baz', '1.0.0', deps: {'qux': '<2.0.0'});
server.serve('qux', '1.0.0');
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await pubGet();
@@ -35,7 +35,7 @@
server.serve('qux', '2.0.0');
server.serve('newdep', '2.0.0', deps: {'baz': '>=1.5.0'});
- await d.appDir({'foo': 'any', 'newdep': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any', 'newdep': 'any'}).create();
await pubGet();
diff --git a/test/get/hosted/unlock_if_version_doesnt_exist_test.dart b/test/get/hosted/unlock_if_version_doesnt_exist_test.dart
index e4cc01b..cdb4229 100644
--- a/test/get/hosted/unlock_if_version_doesnt_exist_test.dart
+++ b/test/get/hosted/unlock_if_version_doesnt_exist_test.dart
@@ -15,7 +15,7 @@
final server = await servePackages();
server.serve('foo', '1.0.0');
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await pubGet();
await d.appPackageConfigFile([
d.packageConfigEntry(name: 'foo', version: '1.0.0'),
diff --git a/test/get/hosted/warn_about_discontinued_test.dart b/test/get/hosted/warn_about_discontinued_test.dart
index 7057f9b..6dfc2fa 100644
--- a/test/get/hosted/warn_about_discontinued_test.dart
+++ b/test/get/hosted/warn_about_discontinued_test.dart
@@ -17,7 +17,7 @@
final server = await servePackages();
server.serve('foo', '1.2.3', deps: {'transitive': 'any'});
server.serve('transitive', '1.0.0');
- await d.appDir({'foo': '1.2.3'}).create();
+ await d.appDir(dependencies: {'foo': '1.2.3'}).create();
await pubGet();
server
@@ -35,11 +35,13 @@
deleteEntry(fooVersionsCache);
deleteEntry(transitiveVersionsCache);
// We warn only about the direct dependency here:
- await pubGet(output: '''
+ await pubGet(
+ output: '''
Resolving dependencies...
foo 1.2.3 (discontinued)
Got dependencies!
-''');
+''',
+ );
expect(fileExists(fooVersionsCache), isTrue);
final c = json.decode(readTextFile(fooVersionsCache));
// Make the cache artificially old.
@@ -49,36 +51,48 @@
server.discontinue('foo', replacementText: 'bar');
- await pubGet(output: '''
+ await pubGet(
+ output: '''
Resolving dependencies...
foo 1.2.3 (discontinued replaced by bar)
-Got dependencies!''');
+Got dependencies!''',
+ );
final c2 = json.decode(readTextFile(fooVersionsCache));
// Make a bad cached value to test that responses are actually from cache.
c2['isDiscontinued'] = false;
writeTextFile(fooVersionsCache, json.encode(c2));
- await pubGet(output: '''
+ await pubGet(
+ output: '''
Resolving dependencies...
-Got dependencies!''');
+Got dependencies!''',
+ );
// Repairing the cache should reset the package listing caches.
await runPub(args: ['cache', 'repair']);
- await pubGet(output: '''
+ await pubGet(
+ output: '''
Resolving dependencies...
foo 1.2.3 (discontinued replaced by bar)
-Got dependencies!''');
+Got dependencies!''',
+ );
// Test that --offline won't try to access the server for retrieving the
// status.
server.serveErrors();
- await pubGet(args: ['--offline'], output: '''
+ await pubGet(
+ args: ['--offline'],
+ output: '''
Resolving dependencies...
foo 1.2.3 (discontinued replaced by bar)
-Got dependencies!''');
+Got dependencies!''',
+ );
deleteEntry(fooVersionsCache);
deleteEntry(transitiveVersionsCache);
- await pubGet(args: ['--offline'], output: '''
+ await pubGet(
+ args: ['--offline'],
+ output: '''
Resolving dependencies...
Got dependencies!
-''');
+''',
+ );
});
test('Warns about discontinued dev dependencies', () async {
@@ -95,7 +109,7 @@
dev_dependencies:
foo: 1.2.3
environment:
- sdk: '>=0.1.2 <1.0.0'
+ sdk: '$defaultSdkConstraint'
''')
]).create();
await pubGet();
@@ -111,11 +125,13 @@
expect(fileExists(fooVersionsCache), isTrue);
deleteEntry(fooVersionsCache);
// We warn only about the direct dependency here:
- await pubGet(output: '''
+ await pubGet(
+ output: '''
Resolving dependencies...
foo 1.2.3 (discontinued)
Got dependencies!
-''');
+''',
+ );
expect(fileExists(fooVersionsCache), isTrue);
final c = json.decode(readTextFile(fooVersionsCache));
// Make the cache artificially old.
@@ -123,49 +139,63 @@
DateTime.now().subtract(Duration(days: 5)).toIso8601String();
writeTextFile(fooVersionsCache, json.encode(c));
builder.discontinue('foo', replacementText: 'bar');
- await pubGet(output: '''
+ await pubGet(
+ output: '''
Resolving dependencies...
foo 1.2.3 (discontinued replaced by bar)
-Got dependencies!''');
+Got dependencies!''',
+ );
final c2 = json.decode(readTextFile(fooVersionsCache));
// Make a bad cached value to test that responses are actually from cache.
c2['isDiscontinued'] = false;
writeTextFile(fooVersionsCache, json.encode(c2));
- await pubGet(output: '''
+ await pubGet(
+ output: '''
Resolving dependencies...
-Got dependencies!''');
+Got dependencies!''',
+ );
// Repairing the cache should reset the package listing caches.
await runPub(args: ['cache', 'repair']);
- await pubGet(output: '''
+ await pubGet(
+ output: '''
Resolving dependencies...
foo 1.2.3 (discontinued replaced by bar)
-Got dependencies!''');
+Got dependencies!''',
+ );
// Test that --offline won't try to access the server for retrieving the
// status.
builder.serveErrors();
- await pubGet(args: ['--offline'], output: '''
+ await pubGet(
+ args: ['--offline'],
+ output: '''
Resolving dependencies...
foo 1.2.3 (discontinued replaced by bar)
-Got dependencies!''');
+Got dependencies!''',
+ );
deleteEntry(fooVersionsCache);
- await pubGet(args: ['--offline'], output: '''
+ await pubGet(
+ args: ['--offline'],
+ output: '''
Resolving dependencies...
Got dependencies!
-''');
+''',
+ );
});
test('get does not fail when status listing fails', () async {
final server = await servePackages();
server.serve('foo', '1.2.3');
- await d.appDir({'foo': '1.2.3'}).create();
+ await d.appDir(dependencies: {'foo': '1.2.3'}).create();
await pubGet();
final fooVersionsCache =
p.join(globalServer.cachingPath, '.cache', 'foo-versions.json');
expect(fileExists(fooVersionsCache), isTrue);
deleteEntry(fooVersionsCache);
// Serve 400 on all requests.
- globalServer.handle(RegExp('.*'),
- (shelf.Request request) => shelf.Response.notFound('Not found'));
+ globalServer.handle(
+ RegExp('.*'),
+ (shelf.Request request) => shelf.Response.notFound('Not found'),
+ );
/// Even if we fail to get status we still report success if versions don't unlock.
await pubGet();
diff --git a/test/get/hosted/warn_about_retracted_package_test.dart b/test/get/hosted/warn_about_retracted_package_test.dart
index 2336c7f..ba9b47d 100644
--- a/test/get/hosted/warn_about_retracted_package_test.dart
+++ b/test/get/hosted/warn_about_retracted_package_test.dart
@@ -14,7 +14,7 @@
final server = await servePackages()
..serve('foo', '1.0.0', deps: {'bar': 'any'})
..serve('bar', '1.0.0');
- await d.appDir({'foo': '1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '1.0.0'}).create();
await pubGet();
@@ -33,7 +33,7 @@
..serve('bar', '1.0.0')
..serve('bar', '2.0.0')
..serve('bar', '2.0.1-pre');
- await d.appDir({'foo': '1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '1.0.0'}).create();
await pubGet();
@@ -52,7 +52,7 @@
..serve('foo', '1.0.0', deps: {'bar': '^1.0.0-pre'})
..serve('bar', '1.0.0-pre')
..serve('bar', '2.0.1-pre');
- await d.appDir({'foo': '1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '1.0.0'}).create();
await pubGet();
@@ -63,6 +63,7 @@
expect(fileExists(barVersionsCache), isTrue);
deleteEntry(barVersionsCache);
await pubGet(
- output: contains('bar 1.0.0-pre (retracted, 2.0.1-pre available)'));
+ output: contains('bar 1.0.0-pre (retracted, 2.0.1-pre available)'),
+ );
});
}
diff --git a/test/get/package_name_test.dart b/test/get/package_name_test.dart
index b1328cc..194324e 100644
--- a/test/get/package_name_test.dart
+++ b/test/get/package_name_test.dart
@@ -15,8 +15,9 @@
]).create();
await pubGet(
- error: contains('"name" field must be a valid Dart identifier.'),
- exitCode: exit_codes.DATA);
+ error: contains('"name" field must be a valid Dart identifier.'),
+ exitCode: exit_codes.DATA,
+ );
await d.dir(appPath, [
// The lockfile should not be created.
@@ -34,8 +35,9 @@
]).create();
await pubGet(
- error: contains('"name" field may not be a Dart reserved word.'),
- exitCode: exit_codes.DATA);
+ error: contains('"name" field may not be a Dart reserved word.'),
+ exitCode: exit_codes.DATA,
+ );
await d.dir(appPath, [
// The lockfile should not be created.
@@ -57,7 +59,8 @@
await d.dir(appPath, [
d.packageConfigFile(
- [d.packageConfigEntry(name: 'foo.bar.baz', path: '.')])
+ [d.packageConfigEntry(name: 'foo.bar.baz', path: '.')],
+ )
]).validate();
});
}
diff --git a/test/get/path/absolute_path_test.dart b/test/get/path/absolute_path_test.dart
index e1897e9..1fa9ddb 100644
--- a/test/get/path/absolute_path_test.dart
+++ b/test/get/path/absolute_path_test.dart
@@ -14,9 +14,11 @@
.dir('foo', [d.libDir('foo'), d.libPubspec('foo', '0.0.1')]).create();
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': path.join(d.sandbox, 'foo')}
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': path.join(d.sandbox, 'foo')}
+ },
+ )
]).create();
await pubGet();
diff --git a/test/get/path/absolute_symlink_test.dart b/test/get/path/absolute_symlink_test.dart
index 83d3433..c0680b7 100644
--- a/test/get/path/absolute_symlink_test.dart
+++ b/test/get/path/absolute_symlink_test.dart
@@ -17,9 +17,11 @@
var fooPath = d.path('foo');
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': fooPath}
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': fooPath}
+ },
+ )
]).create();
await pubGet();
diff --git a/test/get/path/empty_pubspec_test.dart b/test/get/path/empty_pubspec_test.dart
index 0f9843f..9ff471d 100644
--- a/test/get/path/empty_pubspec_test.dart
+++ b/test/get/path/empty_pubspec_test.dart
@@ -15,15 +15,18 @@
await d.dir('foo', [d.libDir('foo'), d.file('pubspec.yaml', '')]).create();
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': '../foo'}
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': '../foo'}
+ },
+ )
]).create();
await pubGet(
- exitCode: exit_codes.DATA,
- error:
- 'Error on line 1, column 1 of ${p.join('..', 'foo', 'pubspec.yaml')}: '
- 'Missing the required "name" field.');
+ exitCode: exit_codes.DATA,
+ error:
+ 'Error on line 1, column 1 of ${p.join('..', 'foo', 'pubspec.yaml')}: '
+ 'Missing the required "name" field.',
+ );
});
}
diff --git a/test/get/path/no_pubspec_test.dart b/test/get/path/no_pubspec_test.dart
index d328f25..769f67b 100644
--- a/test/get/path/no_pubspec_test.dart
+++ b/test/get/path/no_pubspec_test.dart
@@ -16,14 +16,17 @@
var fooPath = path.join(d.sandbox, 'foo');
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': fooPath}
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': fooPath}
+ },
+ )
]).create();
await pubGet(
- error: RegExp(r'Could not find a file named "pubspec.yaml" '
- r'in "[^\n]*"\.'),
- exitCode: exit_codes.NO_INPUT);
+ error: RegExp(r'Could not find a file named "pubspec.yaml" '
+ r'in "[^\n]*"\.'),
+ exitCode: exit_codes.NO_INPUT,
+ );
});
}
diff --git a/test/get/path/nonexistent_dir_test.dart b/test/get/path/nonexistent_dir_test.dart
index 7616087..c17d421 100644
--- a/test/get/path/nonexistent_dir_test.dart
+++ b/test/get/path/nonexistent_dir_test.dart
@@ -14,17 +14,20 @@
var badPath = path.join(d.sandbox, 'bad_path');
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': badPath}
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': badPath}
+ },
+ )
]).create();
await pubGet(
- error: allOf([
- contains("Because myapp depends on foo from path which doesn't exist "
- '(could not find package foo at'),
- contains('bad_path"), version solving failed.')
- ]),
- exitCode: exit_codes.NO_INPUT);
+ error: allOf([
+ contains("Because myapp depends on foo from path which doesn't exist "
+ '(could not find package foo at'),
+ contains('bad_path"), version solving failed.')
+ ]),
+ exitCode: exit_codes.NO_INPUT,
+ );
});
}
diff --git a/test/get/path/path_is_file_test.dart b/test/get/path/path_is_file_test.dart
index 6fafd82..579caae 100644
--- a/test/get/path/path_is_file_test.dart
+++ b/test/get/path/path_is_file_test.dart
@@ -17,13 +17,16 @@
var dummyPath = path.join(d.sandbox, 'dummy.txt');
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': dummyPath}
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': dummyPath}
+ },
+ )
]).create();
await pubGet(
- error: 'Path dependency for package foo must refer to a '
- 'directory, not a file. Was "$dummyPath".');
+ error: 'Path dependency for package foo must refer to a '
+ 'directory, not a file. Was "$dummyPath".',
+ );
});
}
diff --git a/test/get/path/relative_path_test.dart b/test/get/path/relative_path_test.dart
index 3a7fb8f..2ffe3bc 100644
--- a/test/get/path/relative_path_test.dart
+++ b/test/get/path/relative_path_test.dart
@@ -20,9 +20,11 @@
.dir('foo', [d.libDir('foo'), d.libPubspec('foo', '0.0.1')]).create();
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': '../foo'}
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': '../foo'}
+ },
+ )
]).create();
await pubGet();
@@ -36,17 +38,23 @@
await d.dir('relative', [
d.dir('foo', [
d.libDir('foo'),
- d.libPubspec('foo', '0.0.1', deps: {
- 'bar': {'path': '../bar'}
- })
+ d.libPubspec(
+ 'foo',
+ '0.0.1',
+ deps: {
+ 'bar': {'path': '../bar'}
+ },
+ )
]),
d.dir('bar', [d.libDir('bar'), d.libPubspec('bar', '0.0.1')])
]).create();
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': '../relative/foo'}
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': '../relative/foo'}
+ },
+ )
]).create();
await pubGet();
@@ -62,23 +70,30 @@
await d.dir('relative', [
d.dir('foo', [
d.libDir('foo'),
- d.libPubspec('foo', '0.0.1', deps: {
- 'bar': {'path': '../bar'}
- })
+ d.libPubspec(
+ 'foo',
+ '0.0.1',
+ deps: {
+ 'bar': {'path': '../bar'}
+ },
+ )
]),
d.dir('bar', [d.libDir('bar'), d.libPubspec('bar', '0.0.1')])
]).create();
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': '../relative/foo'}
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': '../relative/foo'}
+ },
+ )
]).create();
await pubGet(
- args: ['--directory', appPath],
- workingDirectory: d.sandbox,
- output: contains('Changed 2 dependencies in myapp!'));
+ args: ['--directory', appPath],
+ workingDirectory: d.sandbox,
+ output: contains('Changed 2 dependencies in myapp!'),
+ );
await d.appPackageConfigFile([
d.packageConfigEntry(name: 'foo', path: '../relative/foo'),
@@ -91,9 +106,11 @@
.dir('foo', [d.libDir('foo'), d.libPubspec('foo', '0.0.1')]).create();
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': '../foo'}
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': '../foo'}
+ },
+ )
]).create();
await pubGet();
diff --git a/test/get/path/relative_symlink_test.dart b/test/get/path/relative_symlink_test.dart
index 9136a34..e9ec91e 100644
--- a/test/get/path/relative_symlink_test.dart
+++ b/test/get/path/relative_symlink_test.dart
@@ -21,9 +21,11 @@
.dir('foo', [d.libDir('foo'), d.libPubspec('foo', '0.0.1')]).create();
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': '../foo'}
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': '../foo'}
+ },
+ )
]).create();
await pubGet();
diff --git a/test/get/path/shared_dependency_symlink_test.dart b/test/get/path/shared_dependency_symlink_test.dart
index d450838..9a61bf9 100644
--- a/test/get/path/shared_dependency_symlink_test.dart
+++ b/test/get/path/shared_dependency_symlink_test.dart
@@ -11,28 +11,40 @@
void main() {
test('shared dependency with symlink', () async {
- await d.dir('shared',
- [d.libDir('shared'), d.libPubspec('shared', '0.0.1')]).create();
+ await d.dir(
+ 'shared',
+ [d.libDir('shared'), d.libPubspec('shared', '0.0.1')],
+ ).create();
await d.dir('foo', [
d.libDir('foo'),
- d.libPubspec('foo', '0.0.1', deps: {
- 'shared': {'path': '../shared'}
- })
+ d.libPubspec(
+ 'foo',
+ '0.0.1',
+ deps: {
+ 'shared': {'path': '../shared'}
+ },
+ )
]).create();
await d.dir('bar', [
d.libDir('bar'),
- d.libPubspec('bar', '0.0.1', deps: {
- 'shared': {'path': '../link/shared'}
- })
+ d.libPubspec(
+ 'bar',
+ '0.0.1',
+ deps: {
+ 'shared': {'path': '../link/shared'}
+ },
+ )
]).create();
await d.dir(appPath, [
- d.appPubspec({
- 'bar': {'path': '../bar'},
- 'foo': {'path': '../foo'},
- })
+ d.appPubspec(
+ dependencies: {
+ 'bar': {'path': '../bar'},
+ 'foo': {'path': '../foo'},
+ },
+ )
]).create();
await d.dir('link').create();
diff --git a/test/get/path/shared_dependency_test.dart b/test/get/path/shared_dependency_test.dart
index 3ef91ae..016f092 100644
--- a/test/get/path/shared_dependency_test.dart
+++ b/test/get/path/shared_dependency_test.dart
@@ -9,28 +9,40 @@
void main() {
test('shared dependency with same path', () async {
- await d.dir('shared',
- [d.libDir('shared'), d.libPubspec('shared', '0.0.1')]).create();
+ await d.dir(
+ 'shared',
+ [d.libDir('shared'), d.libPubspec('shared', '0.0.1')],
+ ).create();
await d.dir('foo', [
d.libDir('foo'),
- d.libPubspec('foo', '0.0.1', deps: {
- 'shared': {'path': '../shared'}
- })
+ d.libPubspec(
+ 'foo',
+ '0.0.1',
+ deps: {
+ 'shared': {'path': '../shared'}
+ },
+ )
]).create();
await d.dir('bar', [
d.libDir('bar'),
- d.libPubspec('bar', '0.0.1', deps: {
- 'shared': {'path': '../shared'}
- })
+ d.libPubspec(
+ 'bar',
+ '0.0.1',
+ deps: {
+ 'shared': {'path': '../shared'}
+ },
+ )
]).create();
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': '../foo'},
- 'bar': {'path': '../bar'}
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': '../foo'},
+ 'bar': {'path': '../bar'}
+ },
+ )
]).create();
await pubGet();
@@ -43,28 +55,40 @@
});
test('shared dependency with paths that normalize the same', () async {
- await d.dir('shared',
- [d.libDir('shared'), d.libPubspec('shared', '0.0.1')]).create();
+ await d.dir(
+ 'shared',
+ [d.libDir('shared'), d.libPubspec('shared', '0.0.1')],
+ ).create();
await d.dir('foo', [
d.libDir('foo'),
- d.libPubspec('foo', '0.0.1', deps: {
- 'shared': {'path': '../shared'}
- })
+ d.libPubspec(
+ 'foo',
+ '0.0.1',
+ deps: {
+ 'shared': {'path': '../shared'}
+ },
+ )
]).create();
await d.dir('bar', [
d.libDir('bar'),
- d.libPubspec('bar', '0.0.1', deps: {
- 'shared': {'path': '../././shared'}
- })
+ d.libPubspec(
+ 'bar',
+ '0.0.1',
+ deps: {
+ 'shared': {'path': '../././shared'}
+ },
+ )
]).create();
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': '../foo'},
- 'bar': {'path': '../bar'}
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': '../foo'},
+ 'bar': {'path': '../bar'}
+ },
+ )
]).create();
await pubGet();
diff --git a/test/get/preserve_lock_file_line_endings_test.dart b/test/get/preserve_lock_file_line_endings_test.dart
index 4484fc5..bc6e4e8 100644
--- a/test/get/preserve_lock_file_line_endings_test.dart
+++ b/test/get/preserve_lock_file_line_endings_test.dart
@@ -17,8 +17,10 @@
await pubGet();
await d
- .file(path.join(appPath, 'pubspec.lock'),
- allOf(contains('\n'), isNot(contains('\r\n'))))
+ .file(
+ path.join(appPath, 'pubspec.lock'),
+ allOf(contains('\n'), isNot(contains('\r\n'))),
+ )
.validate();
});
@@ -29,7 +31,8 @@
final lockFile = d.file(path.join(appPath, 'pubspec.lock')).io;
lockFile.writeAsStringSync(
- lockFile.readAsStringSync().replaceAll('\n', '\r\n'));
+ lockFile.readAsStringSync().replaceAll('\n', '\r\n'),
+ );
await d.dir(appPath, [d.file('pubspec.lock', contains('\r\n'))]).validate();
await pubGet();
@@ -52,7 +55,8 @@
expect(detectWindowsLineEndings('\r\n'), true);
expect(detectWindowsLineEndings('abcd\r\nefg\n'), false);
expect(detectWindowsLineEndings('abcd\r\nefg\nhij\r\n'), true);
- expect(detectWindowsLineEndings('''
+ expect(
+ detectWindowsLineEndings('''
packages:\r
bar:\r
dependency: transitive\r
@@ -60,8 +64,11 @@
source: fake\r
version: "1.2.3"\r
sdks: {}\r
-'''), true);
- expect(detectWindowsLineEndings('''
+'''),
+ true,
+ );
+ expect(
+ detectWindowsLineEndings('''
packages:
bar:
dependency: transitive
@@ -69,6 +76,8 @@
source: fake
version: "1.2.3"
sdks: {}
-'''), false);
+'''),
+ false,
+ );
});
}
diff --git a/test/get/sdk_constraint_required_test.dart b/test/get/sdk_constraint_required_test.dart
index e7a1b56..992abcc 100644
--- a/test/get/sdk_constraint_required_test.dart
+++ b/test/get/sdk_constraint_required_test.dart
@@ -17,12 +17,13 @@
]).create();
await pubGet(
- error: allOf(
- contains('pubspec.yaml has no lower-bound SDK constraint.'),
- contains("sdk: '^2.12.0'"),
- ),
- exitCode: exit_codes.DATA,
- environment: {'_PUB_TEST_SDK_VERSION': '2.19.0'});
+ error: allOf(
+ contains('pubspec.yaml has no lower-bound SDK constraint.'),
+ contains("sdk: '^2.19.0'"),
+ ),
+ exitCode: exit_codes.DATA,
+ environment: {'_PUB_TEST_SDK_VERSION': '2.19.1'},
+ );
await d.dir(appPath, [
// The lockfile should not be created.
diff --git a/test/get/summary_only_environment_test.dart b/test/get/summary_only_environment_test.dart
new file mode 100644
index 0000000..a4adb50
--- /dev/null
+++ b/test/get/summary_only_environment_test.dart
@@ -0,0 +1,21 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:test/test.dart';
+
+import '../descriptor.dart' as d;
+import '../test_pub.dart';
+
+void main() {
+ test('pub get with PUB_SUMMARY_ONLY will only print a summary', () async {
+ (await servePackages()).serve('foo', '1.0.0');
+ await d.appDir(dependencies: {'foo': 'any'}).create();
+
+ await pubGet(
+ output: 'Resolving dependencies...\nGot dependencies.',
+ silent: contains('+ foo 1.0.0'),
+ environment: {'PUB_SUMMARY_ONLY': '1'},
+ );
+ });
+}
diff --git a/test/get/switch_source_test.dart b/test/get/switch_source_test.dart
index 7e56652..08bf686 100644
--- a/test/get/switch_source_test.dart
+++ b/test/get/switch_source_test.dart
@@ -12,19 +12,23 @@
final server = await servePackages();
server.serve('foo', '1.2.3');
- await d.dir('foo',
- [d.libDir('foo', 'foo 0.0.1'), d.libPubspec('foo', '0.0.1')]).create();
+ await d.dir(
+ 'foo',
+ [d.libDir('foo', 'foo 0.0.1'), d.libPubspec('foo', '0.0.1')],
+ ).create();
- await d.appDir({
- 'foo': {'path': '../foo'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'path': '../foo'}
+ },
+ ).create();
await pubGet();
await d.appPackageConfigFile([
d.packageConfigEntry(name: 'foo', path: '../foo'),
]).validate();
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await pubGet();
diff --git a/test/get/unknown_sdk_test.dart b/test/get/unknown_sdk_test.dart
index d0c1de3..8d61a2c 100644
--- a/test/get/unknown_sdk_test.dart
+++ b/test/get/unknown_sdk_test.dart
@@ -18,7 +18,8 @@
await pubGet(
error: contains(
- "Error on line 1, column 40 of pubspec.yaml: pubspec.yaml refers to an unknown sdk 'foo'."),
+ "Error on line 1, column 32 of pubspec.yaml: pubspec.yaml refers to an unknown sdk 'foo'.",
+ ),
exitCode: exit_codes.DATA,
);
});
diff --git a/test/get/with_empty_environment_test.dart b/test/get/with_empty_environment_test.dart
index 5dab9b3..28c5b02 100644
--- a/test/get/with_empty_environment_test.dart
+++ b/test/get/with_empty_environment_test.dart
@@ -12,10 +12,13 @@
final server = await servePackages();
server.serve('foo', '1.2.3');
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
- await pubGet(environment: {
- '_PUB_TEST_CONFIG_DIR': null,
- }, includeParentHomeAndPath: false);
+ await pubGet(
+ environment: {
+ '_PUB_TEST_CONFIG_DIR': null,
+ },
+ includeParentHomeAndPath: false,
+ );
});
}
diff --git a/test/global/activate/activate_git_after_hosted_test.dart b/test/global/activate/activate_git_after_hosted_test.dart
index 99f2fcb..dbb7be4 100644
--- a/test/global/activate/activate_git_after_hosted_test.dart
+++ b/test/global/activate/activate_git_after_hosted_test.dart
@@ -13,9 +13,13 @@
ensureGit();
final server = await servePackages();
- server.serve('foo', '1.0.0', contents: [
- d.dir('bin', [d.file('foo.dart', "main(args) => print('hosted');")])
- ]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ contents: [
+ d.dir('bin', [d.file('foo.dart', "main(args) => print('hosted');")])
+ ],
+ );
await d.git('foo.git', [
d.libPubspec('foo', '1.0.0'),
@@ -25,15 +29,17 @@
await runPub(args: ['global', 'activate', 'foo']);
await runPub(
- args: ['global', 'activate', '-sgit', '../foo.git'],
- output: allOf(
- startsWith('Package foo is currently active at version 1.0.0.\n'
- 'Resolving dependencies...\n'
- '* foo 1.0.0 from git ..${separator}foo.git at '),
- // Specific revision number goes here.
- endsWith('Building package executables...\n'
- 'Built foo:foo.\n'
- 'Activated foo 1.0.0 from Git repository "..${separator}foo.git".')));
+ args: ['global', 'activate', '-sgit', '../foo.git'],
+ output: allOf(
+ startsWith('Package foo is currently active at version 1.0.0.\n'
+ 'Resolving dependencies...\n'
+ '* foo 1.0.0 from git ..${separator}foo.git at '),
+ // Specific revision number goes here.
+ endsWith('Building package executables...\n'
+ 'Built foo:foo.\n'
+ 'Activated foo 1.0.0 from Git repository "..${separator}foo.git".'),
+ ),
+ );
// Should now run the git one.
var pub = await pubRun(global: true, args: ['foo']);
diff --git a/test/global/activate/activate_hosted_after_git_test.dart b/test/global/activate/activate_hosted_after_git_test.dart
index 15819ca..83b3c06 100644
--- a/test/global/activate/activate_hosted_after_git_test.dart
+++ b/test/global/activate/activate_hosted_after_git_test.dart
@@ -11,9 +11,13 @@
void main() {
test('activating a hosted package deactivates the Git one', () async {
final server = await servePackages();
- server.serve('foo', '2.0.0', contents: [
- d.dir('bin', [d.file('foo.dart', "main(args) => print('hosted');")])
- ]);
+ server.serve(
+ 'foo',
+ '2.0.0',
+ contents: [
+ d.dir('bin', [d.file('foo.dart', "main(args) => print('hosted');")])
+ ],
+ );
await d.git('foo.git', [
d.libPubspec('foo', '1.0.0'),
@@ -23,13 +27,15 @@
await runPub(args: ['global', 'activate', '-sgit', '../foo.git']);
await runPub(
- args: ['global', 'activate', 'foo'],
- output: allOf([
- contains(
- 'Package foo is currently active from Git repository "..${separator}foo.git".'),
- contains('* foo 2.0.0 (was 1.0.0 from git ..${separator}foo.git at'),
- contains('Activated foo 2.0.0.')
- ]));
+ args: ['global', 'activate', 'foo'],
+ output: allOf([
+ contains(
+ 'Package foo is currently active from Git repository "..${separator}foo.git".',
+ ),
+ contains('* foo 2.0.0 (was 1.0.0 from git ..${separator}foo.git at'),
+ contains('Activated foo 2.0.0.')
+ ]),
+ );
// Should now run the hosted one.
var pub = await pubRun(global: true, args: ['foo']);
diff --git a/test/global/activate/activate_hosted_after_path_test.dart b/test/global/activate/activate_hosted_after_path_test.dart
index 8f91a1f..68ac256 100644
--- a/test/global/activate/activate_hosted_after_path_test.dart
+++ b/test/global/activate/activate_hosted_after_path_test.dart
@@ -12,9 +12,13 @@
void main() {
test('activating a hosted package deactivates the path one', () async {
final server = await servePackages();
- server.serve('foo', '2.0.0', contents: [
- d.dir('bin', [d.file('foo.dart', "main(args) => print('hosted');")])
- ]);
+ server.serve(
+ 'foo',
+ '2.0.0',
+ contents: [
+ d.dir('bin', [d.file('foo.dart', "main(args) => print('hosted');")])
+ ],
+ );
await d.dir('foo', [
d.libPubspec('foo', '1.0.0'),
@@ -24,13 +28,16 @@
await runPub(args: ['global', 'activate', '-spath', '../foo']);
var path = canonicalize(p.join(d.sandbox, 'foo'));
- await runPub(args: ['global', 'activate', 'foo'], output: '''
+ await runPub(
+ args: ['global', 'activate', 'foo'],
+ output: '''
Package foo is currently active at path "$path".
Resolving dependencies...
* foo 2.0.0 (was 1.0.0 from path $path)
Building package executables...
Built foo:foo.
- Activated foo 2.0.0.''');
+ Activated foo 2.0.0.''',
+ );
// Should now run the hosted one.
var pub = await pubRun(global: true, args: ['foo']);
diff --git a/test/global/activate/activate_hosted_twice_test.dart b/test/global/activate/activate_hosted_twice_test.dart
index fb4ce92..5c56b95 100644
--- a/test/global/activate/activate_hosted_twice_test.dart
+++ b/test/global/activate/activate_hosted_twice_test.dart
@@ -11,27 +11,37 @@
test('activating a hosted package twice will not precompile', () async {
final server = await servePackages();
server
- ..serve('foo', '1.0.0', deps: {
- 'bar': 'any'
- }, contents: [
- d.dir('bin', [
- d.file('foo.dart', r'''
+ ..serve(
+ 'foo',
+ '1.0.0',
+ deps: {'bar': 'any'},
+ contents: [
+ d.dir('bin', [
+ d.file('foo.dart', r'''
import 'package:bar/bar.dart';
main(args) => print('bar $version');''')
- ])
- ])
- ..serve('bar', '1.0.0', contents: [
- d.dir('lib', [d.file('bar.dart', 'final version = "1.0.0";')])
- ]);
+ ])
+ ],
+ )
+ ..serve(
+ 'bar',
+ '1.0.0',
+ contents: [
+ d.dir('lib', [d.file('bar.dart', 'final version = "1.0.0";')])
+ ],
+ );
await runPub(args: ['global', 'activate', 'foo'], output: anything);
- await runPub(args: ['global', 'activate', 'foo'], output: '''
+ await runPub(
+ args: ['global', 'activate', 'foo'],
+ output: '''
Package foo is currently active at version 1.0.0.
Resolving dependencies...
The package foo is already activated at newest available version.
To recompile executables, first run `dart pub global deactivate foo`.
-Activated foo 1.0.0.''');
+Activated foo 1.0.0.''',
+ );
var pub = await pubRun(global: true, args: ['foo']);
expect(pub.stdout, emits('bar 1.0.0'));
@@ -39,17 +49,24 @@
await runPub(args: ['global', 'activate', 'foo']);
- server.serve('bar', '2.0.0', contents: [
- d.dir('lib', [d.file('bar.dart', 'final version = "2.0.0";')])
- ]);
+ server.serve(
+ 'bar',
+ '2.0.0',
+ contents: [
+ d.dir('lib', [d.file('bar.dart', 'final version = "2.0.0";')])
+ ],
+ );
- await runPub(args: ['global', 'activate', 'foo'], output: '''
+ await runPub(
+ args: ['global', 'activate', 'foo'],
+ output: '''
Package foo is currently active at version 1.0.0.
Resolving dependencies...
> bar 2.0.0 (was 1.0.0)
Building package executables...
Built foo:foo.
-Activated foo 1.0.0.''');
+Activated foo 1.0.0.''',
+ );
var pub2 = await pubRun(global: true, args: ['foo']);
expect(pub2.stdout, emits('bar 2.0.0'));
diff --git a/test/global/activate/activate_path_after_hosted_test.dart b/test/global/activate/activate_path_after_hosted_test.dart
index 01d493d..ccdb3da 100644
--- a/test/global/activate/activate_path_after_hosted_test.dart
+++ b/test/global/activate/activate_path_after_hosted_test.dart
@@ -12,9 +12,13 @@
void main() {
test('activating a path package deactivates the hosted one', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', contents: [
- d.dir('bin', [d.file('foo.dart', "main(args) => print('hosted');")])
- ]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ contents: [
+ d.dir('bin', [d.file('foo.dart', "main(args) => print('hosted');")])
+ ],
+ );
await d.dir('foo', [
d.libPubspec('foo', '2.0.0'),
@@ -25,11 +29,12 @@
var path = canonicalize(p.join(d.sandbox, 'foo'));
await runPub(
- args: ['global', 'activate', '-spath', '../foo'],
- output: allOf([
- contains('Package foo is currently active at version 1.0.0.'),
- contains('Activated foo 2.0.0 at path "$path".')
- ]));
+ args: ['global', 'activate', '-spath', '../foo'],
+ output: allOf([
+ contains('Package foo is currently active at version 1.0.0.'),
+ contains('Activated foo 2.0.0 at path "$path".')
+ ]),
+ );
// Should now run the path one.
var pub = await pubRun(global: true, args: ['foo']);
diff --git a/test/global/activate/bad_version_test.dart b/test/global/activate/bad_version_test.dart
index c5c4635..8bf921c 100644
--- a/test/global/activate/bad_version_test.dart
+++ b/test/global/activate/bad_version_test.dart
@@ -10,9 +10,9 @@
void main() {
test('fails if the version constraint cannot be parsed', () {
return runPub(
- args: ['global', 'activate', 'foo', '1.0'],
- error:
- contains('Could not parse version "1.0". Unknown text at "1.0".'),
- exitCode: exit_codes.USAGE);
+ args: ['global', 'activate', 'foo', '1.0'],
+ error: contains('Could not parse version "1.0". Unknown text at "1.0".'),
+ exitCode: exit_codes.USAGE,
+ );
});
}
diff --git a/test/global/activate/cached_package_test.dart b/test/global/activate/cached_package_test.dart
index 98db402..f558d09 100644
--- a/test/global/activate/cached_package_test.dart
+++ b/test/global/activate/cached_package_test.dart
@@ -10,18 +10,25 @@
void main() {
test('can activate an already cached package', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', contents: [
- d.dir('bin', [d.file('foo.dart', 'main() => print("hi"); ')])
- ]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ contents: [
+ d.dir('bin', [d.file('foo.dart', 'main() => print("hi"); ')])
+ ],
+ );
await runPub(args: ['cache', 'add', 'foo']);
- await runPub(args: ['global', 'activate', 'foo'], output: '''
+ await runPub(
+ args: ['global', 'activate', 'foo'],
+ output: '''
Resolving dependencies...
+ foo 1.0.0
Building package executables...
Built foo:foo.
- Activated foo 1.0.0.''');
+ Activated foo 1.0.0.''',
+ );
// Should be in global package cache.
await d.dir(cachePath, [
diff --git a/test/global/activate/constraint_with_path_test.dart b/test/global/activate/constraint_with_path_test.dart
index 359cd60..fe4795a 100644
--- a/test/global/activate/constraint_with_path_test.dart
+++ b/test/global/activate/constraint_with_path_test.dart
@@ -10,8 +10,9 @@
void main() {
test('fails if a version is passed with the path source', () {
return runPub(
- args: ['global', 'activate', '-spath', 'foo', '1.2.3'],
- error: contains('Unexpected argument "1.2.3".'),
- exitCode: exit_codes.USAGE);
+ args: ['global', 'activate', '-spath', 'foo', '1.2.3'],
+ error: contains('Unexpected argument "1.2.3".'),
+ exitCode: exit_codes.USAGE,
+ );
});
}
diff --git a/test/global/activate/different_version_test.dart b/test/global/activate/different_version_test.dart
index d84ed8c..fcabe8a 100644
--- a/test/global/activate/different_version_test.dart
+++ b/test/global/activate/different_version_test.dart
@@ -12,23 +12,34 @@
"discards the previous active version if it doesn't match the "
'constraint', () async {
await servePackages()
- ..serve('foo', '1.0.0', contents: [
- d.dir('bin', [d.file('foo.dart', 'main() => print("hi");')])
- ])
- ..serve('foo', '2.0.0', contents: [
- d.dir('bin', [d.file('foo.dart', 'main() => print("hi2");')])
- ]);
+ ..serve(
+ 'foo',
+ '1.0.0',
+ contents: [
+ d.dir('bin', [d.file('foo.dart', 'main() => print("hi");')])
+ ],
+ )
+ ..serve(
+ 'foo',
+ '2.0.0',
+ contents: [
+ d.dir('bin', [d.file('foo.dart', 'main() => print("hi2");')])
+ ],
+ );
// Activate 1.0.0.
await runPub(args: ['global', 'activate', 'foo', '1.0.0']);
// Activating it again with a different constraint changes the version.
- await runPub(args: ['global', 'activate', 'foo', '>1.0.0'], output: '''
+ await runPub(
+ args: ['global', 'activate', 'foo', '>1.0.0'],
+ output: '''
Package foo is currently active at version 1.0.0.
Resolving dependencies...
> foo 2.0.0 (was 1.0.0)
Building package executables...
Built foo:foo.
- Activated foo 2.0.0.''');
+ Activated foo 2.0.0.''',
+ );
});
}
diff --git a/test/global/activate/doesnt_snapshot_path_executables_test.dart b/test/global/activate/doesnt_snapshot_path_executables_test.dart
index 2ca8d3a..3ba3e65 100644
--- a/test/global/activate/doesnt_snapshot_path_executables_test.dart
+++ b/test/global/activate/doesnt_snapshot_path_executables_test.dart
@@ -15,13 +15,16 @@
]).create();
await runPub(
- args: ['global', 'activate', '-spath', '../foo'],
- output: isNot(contains('Built foo:hello.')));
+ args: ['global', 'activate', '-spath', '../foo'],
+ output: isNot(contains('Built foo:hello.')),
+ );
await d.dir(cachePath, [
d.dir('global_packages', [
- d.dir('foo',
- [d.file('pubspec.lock', contains('1.0.0')), d.nothing('bin')])
+ d.dir(
+ 'foo',
+ [d.file('pubspec.lock', contains('1.0.0')), d.nothing('bin')],
+ )
])
]).validate();
});
diff --git a/test/global/activate/empty_constraint_test.dart b/test/global/activate/empty_constraint_test.dart
index d893bcd..bdac786 100644
--- a/test/global/activate/empty_constraint_test.dart
+++ b/test/global/activate/empty_constraint_test.dart
@@ -14,11 +14,12 @@
..serve('foo', '1.0.1');
await runPub(
- args: ['global', 'activate', 'foo', '>1.1.0'],
- error: equalsIgnoringWhitespace("""
+ args: ['global', 'activate', 'foo', '>1.1.0'],
+ error: equalsIgnoringWhitespace("""
Because pub global activate depends on foo >1.1.0 which doesn't match
any versions, version solving failed.
"""),
- exitCode: exit_codes.DATA);
+ exitCode: exit_codes.DATA,
+ );
});
}
diff --git a/test/global/activate/feature_test.dart b/test/global/activate/feature_test.dart
index 58119d1..36d9aee 100644
--- a/test/global/activate/feature_test.dart
+++ b/test/global/activate/feature_test.dart
@@ -11,132 +11,161 @@
void main() {
test('enables default-on features by default', () async {
await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'features': {
- 'stuff': {
- 'dependencies': {'bar': '1.0.0'}
- },
- 'things': {
- 'default': false,
- 'dependencies': {'baz': '1.0.0'}
+ ..serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'dependencies': {'bar': '1.0.0'}
+ },
+ 'things': {
+ 'default': false,
+ 'dependencies': {'baz': '1.0.0'}
+ }
}
- }
- })
+ },
+ )
..serve('bar', '1.0.0')
..serve('baz', '1.0.0');
- await runPub(args: ['global', 'activate', 'foo'], output: contains('''
+ await runPub(
+ args: ['global', 'activate', 'foo'],
+ output: contains('''
Resolving dependencies...
+ bar 1.0.0
+ foo 1.0.0
-Downloading'''));
+Downloading'''),
+ );
});
test('can enable default-off features', () async {
await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'features': {
- 'stuff': {
- 'dependencies': {'bar': '1.0.0'}
- },
- 'things': {
- 'default': false,
- 'dependencies': {'baz': '1.0.0'}
+ ..serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'dependencies': {'bar': '1.0.0'}
+ },
+ 'things': {
+ 'default': false,
+ 'dependencies': {'baz': '1.0.0'}
+ }
}
- }
- })
+ },
+ )
..serve('bar', '1.0.0')
..serve('baz', '1.0.0');
await runPub(
- args: ['global', 'activate', 'foo', '--features', 'things'],
- output: contains('''
+ args: ['global', 'activate', 'foo', '--features', 'things'],
+ output: contains('''
Resolving dependencies...
+ bar 1.0.0
+ baz 1.0.0
+ foo 1.0.0
-Downloading'''));
+Downloading'''),
+ );
});
test('can disable default-on features', () async {
await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'features': {
- 'stuff': {
- 'dependencies': {'bar': '1.0.0'}
- },
- 'things': {
- 'default': false,
- 'dependencies': {'baz': '1.0.0'}
+ ..serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'dependencies': {'bar': '1.0.0'}
+ },
+ 'things': {
+ 'default': false,
+ 'dependencies': {'baz': '1.0.0'}
+ }
}
- }
- })
+ },
+ )
..serve('bar', '1.0.0')
..serve('baz', '1.0.0');
await runPub(
- args: ['global', 'activate', 'foo', '--omit-features', 'stuff'],
- output: contains('''
+ args: ['global', 'activate', 'foo', '--omit-features', 'stuff'],
+ output: contains('''
Resolving dependencies...
+ foo 1.0.0
-Downloading'''));
+Downloading'''),
+ );
});
test('supports multiple arguments', () async {
await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'features': {
- 'stuff': {
- 'default': false,
- 'dependencies': {'bar': '1.0.0'}
- },
- 'things': {
- 'default': false,
- 'dependencies': {'baz': '1.0.0'}
+ ..serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'default': false,
+ 'dependencies': {'bar': '1.0.0'}
+ },
+ 'things': {
+ 'default': false,
+ 'dependencies': {'baz': '1.0.0'}
+ }
}
- }
- })
+ },
+ )
..serve('bar', '1.0.0')
..serve('baz', '1.0.0');
await runPub(
- args: ['global', 'activate', 'foo', '--features', 'things,stuff'],
- output: contains('''
+ args: ['global', 'activate', 'foo', '--features', 'things,stuff'],
+ output: contains('''
Resolving dependencies...
+ bar 1.0.0
+ baz 1.0.0
+ foo 1.0.0
-Downloading'''));
+Downloading'''),
+ );
});
test('can both enable and disable', () async {
await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'features': {
- 'stuff': {
- 'dependencies': {'bar': '1.0.0'}
- },
- 'things': {
- 'default': false,
- 'dependencies': {'baz': '1.0.0'}
+ ..serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'dependencies': {'bar': '1.0.0'}
+ },
+ 'things': {
+ 'default': false,
+ 'dependencies': {'baz': '1.0.0'}
+ }
}
- }
- })
+ },
+ )
..serve('bar', '1.0.0')
..serve('baz', '1.0.0');
- await runPub(args: [
- 'global',
- 'activate',
- 'foo',
- '--features',
- 'things',
- '--omit-features',
- 'stuff'
- ], output: contains('''
+ await runPub(
+ args: [
+ 'global',
+ 'activate',
+ 'foo',
+ '--features',
+ 'things',
+ '--omit-features',
+ 'stuff'
+ ],
+ output: contains('''
Resolving dependencies...
+ baz 1.0.0
+ foo 1.0.0
-Downloading'''));
+Downloading'''),
+ );
});
}
diff --git a/test/global/activate/git_package_test.dart b/test/global/activate/git_package_test.dart
index 6b7215e..245819f 100644
--- a/test/global/activate/git_package_test.dart
+++ b/test/global/activate/git_package_test.dart
@@ -18,14 +18,16 @@
]).create();
await runPub(
- args: ['global', 'activate', '-sgit', '../foo.git'],
- output: allOf(
- startsWith('Resolving dependencies...\n'
- '+ foo 1.0.0 from git ..${p.separator}foo.git at '),
- // Specific revision number goes here.
- endsWith('Building package executables...\n'
- 'Built foo:foo.\n'
- 'Activated foo 1.0.0 from Git repository "..${p.separator}foo.git".')));
+ args: ['global', 'activate', '-sgit', '../foo.git'],
+ output: allOf(
+ startsWith('Resolving dependencies...\n'
+ '+ foo 1.0.0 from git ..${p.separator}foo.git at '),
+ // Specific revision number goes here.
+ endsWith('Building package executables...\n'
+ 'Built foo:foo.\n'
+ 'Activated foo 1.0.0 from Git repository "..${p.separator}foo.git".'),
+ ),
+ );
});
test('activates a package from a Git repo with path and ref', () async {
diff --git a/test/global/activate/ignores_active_version_test.dart b/test/global/activate/ignores_active_version_test.dart
index d3e6094..72d8888 100644
--- a/test/global/activate/ignores_active_version_test.dart
+++ b/test/global/activate/ignores_active_version_test.dart
@@ -14,20 +14,27 @@
'foo',
'1.2.3',
)
- ..serve('foo', '1.3.0', contents: [
- d.dir('bin', [d.file('foo.dart', 'main() => print("hi"); ')])
- ]);
+ ..serve(
+ 'foo',
+ '1.3.0',
+ contents: [
+ d.dir('bin', [d.file('foo.dart', 'main() => print("hi"); ')])
+ ],
+ );
// Activate 1.2.3.
await runPub(args: ['global', 'activate', 'foo', '1.2.3']);
// Activating it again resolves to the new best version.
- await runPub(args: ['global', 'activate', 'foo', '>1.0.0'], output: '''
+ await runPub(
+ args: ['global', 'activate', 'foo', '>1.0.0'],
+ output: '''
Package foo is currently active at version 1.2.3.
Resolving dependencies...
> foo 1.3.0 (was 1.2.3)
Building package executables...
Built foo:foo.
- Activated foo 1.3.0.''');
+ Activated foo 1.3.0.''',
+ );
});
}
diff --git a/test/global/activate/installs_dependencies_for_git_test.dart b/test/global/activate/installs_dependencies_for_git_test.dart
index 04bdc53..a778ec7 100644
--- a/test/global/activate/installs_dependencies_for_git_test.dart
+++ b/test/global/activate/installs_dependencies_for_git_test.dart
@@ -19,10 +19,11 @@
]).create();
await runPub(
- args: ['global', 'activate', '-sgit', '../foo.git'],
- silent: allOf([
- contains('Downloading bar 1.0.0...'),
- contains('Downloading baz 1.0.0...')
- ]));
+ args: ['global', 'activate', '-sgit', '../foo.git'],
+ silent: allOf([
+ contains('Downloading bar 1.0.0...'),
+ contains('Downloading baz 1.0.0...')
+ ]),
+ );
});
}
diff --git a/test/global/activate/installs_dependencies_for_path_test.dart b/test/global/activate/installs_dependencies_for_path_test.dart
index ae90242..4783bfd 100644
--- a/test/global/activate/installs_dependencies_for_path_test.dart
+++ b/test/global/activate/installs_dependencies_for_path_test.dart
@@ -26,13 +26,14 @@
// Puts the lockfile in the linked package itself.
await d.dir('foo', [
d.file(
- 'pubspec.lock',
- allOf([
- contains('bar'),
- contains('1.0.0'),
- contains('baz'),
- contains('2.0.0')
- ]))
+ 'pubspec.lock',
+ allOf([
+ contains('bar'),
+ contains('1.0.0'),
+ contains('baz'),
+ contains('2.0.0')
+ ]),
+ )
]).validate();
});
}
diff --git a/test/global/activate/installs_dependencies_test.dart b/test/global/activate/installs_dependencies_test.dart
index 9cb2354..1cd0043 100644
--- a/test/global/activate/installs_dependencies_test.dart
+++ b/test/global/activate/installs_dependencies_test.dart
@@ -14,10 +14,11 @@
..serve('baz', '1.0.0');
await runPub(
- args: ['global', 'activate', 'foo'],
- silent: allOf([
- contains('Downloading bar 1.0.0...'),
- contains('Downloading baz 1.0.0...')
- ]));
+ args: ['global', 'activate', 'foo'],
+ silent: allOf([
+ contains('Downloading bar 1.0.0...'),
+ contains('Downloading baz 1.0.0...')
+ ]),
+ );
});
}
diff --git a/test/global/activate/outdated_binstub_test.dart b/test/global/activate/outdated_binstub_test.dart
index 6d9e298..f2d9609 100644
--- a/test/global/activate/outdated_binstub_test.dart
+++ b/test/global/activate/outdated_binstub_test.dart
@@ -20,11 +20,19 @@
void main() {
test('an outdated binstub is replaced', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', pubspec: {
- 'executables': {'foo-script': 'script'}
- }, contents: [
- d.dir('bin', [d.file('script.dart', "main(args) => print('ok \$args');")])
- ]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'executables': {'foo-script': 'script'}
+ },
+ contents: [
+ d.dir(
+ 'bin',
+ [d.file('script.dart', "main(args) => print('ok \$args');")],
+ )
+ ],
+ );
await runPub(args: ['global', 'activate', 'foo']);
@@ -37,8 +45,10 @@
await d.dir(cachePath, [
d.dir('bin', [
// The new binstub should contain an if
- d.file(binStubName('foo-script'),
- contains('This file was created by pub v0.1.2+3.'))
+ d.file(
+ binStubName('foo-script'),
+ contains('This file was created by pub v3.1.2+3.'),
+ )
])
]).validate();
});
diff --git a/test/global/activate/path_package_test.dart b/test/global/activate/path_package_test.dart
index 514176a..66b4a42 100644
--- a/test/global/activate/path_package_test.dart
+++ b/test/global/activate/path_package_test.dart
@@ -18,17 +18,22 @@
var path = canonicalize(p.join(d.sandbox, 'foo'));
await runPub(
- args: ['global', 'activate', '--source', 'path', '../foo'],
- output: endsWith('Activated foo 1.0.0 at path "$path".'));
+ args: ['global', 'activate', '--source', 'path', '../foo'],
+ output: endsWith('Activated foo 1.0.0 at path "$path".'),
+ );
});
// Regression test for #1751
test('activates a package at a local path with a relative path dependency',
() async {
await d.dir('foo', [
- d.libPubspec('foo', '1.0.0', deps: {
- 'bar': {'path': '../bar'}
- }),
+ d.libPubspec(
+ 'foo',
+ '1.0.0',
+ deps: {
+ 'bar': {'path': '../bar'}
+ },
+ ),
d.dir('bin', [
d.file('foo.dart', """
import 'package:bar/bar.dart';
@@ -45,13 +50,15 @@
var path = canonicalize(p.join(d.sandbox, 'foo'));
await runPub(
- args: ['global', 'activate', '--source', 'path', '../foo'],
- output: endsWith('Activated foo 1.0.0 at path "$path".'));
+ args: ['global', 'activate', '--source', 'path', '../foo'],
+ output: endsWith('Activated foo 1.0.0 at path "$path".'),
+ );
await runPub(
- args: ['global', 'run', 'foo'],
- output: endsWith('ok'),
- workingDirectory: p.current);
+ args: ['global', 'run', 'foo'],
+ output: endsWith('ok'),
+ workingDirectory: p.current,
+ );
});
test("Doesn't precompile binaries when activating from path", () async {
@@ -70,10 +77,10 @@
]).create();
await runPub(
- args: ['global', 'activate', '--source', 'path', '../foo'],
- output: allOf([
- contains('Activated foo 1.0.0 at path'),
- isNot(contains('Built'))
- ]));
+ args: ['global', 'activate', '--source', 'path', '../foo'],
+ output: allOf(
+ [contains('Activated foo 1.0.0 at path'), isNot(contains('Built'))],
+ ),
+ );
});
}
diff --git a/test/global/activate/reactivating_git_upgrades_test.dart b/test/global/activate/reactivating_git_upgrades_test.dart
index 6ce628d..e2d7bdd 100644
--- a/test/global/activate/reactivating_git_upgrades_test.dart
+++ b/test/global/activate/reactivating_git_upgrades_test.dart
@@ -18,28 +18,32 @@
]).create();
await runPub(
- args: ['global', 'activate', '-sgit', '../foo.git'],
- output: allOf(
- startsWith('Resolving dependencies...\n'
- '+ foo 1.0.0 from git ..${separator}foo.git at '),
- // Specific revision number goes here.
- endsWith('Building package executables...\n'
- 'Built foo:foo.\n'
- 'Activated foo 1.0.0 from Git repository "..${separator}foo.git".')));
+ args: ['global', 'activate', '-sgit', '../foo.git'],
+ output: allOf(
+ startsWith('Resolving dependencies...\n'
+ '+ foo 1.0.0 from git ..${separator}foo.git at '),
+ // Specific revision number goes here.
+ endsWith('Building package executables...\n'
+ 'Built foo:foo.\n'
+ 'Activated foo 1.0.0 from Git repository "..${separator}foo.git".'),
+ ),
+ );
await d.git('foo.git', [d.libPubspec('foo', '1.0.1')]).commit();
// Activating it again pulls down the latest commit.
await runPub(
- args: ['global', 'activate', '-sgit', '../foo.git'],
- output: allOf(
- startsWith('Package foo is currently active from Git repository '
- '"..${separator}foo.git".\n'
- 'Resolving dependencies...\n'
- '> foo 1.0.1 from git ..${separator}foo.git at '),
- // Specific revision number goes here.
- endsWith('Building package executables...\n'
- 'Built foo:foo.\n'
- 'Activated foo 1.0.1 from Git repository "..${separator}foo.git".')));
+ args: ['global', 'activate', '-sgit', '../foo.git'],
+ output: allOf(
+ startsWith('Package foo is currently active from Git repository '
+ '"..${separator}foo.git".\n'
+ 'Resolving dependencies...\n'
+ '> foo 1.0.1 from git ..${separator}foo.git at '),
+ // Specific revision number goes here.
+ endsWith('Building package executables...\n'
+ 'Built foo:foo.\n'
+ 'Activated foo 1.0.1 from Git repository "..${separator}foo.git".'),
+ ),
+ );
});
}
diff --git a/test/global/activate/snapshots_git_executables_test.dart b/test/global/activate/snapshots_git_executables_test.dart
index aee6a71..16a3cd2 100644
--- a/test/global/activate/snapshots_git_executables_test.dart
+++ b/test/global/activate/snapshots_git_executables_test.dart
@@ -22,9 +22,11 @@
]).create();
await runPub(
- args: ['global', 'activate', '-sgit', '../foo.git'],
- output: allOf(
- [contains('Built foo:hello.'), contains('Built foo:goodbye.')]));
+ args: ['global', 'activate', '-sgit', '../foo.git'],
+ output: allOf(
+ [contains('Built foo:hello.'), contains('Built foo:goodbye.')],
+ ),
+ );
await d.dir(cachePath, [
d.dir('global_packages', [
@@ -33,7 +35,9 @@
d.dir('bin', [
d.file('hello.dart-$versionSuffix.snapshot', contains('hello!')),
d.file(
- 'goodbye.dart-$versionSuffix.snapshot', contains('goodbye!')),
+ 'goodbye.dart-$versionSuffix.snapshot',
+ contains('goodbye!'),
+ ),
d.nothing('shell.sh-$versionSuffix.snapshot'),
d.nothing('subdir')
])
diff --git a/test/global/activate/snapshots_hosted_executables_test.dart b/test/global/activate/snapshots_hosted_executables_test.dart
index bc2b332..8bf935f 100644
--- a/test/global/activate/snapshots_hosted_executables_test.dart
+++ b/test/global/activate/snapshots_hosted_executables_test.dart
@@ -10,19 +10,25 @@
void main() {
test('snapshots the executables for a hosted package', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', contents: [
- d.dir('bin', [
- d.file('hello.dart', "void main() => print('hello!');"),
- d.file('goodbye.dart', "void main() => print('goodbye!');"),
- d.file('shell.sh', 'echo shell'),
- d.dir('subdir', [d.file('sub.dart', "void main() => print('sub!');")])
- ])
- ]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ contents: [
+ d.dir('bin', [
+ d.file('hello.dart', "void main() => print('hello!');"),
+ d.file('goodbye.dart', "void main() => print('goodbye!');"),
+ d.file('shell.sh', 'echo shell'),
+ d.dir('subdir', [d.file('sub.dart', "void main() => print('sub!');")])
+ ])
+ ],
+ );
await runPub(
- args: ['global', 'activate', 'foo'],
- output: allOf(
- [contains('Built foo:hello.'), contains('Built foo:goodbye.')]));
+ args: ['global', 'activate', 'foo'],
+ output: allOf(
+ [contains('Built foo:hello.'), contains('Built foo:goodbye.')],
+ ),
+ );
await d.dir(cachePath, [
d.dir('global_packages', [
@@ -31,7 +37,9 @@
d.dir('bin', [
d.file('hello.dart-$versionSuffix.snapshot', contains('hello!')),
d.file(
- 'goodbye.dart-$versionSuffix.snapshot', contains('goodbye!')),
+ 'goodbye.dart-$versionSuffix.snapshot',
+ contains('goodbye!'),
+ ),
d.nothing('shell.sh-$versionSuffix.snapshot'),
d.nothing('subdir')
])
diff --git a/test/global/activate/supports_version_solver_backtracking_test.dart b/test/global/activate/supports_version_solver_backtracking_test.dart
index c8c138d..b583743 100644
--- a/test/global/activate/supports_version_solver_backtracking_test.dart
+++ b/test/global/activate/supports_version_solver_backtracking_test.dart
@@ -8,19 +8,27 @@
import '../../test_pub.dart';
void main() {
- test('performs verison solver backtracking if necessary', () async {
+ test('performs version solver backtracking if necessary', () async {
await servePackages()
- ..serve('foo', '1.1.0', pubspec: {
- 'environment': {'sdk': '>=0.1.2 <0.2.0'}
- })
- ..serve('foo', '1.2.0', pubspec: {
- 'environment': {'sdk': '>=0.1.3 <0.2.0'}
- });
+ ..serve(
+ 'foo',
+ '1.1.0',
+ pubspec: {
+ 'environment': {'sdk': defaultSdkConstraint}
+ },
+ )
+ ..serve(
+ 'foo',
+ '1.2.0',
+ pubspec: {
+ 'environment': {'sdk': '^3.1.3'}
+ },
+ );
await runPub(args: ['global', 'activate', 'foo']);
// foo 1.2.0 won't be picked because its SDK constraint conflicts with the
- // dummy SDK version 0.1.2+3.
+ // dummy SDK version 3.1.2+3.
await d.dir(cachePath, [
d.dir('global_packages', [
d.dir('foo', [d.file('pubspec.lock', contains('1.1.0'))])
diff --git a/test/global/activate/uncached_package_test.dart b/test/global/activate/uncached_package_test.dart
index cb8d26d..666eb63 100644
--- a/test/global/activate/uncached_package_test.dart
+++ b/test/global/activate/uncached_package_test.dart
@@ -10,22 +10,37 @@
void main() {
test('installs and activates the best version of a package', () async {
await servePackages()
- ..serve('foo', '1.0.0', contents: [
- d.dir('bin', [d.file('foo.dart', 'main() => print("hi");')])
- ])
- ..serve('foo', '1.2.3', contents: [
- d.dir('bin', [d.file('foo.dart', 'main() => print("hi 1.2.3");')])
- ])
- ..serve('foo', '2.0.0-wildly.unstable', contents: [
- d.dir('bin', [d.file('foo.dart', 'main() => print("hi unstable");')])
- ]);
+ ..serve(
+ 'foo',
+ '1.0.0',
+ contents: [
+ d.dir('bin', [d.file('foo.dart', 'main() => print("hi");')])
+ ],
+ )
+ ..serve(
+ 'foo',
+ '1.2.3',
+ contents: [
+ d.dir('bin', [d.file('foo.dart', 'main() => print("hi 1.2.3");')])
+ ],
+ )
+ ..serve(
+ 'foo',
+ '2.0.0-wildly.unstable',
+ contents: [
+ d.dir('bin', [d.file('foo.dart', 'main() => print("hi unstable");')])
+ ],
+ );
- await runPub(args: ['global', 'activate', 'foo'], output: '''
+ await runPub(
+ args: ['global', 'activate', 'foo'],
+ output: '''
Resolving dependencies...
+ foo 1.2.3
Building package executables...
Built foo:foo.
- Activated foo 1.2.3.''');
+ Activated foo 1.2.3.''',
+ );
// Should be in global package cache.
await d.dir(cachePath, [
diff --git a/test/global/activate/unexpected_arguments_test.dart b/test/global/activate/unexpected_arguments_test.dart
index be6633d..b1a5193 100644
--- a/test/global/activate/unexpected_arguments_test.dart
+++ b/test/global/activate/unexpected_arguments_test.dart
@@ -10,8 +10,9 @@
void main() {
test('fails if there are extra arguments', () {
return runPub(
- args: ['global', 'activate', 'foo', '1.0.0', 'bar', 'baz'],
- error: contains('Unexpected arguments "bar" and "baz".'),
- exitCode: exit_codes.USAGE);
+ args: ['global', 'activate', 'foo', '1.0.0', 'bar', 'baz'],
+ error: contains('Unexpected arguments "bar" and "baz".'),
+ exitCode: exit_codes.USAGE,
+ );
});
}
diff --git a/test/global/activate/unknown_package_test.dart b/test/global/activate/unknown_package_test.dart
index 271545d..2242c55 100644
--- a/test/global/activate/unknown_package_test.dart
+++ b/test/global/activate/unknown_package_test.dart
@@ -12,13 +12,13 @@
await servePackages();
await runPub(
- args: ['global', 'activate', 'foo'],
- error: allOf([
- contains(
- "Because pub global activate depends on foo any which doesn't "
- 'exist (could not find package foo at http://localhost:'),
- contains('), version solving failed.')
- ]),
- exitCode: exit_codes.UNAVAILABLE);
+ args: ['global', 'activate', 'foo'],
+ error: allOf([
+ contains("Because pub global activate depends on foo any which doesn't "
+ 'exist (could not find package foo at http://localhost:'),
+ contains('), version solving failed.')
+ ]),
+ exitCode: exit_codes.UNAVAILABLE,
+ );
});
}
diff --git a/test/global/binstubs/binstub_runs_executable_test.dart b/test/global/binstubs/binstub_runs_executable_test.dart
index 98ab53b..3b03105 100644
--- a/test/global/binstubs/binstub_runs_executable_test.dart
+++ b/test/global/binstubs/binstub_runs_executable_test.dart
@@ -13,18 +13,27 @@
void main() {
test('the generated binstub runs a snapshotted executable', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', pubspec: {
- 'executables': {'foo-script': 'script'}
- }, contents: [
- d.dir('bin', [d.file('script.dart', "main(args) => print('ok \$args');")])
- ]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'executables': {'foo-script': 'script'}
+ },
+ contents: [
+ d.dir(
+ 'bin',
+ [d.file('script.dart', "main(args) => print('ok \$args');")],
+ )
+ ],
+ );
await runPub(args: ['global', 'activate', 'foo']);
var process = await TestProcess.start(
- p.join(d.sandbox, cachePath, 'bin', binStubName('foo-script')),
- ['arg1', 'arg2'],
- environment: getEnvironment());
+ p.join(d.sandbox, cachePath, 'bin', binStubName('foo-script')),
+ ['arg1', 'arg2'],
+ environment: getEnvironment(),
+ );
expect(process.stdout, emits('ok [arg1, arg2]'));
expect(process.stdout, neverEmits('ok [arg1, arg2]'));
@@ -43,9 +52,10 @@
await runPub(args: ['global', 'activate', '-spath', '../foo']);
var process = await TestProcess.start(
- p.join(d.sandbox, cachePath, 'bin', binStubName('foo-script')),
- ['arg1', 'arg2'],
- environment: getEnvironment());
+ p.join(d.sandbox, cachePath, 'bin', binStubName('foo-script')),
+ ['arg1', 'arg2'],
+ environment: getEnvironment(),
+ );
expect(process.stdout, emits('ok [arg1, arg2]'));
await process.shouldExit();
diff --git a/test/global/binstubs/binstub_runs_global_run_if_no_snapshot_test.dart b/test/global/binstubs/binstub_runs_global_run_if_no_snapshot_test.dart
index 8024c3a..d22d8c2 100644
--- a/test/global/binstubs/binstub_runs_global_run_if_no_snapshot_test.dart
+++ b/test/global/binstubs/binstub_runs_global_run_if_no_snapshot_test.dart
@@ -19,8 +19,9 @@
// Path packages are mutable, so no snapshot is created.
await runPub(
- args: ['global', 'activate', '--source', 'path', '../foo'],
- output: contains('Installed executable foo-script.'));
+ args: ['global', 'activate', '--source', 'path', '../foo'],
+ output: contains('Installed executable foo-script.'),
+ );
await d.dir(cachePath, [
d.dir('bin', [
diff --git a/test/global/binstubs/binstub_runs_precompiled_snapshot_test.dart b/test/global/binstubs/binstub_runs_precompiled_snapshot_test.dart
index cd477db..fd335bb 100644
--- a/test/global/binstubs/binstub_runs_precompiled_snapshot_test.dart
+++ b/test/global/binstubs/binstub_runs_precompiled_snapshot_test.dart
@@ -10,18 +10,25 @@
void main() {
test('the binstubs runs a built snapshot if present', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', pubspec: {
- 'executables': {'foo-script': 'script'}
- }, contents: [
- d.dir('bin', [d.file('script.dart', "main(args) => print('ok');")])
- ]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'executables': {'foo-script': 'script'}
+ },
+ contents: [
+ d.dir('bin', [d.file('script.dart', "main(args) => print('ok');")])
+ ],
+ );
await runPub(args: ['global', 'activate', 'foo']);
await d.dir(cachePath, [
d.dir('bin', [
- d.file(binStubName('foo-script'),
- contains('script.dart-$versionSuffix.snapshot'))
+ d.file(
+ binStubName('foo-script'),
+ contains('script.dart-$versionSuffix.snapshot'),
+ )
])
]).validate();
});
diff --git a/test/global/binstubs/creates_executables_in_pubspec_test.dart b/test/global/binstubs/creates_executables_in_pubspec_test.dart
index a6604ab..5d4a721 100644
--- a/test/global/binstubs/creates_executables_in_pubspec_test.dart
+++ b/test/global/binstubs/creates_executables_in_pubspec_test.dart
@@ -10,19 +10,25 @@
void main() {
test('creates binstubs for each executable in the pubspec', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', pubspec: {
- 'executables': {'one': null, 'two-renamed': 'second'}
- }, contents: [
- d.dir('bin', [
- d.file('one.dart', "main(args) => print('one');"),
- d.file('second.dart', "main(args) => print('two');"),
- d.file('nope.dart', "main(args) => print('nope');")
- ])
- ]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'executables': {'one': null, 'two-renamed': 'second'}
+ },
+ contents: [
+ d.dir('bin', [
+ d.file('one.dart', "main(args) => print('one');"),
+ d.file('second.dart', "main(args) => print('two');"),
+ d.file('nope.dart', "main(args) => print('nope');")
+ ])
+ ],
+ );
await runPub(
- args: ['global', 'activate', 'foo'],
- output: contains('Installed executables one and two-renamed.'));
+ args: ['global', 'activate', 'foo'],
+ output: contains('Installed executables one and two-renamed.'),
+ );
await d.dir(cachePath, [
d.dir('bin', [
diff --git a/test/global/binstubs/does_not_warn_if_no_executables_test.dart b/test/global/binstubs/does_not_warn_if_no_executables_test.dart
index 9814f15..344e399 100644
--- a/test/global/binstubs/does_not_warn_if_no_executables_test.dart
+++ b/test/global/binstubs/does_not_warn_if_no_executables_test.dart
@@ -10,12 +10,20 @@
void main() {
test('does not warn if the package has no executables', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', contents: [
- d.dir('bin', [d.file('script.dart', "main(args) => print('ok \$args');")])
- ]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ contents: [
+ d.dir(
+ 'bin',
+ [d.file('script.dart', "main(args) => print('ok \$args');")],
+ )
+ ],
+ );
await runPub(
- args: ['global', 'activate', 'foo'],
- output: isNot(contains('is not on your path')));
+ args: ['global', 'activate', 'foo'],
+ output: isNot(contains('is not on your path')),
+ );
});
}
diff --git a/test/global/binstubs/does_not_warn_if_on_path_test.dart b/test/global/binstubs/does_not_warn_if_on_path_test.dart
index 9b11386..d2d25ec 100644
--- a/test/global/binstubs/does_not_warn_if_on_path_test.dart
+++ b/test/global/binstubs/does_not_warn_if_on_path_test.dart
@@ -13,11 +13,19 @@
void main() {
test('does not warn if the binstub directory is on the path', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', pubspec: {
- 'executables': {'script': null}
- }, contents: [
- d.dir('bin', [d.file('script.dart', "main(args) => print('ok \$args');")])
- ]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'executables': {'script': null}
+ },
+ contents: [
+ d.dir(
+ 'bin',
+ [d.file('script.dart', "main(args) => print('ok \$args');")],
+ )
+ ],
+ );
// Add the test's cache bin directory to the path.
var binDir = p.dirname(Platform.executable);
@@ -25,8 +33,9 @@
var path = "${Platform.environment["PATH"]}$separator$binDir";
await runPub(
- args: ['global', 'activate', 'foo'],
- output: isNot(contains('is not on your path')),
- environment: {'PATH': path});
+ args: ['global', 'activate', 'foo'],
+ output: isNot(contains('is not on your path')),
+ environment: {'PATH': path},
+ );
});
}
diff --git a/test/global/binstubs/explicit_and_no_executables_options_test.dart b/test/global/binstubs/explicit_and_no_executables_options_test.dart
index 68bbd5b..bc34ce6 100644
--- a/test/global/binstubs/explicit_and_no_executables_options_test.dart
+++ b/test/global/binstubs/explicit_and_no_executables_options_test.dart
@@ -13,17 +13,18 @@
await d.dir('foo', [d.libPubspec('foo', '1.0.0')]).create();
await runPub(
- args: [
- 'global',
- 'activate',
- '--source',
- 'path',
- '../foo',
- '-x',
- 'anything',
- '--no-executables'
- ],
- error: contains('Cannot pass both --no-executables and --executable.'),
- exitCode: exit_codes.USAGE);
+ args: [
+ 'global',
+ 'activate',
+ '--source',
+ 'path',
+ '../foo',
+ '-x',
+ 'anything',
+ '--no-executables'
+ ],
+ error: contains('Cannot pass both --no-executables and --executable.'),
+ exitCode: exit_codes.USAGE,
+ );
});
}
diff --git a/test/global/binstubs/explicit_executables_test.dart b/test/global/binstubs/explicit_executables_test.dart
index e721f73..293ffef 100644
--- a/test/global/binstubs/explicit_executables_test.dart
+++ b/test/global/binstubs/explicit_executables_test.dart
@@ -17,17 +17,20 @@
d.dir('bin', [d.file('script.dart', "main() => print('ok');")])
]).create();
- await runPub(args: [
- 'global',
- 'activate',
- '--source',
- 'path',
- '../foo',
- '-x',
- 'one',
- '--executable',
- 'three'
- ], output: contains('Installed executables one and three.'));
+ await runPub(
+ args: [
+ 'global',
+ 'activate',
+ '--source',
+ 'path',
+ '../foo',
+ '-x',
+ 'one',
+ '--executable',
+ 'three'
+ ],
+ output: contains('Installed executables one and three.'),
+ );
await d.dir(cachePath, [
d.dir('bin', [
diff --git a/test/global/binstubs/missing_script_test.dart b/test/global/binstubs/missing_script_test.dart
index 433f9cf..3a15cc3 100644
--- a/test/global/binstubs/missing_script_test.dart
+++ b/test/global/binstubs/missing_script_test.dart
@@ -20,13 +20,15 @@
var pub = await startPub(args: ['global', 'activate', '-spath', '../foo']);
expect(
- pub.stderr,
- emits('Warning: Executable "missing" runs '
- '"${p.join('bin', 'not_here.dart')}", which was not found in foo.'));
+ pub.stderr,
+ emits('Warning: Executable "missing" runs '
+ '"${p.join('bin', 'not_here.dart')}", which was not found in foo.'),
+ );
expect(
- pub.stderr,
- emits('Warning: Executable "nope" runs '
- '"${p.join('bin', 'nope.dart')}", which was not found in foo.'));
+ pub.stderr,
+ emits('Warning: Executable "nope" runs '
+ '"${p.join('bin', 'nope.dart')}", which was not found in foo.'),
+ );
await pub.shouldExit();
});
}
diff --git a/test/global/binstubs/name_collision_test.dart b/test/global/binstubs/name_collision_test.dart
index 75b72ce..f6b63b5 100644
--- a/test/global/binstubs/name_collision_test.dart
+++ b/test/global/binstubs/name_collision_test.dart
@@ -29,14 +29,19 @@
var pub = await startPub(args: ['global', 'activate', '-spath', '../bar']);
expect(pub.stdout, emitsThrough('Installed executable bar.'));
- expect(pub.stderr,
- emits('Executable collide1 was already installed from foo.'));
- expect(pub.stderr,
- emits('Executable collide2 was already installed from foo.'));
expect(
- pub.stderr,
- emits('Deactivate the other package(s) or activate bar using '
- '--overwrite.'));
+ pub.stderr,
+ emits('Executable collide1 was already installed from foo.'),
+ );
+ expect(
+ pub.stderr,
+ emits('Executable collide2 was already installed from foo.'),
+ );
+ expect(
+ pub.stderr,
+ emits('Deactivate the other package(s) or activate bar using '
+ '--overwrite.'),
+ );
await pub.shouldExit();
await d.dir(cachePath, [
diff --git a/test/global/binstubs/name_collision_with_overwrite_test.dart b/test/global/binstubs/name_collision_with_overwrite_test.dart
index 6e5a869..025b679 100644
--- a/test/global/binstubs/name_collision_with_overwrite_test.dart
+++ b/test/global/binstubs/name_collision_with_overwrite_test.dart
@@ -28,13 +28,20 @@
await runPub(args: ['global', 'activate', '-spath', '../foo']);
var pub = await startPub(
- args: ['global', 'activate', '-spath', '../bar', '--overwrite']);
- expect(pub.stdout,
- emitsThrough('Installed executables bar, collide1 and collide2.'));
+ args: ['global', 'activate', '-spath', '../bar', '--overwrite'],
+ );
expect(
- pub.stderr, emits('Replaced collide1 previously installed from foo.'));
+ pub.stdout,
+ emitsThrough('Installed executables bar, collide1 and collide2.'),
+ );
expect(
- pub.stderr, emits('Replaced collide2 previously installed from foo.'));
+ pub.stderr,
+ emits('Replaced collide1 previously installed from foo.'),
+ );
+ expect(
+ pub.stderr,
+ emits('Replaced collide2 previously installed from foo.'),
+ );
await pub.shouldExit();
await d.dir(cachePath, [
diff --git a/test/global/binstubs/no_executables_flag_test.dart b/test/global/binstubs/no_executables_flag_test.dart
index 39f91cd..be1c699 100644
--- a/test/global/binstubs/no_executables_flag_test.dart
+++ b/test/global/binstubs/no_executables_flag_test.dart
@@ -19,14 +19,16 @@
await runPub(args: ['global', 'activate', '--source', 'path', '../foo']);
- await runPub(args: [
- 'global',
- 'activate',
- '--source',
- 'path',
- '../foo',
- '--no-executables'
- ]);
+ await runPub(
+ args: [
+ 'global',
+ 'activate',
+ '--source',
+ 'path',
+ '../foo',
+ '--no-executables'
+ ],
+ );
// Should still delete old one.
await d.dir(cachePath, [
diff --git a/test/global/binstubs/outdated_binstub_runs_pub_global_test.dart b/test/global/binstubs/outdated_binstub_runs_pub_global_test.dart
index 442dfbc..9884cbc 100644
--- a/test/global/binstubs/outdated_binstub_runs_pub_global_test.dart
+++ b/test/global/binstubs/outdated_binstub_runs_pub_global_test.dart
@@ -25,39 +25,47 @@
test("an outdated binstub runs 'pub global run', which replaces old binstub",
() async {
final server = await servePackages();
- server.serve('foo', '1.0.0', pubspec: {
- 'executables': {
- 'foo-script': 'script',
- 'foo-script2': 'script',
- 'foo-script-not-installed': 'script',
- 'foo-another-script': 'another-script',
- 'foo-another-script-not-installed': 'another-script'
- }
- }, contents: [
- d.dir('bin', [
- d.file('script.dart', r"main(args) => print('ok $args');"),
- d.file(
- 'another-script.dart', r"main(args) => print('not so good $args');")
- ])
- ]);
-
- await runPub(args: [
- 'global',
- 'activate',
+ server.serve(
'foo',
- '--executable',
- 'foo-script',
- '--executable',
- 'foo-script2',
- '--executable',
- 'foo-another-script',
- ], environment: {
- '_PUB_TEST_SDK_VERSION': '0.0.1'
- });
+ '1.0.0',
+ pubspec: {
+ 'executables': {
+ 'foo-script': 'script',
+ 'foo-script2': 'script',
+ 'foo-script-not-installed': 'script',
+ 'foo-another-script': 'another-script',
+ 'foo-another-script-not-installed': 'another-script'
+ }
+ },
+ contents: [
+ d.dir('bin', [
+ d.file('script.dart', r"main(args) => print('ok $args');"),
+ d.file(
+ 'another-script.dart',
+ r"main(args) => print('not so good $args');",
+ )
+ ])
+ ],
+ );
- expect(binStub('foo-script'), contains('script.dart-0.0.1.snapshot'));
+ await runPub(
+ args: [
+ 'global',
+ 'activate',
+ 'foo',
+ '--executable',
+ 'foo-script',
+ '--executable',
+ 'foo-script2',
+ '--executable',
+ 'foo-another-script',
+ ],
+ environment: {'_PUB_TEST_SDK_VERSION': '3.0.0'},
+ );
- expect(binStub('foo-script2'), contains('script.dart-0.0.1.snapshot'));
+ expect(binStub('foo-script'), contains('script.dart-3.0.0.snapshot'));
+
+ expect(binStub('foo-script2'), contains('script.dart-3.0.0.snapshot'));
expect(
binStub('foo-script-not-installed'),
@@ -66,7 +74,7 @@
expect(
binStub('foo-another-script'),
- contains('another-script.dart-0.0.1.snapshot'),
+ contains('another-script.dart-3.0.0.snapshot'),
);
expect(
@@ -81,27 +89,28 @@
d.dir('foo', [
d.dir(
'bin',
- [d.outOfDateSnapshot('script.dart-0.0.1.snapshot')],
+ [d.outOfDateSnapshot('script.dart-3.0.0.snapshot')],
)
])
])
]).create();
var process = await TestProcess.start(
- p.join(d.sandbox, cachePath, 'bin', binStubName('foo-script')),
- ['arg1', 'arg2'],
- environment: getEnvironment());
+ p.join(d.sandbox, cachePath, 'bin', binStubName('foo-script')),
+ ['arg1', 'arg2'],
+ environment: getEnvironment(),
+ );
expect(await process.stdout.rest.toList(), contains('ok [arg1, arg2]'));
expect(
binStub('foo-script'),
- contains('script.dart-0.1.2+3.snapshot'),
+ contains('script.dart-3.1.2+3.snapshot'),
);
expect(
binStub('foo-script2'),
- contains('script.dart-0.1.2+3.snapshot'),
+ contains('script.dart-3.1.2+3.snapshot'),
);
expect(
@@ -112,7 +121,7 @@
expect(
binStub('foo-another-script'),
- contains('another-script.dart-0.0.1.snapshot'),
+ contains('another-script.dart-3.0.0.snapshot'),
reason:
'global run recompile should not refresh binstubs for other scripts',
);
diff --git a/test/global/binstubs/outdated_snapshot_test.dart b/test/global/binstubs/outdated_snapshot_test.dart
index 91bfff6..f55cb3c 100644
--- a/test/global/binstubs/outdated_snapshot_test.dart
+++ b/test/global/binstubs/outdated_snapshot_test.dart
@@ -14,30 +14,48 @@
void main() {
test("a binstub runs 'pub global run' for an outdated snapshot", () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', pubspec: {
- 'executables': {'foo-script': 'script'}
- }, contents: [
- d.dir('bin', [d.file('script.dart', "main(args) => print('ok \$args');")])
- ]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'executables': {'foo-script': 'script'}
+ },
+ contents: [
+ d.dir(
+ 'bin',
+ [d.file('script.dart', "main(args) => print('ok \$args');")],
+ )
+ ],
+ );
await runPub(args: ['global', 'activate', 'foo']);
await d.dir(cachePath, [
d.dir('global_packages', [
d.dir('foo', [
- d.dir('bin',
- [d.outOfDateSnapshot('script.dart-$versionSuffix.snapshot-1')])
+ d.dir(
+ 'bin',
+ [d.outOfDateSnapshot('script.dart-$versionSuffix.snapshot-1')],
+ )
])
])
]).create();
- deleteEntry(p.join(d.dir(cachePath).io.path, 'global_packages', 'foo',
- 'bin', 'script.dart-$versionSuffix.snapshot'));
+ deleteEntry(
+ p.join(
+ d.dir(cachePath).io.path,
+ 'global_packages',
+ 'foo',
+ 'bin',
+ 'script.dart-$versionSuffix.snapshot',
+ ),
+ );
var process = await TestProcess.start(
- p.join(d.sandbox, cachePath, 'bin', binStubName('foo-script')),
- ['arg1', 'arg2'],
- environment: getEnvironment());
+ p.join(d.sandbox, cachePath, 'bin', binStubName('foo-script')),
+ ['arg1', 'arg2'],
+ environment: getEnvironment(),
+ );
// We don't get `Building package executable...` because we are running through
// the binstub.
diff --git a/test/global/binstubs/path_package_test.dart b/test/global/binstubs/path_package_test.dart
index 0461e35..35b2acf 100644
--- a/test/global/binstubs/path_package_test.dart
+++ b/test/global/binstubs/path_package_test.dart
@@ -18,12 +18,15 @@
]).create();
await runPub(
- args: ['global', 'activate', '--source', 'path', '../foo'],
- output: contains('Installed executable foo.'));
+ args: ['global', 'activate', '--source', 'path', '../foo'],
+ output: contains('Installed executable foo.'),
+ );
await d.dir(cachePath, [
- d.dir('bin',
- [d.file(binStubName('foo'), contains('pub global run foo:foo'))])
+ d.dir(
+ 'bin',
+ [d.file(binStubName('foo'), contains('pub global run foo:foo'))],
+ )
]).validate();
});
}
diff --git a/test/global/binstubs/removes_when_deactivated_test.dart b/test/global/binstubs/removes_when_deactivated_test.dart
index 975defe..4bc73f2 100644
--- a/test/global/binstubs/removes_when_deactivated_test.dart
+++ b/test/global/binstubs/removes_when_deactivated_test.dart
@@ -10,21 +10,28 @@
void main() {
test('removes binstubs when the package is deactivated', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', pubspec: {
- 'executables': {'one': null, 'two': null}
- }, contents: [
- d.dir('bin', [
- d.file('one.dart', "main(args) => print('one');"),
- d.file('two.dart', "main(args) => print('two');")
- ])
- ]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'executables': {'one': null, 'two': null}
+ },
+ contents: [
+ d.dir('bin', [
+ d.file('one.dart', "main(args) => print('one');"),
+ d.file('two.dart', "main(args) => print('two');")
+ ])
+ ],
+ );
await runPub(args: ['global', 'activate', 'foo']);
await runPub(args: ['global', 'deactivate', 'foo']);
await d.dir(cachePath, [
d.dir(
- 'bin', [d.nothing(binStubName('one')), d.nothing(binStubName('two'))])
+ 'bin',
+ [d.nothing(binStubName('one')), d.nothing(binStubName('two'))],
+ )
]).validate();
});
}
diff --git a/test/global/binstubs/runs_once_even_when_dart_is_batch_test.dart b/test/global/binstubs/runs_once_even_when_dart_is_batch_test.dart
index 99eeaaf..b1640d6 100644
--- a/test/global/binstubs/runs_once_even_when_dart_is_batch_test.dart
+++ b/test/global/binstubs/runs_once_even_when_dart_is_batch_test.dart
@@ -12,41 +12,46 @@
void main() {
test(
- 'runs only once even when dart on path is a batch file (as in flutter/bin)',
- () async {
- final server = await servePackages();
- server.serve(
- 'foo',
- '1.0.0',
- contents: [
- d.dir('bin', [d.file('script.dart', 'main(args) => print(args);')]),
- ],
- pubspec: {
- 'executables': {'script': 'script'},
- },
- );
+ 'runs only once even when dart on path is a batch file (as in flutter/bin)',
+ () async {
+ final server = await servePackages();
+ server.serve(
+ 'foo',
+ '1.0.0',
+ contents: [
+ d.dir('bin', [d.file('script.dart', 'main(args) => print(args);')]),
+ ],
+ pubspec: {
+ 'executables': {'script': 'script'},
+ },
+ );
- await runPub(args: ['global', 'activate', 'foo']);
+ await runPub(args: ['global', 'activate', 'foo']);
- await d.dir(
- 'bin',
- [
- d.file('dart.bat', '''
+ await d.dir(
+ 'bin',
+ [
+ d.file('dart.bat', '''
@echo off
${Platform.resolvedExecutable} %*
'''),
- ],
- ).create();
+ ],
+ ).create();
- var process =
- await Process.run(p.join(d.sandbox, cachePath, 'bin', 'script.bat'), [
- 'hi'
- ], environment: {
- 'PATH': [p.join(d.sandbox, 'bin'), p.dirname(Platform.resolvedExecutable)]
- .join(';'),
- ...getPubTestEnvironment(),
- });
- expect((process.stdout as String).trim(), '[hi]');
- expect(process.exitCode, 0);
- }, skip: !Platform.isWindows);
+ var process = await Process.run(
+ p.join(d.sandbox, cachePath, 'bin', 'script.bat'),
+ ['hi'],
+ environment: {
+ 'PATH': [
+ p.join(d.sandbox, 'bin'),
+ p.dirname(Platform.resolvedExecutable)
+ ].join(';'),
+ ...getPubTestEnvironment(),
+ },
+ );
+ expect((process.stdout as String).trim(), '[hi]');
+ expect(process.exitCode, 0);
+ },
+ skip: !Platform.isWindows,
+ );
}
diff --git a/test/global/binstubs/unknown_explicit_executable_test.dart b/test/global/binstubs/unknown_explicit_executable_test.dart
index 33b82e7..b4ba8f5 100644
--- a/test/global/binstubs/unknown_explicit_executable_test.dart
+++ b/test/global/binstubs/unknown_explicit_executable_test.dart
@@ -18,10 +18,12 @@
d.dir('bin', [d.file('one.dart', "main() => print('ok');")])
]).create();
- var pub = await startPub(args: [
- 'global', 'activate', '--source', 'path', '../foo', //
- '-x', 'who', '-x', 'one', '--executable', 'wat'
- ]);
+ var pub = await startPub(
+ args: [
+ 'global', 'activate', '--source', 'path', '../foo', //
+ '-x', 'who', '-x', 'one', '--executable', 'wat'
+ ],
+ );
expect(pub.stdout, emitsThrough('Installed executable one.'));
expect(pub.stderr, emits('Unknown executables wat and who.'));
diff --git a/test/global/binstubs/warns_if_not_on_path_test.dart b/test/global/binstubs/warns_if_not_on_path_test.dart
index d98bf76..ca3763a 100644
--- a/test/global/binstubs/warns_if_not_on_path_test.dart
+++ b/test/global/binstubs/warns_if_not_on_path_test.dart
@@ -10,14 +10,23 @@
void main() {
test('warns if the binstub directory is not on the path', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', pubspec: {
- 'executables': {'some-dart-script': 'script'}
- }, contents: [
- d.dir('bin', [d.file('script.dart', "main(args) => print('ok \$args');")])
- ]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'executables': {'some-dart-script': 'script'}
+ },
+ contents: [
+ d.dir(
+ 'bin',
+ [d.file('script.dart', "main(args) => print('ok \$args');")],
+ )
+ ],
+ );
await runPub(
- args: ['global', 'activate', 'foo'],
- error: contains('is not on your path'));
+ args: ['global', 'activate', 'foo'],
+ error: contains('is not on your path'),
+ );
});
}
diff --git a/test/global/deactivate/deactivate_and_reactivate_package_test.dart b/test/global/deactivate/deactivate_and_reactivate_package_test.dart
index 5a6f6e3..e5f4f33 100644
--- a/test/global/deactivate/deactivate_and_reactivate_package_test.dart
+++ b/test/global/deactivate/deactivate_and_reactivate_package_test.dart
@@ -16,16 +16,18 @@
await runPub(args: ['global', 'activate', 'foo', '1.0.0']);
await runPub(
- args: ['global', 'deactivate', 'foo'],
- output: 'Deactivated package foo 1.0.0.');
+ args: ['global', 'deactivate', 'foo'],
+ output: 'Deactivated package foo 1.0.0.',
+ );
// Activating again should forget the old version.
await runPub(
- args: ['global', 'activate', 'foo'],
- silent: contains('Downloading foo 2.0.0...'),
- output: '''
+ args: ['global', 'activate', 'foo'],
+ silent: contains('Downloading foo 2.0.0...'),
+ output: '''
Resolving dependencies...
+ foo 2.0.0
- Activated foo 2.0.0.''');
+ Activated foo 2.0.0.''',
+ );
});
}
diff --git a/test/global/deactivate/git_package_test.dart b/test/global/deactivate/git_package_test.dart
index 04b9267..2cea80d 100644
--- a/test/global/deactivate/git_package_test.dart
+++ b/test/global/deactivate/git_package_test.dart
@@ -20,8 +20,9 @@
await runPub(args: ['global', 'activate', '-sgit', '../foo.git']);
await runPub(
- args: ['global', 'deactivate', 'foo'],
- output:
- 'Deactivated package foo 1.0.0 from Git repository "..${separator}foo.git".');
+ args: ['global', 'deactivate', 'foo'],
+ output:
+ 'Deactivated package foo 1.0.0 from Git repository "..${separator}foo.git".',
+ );
});
}
diff --git a/test/global/deactivate/hosted_package_test.dart b/test/global/deactivate/hosted_package_test.dart
index fa91829..95db3e3 100644
--- a/test/global/deactivate/hosted_package_test.dart
+++ b/test/global/deactivate/hosted_package_test.dart
@@ -14,7 +14,8 @@
await runPub(args: ['global', 'activate', 'foo']);
await runPub(
- args: ['global', 'deactivate', 'foo'],
- output: 'Deactivated package foo 1.0.0.');
+ args: ['global', 'deactivate', 'foo'],
+ output: 'Deactivated package foo 1.0.0.',
+ );
});
}
diff --git a/test/global/deactivate/path_package_test.dart b/test/global/deactivate/path_package_test.dart
index 1f50713..0a99274 100644
--- a/test/global/deactivate/path_package_test.dart
+++ b/test/global/deactivate/path_package_test.dart
@@ -20,7 +20,8 @@
var path = canonicalize(p.join(d.sandbox, 'foo'));
await runPub(
- args: ['global', 'deactivate', 'foo'],
- output: 'Deactivated package foo 1.0.0 at path "$path".');
+ args: ['global', 'deactivate', 'foo'],
+ output: 'Deactivated package foo 1.0.0 at path "$path".',
+ );
});
}
diff --git a/test/global/deactivate/removes_precompiled_snapshots_test.dart b/test/global/deactivate/removes_precompiled_snapshots_test.dart
index a7670e2..a885503 100644
--- a/test/global/deactivate/removes_precompiled_snapshots_test.dart
+++ b/test/global/deactivate/removes_precompiled_snapshots_test.dart
@@ -15,8 +15,9 @@
await runPub(args: ['global', 'activate', 'foo']);
await runPub(
- args: ['global', 'deactivate', 'foo'],
- output: 'Deactivated package foo 1.0.0.');
+ args: ['global', 'deactivate', 'foo'],
+ output: 'Deactivated package foo 1.0.0.',
+ );
await d.dir(cachePath, [
d.dir('global_packages', [d.nothing('foo')])
diff --git a/test/global/deactivate/unknown_package_test.dart b/test/global/deactivate/unknown_package_test.dart
index 35023ad..9b55042 100644
--- a/test/global/deactivate/unknown_package_test.dart
+++ b/test/global/deactivate/unknown_package_test.dart
@@ -12,8 +12,9 @@
await servePackages();
await runPub(
- args: ['global', 'deactivate', 'foo'],
- error: 'No active package foo.',
- exitCode: exit_codes.DATA);
+ args: ['global', 'deactivate', 'foo'],
+ error: 'No active package foo.',
+ exitCode: exit_codes.DATA,
+ );
});
}
diff --git a/test/global/list_test.dart b/test/global/list_test.dart
index e1ba4fd..65f3eff 100644
--- a/test/global/list_test.dart
+++ b/test/global/list_test.dart
@@ -31,8 +31,9 @@
await runPub(args: ['global', 'activate', '-sgit', '../foo.git']);
await runPub(
- args: ['global', 'list'],
- output: 'foo 1.0.0 from Git repository "..${p.separator}foo.git"');
+ args: ['global', 'list'],
+ output: 'foo 1.0.0 from Git repository "..${p.separator}foo.git"',
+ );
});
test('lists an activated Path package', () async {
@@ -57,11 +58,14 @@
await runPub(args: ['global', 'activate', 'aaa']);
await runPub(args: ['global', 'activate', 'bbb']);
- await runPub(args: ['global', 'list'], output: '''
+ await runPub(
+ args: ['global', 'list'],
+ output: '''
aaa 1.0.0
bbb 1.0.0
ccc 1.0.0
-''');
+''',
+ );
});
test('lists nothing when no packages activated', () async {
diff --git a/test/global/run/errors_if_outside_bin_test.dart b/test/global/run/errors_if_outside_bin_test.dart
index 72bcd4f..dcdc2aa 100644
--- a/test/global/run/errors_if_outside_bin_test.dart
+++ b/test/global/run/errors_if_outside_bin_test.dart
@@ -11,15 +11,20 @@
void main() {
test('errors if the script is in a subdirectory.', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', contents: [
- d.dir('example', [d.file('script.dart', "main(args) => print('ok');")])
- ]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ contents: [
+ d.dir('example', [d.file('script.dart', "main(args) => print('ok');")])
+ ],
+ );
await runPub(args: ['global', 'activate', 'foo']);
await runPub(
args: ['global', 'run', 'foo:example/script'],
error: contains(
- 'Cannot run an executable in a subdirectory of a global package.'),
+ 'Cannot run an executable in a subdirectory of a global package.',
+ ),
exitCode: exit_codes.USAGE,
);
});
diff --git a/test/global/run/fails_if_sdk_constraint_is_unmet_test.dart b/test/global/run/fails_if_sdk_constraint_is_unmet_test.dart
index 3bef340..deb31a7 100644
--- a/test/global/run/fails_if_sdk_constraint_is_unmet_test.dart
+++ b/test/global/run/fails_if_sdk_constraint_is_unmet_test.dart
@@ -11,9 +11,13 @@
void main() {
test("fails if the current SDK doesn't match the constraint", () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', contents: [
- d.dir('bin', [d.file('script.dart', "main(args) => print('ok');")])
- ]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ contents: [
+ d.dir('bin', [d.file('script.dart', "main(args) => print('ok');")])
+ ],
+ );
await runPub(args: ['global', 'activate', 'foo']);
@@ -34,70 +38,81 @@
]).create();
await runPub(
- args: ['global', 'run', 'foo:script'],
- error: contains("foo 1.0.0 doesn't support Dart 0.1.2+3."),
- exitCode: exit_codes.DATA);
+ args: ['global', 'run', 'foo:script'],
+ error: contains("foo 1.0.0 doesn't support Dart 3.1.2+3."),
+ exitCode: exit_codes.DATA,
+ );
});
test('fails if SDK is downgraded below the constraints', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', pubspec: {
- 'environment': {
- 'sdk': '>=2.0.0 <3.0.0',
- },
- }, contents: [
- d.dir('bin', [d.file('script.dart', "main(args) => print('123-OK');")])
- ]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ sdk: '^3.0.1',
+ contents: [
+ d.dir('bin', [d.file('script.dart', "main(args) => print('123-OK');")])
+ ],
+ );
+
+ await runPub(args: ['global', 'activate', 'foo']);
await runPub(
- environment: {'_PUB_TEST_SDK_VERSION': '2.0.0'},
- args: ['global', 'activate', 'foo'],
+ args: ['global', 'run', 'foo:script'],
+ output: contains('123-OK'),
);
await runPub(
- environment: {'_PUB_TEST_SDK_VERSION': '2.0.0'},
- args: ['global', 'run', 'foo:script'],
- output: contains('123-OK'));
-
- await runPub(
- environment: {'_PUB_TEST_SDK_VERSION': '1.2.3'},
- args: ['global', 'run', 'foo:script'],
- error: contains("foo 1.0.0 doesn't support Dart 1.2.3."),
- exitCode: exit_codes.DATA);
+ environment: {
+ // Not compatible with [defaultSdkConstraint].
+ '_PUB_TEST_SDK_VERSION': '3.0.0'
+ },
+ args: ['global', 'run', 'foo:script'],
+ error: contains("foo 1.0.0 doesn't support Dart 3.0.0."),
+ exitCode: exit_codes.DATA,
+ );
});
test('fails if SDK is downgraded below dependency SDK constraints', () async {
await servePackages()
- ..serve('foo', '1.0.0', deps: {
- 'bar': '^1.0.0',
- }, pubspec: {
- 'environment': {
- 'sdk': '>=2.0.0 <3.0.0',
+ ..serve(
+ 'foo',
+ '1.0.0',
+ deps: {
+ 'bar': '^1.0.0',
},
- }, contents: [
- d.dir('bin', [d.file('script.dart', "main(args) => print('123-OK');")])
- ])
- ..serve('bar', '1.0.0', pubspec: {
- 'environment': {
- 'sdk': '>=2.2.0 <3.0.0',
+ sdk: '^3.0.0',
+ contents: [
+ d.dir(
+ 'bin',
+ [d.file('script.dart', "main(args) => print('123-OK');")],
+ )
+ ],
+ )
+ ..serve(
+ 'bar',
+ '1.0.0',
+ pubspec: {
+ 'environment': {
+ 'sdk': '^3.0.1',
+ },
},
- });
+ );
+
+ await runPub(args: ['global', 'activate', 'foo']);
await runPub(
- environment: {'_PUB_TEST_SDK_VERSION': '2.2.0'},
- args: ['global', 'activate', 'foo'],
+ args: ['global', 'run', 'foo:script'],
+ output: contains('123-OK'),
);
await runPub(
- environment: {'_PUB_TEST_SDK_VERSION': '2.2.0'},
- args: ['global', 'run', 'foo:script'],
- output: contains('123-OK'));
-
- await runPub(
- environment: {'_PUB_TEST_SDK_VERSION': '2.0.0'},
- args: ['global', 'run', 'foo:script'],
- error: contains(
- "foo as globally activated doesn't support Dart 2.0.0, try: dart pub global activate foo"),
- exitCode: exit_codes.DATA);
+ environment: {'_PUB_TEST_SDK_VERSION': '3.0.0'},
+ args: ['global', 'run', 'foo:script'],
+ error: contains(
+ "foo as globally activated doesn't support Dart 3.0.0, try: dart pub global activate foo",
+ ),
+ exitCode: exit_codes.DATA,
+ );
});
}
diff --git a/test/global/run/implicit_executable_name_test.dart b/test/global/run/implicit_executable_name_test.dart
index 9757772..eec609c 100644
--- a/test/global/run/implicit_executable_name_test.dart
+++ b/test/global/run/implicit_executable_name_test.dart
@@ -10,9 +10,13 @@
void main() {
test('defaults to the package name if the script is omitted', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', contents: [
- d.dir('bin', [d.file('foo.dart', "main(args) => print('foo');")])
- ]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ contents: [
+ d.dir('bin', [d.file('foo.dart', "main(args) => print('foo');")])
+ ],
+ );
await runPub(args: ['global', 'activate', 'foo']);
diff --git a/test/global/run/missing_path_package_test.dart b/test/global/run/missing_path_package_test.dart
index 99cf30a..4dcf3b1 100644
--- a/test/global/run/missing_path_package_test.dart
+++ b/test/global/run/missing_path_package_test.dart
@@ -23,8 +23,10 @@
var pub = await pubRun(global: true, args: ['foo']);
var path = canonicalize(p.join(d.sandbox, 'foo'));
- expect(pub.stderr,
- emits('Could not find a file named "pubspec.yaml" in "$path".'));
+ expect(
+ pub.stderr,
+ emits('Could not find a file named "pubspec.yaml" in "$path".'),
+ );
await pub.shouldExit(exit_codes.NO_INPUT);
});
}
diff --git a/test/global/run/nonexistent_script_test.dart b/test/global/run/nonexistent_script_test.dart
index 8ff0a42..c2bba81 100644
--- a/test/global/run/nonexistent_script_test.dart
+++ b/test/global/run/nonexistent_script_test.dart
@@ -11,17 +11,23 @@
void main() {
test('errors if the script does not exist.', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', pubspec: {
- 'dev_dependencies': {'bar': '1.0.0'}
- });
+ server.serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'dev_dependencies': {'bar': '1.0.0'}
+ },
+ );
await runPub(args: ['global', 'activate', 'foo']);
var pub = await pubRun(global: true, args: ['foo:script']);
expect(
- pub.stderr,
- emits(
- "Could not find ${p.join("bin", "script.dart")} in package foo."));
+ pub.stderr,
+ emits(
+ "Could not find ${p.join("bin", "script.dart")} in package foo.",
+ ),
+ );
await pub.shouldExit(exit_codes.NO_INPUT);
});
}
diff --git a/test/global/run/package_api_test.dart b/test/global/run/package_api_test.dart
index 5db401b..21a54a8 100644
--- a/test/global/run/package_api_test.dart
+++ b/test/global/run/package_api_test.dart
@@ -12,11 +12,13 @@
test('an immutable application sees a file: package config', () async {
await servePackages()
..serve('bar', '1.0.0')
- ..serve('foo', '1.0.0', deps: {
- 'bar': '1.0.0'
- }, contents: [
- d.dir('bin', [
- d.file('script.dart', """
+ ..serve(
+ 'foo',
+ '1.0.0',
+ deps: {'bar': '1.0.0'},
+ contents: [
+ d.dir('bin', [
+ d.file('script.dart', """
import 'dart:isolate';
main() async {
@@ -28,8 +30,9 @@
Uri.parse('package:bar/resource.txt')));
}
""")
- ])
- ]);
+ ])
+ ],
+ );
await runPub(args: ['global', 'activate', 'foo']);
@@ -37,8 +40,11 @@
expect(pub.stdout, emitsThrough('null'));
- var packageConfigPath = p.join(d.sandbox, cachePath,
- 'global_packages/foo/.dart_tool/package_config.json');
+ var packageConfigPath = p.join(
+ d.sandbox,
+ cachePath,
+ 'global_packages/foo/.dart_tool/package_config.json',
+ );
expect(pub.stdout, emits(p.toUri(packageConfigPath).toString()));
var fooResourcePath =
@@ -56,9 +62,11 @@
await d.dir('foo', [d.libPubspec('foo', '1.0.0')]).create();
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': '../foo'}
- }),
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': '../foo'}
+ },
+ ),
d.dir('bin', [
d.file('script.dart', """
import 'dart:isolate';
diff --git a/test/global/run/recompiles_if_snapshot_is_out_of_date_test.dart b/test/global/run/recompiles_if_snapshot_is_out_of_date_test.dart
index 24e65bf..4c018b1 100644
--- a/test/global/run/recompiles_if_snapshot_is_out_of_date_test.dart
+++ b/test/global/run/recompiles_if_snapshot_is_out_of_date_test.dart
@@ -12,9 +12,13 @@
void main() {
test('recompiles a script if the snapshot is out-of-date', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', contents: [
- d.dir('bin', [d.file('script.dart', "main(args) => print('ok');")])
- ]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ contents: [
+ d.dir('bin', [d.file('script.dart', "main(args) => print('ok');")])
+ ],
+ );
await runPub(args: ['global', 'activate', 'foo']);
@@ -28,8 +32,15 @@
])
]).create();
- deleteEntry(p.join(d.dir(cachePath).io.path, 'global_packages', 'foo',
- 'bin', 'script.dart-$versionSuffix.snapshot'));
+ deleteEntry(
+ p.join(
+ d.dir(cachePath).io.path,
+ 'global_packages',
+ 'foo',
+ 'bin',
+ 'script.dart-$versionSuffix.snapshot',
+ ),
+ );
var pub = await pubRun(global: true, args: ['foo:script']);
// In the real world this would just print "hello!", but since we collect
// all output we see the precompilation messages as well.
@@ -40,8 +51,10 @@
await d.dir(cachePath, [
d.dir('global_packages', [
d.dir('foo', [
- d.dir('bin',
- [d.file('script.dart-$versionSuffix.snapshot', contains('ok'))])
+ d.dir(
+ 'bin',
+ [d.file('script.dart-$versionSuffix.snapshot', contains('ok'))],
+ )
])
])
]).validate();
diff --git a/test/global/run/runs_script_in_checked_mode_test.dart b/test/global/run/runs_script_in_checked_mode_test.dart
index d0511cf..5fccfb7 100644
--- a/test/global/run/runs_script_in_checked_mode_test.dart
+++ b/test/global/run/runs_script_in_checked_mode_test.dart
@@ -10,9 +10,13 @@
void main() {
test('runs a script with assertions enabled', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', contents: [
- d.dir('bin', [d.file('script.dart', 'main() { assert(false); }')])
- ]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ contents: [
+ d.dir('bin', [d.file('script.dart', 'main() { assert(false); }')])
+ ],
+ );
await runPub(args: ['global', 'activate', 'foo']);
diff --git a/test/global/run/runs_script_in_unchecked_mode_test.dart b/test/global/run/runs_script_in_unchecked_mode_test.dart
index ca752b2..e1018d9 100644
--- a/test/global/run/runs_script_in_unchecked_mode_test.dart
+++ b/test/global/run/runs_script_in_unchecked_mode_test.dart
@@ -17,9 +17,13 @@
void main() {
test('runs a script in unchecked mode by default', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', contents: [
- d.dir('bin', [d.file('script.dart', _script)])
- ]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ contents: [
+ d.dir('bin', [d.file('script.dart', _script)])
+ ],
+ );
await runPub(args: ['global', 'activate', 'foo']);
diff --git a/test/global/run/runs_script_test.dart b/test/global/run/runs_script_test.dart
index f3f0e99..decc65c 100644
--- a/test/global/run/runs_script_test.dart
+++ b/test/global/run/runs_script_test.dart
@@ -10,9 +10,13 @@
void main() {
test('runs a script in an activated package', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', contents: [
- d.dir('bin', [d.file('script.dart', "main(args) => print('ok');")])
- ]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ contents: [
+ d.dir('bin', [d.file('script.dart', "main(args) => print('ok');")])
+ ],
+ );
await runPub(args: ['global', 'activate', 'foo']);
diff --git a/test/global/run/unknown_package_test.dart b/test/global/run/unknown_package_test.dart
index adcb666..a5f3563 100644
--- a/test/global/run/unknown_package_test.dart
+++ b/test/global/run/unknown_package_test.dart
@@ -12,8 +12,9 @@
await servePackages();
await runPub(
- args: ['global', 'run', 'foo:bar'],
- error: startsWith('No active package foo.'),
- exitCode: exit_codes.DATA);
+ args: ['global', 'run', 'foo:bar'],
+ error: startsWith('No active package foo.'),
+ exitCode: exit_codes.DATA,
+ );
});
}
diff --git a/test/golden_file.dart b/test/golden_file.dart
index 3dcbfb6..515a6b8 100644
--- a/test/golden_file.dart
+++ b/test/golden_file.dart
@@ -217,8 +217,10 @@
/// Such a file can eg. be viewed in vscode with this plugin:
/// https://marketplace.visualstudio.com/items?itemName=iliazeus.vscode-ansi
void testWithGolden(
- String name, FutureOr<void> Function(GoldenTestContext ctx) fn,
- {bool colors = false}) {
+ String name,
+ FutureOr<void> Function(GoldenTestContext ctx) fn, {
+ bool colors = false,
+}) {
final ctx = GoldenTestContext._(
_findCurrentTestFilename(),
name,
diff --git a/test/help_test.dart b/test/help_test.dart
index e66f8a4..110ab84 100644
--- a/test/help_test.dart
+++ b/test/help_test.dart
@@ -28,10 +28,12 @@
final names = <String>{};
yield* cmds
.where((sub) => !sub.hidden && names.add(sub.name))
- .map((sub) => _extractCommands(
- [...parents, sub.name],
- sub.subcommands.values,
- ))
+ .map(
+ (sub) => _extractCommands(
+ [...parents, sub.name],
+ sub.subcommands.values,
+ ),
+ )
.expand((cmds) => cmds);
}
diff --git a/test/hosted/fail_gracefully_on_bad_version_listing_response_test.dart b/test/hosted/fail_gracefully_on_bad_version_listing_response_test.dart
index 7fb22a3..eb933d1 100644
--- a/test/hosted/fail_gracefully_on_bad_version_listing_response_test.dart
+++ b/test/hosted/fail_gracefully_on_bad_version_listing_response_test.dart
@@ -23,21 +23,26 @@
'GET',
RegExp('/api/packages/.*'),
expectAsync1((request) {
- return Response(200,
- body: jsonEncode({
- 'notTheRight': {'response': 'type'}
- }));
+ return Response(
+ 200,
+ body: jsonEncode({
+ 'notTheRight': {'response': 'type'}
+ }),
+ );
}),
);
- await d.appDir({'foo': '1.2.3'}).create();
+ await d.appDir(dependencies: {'foo': '1.2.3'}).create();
- await pubCommand(command,
- error: allOf([
- contains(
- 'Got badly formatted response trying to find package foo at http://localhost:'),
- contains('), version solving failed.')
- ]),
- exitCode: exit_codes.DATA);
+ await pubCommand(
+ command,
+ error: allOf([
+ contains(
+ 'Got badly formatted response trying to find package foo at http://localhost:',
+ ),
+ contains('), version solving failed.')
+ ]),
+ exitCode: exit_codes.DATA,
+ );
});
});
@@ -45,12 +50,14 @@
final server = await servePackages();
server.serve('foo', '1.2.3');
server.expect('GET', RegExp('/api/packages/.*'), (request) {
- return Response(200,
- body: jsonEncode({
- 'notTheRight': {'response': 'type'}
- }));
+ return Response(
+ 200,
+ body: jsonEncode({
+ 'notTheRight': {'response': 'type'}
+ }),
+ );
});
- await d.appDir({'foo': '1.2.3'}).create();
+ await d.appDir(dependencies: {'foo': '1.2.3'}).create();
await ctx.run(['get']);
});
@@ -59,12 +66,14 @@
final server = await servePackages();
server.serve('foo', '1.2.3');
server.expect('GET', RegExp('/api/packages/.*'), (request) {
- return Response(403,
- body: jsonEncode({
- 'notTheRight': {'response': 'type'}
- }));
+ return Response(
+ 403,
+ body: jsonEncode({
+ 'notTheRight': {'response': 'type'}
+ }),
+ );
});
- await d.appDir({'foo': '1.2.3'}).create();
+ await d.appDir(dependencies: {'foo': '1.2.3'}).create();
await ctx.run(['get']);
});
@@ -73,12 +82,14 @@
final server = await servePackages();
server.serve('foo', '1.2.3');
server.expect('GET', RegExp('/api/packages/.*'), (request) {
- return Response(401,
- body: jsonEncode({
- 'notTheRight': {'response': 'type'}
- }));
+ return Response(
+ 401,
+ body: jsonEncode({
+ 'notTheRight': {'response': 'type'}
+ }),
+ );
});
- await d.appDir({'foo': '1.2.3'}).create();
+ await d.appDir(dependencies: {'foo': '1.2.3'}).create();
await ctx.run(['get']);
});
@@ -87,15 +98,17 @@
final server = await servePackages();
server.serve('foo', '1.2.3');
server.expect('GET', RegExp('/api/packages/.*'), (request) {
- return Response(403,
- headers: {
- 'www-authenticate': 'Bearer realm="pub", message="<message>"',
- },
- body: jsonEncode({
- 'notTheRight': {'response': 'type'}
- }));
+ return Response(
+ 403,
+ headers: {
+ 'www-authenticate': 'Bearer realm="pub", message="<message>"',
+ },
+ body: jsonEncode({
+ 'notTheRight': {'response': 'type'}
+ }),
+ );
});
- await d.appDir({'foo': '1.2.3'}).create();
+ await d.appDir(dependencies: {'foo': '1.2.3'}).create();
await ctx.run(['get']);
});
@@ -104,15 +117,17 @@
final server = await servePackages();
server.serve('foo', '1.2.3');
server.expect('GET', RegExp('/api/packages/.*'), (request) {
- return Response(401,
- headers: {
- 'www-authenticate': 'Bearer realm="pub", message="<message>"',
- },
- body: jsonEncode({
- 'notTheRight': {'response': 'type'}
- }));
+ return Response(
+ 401,
+ headers: {
+ 'www-authenticate': 'Bearer realm="pub", message="<message>"',
+ },
+ body: jsonEncode({
+ 'notTheRight': {'response': 'type'}
+ }),
+ );
});
- await d.appDir({'foo': '1.2.3'}).create();
+ await d.appDir(dependencies: {'foo': '1.2.3'}).create();
await ctx.run(['get']);
});
diff --git a/test/hosted/fail_gracefully_on_invalid_url_test.dart b/test/hosted/fail_gracefully_on_invalid_url_test.dart
index 94922c0..dbe6b99 100644
--- a/test/hosted/fail_gracefully_on_invalid_url_test.dart
+++ b/test/hosted/fail_gracefully_on_invalid_url_test.dart
@@ -12,11 +12,13 @@
forBothPubGetAndUpgrade((command) {
test('fails gracefully if the url is invalid', () async {
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {
- 'hosted': {'name': 'foo', 'url': 'not@url-com'}
- }
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {
+ 'hosted': {'name': 'foo', 'url': 'not@url-com'}
+ }
+ },
+ )
]).create();
await pubCommand(
@@ -30,11 +32,13 @@
});
test('fails gracefully if the url has querystring', () async {
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {
- 'hosted': {'name': 'foo', 'url': 'http://example.foo/?key=value'}
- }
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {
+ 'hosted': {'name': 'foo', 'url': 'http://example.foo/?key=value'}
+ }
+ },
+ )
]).create();
await pubCommand(
@@ -49,11 +53,13 @@
test('fails gracefully if the url has fragment', () async {
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {
- 'hosted': {'name': 'foo', 'url': 'http://example.foo/#hash'}
- }
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {
+ 'hosted': {'name': 'foo', 'url': 'http://example.foo/#hash'}
+ }
+ },
+ )
]).create();
await pubCommand(
@@ -68,11 +74,13 @@
test('fails gracefully if the url has user-info (1)', () async {
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {
- 'hosted': {'name': 'foo', 'url': 'http://user:pwd@example.foo/'}
- }
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {
+ 'hosted': {'name': 'foo', 'url': 'http://user:pwd@example.foo/'}
+ }
+ },
+ )
]).create();
await pubCommand(
@@ -87,11 +95,13 @@
test('fails gracefully if the url has user-info (2)', () async {
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {
- 'hosted': {'name': 'foo', 'url': 'http://user@example.foo/'}
- }
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {
+ 'hosted': {'name': 'foo', 'url': 'http://user@example.foo/'}
+ }
+ },
+ )
]).create();
await pubCommand(
diff --git a/test/hosted/fail_gracefully_on_missing_package_test.dart b/test/hosted/fail_gracefully_on_missing_package_test.dart
index 66db87f..4487a4d 100644
--- a/test/hosted/fail_gracefully_on_missing_package_test.dart
+++ b/test/hosted/fail_gracefully_on_missing_package_test.dart
@@ -13,16 +13,18 @@
test('fails gracefully if the package does not exist', () async {
await servePackages();
- await d.appDir({'foo': '1.2.3'}).create();
+ await d.appDir(dependencies: {'foo': '1.2.3'}).create();
- await pubCommand(command,
- error: allOf([
- contains(
- "Because myapp depends on foo any which doesn't exist (could "
- 'not find package foo at http://localhost:'),
- contains('), version solving failed.')
- ]),
- exitCode: exit_codes.UNAVAILABLE);
+ await pubCommand(
+ command,
+ error: allOf([
+ contains(
+ "Because myapp depends on foo any which doesn't exist (could "
+ 'not find package foo at http://localhost:'),
+ contains('), version solving failed.')
+ ]),
+ exitCode: exit_codes.UNAVAILABLE,
+ );
});
});
@@ -32,18 +34,20 @@
final server = await servePackages();
server.serve('foo', '1.2.3', deps: {'bar': '^1.0.0'});
- await d.appDir({'foo': '1.2.3'}).create();
+ await d.appDir(dependencies: {'foo': '1.2.3'}).create();
- await pubCommand(command,
- error: allOf(
- contains('Because every version of foo depends on bar any which '
- 'doesn\'t exist (could not find package bar at '
- 'http://localhost:'),
- contains('), foo is forbidden.\n'
- 'So, because myapp depends on foo 1.2.3, '
- 'version solving failed.'),
- ),
- exitCode: exit_codes.UNAVAILABLE);
+ await pubCommand(
+ command,
+ error: allOf(
+ contains('Because every version of foo depends on bar any which '
+ 'doesn\'t exist (could not find package bar at '
+ 'http://localhost:'),
+ contains('), foo is forbidden.\n'
+ 'So, because myapp depends on foo 1.2.3, '
+ 'version solving failed.'),
+ ),
+ exitCode: exit_codes.UNAVAILABLE,
+ );
});
});
}
diff --git a/test/hosted/fail_gracefully_on_url_resolve_test.dart b/test/hosted/fail_gracefully_on_url_resolve_test.dart
index 0dff951..b36fa7d 100644
--- a/test/hosted/fail_gracefully_on_url_resolve_test.dart
+++ b/test/hosted/fail_gracefully_on_url_resolve_test.dart
@@ -12,20 +12,24 @@
forBothPubGetAndUpgrade((command) {
test('fails gracefully if the url does not resolve', () async {
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {
- 'hosted': {'name': 'foo', 'url': 'https://invalid-url.foo'}
- }
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {
+ 'hosted': {'name': 'foo', 'url': 'https://invalid-url.foo'}
+ }
+ },
+ )
]).create();
- await pubCommand(command,
- error: 'Got socket error trying to find package foo at '
- 'https://invalid-url.foo.',
- exitCode: exit_codes.UNAVAILABLE,
- environment: {
- 'PUB_MAX_HTTP_RETRIES': '2',
- });
+ await pubCommand(
+ command,
+ error: 'Got socket error trying to find package foo at '
+ 'https://invalid-url.foo.',
+ exitCode: exit_codes.UNAVAILABLE,
+ environment: {
+ 'PUB_MAX_HTTP_RETRIES': '2',
+ },
+ );
});
});
}
diff --git a/test/hosted/fail_gracefully_with_hint_test.dart b/test/hosted/fail_gracefully_with_hint_test.dart
index 4f1a326..7d95695 100644
--- a/test/hosted/fail_gracefully_with_hint_test.dart
+++ b/test/hosted/fail_gracefully_with_hint_test.dart
@@ -14,7 +14,7 @@
// Run the server so that we know what URL to use in the system cache.
(await servePackages()).serveErrors();
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await pubGet(
args: ['--offline'],
@@ -48,7 +48,7 @@
]),
]).create();
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await pubGet(
args: ['--offline'],
diff --git a/test/hosted/metadata_test.dart b/test/hosted/metadata_test.dart
index c705ac7..1e70051 100644
--- a/test/hosted/metadata_test.dart
+++ b/test/hosted/metadata_test.dart
@@ -15,20 +15,22 @@
final server = await servePackages();
server.serve('foo', '1.0.0');
- await d.appDir({'foo': '1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '1.0.0'}).create();
- await pubCommand(command,
- silent: allOf([
- contains('X-Pub-OS: ${Platform.operatingSystem}'),
- contains('X-Pub-Command: ${command.name}'),
- contains('X-Pub-Session-ID:'),
- contains('X-Pub-Environment: test-environment'),
+ await pubCommand(
+ command,
+ silent: allOf([
+ contains('X-Pub-OS: ${Platform.operatingSystem}'),
+ contains('X-Pub-Command: ${command.name}'),
+ contains('X-Pub-Session-ID:'),
+ contains('X-Pub-Environment: test-environment'),
- // We should send the reason when we request the pubspec and when we
- // request the tarball.
- matchesMultiple('X-Pub-Reason: direct', 2),
- isNot(contains('X-Pub-Reason: dev')),
- ]));
+ // We should send the reason when we request the pubspec and when we
+ // request the tarball.
+ matchesMultiple('X-Pub-Reason: direct', 2),
+ isNot(contains('X-Pub-Reason: dev')),
+ ]),
+ );
});
test('sends metadata headers for a dev dependency', () async {
@@ -42,52 +44,60 @@
})
]).create();
- await pubCommand(command,
- silent: allOf([
- contains('X-Pub-OS: ${Platform.operatingSystem}'),
- contains('X-Pub-Command: ${command.name}'),
- contains('X-Pub-Session-ID:'),
- contains('X-Pub-Environment: test-environment'),
+ await pubCommand(
+ command,
+ silent: allOf([
+ contains('X-Pub-OS: ${Platform.operatingSystem}'),
+ contains('X-Pub-Command: ${command.name}'),
+ contains('X-Pub-Session-ID:'),
+ contains('X-Pub-Environment: test-environment'),
- // We should send the reason when we request the pubspec and when we
- // request the tarball.
- matchesMultiple('X-Pub-Reason: dev', 2),
- isNot(contains('X-Pub-Reason: direct')),
- ]));
+ // We should send the reason when we request the pubspec and when we
+ // request the tarball.
+ matchesMultiple('X-Pub-Reason: dev', 2),
+ isNot(contains('X-Pub-Reason: direct')),
+ ]),
+ );
});
test('sends metadata headers for a transitive dependency', () async {
final server = await servePackages();
server.serve('bar', '1.0.0');
- await d.appDir({
- 'foo': {'path': '../foo'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'path': '../foo'}
+ },
+ ).create();
await d.dir('foo', [
d.libPubspec('foo', '1.0.0', deps: {'bar': '1.0.0'})
]).create();
- await pubCommand(command,
- silent: allOf([
- contains('X-Pub-OS: ${Platform.operatingSystem}'),
- contains('X-Pub-Command: ${command.name}'),
- contains('X-Pub-Session-ID:'),
- contains('X-Pub-Environment: test-environment'),
- isNot(contains('X-Pub-Reason:')),
- ]));
+ await pubCommand(
+ command,
+ silent: allOf([
+ contains('X-Pub-OS: ${Platform.operatingSystem}'),
+ contains('X-Pub-Command: ${command.name}'),
+ contains('X-Pub-Session-ID:'),
+ contains('X-Pub-Environment: test-environment'),
+ isNot(contains('X-Pub-Reason:')),
+ ]),
+ );
});
test("doesn't send metadata headers to a foreign server", () async {
var server = await startPackageServer()
..serve('foo', '1.0.0');
- await d.appDir({
- 'foo': {
- 'version': '1.0.0',
- 'hosted': {'name': 'foo', 'url': 'http://localhost:${server.port}'}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'version': '1.0.0',
+ 'hosted': {'name': 'foo', 'url': 'http://localhost:${server.port}'}
+ }
+ },
+ ).create();
await pubCommand(command, silent: isNot(contains('X-Pub-')));
});
@@ -95,13 +105,15 @@
test("doesn't send metadata headers when CI=true", () async {
(await servePackages()).serve('foo', '1.0.0');
- await d.appDir({'foo': '1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '1.0.0'}).create();
- await pubCommand(command,
- silent: isNot(contains('X-Pub-')),
- environment: {
- 'CI': 'true',
- });
+ await pubCommand(
+ command,
+ silent: isNot(contains('X-Pub-')),
+ environment: {
+ 'CI': 'true',
+ },
+ );
});
});
}
diff --git a/test/hosted/offline_test.dart b/test/hosted/offline_test.dart
index ca3dc80..5e54c76 100644
--- a/test/hosted/offline_test.dart
+++ b/test/hosted/offline_test.dart
@@ -9,7 +9,9 @@
import '../test_pub.dart';
Future<void> populateCache(
- Map<String, List<String>> versions, PackageServer server) async {
+ Map<String, List<String>> versions,
+ PackageServer server,
+) async {
for (final entry in versions.entries) {
for (final version in entry.value) {
server.serve(entry.key, version);
@@ -17,7 +19,7 @@
}
for (final entry in versions.entries) {
for (final version in entry.value) {
- await d.appDir({entry.key: version}).create();
+ await d.appDir(dependencies: {entry.key: version}).create();
await pubGet();
}
}
@@ -27,15 +29,18 @@
forBothPubGetAndUpgrade((command) {
test('upgrades a package using the cache', () async {
final server = await servePackages();
- await populateCache({
- 'foo': ['1.2.2', '1.2.3'],
- 'bar': ['1.2.3']
- }, server);
+ await populateCache(
+ {
+ 'foo': ['1.2.2', '1.2.3'],
+ 'bar': ['1.2.3']
+ },
+ server,
+ );
// Now serve only errors - to validate we are truly offline.
server.serveErrors();
- await d.appDir({'foo': 'any', 'bar': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any', 'bar': 'any'}).create();
String? warning;
if (command == RunCommand.upgrade) {
@@ -52,13 +57,16 @@
test('supports prerelease versions', () async {
final server = await servePackages();
- await populateCache({
- 'foo': ['1.2.3-alpha.1']
- }, server);
+ await populateCache(
+ {
+ 'foo': ['1.2.3-alpha.1']
+ },
+ server,
+ );
// Now serve only errors - to validate we are truly offline.
server.serveErrors();
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
String? warning;
if (command == RunCommand.upgrade) {
@@ -78,35 +86,43 @@
final server = await servePackages();
server.serveErrors();
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
- await pubCommand(command,
- args: ['--offline'],
- exitCode: exit_codes.UNAVAILABLE,
- error: equalsIgnoringWhitespace("""
+ await pubCommand(
+ command,
+ args: ['--offline'],
+ exitCode: exit_codes.UNAVAILABLE,
+ error: equalsIgnoringWhitespace("""
Because myapp depends on foo any which doesn't exist (could not find
package foo in cache), version solving failed.
Try again without --offline!
- """));
+ """),
+ );
});
test('fails gracefully if no cached versions match', () async {
final server = await servePackages();
- await populateCache({
- 'foo': ['1.2.2', '1.2.3']
- }, server);
+ await populateCache(
+ {
+ 'foo': ['1.2.2', '1.2.3']
+ },
+ server,
+ );
// Run the server so that we know what URL to use in the system cache.
server.serveErrors();
- await d.appDir({'foo': '>2.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '>2.0.0'}).create();
- await pubCommand(command,
- args: ['--offline'], error: equalsIgnoringWhitespace("""
+ await pubCommand(
+ command,
+ args: ['--offline'],
+ error: equalsIgnoringWhitespace("""
Because myapp depends on foo >2.0.0 which doesn't match any
versions, version solving failed.
- """));
+ """),
+ );
});
test(
@@ -117,31 +133,36 @@
// Run the server so that we know what URL to use in the system cache.
server.serveErrors();
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await createLockFile('myapp', hosted: {'foo': '1.2.4'});
- await pubCommand(command,
- args: ['--offline'],
- exitCode: exit_codes.UNAVAILABLE,
- error: equalsIgnoringWhitespace("""
+ await pubCommand(
+ command,
+ args: ['--offline'],
+ exitCode: exit_codes.UNAVAILABLE,
+ error: equalsIgnoringWhitespace("""
Because myapp depends on foo any which doesn't exist (could not find
package foo in cache), version solving failed.
Try again without --offline!
- """));
+ """),
+ );
});
test('downgrades to the version in the cache if necessary', () async {
final server = await servePackages();
- await populateCache({
- 'foo': ['1.2.2', '1.2.3']
- }, server);
+ await populateCache(
+ {
+ 'foo': ['1.2.2', '1.2.3']
+ },
+ server,
+ );
// Run the server so that we know what URL to use in the system cache.
server.serveErrors();
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await createLockFile('myapp', hosted: {'foo': '1.2.4'});
@@ -155,9 +176,12 @@
test('skips invalid cached versions', () async {
final server = await servePackages();
- await populateCache({
- 'foo': ['1.2.2', '1.2.3']
- }, server);
+ await populateCache(
+ {
+ 'foo': ['1.2.2', '1.2.3']
+ },
+ server,
+ );
// Run the server so that we know what URL to use in the system cache.
server.serveErrors();
@@ -166,7 +190,7 @@
d.file('random_filename', ''),
]).create();
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await pubCommand(command, args: ['--offline']);
@@ -178,9 +202,12 @@
test('skips invalid locked versions', () async {
final server = await servePackages();
- await populateCache({
- 'foo': ['1.2.2', '1.2.3']
- }, server);
+ await populateCache(
+ {
+ 'foo': ['1.2.2', '1.2.3']
+ },
+ server,
+ );
// Run the server so that we know what URL to use in the system cache.
server.serveErrors();
@@ -188,7 +215,7 @@
d.dir('foo-1.2.3', [d.file('pubspec.yaml', '{')])
]).create();
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await createLockFile('myapp', hosted: {'foo': '1.2.3'});
diff --git a/test/hosted/remove_removed_dependency_test.dart b/test/hosted/remove_removed_dependency_test.dart
index a0446c0..cabf3f2 100644
--- a/test/hosted/remove_removed_dependency_test.dart
+++ b/test/hosted/remove_removed_dependency_test.dart
@@ -14,7 +14,7 @@
..serve('foo', '1.0.0')
..serve('bar', '1.0.0');
- await d.appDir({'foo': 'any', 'bar': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any', 'bar': 'any'}).create();
await pubCommand(command);
await d.appPackageConfigFile([
@@ -22,7 +22,7 @@
d.packageConfigEntry(name: 'bar', version: '1.0.0'),
]).validate();
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await pubCommand(command);
diff --git a/test/hosted/remove_removed_transitive_dependency_test.dart b/test/hosted/remove_removed_transitive_dependency_test.dart
index 182ec3f..3f0c5d5 100644
--- a/test/hosted/remove_removed_transitive_dependency_test.dart
+++ b/test/hosted/remove_removed_transitive_dependency_test.dart
@@ -18,7 +18,7 @@
..serve('shared_dep', '1.0.0')
..serve('bar_dep', '1.0.0');
- await d.appDir({'foo': 'any', 'bar': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any', 'bar': 'any'}).create();
await pubCommand(command);
await d.appPackageConfigFile([
@@ -28,7 +28,7 @@
d.packageConfigEntry(name: 'bar_dep', version: '1.0.0'),
]).validate();
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await pubCommand(command);
diff --git a/test/hosted/short_syntax_test.dart b/test/hosted/short_syntax_test.dart
index da6d754..6ea6851 100644
--- a/test/hosted/short_syntax_test.dart
+++ b/test/hosted/short_syntax_test.dart
@@ -14,9 +14,13 @@
void main() {
setUp(() async {
final server = await servePackages();
- server.serve('foo', '1.2.3', pubspec: {
- 'environment': {'sdk': '^2.0.0'}
- });
+ server.serve(
+ 'foo',
+ '1.2.3',
+ pubspec: {
+ 'environment': {'sdk': '^2.0.0'}
+ },
+ );
});
forBothPubGetAndUpgrade((command) {
Future<void> testWith(dynamic dependency) async {
@@ -84,7 +88,9 @@
);
expect(
- lockFile['packages']['foo']['description']['url'], globalServer.url);
+ lockFile['packages']['foo']['description']['url'],
+ globalServer.url,
+ );
});
});
}
diff --git a/test/hosted/version_negotiation_test.dart b/test/hosted/version_negotiation_test.dart
index 44dbe7a..b5c3c14 100644
--- a/test/hosted/version_negotiation_test.dart
+++ b/test/hosted/version_negotiation_test.dart
@@ -14,43 +14,56 @@
test('sends the correct Accept header', () async {
await servePackages();
- await d.appDir({
- 'foo': {
- 'hosted': {'name': 'foo', 'url': globalServer.url}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'hosted': {'name': 'foo', 'url': globalServer.url}
+ }
+ },
+ ).create();
globalServer.expect('GET', '/api/packages/foo', (request) {
expect(
- request.headers['accept'], equals('application/vnd.pub.v2+json'));
+ request.headers['accept'],
+ equals('application/vnd.pub.v2+json'),
+ );
return shelf.Response(404);
});
- await pubCommand(command,
- output: anything, exitCode: exit_codes.UNAVAILABLE);
+ await pubCommand(
+ command,
+ output: anything,
+ exitCode: exit_codes.UNAVAILABLE,
+ );
});
test('prints a friendly error if the version is out-of-date', () async {
await servePackages();
- await d.appDir({
- 'foo': {
- 'hosted': {'name': 'foo', 'url': globalServer.url}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'hosted': {'name': 'foo', 'url': globalServer.url}
+ }
+ },
+ ).create();
var pub = await startPub(args: [command.name]);
globalServer.expect(
- 'GET', '/api/packages/foo', (request) => shelf.Response(406));
+ 'GET',
+ '/api/packages/foo',
+ (request) => shelf.Response(406),
+ );
await pub.shouldExit(1);
expect(
- pub.stderr,
- emitsLines(
- 'Pub 0.1.2+3 is incompatible with the current version of localhost.\n'
- 'Upgrade pub to the latest version and try again.'));
+ pub.stderr,
+ emitsLines(
+ 'Pub 3.1.2+3 is incompatible with the current version of localhost.\n'
+ 'Upgrade pub to the latest version and try again.'),
+ );
});
});
}
diff --git a/test/hosted/will_normalize_hosted_url_test.dart b/test/hosted/will_normalize_hosted_url_test.dart
index 904d3d8..3eae81f 100644
--- a/test/hosted/will_normalize_hosted_url_test.dart
+++ b/test/hosted/will_normalize_hosted_url_test.dart
@@ -22,11 +22,13 @@
expect(Uri.parse(globalServer.url).path, isEmpty);
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {
- 'hosted': {'name': 'foo', 'url': globalServer.url},
+ d.appPubspec(
+ dependencies: {
+ 'foo': {
+ 'hosted': {'name': 'foo', 'url': globalServer.url},
+ },
},
- }),
+ ),
]).create();
await pubCommand(
@@ -40,11 +42,13 @@
server.serve('foo', '1.2.3');
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {
- 'hosted': {'name': 'foo', 'url': '${globalServer.url}/'},
+ d.appPubspec(
+ dependencies: {
+ 'foo': {
+ 'hosted': {'name': 'foo', 'url': '${globalServer.url}/'},
+ },
},
- }),
+ ),
]).create();
await pubCommand(
@@ -63,11 +67,13 @@
);
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {
- 'hosted': {'name': 'foo', 'url': '${globalServer.url}//'},
+ d.appPubspec(
+ dependencies: {
+ 'foo': {
+ 'hosted': {'name': 'foo', 'url': '${globalServer.url}//'},
+ },
},
- }),
+ ),
]).create();
await pubCommand(
@@ -92,9 +98,13 @@
final res = await http.get(
Uri.parse('${globalServer.url}/$path'),
);
- return Response(res.statusCode, body: res.bodyBytes, headers: {
- 'Content-Type': res.headers['content-type']!,
- });
+ return Response(
+ res.statusCode,
+ body: res.bodyBytes,
+ headers: {
+ 'Content-Type': res.headers['content-type']!,
+ },
+ );
},
);
}
@@ -109,11 +119,13 @@
final normalizedUrl = '${globalServer.url}/my-folder/';
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {
- 'hosted': {'name': 'foo', 'url': testUrl},
+ d.appPubspec(
+ dependencies: {
+ 'foo': {
+ 'hosted': {'name': 'foo', 'url': testUrl},
+ },
},
- }),
+ ),
]).create();
await pubCommand(command);
@@ -133,11 +145,13 @@
final normalizedUrl = '${globalServer.url}/my-folder/';
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {
- 'hosted': {'name': 'foo', 'url': testUrl},
+ d.appPubspec(
+ dependencies: {
+ 'foo': {
+ 'hosted': {'name': 'foo', 'url': testUrl},
+ },
},
- }),
+ ),
]).create();
await pubCommand(command);
diff --git a/test/ignore_test.dart b/test/ignore_test.dart
index 9d80c5b..be14cda 100644
--- a/test/ignore_test.dart
+++ b/test/ignore_test.dart
@@ -59,25 +59,38 @@
isDir: isDir,
);
if (expected) {
- expect(r, isEmpty,
- reason: 'Expected "$path" to be ignored, it was NOT!');
+ expect(
+ r,
+ isEmpty,
+ reason: 'Expected "$path" to be ignored, it was NOT!',
+ );
} else {
- expect(r, [pathWithoutSlash],
- reason: 'Expected "$path" to NOT be ignored, it was IGNORED!');
+ expect(
+ r,
+ [pathWithoutSlash],
+ reason: 'Expected "$path" to NOT be ignored, it was IGNORED!',
+ );
}
// Also test that the logic of walking the tree works.
final r2 = Ignore.listFiles(
- includeDirs: true,
- listDir: listDir,
- ignoreForDir: ignoreForDir,
- isDir: isDir);
+ includeDirs: true,
+ listDir: listDir,
+ ignoreForDir: ignoreForDir,
+ isDir: isDir,
+ );
if (expected) {
- expect(r2, isNot(contains(pathWithoutSlash)),
- reason: 'Expected "$path" to be ignored, it was NOT!');
+ expect(
+ r2,
+ isNot(contains(pathWithoutSlash)),
+ reason: 'Expected "$path" to be ignored, it was NOT!',
+ );
} else {
- expect(r2, contains(pathWithoutSlash),
- reason: 'Expected "$path" to NOT be ignored, it was IGNORED!');
+ expect(
+ r2,
+ contains(pathWithoutSlash),
+ reason: 'Expected "$path" to NOT be ignored, it was IGNORED!',
+ );
}
expect(hasWarning, c.hasWarning);
});
@@ -99,8 +112,11 @@
ProcessResult runGit(List<String> args, {String? workingDirectory}) {
final executable = Platform.isWindows ? 'cmd' : 'git';
args = Platform.isWindows ? ['/c', 'git', ...args] : args;
- return Process.runSync(executable, args,
- workingDirectory: workingDirectory);
+ return Process.runSync(
+ executable,
+ args,
+ workingDirectory: workingDirectory,
+ );
}
group('git', () {
@@ -110,9 +126,12 @@
tmp = await Directory.systemTemp.createTemp('package-ignore-test-');
final ret = runGit(['init'], workingDirectory: tmp!.path);
- expect(ret.exitCode, equals(0),
- reason:
- 'Running "git init" failed. StdErr: ${ret.stderr} StdOut: ${ret.stdout}');
+ expect(
+ ret.exitCode,
+ equals(0),
+ reason:
+ 'Running "git init" failed. StdErr: ${ret.stderr} StdOut: ${ret.stdout}',
+ );
});
tearDownAll(() async {
@@ -132,41 +151,48 @@
) {
final casing = 'with ignoreCase = $ignoreCase';
final result = expected ? 'IGNORED' : 'NOT ignored';
- test('${c.name}: git check-ignore "$path" is $result $casing', () async {
- expect(
- runGit(
- ['config', '--local', 'core.ignoreCase', ignoreCase.toString()],
- workingDirectory: tmp!.path,
- ).exitCode,
- anyOf(0, 1),
- reason: 'Running "git config --local core.ignoreCase ..." failed',
- );
-
- for (final directory in c.patterns.keys) {
- final resolvedDirectory =
- directory == '' ? tmp!.uri : tmp!.uri.resolve('$directory/');
- Directory.fromUri(resolvedDirectory).createSync(recursive: true);
- final gitIgnore =
- File.fromUri(resolvedDirectory.resolve('.gitignore'));
- gitIgnore.writeAsStringSync(
- '${c.patterns[directory]!.join('\n')}\n',
+ test(
+ '${c.name}: git check-ignore "$path" is $result $casing',
+ () async {
+ expect(
+ runGit(
+ ['config', '--local', 'core.ignoreCase', ignoreCase.toString()],
+ workingDirectory: tmp!.path,
+ ).exitCode,
+ anyOf(0, 1),
+ reason: 'Running "git config --local core.ignoreCase ..." failed',
);
- }
- final process = runGit(
- ['-C', tmp!.path, 'check-ignore', '--no-index', path],
- workingDirectory: tmp!.path);
- expect(process.exitCode, anyOf(0, 1),
- reason: 'Running "git check-ignore" failed');
- final ignored = process.exitCode == 0;
- if (expected != ignored) {
- if (expected) {
- fail('Expected "$path" to be ignored, it was NOT!');
+
+ for (final directory in c.patterns.keys) {
+ final resolvedDirectory =
+ directory == '' ? tmp!.uri : tmp!.uri.resolve('$directory/');
+ Directory.fromUri(resolvedDirectory).createSync(recursive: true);
+ final gitIgnore =
+ File.fromUri(resolvedDirectory.resolve('.gitignore'));
+ gitIgnore.writeAsStringSync(
+ '${c.patterns[directory]!.join('\n')}\n',
+ );
}
- fail('Expected "$path" to NOT be ignored, it was IGNORED!');
- }
- },
- skip: Platform.isMacOS || // System `git` on mac has issues...
- c.skipOnWindows && Platform.isWindows);
+ final process = runGit(
+ ['-C', tmp!.path, 'check-ignore', '--no-index', path],
+ workingDirectory: tmp!.path,
+ );
+ expect(
+ process.exitCode,
+ anyOf(0, 1),
+ reason: 'Running "git check-ignore" failed',
+ );
+ final ignored = process.exitCode == 0;
+ if (expected != ignored) {
+ if (expected) {
+ fail('Expected "$path" to be ignored, it was NOT!');
+ }
+ fail('Expected "$path" to NOT be ignored, it was IGNORED!');
+ }
+ },
+ skip: Platform.isMacOS || // System `git` on mac has issues...
+ c.skipOnWindows && Platform.isWindows,
+ );
}
for (final c in testData) {
@@ -428,112 +454,124 @@
// Special characters from RegExp that are not special in .gitignore
for (final c in r'(){}+.^$|'.split('')) ...[
TestData.single(
- '${c}file.txt',
- {
- '${c}file.txt': true,
- 'file.txt': false,
- 'file.txt$c': false,
- },
- skipOnWindows: c == '^' || c == '|'),
+ '${c}file.txt',
+ {
+ '${c}file.txt': true,
+ 'file.txt': false,
+ 'file.txt$c': false,
+ },
+ skipOnWindows: c == '^' || c == '|',
+ ),
TestData.single(
- 'file.txt$c',
- {
- 'file.txt$c': true,
- 'file.txt': false,
- '${c}file.txt': false,
- },
- skipOnWindows: c == '^' || c == '|'),
+ 'file.txt$c',
+ {
+ 'file.txt$c': true,
+ 'file.txt': false,
+ '${c}file.txt': false,
+ },
+ skipOnWindows: c == '^' || c == '|',
+ ),
TestData.single(
- 'fi${c}l)e.txt',
- {
- 'fi${c}l)e.txt': true,
- 'f${c}il)e.txt': false,
- 'fil)e.txt': false,
- },
- skipOnWindows: c == '^' || c == '|'),
+ 'fi${c}l)e.txt',
+ {
+ 'fi${c}l)e.txt': true,
+ 'f${c}il)e.txt': false,
+ 'fil)e.txt': false,
+ },
+ skipOnWindows: c == '^' || c == '|',
+ ),
TestData.single(
- 'fi${c}l}e.txt',
- {
- 'fi${c}l}e.txt': true,
- 'f${c}il}e.txt': false,
- 'fil}e.txt': false,
- },
- skipOnWindows: c == '^' || c == '|'),
+ 'fi${c}l}e.txt',
+ {
+ 'fi${c}l}e.txt': true,
+ 'f${c}il}e.txt': false,
+ 'fil}e.txt': false,
+ },
+ skipOnWindows: c == '^' || c == '|',
+ ),
],
// Special characters from RegExp that are also special in .gitignore
// can be escaped.
for (final c in r'[]*?\'.split('')) ...[
TestData.single(
- '\\${c}file.txt',
- {
- '${c}file.txt': true,
- 'file.txt': false,
- 'file.txt$c': false,
- },
- skipOnWindows: c == r'\'),
+ '\\${c}file.txt',
+ {
+ '${c}file.txt': true,
+ 'file.txt': false,
+ 'file.txt$c': false,
+ },
+ skipOnWindows: c == r'\',
+ ),
TestData.single(
- 'file.txt\\$c',
- {
- 'file.txt$c': true,
- 'file.txt': false,
- '${c}file.txt': false,
- },
- skipOnWindows: c == r'\'),
+ 'file.txt\\$c',
+ {
+ 'file.txt$c': true,
+ 'file.txt': false,
+ '${c}file.txt': false,
+ },
+ skipOnWindows: c == r'\',
+ ),
TestData.single(
- 'fi\\${c}l)e.txt',
- {
- 'fi${c}l)e.txt': true,
- 'f${c}il)e.txt': false,
- 'fil)e.txt': false,
- },
- skipOnWindows: c == r'\'),
+ 'fi\\${c}l)e.txt',
+ {
+ 'fi${c}l)e.txt': true,
+ 'f${c}il)e.txt': false,
+ 'fil)e.txt': false,
+ },
+ skipOnWindows: c == r'\',
+ ),
TestData.single(
- 'fi\\${c}l}e.txt',
- {
- 'fi${c}l}e.txt': true,
- 'f${c}il}e.txt': false,
- 'fil}e.txt': false,
- },
- skipOnWindows: c == r'\'),
+ 'fi\\${c}l}e.txt',
+ {
+ 'fi${c}l}e.txt': true,
+ 'f${c}il}e.txt': false,
+ 'fil}e.txt': false,
+ },
+ skipOnWindows: c == r'\',
+ ),
],
// Special characters from RegExp can always be escaped
for (final c in r'()[]{}*+?.^$|\'.split('')) ...[
TestData.single(
- '\\${c}file.txt',
- {
- '${c}file.txt': true,
- 'file.txt': false,
- 'file.txt$c': false,
- },
- skipOnWindows: c == '^' || c == '|' || c == r'\'),
+ '\\${c}file.txt',
+ {
+ '${c}file.txt': true,
+ 'file.txt': false,
+ 'file.txt$c': false,
+ },
+ skipOnWindows: c == '^' || c == '|' || c == r'\',
+ ),
TestData.single(
- 'file.txt\\$c',
- {
- 'file.txt$c': true,
- 'file.txt': false,
- '${c}file.txt': false,
- },
- skipOnWindows: c == '^' || c == '|' || c == r'\'),
+ 'file.txt\\$c',
+ {
+ 'file.txt$c': true,
+ 'file.txt': false,
+ '${c}file.txt': false,
+ },
+ skipOnWindows: c == '^' || c == '|' || c == r'\',
+ ),
TestData.single(
- 'file\\$c.txt',
- {
- 'file$c.txt': true,
- 'file.txt': false,
- '${c}file.txt': false,
- },
- skipOnWindows: c == '^' || c == '|' || c == r'\'),
+ 'file\\$c.txt',
+ {
+ 'file$c.txt': true,
+ 'file.txt': false,
+ '${c}file.txt': false,
+ },
+ skipOnWindows: c == '^' || c == '|' || c == r'\',
+ ),
],
// Ending in backslash (unescaped)
TestData.single(
- 'file.txt\\',
- {
- 'file.txt\\': false,
- 'file.txt ': false,
- 'file.txt\n': false,
- 'file.txt': false,
- },
- hasWarning: true,
- skipOnWindows: true),
+ 'file.txt\\',
+ {
+ 'file.txt\\': false,
+ 'file.txt ': false,
+ 'file.txt\n': false,
+ 'file.txt': false,
+ },
+ hasWarning: true,
+ skipOnWindows: true,
+ ),
TestData.single(r'file.txt\n', {
'file.txt\\\n': false,
'file.txt ': false,
@@ -541,23 +579,25 @@
'file.txt': false,
}),
TestData.single(
- '**\\',
- {
- 'file.txt\\\n': false,
- 'file.txt ': false,
- 'file.txt\n': false,
- 'file.txt': false,
- },
- hasWarning: true),
+ '**\\',
+ {
+ 'file.txt\\\n': false,
+ 'file.txt ': false,
+ 'file.txt\n': false,
+ 'file.txt': false,
+ },
+ hasWarning: true,
+ ),
TestData.single(
- '*\\',
- {
- 'file.txt\\\n': false,
- 'file.txt ': false,
- 'file.txt\n': false,
- 'file.txt': false,
- },
- hasWarning: true),
+ '*\\',
+ {
+ 'file.txt\\\n': false,
+ 'file.txt ': false,
+ 'file.txt\n': false,
+ 'file.txt': false,
+ },
+ hasWarning: true,
+ ),
// ? matches anything except /
TestData.single('?', {
'f': true,
@@ -627,84 +667,91 @@
}),
// Empty character classes
TestData.single(
- 'a[]c',
- {
- 'abc': false,
- 'ac': false,
- 'a': false,
- 'a[]c': false,
- 'c': false,
- },
- hasWarning: true),
+ 'a[]c',
+ {
+ 'abc': false,
+ 'ac': false,
+ 'a': false,
+ 'a[]c': false,
+ 'c': false,
+ },
+ hasWarning: true,
+ ),
TestData.single(
- 'a[]',
- {
- 'abc': false,
- 'ac': false,
- 'a': false,
- 'a[]': false,
- 'c': false,
- },
- hasWarning: true),
+ 'a[]',
+ {
+ 'abc': false,
+ 'ac': false,
+ 'a': false,
+ 'a[]': false,
+ 'c': false,
+ },
+ hasWarning: true,
+ ),
// Invalid character classes
TestData.single(
- r'a[\]',
- {
- 'abc': false,
- 'ac': false,
- 'a': false,
- 'a\\': false,
- 'a[]': false,
- 'a[': false,
- 'a[\\]': false,
- 'c': false,
- },
- hasWarning: true,
- skipOnWindows: true),
+ r'a[\]',
+ {
+ 'abc': false,
+ 'ac': false,
+ 'a': false,
+ 'a\\': false,
+ 'a[]': false,
+ 'a[': false,
+ 'a[\\]': false,
+ 'c': false,
+ },
+ hasWarning: true,
+ skipOnWindows: true,
+ ),
TestData.single(
- r'a[\\\]',
- {
- 'abc': false,
- 'ac': false,
- 'a': false,
- 'a[]': false,
- 'a[': false,
- 'a[\\]': false,
- 'c': false,
- },
- hasWarning: true,
- skipOnWindows: true),
+ r'a[\\\]',
+ {
+ 'abc': false,
+ 'ac': false,
+ 'a': false,
+ 'a[]': false,
+ 'a[': false,
+ 'a[\\]': false,
+ 'c': false,
+ },
+ hasWarning: true,
+ skipOnWindows: true,
+ ),
// Character classes with special characters
TestData.single(
- r'a[\\]',
- {
- 'a': false,
- 'ab': false,
- 'a[]': false,
- 'a[': false,
- 'a\\': true,
- },
- skipOnWindows: true),
+ r'a[\\]',
+ {
+ 'a': false,
+ 'ab': false,
+ 'a[]': false,
+ 'a[': false,
+ 'a\\': true,
+ },
+ skipOnWindows: true,
+ ),
TestData.single(
- r'a[^b]',
- {
- 'a': false,
- 'ab': false,
- 'ac': true,
- 'a[': true,
- 'a\\': true,
- },
- skipOnWindows: true),
+ r'a[^b]',
+ {
+ 'a': false,
+ 'ab': false,
+ 'ac': true,
+ 'a[': true,
+ 'a\\': true,
+ },
+ skipOnWindows: true,
+ ),
TestData.single(
- r'a[!b]',
- {
- 'a': false,
- 'ab': false,
- 'ac': true,
- 'a[': true,
- 'a\\': true,
- },
- skipOnWindows: true),
+ r'a[!b]',
+ {
+ 'a': false,
+ 'ab': false,
+ 'ac': true,
+ 'a[': true,
+ 'a\\': true,
+ },
+ skipOnWindows: true,
+ ),
TestData.single(r'a[[]', {
'a': false,
'ab': false,
diff --git a/test/io_test.dart b/test/io_test.dart
index d94e289..aa5a694 100644
--- a/test/io_test.dart
+++ b/test/io_test.dart
@@ -25,43 +25,56 @@
(e) =>
e is ApplicationException &&
e.message.contains(
- 'Pub failed to run subprocess `$nonExisting`: ProcessException:'),
+ 'Pub failed to run subprocess `$nonExisting`: ProcessException:',
+ ),
),
);
- expect(() => runProcess(nonExisting, ['a', 'b', 'c']),
- throwsNiceErrorMessage);
- expect(() => startProcess(nonExisting, ['a', 'b', 'c']),
- throwsNiceErrorMessage);
- expect(() => runProcessSync(nonExisting, ['a', 'b', 'c']),
- throwsNiceErrorMessage);
+ expect(
+ () => runProcess(nonExisting, ['a', 'b', 'c']),
+ throwsNiceErrorMessage,
+ );
+ expect(
+ () => startProcess(nonExisting, ['a', 'b', 'c']),
+ throwsNiceErrorMessage,
+ );
+ expect(
+ () => runProcessSync(nonExisting, ['a', 'b', 'c']),
+ throwsNiceErrorMessage,
+ );
});
});
group('listDir', () {
test('ignores hidden files by default', () {
- expect(withTempDir((temp) {
- writeTextFile(path.join(temp, 'file1.txt'), '');
- writeTextFile(path.join(temp, 'file2.txt'), '');
- writeTextFile(path.join(temp, '.file3.txt'), '');
- _createDir(path.join(temp, '.subdir'));
- writeTextFile(path.join(temp, '.subdir', 'file3.txt'), '');
+ expect(
+ withTempDir((temp) {
+ writeTextFile(path.join(temp, 'file1.txt'), '');
+ writeTextFile(path.join(temp, 'file2.txt'), '');
+ writeTextFile(path.join(temp, '.file3.txt'), '');
+ _createDir(path.join(temp, '.subdir'));
+ writeTextFile(path.join(temp, '.subdir', 'file3.txt'), '');
- expect(
+ expect(
listDir(temp, recursive: true),
unorderedEquals(
- [path.join(temp, 'file1.txt'), path.join(temp, 'file2.txt')]));
- }), completes);
+ [path.join(temp, 'file1.txt'), path.join(temp, 'file2.txt')],
+ ),
+ );
+ }),
+ completes,
+ );
});
test('includes hidden files when told to', () {
- expect(withTempDir((temp) {
- writeTextFile(path.join(temp, 'file1.txt'), '');
- writeTextFile(path.join(temp, 'file2.txt'), '');
- writeTextFile(path.join(temp, '.file3.txt'), '');
- _createDir(path.join(temp, '.subdir'));
- writeTextFile(path.join(temp, '.subdir', 'file3.txt'), '');
+ expect(
+ withTempDir((temp) {
+ writeTextFile(path.join(temp, 'file1.txt'), '');
+ writeTextFile(path.join(temp, 'file2.txt'), '');
+ writeTextFile(path.join(temp, '.file3.txt'), '');
+ _createDir(path.join(temp, '.subdir'));
+ writeTextFile(path.join(temp, '.subdir', 'file3.txt'), '');
- expect(
+ expect(
listDir(temp, recursive: true, includeHidden: true),
unorderedEquals([
path.join(temp, 'file1.txt'),
@@ -69,162 +82,232 @@
path.join(temp, '.file3.txt'),
path.join(temp, '.subdir'),
path.join(temp, '.subdir', 'file3.txt')
- ]));
- }), completes);
+ ]),
+ );
+ }),
+ completes,
+ );
});
test("doesn't ignore hidden files above the directory being listed", () {
- expect(withTempDir((temp) {
- var dir = path.join(temp, '.foo', 'bar');
- ensureDir(dir);
- writeTextFile(path.join(dir, 'file1.txt'), '');
- writeTextFile(path.join(dir, 'file2.txt'), '');
- writeTextFile(path.join(dir, 'file3.txt'), '');
+ expect(
+ withTempDir((temp) {
+ var dir = path.join(temp, '.foo', 'bar');
+ ensureDir(dir);
+ writeTextFile(path.join(dir, 'file1.txt'), '');
+ writeTextFile(path.join(dir, 'file2.txt'), '');
+ writeTextFile(path.join(dir, 'file3.txt'), '');
- expect(
+ expect(
listDir(dir, recursive: true),
unorderedEquals([
path.join(dir, 'file1.txt'),
path.join(dir, 'file2.txt'),
path.join(dir, 'file3.txt')
- ]));
- }), completes);
+ ]),
+ );
+ }),
+ completes,
+ );
});
});
group('canonicalize', () {
test('resolves a non-link', () {
- expect(_withCanonicalTempDir((temp) {
- var filePath = path.join(temp, 'file');
- writeTextFile(filePath, '');
- expect(canonicalize(filePath), equals(filePath));
- }), completes);
+ expect(
+ _withCanonicalTempDir((temp) {
+ var filePath = path.join(temp, 'file');
+ writeTextFile(filePath, '');
+ expect(canonicalize(filePath), equals(filePath));
+ }),
+ completes,
+ );
});
test('resolves a non-existent file', () {
- expect(_withCanonicalTempDir((temp) {
- expect(canonicalize(path.join(temp, 'nothing')),
- equals(path.join(temp, 'nothing')));
- }), completes);
+ expect(
+ _withCanonicalTempDir((temp) {
+ expect(
+ canonicalize(path.join(temp, 'nothing')),
+ equals(path.join(temp, 'nothing')),
+ );
+ }),
+ completes,
+ );
});
test('resolves a symlink', () {
- expect(_withCanonicalTempDir((temp) {
- _createDir(path.join(temp, 'linked-dir'));
- createSymlink(path.join(temp, 'linked-dir'), path.join(temp, 'dir'));
- expect(canonicalize(path.join(temp, 'dir')),
- equals(path.join(temp, 'linked-dir')));
- }), completes);
+ expect(
+ _withCanonicalTempDir((temp) {
+ _createDir(path.join(temp, 'linked-dir'));
+ createSymlink(path.join(temp, 'linked-dir'), path.join(temp, 'dir'));
+ expect(
+ canonicalize(path.join(temp, 'dir')),
+ equals(path.join(temp, 'linked-dir')),
+ );
+ }),
+ completes,
+ );
});
test('resolves a relative symlink', () {
- expect(_withCanonicalTempDir((temp) {
- _createDir(path.join(temp, 'linked-dir'));
- createSymlink(path.join(temp, 'linked-dir'), path.join(temp, 'dir'),
- relative: true);
- expect(canonicalize(path.join(temp, 'dir')),
- equals(path.join(temp, 'linked-dir')));
- }), completes);
+ expect(
+ _withCanonicalTempDir((temp) {
+ _createDir(path.join(temp, 'linked-dir'));
+ createSymlink(
+ path.join(temp, 'linked-dir'),
+ path.join(temp, 'dir'),
+ relative: true,
+ );
+ expect(
+ canonicalize(path.join(temp, 'dir')),
+ equals(path.join(temp, 'linked-dir')),
+ );
+ }),
+ completes,
+ );
});
test('resolves a single-level horizontally recursive symlink', () {
- expect(_withCanonicalTempDir((temp) {
- var linkPath = path.join(temp, 'foo');
- createSymlink(linkPath, linkPath);
- expect(canonicalize(linkPath), equals(linkPath));
- }), completes);
+ expect(
+ _withCanonicalTempDir((temp) {
+ var linkPath = path.join(temp, 'foo');
+ createSymlink(linkPath, linkPath);
+ expect(canonicalize(linkPath), equals(linkPath));
+ }),
+ completes,
+ );
});
test('resolves a multi-level horizontally recursive symlink', () {
- expect(_withCanonicalTempDir((temp) {
- var fooPath = path.join(temp, 'foo');
- var barPath = path.join(temp, 'bar');
- var bazPath = path.join(temp, 'baz');
- createSymlink(barPath, fooPath);
- createSymlink(bazPath, barPath);
- createSymlink(fooPath, bazPath);
- expect(canonicalize(fooPath), equals(fooPath));
- expect(canonicalize(barPath), equals(barPath));
- expect(canonicalize(bazPath), equals(bazPath));
+ expect(
+ _withCanonicalTempDir((temp) {
+ var fooPath = path.join(temp, 'foo');
+ var barPath = path.join(temp, 'bar');
+ var bazPath = path.join(temp, 'baz');
+ createSymlink(barPath, fooPath);
+ createSymlink(bazPath, barPath);
+ createSymlink(fooPath, bazPath);
+ expect(canonicalize(fooPath), equals(fooPath));
+ expect(canonicalize(barPath), equals(barPath));
+ expect(canonicalize(bazPath), equals(bazPath));
- createSymlink(fooPath, path.join(temp, 'outer'));
- expect(canonicalize(path.join(temp, 'outer')), equals(fooPath));
- }), completes);
+ createSymlink(fooPath, path.join(temp, 'outer'));
+ expect(canonicalize(path.join(temp, 'outer')), equals(fooPath));
+ }),
+ completes,
+ );
});
test('resolves a broken symlink', () {
- expect(_withCanonicalTempDir((temp) {
- createSymlink(path.join(temp, 'nonexistent'), path.join(temp, 'foo'));
- expect(canonicalize(path.join(temp, 'foo')),
- equals(path.join(temp, 'nonexistent')));
- }), completes);
+ expect(
+ _withCanonicalTempDir((temp) {
+ createSymlink(path.join(temp, 'nonexistent'), path.join(temp, 'foo'));
+ expect(
+ canonicalize(path.join(temp, 'foo')),
+ equals(path.join(temp, 'nonexistent')),
+ );
+ }),
+ completes,
+ );
});
test('resolves multiple nested symlinks', () {
- expect(_withCanonicalTempDir((temp) {
- var dir1 = path.join(temp, 'dir1');
- var dir2 = path.join(temp, 'dir2');
- var subdir1 = path.join(dir1, 'subdir1');
- var subdir2 = path.join(dir2, 'subdir2');
- _createDir(dir2);
- _createDir(subdir2);
- createSymlink(dir2, dir1);
- createSymlink(subdir2, subdir1);
- expect(canonicalize(path.join(subdir1, 'file')),
- equals(path.join(subdir2, 'file')));
- }), completes);
+ expect(
+ _withCanonicalTempDir((temp) {
+ var dir1 = path.join(temp, 'dir1');
+ var dir2 = path.join(temp, 'dir2');
+ var subdir1 = path.join(dir1, 'subdir1');
+ var subdir2 = path.join(dir2, 'subdir2');
+ _createDir(dir2);
+ _createDir(subdir2);
+ createSymlink(dir2, dir1);
+ createSymlink(subdir2, subdir1);
+ expect(
+ canonicalize(path.join(subdir1, 'file')),
+ equals(path.join(subdir2, 'file')),
+ );
+ }),
+ completes,
+ );
});
test('resolves a nested vertical symlink', () {
- expect(_withCanonicalTempDir((temp) {
- var dir1 = path.join(temp, 'dir1');
- var dir2 = path.join(temp, 'dir2');
- var subdir = path.join(dir1, 'subdir');
- _createDir(dir1);
- _createDir(dir2);
- createSymlink(dir2, subdir);
- expect(canonicalize(path.join(subdir, 'file')),
- equals(path.join(dir2, 'file')));
- }), completes);
+ expect(
+ _withCanonicalTempDir((temp) {
+ var dir1 = path.join(temp, 'dir1');
+ var dir2 = path.join(temp, 'dir2');
+ var subdir = path.join(dir1, 'subdir');
+ _createDir(dir1);
+ _createDir(dir2);
+ createSymlink(dir2, subdir);
+ expect(
+ canonicalize(path.join(subdir, 'file')),
+ equals(path.join(dir2, 'file')),
+ );
+ }),
+ completes,
+ );
});
test('resolves a vertically recursive symlink', () {
- expect(_withCanonicalTempDir((temp) {
- var dir = path.join(temp, 'dir');
- var subdir = path.join(dir, 'subdir');
- _createDir(dir);
- createSymlink(dir, subdir);
- expect(
- canonicalize(path.join(
- temp, 'dir', 'subdir', 'subdir', 'subdir', 'subdir', 'file')),
- equals(path.join(dir, 'file')));
- }), completes);
+ expect(
+ _withCanonicalTempDir((temp) {
+ var dir = path.join(temp, 'dir');
+ var subdir = path.join(dir, 'subdir');
+ _createDir(dir);
+ createSymlink(dir, subdir);
+ expect(
+ canonicalize(
+ path.join(
+ temp,
+ 'dir',
+ 'subdir',
+ 'subdir',
+ 'subdir',
+ 'subdir',
+ 'file',
+ ),
+ ),
+ equals(path.join(dir, 'file')),
+ );
+ }),
+ completes,
+ );
});
test('resolves a symlink that links to a path that needs more resolving',
() {
- expect(_withCanonicalTempDir((temp) {
- var dir = path.join(temp, 'dir');
- var linkdir = path.join(temp, 'linkdir');
- var linkfile = path.join(dir, 'link');
- _createDir(dir);
- createSymlink(dir, linkdir);
- createSymlink(path.join(linkdir, 'file'), linkfile);
- expect(canonicalize(linkfile), equals(path.join(dir, 'file')));
- }), completes);
+ expect(
+ _withCanonicalTempDir((temp) {
+ var dir = path.join(temp, 'dir');
+ var linkdir = path.join(temp, 'linkdir');
+ var linkfile = path.join(dir, 'link');
+ _createDir(dir);
+ createSymlink(dir, linkdir);
+ createSymlink(path.join(linkdir, 'file'), linkfile);
+ expect(canonicalize(linkfile), equals(path.join(dir, 'file')));
+ }),
+ completes,
+ );
});
test('resolves a pair of pathologically-recursive symlinks', () {
- expect(_withCanonicalTempDir((temp) {
- var foo = path.join(temp, 'foo');
- var subfoo = path.join(foo, 'subfoo');
- var bar = path.join(temp, 'bar');
- var subbar = path.join(bar, 'subbar');
- createSymlink(subbar, foo);
- createSymlink(subfoo, bar);
- expect(canonicalize(subfoo),
- equals(path.join(subfoo, 'subbar', 'subfoo')));
- }), completes);
+ expect(
+ _withCanonicalTempDir((temp) {
+ var foo = path.join(temp, 'foo');
+ var subfoo = path.join(foo, 'subfoo');
+ var bar = path.join(temp, 'bar');
+ var subbar = path.join(bar, 'subbar');
+ createSymlink(subbar, foo);
+ createSymlink(subfoo, bar);
+ expect(
+ canonicalize(subfoo),
+ equals(path.join(subfoo, 'subbar', 'subfoo')),
+ );
+ }),
+ completes,
+ );
});
});
@@ -232,16 +315,17 @@
test('decompresses simple archive', () async {
await withTempDir((tempDir) async {
await extractTarGz(
- Stream.fromIterable(
- [
- base64Decode(
- 'H4sIAP2weF4AA+3S0QqCMBiG4V2KeAE1nfuF7maViNBqzDyQ6N4z6yCIogOtg97ncAz2wTvfuxCW'
- 'alZ6UFqttIiUYpXObWlzM57fqcyIkcxoU2ZKZyYvtErsvLNuuvboYpKotqm7uPUv74XYeBf7Oh66'
- '8I1dX+LH/qFbt6HaLHrnd9O/cQ0sxZv++UP/Qob+1srQX08/5dmf9z+le+erdJWOHyE9/3oPAAAA'
- 'AAAAAAAAAAAAgM9dALkoaRMAKAAA')
- ],
- ),
- tempDir);
+ Stream.fromIterable(
+ [
+ base64Decode(
+ 'H4sIAP2weF4AA+3S0QqCMBiG4V2KeAE1nfuF7maViNBqzDyQ6N4z6yCIogOtg97ncAz2wTvfuxCW'
+ 'alZ6UFqttIiUYpXObWlzM57fqcyIkcxoU2ZKZyYvtErsvLNuuvboYpKotqm7uPUv74XYeBf7Oh66'
+ '8I1dX+LH/qFbt6HaLHrnd9O/cQ0sxZv++UP/Qob+1srQX08/5dmf9z+le+erdJWOHyE9/3oPAAAA'
+ 'AAAAAAAAAAAAgM9dALkoaRMAKAAA')
+ ],
+ ),
+ tempDir,
+ );
await d.dir(appPath, [
d.rawPubspec({
@@ -254,19 +338,21 @@
test('throws on tar error', () async {
await withTempDir((tempDir) async {
await expectLater(
- () async => await extractTarGz(
- Stream.fromIterable(
- [
- base64Decode(
- // Correct Gzip of a faulty tar archive.
- 'H4sICBKyeF4AA215YXBwLnRhcgDt0sEKgjAAh/GdewrxAWpzbkJvs0pEaDVmHiR699Q6BBJ00Dr0'
- '/Y5jsD98850LYSMWJXuFkUJaITNTmEyPR09Caaut0lIXSkils1yKxCy76KFtLi4miWjqqo0H//Ze'
- 'iLV3saviuQ3f2PUlfkwf2l0Tyv26c/44/xtDYJsP6a0trJn2z1765/3/UMbYvr+cf8rUn/e/pifn'
- 'y3Sbjh8hvf16DwAAAAAAAAAAAAAAAIDPre4CU/3q/CcAAA==')
- ],
- ),
- tempDir),
- throwsA(isA<TarException>()));
+ () async => await extractTarGz(
+ Stream.fromIterable(
+ [
+ base64Decode(
+ // Correct Gzip of a faulty tar archive.
+ 'H4sICBKyeF4AA215YXBwLnRhcgDt0sEKgjAAh/GdewrxAWpzbkJvs0pEaDVmHiR699Q6BBJ00Dr0'
+ '/Y5jsD98850LYSMWJXuFkUJaITNTmEyPR09Caaut0lIXSkils1yKxCy76KFtLi4miWjqqo0H//Ze'
+ 'iLV3saviuQ3f2PUlfkwf2l0Tyv26c/44/xtDYJsP6a0trJn2z1765/3/UMbYvr+cf8rUn/e/pifn'
+ 'y3Sbjh8hvf16DwAAAAAAAAAAAAAAAIDPre4CU/3q/CcAAA==')
+ ],
+ ),
+ tempDir,
+ ),
+ throwsA(isA<TarException>()),
+ );
});
});
@@ -274,15 +360,19 @@
await withTempDir((tempDir) async {
await expectLater(
() async => await extractTarGz(
- Stream.fromIterable(
- [
- [10, 20, 30] // Not a good gz stream.
- ],
- ),
- tempDir),
+ Stream.fromIterable(
+ [
+ [10, 20, 30] // Not a good gz stream.
+ ],
+ ),
+ tempDir,
+ ),
throwsA(
- isA<FormatException>().having((e) => e.message, 'message',
- contains('Filter error, bad data')),
+ isA<FormatException>().having(
+ (e) => e.message,
+ 'message',
+ contains('Filter error, bad data'),
+ ),
),
);
});
@@ -291,16 +381,21 @@
test(
'applies executable bits from tar file',
() => withTempDir((tempDir) async {
- final entry = Stream<TarEntry>.value(TarEntry.data(
+ final entry = Stream<TarEntry>.value(
+ TarEntry.data(
TarHeader(
name: 'weird_exe',
typeFlag: TypeFlag.reg,
mode: int.parse('110', radix: 8),
),
- const []));
+ const [],
+ ),
+ );
await extractTarGz(
- entry.transform(tarWriter).transform(gzip.encoder), tempDir);
+ entry.transform(tarWriter).transform(gzip.encoder),
+ tempDir,
+ );
expect(File('$tempDir/weird_exe').statSync().modeString(), 'rwxr-xr--');
}),
@@ -334,7 +429,9 @@
]);
await extractTarGz(
- entries.transform(tarWriter).transform(gzip.encoder), tempDir);
+ entries.transform(tarWriter).transform(gzip.encoder),
+ tempDir,
+ );
await d.dir(
'.',
@@ -349,36 +446,50 @@
test('preserves empty directories', () {
return withTempDir((tempDir) async {
- final entry = Stream<TarEntry>.value(TarEntry.data(
+ final entry = Stream<TarEntry>.value(
+ TarEntry.data(
TarHeader(
name: 'bin/',
typeFlag: TypeFlag.dir,
),
- const []));
+ const [],
+ ),
+ );
await extractTarGz(
- entry.transform(tarWriter).transform(gzip.encoder), tempDir);
+ entry.transform(tarWriter).transform(gzip.encoder),
+ tempDir,
+ );
await expectLater(
- Directory(tempDir).list(),
- emits(isA<Directory>()
- .having((e) => path.basename(e.path), 'basename', 'bin')));
+ Directory(tempDir).list(),
+ emits(
+ isA<Directory>()
+ .having((e) => path.basename(e.path), 'basename', 'bin'),
+ ),
+ );
});
});
test('throws for entries escaping the tar file', () {
return withTempDir((tempDir) async {
- final entry = Stream<TarEntry>.value(TarEntry.data(
+ final entry = Stream<TarEntry>.value(
+ TarEntry.data(
TarHeader(
name: '../other_package-1.2.3/lib/file.dart',
typeFlag: TypeFlag.reg,
),
- const []));
+ const [],
+ ),
+ );
await expectLater(
- extractTarGz(
- entry.transform(tarWriter).transform(gzip.encoder), tempDir),
- throwsA(isA<FormatException>()));
+ extractTarGz(
+ entry.transform(tarWriter).transform(gzip.encoder),
+ tempDir,
+ ),
+ throwsA(isA<FormatException>()),
+ );
await expectLater(Directory(tempDir).list(), emitsDone);
});
@@ -386,16 +497,21 @@
test('skips symlinks escaping the tar file', () {
return withTempDir((tempDir) async {
- final entry = Stream<TarEntry>.value(TarEntry.data(
+ final entry = Stream<TarEntry>.value(
+ TarEntry.data(
TarHeader(
name: 'nested/bad_link',
typeFlag: TypeFlag.symlink,
linkName: '../../outside.txt',
),
- const []));
+ const [],
+ ),
+ );
await extractTarGz(
- entry.transform(tarWriter).transform(gzip.encoder), tempDir);
+ entry.transform(tarWriter).transform(gzip.encoder),
+ tempDir,
+ );
await expectLater(Directory(tempDir).list(), emitsDone);
});
@@ -403,162 +519,209 @@
test('skips hardlinks escaping the tar file', () {
return withTempDir((tempDir) async {
- final entry = Stream<TarEntry>.value(TarEntry.data(
+ final entry = Stream<TarEntry>.value(
+ TarEntry.data(
TarHeader(
name: 'nested/bad_link',
typeFlag: TypeFlag.link,
linkName: '../outside.txt',
),
- const []));
+ const [],
+ ),
+ );
await extractTarGz(
- entry.transform(tarWriter).transform(gzip.encoder), tempDir);
+ entry.transform(tarWriter).transform(gzip.encoder),
+ tempDir,
+ );
await expectLater(Directory(tempDir).list(), emitsDone);
});
});
});
- testExistencePredicate('entryExists', entryExists,
- forFile: true,
- forFileSymlink: true,
- forMultiLevelFileSymlink: true,
- forDirectory: true,
- forDirectorySymlink: true,
- forMultiLevelDirectorySymlink: true,
- forBrokenSymlink: true,
- forMultiLevelBrokenSymlink: true);
+ testExistencePredicate(
+ 'entryExists',
+ entryExists,
+ forFile: true,
+ forFileSymlink: true,
+ forMultiLevelFileSymlink: true,
+ forDirectory: true,
+ forDirectorySymlink: true,
+ forMultiLevelDirectorySymlink: true,
+ forBrokenSymlink: true,
+ forMultiLevelBrokenSymlink: true,
+ );
- testExistencePredicate('linkExists', linkExists,
- forFile: false,
- forFileSymlink: true,
- forMultiLevelFileSymlink: true,
- forDirectory: false,
- forDirectorySymlink: true,
- forMultiLevelDirectorySymlink: true,
- forBrokenSymlink: true,
- forMultiLevelBrokenSymlink: true);
+ testExistencePredicate(
+ 'linkExists',
+ linkExists,
+ forFile: false,
+ forFileSymlink: true,
+ forMultiLevelFileSymlink: true,
+ forDirectory: false,
+ forDirectorySymlink: true,
+ forMultiLevelDirectorySymlink: true,
+ forBrokenSymlink: true,
+ forMultiLevelBrokenSymlink: true,
+ );
- testExistencePredicate('fileExists', fileExists,
- forFile: true,
- forFileSymlink: true,
- forMultiLevelFileSymlink: true,
- forDirectory: false,
- forDirectorySymlink: false,
- forMultiLevelDirectorySymlink: false,
- forBrokenSymlink: false,
- forMultiLevelBrokenSymlink: false);
+ testExistencePredicate(
+ 'fileExists',
+ fileExists,
+ forFile: true,
+ forFileSymlink: true,
+ forMultiLevelFileSymlink: true,
+ forDirectory: false,
+ forDirectorySymlink: false,
+ forMultiLevelDirectorySymlink: false,
+ forBrokenSymlink: false,
+ forMultiLevelBrokenSymlink: false,
+ );
- testExistencePredicate('dirExists', dirExists,
- forFile: false,
- forFileSymlink: false,
- forMultiLevelFileSymlink: false,
- forDirectory: true,
- forDirectorySymlink: true,
- forMultiLevelDirectorySymlink: true,
- forBrokenSymlink: false,
- forMultiLevelBrokenSymlink: false);
+ testExistencePredicate(
+ 'dirExists',
+ dirExists,
+ forFile: false,
+ forFileSymlink: false,
+ forMultiLevelFileSymlink: false,
+ forDirectory: true,
+ forDirectorySymlink: true,
+ forMultiLevelDirectorySymlink: true,
+ forBrokenSymlink: false,
+ forMultiLevelBrokenSymlink: false,
+ );
}
-void testExistencePredicate(String name, bool Function(String path) predicate,
- {required bool forFile,
- required bool forFileSymlink,
- required bool forMultiLevelFileSymlink,
- required bool forDirectory,
- required bool forDirectorySymlink,
- required bool forMultiLevelDirectorySymlink,
- required bool forBrokenSymlink,
- required bool forMultiLevelBrokenSymlink}) {
+void testExistencePredicate(
+ String name,
+ bool Function(String path) predicate, {
+ required bool forFile,
+ required bool forFileSymlink,
+ required bool forMultiLevelFileSymlink,
+ required bool forDirectory,
+ required bool forDirectorySymlink,
+ required bool forMultiLevelDirectorySymlink,
+ required bool forBrokenSymlink,
+ required bool forMultiLevelBrokenSymlink,
+}) {
group(name, () {
test('returns $forFile for a file', () {
- expect(withTempDir((temp) {
- var file = path.join(temp, 'test.txt');
- writeTextFile(file, 'contents');
- expect(predicate(file), equals(forFile));
- }), completes);
+ expect(
+ withTempDir((temp) {
+ var file = path.join(temp, 'test.txt');
+ writeTextFile(file, 'contents');
+ expect(predicate(file), equals(forFile));
+ }),
+ completes,
+ );
});
test('returns $forDirectory for a directory', () {
- expect(withTempDir((temp) {
- var file = path.join(temp, 'dir');
- _createDir(file);
- expect(predicate(file), equals(forDirectory));
- }), completes);
+ expect(
+ withTempDir((temp) {
+ var file = path.join(temp, 'dir');
+ _createDir(file);
+ expect(predicate(file), equals(forDirectory));
+ }),
+ completes,
+ );
});
test('returns $forDirectorySymlink for a symlink to a directory', () {
- expect(withTempDir((temp) {
- var targetPath = path.join(temp, 'dir');
- var symlinkPath = path.join(temp, 'linkdir');
- _createDir(targetPath);
- createSymlink(targetPath, symlinkPath);
- expect(predicate(symlinkPath), equals(forDirectorySymlink));
- }), completes);
+ expect(
+ withTempDir((temp) {
+ var targetPath = path.join(temp, 'dir');
+ var symlinkPath = path.join(temp, 'linkdir');
+ _createDir(targetPath);
+ createSymlink(targetPath, symlinkPath);
+ expect(predicate(symlinkPath), equals(forDirectorySymlink));
+ }),
+ completes,
+ );
});
test(
'returns $forMultiLevelDirectorySymlink for a multi-level symlink to '
'a directory', () {
- expect(withTempDir((temp) {
- var targetPath = path.join(temp, 'dir');
- var symlink1Path = path.join(temp, 'link1dir');
- var symlink2Path = path.join(temp, 'link2dir');
- _createDir(targetPath);
- createSymlink(targetPath, symlink1Path);
- createSymlink(symlink1Path, symlink2Path);
- expect(predicate(symlink2Path), equals(forMultiLevelDirectorySymlink));
- }), completes);
+ expect(
+ withTempDir((temp) {
+ var targetPath = path.join(temp, 'dir');
+ var symlink1Path = path.join(temp, 'link1dir');
+ var symlink2Path = path.join(temp, 'link2dir');
+ _createDir(targetPath);
+ createSymlink(targetPath, symlink1Path);
+ createSymlink(symlink1Path, symlink2Path);
+ expect(
+ predicate(symlink2Path),
+ equals(forMultiLevelDirectorySymlink),
+ );
+ }),
+ completes,
+ );
});
test('returns $forBrokenSymlink for a broken symlink', () {
- expect(withTempDir((temp) {
- var targetPath = path.join(temp, 'dir');
- var symlinkPath = path.join(temp, 'linkdir');
- _createDir(targetPath);
- createSymlink(targetPath, symlinkPath);
- deleteEntry(targetPath);
- expect(predicate(symlinkPath), equals(forBrokenSymlink));
- }), completes);
+ expect(
+ withTempDir((temp) {
+ var targetPath = path.join(temp, 'dir');
+ var symlinkPath = path.join(temp, 'linkdir');
+ _createDir(targetPath);
+ createSymlink(targetPath, symlinkPath);
+ deleteEntry(targetPath);
+ expect(predicate(symlinkPath), equals(forBrokenSymlink));
+ }),
+ completes,
+ );
});
test('returns $forMultiLevelBrokenSymlink for a multi-level broken symlink',
() {
- expect(withTempDir((temp) {
- var targetPath = path.join(temp, 'dir');
- var symlink1Path = path.join(temp, 'link1dir');
- var symlink2Path = path.join(temp, 'link2dir');
- _createDir(targetPath);
- createSymlink(targetPath, symlink1Path);
- createSymlink(symlink1Path, symlink2Path);
- deleteEntry(targetPath);
- expect(predicate(symlink2Path), equals(forMultiLevelBrokenSymlink));
- }), completes);
+ expect(
+ withTempDir((temp) {
+ var targetPath = path.join(temp, 'dir');
+ var symlink1Path = path.join(temp, 'link1dir');
+ var symlink2Path = path.join(temp, 'link2dir');
+ _createDir(targetPath);
+ createSymlink(targetPath, symlink1Path);
+ createSymlink(symlink1Path, symlink2Path);
+ deleteEntry(targetPath);
+ expect(predicate(symlink2Path), equals(forMultiLevelBrokenSymlink));
+ }),
+ completes,
+ );
});
// Windows doesn't support symlinking to files.
if (!Platform.isWindows) {
test('returns $forFileSymlink for a symlink to a file', () {
- expect(withTempDir((temp) {
- var targetPath = path.join(temp, 'test.txt');
- var symlinkPath = path.join(temp, 'link.txt');
- writeTextFile(targetPath, 'contents');
- createSymlink(targetPath, symlinkPath);
- expect(predicate(symlinkPath), equals(forFileSymlink));
- }), completes);
+ expect(
+ withTempDir((temp) {
+ var targetPath = path.join(temp, 'test.txt');
+ var symlinkPath = path.join(temp, 'link.txt');
+ writeTextFile(targetPath, 'contents');
+ createSymlink(targetPath, symlinkPath);
+ expect(predicate(symlinkPath), equals(forFileSymlink));
+ }),
+ completes,
+ );
});
test(
'returns $forMultiLevelFileSymlink for a multi-level symlink to a '
'file', () {
- expect(withTempDir((temp) {
- var targetPath = path.join(temp, 'test.txt');
- var symlink1Path = path.join(temp, 'link1.txt');
- var symlink2Path = path.join(temp, 'link2.txt');
- writeTextFile(targetPath, 'contents');
- createSymlink(targetPath, symlink1Path);
- createSymlink(symlink1Path, symlink2Path);
- expect(predicate(symlink2Path), equals(forMultiLevelFileSymlink));
- }), completes);
+ expect(
+ withTempDir((temp) {
+ var targetPath = path.join(temp, 'test.txt');
+ var symlink1Path = path.join(temp, 'link1.txt');
+ var symlink2Path = path.join(temp, 'link2.txt');
+ writeTextFile(targetPath, 'contents');
+ createSymlink(targetPath, symlink1Path);
+ createSymlink(symlink1Path, symlink2Path);
+ expect(predicate(symlink2Path), equals(forMultiLevelFileSymlink));
+ }),
+ completes,
+ );
});
}
});
diff --git a/test/levenshtein_test.dart b/test/levenshtein_test.dart
index 67361af..31378da 100644
--- a/test/levenshtein_test.dart
+++ b/test/levenshtein_test.dart
@@ -51,7 +51,9 @@
});
test('is symmetrical', () {
- expect(levenshteinDistance('j', 'alsdlasksjdlakdjlakq2rqb1o3i'),
- levenshteinDistance('alsdlasksjdlakdjlakq2rqb1o3i', 'j'));
+ expect(
+ levenshteinDistance('j', 'alsdlasksjdlakdjlakq2rqb1o3i'),
+ levenshteinDistance('alsdlasksjdlakdjlakq2rqb1o3i', 'j'),
+ );
});
}
diff --git a/test/lish/archives_and_uploads_a_package_test.dart b/test/lish/archives_and_uploads_a_package_test.dart
index 9cb4146..ffad2ea 100644
--- a/test/lish/archives_and_uploads_a_package_test.dart
+++ b/test/lish/archives_and_uploads_a_package_test.dart
@@ -26,9 +26,11 @@
handleUpload(globalServer);
globalServer.expect('GET', '/create', (request) {
- return shelf.Response.ok(jsonEncode({
- 'success': {'message': 'Package test_pkg 1.0.0 uploaded!'}
- }));
+ return shelf.Response.ok(
+ jsonEncode({
+ 'success': {'message': 'Package test_pkg 1.0.0 uploaded!'}
+ }),
+ );
});
expect(pub.stdout, emits(startsWith('Uploading...')));
@@ -52,9 +54,11 @@
handleUpload(globalServer);
globalServer.expect('GET', '/create', (request) {
- return shelf.Response.ok(jsonEncode({
- 'success': {'message': 'Package test_pkg 1.0.0 uploaded!'}
- }));
+ return shelf.Response.ok(
+ jsonEncode({
+ 'success': {'message': 'Package test_pkg 1.0.0 uploaded!'}
+ }),
+ );
});
expect(pub.stdout, emits(startsWith('Uploading...')));
@@ -83,9 +87,11 @@
handleUpload(globalServer);
globalServer.expect('GET', '/create', (request) {
- return shelf.Response.ok(jsonEncode({
- 'success': {'message': 'Package test_pkg 1.0.0 uploaded!'}
- }));
+ return shelf.Response.ok(
+ jsonEncode({
+ 'success': {'message': 'Package test_pkg 1.0.0 uploaded!'}
+ }),
+ );
});
expect(pub.stdout, emits(startsWith('Uploading...')));
@@ -126,9 +132,11 @@
handleUpload(globalServer);
globalServer.expect('GET', '/create', (request) {
- return shelf.Response.ok(jsonEncode({
- 'success': {'message': 'Package test_pkg 1.0.0 uploaded!'}
- }));
+ return shelf.Response.ok(
+ jsonEncode({
+ 'success': {'message': 'Package test_pkg 1.0.0 uploaded!'}
+ }),
+ );
});
expect(pub.stdout, emits(startsWith('Uploading...')));
diff --git a/test/lish/cloud_storage_upload_provides_an_error_test.dart b/test/lish/cloud_storage_upload_provides_an_error_test.dart
index 85e55af..fa3a783 100644
--- a/test/lish/cloud_storage_upload_provides_an_error_test.dart
+++ b/test/lish/cloud_storage_upload_provides_an_error_test.dart
@@ -22,8 +22,9 @@
globalServer.expect('POST', '/upload', (request) {
return request.read().drain().then((_) {
return shelf.Response.notFound(
- '<Error><Message>Your request sucked.</Message></Error>',
- headers: {'content-type': 'application/xml'});
+ '<Error><Message>Your request sucked.</Message></Error>',
+ headers: {'content-type': 'application/xml'},
+ );
});
});
diff --git a/test/lish/does_not_include_dot_file.dart b/test/lish/does_not_include_dot_file.dart
index cec8ab0..ab0b8a8 100644
--- a/test/lish/does_not_include_dot_file.dart
+++ b/test/lish/does_not_include_dot_file.dart
@@ -38,9 +38,11 @@
handleUpload(globalServer);
globalServer.expect('GET', '/create', (request) {
- return shelf.Response.ok(jsonEncode({
- 'success': {'message': 'Package test_pkg 1.0.0 uploaded!'}
- }));
+ return shelf.Response.ok(
+ jsonEncode({
+ 'success': {'message': 'Package test_pkg 1.0.0 uploaded!'}
+ }),
+ );
});
expect(pub.stdout, emits('test_pkg.dart'));
diff --git a/test/lish/does_not_include_pubspec_overrides_file.dart b/test/lish/does_not_include_pubspec_overrides_file.dart
index 3fa378b..9ff584b 100644
--- a/test/lish/does_not_include_pubspec_overrides_file.dart
+++ b/test/lish/does_not_include_pubspec_overrides_file.dart
@@ -39,9 +39,11 @@
handleUpload(globalServer);
globalServer.expect('GET', '/create', (request) {
- return shelf.Response.ok(jsonEncode({
- 'success': {'message': 'Package test_pkg 1.0.0 uploaded!'}
- }));
+ return shelf.Response.ok(
+ jsonEncode({
+ 'success': {'message': 'Package test_pkg 1.0.0 uploaded!'}
+ }),
+ );
});
expect(pub.stdout, emits('test_pkg.dart'));
diff --git a/test/lish/does_not_publish_if_private_test.dart b/test/lish/does_not_publish_if_private_test.dart
index 52321c2..c47610b 100644
--- a/test/lish/does_not_publish_if_private_test.dart
+++ b/test/lish/does_not_publish_if_private_test.dart
@@ -15,8 +15,9 @@
await d.dir(appPath, [d.pubspec(pkg)]).create();
await runPub(
- args: ['lish'],
- error: startsWith('A private package cannot be published.'),
- exitCode: exit_codes.DATA);
+ args: ['lish'],
+ error: startsWith('A private package cannot be published.'),
+ exitCode: exit_codes.DATA,
+ );
});
}
diff --git a/test/lish/dry_run_errors_if_private_test.dart b/test/lish/dry_run_errors_if_private_test.dart
index 10dd739..c9b6c6a 100644
--- a/test/lish/dry_run_errors_if_private_test.dart
+++ b/test/lish/dry_run_errors_if_private_test.dart
@@ -16,8 +16,9 @@
await d.dir(appPath, [d.pubspec(pkg)]).create();
await runPub(
- args: ['lish', '--dry-run'],
- error: startsWith('A private package cannot be published.'),
- exitCode: exit_codes.DATA);
+ args: ['lish', '--dry-run'],
+ error: startsWith('A private package cannot be published.'),
+ exitCode: exit_codes.DATA,
+ );
});
}
diff --git a/test/lish/dry_run_package_validation_has_a_warning_test.dart b/test/lish/dry_run_package_validation_has_a_warning_test.dart
index 1edd48d..d6c2166 100644
--- a/test/lish/dry_run_package_validation_has_a_warning_test.dart
+++ b/test/lish/dry_run_package_validation_has_a_warning_test.dart
@@ -14,8 +14,13 @@
(await servePackages()).serve('foo', '1.0.0');
await d.validPackage.create();
- var pkg =
- packageMap('test_pkg', '1.0.0', null, null, {'sdk': '>=0.1.2 <0.2.0'});
+ var pkg = packageMap(
+ 'test_pkg',
+ '1.0.0',
+ null,
+ null,
+ {'sdk': defaultSdkConstraint},
+ );
pkg['dependencies'] = {'foo': 'any'};
await d.dir(appPath, [d.pubspec(pkg)]).create();
diff --git a/test/lish/force_does_not_publish_if_private_test.dart b/test/lish/force_does_not_publish_if_private_test.dart
index 0d4ad59..edd3611 100644
--- a/test/lish/force_does_not_publish_if_private_test.dart
+++ b/test/lish/force_does_not_publish_if_private_test.dart
@@ -15,8 +15,9 @@
await d.dir(appPath, [d.pubspec(pkg)]).create();
await runPub(
- args: ['lish', '--force'],
- error: startsWith('A private package cannot be published.'),
- exitCode: exit_codes.DATA);
+ args: ['lish', '--force'],
+ error: startsWith('A private package cannot be published.'),
+ exitCode: exit_codes.DATA,
+ );
});
}
diff --git a/test/lish/force_does_not_publish_if_there_are_errors_test.dart b/test/lish/force_does_not_publish_if_there_are_errors_test.dart
index 69c770a..c803556 100644
--- a/test/lish/force_does_not_publish_if_there_are_errors_test.dart
+++ b/test/lish/force_does_not_publish_if_there_are_errors_test.dart
@@ -25,7 +25,8 @@
expect(
pub.stderr,
emitsThrough(
- "Sorry, your package is missing a requirement and can't be published yet."),
+ "Sorry, your package is missing a requirement and can't be published yet.",
+ ),
);
});
}
diff --git a/test/lish/force_publishes_if_tests_are_no_warnings_or_errors_test.dart b/test/lish/force_publishes_if_tests_are_no_warnings_or_errors_test.dart
index 5b25f48..c287c31 100644
--- a/test/lish/force_publishes_if_tests_are_no_warnings_or_errors_test.dart
+++ b/test/lish/force_publishes_if_tests_are_no_warnings_or_errors_test.dart
@@ -23,9 +23,11 @@
handleUpload(globalServer);
globalServer.expect('GET', '/create', (request) {
- return shelf.Response.ok(jsonEncode({
- 'success': {'message': 'Package test_pkg 1.0.0 uploaded!'}
- }));
+ return shelf.Response.ok(
+ jsonEncode({
+ 'success': {'message': 'Package test_pkg 1.0.0 uploaded!'}
+ }),
+ );
});
await pub.shouldExit(exit_codes.SUCCESS);
diff --git a/test/lish/force_publishes_if_there_are_warnings_test.dart b/test/lish/force_publishes_if_there_are_warnings_test.dart
index 41a115c..62e8754 100644
--- a/test/lish/force_publishes_if_there_are_warnings_test.dart
+++ b/test/lish/force_publishes_if_there_are_warnings_test.dart
@@ -15,8 +15,13 @@
void main() {
test('--force publishes if there are warnings', () async {
await d.validPackage.create();
- var pkg =
- packageMap('test_pkg', '1.0.0', null, null, {'sdk': '>=0.1.2 <0.2.0'});
+ var pkg = packageMap(
+ 'test_pkg',
+ '1.0.0',
+ null,
+ null,
+ {'sdk': defaultSdkConstraint},
+ );
pkg['dependencies'] = {'foo': 'any'};
await d.dir(appPath, [d.pubspec(pkg)]).create();
@@ -29,20 +34,24 @@
handleUpload(globalServer);
globalServer.expect('GET', '/create', (request) {
- return shelf.Response.ok(jsonEncode({
- 'success': {'message': 'Package test_pkg 1.0.0 uploaded!'}
- }));
+ return shelf.Response.ok(
+ jsonEncode({
+ 'success': {'message': 'Package test_pkg 1.0.0 uploaded!'}
+ }),
+ );
});
await pub.shouldExit(exit_codes.SUCCESS);
final stderrLines = await pub.stderr.rest.toList();
expect(
- stderrLines,
- allOf([
- contains('Package validation found the following potential issue:'),
- contains(
- '* Your dependency on "foo" should have a version constraint. For example:'),
- ]));
+ stderrLines,
+ allOf([
+ contains('Package validation found the following potential issue:'),
+ contains(
+ '* Your dependency on "foo" should have a version constraint. For example:',
+ ),
+ ]),
+ );
expect(pub.stdout, emitsThrough('Package test_pkg 1.0.0 uploaded!'));
});
}
diff --git a/test/lish/many_files_test.dart b/test/lish/many_files_test.dart
index ebb5a65..d3805d1 100644
--- a/test/lish/many_files_test.dart
+++ b/test/lish/many_files_test.dart
@@ -47,15 +47,18 @@
handleUpload(globalServer);
globalServer.expect('GET', '/create', (request) {
- return shelf.Response.ok(jsonEncode({
- 'success': {'message': 'Package test_pkg 1.0.0 uploaded!'}
- }));
+ return shelf.Response.ok(
+ jsonEncode({
+ 'success': {'message': 'Package test_pkg 1.0.0 uploaded!'}
+ }),
+ );
});
await pub.shouldExit(exit_codes.SUCCESS);
final stdout = await pub.stdout.rest.toList();
context.expectNextSection(
- stdout.join('\n').replaceAll(globalServer.port.toString(), r'$PORT'));
+ stdout.join('\n').replaceAll(globalServer.port.toString(), r'$PORT'),
+ );
});
test(
@@ -112,9 +115,11 @@
handleUpload(globalServer);
globalServer.expect('GET', '/create', (request) {
- return shelf.Response.ok(jsonEncode({
- 'success': {'message': 'Package test_pkg 1.0.0 uploaded!'}
- }));
+ return shelf.Response.ok(
+ jsonEncode({
+ 'success': {'message': 'Package test_pkg 1.0.0 uploaded!'}
+ }),
+ );
});
expect(pub.stdout, emits(startsWith('Uploading...')));
diff --git a/test/lish/package_creation_provides_an_error_test.dart b/test/lish/package_creation_provides_an_error_test.dart
index a4fde1b..c1d8bba 100644
--- a/test/lish/package_creation_provides_an_error_test.dart
+++ b/test/lish/package_creation_provides_an_error_test.dart
@@ -23,9 +23,11 @@
handleUpload(globalServer);
globalServer.expect('GET', '/create', (request) {
- return shelf.Response.notFound(jsonEncode({
- 'error': {'message': 'Your package was too boring.'}
- }));
+ return shelf.Response.notFound(
+ jsonEncode({
+ 'error': {'message': 'Your package was too boring.'}
+ }),
+ );
});
expect(pub.stderr, emits('Your package was too boring.'));
diff --git a/test/lish/package_creation_provides_invalid_json_test.dart b/test/lish/package_creation_provides_invalid_json_test.dart
index 7181d8e..124e01a 100644
--- a/test/lish/package_creation_provides_invalid_json_test.dart
+++ b/test/lish/package_creation_provides_invalid_json_test.dart
@@ -25,9 +25,10 @@
});
expect(
- pub.stderr,
- emitsLines('Invalid server response:\n'
- '{not json'));
+ pub.stderr,
+ emitsLines('Invalid server response:\n'
+ '{not json'),
+ );
await pub.shouldExit(1);
});
}
diff --git a/test/lish/package_validation_has_a_warning_and_continues_test.dart b/test/lish/package_validation_has_a_warning_and_continues_test.dart
index 92c74de..5355434 100644
--- a/test/lish/package_validation_has_a_warning_and_continues_test.dart
+++ b/test/lish/package_validation_has_a_warning_and_continues_test.dart
@@ -30,9 +30,11 @@
handleUpload(globalServer);
globalServer.expect('GET', '/create', (request) {
- return shelf.Response.ok(jsonEncode({
- 'success': {'message': 'Package test_pkg 1.0.0 uploaded!'}
- }));
+ return shelf.Response.ok(
+ jsonEncode({
+ 'success': {'message': 'Package test_pkg 1.0.0 uploaded!'}
+ }),
+ );
});
await pub.shouldExit(exit_codes.SUCCESS);
diff --git a/test/lish/package_validation_has_a_warning_and_is_canceled_test.dart b/test/lish/package_validation_has_a_warning_and_is_canceled_test.dart
index b552a25..f4e4b0b 100644
--- a/test/lish/package_validation_has_a_warning_and_is_canceled_test.dart
+++ b/test/lish/package_validation_has_a_warning_and_is_canceled_test.dart
@@ -11,8 +11,13 @@
void main() {
test('package validation has a warning and is canceled', () async {
await d.validPackage.create();
- var pkg =
- packageMap('test_pkg', '1.0.0', null, null, {'sdk': '>=0.1.2 <0.2.0'});
+ var pkg = packageMap(
+ 'test_pkg',
+ '1.0.0',
+ null,
+ null,
+ {'sdk': defaultSdkConstraint},
+ );
pkg['author'] = 'Natalie Weizenbaum';
await d.dir(appPath, [
d.pubspec(pkg),
diff --git a/test/lish/package_validation_has_an_error_test.dart b/test/lish/package_validation_has_an_error_test.dart
index aa0e6f6..70e02df 100644
--- a/test/lish/package_validation_has_an_error_test.dart
+++ b/test/lish/package_validation_has_an_error_test.dart
@@ -15,7 +15,7 @@
'name': 'test_pkg',
'homepage': 'https://pub.dev',
'version': '1.0.0',
- 'environment': {'sdk': '>=0.1.2 <0.2.0'}
+ 'environment': {'sdk': defaultSdkConstraint}
}),
]).create();
@@ -24,8 +24,9 @@
await pub.shouldExit(exit_codes.DATA);
expect(
- pub.stderr,
- emitsThrough('Sorry, your package is missing some '
- "requirements and can't be published yet."));
+ pub.stderr,
+ emitsThrough('Sorry, your package is missing some '
+ "requirements and can't be published yet."),
+ );
});
}
diff --git a/test/lish/requires_resolution_before_publishing_test.dart b/test/lish/requires_resolution_before_publishing_test.dart
index e3294bc..3dfebc0 100644
--- a/test/lish/requires_resolution_before_publishing_test.dart
+++ b/test/lish/requires_resolution_before_publishing_test.dart
@@ -12,7 +12,7 @@
test('does not publish if no resolution can be found', () async {
await servePackages(); // No packages.
await d.validPackage.create();
- await d.appDir({'foo': '1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '1.0.0'}).create();
await runPub(
args: ['lish'],
error: contains("Because myapp depends on foo any which doesn't exist"),
diff --git a/test/lish/server_arg_does_not_override_private_test.dart b/test/lish/server_arg_does_not_override_private_test.dart
index 58a1af1..f9d7bf8 100644
--- a/test/lish/server_arg_does_not_override_private_test.dart
+++ b/test/lish/server_arg_does_not_override_private_test.dart
@@ -16,8 +16,9 @@
await d.dir(appPath, [d.pubspec(pkg)]).create();
await runPub(
- args: ['lish', '--server', 'http://arg.com'],
- error: startsWith('A private package cannot be published.'),
- exitCode: exit_codes.DATA);
+ args: ['lish', '--server', 'http://arg.com'],
+ error: startsWith('A private package cannot be published.'),
+ exitCode: exit_codes.DATA,
+ );
});
}
diff --git a/test/lish/server_arg_overrides_publish_to_url_test.dart b/test/lish/server_arg_overrides_publish_to_url_test.dart
index fcfdf14..dd05b7c 100644
--- a/test/lish/server_arg_overrides_publish_to_url_test.dart
+++ b/test/lish/server_arg_overrides_publish_to_url_test.dart
@@ -19,9 +19,10 @@
pkg['publish_to'] = 'http://pubspec.com';
await d.dir(appPath, [d.pubspec(pkg)]).create();
await runPub(
- args: ['lish', '--dry-run', '--server', packageServer.url],
- output: contains(packageServer.url),
- exitCode: exit_codes.DATA);
+ args: ['lish', '--dry-run', '--server', packageServer.url],
+ output: contains(packageServer.url),
+ exitCode: exit_codes.DATA,
+ );
await packageServer.close();
});
diff --git a/test/lish/upload_form_provides_an_error_test.dart b/test/lish/upload_form_provides_an_error_test.dart
index 68a6c66..048ca17 100644
--- a/test/lish/upload_form_provides_an_error_test.dart
+++ b/test/lish/upload_form_provides_an_error_test.dart
@@ -20,9 +20,11 @@
await confirmPublish(pub);
globalServer.expect('GET', '/api/packages/versions/new', (request) async {
- return shelf.Response.notFound(jsonEncode({
- 'error': {'message': 'your request sucked'}
- }));
+ return shelf.Response.notFound(
+ jsonEncode({
+ 'error': {'message': 'your request sucked'}
+ }),
+ );
});
expect(pub.stderr, emits('your request sucked'));
diff --git a/test/lish/upload_form_provides_invalid_json_test.dart b/test/lish/upload_form_provides_invalid_json_test.dart
index 73ffb9a..03f1551 100644
--- a/test/lish/upload_form_provides_invalid_json_test.dart
+++ b/test/lish/upload_form_provides_invalid_json_test.dart
@@ -18,13 +18,17 @@
await confirmPublish(pub);
- globalServer.expect('GET', '/api/packages/versions/new',
- (request) => shelf.Response.ok('{not json'));
+ globalServer.expect(
+ 'GET',
+ '/api/packages/versions/new',
+ (request) => shelf.Response.ok('{not json'),
+ );
expect(
- pub.stderr,
- emitsLines('Invalid server response:\n'
- '{not json'));
+ pub.stderr,
+ emitsLines('Invalid server response:\n'
+ '{not json'),
+ );
await pub.shouldExit(1);
});
}
diff --git a/test/lish/uses_publish_to_url_test.dart b/test/lish/uses_publish_to_url_test.dart
index d9408c4..37ad1f6 100644
--- a/test/lish/uses_publish_to_url_test.dart
+++ b/test/lish/uses_publish_to_url_test.dart
@@ -15,8 +15,9 @@
pkg['publish_to'] = 'http://example.com';
await d.dir(appPath, [d.pubspec(pkg)]).create();
await runPub(
- args: ['lish', '--dry-run'],
- output: contains('Publishing test_pkg 1.0.0 to http://example.com'),
- exitCode: exit_codes.DATA);
+ args: ['lish', '--dry-run'],
+ output: contains('Publishing test_pkg 1.0.0 to http://example.com'),
+ exitCode: exit_codes.DATA,
+ );
});
}
diff --git a/test/lish/utils.dart b/test/lish/utils.dart
index f134e4a..03766a4 100644
--- a/test/lish/utils.dart
+++ b/test/lish/utils.dart
@@ -12,15 +12,19 @@
void handleUploadForm(PackageServer server, {Map? body, String path = ''}) {
server.expect('GET', '$path/api/packages/versions/new', (request) {
expect(
- request.headers, containsPair('authorization', 'Bearer access token'));
+ request.headers,
+ containsPair('authorization', 'Bearer access token'),
+ );
body ??= {
'url': Uri.parse(server.url).resolve('/upload').toString(),
'fields': {'field1': 'value1', 'field2': 'value2'}
};
- return shelf.Response.ok(jsonEncode(body),
- headers: {'content-type': 'application/json'});
+ return shelf.Response.ok(
+ jsonEncode(body),
+ headers: {'content-type': 'application/json'},
+ );
});
}
diff --git a/test/list_package_dirs/ignores_updated_pubspec_test.dart b/test/list_package_dirs/ignores_updated_pubspec_test.dart
index 2524681..34ca2ac 100644
--- a/test/list_package_dirs/ignores_updated_pubspec_test.dart
+++ b/test/list_package_dirs/ignores_updated_pubspec_test.dart
@@ -16,34 +16,36 @@
.dir('foo', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': path.join(d.sandbox, 'foo')}
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': path.join(d.sandbox, 'foo')}
+ },
+ )
]).create();
await pubGet();
// Add a dependency on "bar" and remove "foo", but don't run "pub get".
await d.dir(appPath, [
- d.appPubspec({'bar': 'any'})
+ d.appPubspec(dependencies: {'bar': 'any'})
]).create();
// Note: Using canonicalize here because pub gets the path to the
// entrypoint package from the working directory, which has had symlinks
// resolve. On Mac, "/tmp" is actually a symlink to "/private/tmp", so we
// need to accommodate that.
- await runPub(args: [
- 'list-package-dirs',
- '--format=json'
- ], outputJson: {
- 'packages': {
- 'foo': path.join(d.sandbox, 'foo', 'lib'),
- 'myapp': canonicalize(path.join(d.sandbox, appPath, 'lib'))
+ await runPub(
+ args: ['list-package-dirs', '--format=json'],
+ outputJson: {
+ 'packages': {
+ 'foo': path.join(d.sandbox, 'foo', 'lib'),
+ 'myapp': canonicalize(path.join(d.sandbox, appPath, 'lib'))
+ },
+ 'input_files': [
+ canonicalize(path.join(d.sandbox, appPath, 'pubspec.lock')),
+ canonicalize(path.join(d.sandbox, appPath, 'pubspec.yaml'))
+ ]
},
- 'input_files': [
- canonicalize(path.join(d.sandbox, appPath, 'pubspec.lock')),
- canonicalize(path.join(d.sandbox, appPath, 'pubspec.yaml'))
- ]
- });
+ );
});
}
diff --git a/test/list_package_dirs/includes_dev_dependencies_test.dart b/test/list_package_dirs/includes_dev_dependencies_test.dart
index 61cc56b..fbb99ff 100644
--- a/test/list_package_dirs/includes_dev_dependencies_test.dart
+++ b/test/list_package_dirs/includes_dev_dependencies_test.dart
@@ -30,18 +30,18 @@
// entrypoint package from the working directory, which has had symlinks
// resolve. On Mac, "/tmp" is actually a symlink to "/private/tmp", so we
// need to accommodate that.
- await runPub(args: [
- 'list-package-dirs',
- '--format=json'
- ], outputJson: {
- 'packages': {
- 'foo': path.join(d.sandbox, 'foo', 'lib'),
- 'myapp': canonicalize(path.join(d.sandbox, appPath, 'lib'))
+ await runPub(
+ args: ['list-package-dirs', '--format=json'],
+ outputJson: {
+ 'packages': {
+ 'foo': path.join(d.sandbox, 'foo', 'lib'),
+ 'myapp': canonicalize(path.join(d.sandbox, appPath, 'lib'))
+ },
+ 'input_files': [
+ canonicalize(path.join(d.sandbox, appPath, 'pubspec.lock')),
+ canonicalize(path.join(d.sandbox, appPath, 'pubspec.yaml'))
+ ]
},
- 'input_files': [
- canonicalize(path.join(d.sandbox, appPath, 'pubspec.lock')),
- canonicalize(path.join(d.sandbox, appPath, 'pubspec.yaml'))
- ]
- });
+ );
});
}
diff --git a/test/list_package_dirs/lists_dependency_directories_test.dart b/test/list_package_dirs/lists_dependency_directories_test.dart
index 2cd9664..a9731a5 100644
--- a/test/list_package_dirs/lists_dependency_directories_test.dart
+++ b/test/list_package_dirs/lists_dependency_directories_test.dart
@@ -19,10 +19,12 @@
.dir('foo', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': path.join(d.sandbox, 'foo')},
- 'bar': 'any'
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': path.join(d.sandbox, 'foo')},
+ 'bar': 'any'
+ },
+ )
]).create();
await pubGet();
@@ -31,20 +33,26 @@
// entrypoint package from the working directory, which has had symlinks
// resolve. On Mac, "/tmp" is actually a symlink to "/private/tmp", so we
// need to accommodate that.
- await runPub(args: [
- 'list-package-dirs',
- '--format=json'
- ], outputJson: {
- 'packages': {
- 'foo': path.join(d.sandbox, 'foo', 'lib'),
- 'bar': path.join(d.sandbox, cachePath, 'hosted',
- 'localhost%58${server.port}', 'bar-1.0.0', 'lib'),
- 'myapp': canonicalize(path.join(d.sandbox, appPath, 'lib'))
+ await runPub(
+ args: ['list-package-dirs', '--format=json'],
+ outputJson: {
+ 'packages': {
+ 'foo': path.join(d.sandbox, 'foo', 'lib'),
+ 'bar': path.join(
+ d.sandbox,
+ cachePath,
+ 'hosted',
+ 'localhost%58${server.port}',
+ 'bar-1.0.0',
+ 'lib',
+ ),
+ 'myapp': canonicalize(path.join(d.sandbox, appPath, 'lib'))
+ },
+ 'input_files': [
+ canonicalize(path.join(d.sandbox, appPath, 'pubspec.lock')),
+ canonicalize(path.join(d.sandbox, appPath, 'pubspec.yaml'))
+ ]
},
- 'input_files': [
- canonicalize(path.join(d.sandbox, appPath, 'pubspec.lock')),
- canonicalize(path.join(d.sandbox, appPath, 'pubspec.yaml'))
- ]
- });
+ );
});
}
diff --git a/test/list_package_dirs/lockfile_error_test.dart b/test/list_package_dirs/lockfile_error_test.dart
index 5c7bff9..752f3f5 100644
--- a/test/list_package_dirs/lockfile_error_test.dart
+++ b/test/list_package_dirs/lockfile_error_test.dart
@@ -12,15 +12,18 @@
void main() {
test('reports the lockfile path when there is an error in it', () async {
- await d.dir(appPath,
- [d.appPubspec(), d.file('pubspec.lock', 'some bad yaml')]).create();
+ await d.dir(
+ appPath,
+ [d.appPubspec(), d.file('pubspec.lock', 'some bad yaml')],
+ ).create();
- await runPub(args: [
- 'list-package-dirs',
- '--format=json'
- ], outputJson: {
- 'error': contains('Expected a YAML mapping.'),
- 'path': canonicalize(path.join(d.sandbox, appPath, 'pubspec.lock'))
- }, exitCode: exit_codes.DATA);
+ await runPub(
+ args: ['list-package-dirs', '--format=json'],
+ outputJson: {
+ 'error': contains('Expected a YAML mapping.'),
+ 'path': canonicalize(path.join(d.sandbox, appPath, 'pubspec.lock'))
+ },
+ exitCode: exit_codes.DATA,
+ );
});
}
diff --git a/test/list_package_dirs/missing_pubspec_test.dart b/test/list_package_dirs/missing_pubspec_test.dart
index 83a58c2..07cecaf 100644
--- a/test/list_package_dirs/missing_pubspec_test.dart
+++ b/test/list_package_dirs/missing_pubspec_test.dart
@@ -15,13 +15,14 @@
test('reports a missing pubspec error using JSON', () async {
await d.dir(appPath).create();
- await runPub(args: [
- 'list-package-dirs',
- '--format=json'
- ], outputJson: {
- 'error': 'Could not find a file named "pubspec.yaml" in '
- '"${canonicalize(path.join(d.sandbox, appPath))}".',
- 'path': canonicalize(path.join(d.sandbox, appPath, 'pubspec.yaml'))
- }, exitCode: exit_codes.NO_INPUT);
+ await runPub(
+ args: ['list-package-dirs', '--format=json'],
+ outputJson: {
+ 'error': 'Could not find a file named "pubspec.yaml" in '
+ '"${canonicalize(path.join(d.sandbox, appPath))}".',
+ 'path': canonicalize(path.join(d.sandbox, appPath, 'pubspec.yaml'))
+ },
+ exitCode: exit_codes.NO_INPUT,
+ );
});
}
diff --git a/test/list_package_dirs/no_lockfile_test.dart b/test/list_package_dirs/no_lockfile_test.dart
index 5939099..1593e2f 100644
--- a/test/list_package_dirs/no_lockfile_test.dart
+++ b/test/list_package_dirs/no_lockfile_test.dart
@@ -13,12 +13,13 @@
test('with no lockfile, exits with error', () async {
await d.dir(appPath, [d.appPubspec()]).create();
- await runPub(args: [
- 'list-package-dirs',
- '--format=json'
- ], outputJson: {
- 'error':
- 'Package "myapp" has no lockfile. Please run "dart pub get" first.'
- }, exitCode: exit_codes.DATA);
+ await runPub(
+ args: ['list-package-dirs', '--format=json'],
+ outputJson: {
+ 'error':
+ 'Package "myapp" has no lockfile. Please run "dart pub get" first.'
+ },
+ exitCode: exit_codes.DATA,
+ );
});
}
diff --git a/test/list_package_dirs/pubspec_error_test.dart b/test/list_package_dirs/pubspec_error_test.dart
index c282c5c..458bafe 100644
--- a/test/list_package_dirs/pubspec_error_test.dart
+++ b/test/list_package_dirs/pubspec_error_test.dart
@@ -14,12 +14,13 @@
test('reports the pubspec path when there is an error in it', () async {
await d.dir(appPath, [d.file('pubspec.yaml', 'some bad yaml')]).create();
- await runPub(args: [
- 'list-package-dirs',
- '--format=json'
- ], outputJson: {
- 'error': contains('Error on line 1'),
- 'path': canonicalize(path.join(d.sandbox, appPath, 'pubspec.yaml'))
- }, exitCode: exit_codes.DATA);
+ await runPub(
+ args: ['list-package-dirs', '--format=json'],
+ outputJson: {
+ 'error': contains('Error on line 1'),
+ 'path': canonicalize(path.join(d.sandbox, appPath, 'pubspec.yaml'))
+ },
+ exitCode: exit_codes.DATA,
+ );
});
}
diff --git a/test/lock_file_test.dart b/test/lock_file_test.dart
index 20e3976..230ba1b 100644
--- a/test/lock_file_test.dart
+++ b/test/lock_file_test.dart
@@ -26,7 +26,8 @@
});
test('parses a series of package descriptions', () {
- var lockFile = LockFile.parse('''
+ var lockFile = LockFile.parse(
+ '''
packages:
bar:
version: 1.2.3
@@ -40,7 +41,9 @@
description:
name: foo
url: https://foo.com
-''', cache.sources);
+''',
+ cache.sources,
+ );
expect(lockFile.packages.length, equals(2));
@@ -48,165 +51,245 @@
expect(bar.name, equals('bar'));
expect(bar.version, equals(Version(1, 2, 3)));
expect(bar.source, equals(cache.hosted));
- expect((bar.description.description as HostedDescription).url,
- equals('https://bar.com'));
+ expect(
+ (bar.description.description as HostedDescription).url,
+ equals('https://bar.com'),
+ );
var foo = lockFile.packages['foo']!;
expect(foo.name, equals('foo'));
expect(foo.version, equals(Version(2, 3, 4)));
expect(foo.source, equals(cache.hosted));
- expect((foo.description.description as HostedDescription).url,
- equals('https://foo.com'));
+ expect(
+ (foo.description.description as HostedDescription).url,
+ equals('https://foo.com'),
+ );
});
test('allows an unknown source', () {
- var lockFile = LockFile.parse('''
+ var lockFile = LockFile.parse(
+ '''
packages:
foo:
source: bad
version: 1.2.3
description: foo desc
-''', cache.sources);
+''',
+ cache.sources,
+ );
var foo = lockFile.packages['foo']!;
expect(foo.source, equals(sources('bad')));
});
test('allows an empty dependency map', () {
- var lockFile = LockFile.parse('''
+ var lockFile = LockFile.parse(
+ '''
packages:
-''', sources);
+''',
+ sources,
+ );
expect(lockFile.packages, isEmpty);
});
test('allows an old-style SDK constraint', () {
var lockFile = LockFile.parse('sdk: ">=1.2.3 <4.0.0"', sources);
- expect(lockFile.sdkConstraints,
- containsPair('dart', VersionConstraint.parse('>=1.2.3 <4.0.0')));
+ expect(
+ lockFile.sdkConstraints,
+ containsPair('dart', VersionConstraint.parse('>=1.2.3 <4.0.0')),
+ );
expect(lockFile.sdkConstraints, isNot(contains('flutter')));
expect(lockFile.sdkConstraints, isNot(contains('fuchsia')));
});
test('allows new-style SDK constraints', () {
- var lockFile = LockFile.parse('''
+ var lockFile = LockFile.parse(
+ '''
sdks:
dart: ">=1.2.3 <4.0.0"
flutter: ^0.1.2
fuchsia: ^5.6.7
-''', sources);
- expect(lockFile.sdkConstraints,
- containsPair('dart', VersionConstraint.parse('>=1.2.3 <4.0.0')));
- expect(lockFile.sdkConstraints,
- containsPair('flutter', VersionConstraint.parse('^0.1.2')));
- expect(lockFile.sdkConstraints,
- containsPair('fuchsia', VersionConstraint.parse('^5.6.7')));
+''',
+ sources,
+ );
+ expect(
+ lockFile.sdkConstraints,
+ containsPair('dart', VersionConstraint.parse('>=1.2.3 <4.0.0')),
+ );
+ expect(
+ lockFile.sdkConstraints,
+ containsPair('flutter', VersionConstraint.parse('^0.1.2')),
+ );
+ expect(
+ lockFile.sdkConstraints,
+ containsPair('fuchsia', VersionConstraint.parse('^5.6.7')),
+ );
});
test('throws if the top level is not a map', () {
- expect(() {
- LockFile.parse('''
+ expect(
+ () {
+ LockFile.parse(
+ '''
not a map
-''', sources);
- }, throwsFormatException);
+''',
+ sources,
+ );
+ },
+ throwsFormatException,
+ );
});
test("throws if the contents of 'packages' is not a map", () {
- expect(() {
- LockFile.parse('''
+ expect(
+ () {
+ LockFile.parse(
+ '''
packages: not a map
-''', sources);
- }, throwsFormatException);
+''',
+ sources,
+ );
+ },
+ throwsFormatException,
+ );
});
test('throws if the version is missing', () {
- expect(() {
- LockFile.parse('''
+ expect(
+ () {
+ LockFile.parse(
+ '''
packages:
foo:
source: fake
description: foo desc
-''', sources);
- }, throwsFormatException);
+''',
+ sources,
+ );
+ },
+ throwsFormatException,
+ );
});
test('throws if the version is invalid', () {
- expect(() {
- LockFile.parse('''
+ expect(
+ () {
+ LockFile.parse(
+ '''
packages:
foo:
version: vorpal
source: fake
description: foo desc
-''', sources);
- }, throwsFormatException);
+''',
+ sources,
+ );
+ },
+ throwsFormatException,
+ );
});
test('throws if the source is missing', () {
- expect(() {
- LockFile.parse('''
+ expect(
+ () {
+ LockFile.parse(
+ '''
packages:
foo:
version: 1.2.3
description: foo desc
-''', sources);
- }, throwsFormatException);
+''',
+ sources,
+ );
+ },
+ throwsFormatException,
+ );
});
test('throws if the description is missing', () {
- expect(() {
- LockFile.parse('''
+ expect(
+ () {
+ LockFile.parse(
+ '''
packages:
foo:
version: 1.2.3
source: fake
-''', sources);
- }, throwsFormatException);
+''',
+ sources,
+ );
+ },
+ throwsFormatException,
+ );
});
test('throws if the description is invalid', () {
- expect(() {
- LockFile.parse('''
+ expect(
+ () {
+ LockFile.parse(
+ '''
packages:
foo:
version: 1.2.3
source: hosted
description: foam
-''', sources);
- }, throwsFormatException);
+''',
+ sources,
+ );
+ },
+ throwsFormatException,
+ );
});
test("throws if the old-style SDK constraint isn't a string", () {
expect(
- () => LockFile.parse('sdk: 1.0', sources), throwsFormatException);
+ () => LockFile.parse('sdk: 1.0', sources),
+ throwsFormatException,
+ );
});
test('throws if the old-style SDK constraint is invalid', () {
expect(
- () => LockFile.parse('sdk: oops', sources), throwsFormatException);
+ () => LockFile.parse('sdk: oops', sources),
+ throwsFormatException,
+ );
});
test("throws if the sdks field isn't a map", () {
expect(
- () => LockFile.parse('sdks: oops', sources), throwsFormatException);
+ () => LockFile.parse('sdks: oops', sources),
+ throwsFormatException,
+ );
});
test("throws if an sdk constraint isn't a string", () {
- expect(() => LockFile.parse('sdks: {dart: 1.0}', sources),
- throwsFormatException);
- expect(() {
- LockFile.parse('sdks: {dart: 1.0.0, flutter: 1.0}', sources);
- }, throwsFormatException);
+ expect(
+ () => LockFile.parse('sdks: {dart: 1.0}', sources),
+ throwsFormatException,
+ );
+ expect(
+ () {
+ LockFile.parse('sdks: {dart: 1.0.0, flutter: 1.0}', sources);
+ },
+ throwsFormatException,
+ );
});
test('throws if an sdk constraint is invalid', () {
- expect(() => LockFile.parse('sdks: {dart: oops}', sources),
- throwsFormatException);
- expect(() {
- LockFile.parse('sdks: {dart: 1.0.0, flutter: oops}', sources);
- }, throwsFormatException);
+ expect(
+ () => LockFile.parse('sdks: {dart: oops}', sources),
+ throwsFormatException,
+ );
+ expect(
+ () {
+ LockFile.parse('sdks: {dart: 1.0.0, flutter: oops}', sources);
+ },
+ throwsFormatException,
+ );
});
test('ignores extra stuff in file', () {
- LockFile.parse('''
+ LockFile.parse(
+ '''
extra:
some: stuff
packages:
@@ -215,51 +298,55 @@
version: 1.2.3
source: fake
description: foo desc
-''', sources);
+''',
+ sources,
+ );
});
});
test('serialize() dumps the lockfile to YAML', () {
- var lockfile = LockFile([
- PackageId(
- 'foo',
- Version.parse('1.2.3'),
- ResolvedHostedDescription(
- HostedDescription('foo', 'https://foo.com'),
- sha256: null,
+ var lockfile = LockFile(
+ [
+ PackageId(
+ 'foo',
+ Version.parse('1.2.3'),
+ ResolvedHostedDescription(
+ HostedDescription('foo', 'https://foo.com'),
+ sha256: null,
+ ),
),
- ),
- PackageId(
- 'bar',
- Version.parse('3.2.1'),
- ResolvedHostedDescription(
- HostedDescription('bar', 'https://bar.com'),
- sha256: null,
+ PackageId(
+ 'bar',
+ Version.parse('3.2.1'),
+ ResolvedHostedDescription(
+ HostedDescription('bar', 'https://bar.com'),
+ sha256: null,
+ ),
),
- ),
- ], devDependencies: {
- 'bar'
- });
+ ],
+ devDependencies: {'bar'},
+ );
expect(
- loadYaml(lockfile.serialize('', cache)),
- equals({
- 'sdks': {'dart': 'any'},
- 'packages': {
- 'foo': {
- 'version': '1.2.3',
- 'source': 'hosted',
- 'description': {'name': 'foo', 'url': 'https://foo.com'},
- 'dependency': 'transitive'
- },
- 'bar': {
- 'version': '3.2.1',
- 'source': 'hosted',
- 'description': {'name': 'bar', 'url': 'https://bar.com'},
- 'dependency': 'direct dev'
- }
+ loadYaml(lockfile.serialize('', cache)),
+ equals({
+ 'sdks': {'dart': 'any'},
+ 'packages': {
+ 'foo': {
+ 'version': '1.2.3',
+ 'source': 'hosted',
+ 'description': {'name': 'foo', 'url': 'https://foo.com'},
+ 'dependency': 'transitive'
+ },
+ 'bar': {
+ 'version': '3.2.1',
+ 'source': 'hosted',
+ 'description': {'name': 'bar', 'url': 'https://bar.com'},
+ 'dependency': 'direct dev'
}
- }));
+ }
+ }),
+ );
});
});
}
diff --git a/test/must_pub_get_test.dart b/test/must_pub_get_test.dart
index e7b0064..7663401 100644
--- a/test/must_pub_get_test.dart
+++ b/test/must_pub_get_test.dart
@@ -39,9 +39,11 @@
d.pubspec({'name': 'bar'})
]).create();
await d.dir(appPath, [
- d.appPubspec({
- 'bar': {'path': '../bar'}
- })
+ d.appPubspec(
+ dependencies: {
+ 'bar': {'path': '../bar'}
+ },
+ )
]).create();
await pubGet();
@@ -65,7 +67,8 @@
});
_requiresPubGet(
- 'No pubspec.lock file found, please run "dart pub get" first.');
+ 'No pubspec.lock file found, please run "dart pub get" first.',
+ );
});
group("there's no package_config.json", () {
@@ -74,7 +77,8 @@
});
_requiresPubGet(
- 'No .dart_tool${p.separator}package_config.json file found, please run "dart pub get".');
+ 'No .dart_tool${p.separator}package_config.json file found, please run "dart pub get".',
+ );
});
group('the pubspec has a new dependency', () {
@@ -82,9 +86,11 @@
await d.dir('foo', [d.libPubspec('foo', '1.0.0')]).create();
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': '../foo'}
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': '../foo'}
+ },
+ )
]).create();
// Ensure that the pubspec looks newer than the lockfile.
@@ -98,7 +104,7 @@
group('the lockfile has a dependency from the wrong source', () {
setUp(() async {
await d.dir(appPath, [
- d.appPubspec({'foo': '1.0.0'})
+ d.appPubspec(dependencies: {'foo': '1.0.0'})
]).create();
await pubGet();
@@ -116,23 +122,24 @@
group('the lockfile has a dependency from an unknown source', () {
setUp(() async {
await d.dir(appPath, [
- d.appPubspec({'foo': '1.0.0'})
+ d.appPubspec(dependencies: {'foo': '1.0.0'})
]).create();
await pubGet();
await d.dir(appPath, [
d.file(
- 'pubspec.lock',
- yaml({
- 'packages': {
- 'foo': {
- 'description': 'foo',
- 'version': '1.0.0',
- 'source': 'sdk'
- }
+ 'pubspec.lock',
+ yaml({
+ 'packages': {
+ 'foo': {
+ 'description': 'foo',
+ 'version': '1.0.0',
+ 'source': 'sdk'
}
- }))
+ }
+ }),
+ )
]).create();
// Ensure that the pubspec looks newer than the lockfile.
@@ -148,9 +155,11 @@
await d.dir('bar', [d.libPubspec('foo', '1.0.0')]).create();
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': '../bar'}
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': '../bar'}
+ },
+ )
]).create();
await pubGet();
@@ -168,13 +177,13 @@
group('the pubspec has an incompatible version of a dependency', () {
setUp(() async {
await d.dir(appPath, [
- d.appPubspec({'foo': '1.0.0'})
+ d.appPubspec(dependencies: {'foo': '1.0.0'})
]).create();
await pubGet();
await d.dir(appPath, [
- d.appPubspec({'foo': '2.0.0'})
+ d.appPubspec(dependencies: {'foo': '2.0.0'})
]).create();
// Ensure that the pubspec looks newer than the lockfile.
@@ -190,7 +199,7 @@
'pubspec', () {
setUp(() async {
await d.dir(appPath, [
- d.appPubspec({'foo': '1.0.0'})
+ d.appPubspec(dependencies: {'foo': '1.0.0'})
]).create();
await pubGet();
@@ -210,9 +219,11 @@
await d.dir('bar', [d.libPubspec('foo', '1.0.0')]).create();
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': '../bar'}
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': '../bar'}
+ },
+ )
]).create();
await pubGet();
@@ -243,9 +254,13 @@
setUp(() async {
// Avoid using a path dependency because it triggers the full validation
// logic. We want to be sure SDK-validation works without that logic.
- server.serve('foo', '3.0.0', pubspec: {
- 'environment': {'sdk': '>=1.0.0 <2.0.0'}
- });
+ server.serve(
+ 'foo',
+ '3.0.0',
+ pubspec: {
+ 'environment': {'sdk': '>=1.0.0 <2.0.0'}
+ },
+ );
await d.dir(appPath, [
d.pubspec({
@@ -260,7 +275,7 @@
await pubGet(environment: {'_PUB_TEST_SDK_VERSION': '1.2.3+4'});
});
- _requiresPubGet("Dart 0.1.2+3 is incompatible with your dependencies' "
+ _requiresPubGet("Dart 3.1.2+3 is incompatible with your dependencies' "
'SDK constraints. Please run "dart pub get" again.');
});
@@ -269,14 +284,21 @@
'current Flutter SDK', () async {
// Avoid using a path dependency because it triggers the full validation
// logic. We want to be sure SDK-validation works without that logic.
- server.serve('foo', '3.0.0', pubspec: {
- 'environment': {'flutter': '>=1.0.0 <2.0.0'}
- });
+ server.serve(
+ 'foo',
+ '3.0.0',
+ pubspec: {
+ 'environment': {
+ 'flutter': '>=1.0.0 <2.0.0',
+ 'sdk': defaultSdkConstraint
+ }
+ },
+ );
await d.dir('flutter', [d.file('version', '1.2.3')]).create();
await d.dir(appPath, [
- d.appPubspec({'foo': '3.0.0'})
+ d.appPubspec(dependencies: {'foo': '3.0.0'})
]).create();
await pubGet(environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')});
@@ -286,11 +308,12 @@
// Run pub manually here because otherwise we don't have access to
// d.sandbox.
await runPub(
- args: ['run', 'script'],
- environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
- error: "Flutter 0.9.0 is incompatible with your dependencies' SDK "
- 'constraints. Please run "dart pub get" again.',
- exitCode: exit_codes.DATA);
+ args: ['run', 'script'],
+ environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
+ error: "Flutter 0.9.0 is incompatible with your dependencies' SDK "
+ 'constraints. Please run "dart pub get" again.',
+ exitCode: exit_codes.DATA,
+ );
});
group("a path dependency's dependency doesn't match the lockfile", () {
@@ -300,9 +323,11 @@
]).create();
await d.dir(appPath, [
- d.appPubspec({
- 'bar': {'path': '../bar'}
- })
+ d.appPubspec(
+ dependencies: {
+ 'bar': {'path': '../bar'}
+ },
+ )
]).create();
await pubGet();
@@ -327,15 +352,17 @@
'bar',
'1.0.0',
deps: {'foo': '1.0.0'},
- // Creates language version requirement 0.0
- sdk: '>= 0.0.1 <=0.9.9', // tests runs with '0.1.2+3'
+ // Creates language version requirement 2.99
+ sdk: '>= 2.99.0 <=4.0.0', // tests runs with '3.1.2+3'
),
]).create();
await d.dir(appPath, [
- d.appPubspec({
- 'bar': {'path': '../bar'}
- })
+ d.appPubspec(
+ dependencies: {
+ 'bar': {'path': '../bar'}
+ },
+ )
]).create();
await pubGet();
@@ -346,8 +373,8 @@
'bar',
'1.0.0',
deps: {'foo': '1.0.0'},
- // Creates language version requirement 0.1
- sdk: '>= 0.1.0 <=0.9.9', // tests runs with '0.1.2+3'
+ // Creates language version requirement 2.100
+ sdk: '>= 2.100.0 <=4.0.0', // tests runs with '3.1.2+3'
),
]).create();
});
@@ -364,7 +391,7 @@
'package-config, even if the contents are wrong', () {
setUp(() async {
await d.dir(appPath, [
- d.appPubspec({'foo': '1.0.0'})
+ d.appPubspec(dependencies: {'foo': '1.0.0'})
]).create();
// Ensure we get a new mtime (mtime is only reported with 1s precision)
await _touch('pubspec.yaml');
@@ -379,7 +406,7 @@
group("the pubspec is newer than the lockfile, but they're up-to-date", () {
setUp(() async {
await d.dir(appPath, [
- d.appPubspec({'foo': '1.0.0'})
+ d.appPubspec(dependencies: {'foo': '1.0.0'})
]).create();
await pubGet();
@@ -398,9 +425,11 @@
]).create();
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': '../foo'}
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': '../foo'}
+ },
+ )
]).create();
await pubGet();
@@ -415,7 +444,7 @@
() {
setUp(() async {
await d.dir(appPath, [
- d.appPubspec({'foo': '1.0.0'})
+ d.appPubspec(dependencies: {'foo': '1.0.0'})
]).create();
await pubGet();
@@ -428,9 +457,13 @@
group("an overridden dependency's SDK constraint is unmatched", () {
setUp(() async {
- server.serve('bar', '1.0.0', pubspec: {
- 'environment': {'sdk': '0.0.0-fake'}
- });
+ server.serve(
+ 'bar',
+ '1.0.0',
+ pubspec: {
+ 'environment': {'sdk': '0.0.0-fake'}
+ },
+ );
await d.dir(appPath, [
d.pubspec({
@@ -451,14 +484,21 @@
() async {
// Avoid using a path dependency because it triggers the full validation
// logic. We want to be sure SDK-validation works without that logic.
- server.serve('foo', '3.0.0', pubspec: {
- 'environment': {'flutter': '>=1.0.0 <2.0.0'}
- });
+ server.serve(
+ 'foo',
+ '3.0.0',
+ pubspec: {
+ 'environment': {
+ 'flutter': '>=1.0.0 <2.0.0',
+ 'sdk': defaultSdkConstraint
+ }
+ },
+ );
await d.dir('flutter', [d.file('version', '1.2.3')]).create();
await d.dir(appPath, [
- d.appPubspec({'foo': '3.0.0'})
+ d.appPubspec(dependencies: {'foo': '3.0.0'})
]).create();
await pubGet(environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')});
@@ -481,7 +521,10 @@
if (command == 'run') args.add('script');
return runPub(
- args: args, error: contains(message), exitCode: exit_codes.DATA);
+ args: args,
+ error: contains(message),
+ exitCode: exit_codes.DATA,
+ );
});
}
}
diff --git a/test/oauth2/logout_test.dart b/test/oauth2/logout_test.dart
index fb95c73..f5c8619 100644
--- a/test/oauth2/logout_test.dart
+++ b/test/oauth2/logout_test.dart
@@ -11,9 +11,12 @@
test('with an existing credentials file, deletes it.', () async {
await servePackages();
await d
- .credentialsFile(globalServer, 'access token',
- refreshToken: 'refresh token',
- expiration: DateTime.now().add(Duration(hours: 1)))
+ .credentialsFile(
+ globalServer,
+ 'access token',
+ refreshToken: 'refresh token',
+ expiration: DateTime.now().add(Duration(hours: 1)),
+ )
.create();
await runPub(args: ['logout'], output: contains('Logging out of pub.dev.'));
@@ -59,7 +62,9 @@
test('with no existing credentials.json, notifies.', () async {
await d.dir(configPath, [d.nothing('pub-credentials.json')]).create();
await runPub(
- args: ['logout'], output: contains('No existing credentials file'));
+ args: ['logout'],
+ output: contains('No existing credentials file'),
+ );
await d.dir(configPath, [d.nothing('pub-credentials.json')]).validate();
});
diff --git a/test/oauth2/utils.dart b/test/oauth2/utils.dart
index b486f56..f7043a0 100644
--- a/test/oauth2/utils.dart
+++ b/test/oauth2/utils.dart
@@ -13,12 +13,16 @@
import '../test_pub.dart';
-Future authorizePub(TestProcess pub, PackageServer server,
- [String accessToken = 'access token']) async {
+Future authorizePub(
+ TestProcess pub,
+ PackageServer server, [
+ String accessToken = 'access token',
+]) async {
await expectLater(
- pub.stdout,
- emits('Pub needs your authorization to upload packages on your '
- 'behalf.'));
+ pub.stdout,
+ emits('Pub needs your authorization to upload packages on your '
+ 'behalf.'),
+ );
var line = await pub.stdout.next;
var match =
@@ -44,8 +48,9 @@
expect(body, matches(RegExp(r'(^|&)code=access\+code(&|$)')));
return shelf.Response.ok(
- jsonEncode({'access_token': accessToken, 'token_type': 'bearer'}),
- headers: {'content-type': 'application/json'});
+ jsonEncode({'access_token': accessToken, 'token_type': 'bearer'}),
+ headers: {'content-type': 'application/json'},
+ );
});
}
diff --git a/test/oauth2/with_a_malformed_credentials_authenticates_again_test.dart b/test/oauth2/with_a_malformed_credentials_authenticates_again_test.dart
index 75b47ab..31c68a8 100644
--- a/test/oauth2/with_a_malformed_credentials_authenticates_again_test.dart
+++ b/test/oauth2/with_a_malformed_credentials_authenticates_again_test.dart
@@ -17,15 +17,19 @@
await servePackages();
await d.dir(
- configPath, [d.file('pub-credentials.json', '{bad json')]).create();
+ configPath,
+ [d.file('pub-credentials.json', '{bad json')],
+ ).create();
var pub = await startPublish(globalServer);
await confirmPublish(pub);
await authorizePub(pub, globalServer, 'new access token');
globalServer.expect('GET', '/api/packages/versions/new', (request) {
- expect(request.headers,
- containsPair('authorization', 'Bearer new access token'));
+ expect(
+ request.headers,
+ containsPair('authorization', 'Bearer new access token'),
+ );
return shelf.Response(200);
});
diff --git a/test/oauth2/with_a_server_rejected_refresh_token_authenticates_again_test.dart b/test/oauth2/with_a_server_rejected_refresh_token_authenticates_again_test.dart
index 624f427..7e38887 100644
--- a/test/oauth2/with_a_server_rejected_refresh_token_authenticates_again_test.dart
+++ b/test/oauth2/with_a_server_rejected_refresh_token_authenticates_again_test.dart
@@ -21,18 +21,23 @@
await servePackages();
await d
- .credentialsFile(globalServer, 'access token',
- refreshToken: 'bad refresh token',
- expiration: DateTime.now().subtract(Duration(hours: 1)))
+ .credentialsFile(
+ globalServer,
+ 'access token',
+ refreshToken: 'bad refresh token',
+ expiration: DateTime.now().subtract(Duration(hours: 1)),
+ )
.create();
var pub = await startPublish(globalServer);
globalServer.expect('POST', '/token', (request) {
return request.read().drain().then((_) {
- return shelf.Response(400,
- body: jsonEncode({'error': 'invalid_request'}),
- headers: {'content-type': 'application/json'});
+ return shelf.Response(
+ 400,
+ body: jsonEncode({'error': 'invalid_request'}),
+ headers: {'content-type': 'application/json'},
+ );
});
});
@@ -43,8 +48,10 @@
var done = Completer();
globalServer.expect('GET', '/api/packages/versions/new', (request) async {
- expect(request.headers,
- containsPair('authorization', 'Bearer new access token'));
+ expect(
+ request.headers,
+ containsPair('authorization', 'Bearer new access token'),
+ );
// kill pub and complete test
await pub.kill();
diff --git a/test/oauth2/with_an_expired_credentials_refreshes_and_saves_test.dart b/test/oauth2/with_an_expired_credentials_refreshes_and_saves_test.dart
index 7fbbb9f..c4a54e1 100644
--- a/test/oauth2/with_an_expired_credentials_refreshes_and_saves_test.dart
+++ b/test/oauth2/with_an_expired_credentials_refreshes_and_saves_test.dart
@@ -18,9 +18,12 @@
await servePackages();
await d
- .credentialsFile(globalServer, 'access token',
- refreshToken: 'refresh token',
- expiration: DateTime.now().subtract(Duration(hours: 1)))
+ .credentialsFile(
+ globalServer,
+ 'access token',
+ refreshToken: 'refresh token',
+ expiration: DateTime.now().subtract(Duration(hours: 1)),
+ )
.create();
var pub = await startPublish(globalServer);
@@ -29,18 +32,24 @@
globalServer.expect('POST', '/token', (request) {
return request.readAsString().then((body) {
expect(
- body, matches(RegExp(r'(^|&)refresh_token=refresh\+token(&|$)')));
+ body,
+ matches(RegExp(r'(^|&)refresh_token=refresh\+token(&|$)')),
+ );
return shelf.Response.ok(
- jsonEncode(
- {'access_token': 'new access token', 'token_type': 'bearer'}),
- headers: {'content-type': 'application/json'});
+ jsonEncode(
+ {'access_token': 'new access token', 'token_type': 'bearer'},
+ ),
+ headers: {'content-type': 'application/json'},
+ );
});
});
globalServer.expect('GET', '/api/packages/versions/new', (request) {
- expect(request.headers,
- containsPair('authorization', 'Bearer new access token'));
+ expect(
+ request.headers,
+ containsPair('authorization', 'Bearer new access token'),
+ );
return shelf.Response(200);
});
@@ -48,8 +57,11 @@
await pub.shouldExit();
await d
- .credentialsFile(globalServer, 'new access token',
- refreshToken: 'refresh token')
+ .credentialsFile(
+ globalServer,
+ 'new access token',
+ refreshToken: 'refresh token',
+ )
.validate();
});
}
diff --git a/test/oauth2/with_an_expired_credentials_without_a_refresh_token_authenticates_again_test.dart b/test/oauth2/with_an_expired_credentials_without_a_refresh_token_authenticates_again_test.dart
index fb63cde..ac22d7f 100644
--- a/test/oauth2/with_an_expired_credentials_without_a_refresh_token_authenticates_again_test.dart
+++ b/test/oauth2/with_an_expired_credentials_without_a_refresh_token_authenticates_again_test.dart
@@ -17,22 +17,28 @@
await d.validPackage.create();
await d
- .credentialsFile(globalServer, 'access token',
- expiration: DateTime.now().subtract(Duration(hours: 1)))
+ .credentialsFile(
+ globalServer,
+ 'access token',
+ expiration: DateTime.now().subtract(Duration(hours: 1)),
+ )
.create();
var pub = await startPublish(globalServer);
await confirmPublish(pub);
await expectLater(
- pub.stderr,
- emits("Pub's authorization to upload packages has expired and "
- "can't be automatically refreshed."));
+ pub.stderr,
+ emits("Pub's authorization to upload packages has expired and "
+ "can't be automatically refreshed."),
+ );
await authorizePub(pub, globalServer, 'new access token');
globalServer.expect('GET', '/api/packages/versions/new', (request) {
- expect(request.headers,
- containsPair('authorization', 'Bearer new access token'));
+ expect(
+ request.headers,
+ containsPair('authorization', 'Bearer new access token'),
+ );
return shelf.Response(200);
});
diff --git a/test/oauth2/with_no_credentials_authenticates_and_saves_credentials_test.dart b/test/oauth2/with_no_credentials_authenticates_and_saves_credentials_test.dart
index 2fdb7a4..c4d61ed 100644
--- a/test/oauth2/with_no_credentials_authenticates_and_saves_credentials_test.dart
+++ b/test/oauth2/with_no_credentials_authenticates_and_saves_credentials_test.dart
@@ -20,8 +20,10 @@
await authorizePub(pub, globalServer);
globalServer.expect('GET', '/api/packages/versions/new', (request) {
- expect(request.headers,
- containsPair('authorization', 'Bearer access token'));
+ expect(
+ request.headers,
+ containsPair('authorization', 'Bearer access token'),
+ );
return shelf.Response(200);
});
diff --git a/test/oauth2/with_server_rejected_credentials_authenticates_again_test.dart b/test/oauth2/with_server_rejected_credentials_authenticates_again_test.dart
index 2e3b62f..03468cf 100644
--- a/test/oauth2/with_server_rejected_credentials_authenticates_again_test.dart
+++ b/test/oauth2/with_server_rejected_credentials_authenticates_again_test.dart
@@ -22,18 +22,22 @@
await confirmPublish(pub);
globalServer.expect('GET', '/api/packages/versions/new', (request) {
- return shelf.Response(401,
- body: jsonEncode({
- 'error': {'message': 'your token sucks'}
- }),
- headers: {
- 'www-authenticate': 'Bearer error="invalid_token",'
- ' error_description="your token sucks"'
- });
+ return shelf.Response(
+ 401,
+ body: jsonEncode({
+ 'error': {'message': 'your token sucks'}
+ }),
+ headers: {
+ 'www-authenticate': 'Bearer error="invalid_token",'
+ ' error_description="your token sucks"'
+ },
+ );
});
await expectLater(
- pub.stderr, emits('OAuth2 authorization failed (your token sucks).'));
+ pub.stderr,
+ emits('OAuth2 authorization failed (your token sucks).'),
+ );
expect(pub.stdout, emits(startsWith('Uploading...')));
await pub.kill();
});
diff --git a/test/outdated/outdated_test.dart b/test/outdated/outdated_test.dart
index 5a90fae..60622a7 100644
--- a/test/outdated/outdated_test.dart
+++ b/test/outdated/outdated_test.dart
@@ -21,10 +21,6 @@
['outdated', '--no-color', '--prereleases'],
['outdated', '--no-color', '--no-dev-dependencies'],
['outdated', '--no-color', '--no-dependency-overrides'],
- ['outdated', '--no-color', '--mode=null-safety'],
- ['outdated', '--no-color', '--mode=null-safety', '--transitive'],
- ['outdated', '--no-color', '--mode=null-safety', '--no-prereleases'],
- ['outdated', '--json', '--mode=null-safety'],
['outdated', '--json', '--no-dev-dependencies'],
];
for (final args in commands) {
@@ -44,7 +40,7 @@
});
testWithGolden('no lockfile', (ctx) async {
- await d.appDir({'foo': '^1.0.0', 'bar': '^1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '^1.0.0', 'bar': '^1.0.0'}).create();
await servePackages()
..serve('foo', '1.2.3')
..serve('bar', '1.2.3')
@@ -65,10 +61,14 @@
builder
..serve('foo', '1.2.3', deps: {'transitive': '^1.0.0'})
..serve('bar', '1.0.0')
- ..serve('builder', '1.2.3', deps: {
- 'transitive': '^1.0.0',
- 'dev_trans': '^1.0.0',
- })
+ ..serve(
+ 'builder',
+ '1.2.3',
+ deps: {
+ 'transitive': '^1.0.0',
+ 'dev_trans': '^1.0.0',
+ },
+ )
..serve('transitive', '1.2.3')
..serve('dev_trans', '1.0.0');
@@ -91,15 +91,22 @@
await pubGet();
builder
..serve('foo', '1.3.0', deps: {'transitive': '>=1.0.0<3.0.0'})
- ..serve('foo', '2.0.0',
- deps: {'transitive': '>=1.0.0<3.0.0', 'transitive2': '^1.0.0'})
+ ..serve(
+ 'foo',
+ '2.0.0',
+ deps: {'transitive': '>=1.0.0<3.0.0', 'transitive2': '^1.0.0'},
+ )
..serve('foo', '3.0.0', deps: {'transitive': '^2.0.0'})
..serve('builder', '1.3.0', deps: {'transitive': '^1.0.0'})
- ..serve('builder', '2.0.0', deps: {
- 'transitive': '^1.0.0',
- 'transitive3': '^1.0.0',
- 'dev_trans': '^1.0.0'
- })
+ ..serve(
+ 'builder',
+ '2.0.0',
+ deps: {
+ 'transitive': '^1.0.0',
+ 'transitive3': '^1.0.0',
+ 'dev_trans': '^1.0.0'
+ },
+ )
..serve('builder', '3.0.0-alpha', deps: {'transitive': '^1.0.0'})
..serve('transitive', '1.3.0')
..serve('transitive', '2.0.0')
@@ -175,163 +182,6 @@
await ctx.runOutdatedTests();
});
- testWithGolden('null safety compliance', (ctx) async {
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'app',
- 'version': '1.0.1',
- 'dependencies': {
- 'foo': '^1.0.0',
- 'bar': '^1.0.0',
- 'file_opts_out': '^1.0.0',
- 'fails_analysis': '^1.0.0',
- 'file_in_dependency_opts_out': '^1.0.0',
- 'fails_analysis_in_dependency': '^1.0.0',
- },
- 'environment': {'sdk': '>=2.12.0 < 3.0.0'},
- }),
- ]).create();
-
- await servePackages()
- ..serve('foo', '1.0.0', deps: {
- 'bar': '^1.0.0'
- }, pubspec: {
- 'environment': {'sdk': '>=2.9.0 < 3.0.0'}
- })
- ..serve('bar', '1.0.0', pubspec: {
- 'environment': {'sdk': '>=2.9.0 < 3.0.0'}
- })
- ..serve('foo', '2.0.0-nullsafety.0', deps: {
- 'bar': '^2.0.0'
- }, pubspec: {
- 'environment': {'sdk': '>=2.12.0 < 3.0.0'}
- })
- ..serve('foo', '2.0.0', deps: {
- 'bar': '^1.0.0'
- }, pubspec: {
- 'environment': {'sdk': '>=2.12.0 < 3.0.0'}
- })
- ..serve('bar', '2.0.0', pubspec: {
- 'environment': {'sdk': '>=2.13.0 < 3.0.0'}
- })
- ..serve('file_opts_out', '1.0.0', pubspec: {
- 'environment': {'sdk': '>=2.12.0 < 3.0.0'},
- }, contents: [
- d.dir('lib', [d.file('main.dart', '// @dart = 2.9\n')])
- ])
- ..serve('file_opts_out', '2.0.0', pubspec: {
- 'environment': {'sdk': '>=2.12.0 < 3.0.0'},
- })
- ..serve('fails_analysis', '1.0.0', pubspec: {
- 'environment': {'sdk': '>=2.12.0 < 3.0.0'},
- }, contents: [
- d.dir('lib', [d.file('main.dart', 'syntax error\n')])
- ])
- ..serve('fails_analysis', '2.0.0', pubspec: {
- 'environment': {'sdk': '>=2.12.0 < 3.0.0'},
- })
- ..serve('file_in_dependency_opts_out', '1.0.0', deps: {
- 'file_opts_out': '^1.0.0'
- }, pubspec: {
- 'environment': {'sdk': '>=2.12.0 < 3.0.0'},
- })
- ..serve('file_in_dependency_opts_out', '2.0.0', pubspec: {
- 'environment': {'sdk': '>=2.12.0 < 3.0.0'},
- })
- ..serve('fails_analysis_in_dependency', '1.0.0', deps: {
- 'fails_analysis': '^1.0.0'
- }, pubspec: {
- 'environment': {'sdk': '>=2.12.0 < 3.0.0'},
- })
- ..serve('fails_analysis_in_dependency', '2.0.0', pubspec: {
- 'environment': {'sdk': '>=2.12.0 < 3.0.0'},
- });
- await pubGet(environment: {'_PUB_TEST_SDK_VERSION': '2.13.0'});
-
- await ctx.runOutdatedTests(environment: {
- '_PUB_TEST_SDK_VERSION': '2.13.0',
- });
- });
-
- testWithGolden('null-safety no resolution', (ctx) async {
- await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'environment': {'sdk': '>=2.9.0 < 3.0.0'}
- })
- ..serve('foo', '2.0.0-nullsafety.0', deps: {
- 'bar': '^1.0.0'
- }, pubspec: {
- 'environment': {'sdk': '>=2.12.0 < 3.0.0'}
- })
- ..serve('bar', '1.0.0', pubspec: {
- 'environment': {'sdk': '>=2.9.0 < 3.0.0'}
- })
- ..serve('bar', '2.0.0-nullsafety.0', deps: {
- 'foo': '^1.0.0'
- }, pubspec: {
- 'environment': {'sdk': '>=2.12.0 < 3.0.0'}
- });
-
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'app',
- 'version': '1.0.0',
- 'dependencies': {
- 'foo': '^1.0.0',
- 'bar': '^1.0.0',
- },
- 'environment': {'sdk': '>=2.12.0 < 3.0.0'},
- }),
- ]).create();
-
- await pubGet(environment: {'_PUB_TEST_SDK_VERSION': '2.13.0'});
-
- await ctx.runOutdatedTests(environment: {
- '_PUB_TEST_SDK_VERSION': '2.13.0',
- });
- });
-
- testWithGolden('null-safety already migrated', (ctx) async {
- await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'environment': {'sdk': '>=2.9.0 < 3.0.0'}
- })
- ..serve('foo', '2.0.0', pubspec: {
- 'environment': {'sdk': '>=2.12.0 < 3.0.0'}
- })
- ..serve('bar', '1.0.0', pubspec: {
- 'environment': {'sdk': '>=2.9.0 < 3.0.0'}
- })
- ..serve('bar', '2.0.0', deps: {
- 'devTransitive': '^1.0.0'
- }, pubspec: {
- 'environment': {'sdk': '>=2.12.0 < 3.0.0'}
- })
- ..serve('devTransitive', '1.0.0', pubspec: {
- 'environment': {'sdk': '>=2.9.0 < 3.0.0'}
- });
-
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'app',
- 'version': '1.0.0',
- 'dependencies': {
- 'foo': '^2.0.0',
- },
- 'dev_dependencies': {
- 'bar': '^2.0.0',
- },
- 'environment': {'sdk': '>=2.12.0 < 3.0.0'},
- }),
- ]).create();
-
- await pubGet(environment: {'_PUB_TEST_SDK_VERSION': '2.13.0'});
-
- await ctx.runOutdatedTests(environment: {
- '_PUB_TEST_SDK_VERSION': '2.13.0',
- });
- });
-
testWithGolden('overridden dependencies', (ctx) async {
ensureGit();
await servePackages()
@@ -434,15 +284,27 @@
testWithGolden('Handles SDK dependencies', (ctx) async {
await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'environment': {'sdk': '>=2.10.0 <3.0.0'}
- })
- ..serve('foo', '1.1.0', pubspec: {
- 'environment': {'sdk': '>=2.10.0 <3.0.0'}
- })
- ..serve('foo', '2.0.0', pubspec: {
- 'environment': {'sdk': '>=2.12.0 <3.0.0'}
- });
+ ..serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'environment': {'sdk': '>=2.10.0 <3.0.0'}
+ },
+ )
+ ..serve(
+ 'foo',
+ '1.1.0',
+ pubspec: {
+ 'environment': {'sdk': '>=2.10.0 <3.0.0'}
+ },
+ )
+ ..serve(
+ 'foo',
+ '2.0.0',
+ pubspec: {
+ 'environment': {'sdk': '>=2.12.0 <3.0.0'}
+ },
+ );
await d.dir('flutter-root', [
d.file('version', '1.2.3'),
@@ -476,17 +338,21 @@
})
]).create();
- await pubGet(environment: {
- 'FLUTTER_ROOT': d.path('flutter-root'),
- '_PUB_TEST_SDK_VERSION': '2.13.0'
- });
+ await pubGet(
+ environment: {
+ 'FLUTTER_ROOT': d.path('flutter-root'),
+ '_PUB_TEST_SDK_VERSION': '2.13.0'
+ },
+ );
- await ctx.runOutdatedTests(environment: {
- 'FLUTTER_ROOT': d.path('flutter-root'),
- '_PUB_TEST_SDK_VERSION': '2.13.0',
- // To test that the reproduction command is reflected correctly.
- 'PUB_ENVIRONMENT': 'flutter_cli:get',
- });
+ await ctx.runOutdatedTests(
+ environment: {
+ 'FLUTTER_ROOT': d.path('flutter-root'),
+ '_PUB_TEST_SDK_VERSION': '2.13.0',
+ // To test that the reproduction command is reflected correctly.
+ 'PUB_ENVIRONMENT': 'flutter_cli:get',
+ },
+ );
});
testWithGolden('does not allow arguments - handles bad flags', (ctx) async {
diff --git a/test/package_config_file_test.dart b/test/package_config_file_test.dart
index 763ce42..d94d7fc 100644
--- a/test/package_config_file_test.dart
+++ b/test/package_config_file_test.dart
@@ -13,14 +13,22 @@
forBothPubGetAndUpgrade((command) {
test('package_config.json file is created', () async {
await servePackages()
- ..serve('foo', '1.2.3',
- deps: {'baz': '2.2.2'}, contents: [d.dir('lib', [])])
+ ..serve(
+ 'foo',
+ '1.2.3',
+ deps: {'baz': '2.2.2'},
+ contents: [d.dir('lib', [])],
+ )
..serve('bar', '3.2.1', contents: [d.dir('lib', [])])
- ..serve('baz', '2.2.2',
- deps: {'bar': '3.2.1'}, contents: [d.dir('lib', [])]);
+ ..serve(
+ 'baz',
+ '2.2.2',
+ deps: {'bar': '3.2.1'},
+ contents: [d.dir('lib', [])],
+ );
await d.dir(appPath, [
- d.appPubspec({'foo': '1.2.3'}),
+ d.appPubspec(dependencies: {'foo': '1.2.3'}),
d.dir('lib')
]).create();
@@ -31,22 +39,22 @@
d.packageConfigEntry(
name: 'foo',
version: '1.2.3',
- languageVersion: '2.7',
+ languageVersion: '3.0',
),
d.packageConfigEntry(
name: 'bar',
version: '3.2.1',
- languageVersion: '2.7',
+ languageVersion: '3.0',
),
d.packageConfigEntry(
name: 'baz',
version: '2.2.2',
- languageVersion: '2.7',
+ languageVersion: '3.0',
),
d.packageConfigEntry(
name: 'myapp',
path: '.',
- languageVersion: '0.1',
+ languageVersion: '3.0',
),
]),
]).validate();
@@ -54,14 +62,22 @@
test('package_config.json file is overwritten', () async {
await servePackages()
- ..serve('foo', '1.2.3',
- deps: {'baz': '2.2.2'}, contents: [d.dir('lib', [])])
+ ..serve(
+ 'foo',
+ '1.2.3',
+ deps: {'baz': '2.2.2'},
+ contents: [d.dir('lib', [])],
+ )
..serve('bar', '3.2.1', contents: [d.dir('lib', [])])
- ..serve('baz', '2.2.2',
- deps: {'bar': '3.2.1'}, contents: [d.dir('lib', [])]);
+ ..serve(
+ 'baz',
+ '2.2.2',
+ deps: {'bar': '3.2.1'},
+ contents: [d.dir('lib', [])],
+ );
await d.dir(appPath, [
- d.appPubspec({'foo': '1.2.3'}),
+ d.appPubspec(dependencies: {'foo': '1.2.3'}),
d.dir('lib')
]).create();
@@ -84,22 +100,22 @@
d.packageConfigEntry(
name: 'foo',
version: '1.2.3',
- languageVersion: '2.7',
+ languageVersion: '3.0',
),
d.packageConfigEntry(
name: 'bar',
version: '3.2.1',
- languageVersion: '2.7',
+ languageVersion: '3.0',
),
d.packageConfigEntry(
name: 'baz',
version: '2.2.2',
- languageVersion: '2.7',
+ languageVersion: '3.0',
),
d.packageConfigEntry(
name: 'myapp',
path: '.',
- languageVersion: '0.1',
+ languageVersion: '3.0',
),
]),
]).validate();
@@ -107,17 +123,21 @@
test('package_config.json file is not created if pub fails', () async {
await d.dir(appPath, [
- d.appPubspec({'foo': '1.2.3'}),
+ d.appPubspec(dependencies: {'foo': '1.2.3'}),
d.dir('lib')
]).create();
- await pubCommand(command,
- args: ['--offline'], error: equalsIgnoringWhitespace("""
+ await pubCommand(
+ command,
+ args: ['--offline'],
+ error: equalsIgnoringWhitespace("""
Because myapp depends on foo any which doesn't exist (could not find
package foo in cache), version solving failed.
Try again without --offline!
- """), exitCode: exit_codes.UNAVAILABLE);
+ """),
+ exitCode: exit_codes.UNAVAILABLE,
+ );
await d.dir(appPath, [
d.nothing('.dart_tool/package_config.json'),
@@ -128,13 +148,17 @@
'.dart_tool/package_config.json file has relative path to path dependency',
() async {
await servePackages()
- ..serve('foo', '1.2.3',
- deps: {'baz': 'any'}, contents: [d.dir('lib', [])])
+ ..serve(
+ 'foo',
+ '1.2.3',
+ deps: {'baz': 'any'},
+ contents: [d.dir('lib', [])],
+ )
..serve('baz', '9.9.9', deps: {}, contents: [d.dir('lib', [])]);
await d.dir('local_baz', [
d.libDir('baz', 'baz 3.2.1'),
- d.rawPubspec({
+ d.pubspec({
'name': 'baz',
'version': '3.2.1',
}),
@@ -160,17 +184,17 @@
d.packageConfigEntry(
name: 'foo',
version: '1.2.3',
- languageVersion: '2.7',
+ languageVersion: '3.0',
),
d.packageConfigEntry(
name: 'baz',
path: '../local_baz',
- languageVersion: '2.7',
+ languageVersion: '3.0',
),
d.packageConfigEntry(
name: 'myapp',
path: '.',
- languageVersion: '0.1',
+ languageVersion: '3.0',
),
]),
]).validate();
@@ -183,7 +207,7 @@
'1.2.3',
pubspec: {
'environment': {
- 'sdk': '>=0.0.1 <=0.2.2+2', // tests runs with '0.1.2+3'
+ 'sdk': '>=3.0.1 <=3.2.2+2', // tests runs with '3.1.2+3'
},
},
contents: [d.dir('lib', [])],
@@ -196,7 +220,7 @@
'foo': '^1.2.3',
},
'environment': {
- 'sdk': '>=0.1.0 <=0.2.2+2', // tests runs with '0.1.2+3'
+ 'sdk': '>=3.1.0 <=3.2.2+2', // tests runs with '3.1.2+3'
},
}),
d.dir('lib')
@@ -209,25 +233,26 @@
d.packageConfigEntry(
name: 'foo',
version: '1.2.3',
- languageVersion: '0.0',
+ languageVersion: '3.0',
),
d.packageConfigEntry(
name: 'myapp',
path: '.',
- languageVersion: '0.1',
+ languageVersion: '3.1',
),
]),
]).validate();
});
test('package_config.json has 2.7 default language version', () async {
+ // TODO(sigurdm): Reconsider the default language version for dart 3.
final server = await servePackages();
server.serve(
'foo',
'1.2.3',
pubspec: {
'environment': {
- 'sdk': 'any',
+ 'sdk': '<4.0.0',
},
},
contents: [d.dir('lib', [])],
@@ -255,7 +280,7 @@
d.packageConfigEntry(
name: 'myapp',
path: '.',
- languageVersion: '0.1',
+ languageVersion: '3.0',
),
]),
]).validate();
diff --git a/test/package_list_files_test.dart b/test/package_list_files_test.dart
index 889d773..1fadb8c 100644
--- a/test/package_list_files_test.dart
+++ b/test/package_list_files_test.dart
@@ -33,16 +33,20 @@
createEntrypoint();
expect(
- entrypoint!.root.listFiles(),
- unorderedEquals([
- p.join(root, 'pubspec.yaml'),
- p.join(root, 'file1.txt'),
- p.join(root, 'file2.txt'),
- p.join(root, 'subdir', 'subfile1.txt'),
- p.join(root, 'subdir', 'subfile2.txt'),
- p.join(root, Uri.encodeComponent('\\/%+-='),
- Uri.encodeComponent('\\/%+-=')),
- ]));
+ entrypoint!.root.listFiles(),
+ unorderedEquals([
+ p.join(root, 'pubspec.yaml'),
+ p.join(root, 'file1.txt'),
+ p.join(root, 'file2.txt'),
+ p.join(root, 'subdir', 'subfile1.txt'),
+ p.join(root, 'subdir', 'subfile2.txt'),
+ p.join(
+ root,
+ Uri.encodeComponent('\\/%+-='),
+ Uri.encodeComponent('\\/%+-='),
+ ),
+ ]),
+ );
});
// On windows symlinks to directories are distinct from symlinks to files.
@@ -64,7 +68,9 @@
]),
]).create();
createDirectorySymlink(
- p.join(d.sandbox, appPath, 'subdir', 'symlink'), 'a');
+ p.join(d.sandbox, appPath, 'subdir', 'symlink'),
+ 'a',
+ );
createEntrypoint();
@@ -95,8 +101,10 @@
final root = p.join(d.sandbox, 'symlink');
createDirectorySymlink(root, appPath);
- final entrypoint = Entrypoint(p.join(d.sandbox, 'symlink'),
- SystemCache(rootDir: p.join(d.sandbox, cachePath)));
+ final entrypoint = Entrypoint(
+ p.join(d.sandbox, 'symlink'),
+ SystemCache(rootDir: p.join(d.sandbox, cachePath)),
+ );
expect(entrypoint.root.listFiles(), {
p.join(root, 'pubspec.yaml'),
@@ -127,7 +135,8 @@
(e) => e.message,
'message',
contains(
- 'Pub does not support publishing packages with non-resolving symlink:'),
+ 'Pub does not support publishing packages with non-resolving symlink:',
+ ),
),
),
);
@@ -155,7 +164,8 @@
(e) => e.message,
'message',
contains(
- 'Pub does not support publishing packages with non-resolving symlink:'),
+ 'Pub does not support publishing packages with non-resolving symlink:',
+ ),
),
),
);
diff --git a/test/package_server.dart b/test/package_server.dart
index d69d0ef..9990a5f 100644
--- a/test/package_server.dart
+++ b/test/package_server.dart
@@ -82,31 +82,32 @@
}
return shelf.Response.ok(
- jsonEncode({
- 'name': name,
- 'uploaders': ['nweiz@google.com'],
- 'versions': [
- for (final version in package.versions.values)
- {
- 'pubspec': version.pubspec,
- 'version': version.version.toString(),
- 'archive_url':
- '${server.url}/packages/$name/versions/${version.version}.tar.gz',
- if (version.isRetracted) 'retracted': true,
- if (version.sha256 != null || server.serveContentHashes)
- 'archive_sha256': version.sha256 ??
- hexEncode(
- (await sha256.bind(version.contents()).first)
- .bytes)
- }
- ],
- if (package.isDiscontinued) 'isDiscontinued': true,
- if (package.discontinuedReplacementText != null)
- 'replacedBy': package.discontinuedReplacementText,
- }),
- headers: {
- HttpHeaders.contentTypeHeader: 'application/vnd.pub.v2+json'
- });
+ jsonEncode({
+ 'name': name,
+ 'uploaders': ['nweiz@google.com'],
+ 'versions': [
+ for (final version in package.versions.values)
+ {
+ 'pubspec': version.pubspec,
+ 'version': version.version.toString(),
+ 'archive_url':
+ '${server.url}/packages/$name/versions/${version.version}.tar.gz',
+ if (version.isRetracted) 'retracted': true,
+ if (version.sha256 != null || server.serveContentHashes)
+ 'archive_sha256': version.sha256 ??
+ hexEncode(
+ (await sha256.bind(version.contents()).first).bytes,
+ )
+ }
+ ],
+ if (package.isDiscontinued) 'isDiscontinued': true,
+ if (package.discontinuedReplacementText != null)
+ 'replacedBy': package.discontinuedReplacementText,
+ }),
+ headers: {
+ HttpHeaders.contentTypeHeader: 'application/vnd.pub.v2+json'
+ },
+ );
},
);
@@ -123,7 +124,8 @@
}
final version = Version.parse(
- parts[3].substring(0, parts[3].length - '.tar.gz'.length));
+ parts[3].substring(0, parts[3].length - '.tar.gz'.length),
+ );
assert(parts[3].endsWith('.tar.gz'));
for (final packageVersion in package.versions.values) {
@@ -138,11 +140,14 @@
if (server.serveChecksums &&
!headers.containsKey(checksumHeaderName)) {
headers[checksumHeaderName] = composeChecksumHeader(
- crc32c: await packageVersion.computeArchiveCrc32c());
+ crc32c: await packageVersion.computeArchiveCrc32c(),
+ );
}
- return shelf.Response.ok(packageVersion.contents(),
- headers: headers);
+ return shelf.Response.ok(
+ packageVersion.contents(),
+ headers: headers,
+ );
}
}
return shelf.Response.notFound('No version $version of $name');
@@ -222,12 +227,20 @@
///
/// If [contents] is passed, it's used as the contents of the package. By
/// default, a package just contains a dummy lib directory.
- void serve(String name, String version,
- {Map<String, dynamic>? deps,
- Map<String, dynamic>? pubspec,
- List<d.Descriptor>? contents,
- Map<String, List<String>>? headers}) {
- var pubspecFields = <String, dynamic>{'name': name, 'version': version};
+ void serve(
+ String name,
+ String version, {
+ Map<String, dynamic>? deps,
+ Map<String, dynamic>? pubspec,
+ List<d.Descriptor>? contents,
+ String? sdk,
+ Map<String, List<String>>? headers,
+ }) {
+ var pubspecFields = <String, dynamic>{
+ 'name': name,
+ 'version': version,
+ 'environment': {'sdk': sdk ?? '^3.0.0'}
+ };
if (pubspec != null) pubspecFields.addAll(pubspec);
if (deps != null) pubspecFields['dependencies'] = deps;
@@ -243,8 +256,11 @@
}
// Mark a package discontinued.
- void discontinue(String name,
- {bool isDiscontinued = true, String? replacementText}) {
+ void discontinue(
+ String name, {
+ bool isDiscontinued = true,
+ String? replacementText,
+ }) {
_packages[name]!
..isDiscontinued = isDiscontinued
..discontinuedReplacementText = replacementText;
@@ -284,8 +300,10 @@
return checksumHeader?.join(',');
}
- static List<String> composeChecksumHeader(
- {int? crc32c, String? md5 = '5f4dcc3b5aa765d61d8327deb882cf99'}) {
+ static List<String> composeChecksumHeader({
+ int? crc32c,
+ String? md5 = '5f4dcc3b5aa765d61d8327deb882cf99',
+ }) {
List<String> header = [];
if (crc32c != null) {
diff --git a/test/pub_get_and_upgrade_test.dart b/test/pub_get_and_upgrade_test.dart
index f64f93b..83b06b1 100644
--- a/test/pub_get_and_upgrade_test.dart
+++ b/test/pub_get_and_upgrade_test.dart
@@ -15,10 +15,12 @@
test('a pubspec', () async {
await d.dir(appPath, []).create();
- await pubCommand(command,
- error: RegExp(r'Could not find a file named "pubspec.yaml" '
- r'in "[^\n]*"\.'),
- exitCode: exit_codes.NO_INPUT);
+ await pubCommand(
+ command,
+ error: RegExp(r'Could not find a file named "pubspec.yaml" '
+ r'in "[^\n]*"\.'),
+ exitCode: exit_codes.NO_INPUT,
+ );
});
test('a pubspec with a "name" key', () async {
@@ -28,9 +30,11 @@
})
]).create();
- await pubCommand(command,
- error: contains('Missing the required "name" field.'),
- exitCode: exit_codes.DATA);
+ await pubCommand(
+ command,
+ error: contains('Missing the required "name" field.'),
+ exitCode: exit_codes.DATA,
+ );
});
});
@@ -46,7 +50,8 @@
await d.dir('myapp', [
d.packageConfigFile(
- [d.packageConfigEntry(name: 'myapp_name', path: '.')]),
+ [d.packageConfigEntry(name: 'myapp_name', path: '.')],
+ ),
]).validate();
});
@@ -75,26 +80,34 @@
]).create();
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': '../deps/foo'},
- 'bar': {'path': '../deps/bar'}
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': '../deps/foo'},
+ 'bar': {'path': '../deps/bar'}
+ },
+ )
]).create();
- await pubCommand(command,
- error: RegExp(r'bar from path is incompatible with foo from path'));
+ await pubCommand(
+ command,
+ error: RegExp(r'bar from path is incompatible with foo from path'),
+ );
});
test('does not allow a dependency on itself', () async {
await d.dir(appPath, [
- d.appPubspec({
- 'myapp': {'path': '.'}
- })
+ d.appPubspec(
+ dependencies: {
+ 'myapp': {'path': '.'}
+ },
+ )
]).create();
- await pubCommand(command,
- error: contains('A package may not list itself as a dependency.'),
- exitCode: exit_codes.DATA);
+ await pubCommand(
+ command,
+ error: contains('A package may not list itself as a dependency.'),
+ exitCode: exit_codes.DATA,
+ );
});
test('does not allow a dev dependency on itself', () async {
@@ -107,9 +120,11 @@
})
]).create();
- await pubCommand(command,
- error: contains('A package may not list itself as a dependency.'),
- exitCode: exit_codes.DATA);
+ await pubCommand(
+ command,
+ error: contains('A package may not list itself as a dependency.'),
+ exitCode: exit_codes.DATA,
+ );
});
});
}
diff --git a/test/pubspec_overrides_test.dart b/test/pubspec_overrides_test.dart
index 9f48c23..5d71c3a 100644
--- a/test/pubspec_overrides_test.dart
+++ b/test/pubspec_overrides_test.dart
@@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:path/path.dart' as p;
import 'package:test/test.dart';
import 'descriptor.dart' as d;
@@ -15,19 +16,19 @@
..serve('lib', '2.0.0');
await d.dir(appPath, [
- d.appPubspec({'lib': '1.0.0'}),
+ d.appPubspec(dependencies: {'lib': '1.0.0'}),
d.dir('lib'),
d.pubspecOverrides({
'dependency_overrides': {'lib': '2.0.0'}
}),
]).create();
+ final overridesPath = p.join('.', 'pubspec_overrides.yaml');
await pubCommand(
command,
- warning:
- 'Warning: pubspec.yaml has overrides from pubspec_overrides.yaml\n'
- 'Warning: You are using these overridden dependencies:\n'
- '! lib 2.0.0',
+ output: contains(
+ '! lib 2.0.0 (overridden in $overridesPath)',
+ ),
);
await d.dir(appPath, [
@@ -35,15 +36,71 @@
d.packageConfigEntry(
name: 'lib',
version: '2.0.0',
- languageVersion: '2.7',
+ languageVersion: '3.0',
),
d.packageConfigEntry(
name: 'myapp',
path: '.',
- languageVersion: '0.1',
+ languageVersion: '3.0',
),
])
]).validate();
});
});
+
+ test('pubspec_overrides.yaml shadows overrides from pubspec.yaml', () async {
+ await servePackages()
+ ..serve('lib', '1.0.0')
+ ..serve('lib', '2.0.0')
+ ..serve('lib', '3.0.0')
+ ..serve('foo', '1.0.0')
+ ..serve('foo', '2.0.0');
+
+ await d.dir(appPath, [
+ d.appPubspec(
+ dependencies: {'lib': '1.0.0', 'foo': '1.0.0'},
+ extras: {
+ 'dependency_overrides': {'lib': '2.0.0', 'foo': '2.0.0'}
+ },
+ ),
+ d.dir('lib'),
+ // empty overrides file:
+ d.pubspecOverrides({
+ 'dependency_overrides': {'lib': '3.0.0'}
+ }),
+ ]).create();
+
+ final overridesPath = p.join('.', 'pubspec_overrides.yaml');
+ await pubGet(
+ output: allOf(
+ contains('! lib 3.0.0 (overridden in $overridesPath)'),
+ contains('+ foo 1.0.0 (2.0.0 available)'),
+ ),
+ );
+ });
+ test(
+ "An empty pubspec_overrides.yaml doesn't shadow overrides from pubspec.yaml",
+ () async {
+ await servePackages()
+ ..serve('lib', '1.0.0')
+ ..serve('lib', '2.0.0');
+
+ await d.dir(appPath, [
+ d.appPubspec(
+ dependencies: {
+ 'lib': '1.0.0',
+ },
+ extras: {
+ 'dependency_overrides': {'lib': '2.0.0'}
+ },
+ ),
+ d.dir('lib'),
+ // empty overrides file:
+ d.pubspecOverrides({}),
+ ]).create();
+
+ await pubGet(
+ output: contains('! lib 2.0.0 (overridden)'),
+ );
+ });
}
diff --git a/test/pubspec_test.dart b/test/pubspec_test.dart
index c4e3112..b1dc3b0 100644
--- a/test/pubspec_test.dart
+++ b/test/pubspec_test.dart
@@ -18,12 +18,18 @@
var throwsPubspecException =
throwsA(const TypeMatcher<SourceSpanApplicationException>());
- void expectPubspecException(String contents, void Function(Pubspec) fn,
- [String? expectedContains]) {
+ void expectPubspecException(
+ String contents,
+ void Function(Pubspec) fn, [
+ String? expectedContains,
+ ]) {
var expectation = const TypeMatcher<SourceSpanApplicationException>();
if (expectedContains != null) {
expectation = expectation.having(
- (error) => error.message, 'message', contains(expectedContains));
+ (error) => error.message,
+ 'message',
+ contains(expectedContains),
+ );
}
var pubspec = Pubspec.parse(contents, sources);
@@ -38,26 +44,33 @@
test(
"eagerly throws an error if the pubspec name doesn't match the "
'expected name', () {
- expect(() => Pubspec.parse('name: foo', sources, expectedName: 'bar'),
- throwsPubspecException);
+ expect(
+ () => Pubspec.parse('name: foo', sources, expectedName: 'bar'),
+ throwsPubspecException,
+ );
});
test(
"eagerly throws an error if the pubspec doesn't have a name and an "
'expected name is passed', () {
- expect(() => Pubspec.parse('{}', sources, expectedName: 'bar'),
- throwsPubspecException);
+ expect(
+ () => Pubspec.parse('{}', sources, expectedName: 'bar'),
+ throwsPubspecException,
+ );
});
test('allows a version constraint for dependencies', () {
- var pubspec = Pubspec.parse('''
+ var pubspec = Pubspec.parse(
+ '''
dependencies:
foo:
hosted:
name: foo
url: https://foo.com
version: ">=1.2.3 <3.4.5"
-''', sources);
+''',
+ sources,
+ );
var foo = pubspec.dependencies['foo']!;
expect(foo.name, equals('foo'));
@@ -67,14 +80,17 @@
});
test('allows empty version constraint', () {
- var pubspec = Pubspec.parse('''
+ var pubspec = Pubspec.parse(
+ '''
dependencies:
foo:
hosted:
name: foo
url: https://foo.com
version: ">=1.2.3 <0.0.0"
-''', sources);
+''',
+ sources,
+ );
var foo = pubspec.dependencies['foo']!;
expect(foo.name, equals('foo'));
@@ -82,22 +98,28 @@
});
test('allows an empty dependencies map', () {
- var pubspec = Pubspec.parse('''
+ var pubspec = Pubspec.parse(
+ '''
dependencies:
-''', sources);
+''',
+ sources,
+ );
expect(pubspec.dependencies, isEmpty);
});
test('allows a version constraint for dev dependencies', () {
- var pubspec = Pubspec.parse('''
+ var pubspec = Pubspec.parse(
+ '''
dev_dependencies:
foo:
hosted:
name: foo
url: https://foo.com
version: ">=1.2.3 <3.4.5"
-''', sources);
+''',
+ sources,
+ );
var foo = pubspec.devDependencies['foo']!;
expect(foo.name, equals('foo'));
@@ -107,22 +129,28 @@
});
test('allows an empty dev dependencies map', () {
- var pubspec = Pubspec.parse('''
+ var pubspec = Pubspec.parse(
+ '''
dev_dependencies:
-''', sources);
+''',
+ sources,
+ );
expect(pubspec.devDependencies, isEmpty);
});
test('allows a version constraint for dependency overrides', () {
- var pubspec = Pubspec.parse('''
+ var pubspec = Pubspec.parse(
+ '''
dependency_overrides:
foo:
hosted:
name: foo
url: https://foo.com
version: ">=1.2.3 <3.4.5"
-''', sources);
+''',
+ sources,
+ );
var foo = pubspec.dependencyOverrides['foo']!;
expect(foo.name, equals('foo'));
@@ -132,19 +160,25 @@
});
test('allows an empty dependency overrides map', () {
- var pubspec = Pubspec.parse('''
+ var pubspec = Pubspec.parse(
+ '''
dependency_overrides:
-''', sources);
+''',
+ sources,
+ );
expect(pubspec.dependencyOverrides, isEmpty);
});
test('allows an unknown source', () {
- var pubspec = Pubspec.parse('''
+ var pubspec = Pubspec.parse(
+ '''
dependencies:
foo:
unknown: blah
-''', sources);
+''',
+ sources,
+ );
var foo = pubspec.dependencies['foo']!;
expect(foo.name, equals('foo'));
@@ -152,11 +186,14 @@
});
test('allows a default source', () {
- var pubspec = Pubspec.parse('''
+ var pubspec = Pubspec.parse(
+ '''
dependencies:
foo:
version: 1.2.3
-''', sources);
+''',
+ sources,
+ );
var foo = pubspec.dependencies['foo']!;
expect(foo.name, equals('foo'));
@@ -164,69 +201,92 @@
});
test('throws if it depends on itself', () {
- expectPubspecException('''
+ expectPubspecException(
+ '''
name: myapp
dependencies:
myapp:
fake: ok
-''', (pubspec) => pubspec.dependencies);
+''',
+ (pubspec) => pubspec.dependencies,
+ );
});
test('throws if it has a dev dependency on itself', () {
- expectPubspecException('''
+ expectPubspecException(
+ '''
name: myapp
dev_dependencies:
myapp:
fake: ok
-''', (pubspec) => pubspec.devDependencies);
+''',
+ (pubspec) => pubspec.devDependencies,
+ );
});
test('throws if it has an override on itself', () {
- expectPubspecException('''
+ expectPubspecException(
+ '''
name: myapp
dependency_overrides:
myapp:
fake: ok
-''', (pubspec) => pubspec.dependencyOverrides);
+''',
+ (pubspec) => pubspec.dependencyOverrides,
+ );
});
test("throws if the description isn't valid", () {
- expectPubspecException('''
+ expectPubspecException(
+ '''
name: myapp
dependencies:
foo:
hosted:
name: foo
url: '::'
-''', (pubspec) => pubspec.dependencies);
+''',
+ (pubspec) => pubspec.dependencies,
+ );
});
test('throws if dependency version is not a string', () {
- expectPubspecException('''
+ expectPubspecException(
+ '''
dependencies:
foo:
fake: ok
version: 1.2
-''', (pubspec) => pubspec.dependencies);
+''',
+ (pubspec) => pubspec.dependencies,
+ );
});
test('throws if version is not a version constraint', () {
- expectPubspecException('''
+ expectPubspecException(
+ '''
dependencies:
foo:
fake: ok
version: not constraint
-''', (pubspec) => pubspec.dependencies);
+''',
+ (pubspec) => pubspec.dependencies,
+ );
});
test("throws if 'name' is not a string", () {
expectPubspecException(
- 'name: [not, a, string]', (pubspec) => pubspec.name);
+ 'name: [not, a, string]',
+ (pubspec) => pubspec.name,
+ );
});
test('throws if version is not a string', () {
- expectPubspecException('version: [2, 0, 0]', (pubspec) => pubspec.version,
- '"version" field must be a string');
+ expectPubspecException(
+ 'version: [2, 0, 0]',
+ (pubspec) => pubspec.version,
+ '"version" field must be a string',
+ );
});
test('throws if version is malformed (looking like a double)', () {
@@ -247,16 +307,21 @@
test('throws if version is not a version', () {
expectPubspecException(
- 'version: not version', (pubspec) => pubspec.version);
+ 'version: not version',
+ (pubspec) => pubspec.version,
+ );
});
test('allows comment-only files', () {
- var pubspec = Pubspec.parse('''
+ var pubspec = Pubspec.parse(
+ '''
# No external dependencies yet
# Including for completeness
# ...and hoping the spec expands to include details about author, version, etc
# See https://dart.dev/tools/pub/cmd for details
-''', sources);
+''',
+ sources,
+ );
expect(pubspec.version, equals(Version.none));
expect(pubspec.dependencies, isEmpty);
});
@@ -387,14 +452,17 @@
test(
'reports helpful span when using new syntax with invalid environment',
() {
- var pubspec = Pubspec.parse('''
+ var pubspec = Pubspec.parse(
+ '''
name: pkg
environment:
sdk: invalid value
dependencies:
foo:
hosted: https://example.org/pub/
-''', sources);
+''',
+ sources,
+ );
expect(
() => pubspec.dependencies,
@@ -465,41 +533,53 @@
group('git dependencies', () {
test('path must be a string', () {
- expectPubspecException('''
+ expectPubspecException(
+ '''
dependencies:
foo:
git:
url: git://github.com/dart-lang/foo
path: 12
-''', (pubspec) => pubspec.dependencies);
+''',
+ (pubspec) => pubspec.dependencies,
+ );
});
test('path must be relative', () {
- expectPubspecException('''
+ expectPubspecException(
+ '''
dependencies:
foo:
git:
url: git://github.com/dart-lang/foo
path: git://github.com/dart-lang/foo/bar
-''', (pubspec) => pubspec.dependencies);
+''',
+ (pubspec) => pubspec.dependencies,
+ );
- expectPubspecException('''
+ expectPubspecException(
+ '''
dependencies:
foo:
git:
url: git://github.com/dart-lang/foo
path: /foo
-''', (pubspec) => pubspec.dependencies);
+''',
+ (pubspec) => pubspec.dependencies,
+ );
});
test('path must be within the repository', () {
- expectPubspecException('''
+ expectPubspecException(
+ '''
dependencies:
foo:
git:
url: git://github.com/dart-lang/foo
path: foo/../../bar
-''', (pubspec) => pubspec.dependencies);
+''',
+ (pubspec) => pubspec.dependencies,
+ );
});
});
@@ -526,11 +606,14 @@
});
test('defaults the upper constraint for the SDK', () {
- var pubspec = Pubspec.parse('''
+ var pubspec = Pubspec.parse(
+ '''
name: test
environment:
sdk: ">1.0.0"
- ''', sources);
+ ''',
+ sources,
+ );
expect(
pubspec.dartSdkConstraint.effectiveConstraint,
VersionConstraint.parse('>1.0.0 <2.0.0'),
@@ -542,67 +625,95 @@
test(
'default upper constraint for the SDK applies only if compatibile '
'with the lower bound', () {
- var pubspec = Pubspec.parse('''
+ var pubspec = Pubspec.parse(
+ '''
environment:
sdk: ">3.0.0"
- ''', sources);
+ ''',
+ sources,
+ );
expect(
- pubspec.sdkConstraints,
- containsPair(
- 'dart',
- SdkConstraint(VersionConstraint.parse('>3.0.0')),
- ));
+ pubspec.sdkConstraints,
+ containsPair(
+ 'dart',
+ SdkConstraint(VersionConstraint.parse('>3.0.0')),
+ ),
+ );
expect(pubspec.sdkConstraints, isNot(contains('flutter')));
expect(pubspec.sdkConstraints, isNot(contains('fuchsia')));
});
test("throws if the environment value isn't a map", () {
expectPubspecException(
- 'environment: []', (pubspec) => pubspec.sdkConstraints);
+ 'environment: []',
+ (pubspec) => pubspec.sdkConstraints,
+ );
});
test('allows a version constraint for the SDKs', () {
- var pubspec = Pubspec.parse('''
+ var pubspec = Pubspec.parse(
+ '''
environment:
sdk: ">=1.2.3 <2.3.4"
flutter: ^0.1.2
fuchsia: ^5.6.7
-''', sources);
- expect(
- pubspec.sdkConstraints,
- containsPair('dart',
- SdkConstraint(VersionConstraint.parse('>=1.2.3 <2.3.4'))));
- expect(
- pubspec.sdkConstraints,
- containsPair(
- 'flutter',
- SdkConstraint(
- VersionConstraint.parse('>=0.1.2'),
- originalConstraint: VersionConstraint.parse('^0.1.2'),
- )));
+''',
+ sources,
+ );
expect(
pubspec.sdkConstraints,
containsPair(
- 'fuchsia', SdkConstraint(VersionConstraint.parse('^5.6.7'))),
+ 'dart',
+ SdkConstraint(VersionConstraint.parse('>=1.2.3 <2.3.4')),
+ ),
+ );
+ expect(
+ pubspec.sdkConstraints,
+ containsPair(
+ 'flutter',
+ SdkConstraint(
+ VersionConstraint.parse('>=0.1.2'),
+ originalConstraint: VersionConstraint.parse('^0.1.2'),
+ ),
+ ),
+ );
+ expect(
+ pubspec.sdkConstraints,
+ containsPair(
+ 'fuchsia',
+ SdkConstraint(VersionConstraint.parse('^5.6.7')),
+ ),
);
});
test("throws if the sdk isn't a string", () {
expectPubspecException(
- 'environment: {sdk: []}', (pubspec) => pubspec.sdkConstraints);
+ 'environment: {sdk: []}',
+ (pubspec) => pubspec.sdkConstraints,
+ );
expectPubspecException(
- 'environment: {sdk: 1.0}', (pubspec) => pubspec.sdkConstraints);
- expectPubspecException('environment: {sdk: 1.2.3, flutter: []}',
- (pubspec) => pubspec.sdkConstraints);
- expectPubspecException('environment: {sdk: 1.2.3, flutter: 1.0}',
- (pubspec) => pubspec.sdkConstraints);
+ 'environment: {sdk: 1.0}',
+ (pubspec) => pubspec.sdkConstraints,
+ );
+ expectPubspecException(
+ 'environment: {sdk: 1.2.3, flutter: []}',
+ (pubspec) => pubspec.sdkConstraints,
+ );
+ expectPubspecException(
+ 'environment: {sdk: 1.2.3, flutter: 1.0}',
+ (pubspec) => pubspec.sdkConstraints,
+ );
});
test("throws if the sdk isn't a valid version constraint", () {
- expectPubspecException('environment: {sdk: "oopies"}',
- (pubspec) => pubspec.sdkConstraints);
- expectPubspecException('environment: {sdk: 1.2.3, flutter: "oopies"}',
- (pubspec) => pubspec.sdkConstraints);
+ expectPubspecException(
+ 'environment: {sdk: "oopies"}',
+ (pubspec) => pubspec.sdkConstraints,
+ );
+ expectPubspecException(
+ 'environment: {sdk: 1.2.3, flutter: "oopies"}',
+ (pubspec) => pubspec.sdkConstraints,
+ );
});
});
@@ -614,31 +725,43 @@
test('throws if not a string', () {
expectPubspecException(
- 'publish_to: 123', (pubspec) => pubspec.publishTo);
+ 'publish_to: 123',
+ (pubspec) => pubspec.publishTo,
+ );
});
test('allows a URL', () {
- var pubspec = Pubspec.parse('''
+ var pubspec = Pubspec.parse(
+ '''
publish_to: http://example.com
-''', sources);
+''',
+ sources,
+ );
expect(pubspec.publishTo, equals('http://example.com'));
});
test('allows none', () {
- var pubspec = Pubspec.parse('''
+ var pubspec = Pubspec.parse(
+ '''
publish_to: none
-''', sources);
+''',
+ sources,
+ );
expect(pubspec.publishTo, equals('none'));
});
test('throws on other strings', () {
- expectPubspecException('publish_to: http://bad.url:not-port',
- (pubspec) => pubspec.publishTo);
+ expectPubspecException(
+ 'publish_to: http://bad.url:not-port',
+ (pubspec) => pubspec.publishTo,
+ );
});
test('throws on non-absolute URLs', () {
expectPubspecException(
- 'publish_to: pub.dev', (pubspec) => pubspec.publishTo);
+ 'publish_to: pub.dev',
+ (pubspec) => pubspec.publishTo,
+ );
});
});
@@ -649,48 +772,66 @@
});
test('allows simple names for keys and most characters in values', () {
- var pubspec = Pubspec.parse('''
+ var pubspec = Pubspec.parse(
+ '''
executables:
abcDEF-123_: "abc DEF-123._"
-''', sources);
+''',
+ sources,
+ );
expect(pubspec.executables['abcDEF-123_'], equals('abc DEF-123._'));
});
test('throws if not a map', () {
expectPubspecException(
- 'executables: not map', (pubspec) => pubspec.executables);
+ 'executables: not map',
+ (pubspec) => pubspec.executables,
+ );
});
test('throws if key is not a string', () {
expectPubspecException(
- 'executables: {123: value}', (pubspec) => pubspec.executables);
+ 'executables: {123: value}',
+ (pubspec) => pubspec.executables,
+ );
});
test("throws if a key isn't a simple name", () {
expectPubspecException(
- 'executables: {funny/name: ok}', (pubspec) => pubspec.executables);
+ 'executables: {funny/name: ok}',
+ (pubspec) => pubspec.executables,
+ );
});
test('throws if a value is not a string', () {
expectPubspecException(
- 'executables: {command: 123}', (pubspec) => pubspec.executables);
+ 'executables: {command: 123}',
+ (pubspec) => pubspec.executables,
+ );
});
test('throws if a value contains a path separator', () {
- expectPubspecException('executables: {command: funny_name/part}',
- (pubspec) => pubspec.executables);
+ expectPubspecException(
+ 'executables: {command: funny_name/part}',
+ (pubspec) => pubspec.executables,
+ );
});
test('throws if a value contains a windows path separator', () {
- expectPubspecException(r'executables: {command: funny_name\part}',
- (pubspec) => pubspec.executables);
+ expectPubspecException(
+ r'executables: {command: funny_name\part}',
+ (pubspec) => pubspec.executables,
+ );
});
test('uses the key if the value is null', () {
- var pubspec = Pubspec.parse('''
+ var pubspec = Pubspec.parse(
+ '''
executables:
command:
-''', sources);
+''',
+ sources,
+ );
expect(pubspec.executables['command'], equals('command'));
});
});
@@ -718,8 +859,11 @@
]) {
var expectation = isA<SourceSpanApplicationException>();
if (expectedContains != null) {
- expectation = expectation.having((error) => error.toString(),
- 'toString()', contains(expectedContains));
+ expectation = expectation.having(
+ (error) => error.toString(),
+ 'toString()',
+ contains(expectedContains),
+ );
}
var pubspec = parsePubspecOverrides(contents);
@@ -772,15 +916,21 @@
});
test('throws if overrides contain invalid dependency section', () {
- expectPubspecOverridesException('''
+ expectPubspecOverridesException(
+ '''
dependency_overrides: false
-''', (pubspecOverrides) => pubspecOverrides.dependencyOverrides);
+''',
+ (pubspecOverrides) => pubspecOverrides.dependencyOverrides,
+ );
});
test('throws if overrides contain an unknown field', () {
- expectPubspecOverridesException('''
+ expectPubspecOverridesException(
+ '''
name: 'foo'
-''', (pubspecOverrides) => pubspecOverrides.dependencyOverrides);
+''',
+ (pubspecOverrides) => pubspecOverrides.dependencyOverrides,
+ );
});
});
});
diff --git a/test/rate_limited_scheduler_test.dart b/test/rate_limited_scheduler_test.dart
index 8562b07..6c94751 100644
--- a/test/rate_limited_scheduler_test.dart
+++ b/test/rate_limited_scheduler_test.dart
@@ -27,7 +27,8 @@
preschedule('b');
preschedule('c');
await Future.wait(
- [isBeingProcessed['a']!.future, isBeingProcessed['b']!.future]);
+ [isBeingProcessed['a']!.future, isBeingProcessed['b']!.future],
+ );
expect(isBeingProcessed['c']!.isCompleted, isFalse);
completers['a']!.complete();
await isBeingProcessed['c']!.future;
@@ -185,29 +186,41 @@
final scheduler = RateLimitedScheduler(f, maxConcurrentOperations: 2);
await scheduler.withPrescheduling((preschedule) async {
- runZoned(() {
- preschedule('a');
- }, zoneValues: {'zoneValue': 'A'});
- runZoned(() {
- preschedule('b');
- }, zoneValues: {'zoneValue': 'B'});
- runZoned(() {
- preschedule('c');
- }, zoneValues: {'zoneValue': 'C'});
+ runZoned(
+ () {
+ preschedule('a');
+ },
+ zoneValues: {'zoneValue': 'A'},
+ );
+ runZoned(
+ () {
+ preschedule('b');
+ },
+ zoneValues: {'zoneValue': 'B'},
+ );
+ runZoned(
+ () {
+ preschedule('c');
+ },
+ zoneValues: {'zoneValue': 'C'},
+ );
- await runZoned(() async {
- await isBeingProcessed['a']!.future;
- await isBeingProcessed['b']!.future;
- // This will put 'c' in front of the queue, but in a zone with zoneValue
- // bound to S.
- final f = expectLater(scheduler.schedule('c'), completion('S'));
- completers['a']!.complete();
- completers['b']!.complete();
- expect(await scheduler.schedule('a'), 'A');
- expect(await scheduler.schedule('b'), 'B');
- completers['c']!.complete();
- await f;
- }, zoneValues: {'zoneValue': 'S'});
+ await runZoned(
+ () async {
+ await isBeingProcessed['a']!.future;
+ await isBeingProcessed['b']!.future;
+ // This will put 'c' in front of the queue, but in a zone with zoneValue
+ // bound to S.
+ final f = expectLater(scheduler.schedule('c'), completion('S'));
+ completers['a']!.complete();
+ completers['b']!.complete();
+ expect(await scheduler.schedule('a'), 'A');
+ expect(await scheduler.schedule('b'), 'B');
+ completers['c']!.complete();
+ await f;
+ },
+ zoneValues: {'zoneValue': 'S'},
+ );
});
});
}
diff --git a/test/reformat_ranges_test.dart b/test/reformat_ranges_test.dart
index 2ead04d..90f5b05 100644
--- a/test/reformat_ranges_test.dart
+++ b/test/reformat_ranges_test.dart
@@ -54,13 +54,14 @@
),
);
expect(
- reformatMax(
- [],
- VersionRange(
- max: Version.parse('1.2.4+1'),
- alwaysIncludeMaxPreRelease: true,
- ),
+ reformatMax(
+ [],
+ VersionRange(
+ max: Version.parse('1.2.4+1'),
+ alwaysIncludeMaxPreRelease: true,
),
- equals(null));
+ ),
+ equals(null),
+ );
});
}
diff --git a/test/remove/remove_test.dart b/test/remove/remove_test.dart
index 8c82527..2a90f27 100644
--- a/test/remove/remove_test.dart
+++ b/test/remove/remove_test.dart
@@ -15,7 +15,7 @@
final server = await servePackages();
server.serve('foo', '1.2.3');
- await d.appDir({'foo': '1.2.3'}).create();
+ await d.appDir(dependencies: {'foo': '1.2.3'}).create();
await pubGet();
await pubRemove(args: ['foo']);
@@ -35,14 +35,14 @@
await d.dir(appPath, [
d.file('pubspec.yaml', '''
name: myapp
-dependencies:
+dependencies:
foo: 1.2.3
dev_dependencies:
bar: 2.0.0
environment:
- sdk: '>=0.1.2 <1.0.0'
+ sdk: '$defaultSdkConstraint'
''')
]).create();
@@ -65,24 +65,26 @@
final server = await servePackages();
server.serve('foo', '1.2.3');
- await d.appDir({'foo': '1.2.3'}).create();
+ await d.appDir(dependencies: {'foo': '1.2.3'}).create();
await pubGet();
await pubRemove(
- args: ['foo', '--dry-run'],
- output: allOf([
- contains('These packages are no longer being depended on:'),
- contains('- foo 1.2.3')
- ]));
+ args: ['foo', '--dry-run'],
+ output: allOf([
+ contains('These packages are no longer being depended on:'),
+ contains('- foo 1.2.3')
+ ]),
+ );
- await d.appDir({'foo': '1.2.3'}).validate();
+ await d.appDir(dependencies: {'foo': '1.2.3'}).validate();
});
test('prints a warning if package does not exist', () async {
await d.appDir().create();
await pubRemove(
- args: ['foo'],
- warning: contains('Package "foo" was not found in pubspec.yaml!'));
+ args: ['foo'],
+ warning: contains('Package "foo" was not found in pubspec.yaml!'),
+ );
await d.appDir().validate();
});
@@ -92,8 +94,9 @@
d.pubspec({'name': 'myapp'})
]).create();
await pubRemove(
- args: ['foo'],
- warning: contains('Package "foo" was not found in pubspec.yaml!'));
+ args: ['foo'],
+ warning: contains('Package "foo" was not found in pubspec.yaml!'),
+ );
await d.dir(appPath, [
d.pubspec({'name': 'myapp'})
@@ -165,12 +168,14 @@
]);
await repo.create();
- await d.appDir({
- 'foo': {
- 'git': {'url': '../foo.git', 'path': 'subdir'}
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'git': {'url': '../foo.git', 'path': 'subdir'}
+ },
+ 'bar': '1.2.3'
},
- 'bar': '1.2.3'
- }).create();
+ ).create();
await pubGet();
@@ -179,7 +184,7 @@
await d.appPackageConfigFile([
d.packageConfigEntry(name: 'bar', version: '1.2.3'),
]).validate();
- await d.appDir({'bar': '1.2.3'}).validate();
+ await d.appDir(dependencies: {'bar': '1.2.3'}).validate();
});
test('removes path dependencies', () async {
@@ -188,10 +193,12 @@
await d
.dir('foo', [d.libDir('foo'), d.libPubspec('foo', '0.0.1')]).create();
- await d.appDir({
- 'foo': {'path': '../foo'},
- 'bar': '1.2.3'
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'path': '../foo'},
+ 'bar': '1.2.3'
+ },
+ ).create();
await pubGet();
@@ -199,7 +206,7 @@
await d.appPackageConfigFile([
d.packageConfigEntry(name: 'bar', version: '1.2.3'),
]).validate();
- await d.appDir({'bar': '1.2.3'}).validate();
+ await d.appDir(dependencies: {'bar': '1.2.3'}).validate();
});
test('removes hosted dependencies', () async {
@@ -209,13 +216,15 @@
var custom = await startPackageServer();
custom.serve('foo', '1.2.3');
- await d.appDir({
- 'foo': {
- 'version': '1.2.3',
- 'hosted': {'name': 'foo', 'url': 'http://localhost:${custom.port}'}
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'version': '1.2.3',
+ 'hosted': {'name': 'foo', 'url': 'http://localhost:${custom.port}'}
+ },
+ 'bar': '2.0.1'
},
- 'bar': '2.0.1'
- }).create();
+ ).create();
await pubGet();
@@ -223,7 +232,7 @@
await d.appPackageConfigFile([
d.packageConfigEntry(name: 'bar', version: '2.0.1'),
]).validate();
- await d.appDir({'bar': '2.0.1'}).validate();
+ await d.appDir(dependencies: {'bar': '2.0.1'}).validate();
});
test('preserves comments', () async {
@@ -241,7 +250,7 @@
foo: 1.0.0 # comment D
# comment E
environment:
- sdk: '>=0.1.2 <1.0.0'
+ sdk: '$defaultSdkConstraint'
'''),
]).create();
@@ -249,18 +258,19 @@
await pubRemove(args: ['bar']);
- await d.appDir({'foo': '1.0.0'}).validate();
+ await d.appDir(dependencies: {'foo': '1.0.0'}).validate();
final fullPath = p.join(d.sandbox, appPath, 'pubspec.yaml');
expect(File(fullPath).existsSync(), true);
final contents = File(fullPath).readAsStringSync();
expect(
- contents,
- allOf([
- contains('# comment A'),
- contains('# comment B'),
- contains('# comment C'),
- contains('# comment D'),
- contains('# comment E')
- ]));
+ contents,
+ allOf([
+ contains('# comment A'),
+ contains('# comment B'),
+ contains('# comment C'),
+ contains('# comment D'),
+ contains('# comment E')
+ ]),
+ );
});
}
diff --git a/test/run/enable_experiments_test.dart b/test/run/enable_experiments_test.dart
index dd6512b..a21fee3 100644
--- a/test/run/enable_experiments_test.dart
+++ b/test/run/enable_experiments_test.dart
@@ -28,50 +28,4 @@
environment: {'_PUB_TEST_SDK_VERSION': '2.10.0'},
);
});
-
- test('Passes --no-sound-null-safety to the vm', () async {
- const vmWithExperiment = '2.11.0';
-
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'test_package',
- 'environment': {'sdk': '>=$vmWithExperiment <=3.0.0'}
- }),
- d.dir('bin', [
- d.file('script.dart', '''
-import 'package:test_package/foo.dart';
-
-main() {
- int? a = int.tryParse('123');
- int b = p;
-}
-''')
- ]),
- d.dir(
- 'lib',
- [
- d.file('foo.dart', '''
-// @dart = 2.8
-int p = 10;
-'''),
- ],
- ),
- ]).create();
-
- const environment = {'_PUB_TEST_SDK_VERSION': vmWithExperiment};
-
- await pubGet(environment: environment);
- await runPub(args: [
- 'run',
- '--no-sound-null-safety',
- '--enable-experiment=non-nullable',
- 'bin/script.dart'
- ], environment: environment);
- await runPub(
- args: ['run', '--enable-experiment=non-nullable', 'bin/script.dart'],
- environment: environment,
- error: contains("A library can't opt out of null safety by default"),
- exitCode: 254,
- );
- });
}
diff --git a/test/run/errors_if_only_transitive_dependency_test.dart b/test/run/errors_if_only_transitive_dependency_test.dart
index 71fcd3d..b93c4a6 100644
--- a/test/run/errors_if_only_transitive_dependency_test.dart
+++ b/test/run/errors_if_only_transitive_dependency_test.dart
@@ -16,23 +16,31 @@
]).create();
await d.dir('bar', [
- d.libPubspec('bar', '1.0.0', deps: {
- 'foo': {'path': '../foo'}
- })
+ d.libPubspec(
+ 'bar',
+ '1.0.0',
+ deps: {
+ 'foo': {'path': '../foo'}
+ },
+ )
]).create();
await d.dir(appPath, [
- d.appPubspec({
- 'bar': {'path': '../bar'}
- })
+ d.appPubspec(
+ dependencies: {
+ 'bar': {'path': '../bar'}
+ },
+ )
]).create();
await pubGet();
var pub = await pubRun(args: ['foo:script']);
expect(pub.stderr, emits('Package "foo" is not an immediate dependency.'));
- expect(pub.stderr,
- emits('Cannot run executables in transitive dependencies.'));
+ expect(
+ pub.stderr,
+ emits('Cannot run executables in transitive dependencies.'),
+ );
await pub.shouldExit(exit_codes.DATA);
});
}
diff --git a/test/run/errors_if_path_in_dependency_test.dart b/test/run/errors_if_path_in_dependency_test.dart
index 329650b..ec5a2ee 100644
--- a/test/run/errors_if_path_in_dependency_test.dart
+++ b/test/run/errors_if_path_in_dependency_test.dart
@@ -15,9 +15,11 @@
await d.dir('foo', [d.libPubspec('foo', '1.0.0')]).create();
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': '../foo'}
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': '../foo'}
+ },
+ )
]).create();
await runPub(
diff --git a/test/run/loads_package_imports_in_a_dependency_test.dart b/test/run/loads_package_imports_in_a_dependency_test.dart
index 7bfb047..10fad43 100644
--- a/test/run/loads_package_imports_in_a_dependency_test.dart
+++ b/test/run/loads_package_imports_in_a_dependency_test.dart
@@ -22,9 +22,11 @@
]).create();
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': '../foo'}
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': '../foo'}
+ },
+ )
]).create();
await pubGet();
diff --git a/test/run/nonexistent_dependency_test.dart b/test/run/nonexistent_dependency_test.dart
index 2051149..955cdaa 100644
--- a/test/run/nonexistent_dependency_test.dart
+++ b/test/run/nonexistent_dependency_test.dart
@@ -15,9 +15,10 @@
await pubGet();
var pub = await pubRun(args: ['foo:script']);
expect(
- pub.stderr,
- emits('Could not find package "foo". Did you forget to add a '
- 'dependency?'));
+ pub.stderr,
+ emits('Could not find package "foo". Did you forget to add a '
+ 'dependency?'),
+ );
await pub.shouldExit(exit_codes.DATA);
});
}
diff --git a/test/run/nonexistent_script_in_dependency_test.dart b/test/run/nonexistent_script_in_dependency_test.dart
index 62816df..a5e208a 100644
--- a/test/run/nonexistent_script_in_dependency_test.dart
+++ b/test/run/nonexistent_script_in_dependency_test.dart
@@ -14,18 +14,22 @@
await d.dir('foo', [d.libPubspec('foo', '1.0.0')]).create();
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': '../foo'}
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': '../foo'}
+ },
+ )
]).create();
await pubGet();
var pub = await pubRun(args: ['foo:script']);
expect(
- pub.stderr,
- emits(
- "Could not find ${p.join("bin", "script.dart")} in package foo."));
+ pub.stderr,
+ emits(
+ "Could not find ${p.join("bin", "script.dart")} in package foo.",
+ ),
+ );
await pub.shouldExit(exit_codes.NO_INPUT);
});
}
diff --git a/test/run/nonexistent_script_test.dart b/test/run/nonexistent_script_test.dart
index 0e12ee1..4ebb8c0 100644
--- a/test/run/nonexistent_script_test.dart
+++ b/test/run/nonexistent_script_test.dart
@@ -16,7 +16,9 @@
await pubGet();
var pub = await pubRun(args: [p.join('bin', 'script')]);
expect(
- pub.stderr, emits("Could not find ${p.join("bin", "script.dart")}."));
+ pub.stderr,
+ emits("Could not find ${p.join("bin", "script.dart")}."),
+ );
await pub.shouldExit(exit_codes.NO_INPUT);
});
}
diff --git a/test/run/package_api_test.dart b/test/run/package_api_test.dart
index 4d05408..944b064 100644
--- a/test/run/package_api_test.dart
+++ b/test/run/package_api_test.dart
@@ -26,9 +26,11 @@
await d.dir('foo', [d.libPubspec('foo', '1.0.0')]).create();
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': '../foo'}
- }),
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': '../foo'}
+ },
+ ),
d.dir('bin', [d.file('script.dart', _script)])
]).create();
@@ -37,25 +39,36 @@
expect(pub.stdout, emitsThrough('null'));
expect(
- pub.stdout,
- emits(p
+ pub.stdout,
+ emits(
+ p
.toUri(p.join(d.sandbox, 'myapp/.dart_tool/package_config.json'))
- .toString()));
- expect(pub.stdout,
- emits(p.toUri(p.join(d.sandbox, 'myapp/lib/resource.txt')).toString()));
- expect(pub.stdout,
- emits(p.toUri(p.join(d.sandbox, 'foo/lib/resource.txt')).toString()));
+ .toString(),
+ ),
+ );
+ expect(
+ pub.stdout,
+ emits(p.toUri(p.join(d.sandbox, 'myapp/lib/resource.txt')).toString()),
+ );
+ expect(
+ pub.stdout,
+ emits(p.toUri(p.join(d.sandbox, 'foo/lib/resource.txt')).toString()),
+ );
await pub.shouldExit(0);
});
test('a snapshotted application sees a file: package root', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', contents: [
- d.dir('bin', [d.file('script.dart', _script)])
- ]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ contents: [
+ d.dir('bin', [d.file('script.dart', _script)])
+ ],
+ );
await d.dir(appPath, [
- d.appPubspec({'foo': 'any'})
+ d.appPubspec(dependencies: {'foo': 'any'})
]).create();
await pubGet();
@@ -66,12 +79,17 @@
expect(pub.stdout, emits('Built foo:script.'));
expect(pub.stdout, emits('null'));
expect(
- pub.stdout,
- emits(p
+ pub.stdout,
+ emits(
+ p
.toUri(p.join(d.sandbox, 'myapp/.dart_tool/package_config.json'))
- .toString()));
- expect(pub.stdout,
- emits(p.toUri(p.join(d.sandbox, 'myapp/lib/resource.txt')).toString()));
+ .toString(),
+ ),
+ );
+ expect(
+ pub.stdout,
+ emits(p.toUri(p.join(d.sandbox, 'myapp/lib/resource.txt')).toString()),
+ );
var fooResourcePath =
p.join(globalServer.pathInCache('foo', '1.0.0'), 'lib/resource.txt');
expect(pub.stdout, emits(p.toUri(fooResourcePath).toString()));
diff --git a/test/run/precompile_test.dart b/test/run/precompile_test.dart
index 2d70b4c..6505b0b 100644
--- a/test/run/precompile_test.dart
+++ b/test/run/precompile_test.dart
@@ -18,14 +18,20 @@
void main() {
Future<void> setupForPubRunToPrecompile() async {
await d.dir(appPath, [
- d.appPubspec({'test': '1.0.0'}),
+ d.appPubspec(dependencies: {'test': '1.0.0'}),
]).create();
final server = await servePackages();
- server.serve('test', '1.0.0', contents: [
- d.dir('bin',
- [d.file('test.dart', 'main(List<String> args) => print("hello");')])
- ]);
+ server.serve(
+ 'test',
+ '1.0.0',
+ contents: [
+ d.dir(
+ 'bin',
+ [d.file('test.dart', 'main(List<String> args) => print("hello");')],
+ )
+ ],
+ );
await pubGet(args: ['--no-precompile']);
}
@@ -54,16 +60,22 @@
// Regression test of https://github.com/dart-lang/pub/issues/2483
test('`pub run` precompiles script with relative PUB_CACHE', () async {
await d.dir(appPath, [
- d.appPubspec({'test': '1.0.0'}),
+ d.appPubspec(dependencies: {'test': '1.0.0'}),
]).create();
final server = await servePackages();
- server.serve('test', '1.0.0', contents: [
- d.dir('bin', [d.file('test.dart', _script)])
- ]);
+ server.serve(
+ 'test',
+ '1.0.0',
+ contents: [
+ d.dir('bin', [d.file('test.dart', _script)])
+ ],
+ );
await pubGet(
- args: ['--no-precompile'], environment: {'PUB_CACHE': '.pub_cache'});
+ args: ['--no-precompile'],
+ environment: {'PUB_CACHE': '.pub_cache'},
+ );
var pub = await pubRun(
args: ['test'],
@@ -77,17 +89,22 @@
test('`get --precompile` precompiles script', () async {
await d.dir(appPath, [
- d.appPubspec({'test': '1.0.0'}),
+ d.appPubspec(dependencies: {'test': '1.0.0'}),
]).create();
final server = await servePackages();
- server.serve('test', '1.0.0', contents: [
- d.dir('bin', [d.file('test.dart', _script)])
- ]);
+ server.serve(
+ 'test',
+ '1.0.0',
+ contents: [
+ d.dir('bin', [d.file('test.dart', _script)])
+ ],
+ );
await pubGet(
- args: ['--precompile'],
- output: contains('Building package executables...'));
+ args: ['--precompile'],
+ output: contains('Building package executables...'),
+ );
var pub = await pubRun(
args: ['test'],
@@ -101,18 +118,23 @@
test('`get --precompile` precompiles script with relative PUB_CACHE',
() async {
await d.dir(appPath, [
- d.appPubspec({'test': '1.0.0'}),
+ d.appPubspec(dependencies: {'test': '1.0.0'}),
]).create();
final server = await servePackages();
- server.serve('test', '1.0.0', contents: [
- d.dir('bin', [d.file('test.dart', _script)])
- ]);
+ server.serve(
+ 'test',
+ '1.0.0',
+ contents: [
+ d.dir('bin', [d.file('test.dart', _script)])
+ ],
+ );
await pubGet(
- args: ['--precompile'],
- environment: {'PUB_CACHE': '.pub_cache'},
- output: contains('Building package executables...'));
+ args: ['--precompile'],
+ environment: {'PUB_CACHE': '.pub_cache'},
+ output: contains('Building package executables...'),
+ );
var pub = await pubRun(
args: ['test'],
diff --git a/test/run/runs_from_a_dependency_override_after_dependency_test.dart b/test/run/runs_from_a_dependency_override_after_dependency_test.dart
index c11bacb..519b9c1 100644
--- a/test/run/runs_from_a_dependency_override_after_dependency_test.dart
+++ b/test/run/runs_from_a_dependency_override_after_dependency_test.dart
@@ -11,15 +11,17 @@
// Regression test for issue 23113
test('runs a named Dart application in a dependency', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', pubspec: {
- 'name': 'foo',
- 'version': '1.0.0'
- }, contents: [
- d.dir('bin', [d.file('bar.dart', "main() => print('foobar');")])
- ]);
+ server.serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {'name': 'foo', 'version': '1.0.0'},
+ contents: [
+ d.dir('bin', [d.file('bar.dart', "main() => print('foobar');")])
+ ],
+ );
await d.dir(appPath, [
- d.appPubspec({'foo': null})
+ d.appPubspec(dependencies: {'foo': null})
]).create();
await pubGet(args: ['--precompile']);
diff --git a/test/run/runs_named_app_in_dependency_test.dart b/test/run/runs_named_app_in_dependency_test.dart
index 8f3d73d..0c6fca7 100644
--- a/test/run/runs_named_app_in_dependency_test.dart
+++ b/test/run/runs_named_app_in_dependency_test.dart
@@ -15,9 +15,11 @@
]).create();
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': '../foo'}
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': '../foo'}
+ },
+ )
]).create();
await pubGet();
diff --git a/test/run/runs_the_script_in_checked_mode_test.dart b/test/run/runs_the_script_in_checked_mode_test.dart
index 8b4010a..ef2d27e 100644
--- a/test/run/runs_the_script_in_checked_mode_test.dart
+++ b/test/run/runs_the_script_in_checked_mode_test.dart
@@ -16,8 +16,9 @@
await pubGet();
await runPub(
- args: ['run', '--enable-asserts', 'bin/script'],
- error: contains('Failed assertion'),
- exitCode: 255);
+ args: ['run', '--enable-asserts', 'bin/script'],
+ error: contains('Failed assertion'),
+ exitCode: 255,
+ );
});
}
diff --git a/test/sdk_test.dart b/test/sdk_test.dart
index 6165cd5..b9a89d5 100644
--- a/test/sdk_test.dart
+++ b/test/sdk_test.dart
@@ -24,60 +24,83 @@
])
]),
d.dir('bin/cache/pkg', [
- d.dir('baz',
- [d.libDir('baz', 'foo 0.0.1'), d.libPubspec('baz', '0.0.1')])
+ d.dir(
+ 'baz',
+ [d.libDir('baz', 'foo 0.0.1'), d.libPubspec('baz', '0.0.1')],
+ )
]),
d.file('version', '1.2.3')
]).create();
});
test("gets an SDK dependency's dependencies", () async {
- await d.appDir({
- 'foo': {'sdk': 'flutter'}
- }).create();
- await pubCommand(command,
- environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')});
+ await d.appDir(
+ dependencies: {
+ 'foo': {'sdk': 'flutter'}
+ },
+ ).create();
+ await pubCommand(
+ command,
+ environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
+ );
await d.appPackageConfigFile([
d.packageConfigEntry(
- name: 'foo', path: p.join(d.sandbox, 'flutter', 'packages', 'foo')),
+ name: 'foo',
+ path: p.join(d.sandbox, 'flutter', 'packages', 'foo'),
+ ),
d.packageConfigEntry(name: 'bar', version: '1.0.0'),
]).validate();
});
test('gets an SDK dependency from bin/cache/pkg', () async {
- await d.appDir({
- 'baz': {'sdk': 'flutter'}
- }).create();
- await pubCommand(command,
- environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')});
+ await d.appDir(
+ dependencies: {
+ 'baz': {'sdk': 'flutter'}
+ },
+ ).create();
+ await pubCommand(
+ command,
+ environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
+ );
await d.appPackageConfigFile([
d.packageConfigEntry(
- name: 'baz',
- path: p.join(d.sandbox, 'flutter', 'bin', 'cache', 'pkg', 'baz')),
+ name: 'baz',
+ path: p.join(d.sandbox, 'flutter', 'bin', 'cache', 'pkg', 'baz'),
+ ),
]).validate();
});
test('unlocks an SDK dependency when the version changes', () async {
- await d.appDir({
- 'foo': {'sdk': 'flutter'}
- }).create();
- await pubCommand(command,
- environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')});
+ await d.appDir(
+ dependencies: {
+ 'foo': {'sdk': 'flutter'}
+ },
+ ).create();
+ await pubCommand(
+ command,
+ environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
+ );
await d
- .file('$appPath/pubspec.lock',
- allOf([contains('0.0.1'), isNot(contains('0.0.2'))]))
+ .file(
+ '$appPath/pubspec.lock',
+ allOf([contains('0.0.1'), isNot(contains('0.0.2'))]),
+ )
.validate();
await d
.dir('flutter/packages/foo', [d.libPubspec('foo', '0.0.2')]).create();
- await pubCommand(command,
- environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')});
+ await pubCommand(
+ command,
+ environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
+ );
await d
- .file('$appPath/pubspec.lock',
- allOf([isNot(contains('0.0.1')), contains('0.0.2')]))
+ .file(
+ '$appPath/pubspec.lock',
+ allOf([isNot(contains('0.0.1')), contains('0.0.2')]),
+ )
.validate();
});
@@ -87,84 +110,118 @@
'nothing depends on Flutter', () async {
await d.appDir().create();
deleteEntry(p.join(d.sandbox, 'flutter', 'version'));
- await pubCommand(command,
- environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')});
+ await pubCommand(
+ command,
+ environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
+ );
await d.appPackageConfigFile([]).validate();
});
group('fails if', () {
test("the version constraint doesn't match", () async {
- await d.appDir({
- 'foo': {'sdk': 'flutter', 'version': '^1.0.0'}
- }).create();
- await pubCommand(command,
- environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
- error: equalsIgnoringWhitespace("""
+ await d.appDir(
+ dependencies: {
+ 'foo': {'sdk': 'flutter', 'version': '^1.0.0'}
+ },
+ ).create();
+ await pubCommand(
+ command,
+ environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
+ error: equalsIgnoringWhitespace("""
Because myapp depends on foo ^1.0.0 from sdk which doesn't match
any versions, version solving failed.
- """));
+ """),
+ );
});
test('the SDK is unknown', () async {
- await d.appDir({
- 'foo': {'sdk': 'unknown'}
- }).create();
- await pubCommand(command, error: equalsIgnoringWhitespace("""
+ await d.appDir(
+ dependencies: {
+ 'foo': {'sdk': 'unknown'}
+ },
+ ).create();
+ await pubCommand(
+ command,
+ error: equalsIgnoringWhitespace("""
Because myapp depends on foo from sdk which doesn't exist
(unknown SDK "unknown"), version solving failed.
- """), exitCode: exit_codes.UNAVAILABLE);
+ """),
+ exitCode: exit_codes.UNAVAILABLE,
+ );
});
test('the SDK is unavailable', () async {
- await d.appDir({
- 'foo': {'sdk': 'flutter'}
- }).create();
- await pubCommand(command, error: equalsIgnoringWhitespace("""
+ await d.appDir(
+ dependencies: {
+ 'foo': {'sdk': 'flutter'}
+ },
+ ).create();
+ await pubCommand(
+ command,
+ error: equalsIgnoringWhitespace("""
Because myapp depends on foo from sdk which doesn't exist (the
Flutter SDK is not available), version solving failed.
Flutter users should run `flutter pub get` instead of `dart pub
get`.
- """), exitCode: exit_codes.UNAVAILABLE);
+ """),
+ exitCode: exit_codes.UNAVAILABLE,
+ );
});
test("the SDK doesn't contain the package", () async {
- await d.appDir({
- 'bar': {'sdk': 'flutter'}
- }).create();
- await pubCommand(command,
- environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
- error: equalsIgnoringWhitespace("""
+ await d.appDir(
+ dependencies: {
+ 'bar': {'sdk': 'flutter'}
+ },
+ ).create();
+ await pubCommand(
+ command,
+ environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
+ error: equalsIgnoringWhitespace("""
Because myapp depends on bar from sdk which doesn't exist
(could not find package bar in the Flutter SDK), version solving
failed.
"""),
- exitCode: exit_codes.UNAVAILABLE);
+ exitCode: exit_codes.UNAVAILABLE,
+ );
});
test("the Dart SDK doesn't contain the package", () async {
- await d.appDir({
- 'bar': {'sdk': 'dart'}
- }).create();
- await pubCommand(command, error: equalsIgnoringWhitespace("""
+ await d.appDir(
+ dependencies: {
+ 'bar': {'sdk': 'dart'}
+ },
+ ).create();
+ await pubCommand(
+ command,
+ error: equalsIgnoringWhitespace("""
Because myapp depends on bar from sdk which doesn't exist
(could not find package bar in the Dart SDK), version solving
failed.
- """), exitCode: exit_codes.UNAVAILABLE);
+ """),
+ exitCode: exit_codes.UNAVAILABLE,
+ );
});
});
test('supports the Fuchsia SDK', () async {
renameDir(p.join(d.sandbox, 'flutter'), p.join(d.sandbox, 'fuchsia'));
- await d.appDir({
- 'foo': {'sdk': 'fuchsia'}
- }).create();
- await pubCommand(command,
- environment: {'FUCHSIA_DART_SDK_ROOT': p.join(d.sandbox, 'fuchsia')});
+ await d.appDir(
+ dependencies: {
+ 'foo': {'sdk': 'fuchsia'}
+ },
+ ).create();
+ await pubCommand(
+ command,
+ environment: {'FUCHSIA_DART_SDK_ROOT': p.join(d.sandbox, 'fuchsia')},
+ );
await d.appPackageConfigFile([
d.packageConfigEntry(
- name: 'foo', path: p.join(d.sandbox, 'fuchsia', 'packages', 'foo')),
+ name: 'foo',
+ path: p.join(d.sandbox, 'fuchsia', 'packages', 'foo'),
+ ),
d.packageConfigEntry(name: 'bar', version: '1.0.0'),
]).validate();
});
diff --git a/test/snapshot_test.dart b/test/snapshot_test.dart
index 8143f7e..6fe8d43 100644
--- a/test/snapshot_test.dart
+++ b/test/snapshot_test.dart
@@ -12,21 +12,30 @@
group('creates a snapshot', () {
test('for an immediate dependency', () async {
final server = await servePackages();
- server.serve('foo', '1.2.3', contents: [
- d.dir('bin', [
- d.file('hello.dart', "void main() => print('hello!');"),
- d.file('goodbye.dart', "void main() => print('goodbye!');"),
- d.file('shell.sh', 'echo shell'),
- d.dir('subdir', [d.file('sub.dart', "void main() => print('sub!');")])
- ])
- ]);
+ server.serve(
+ 'foo',
+ '1.2.3',
+ contents: [
+ d.dir('bin', [
+ d.file('hello.dart', "void main() => print('hello!');"),
+ d.file('goodbye.dart', "void main() => print('goodbye!');"),
+ d.file('shell.sh', 'echo shell'),
+ d.dir(
+ 'subdir',
+ [d.file('sub.dart', "void main() => print('sub!');")],
+ )
+ ])
+ ],
+ );
- await d.appDir({'foo': '1.2.3'}).create();
+ await d.appDir(dependencies: {'foo': '1.2.3'}).create();
await pubGet(
- args: ['--precompile'],
- output: allOf(
- [contains('Built foo:hello.'), contains('Built foo:goodbye.')]));
+ args: ['--precompile'],
+ output: allOf(
+ [contains('Built foo:hello.'), contains('Built foo:goodbye.')],
+ ),
+ );
await d.dir(p.join(appPath, '.dart_tool', 'pub', 'bin'), [
d.dir('foo', [
@@ -48,23 +57,31 @@
test("for an immediate dependency that's also transitive", () async {
await servePackages()
- ..serve('foo', '1.2.3', contents: [
- d.dir('bin', [
- d.file('hello.dart', "void main() => print('hello!');"),
- d.file('goodbye.dart', "void main() => print('goodbye!');"),
- d.file('shell.sh', 'echo shell'),
- d.dir(
- 'subdir', [d.file('sub.dart', "void main() => print('sub!');")])
- ])
- ])
+ ..serve(
+ 'foo',
+ '1.2.3',
+ contents: [
+ d.dir('bin', [
+ d.file('hello.dart', "void main() => print('hello!');"),
+ d.file('goodbye.dart', "void main() => print('goodbye!');"),
+ d.file('shell.sh', 'echo shell'),
+ d.dir(
+ 'subdir',
+ [d.file('sub.dart', "void main() => print('sub!');")],
+ )
+ ])
+ ],
+ )
..serve('bar', '1.2.3', deps: {'foo': '1.2.3'});
- await d.appDir({'foo': '1.2.3'}).create();
+ await d.appDir(dependencies: {'foo': '1.2.3'}).create();
await pubGet(
- args: ['--precompile'],
- output: allOf(
- [contains('Built foo:hello.'), contains('Built foo:goodbye.')]));
+ args: ['--precompile'],
+ output: allOf(
+ [contains('Built foo:hello.'), contains('Built foo:goodbye.')],
+ ),
+ );
await d.dir(p.join(appPath, '.dart_tool', 'pub', 'bin'), [
d.dir('foo', [
@@ -87,27 +104,43 @@
group('again if', () {
test('its package is updated', () async {
final server = await servePackages();
- server.serve('foo', '1.2.3', contents: [
- d.dir(
- 'bin', [d.file('hello.dart', "void main() => print('hello!');")])
- ]);
+ server.serve(
+ 'foo',
+ '1.2.3',
+ contents: [
+ d.dir(
+ 'bin',
+ [d.file('hello.dart', "void main() => print('hello!');")],
+ )
+ ],
+ );
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await pubGet(
- args: ['--precompile'], output: contains('Built foo:hello.'));
+ args: ['--precompile'],
+ output: contains('Built foo:hello.'),
+ );
await d.dir(p.join(appPath, '.dart_tool', 'pub', 'bin', 'foo'), [
d.file('hello.dart-$versionSuffix.snapshot', contains('hello!'))
]).validate();
- server.serve('foo', '1.2.4', contents: [
- d.dir('bin',
- [d.file('hello.dart', "void main() => print('hello 2!');")])
- ]);
+ server.serve(
+ 'foo',
+ '1.2.4',
+ contents: [
+ d.dir(
+ 'bin',
+ [d.file('hello.dart', "void main() => print('hello 2!');")],
+ )
+ ],
+ );
await pubUpgrade(
- args: ['--precompile'], output: contains('Built foo:hello.'));
+ args: ['--precompile'],
+ output: contains('Built foo:hello.'),
+ );
await d.dir(p.join(appPath, '.dart_tool', 'pub', 'bin', 'foo'), [
d.file('hello.dart-$versionSuffix.snapshot', contains('hello 2!'))
@@ -121,36 +154,53 @@
test('a dependency of its package is updated', () async {
final server = await servePackages();
- server.serve('foo', '1.2.3', pubspec: {
- 'dependencies': {'bar': 'any'}
- }, contents: [
- d.dir('bin', [
- d.file('hello.dart', """
+ server.serve(
+ 'foo',
+ '1.2.3',
+ pubspec: {
+ 'dependencies': {'bar': 'any'}
+ },
+ contents: [
+ d.dir('bin', [
+ d.file('hello.dart', """
import 'package:bar/bar.dart';
void main() => print(message);
""")
- ])
- ]);
- server.serve('bar', '1.2.3', contents: [
- d.dir('lib', [d.file('bar.dart', "final message = 'hello!';")])
- ]);
+ ])
+ ],
+ );
+ server.serve(
+ 'bar',
+ '1.2.3',
+ contents: [
+ d.dir('lib', [d.file('bar.dart', "final message = 'hello!';")])
+ ],
+ );
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await pubGet(
- args: ['--precompile'], output: contains('Built foo:hello.'));
+ args: ['--precompile'],
+ output: contains('Built foo:hello.'),
+ );
await d.dir(p.join(appPath, '.dart_tool', 'pub', 'bin', 'foo'), [
d.file('hello.dart-$versionSuffix.snapshot', contains('hello!'))
]).validate();
- server.serve('bar', '1.2.4', contents: [
- d.dir('lib', [d.file('bar.dart', "final message = 'hello 2!';")]),
- ]);
+ server.serve(
+ 'bar',
+ '1.2.4',
+ contents: [
+ d.dir('lib', [d.file('bar.dart', "final message = 'hello 2!';")]),
+ ],
+ );
await pubUpgrade(
- args: ['--precompile'], output: contains('Built foo:hello.'));
+ args: ['--precompile'],
+ output: contains('Built foo:hello.'),
+ );
await d.dir(p.join(appPath, '.dart_tool', 'pub', 'bin', 'foo'), [
d.file('hello.dart-$versionSuffix.snapshot', contains('hello 2!'))
@@ -167,27 +217,37 @@
await d.git('foo.git', [
d.pubspec({'name': 'foo', 'version': '0.0.1'}),
d.dir(
- 'bin', [d.file('hello.dart', "void main() => print('Hello!');")])
+ 'bin',
+ [d.file('hello.dart', "void main() => print('Hello!');")],
+ )
]).create();
- await d.appDir({
- 'foo': {'git': '../foo.git'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'git': '../foo.git'}
+ },
+ ).create();
await pubGet(
- args: ['--precompile'], output: contains('Built foo:hello.'));
+ args: ['--precompile'],
+ output: contains('Built foo:hello.'),
+ );
await d.dir(p.join(appPath, '.dart_tool', 'pub', 'bin', 'foo'), [
d.file('hello.dart-$versionSuffix.snapshot', contains('Hello!'))
]).validate();
await d.git('foo.git', [
- d.dir('bin',
- [d.file('hello.dart', "void main() => print('Goodbye!');")])
+ d.dir(
+ 'bin',
+ [d.file('hello.dart', "void main() => print('Goodbye!');")],
+ )
]).commit();
await pubUpgrade(
- args: ['--precompile'], output: contains('Built foo:hello.'));
+ args: ['--precompile'],
+ output: contains('Built foo:hello.'),
+ );
await d.dir(p.join(appPath, '.dart_tool', 'pub', 'bin', 'foo'), [
d.file('hello.dart-$versionSuffix.snapshot', contains('Goodbye!'))
@@ -200,18 +260,26 @@
test('the SDK is out of date', () async {
final server = await servePackages();
- server.serve('foo', '5.6.7', contents: [
- d.dir(
- 'bin', [d.file('hello.dart', "void main() => print('hello!');")])
- ]);
+ server.serve(
+ 'foo',
+ '5.6.7',
+ contents: [
+ d.dir(
+ 'bin',
+ [d.file('hello.dart', "void main() => print('hello!');")],
+ )
+ ],
+ );
- await d.appDir({'foo': '5.6.7'}).create();
+ await d.appDir(dependencies: {'foo': '5.6.7'}).create();
await pubGet(args: ['--no-precompile']);
await d.dir(p.join(appPath, '.dart_tool', 'pub', 'bin'), [
- d.dir('foo',
- [d.outOfDateSnapshot('hello.dart-$versionSuffix.snapshot')])
+ d.dir(
+ 'foo',
+ [d.outOfDateSnapshot('hello.dart-$versionSuffix.snapshot')],
+ )
]).create();
var process = await pubRun(args: ['foo:hello']);
diff --git a/test/test_pub.dart b/test/test_pub.dart
index 5680407..e6aa8cc 100644
--- a/test/test_pub.dart
+++ b/test/test_pub.dart
@@ -73,8 +73,10 @@
/// The entry from the `.dart_tool/package_config.json` file for [packageName].
Map<String, dynamic> packageSpec(String packageName) => json
.decode(File(d.path(packageConfigFilePath)).readAsStringSync())['packages']
- .firstWhere((e) => e['name'] == packageName,
- orElse: () => null) as Map<String, dynamic>;
+ .firstWhere(
+ (e) => e['name'] == packageName,
+ orElse: () => null,
+ ) as Map<String, dynamic>;
/// The suffix appended to a built snapshot.
const versionSuffix = testVersion;
@@ -83,17 +85,28 @@
/// output.
class RunCommand {
static final add = RunCommand(
- 'add', RegExp(r'Got dependencies!|Changed \d+ dependenc(y|ies)!'));
+ 'add',
+ RegExp(r'Got dependencies!|Changed \d+ dependenc(y|ies)!'),
+ );
static final get = RunCommand(
- 'get', RegExp(r'Got dependencies!|Changed \d+ dependenc(y|ies)!'));
- static final upgrade = RunCommand('upgrade', RegExp(r'''
+ 'get',
+ RegExp(r'Got dependencies!|Changed \d+ dependenc(y|ies)!'),
+ );
+ static final upgrade = RunCommand(
+ 'upgrade',
+ RegExp(r'''
(No dependencies changed\.|Changed \d+ dependenc(y|ies)!)($|
\d+ packages? (has|have) newer versions incompatible with dependency constraints.
-Try `dart pub outdated` for more information.$)'''));
- static final downgrade = RunCommand('downgrade',
- RegExp(r'(No dependencies changed\.|Changed \d+ dependenc(y|ies)!)$'));
+Try `dart pub outdated` for more information.$)'''),
+ );
+ static final downgrade = RunCommand(
+ 'downgrade',
+ RegExp(r'(No dependencies changed\.|Changed \d+ dependenc(y|ies)!)$'),
+ );
static final remove = RunCommand(
- 'remove', RegExp(r'Got dependencies!|Changed \d+ dependenc(y|ies)!'));
+ 'remove',
+ RegExp(r'Got dependencies!|Changed \d+ dependenc(y|ies)!'),
+ );
final String name;
final RegExp success;
@@ -151,14 +164,15 @@
if (warning != null) error = warning;
await runPub(
- args: allArgs,
- output: output,
- error: error,
- silent: silent,
- exitCode: exitCode,
- environment: environment,
- workingDirectory: workingDirectory,
- includeParentHomeAndPath: includeParentHomeAndPath);
+ args: allArgs,
+ output: output,
+ error: error,
+ silent: silent,
+ exitCode: exitCode,
+ environment: environment,
+ workingDirectory: workingDirectory,
+ includeParentHomeAndPath: includeParentHomeAndPath,
+ );
}
Future<void> pubAdd({
@@ -205,15 +219,16 @@
includeParentHomeAndPath: includeParentHomeAndPath,
);
-Future<void> pubUpgrade(
- {Iterable<String>? args,
- Object? output,
- Object? error,
- Object? warning,
- Object? silent,
- int? exitCode,
- Map<String, String>? environment,
- String? workingDirectory}) async =>
+Future<void> pubUpgrade({
+ Iterable<String>? args,
+ Object? output,
+ Object? error,
+ Object? warning,
+ Object? silent,
+ int? exitCode,
+ Map<String, String>? environment,
+ String? workingDirectory,
+}) async =>
await pubCommand(
RunCommand.upgrade,
args: args,
@@ -273,11 +288,12 @@
/// "pub run".
///
/// Returns the `pub run` process.
-Future<PubProcess> pubRun(
- {bool global = false,
- required Iterable<String> args,
- Map<String, String>? environment,
- bool verbose = true}) async {
+Future<PubProcess> pubRun({
+ bool global = false,
+ required Iterable<String> args,
+ Map<String, String>? environment,
+ bool verbose = true,
+}) async {
var pubArgs = global ? ['global', 'run'] : ['run'];
pubArgs.addAll(args);
var pub = await startPub(
@@ -319,17 +335,18 @@
///
/// If [environment] is given, any keys in it will override the environment
/// variables passed to the spawned process.
-Future<void> runPub(
- {List<String>? args,
- Object? output,
- Object? error,
- Object? outputJson,
- Object? silent,
- int? exitCode,
- String? workingDirectory,
- Map<String, String?>? environment,
- List<String>? input,
- includeParentHomeAndPath = true}) async {
+Future<void> runPub({
+ List<String>? args,
+ Object? output,
+ Object? error,
+ Object? outputJson,
+ Object? silent,
+ int? exitCode,
+ String? workingDirectory,
+ Map<String, String?>? environment,
+ List<String>? input,
+ includeParentHomeAndPath = true,
+}) async {
exitCode ??= exit_codes.SUCCESS;
// Cannot pass both output and outputJson.
assert(output == null || outputJson == null);
@@ -381,13 +398,17 @@
}) async {
var tokenEndpoint = Uri.parse(server.url).resolve('/token').toString();
args = ['lish', ...?args];
- return await startPub(args: args, tokenEndpoint: tokenEndpoint, environment: {
- if (overrideDefaultHostedServer)
- '_PUB_TEST_DEFAULT_HOSTED_URL': server.url + path
- else
- 'PUB_HOSTED_URL': server.url + path,
- if (environment != null) ...environment,
- });
+ return await startPub(
+ args: args,
+ tokenEndpoint: tokenEndpoint,
+ environment: {
+ if (overrideDefaultHostedServer)
+ '_PUB_TEST_DEFAULT_HOSTED_URL': server.url + path
+ else
+ 'PUB_HOSTED_URL': server.url + path,
+ if (environment != null) ...environment,
+ },
+ );
}
/// Handles the beginning confirmation process for uploading a packages.
@@ -398,12 +419,17 @@
// TODO(rnystrom): This is overly specific and inflexible regarding different
// test packages. Should validate this a little more loosely.
await expectLater(
- pub.stdout, emitsThrough(startsWith('Publishing test_pkg 1.0.0 to ')));
+ pub.stdout,
+ emitsThrough(startsWith('Publishing test_pkg 1.0.0 to ')),
+ );
await expectLater(
- pub.stdout,
- emitsThrough(matches(
+ pub.stdout,
+ emitsThrough(
+ matches(
r'^Do you want to publish [^ ]+ [^ ]+ (y/N)?',
- )));
+ ),
+ ),
+ );
pub.stdin.writeln('y');
}
@@ -414,7 +440,10 @@
/// sandbox.
String _pathInSandbox(String relPath) => p.join(d.sandbox, relPath);
-const String testVersion = '0.1.2+3';
+const String testVersion = '3.1.2+3';
+
+/// This constraint is compatible with [testVersion].
+const String defaultSdkConstraint = '^3.0.2';
/// Gets the environment variables used to run pub in a test context.
Map<String, String> getPubTestEnvironment([String? tokenEndpoint]) => {
@@ -435,7 +464,8 @@
final String _pubRoot = (() {
if (!fileExists(p.join('bin', 'pub.dart'))) {
throw StateError(
- "Current working directory (${p.current} is not pub's root. Run tests from pub's root.");
+ "Current working directory (${p.current} is not pub's root. Run tests from pub's root.",
+ );
}
return p.current;
})();
@@ -447,13 +477,14 @@
///
/// If [environment] is given, any keys in it will override the environment
/// variables passed to the spawned process.
-Future<PubProcess> startPub(
- {Iterable<String>? args,
- String? tokenEndpoint,
- String? workingDirectory,
- Map<String, String?>? environment,
- bool verbose = true,
- includeParentHomeAndPath = true}) async {
+Future<PubProcess> startPub({
+ Iterable<String>? args,
+ String? tokenEndpoint,
+ String? workingDirectory,
+ Map<String, String?>? environment,
+ bool verbose = true,
+ includeParentHomeAndPath = true,
+}) async {
args ??= [];
ensureDir(_pathInSandbox(appPath));
@@ -499,11 +530,14 @@
}
}
- return await PubProcess.start(Platform.resolvedExecutable, dartArgs,
- environment: mergedEnvironment,
- workingDirectory: workingDirectory ?? _pathInSandbox(appPath),
- description: args.isEmpty ? 'pub' : 'pub ${args.first}',
- includeParentEnvironment: false);
+ return await PubProcess.start(
+ Platform.resolvedExecutable,
+ dartArgs,
+ environment: mergedEnvironment,
+ workingDirectory: workingDirectory ?? _pathInSandbox(appPath),
+ description: args.isEmpty ? 'pub' : 'pub ${args.first}',
+ includeParentEnvironment: false,
+ );
}
/// A subclass of [TestProcess] that parses pub's verbose logging output and
@@ -514,25 +548,33 @@
createLogSplitter();
StreamSplitter<Pair<log.Level, String>> createLogSplitter() {
- return StreamSplitter(StreamGroup.merge([
- _outputToLog(super.stdoutStream(), log.Level.message),
- _outputToLog(super.stderrStream(), log.Level.error)
- ]));
+ return StreamSplitter(
+ StreamGroup.merge([
+ _outputToLog(super.stdoutStream(), log.Level.message),
+ _outputToLog(super.stderrStream(), log.Level.error)
+ ]),
+ );
}
- static Future<PubProcess> start(String executable, Iterable<String> arguments,
- {String? workingDirectory,
- Map<String, String>? environment,
- bool includeParentEnvironment = true,
- bool runInShell = false,
- String? description,
- Encoding encoding = utf8,
- bool forwardStdio = false}) async {
- var process = await Process.start(executable, arguments.toList(),
- workingDirectory: workingDirectory,
- environment: environment,
- includeParentEnvironment: includeParentEnvironment,
- runInShell: runInShell);
+ static Future<PubProcess> start(
+ String executable,
+ Iterable<String> arguments, {
+ String? workingDirectory,
+ Map<String, String>? environment,
+ bool includeParentEnvironment = true,
+ bool runInShell = false,
+ String? description,
+ Encoding encoding = utf8,
+ bool forwardStdio = false,
+ }) async {
+ var process = await Process.start(
+ executable,
+ arguments.toList(),
+ workingDirectory: workingDirectory,
+ environment: environment,
+ includeParentEnvironment: includeParentEnvironment,
+ runInShell: runInShell,
+ );
if (description == null) {
var humanExecutable = p.isWithin(p.current, executable)
@@ -541,15 +583,26 @@
description = '$humanExecutable ${arguments.join(' ')}';
}
- return PubProcess(process, description,
- encoding: encoding, forwardStdio: forwardStdio);
+ return PubProcess(
+ process,
+ description,
+ encoding: encoding,
+ forwardStdio: forwardStdio,
+ );
}
/// This is protected.
- PubProcess(process, description,
- {Encoding encoding = utf8, bool forwardStdio = false})
- : super(process, description,
- encoding: encoding, forwardStdio: forwardStdio);
+ PubProcess(
+ process,
+ description, {
+ Encoding encoding = utf8,
+ bool forwardStdio = false,
+ }) : super(
+ process,
+ description,
+ encoding: encoding,
+ forwardStdio: forwardStdio,
+ );
final _logLineRegExp = RegExp(r'^([A-Z ]{4})[:|] (.*)$');
final Map<String, log.Level> _logLevels = [
@@ -565,7 +618,9 @@
});
Stream<Pair<log.Level, String>> _outputToLog(
- Stream<String> stream, log.Level defaultLevel) {
+ Stream<String> stream,
+ log.Level defaultLevel,
+ ) {
late log.Level lastLevel;
return stream.map((line) {
var match = _logLineRegExp.firstMatch(line);
@@ -622,9 +677,11 @@
///
/// [hosted] is a list of package names to version strings for dependencies on
/// hosted packages.
-Future<void> createLockFile(String package,
- {Iterable<String>? dependenciesInSandBox,
- Map<String, String>? hosted}) async {
+Future<void> createLockFile(
+ String package, {
+ Iterable<String>? dependenciesInSandBox,
+ Map<String, String>? hosted,
+}) async {
var cache = SystemCache(rootDir: _pathInSandbox(cachePath));
var lockFile =
@@ -632,7 +689,9 @@
await d.dir(package, [
d.file(
- 'pubspec.lock', lockFile.serialize(p.join(d.sandbox, package), cache))
+ 'pubspec.lock',
+ lockFile.serialize(p.join(d.sandbox, package), cache),
+ )
]).create();
}
@@ -643,8 +702,11 @@
///
/// [hosted] is a list of package names to version strings for dependencies on
/// hosted packages.
-LockFile _createLockFile(SystemCache cache,
- {Iterable<String>? sandbox, Map<String, String>? hosted}) {
+LockFile _createLockFile(
+ SystemCache cache, {
+ Iterable<String>? sandbox,
+ Map<String, String>? hosted,
+}) {
var dependencies = {};
if (sandbox != null) {
@@ -654,20 +716,26 @@
}
final packages = <PackageId>[
- ...dependencies.entries.map((entry) => cache.path.parseId(
- entry.key, Version(0, 0, 0), {'path': entry.value, 'relative': true},
- containingDir: p.join(d.sandbox, appPath))),
+ ...dependencies.entries.map(
+ (entry) => cache.path.parseId(
+ entry.key,
+ Version(0, 0, 0),
+ {'path': entry.value, 'relative': true},
+ containingDir: p.join(d.sandbox, appPath),
+ ),
+ ),
if (hosted != null)
...hosted.entries.map(
(entry) => PackageId(
entry.key,
Version.parse(entry.value),
ResolvedHostedDescription(
- HostedDescription(
- entry.key,
- 'https://pub.dev',
- ),
- sha256: null),
+ HostedDescription(
+ entry.key,
+ 'https://pub.dev',
+ ),
+ sha256: null,
+ ),
),
)
];
@@ -699,7 +767,7 @@
var package = <String, Object>{
'name': name,
'version': version,
- 'homepage': 'http://pub.dev',
+ 'homepage': 'https://pub.dev',
'description': 'A package, I guess.'
};
@@ -721,7 +789,11 @@
///
/// If it's a [RegExp] or [Matcher], just reports whether the output matches.
void _validateOutput(
- List<String> failures, String pipe, expected, String actual) {
+ List<String> failures,
+ String pipe,
+ expected,
+ String actual,
+) {
if (expected == null) return;
if (expected is String) {
@@ -733,7 +805,11 @@
}
void _validateOutputString(
- List<String> failures, String pipe, String expected, String actual) {
+ List<String> failures,
+ String pipe,
+ String expected,
+ String actual,
+) {
var actualLines = actual.split('\n');
var expectedLines = expected.split('\n');
@@ -785,7 +861,11 @@
/// Validates that [actualText] is a string of JSON that matches [expected],
/// which may be a literal JSON object, or any other [Matcher].
void _validateOutputJson(
- List<String> failures, String pipe, expected, String actualText) {
+ List<String> failures,
+ String pipe,
+ expected,
+ String actualText,
+) {
late Map actual;
try {
actual = jsonDecode(actualText);
@@ -798,9 +878,11 @@
// Remove dart2js's timing logs, which would otherwise cause tests to fail
// flakily when compilation takes a long time.
- actual['log']?.removeWhere((entry) =>
- entry['level'] == 'Fine' &&
- entry['message'].startsWith('Not yet complete after'));
+ actual['log']?.removeWhere(
+ (entry) =>
+ entry['level'] == 'Fine' &&
+ entry['message'].startsWith('Not yet complete after'),
+ );
// Match against the expectation.
expect(actual, expected);
@@ -909,7 +991,8 @@
// }
final pipe = stdin == null ? '' : ' echo ${escapeShellArgument(stdin)} |';
buffer.writeln(
- '\$$pipe pub ${args.map(filterUnstableText).map(escapeShellArgument).join(' ')}');
+ '\$$pipe pub ${args.map(filterUnstableText).map(escapeShellArgument).join(' ')}',
+ );
for (final line in await process.stdout.rest.toList()) {
buffer.writeln(filterUnstableText(line));
}
@@ -951,8 +1034,10 @@
/// By adding the bin/ folder to the search `$PATH` we can prevent `pub` from
/// detecting the installed 'git' binary and we can test that it prints
/// a useful error message.
-Future<void> setUpFakeGitScript(
- {required String bash, required String batch}) async {
+Future<void> setUpFakeGitScript({
+ required String bash,
+ required String batch,
+}) async {
await d.dir('bin', [
if (!Platform.isWindows) d.file('git', bash),
if (Platform.isWindows) d.file('git.bat', batch),
@@ -1004,9 +1089,11 @@
for (final e in contents) {
addDescriptor(e, '');
}
- return _replaceOs(Stream.fromIterable(entries)
- .transform(tarWriterWith(format: OutputFormat.gnuLongName))
- .transform(gzip.encoder));
+ return _replaceOs(
+ Stream.fromIterable(entries)
+ .transform(tarWriterWith(format: OutputFormat.gnuLongName))
+ .transform(gzip.encoder),
+ );
}
/// Replaces the entry at index 9 in [stream] with a 0. This replaces the os
diff --git a/test/testdata/goldens/dependency_services/dependency_services_test/Adding transitive.txt b/test/testdata/goldens/dependency_services/dependency_services_test/Adding transitive.txt
index 3b16db1..9c04c2f 100644
--- a/test/testdata/goldens/dependency_services/dependency_services_test/Adding transitive.txt
+++ b/test/testdata/goldens/dependency_services/dependency_services_test/Adding transitive.txt
@@ -1,7 +1,7 @@
# GENERATED BY: test/dependency_services/dependency_services_test.dart
$ cat pubspec.yaml
-{"name":"app","dependencies":{"foo":"^1.0.0"},"environment":{"sdk":">=0.1.2 <1.0.0"}}
+{"name":"app","dependencies":{"foo":"^1.0.0"},"environment":{"sdk":"^3.0.2"}}
$ cat pubspec.lock
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
@@ -10,12 +10,12 @@
dependency: "direct main"
description:
name: foo
- sha256: "1614d63c0867d0994f75a231be7ee394a4f30cdeede4c7ea471fcad354c23d1f"
+ sha256: "0a2eec28c63c8ee616670da9bae0dbfe9294f5b04b264cc4a9be24876ea23d3b"
url: "http://localhost:$PORT"
source: hosted
version: "1.2.3"
sdks:
- dart: ">=0.1.2 <1.0.0"
+ dart: ">=3.0.2 <4.0.0"
-------------------------------- END OF OUTPUT ---------------------------------
## Section list
@@ -32,7 +32,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "1614d63c0867d0994f75a231be7ee394a4f30cdeede4c7ea471fcad354c23d1f"
+ "sha256": "0a2eec28c63c8ee616670da9bae0dbfe9294f5b04b264cc4a9be24876ea23d3b"
}
}
}
@@ -54,7 +54,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "1614d63c0867d0994f75a231be7ee394a4f30cdeede4c7ea471fcad354c23d1f"
+ "sha256": "0a2eec28c63c8ee616670da9bae0dbfe9294f5b04b264cc4a9be24876ea23d3b"
}
},
"latest": "2.2.3",
@@ -70,7 +70,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "fc06d01652f7b73f789abeb5b61aeb68b13cd472f87610cb8fb80e402a9139ff"
+ "sha256": "ac18fe8b90da258e8aaba1334745de249d93ebc2adee76e37922096dabc6fa7f"
}
},
"constraintBumped": "^2.2.3",
@@ -83,7 +83,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "1614d63c0867d0994f75a231be7ee394a4f30cdeede4c7ea471fcad354c23d1f"
+ "sha256": "0a2eec28c63c8ee616670da9bae0dbfe9294f5b04b264cc4a9be24876ea23d3b"
}
}
},
@@ -96,7 +96,7 @@
"description": {
"name": "transitive",
"url": "http://localhost:$PORT",
- "sha256": "8d245de5cde3ab3293e4cdea516c6a0395e24d338688279bab5f6c97bffa0915"
+ "sha256": "bbf701e5d89787675cdbf7d818561d8cd8524a0fb49d79133a887418120ecaab"
}
},
"constraintBumped": null,
@@ -117,7 +117,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "fc06d01652f7b73f789abeb5b61aeb68b13cd472f87610cb8fb80e402a9139ff"
+ "sha256": "ac18fe8b90da258e8aaba1334745de249d93ebc2adee76e37922096dabc6fa7f"
}
},
"constraintBumped": "^2.2.3",
@@ -130,7 +130,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "1614d63c0867d0994f75a231be7ee394a4f30cdeede4c7ea471fcad354c23d1f"
+ "sha256": "0a2eec28c63c8ee616670da9bae0dbfe9294f5b04b264cc4a9be24876ea23d3b"
}
}
},
@@ -143,7 +143,7 @@
"description": {
"name": "transitive",
"url": "http://localhost:$PORT",
- "sha256": "8d245de5cde3ab3293e4cdea516c6a0395e24d338688279bab5f6c97bffa0915"
+ "sha256": "bbf701e5d89787675cdbf7d818561d8cd8524a0fb49d79133a887418120ecaab"
}
},
"constraintBumped": null,
@@ -167,7 +167,7 @@
-------------------------------- END OF OUTPUT ---------------------------------
$ cat pubspec.yaml
-{"name":"app","dependencies":{"foo":^2.2.3},"environment":{"sdk":">=0.1.2 <1.0.0"}}
+{"name":"app","dependencies":{"foo":^2.2.3},"environment":{"sdk":"^3.0.2"}}
$ cat pubspec.lock
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
@@ -176,7 +176,7 @@
dependency: "direct main"
description:
name: foo
- sha256: fc06d01652f7b73f789abeb5b61aeb68b13cd472f87610cb8fb80e402a9139ff
+ sha256: ac18fe8b90da258e8aaba1334745de249d93ebc2adee76e37922096dabc6fa7f
url: "http://localhost:$PORT"
source: hosted
version: "2.2.3"
@@ -184,9 +184,9 @@
dependency: transitive
description:
name: transitive
- sha256: "8d245de5cde3ab3293e4cdea516c6a0395e24d338688279bab5f6c97bffa0915"
+ sha256: bbf701e5d89787675cdbf7d818561d8cd8524a0fb49d79133a887418120ecaab
url: "http://localhost:$PORT"
source: hosted
version: "1.0.0"
sdks:
- dart: ">=0.1.2 <1.0.0"
+ dart: ">=3.0.2 <4.0.0"
diff --git a/test/testdata/goldens/dependency_services/dependency_services_test/Can update a git package.txt b/test/testdata/goldens/dependency_services/dependency_services_test/Can update a git package.txt
index 35de0ad..17f7096 100644
--- a/test/testdata/goldens/dependency_services/dependency_services_test/Can update a git package.txt
+++ b/test/testdata/goldens/dependency_services/dependency_services_test/Can update a git package.txt
@@ -1,7 +1,7 @@
# GENERATED BY: test/dependency_services/dependency_services_test.dart
$ cat pubspec.yaml
-{"name":"myapp","environment":{"sdk":">=0.1.2 <1.0.0"},"dependencies":{"foo":{"git":{"url":"../foo.git"}},"bar":{"git":{"url":"../bar.git"},"version":"^1.0.0"}}}
+{"name":"myapp","dependencies":{"foo":{"git":{"url":"../foo.git"}},"bar":{"git":{"url":"../bar.git"},"version":"^1.0.0"}},"environment":{"sdk":"^3.0.2"}}
$ cat pubspec.lock
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
@@ -11,7 +11,7 @@
description:
path: "."
ref: HEAD
- resolved-ref: "5373af3230028f3e31e9ee39e326228db83710cb"
+ resolved-ref: "1ea665d6de007c60308949db4c6ae8049c2395f0"
url: "../bar.git"
source: git
version: "1.0.0"
@@ -20,12 +20,12 @@
description:
path: "."
ref: HEAD
- resolved-ref: "428f5dd6e627cb2384343eca6aed099f4f7d183d"
+ resolved-ref: "9e8b8ad5091bec2c4724b1e0c8ff9d6e32a7eaa4"
url: "../foo.git"
source: git
version: "1.0.0"
sdks:
- dart: ">=0.1.2 <1.0.0"
+ dart: ">=3.0.2 <4.0.0"
-------------------------------- END OF OUTPUT ---------------------------------
## Section list
@@ -34,7 +34,7 @@
"dependencies": [
{
"name": "bar",
- "version": "5373af3230028f3e31e9ee39e326228db83710cb",
+ "version": "1ea665d6de007c60308949db4c6ae8049c2395f0",
"kind": "direct",
"constraint": "^1.0.0",
"source": {
@@ -42,14 +42,14 @@
"description": {
"url": "../bar.git",
"ref": "HEAD",
- "resolved-ref": "5373af3230028f3e31e9ee39e326228db83710cb",
+ "resolved-ref": "1ea665d6de007c60308949db4c6ae8049c2395f0",
"path": "."
}
}
},
{
"name": "foo",
- "version": "428f5dd6e627cb2384343eca6aed099f4f7d183d",
+ "version": "9e8b8ad5091bec2c4724b1e0c8ff9d6e32a7eaa4",
"kind": "direct",
"constraint": "any",
"source": {
@@ -57,7 +57,7 @@
"description": {
"url": "../foo.git",
"ref": "HEAD",
- "resolved-ref": "428f5dd6e627cb2384343eca6aed099f4f7d183d",
+ "resolved-ref": "9e8b8ad5091bec2c4724b1e0c8ff9d6e32a7eaa4",
"path": "."
}
}
@@ -73,45 +73,45 @@
"dependencies": [
{
"name": "bar",
- "version": "5373af3230028f3e31e9ee39e326228db83710cb",
+ "version": "1ea665d6de007c60308949db4c6ae8049c2395f0",
"kind": "direct",
"source": {
"type": "git",
"description": {
"url": "../bar.git",
"ref": "HEAD",
- "resolved-ref": "5373af3230028f3e31e9ee39e326228db83710cb",
+ "resolved-ref": "1ea665d6de007c60308949db4c6ae8049c2395f0",
"path": "."
}
},
- "latest": "40d0ffbfc376f2a796b0bbb928636c242285a01c",
+ "latest": "6385a9b18caf6b92622d4ecef32356aeaab35ff7",
"constraint": "^1.0.0",
"compatible": [],
"singleBreaking": [
{
"name": "bar",
- "version": "40d0ffbfc376f2a796b0bbb928636c242285a01c",
+ "version": "6385a9b18caf6b92622d4ecef32356aeaab35ff7",
"kind": "direct",
"source": {
"type": "git",
"description": {
"url": "../bar.git",
"ref": "HEAD",
- "resolved-ref": "40d0ffbfc376f2a796b0bbb928636c242285a01c",
+ "resolved-ref": "6385a9b18caf6b92622d4ecef32356aeaab35ff7",
"path": "."
}
},
"constraintBumped": "^2.0.0",
"constraintWidened": ">=1.0.0 <3.0.0",
"constraintBumpedIfNeeded": "^2.0.0",
- "previousVersion": "5373af3230028f3e31e9ee39e326228db83710cb",
+ "previousVersion": "1ea665d6de007c60308949db4c6ae8049c2395f0",
"previousConstraint": "^1.0.0",
"previousSource": {
"type": "git",
"description": {
"url": "../bar.git",
"ref": "HEAD",
- "resolved-ref": "5373af3230028f3e31e9ee39e326228db83710cb",
+ "resolved-ref": "1ea665d6de007c60308949db4c6ae8049c2395f0",
"path": "."
}
}
@@ -120,28 +120,28 @@
"multiBreaking": [
{
"name": "bar",
- "version": "40d0ffbfc376f2a796b0bbb928636c242285a01c",
+ "version": "6385a9b18caf6b92622d4ecef32356aeaab35ff7",
"kind": "direct",
"source": {
"type": "git",
"description": {
"url": "../bar.git",
"ref": "HEAD",
- "resolved-ref": "40d0ffbfc376f2a796b0bbb928636c242285a01c",
+ "resolved-ref": "6385a9b18caf6b92622d4ecef32356aeaab35ff7",
"path": "."
}
},
"constraintBumped": "^2.0.0",
"constraintWidened": ">=1.0.0 <3.0.0",
"constraintBumpedIfNeeded": "^2.0.0",
- "previousVersion": "5373af3230028f3e31e9ee39e326228db83710cb",
+ "previousVersion": "1ea665d6de007c60308949db4c6ae8049c2395f0",
"previousConstraint": "^1.0.0",
"previousSource": {
"type": "git",
"description": {
"url": "../bar.git",
"ref": "HEAD",
- "resolved-ref": "5373af3230028f3e31e9ee39e326228db83710cb",
+ "resolved-ref": "1ea665d6de007c60308949db4c6ae8049c2395f0",
"path": "."
}
}
@@ -150,46 +150,46 @@
},
{
"name": "foo",
- "version": "428f5dd6e627cb2384343eca6aed099f4f7d183d",
+ "version": "9e8b8ad5091bec2c4724b1e0c8ff9d6e32a7eaa4",
"kind": "direct",
"source": {
"type": "git",
"description": {
"url": "../foo.git",
"ref": "HEAD",
- "resolved-ref": "428f5dd6e627cb2384343eca6aed099f4f7d183d",
+ "resolved-ref": "9e8b8ad5091bec2c4724b1e0c8ff9d6e32a7eaa4",
"path": "."
}
},
- "latest": "40c4eb4fb235961264ee9cdbdfa54ef7f6aa5199",
+ "latest": "385bb2860e7ebf9519993b2548d6cab74a6008ef",
"constraint": "any",
"compatible": [],
"singleBreaking": [],
"multiBreaking": [
{
"name": "foo",
- "version": "40c4eb4fb235961264ee9cdbdfa54ef7f6aa5199",
+ "version": "385bb2860e7ebf9519993b2548d6cab74a6008ef",
"kind": "direct",
"source": {
"type": "git",
"description": {
"url": "../foo.git",
"ref": "HEAD",
- "resolved-ref": "40c4eb4fb235961264ee9cdbdfa54ef7f6aa5199",
+ "resolved-ref": "385bb2860e7ebf9519993b2548d6cab74a6008ef",
"path": "."
}
},
"constraintBumped": "^2.0.0",
"constraintWidened": "any",
"constraintBumpedIfNeeded": "any",
- "previousVersion": "428f5dd6e627cb2384343eca6aed099f4f7d183d",
+ "previousVersion": "9e8b8ad5091bec2c4724b1e0c8ff9d6e32a7eaa4",
"previousConstraint": "any",
"previousSource": {
"type": "git",
"description": {
"url": "../foo.git",
"ref": "HEAD",
- "resolved-ref": "428f5dd6e627cb2384343eca6aed099f4f7d183d",
+ "resolved-ref": "9e8b8ad5091bec2c4724b1e0c8ff9d6e32a7eaa4",
"path": "."
}
}
@@ -202,13 +202,13 @@
-------------------------------- END OF OUTPUT ---------------------------------
## Section apply
-$ echo '{"dependencyChanges":[{"name":"foo","version":"40c4eb4fb235961264ee9cdbdfa54ef7f6aa5199"}]}' | dependency_services apply
+$ echo '{"dependencyChanges":[{"name":"foo","version":"385bb2860e7ebf9519993b2548d6cab74a6008ef"}]}' | dependency_services apply
{"dependencies":[]}
-------------------------------- END OF OUTPUT ---------------------------------
$ cat pubspec.yaml
-{"name":"myapp","environment":{"sdk":">=0.1.2 <1.0.0"},"dependencies":{"foo":{"git":{"url":"../foo.git"}},"bar":{"git":{"url":"../bar.git"},"version":"^1.0.0"}}}
+{"name":"myapp","dependencies":{"foo":{"git":{"url":"../foo.git"}},"bar":{"git":{"url":"../bar.git"},"version":"^1.0.0"}},"environment":{"sdk":"^3.0.2"}}
$ cat pubspec.lock
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
@@ -218,7 +218,7 @@
description:
path: "."
ref: HEAD
- resolved-ref: "5373af3230028f3e31e9ee39e326228db83710cb"
+ resolved-ref: "1ea665d6de007c60308949db4c6ae8049c2395f0"
url: "../bar.git"
source: git
version: "1.0.0"
@@ -227,9 +227,9 @@
description:
path: "."
ref: HEAD
- resolved-ref: "40c4eb4fb235961264ee9cdbdfa54ef7f6aa5199"
+ resolved-ref: "385bb2860e7ebf9519993b2548d6cab74a6008ef"
url: "../foo.git"
source: git
version: "2.0.0"
sdks:
- dart: ">=0.1.2 <1.0.0"
+ dart: ">=3.0.2 <4.0.0"
diff --git a/test/testdata/goldens/dependency_services/dependency_services_test/Compatible.txt b/test/testdata/goldens/dependency_services/dependency_services_test/Compatible.txt
index 4fbaffb..86e82b9 100644
--- a/test/testdata/goldens/dependency_services/dependency_services_test/Compatible.txt
+++ b/test/testdata/goldens/dependency_services/dependency_services_test/Compatible.txt
@@ -1,7 +1,7 @@
# GENERATED BY: test/dependency_services/dependency_services_test.dart
$ cat pubspec.yaml
-{"name":"app","dependencies":{"foo":"^1.0.0","bar":"^1.0.0","boo":"^1.0.0"},"environment":{"sdk":">=0.1.2 <1.0.0"}}
+{"name":"app","dependencies":{"foo":"^1.0.0","bar":"^1.0.0","boo":"^1.0.0"},"environment":{"sdk":"^3.0.2"}}
$ cat pubspec.lock
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
@@ -10,7 +10,7 @@
dependency: "direct main"
description:
name: bar
- sha256: ea004e8b0069df9e9827b101b64aaad455cc358849f1801dc48a41111cabbe20
+ sha256: "0a2afc2a042366f06a89e07dfe845d3c77c07534fe489d5c4d8e8a8bdcbf0c22"
url: "http://localhost:$PORT"
source: hosted
version: "1.2.3"
@@ -18,7 +18,7 @@
dependency: "direct main"
description:
name: boo
- sha256: "7971e197614f18130070007a54f446366c6e594f0ed159ae2c4e2b42972c426b"
+ sha256: "2dcaf9c9913755c735f929592ea582bdef50c544c84eeacba9bcecd08f583ab4"
url: "http://localhost:$PORT"
source: hosted
version: "1.2.3"
@@ -26,12 +26,12 @@
dependency: "direct main"
description:
name: foo
- sha256: "1614d63c0867d0994f75a231be7ee394a4f30cdeede4c7ea471fcad354c23d1f"
+ sha256: "0a2eec28c63c8ee616670da9bae0dbfe9294f5b04b264cc4a9be24876ea23d3b"
url: "http://localhost:$PORT"
source: hosted
version: "1.2.3"
sdks:
- dart: ">=0.1.2 <1.0.0"
+ dart: ">=3.0.2 <4.0.0"
-------------------------------- END OF OUTPUT ---------------------------------
## Section list
@@ -48,7 +48,7 @@
"description": {
"name": "bar",
"url": "http://localhost:$PORT",
- "sha256": "ea004e8b0069df9e9827b101b64aaad455cc358849f1801dc48a41111cabbe20"
+ "sha256": "0a2afc2a042366f06a89e07dfe845d3c77c07534fe489d5c4d8e8a8bdcbf0c22"
}
}
},
@@ -62,7 +62,7 @@
"description": {
"name": "boo",
"url": "http://localhost:$PORT",
- "sha256": "7971e197614f18130070007a54f446366c6e594f0ed159ae2c4e2b42972c426b"
+ "sha256": "2dcaf9c9913755c735f929592ea582bdef50c544c84eeacba9bcecd08f583ab4"
}
}
},
@@ -76,7 +76,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "1614d63c0867d0994f75a231be7ee394a4f30cdeede4c7ea471fcad354c23d1f"
+ "sha256": "0a2eec28c63c8ee616670da9bae0dbfe9294f5b04b264cc4a9be24876ea23d3b"
}
}
}
@@ -98,7 +98,7 @@
"description": {
"name": "bar",
"url": "http://localhost:$PORT",
- "sha256": "ea004e8b0069df9e9827b101b64aaad455cc358849f1801dc48a41111cabbe20"
+ "sha256": "0a2afc2a042366f06a89e07dfe845d3c77c07534fe489d5c4d8e8a8bdcbf0c22"
}
},
"latest": "2.2.3",
@@ -114,7 +114,7 @@
"description": {
"name": "bar",
"url": "http://localhost:$PORT",
- "sha256": "adcfe9ac3d6955fd4332f29f47bf3e814e388e2da7c2bc55d4561971bf8b5335"
+ "sha256": "7f5edf6d86145cb08b8c137151a8d59c9973d2a45a46921e2edb61db125e54f4"
}
},
"constraintBumped": "^2.2.3",
@@ -127,7 +127,7 @@
"description": {
"name": "bar",
"url": "http://localhost:$PORT",
- "sha256": "ea004e8b0069df9e9827b101b64aaad455cc358849f1801dc48a41111cabbe20"
+ "sha256": "0a2afc2a042366f06a89e07dfe845d3c77c07534fe489d5c4d8e8a8bdcbf0c22"
}
}
}
@@ -142,7 +142,7 @@
"description": {
"name": "bar",
"url": "http://localhost:$PORT",
- "sha256": "adcfe9ac3d6955fd4332f29f47bf3e814e388e2da7c2bc55d4561971bf8b5335"
+ "sha256": "7f5edf6d86145cb08b8c137151a8d59c9973d2a45a46921e2edb61db125e54f4"
}
},
"constraintBumped": "^2.2.3",
@@ -155,7 +155,7 @@
"description": {
"name": "bar",
"url": "http://localhost:$PORT",
- "sha256": "ea004e8b0069df9e9827b101b64aaad455cc358849f1801dc48a41111cabbe20"
+ "sha256": "0a2afc2a042366f06a89e07dfe845d3c77c07534fe489d5c4d8e8a8bdcbf0c22"
}
}
}
@@ -170,7 +170,7 @@
"description": {
"name": "boo",
"url": "http://localhost:$PORT",
- "sha256": "7971e197614f18130070007a54f446366c6e594f0ed159ae2c4e2b42972c426b"
+ "sha256": "2dcaf9c9913755c735f929592ea582bdef50c544c84eeacba9bcecd08f583ab4"
}
},
"latest": "1.2.4",
@@ -185,7 +185,7 @@
"description": {
"name": "boo",
"url": "http://localhost:$PORT",
- "sha256": "b060c0315b77c8383da5f9a7eee7667dbdc8108969e0a7855e294e35e7f42230"
+ "sha256": "32cfaf6e71b23797af1005b575a2279216b171987093748ff5ca8282fbc991fd"
}
},
"constraintBumped": "^1.0.0",
@@ -198,7 +198,7 @@
"description": {
"name": "boo",
"url": "http://localhost:$PORT",
- "sha256": "7971e197614f18130070007a54f446366c6e594f0ed159ae2c4e2b42972c426b"
+ "sha256": "2dcaf9c9913755c735f929592ea582bdef50c544c84eeacba9bcecd08f583ab4"
}
}
}
@@ -213,7 +213,7 @@
"description": {
"name": "boo",
"url": "http://localhost:$PORT",
- "sha256": "b060c0315b77c8383da5f9a7eee7667dbdc8108969e0a7855e294e35e7f42230"
+ "sha256": "32cfaf6e71b23797af1005b575a2279216b171987093748ff5ca8282fbc991fd"
}
},
"constraintBumped": "^1.2.4",
@@ -226,7 +226,7 @@
"description": {
"name": "boo",
"url": "http://localhost:$PORT",
- "sha256": "7971e197614f18130070007a54f446366c6e594f0ed159ae2c4e2b42972c426b"
+ "sha256": "2dcaf9c9913755c735f929592ea582bdef50c544c84eeacba9bcecd08f583ab4"
}
}
}
@@ -241,7 +241,7 @@
"description": {
"name": "boo",
"url": "http://localhost:$PORT",
- "sha256": "b060c0315b77c8383da5f9a7eee7667dbdc8108969e0a7855e294e35e7f42230"
+ "sha256": "32cfaf6e71b23797af1005b575a2279216b171987093748ff5ca8282fbc991fd"
}
},
"constraintBumped": "^1.2.4",
@@ -254,7 +254,7 @@
"description": {
"name": "boo",
"url": "http://localhost:$PORT",
- "sha256": "7971e197614f18130070007a54f446366c6e594f0ed159ae2c4e2b42972c426b"
+ "sha256": "2dcaf9c9913755c735f929592ea582bdef50c544c84eeacba9bcecd08f583ab4"
}
}
}
@@ -269,7 +269,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "1614d63c0867d0994f75a231be7ee394a4f30cdeede4c7ea471fcad354c23d1f"
+ "sha256": "0a2eec28c63c8ee616670da9bae0dbfe9294f5b04b264cc4a9be24876ea23d3b"
}
},
"latest": "2.2.3",
@@ -284,7 +284,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "88f2f9251967bf04bd478873f074b9d8df9f1c959afc150ba3b0ea813d48161e"
+ "sha256": "98405f2be818d57d0c01a1252e6bc50c1db9bb69b90557909740083019f214cd"
}
},
"constraintBumped": "^1.0.0",
@@ -297,7 +297,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "1614d63c0867d0994f75a231be7ee394a4f30cdeede4c7ea471fcad354c23d1f"
+ "sha256": "0a2eec28c63c8ee616670da9bae0dbfe9294f5b04b264cc4a9be24876ea23d3b"
}
}
}
@@ -312,7 +312,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "bf378a3f6c4840f911d66ab375f6d3eae78a015a41f0b8b202c31d4af010892e"
+ "sha256": "161f5087dae6dc41086fcac53e2db376488e5fa446f81b4352512917e20ccb0a"
}
},
"constraintBumped": "^2.2.3",
@@ -325,7 +325,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "1614d63c0867d0994f75a231be7ee394a4f30cdeede4c7ea471fcad354c23d1f"
+ "sha256": "0a2eec28c63c8ee616670da9bae0dbfe9294f5b04b264cc4a9be24876ea23d3b"
}
}
}
@@ -340,7 +340,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "bf378a3f6c4840f911d66ab375f6d3eae78a015a41f0b8b202c31d4af010892e"
+ "sha256": "161f5087dae6dc41086fcac53e2db376488e5fa446f81b4352512917e20ccb0a"
}
},
"constraintBumped": "^2.2.3",
@@ -353,7 +353,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "1614d63c0867d0994f75a231be7ee394a4f30cdeede4c7ea471fcad354c23d1f"
+ "sha256": "0a2eec28c63c8ee616670da9bae0dbfe9294f5b04b264cc4a9be24876ea23d3b"
}
}
}
@@ -371,7 +371,7 @@
-------------------------------- END OF OUTPUT ---------------------------------
$ cat pubspec.yaml
-{"name":"app","dependencies":{"foo":"^1.0.0","bar":"^1.0.0","boo":"^1.0.0"},"environment":{"sdk":">=0.1.2 <1.0.0"}}
+{"name":"app","dependencies":{"foo":"^1.0.0","bar":"^1.0.0","boo":"^1.0.0"},"environment":{"sdk":"^3.0.2"}}
$ cat pubspec.lock
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
@@ -380,7 +380,7 @@
dependency: "direct main"
description:
name: bar
- sha256: ea004e8b0069df9e9827b101b64aaad455cc358849f1801dc48a41111cabbe20
+ sha256: "0a2afc2a042366f06a89e07dfe845d3c77c07534fe489d5c4d8e8a8bdcbf0c22"
url: "http://localhost:$PORT"
source: hosted
version: "1.2.3"
@@ -388,7 +388,7 @@
dependency: "direct main"
description:
name: boo
- sha256: "7971e197614f18130070007a54f446366c6e594f0ed159ae2c4e2b42972c426b"
+ sha256: "2dcaf9c9913755c735f929592ea582bdef50c544c84eeacba9bcecd08f583ab4"
url: "http://localhost:$PORT"
source: hosted
version: "1.2.3"
@@ -396,9 +396,9 @@
dependency: "direct main"
description:
name: foo
- sha256: "88f2f9251967bf04bd478873f074b9d8df9f1c959afc150ba3b0ea813d48161e"
+ sha256: "98405f2be818d57d0c01a1252e6bc50c1db9bb69b90557909740083019f214cd"
url: "http://localhost:$PORT"
source: hosted
version: "1.2.4"
sdks:
- dart: ">=0.1.2 <1.0.0"
+ dart: ">=3.0.2 <4.0.0"
diff --git a/test/testdata/goldens/dependency_services/dependency_services_test/No pubspec.lock.txt b/test/testdata/goldens/dependency_services/dependency_services_test/No pubspec.lock.txt
index a6709fc..46d1a77 100644
--- a/test/testdata/goldens/dependency_services/dependency_services_test/No pubspec.lock.txt
+++ b/test/testdata/goldens/dependency_services/dependency_services_test/No pubspec.lock.txt
@@ -1,7 +1,7 @@
# GENERATED BY: test/dependency_services/dependency_services_test.dart
$ cat pubspec.yaml
-{"name":"app","dependencies":{"foo":"^1.0.0","bar":{"git":{"url":"../bar.git"}}},"environment":{"sdk":">=0.1.2 <1.0.0"}}
+{"name":"app","dependencies":{"foo":"^1.0.0","bar":{"git":{"url":"../bar.git"}}},"environment":{"sdk":"^3.0.2"}}
$ cat pubspec.lock
No such file pubspec.lock.
-------------------------------- END OF OUTPUT ---------------------------------
@@ -12,7 +12,7 @@
"dependencies": [
{
"name": "bar",
- "version": "5373af3230028f3e31e9ee39e326228db83710cb",
+ "version": "1ea665d6de007c60308949db4c6ae8049c2395f0",
"kind": "direct",
"constraint": "any",
"source": {
@@ -20,7 +20,7 @@
"description": {
"url": "../bar.git",
"ref": "HEAD",
- "resolved-ref": "5373af3230028f3e31e9ee39e326228db83710cb",
+ "resolved-ref": "1ea665d6de007c60308949db4c6ae8049c2395f0",
"path": "."
}
}
@@ -35,7 +35,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "72f6a04c4af0d78e4f1a1e2eb00a850843e6c0c5233ac2ca911aa061cbd5f8f1"
+ "sha256": "e963d896bb117842c18b0c7ed19c31b84c414acf5845b853acc89994339b613a"
}
}
},
@@ -49,7 +49,7 @@
"description": {
"name": "transitive",
"url": "http://localhost:$PORT",
- "sha256": "8d245de5cde3ab3293e4cdea516c6a0395e24d338688279bab5f6c97bffa0915"
+ "sha256": "bbf701e5d89787675cdbf7d818561d8cd8524a0fb49d79133a887418120ecaab"
}
}
}
@@ -64,18 +64,18 @@
"dependencies": [
{
"name": "bar",
- "version": "5373af3230028f3e31e9ee39e326228db83710cb",
+ "version": "1ea665d6de007c60308949db4c6ae8049c2395f0",
"kind": "direct",
"source": {
"type": "git",
"description": {
"url": "../bar.git",
"ref": "HEAD",
- "resolved-ref": "5373af3230028f3e31e9ee39e326228db83710cb",
+ "resolved-ref": "1ea665d6de007c60308949db4c6ae8049c2395f0",
"path": "."
}
},
- "latest": "5373af3230028f3e31e9ee39e326228db83710cb",
+ "latest": "1ea665d6de007c60308949db4c6ae8049c2395f0",
"constraint": "any",
"compatible": [],
"singleBreaking": [],
@@ -89,7 +89,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "bf378a3f6c4840f911d66ab375f6d3eae78a015a41f0b8b202c31d4af010892e"
+ "sha256": "161f5087dae6dc41086fcac53e2db376488e5fa446f81b4352512917e20ccb0a"
}
},
"constraintBumped": "^2.2.3",
@@ -102,7 +102,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "72f6a04c4af0d78e4f1a1e2eb00a850843e6c0c5233ac2ca911aa061cbd5f8f1"
+ "sha256": "e963d896bb117842c18b0c7ed19c31b84c414acf5845b853acc89994339b613a"
}
}
}
@@ -117,7 +117,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "72f6a04c4af0d78e4f1a1e2eb00a850843e6c0c5233ac2ca911aa061cbd5f8f1"
+ "sha256": "e963d896bb117842c18b0c7ed19c31b84c414acf5845b853acc89994339b613a"
}
},
"latest": "2.2.3",
@@ -133,7 +133,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "bf378a3f6c4840f911d66ab375f6d3eae78a015a41f0b8b202c31d4af010892e"
+ "sha256": "161f5087dae6dc41086fcac53e2db376488e5fa446f81b4352512917e20ccb0a"
}
},
"constraintBumped": "^2.2.3",
@@ -146,7 +146,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "72f6a04c4af0d78e4f1a1e2eb00a850843e6c0c5233ac2ca911aa061cbd5f8f1"
+ "sha256": "e963d896bb117842c18b0c7ed19c31b84c414acf5845b853acc89994339b613a"
}
}
}
@@ -161,7 +161,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "bf378a3f6c4840f911d66ab375f6d3eae78a015a41f0b8b202c31d4af010892e"
+ "sha256": "161f5087dae6dc41086fcac53e2db376488e5fa446f81b4352512917e20ccb0a"
}
},
"constraintBumped": "^2.2.3",
@@ -174,7 +174,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "72f6a04c4af0d78e4f1a1e2eb00a850843e6c0c5233ac2ca911aa061cbd5f8f1"
+ "sha256": "e963d896bb117842c18b0c7ed19c31b84c414acf5845b853acc89994339b613a"
}
}
}
@@ -189,7 +189,7 @@
"description": {
"name": "transitive",
"url": "http://localhost:$PORT",
- "sha256": "8d245de5cde3ab3293e4cdea516c6a0395e24d338688279bab5f6c97bffa0915"
+ "sha256": "bbf701e5d89787675cdbf7d818561d8cd8524a0fb49d79133a887418120ecaab"
}
},
"latest": "1.0.0",
@@ -210,6 +210,6 @@
-------------------------------- END OF OUTPUT ---------------------------------
$ cat pubspec.yaml
-{"name":"app","dependencies":{"foo":^2.2.3,"bar":{"git":{"url":"../bar.git"}}},"environment":{"sdk":">=0.1.2 <1.0.0"}}
+{"name":"app","dependencies":{"foo":^2.2.3,"bar":{"git":{"url":"../bar.git"}}},"environment":{"sdk":"^3.0.2"}}
$ cat pubspec.lock
No such file pubspec.lock.
diff --git a/test/testdata/goldens/dependency_services/dependency_services_test/Preserves no content-hashes.txt b/test/testdata/goldens/dependency_services/dependency_services_test/Preserves no content-hashes.txt
index bd707b4..a0ffae6 100644
--- a/test/testdata/goldens/dependency_services/dependency_services_test/Preserves no content-hashes.txt
+++ b/test/testdata/goldens/dependency_services/dependency_services_test/Preserves no content-hashes.txt
@@ -1,7 +1,7 @@
# GENERATED BY: test/dependency_services/dependency_services_test.dart
$ cat pubspec.yaml
-{"name":"app","dependencies":{"foo":"^1.0.0","bar":"^1.0.0","boo":"^1.0.0"},"environment":{"sdk":">=0.1.2 <1.0.0"}}
+{"name":"app","dependencies":{"foo":"^1.0.0","bar":"^1.0.0","boo":"^1.0.0"},"environment":{"sdk":"^3.0.2"}}
$ cat pubspec.lock
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
@@ -28,7 +28,7 @@
source: hosted
version: "1.2.3"
sdks:
- dart: ">=0.1.2 <1.0.0"
+ dart: ">=3.0.2 <4.0.0"
-------------------------------- END OF OUTPUT ---------------------------------
## Section list
@@ -107,7 +107,7 @@
"description": {
"name": "bar",
"url": "http://localhost:$PORT",
- "sha256": "adcfe9ac3d6955fd4332f29f47bf3e814e388e2da7c2bc55d4561971bf8b5335"
+ "sha256": "7f5edf6d86145cb08b8c137151a8d59c9973d2a45a46921e2edb61db125e54f4"
}
},
"constraintBumped": "^2.2.3",
@@ -134,7 +134,7 @@
"description": {
"name": "bar",
"url": "http://localhost:$PORT",
- "sha256": "adcfe9ac3d6955fd4332f29f47bf3e814e388e2da7c2bc55d4561971bf8b5335"
+ "sha256": "7f5edf6d86145cb08b8c137151a8d59c9973d2a45a46921e2edb61db125e54f4"
}
},
"constraintBumped": "^2.2.3",
@@ -175,7 +175,7 @@
"description": {
"name": "boo",
"url": "http://localhost:$PORT",
- "sha256": "b060c0315b77c8383da5f9a7eee7667dbdc8108969e0a7855e294e35e7f42230"
+ "sha256": "32cfaf6e71b23797af1005b575a2279216b171987093748ff5ca8282fbc991fd"
}
},
"constraintBumped": "^1.0.0",
@@ -202,7 +202,7 @@
"description": {
"name": "boo",
"url": "http://localhost:$PORT",
- "sha256": "b060c0315b77c8383da5f9a7eee7667dbdc8108969e0a7855e294e35e7f42230"
+ "sha256": "32cfaf6e71b23797af1005b575a2279216b171987093748ff5ca8282fbc991fd"
}
},
"constraintBumped": "^1.2.4",
@@ -229,7 +229,7 @@
"description": {
"name": "boo",
"url": "http://localhost:$PORT",
- "sha256": "b060c0315b77c8383da5f9a7eee7667dbdc8108969e0a7855e294e35e7f42230"
+ "sha256": "32cfaf6e71b23797af1005b575a2279216b171987093748ff5ca8282fbc991fd"
}
},
"constraintBumped": "^1.2.4",
@@ -270,7 +270,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "88f2f9251967bf04bd478873f074b9d8df9f1c959afc150ba3b0ea813d48161e"
+ "sha256": "98405f2be818d57d0c01a1252e6bc50c1db9bb69b90557909740083019f214cd"
}
},
"constraintBumped": "^1.0.0",
@@ -297,7 +297,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "bf378a3f6c4840f911d66ab375f6d3eae78a015a41f0b8b202c31d4af010892e"
+ "sha256": "161f5087dae6dc41086fcac53e2db376488e5fa446f81b4352512917e20ccb0a"
}
},
"constraintBumped": "^2.2.3",
@@ -324,7 +324,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "bf378a3f6c4840f911d66ab375f6d3eae78a015a41f0b8b202c31d4af010892e"
+ "sha256": "161f5087dae6dc41086fcac53e2db376488e5fa446f81b4352512917e20ccb0a"
}
},
"constraintBumped": "^2.2.3",
@@ -354,7 +354,7 @@
-------------------------------- END OF OUTPUT ---------------------------------
$ cat pubspec.yaml
-{"name":"app","dependencies":{"foo":"^1.0.0","bar":"^1.0.0","boo":"^1.0.0"},"environment":{"sdk":">=0.1.2 <1.0.0"}}
+{"name":"app","dependencies":{"foo":"^1.0.0","bar":"^1.0.0","boo":"^1.0.0"},"environment":{"sdk":"^3.0.2"}}
$ cat pubspec.lock
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
@@ -381,4 +381,4 @@
source: hosted
version: "1.2.4"
sdks:
- dart: ">=0.1.2 <1.0.0"
+ dart: ">=3.0.2 <4.0.0"
diff --git a/test/testdata/goldens/dependency_services/dependency_services_test/Relative paths are allowed.txt b/test/testdata/goldens/dependency_services/dependency_services_test/Relative paths are allowed.txt
index 2e38773..6ac254b 100644
--- a/test/testdata/goldens/dependency_services/dependency_services_test/Relative paths are allowed.txt
+++ b/test/testdata/goldens/dependency_services/dependency_services_test/Relative paths are allowed.txt
@@ -1,7 +1,7 @@
# GENERATED BY: test/dependency_services/dependency_services_test.dart
$ cat pubspec.yaml
-{"name":"myapp","environment":{"sdk":">=0.1.2 <1.0.0"},"dependencies":{"foo":"^1.0.0","bar":{"path":"../bar"}}}
+{"name":"myapp","dependencies":{"foo":"^1.0.0","bar":{"path":"../bar"}},"environment":{"sdk":"^3.0.2"}}
$ cat pubspec.lock
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
@@ -17,12 +17,12 @@
dependency: "direct main"
description:
name: foo
- sha256: "439814f59cbc73e1c28ca5ac6e437d5f2af10dfd18db786ce46fe0663e605ccb"
+ sha256: "4a8df8c695623e81d90f663801ead4a5269b406599b43b90ad558561a6f09c59"
url: "http://localhost:$PORT"
source: hosted
version: "1.0.0"
sdks:
- dart: ">=0.1.2 <1.0.0"
+ dart: ">=3.0.2 <4.0.0"
-------------------------------- END OF OUTPUT ---------------------------------
## Section list
@@ -52,7 +52,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "439814f59cbc73e1c28ca5ac6e437d5f2af10dfd18db786ce46fe0663e605ccb"
+ "sha256": "4a8df8c695623e81d90f663801ead4a5269b406599b43b90ad558561a6f09c59"
}
}
}
@@ -91,7 +91,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "439814f59cbc73e1c28ca5ac6e437d5f2af10dfd18db786ce46fe0663e605ccb"
+ "sha256": "4a8df8c695623e81d90f663801ead4a5269b406599b43b90ad558561a6f09c59"
}
},
"latest": "2.0.0",
@@ -107,7 +107,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "c3bda774737102f799574749076544dea1a4745b5c38d590d4f206f997bfe8a0"
+ "sha256": "3b080cba6d4ca9699c5c75c6b54852f77fe6d15e9cd13039ea4ca37683393021"
}
},
"constraintBumped": "^2.0.0",
@@ -120,7 +120,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "439814f59cbc73e1c28ca5ac6e437d5f2af10dfd18db786ce46fe0663e605ccb"
+ "sha256": "4a8df8c695623e81d90f663801ead4a5269b406599b43b90ad558561a6f09c59"
}
}
}
@@ -135,7 +135,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "c3bda774737102f799574749076544dea1a4745b5c38d590d4f206f997bfe8a0"
+ "sha256": "3b080cba6d4ca9699c5c75c6b54852f77fe6d15e9cd13039ea4ca37683393021"
}
},
"constraintBumped": "^2.0.0",
@@ -148,7 +148,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "439814f59cbc73e1c28ca5ac6e437d5f2af10dfd18db786ce46fe0663e605ccb"
+ "sha256": "4a8df8c695623e81d90f663801ead4a5269b406599b43b90ad558561a6f09c59"
}
}
}
@@ -166,7 +166,7 @@
-------------------------------- END OF OUTPUT ---------------------------------
$ cat pubspec.yaml
-{"name":"myapp","environment":{"sdk":">=0.1.2 <1.0.0"},"dependencies":{"foo":^2.0.0,"bar":{"path":"../bar"}}}
+{"name":"myapp","dependencies":{"foo":^2.0.0,"bar":{"path":"../bar"}},"environment":{"sdk":"^3.0.2"}}
$ cat pubspec.lock
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
@@ -182,9 +182,9 @@
dependency: "direct main"
description:
name: foo
- sha256: c3bda774737102f799574749076544dea1a4745b5c38d590d4f206f997bfe8a0
+ sha256: "3b080cba6d4ca9699c5c75c6b54852f77fe6d15e9cd13039ea4ca37683393021"
url: "http://localhost:$PORT"
source: hosted
version: "2.0.0"
sdks:
- dart: ">=0.1.2 <1.0.0"
+ dart: ">=3.0.2 <4.0.0"
diff --git a/test/testdata/goldens/dependency_services/dependency_services_test/Removing transitive.txt b/test/testdata/goldens/dependency_services/dependency_services_test/Removing transitive.txt
index 0498611..097456a 100644
--- a/test/testdata/goldens/dependency_services/dependency_services_test/Removing transitive.txt
+++ b/test/testdata/goldens/dependency_services/dependency_services_test/Removing transitive.txt
@@ -1,7 +1,7 @@
# GENERATED BY: test/dependency_services/dependency_services_test.dart
$ cat pubspec.yaml
-{"name":"app","dependencies":{"foo":"^1.0.0"},"environment":{"sdk":">=0.1.2 <1.0.0"}}
+{"name":"app","dependencies":{"foo":"^1.0.0"},"environment":{"sdk":"^3.0.2"}}
$ cat pubspec.lock
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
@@ -10,7 +10,7 @@
dependency: "direct main"
description:
name: foo
- sha256: "72f6a04c4af0d78e4f1a1e2eb00a850843e6c0c5233ac2ca911aa061cbd5f8f1"
+ sha256: e963d896bb117842c18b0c7ed19c31b84c414acf5845b853acc89994339b613a
url: "http://localhost:$PORT"
source: hosted
version: "1.2.3"
@@ -18,12 +18,12 @@
dependency: transitive
description:
name: transitive
- sha256: "8d245de5cde3ab3293e4cdea516c6a0395e24d338688279bab5f6c97bffa0915"
+ sha256: bbf701e5d89787675cdbf7d818561d8cd8524a0fb49d79133a887418120ecaab
url: "http://localhost:$PORT"
source: hosted
version: "1.0.0"
sdks:
- dart: ">=0.1.2 <1.0.0"
+ dart: ">=3.0.2 <4.0.0"
-------------------------------- END OF OUTPUT ---------------------------------
## Section list
@@ -40,7 +40,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "72f6a04c4af0d78e4f1a1e2eb00a850843e6c0c5233ac2ca911aa061cbd5f8f1"
+ "sha256": "e963d896bb117842c18b0c7ed19c31b84c414acf5845b853acc89994339b613a"
}
}
},
@@ -54,7 +54,7 @@
"description": {
"name": "transitive",
"url": "http://localhost:$PORT",
- "sha256": "8d245de5cde3ab3293e4cdea516c6a0395e24d338688279bab5f6c97bffa0915"
+ "sha256": "bbf701e5d89787675cdbf7d818561d8cd8524a0fb49d79133a887418120ecaab"
}
}
}
@@ -76,7 +76,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "72f6a04c4af0d78e4f1a1e2eb00a850843e6c0c5233ac2ca911aa061cbd5f8f1"
+ "sha256": "e963d896bb117842c18b0c7ed19c31b84c414acf5845b853acc89994339b613a"
}
},
"latest": "2.2.3",
@@ -92,7 +92,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "bf378a3f6c4840f911d66ab375f6d3eae78a015a41f0b8b202c31d4af010892e"
+ "sha256": "161f5087dae6dc41086fcac53e2db376488e5fa446f81b4352512917e20ccb0a"
}
},
"constraintBumped": "^2.2.3",
@@ -105,7 +105,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "72f6a04c4af0d78e4f1a1e2eb00a850843e6c0c5233ac2ca911aa061cbd5f8f1"
+ "sha256": "e963d896bb117842c18b0c7ed19c31b84c414acf5845b853acc89994339b613a"
}
}
},
@@ -123,7 +123,7 @@
"description": {
"name": "transitive",
"url": "http://localhost:$PORT",
- "sha256": "8d245de5cde3ab3293e4cdea516c6a0395e24d338688279bab5f6c97bffa0915"
+ "sha256": "bbf701e5d89787675cdbf7d818561d8cd8524a0fb49d79133a887418120ecaab"
}
}
}
@@ -138,7 +138,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "bf378a3f6c4840f911d66ab375f6d3eae78a015a41f0b8b202c31d4af010892e"
+ "sha256": "161f5087dae6dc41086fcac53e2db376488e5fa446f81b4352512917e20ccb0a"
}
},
"constraintBumped": "^2.2.3",
@@ -151,7 +151,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "72f6a04c4af0d78e4f1a1e2eb00a850843e6c0c5233ac2ca911aa061cbd5f8f1"
+ "sha256": "e963d896bb117842c18b0c7ed19c31b84c414acf5845b853acc89994339b613a"
}
}
},
@@ -169,7 +169,7 @@
"description": {
"name": "transitive",
"url": "http://localhost:$PORT",
- "sha256": "8d245de5cde3ab3293e4cdea516c6a0395e24d338688279bab5f6c97bffa0915"
+ "sha256": "bbf701e5d89787675cdbf7d818561d8cd8524a0fb49d79133a887418120ecaab"
}
}
}
@@ -184,7 +184,7 @@
"description": {
"name": "transitive",
"url": "http://localhost:$PORT",
- "sha256": "8d245de5cde3ab3293e4cdea516c6a0395e24d338688279bab5f6c97bffa0915"
+ "sha256": "bbf701e5d89787675cdbf7d818561d8cd8524a0fb49d79133a887418120ecaab"
}
},
"latest": "1.0.0",
@@ -205,7 +205,7 @@
-------------------------------- END OF OUTPUT ---------------------------------
$ cat pubspec.yaml
-{"name":"app","dependencies":{"foo":^2.2.3},"environment":{"sdk":">=0.1.2 <1.0.0"}}
+{"name":"app","dependencies":{"foo":^2.2.3},"environment":{"sdk":"^3.0.2"}}
$ cat pubspec.lock
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
@@ -214,9 +214,9 @@
dependency: "direct main"
description:
name: foo
- sha256: bf378a3f6c4840f911d66ab375f6d3eae78a015a41f0b8b202c31d4af010892e
+ sha256: "161f5087dae6dc41086fcac53e2db376488e5fa446f81b4352512917e20ccb0a"
url: "http://localhost:$PORT"
source: hosted
version: "2.2.3"
sdks:
- dart: ">=0.1.2 <1.0.0"
+ dart: ">=3.0.2 <4.0.0"
diff --git a/test/testdata/goldens/dependency_services/dependency_services_test/multibreaking.txt b/test/testdata/goldens/dependency_services/dependency_services_test/multibreaking.txt
index 3767075..aa053e5 100644
--- a/test/testdata/goldens/dependency_services/dependency_services_test/multibreaking.txt
+++ b/test/testdata/goldens/dependency_services/dependency_services_test/multibreaking.txt
@@ -1,7 +1,7 @@
# GENERATED BY: test/dependency_services/dependency_services_test.dart
$ cat pubspec.yaml
-{"name":"app","dependencies":{"foo":"^1.0.0","bar":"^1.0.0","baz":"1.0.0"},"environment":{"sdk":">=0.1.2 <1.0.0"}}
+{"name":"app","dependencies":{"foo":"^1.0.0","bar":"^1.0.0","baz":"1.0.0"},"environment":{"sdk":"^3.0.2"}}
$ cat pubspec.lock
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
@@ -10,7 +10,7 @@
dependency: "direct main"
description:
name: bar
- sha256: "4de00552ae3719481f5f0e30b82ecb8b14a62907553b217e7ca178e80625329a"
+ sha256: "8cd4b5a00de63aa592f4240249affd87abf49de4281233870f22b30919f87d42"
url: "http://localhost:$PORT"
source: hosted
version: "1.0.0"
@@ -18,7 +18,7 @@
dependency: "direct main"
description:
name: baz
- sha256: "377433f0e0aff092191e57de97f5869cad0dd0779ee6d31e7096b84878ca41e8"
+ sha256: b61dfc82400bc16736afba3958f2c81ff8a5a4b41a31c1b15bdc43a090113cef
url: "http://localhost:$PORT"
source: hosted
version: "1.0.0"
@@ -26,12 +26,12 @@
dependency: "direct main"
description:
name: foo
- sha256: "439814f59cbc73e1c28ca5ac6e437d5f2af10dfd18db786ce46fe0663e605ccb"
+ sha256: "4a8df8c695623e81d90f663801ead4a5269b406599b43b90ad558561a6f09c59"
url: "http://localhost:$PORT"
source: hosted
version: "1.0.0"
sdks:
- dart: ">=0.1.2 <1.0.0"
+ dart: ">=3.0.2 <4.0.0"
-------------------------------- END OF OUTPUT ---------------------------------
## Section list
@@ -48,7 +48,7 @@
"description": {
"name": "bar",
"url": "http://localhost:$PORT",
- "sha256": "4de00552ae3719481f5f0e30b82ecb8b14a62907553b217e7ca178e80625329a"
+ "sha256": "8cd4b5a00de63aa592f4240249affd87abf49de4281233870f22b30919f87d42"
}
}
},
@@ -62,7 +62,7 @@
"description": {
"name": "baz",
"url": "http://localhost:$PORT",
- "sha256": "377433f0e0aff092191e57de97f5869cad0dd0779ee6d31e7096b84878ca41e8"
+ "sha256": "b61dfc82400bc16736afba3958f2c81ff8a5a4b41a31c1b15bdc43a090113cef"
}
}
},
@@ -76,7 +76,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "439814f59cbc73e1c28ca5ac6e437d5f2af10dfd18db786ce46fe0663e605ccb"
+ "sha256": "4a8df8c695623e81d90f663801ead4a5269b406599b43b90ad558561a6f09c59"
}
}
}
@@ -98,7 +98,7 @@
"description": {
"name": "bar",
"url": "http://localhost:$PORT",
- "sha256": "4de00552ae3719481f5f0e30b82ecb8b14a62907553b217e7ca178e80625329a"
+ "sha256": "8cd4b5a00de63aa592f4240249affd87abf49de4281233870f22b30919f87d42"
}
},
"latest": "2.0.0",
@@ -115,7 +115,7 @@
"description": {
"name": "bar",
"url": "http://localhost:$PORT",
- "sha256": "b8187621010649d6385788d7630adcd88d6548a7938899b6f18820961df3b879"
+ "sha256": "d8f427cae6af20c3915ea195fc8b17f98a4bb333953d418657d83d9f8fb829d7"
}
},
"constraintBumped": "^2.0.0",
@@ -128,7 +128,7 @@
"description": {
"name": "bar",
"url": "http://localhost:$PORT",
- "sha256": "4de00552ae3719481f5f0e30b82ecb8b14a62907553b217e7ca178e80625329a"
+ "sha256": "8cd4b5a00de63aa592f4240249affd87abf49de4281233870f22b30919f87d42"
}
}
},
@@ -141,7 +141,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "2347a7792f73d0f8cc8aa41d4895317bd1745724b8bc77d8c03faf821c9059b7"
+ "sha256": "02b6111db259663d77ff60109d07ccf04e216af6d8d31166f55547e5bed89e21"
}
},
"constraintBumped": "^3.0.1",
@@ -154,7 +154,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "439814f59cbc73e1c28ca5ac6e437d5f2af10dfd18db786ce46fe0663e605ccb"
+ "sha256": "4a8df8c695623e81d90f663801ead4a5269b406599b43b90ad558561a6f09c59"
}
}
}
@@ -169,7 +169,7 @@
"description": {
"name": "baz",
"url": "http://localhost:$PORT",
- "sha256": "377433f0e0aff092191e57de97f5869cad0dd0779ee6d31e7096b84878ca41e8"
+ "sha256": "b61dfc82400bc16736afba3958f2c81ff8a5a4b41a31c1b15bdc43a090113cef"
}
},
"latest": "1.1.0",
@@ -185,7 +185,7 @@
"description": {
"name": "baz",
"url": "http://localhost:$PORT",
- "sha256": "7474da026b513eafecba9d1c79a8a3b4a9ef5158730e0968383063b3237c5dec"
+ "sha256": "f1a51ba864d7ef5702590e96167b812443ace67e15a82a0e064e735ac1376ec5"
}
},
"constraintBumped": "^1.1.0",
@@ -198,7 +198,7 @@
"description": {
"name": "baz",
"url": "http://localhost:$PORT",
- "sha256": "377433f0e0aff092191e57de97f5869cad0dd0779ee6d31e7096b84878ca41e8"
+ "sha256": "b61dfc82400bc16736afba3958f2c81ff8a5a4b41a31c1b15bdc43a090113cef"
}
}
}
@@ -213,7 +213,7 @@
"description": {
"name": "baz",
"url": "http://localhost:$PORT",
- "sha256": "7474da026b513eafecba9d1c79a8a3b4a9ef5158730e0968383063b3237c5dec"
+ "sha256": "f1a51ba864d7ef5702590e96167b812443ace67e15a82a0e064e735ac1376ec5"
}
},
"constraintBumped": "^1.1.0",
@@ -226,7 +226,7 @@
"description": {
"name": "baz",
"url": "http://localhost:$PORT",
- "sha256": "377433f0e0aff092191e57de97f5869cad0dd0779ee6d31e7096b84878ca41e8"
+ "sha256": "b61dfc82400bc16736afba3958f2c81ff8a5a4b41a31c1b15bdc43a090113cef"
}
}
}
@@ -241,7 +241,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "439814f59cbc73e1c28ca5ac6e437d5f2af10dfd18db786ce46fe0663e605ccb"
+ "sha256": "4a8df8c695623e81d90f663801ead4a5269b406599b43b90ad558561a6f09c59"
}
},
"latest": "3.0.1",
@@ -256,7 +256,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "efa386ac7cc7698525e2e820a90e6bcee5d6c071de4315051a0fb2f3aff5d084"
+ "sha256": "601504c450e2e657b80fd1912e90d38393a7e2e6a3f5a641220952c812fcb722"
}
},
"constraintBumped": "^1.0.0",
@@ -269,7 +269,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "439814f59cbc73e1c28ca5ac6e437d5f2af10dfd18db786ce46fe0663e605ccb"
+ "sha256": "4a8df8c695623e81d90f663801ead4a5269b406599b43b90ad558561a6f09c59"
}
}
}
@@ -284,7 +284,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "c3bda774737102f799574749076544dea1a4745b5c38d590d4f206f997bfe8a0"
+ "sha256": "3b080cba6d4ca9699c5c75c6b54852f77fe6d15e9cd13039ea4ca37683393021"
}
},
"constraintBumped": "^2.0.0",
@@ -297,7 +297,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "439814f59cbc73e1c28ca5ac6e437d5f2af10dfd18db786ce46fe0663e605ccb"
+ "sha256": "4a8df8c695623e81d90f663801ead4a5269b406599b43b90ad558561a6f09c59"
}
}
}
@@ -312,7 +312,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "2347a7792f73d0f8cc8aa41d4895317bd1745724b8bc77d8c03faf821c9059b7"
+ "sha256": "02b6111db259663d77ff60109d07ccf04e216af6d8d31166f55547e5bed89e21"
}
},
"constraintBumped": "^3.0.1",
@@ -325,7 +325,7 @@
"description": {
"name": "foo",
"url": "http://localhost:$PORT",
- "sha256": "439814f59cbc73e1c28ca5ac6e437d5f2af10dfd18db786ce46fe0663e605ccb"
+ "sha256": "4a8df8c695623e81d90f663801ead4a5269b406599b43b90ad558561a6f09c59"
}
}
},
@@ -338,7 +338,7 @@
"description": {
"name": "bar",
"url": "http://localhost:$PORT",
- "sha256": "b8187621010649d6385788d7630adcd88d6548a7938899b6f18820961df3b879"
+ "sha256": "d8f427cae6af20c3915ea195fc8b17f98a4bb333953d418657d83d9f8fb829d7"
}
},
"constraintBumped": "^2.0.0",
@@ -351,7 +351,7 @@
"description": {
"name": "bar",
"url": "http://localhost:$PORT",
- "sha256": "4de00552ae3719481f5f0e30b82ecb8b14a62907553b217e7ca178e80625329a"
+ "sha256": "8cd4b5a00de63aa592f4240249affd87abf49de4281233870f22b30919f87d42"
}
}
}
@@ -369,7 +369,7 @@
-------------------------------- END OF OUTPUT ---------------------------------
$ cat pubspec.yaml
-{"name":"app","dependencies":{"foo":^3.0.0,"bar":^2.0.0,"baz":"1.0.0"},"environment":{"sdk":">=0.1.2 <1.0.0"}}
+{"name":"app","dependencies":{"foo":^3.0.0,"bar":^2.0.0,"baz":"1.0.0"},"environment":{"sdk":"^3.0.2"}}
$ cat pubspec.lock
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
@@ -378,7 +378,7 @@
dependency: "direct main"
description:
name: bar
- sha256: b8187621010649d6385788d7630adcd88d6548a7938899b6f18820961df3b879
+ sha256: d8f427cae6af20c3915ea195fc8b17f98a4bb333953d418657d83d9f8fb829d7
url: "http://localhost:$PORT"
source: hosted
version: "2.0.0"
@@ -386,7 +386,7 @@
dependency: "direct main"
description:
name: baz
- sha256: "377433f0e0aff092191e57de97f5869cad0dd0779ee6d31e7096b84878ca41e8"
+ sha256: b61dfc82400bc16736afba3958f2c81ff8a5a4b41a31c1b15bdc43a090113cef
url: "http://localhost:$PORT"
source: hosted
version: "1.0.0"
@@ -394,9 +394,9 @@
dependency: "direct main"
description:
name: foo
- sha256: "2347a7792f73d0f8cc8aa41d4895317bd1745724b8bc77d8c03faf821c9059b7"
+ sha256: "02b6111db259663d77ff60109d07ccf04e216af6d8d31166f55547e5bed89e21"
url: "http://localhost:$PORT"
source: hosted
version: "3.0.1"
sdks:
- dart: ">=0.1.2 <1.0.0"
+ dart: ">=3.0.2 <4.0.0"
diff --git a/test/testdata/goldens/deps/executables_test/applies formatting before printing executables.txt b/test/testdata/goldens/deps/executables_test/applies formatting before printing executables.txt
index 4c8b2b9..94e40bd 100644
--- a/test/testdata/goldens/deps/executables_test/applies formatting before printing executables.txt
+++ b/test/testdata/goldens/deps/executables_test/applies formatting before printing executables.txt
@@ -68,7 +68,7 @@
"sdks": [
{
"name": "Dart",
- "version": "0.1.2+3"
+ "version": "3.1.2+3"
}
],
"executables": [
diff --git a/test/testdata/goldens/deps/executables_test/dev dependencies.txt b/test/testdata/goldens/deps/executables_test/dev dependencies.txt
index 8493d62..fe0d91c 100644
--- a/test/testdata/goldens/deps/executables_test/dev dependencies.txt
+++ b/test/testdata/goldens/deps/executables_test/dev dependencies.txt
@@ -49,7 +49,7 @@
"sdks": [
{
"name": "Dart",
- "version": "0.1.2+3"
+ "version": "3.1.2+3"
}
],
"executables": [
diff --git a/test/testdata/goldens/deps/executables_test/lists Dart executables, without entrypoints.txt b/test/testdata/goldens/deps/executables_test/lists Dart executables, without entrypoints.txt
index 3b46fb0..4a9cf40 100644
--- a/test/testdata/goldens/deps/executables_test/lists Dart executables, without entrypoints.txt
+++ b/test/testdata/goldens/deps/executables_test/lists Dart executables, without entrypoints.txt
@@ -39,7 +39,7 @@
"sdks": [
{
"name": "Dart",
- "version": "0.1.2+3"
+ "version": "3.1.2+3"
}
],
"executables": [
diff --git a/test/testdata/goldens/deps/executables_test/lists executables from a dependency.txt b/test/testdata/goldens/deps/executables_test/lists executables from a dependency.txt
index b78f99f..a2e04ea 100644
--- a/test/testdata/goldens/deps/executables_test/lists executables from a dependency.txt
+++ b/test/testdata/goldens/deps/executables_test/lists executables from a dependency.txt
@@ -49,7 +49,7 @@
"sdks": [
{
"name": "Dart",
- "version": "0.1.2+3"
+ "version": "3.1.2+3"
}
],
"executables": [
diff --git a/test/testdata/goldens/deps/executables_test/lists executables only from immediate dependencies.txt b/test/testdata/goldens/deps/executables_test/lists executables only from immediate dependencies.txt
index 5d4cf00..5641ae5 100644
--- a/test/testdata/goldens/deps/executables_test/lists executables only from immediate dependencies.txt
+++ b/test/testdata/goldens/deps/executables_test/lists executables only from immediate dependencies.txt
@@ -62,7 +62,7 @@
"sdks": [
{
"name": "Dart",
- "version": "0.1.2+3"
+ "version": "3.1.2+3"
}
],
"executables": [
diff --git a/test/testdata/goldens/deps/executables_test/overriden dependencies executables.txt b/test/testdata/goldens/deps/executables_test/overriden dependencies executables.txt
index edb3098..4502673 100644
--- a/test/testdata/goldens/deps/executables_test/overriden dependencies executables.txt
+++ b/test/testdata/goldens/deps/executables_test/overriden dependencies executables.txt
@@ -54,7 +54,7 @@
"sdks": [
{
"name": "Dart",
- "version": "0.1.2+3"
+ "version": "3.1.2+3"
}
],
"executables": [
diff --git a/test/testdata/goldens/deps/executables_test/skips executables in sub directories.txt b/test/testdata/goldens/deps/executables_test/skips executables in sub directories.txt
index 514e5ef..ce15a02 100644
--- a/test/testdata/goldens/deps/executables_test/skips executables in sub directories.txt
+++ b/test/testdata/goldens/deps/executables_test/skips executables in sub directories.txt
@@ -40,7 +40,7 @@
"sdks": [
{
"name": "Dart",
- "version": "0.1.2+3"
+ "version": "3.1.2+3"
}
],
"executables": [
diff --git a/test/testdata/goldens/deps/executables_test/skips non-Dart executables.txt b/test/testdata/goldens/deps/executables_test/skips non-Dart executables.txt
index 8cf6076..71c0fc2 100644
--- a/test/testdata/goldens/deps/executables_test/skips non-Dart executables.txt
+++ b/test/testdata/goldens/deps/executables_test/skips non-Dart executables.txt
@@ -37,7 +37,7 @@
"sdks": [
{
"name": "Dart",
- "version": "0.1.2+3"
+ "version": "3.1.2+3"
}
],
"executables": []
diff --git a/test/testdata/goldens/directory_option_test/commands taking a --directory~-C parameter work.txt b/test/testdata/goldens/directory_option_test/commands taking a --directory~-C parameter work.txt
index e133de4..bcd8451 100644
--- a/test/testdata/goldens/directory_option_test/commands taking a --directory~-C parameter work.txt
+++ b/test/testdata/goldens/directory_option_test/commands taking a --directory~-C parameter work.txt
@@ -53,7 +53,7 @@
Resolving dependencies in myapp/example2...
[STDERR] Error on line 1, column 9 of myapp/pubspec.yaml: "name" field doesn't match expected name "myapp".
[STDERR] â•·
-[STDERR] 1 │ {"name":"test_pkg","version":"1.0.0","homepage":"http://pub.dev","description":"A package, I guess.","environment":{"sdk":">=0.1.2 <=0.2.0"}, dependencies: { foo: ^1.0.0}}
+[STDERR] 1 │ {"name":"test_pkg","version":"1.0.0","homepage":"https://pub.dev","description":"A package, I guess.","environment":{"sdk":">=3.1.2 <=3.2.0"}, dependencies: { foo: ^1.0.0}}
[STDERR] │ ^^^^^^^^^^
[STDERR] ╵
[EXIT CODE] 65
@@ -86,8 +86,11 @@
## Section 10
$ pub run -C myapp 'bin/app.dart'
Building package executable...
-Built test_pkg:app.
-Hi
+[STDERR] Failed to build test_pkg:app:
+[STDERR] myapp/bin/app.dart:1:1: Error: The specified language version is too high. The highest supported language version is 3.0.
+[STDERR] main() => print('Hi');
+[STDERR] ^
+[EXIT CODE] 1
-------------------------------- END OF OUTPUT ---------------------------------
@@ -108,15 +111,9 @@
├── lib
│ └── test_pkg.dart (<1 KB)
└── pubspec.yaml (<1 KB)
-[STDERR] Package validation found the following error:
-[STDERR] * Older versions of pub don't support ^ version constraints.
-[STDERR] Make sure your SDK constraint excludes old versions:
-[STDERR]
-[STDERR] environment:
-[STDERR] sdk: "^1.8.0"
-[STDERR] Sorry, your package is missing a requirement and can't be published yet.
-[STDERR] For more information, see: https://dart.dev/tools/pub/cmd/pub-lish.
-[EXIT CODE] 65
+The server may enforce additional checks.
+[STDERR]
+[STDERR] Package has 0 warnings.
-------------------------------- END OF OUTPUT ---------------------------------
@@ -132,7 +129,7 @@
## Section 13
$ pub deps -C myapp
-Dart SDK 0.1.2+3
+Dart SDK 3.1.2+3
test_pkg 1.0.0
└── foo 1.0.0
diff --git a/test/testdata/goldens/embedding/embedding_test/--color forces colors.txt b/test/testdata/goldens/embedding/embedding_test/--color forces colors.txt
index e4ad1d1..ed56eb3 100644
--- a/test/testdata/goldens/embedding/embedding_test/--color forces colors.txt
+++ b/test/testdata/goldens/embedding/embedding_test/--color forces colors.txt
@@ -1,14 +1,14 @@
# GENERATED BY: test/embedding/embedding_test.dart
$ tool/test-bin/pub_command_runner.dart pub --no-color get
-Resolving dependencies...
+Resolving dependencies...
+ foo 1.0.0 (2.0.0 available)
Changed 1 dependency!
-------------------------------- END OF OUTPUT ---------------------------------
$ tool/test-bin/pub_command_runner.dart pub --color get
-Resolving dependencies...
+Resolving dependencies...
[1mfoo[0m 1.0.0 [36m(2.0.0 available)[39m
Got dependencies!
diff --git a/test/testdata/goldens/embedding/embedding_test/logfile is written with --verbose and on unexpected exceptions.txt b/test/testdata/goldens/embedding/embedding_test/logfile is written with --verbose and on unexpected exceptions.txt
index 642f8fd..f8d34c3 100644
--- a/test/testdata/goldens/embedding/embedding_test/logfile is written with --verbose and on unexpected exceptions.txt
+++ b/test/testdata/goldens/embedding/embedding_test/logfile is written with --verbose and on unexpected exceptions.txt
@@ -5,7 +5,7 @@
MSG : + foo 1.0.0
MSG : Changed 1 dependency!
MSG : Logs written to $SANDBOX/cache/log/pub_log.txt.
-[E] FINE: Pub 0.1.2+3
+[E] FINE: Pub 3.1.2+3
[E] SLVR: fact: myapp is 0.0.0
[E] SLVR: derived: myapp
[E] SLVR: fact: myapp depends on foo any
@@ -19,19 +19,19 @@
[E] | X-Pub-Session-ID: $ID
[E] | X-Pub-Environment: test-environment
[E] | X-Pub-Reason: direct
-[E] | user-agent: Dart pub 0.1.2+3
+[E] | user-agent: Dart pub 3.1.2+3
[E] IO : HTTP response 200 OK for GET http://localhost:$PORT/api/packages/foo
[E] | took: $TIME
[E] | x-powered-by: Dart with package:shelf
[E] | date: $TIME
-[E] | content-length: 281
+[E] | content-length: 312
[E] | x-frame-options: SAMEORIGIN
[E] | content-type: application/vnd.pub.v2+json
[E] | x-xss-protection: 1; mode=block
[E] | x-content-type-options: nosniff
[E] IO : Writing $N characters to text file $SANDBOX/cache/hosted/localhost%58$PORT/.cache/foo-versions.json.
[E] FINE: Contents:
-[E] | {"name":"foo","uploaders":["nweiz@google.com"],"versions":[{"pubspec":{"name":"foo","version":"1.0.0"},"version":"1.0.0","archive_url":"http://localhost:$PORT/packages/foo/versions/1.0.0.tar.gz","archive_sha256":"439814f59cbc73e1c28ca5ac6e437d5f2af10dfd18db786ce46fe0663e605ccb"}],"_fetchedAt": "$TIME"}
+[E] | {"name":"foo","uploaders":["nweiz@google.com"],"versions":[{"pubspec":{"name":"foo","version":"1.0.0","environment":{"sdk":"^3.0.0"}},"version":"1.0.0","archive_url":"http://localhost:$PORT/packages/foo/versions/1.0.0.tar.gz","archive_sha256":"4a8df8c695623e81d90f663801ead4a5269b406599b43b90ad558561a6f09c59"}],"_fetchedAt": "$TIME"}
[E] SLVR: selecting foo 1.0.0
[E] SLVR: Version solving took: $TIME
[E] | Tried 1 solutions.
@@ -45,7 +45,7 @@
[E] | X-Pub-Session-ID: $ID
[E] | X-Pub-Environment: test-environment
[E] | X-Pub-Reason: direct
-[E] | user-agent: Dart pub 0.1.2+3
+[E] | user-agent: Dart pub 3.1.2+3
[E] IO : HTTP response 200 OK for GET http://localhost:$PORT/packages/foo/versions/1.0.0.tar.gz
[E] | took: $TIME
[E] | x-powered-by: Dart with package:shelf
@@ -60,7 +60,7 @@
[E] FINE: Computed checksum $CRC32C for foo 1.0.0 with expected CRC32C of $CRC32C.
[E] IO : Writing $N characters to text file $SANDBOX/cache/hosted-hashes/localhost%58$PORT/foo-1.0.0.sha256.
[E] FINE: Contents:
-[E] | 439814f59cbc73e1c28ca5ac6e437d5f2af10dfd18db786ce46fe0663e605ccb
+[E] | 4a8df8c695623e81d90f663801ead4a5269b406599b43b90ad558561a6f09c59
[E] FINE: Created $FILE from stream
[E] IO : Created temp directory $DIR
[E] IO : Reading binary file $FILE.
@@ -96,12 +96,12 @@
[E] | dependency: "direct main"
[E] | description:
[E] | name: foo
-[E] | sha256: "439814f59cbc73e1c28ca5ac6e437d5f2af10dfd18db786ce46fe0663e605ccb"
+[E] | sha256: "4a8df8c695623e81d90f663801ead4a5269b406599b43b90ad558561a6f09c59"
[E] | url: "http://localhost:$PORT"
[E] | source: hosted
[E] | version: "1.0.0"
[E] | sdks:
-[E] | dart: ">=0.1.2 <1.0.0"
+[E] | dart: ">=3.0.2 <4.0.0"
[E] IO : Writing $N characters to text file .dart_tool/package_config.json.
[E] FINE: Contents:
[E] | {
@@ -111,18 +111,18 @@
[E] | "name": "foo",
[E] | "rootUri": "file://$SANDBOX/cache/hosted/localhost%2558$PORT/foo-1.0.0",
[E] | "packageUri": "lib/",
-[E] | "languageVersion": "2.7"
+[E] | "languageVersion": "3.0"
[E] | },
[E] | {
[E] | "name": "myapp",
[E] | "rootUri": "../",
[E] | "packageUri": "lib/",
-[E] | "languageVersion": "0.1"
+[E] | "languageVersion": "3.0"
[E] | }
[E] | ],
[E] | "generated": "$TIME",
[E] | "generator": "pub",
-[E] | "generatorVersion": "0.1.2+3"
+[E] | "generatorVersion": "3.1.2+3"
[E] | }
[E] IO : Writing $N characters to text file $SANDBOX/cache/log/pub_log.txt.
@@ -135,7 +135,7 @@
Before making this file public, make sure to remove any sensitive information!
-Pub version: 0.1.2+3
+Pub version: 3.1.2+3
Created: $TIME
FLUTTER_ROOT: <not set>
PUB_HOSTED_URL: http://localhost:$PORT
@@ -144,7 +144,7 @@
Platform: $OS
---- $SANDBOX/myapp/pubspec.yaml ----
-{"name":"myapp","environment":{"sdk":">=0.1.2 <1.0.0"},"dependencies":{"foo":"any"}}
+{"name":"myapp","dependencies":{"foo":"any"},"environment":{"sdk":"^3.0.2"}}
---- End pubspec.yaml ----
---- $SANDBOX/myapp/pubspec.lock ----
# Generated by pub
@@ -154,16 +154,16 @@
dependency: "direct main"
description:
name: foo
- sha256: "439814f59cbc73e1c28ca5ac6e437d5f2af10dfd18db786ce46fe0663e605ccb"
+ sha256: "4a8df8c695623e81d90f663801ead4a5269b406599b43b90ad558561a6f09c59"
url: "http://localhost:$PORT"
source: hosted
version: "1.0.0"
sdks:
- dart: ">=0.1.2 <1.0.0"
+ dart: ">=3.0.2 <4.0.0"
---- End pubspec.lock ----
---- Log transcript ----
-FINE: Pub 0.1.2+3
+FINE: Pub 3.1.2+3
MSG : Resolving dependencies...
SLVR: fact: myapp is 0.0.0
SLVR: derived: myapp
@@ -178,19 +178,19 @@
| X-Pub-Session-ID: $ID
| X-Pub-Environment: test-environment
| X-Pub-Reason: direct
- | user-agent: Dart pub 0.1.2+3
+ | user-agent: Dart pub 3.1.2+3
IO : HTTP response 200 OK for GET http://localhost:$PORT/api/packages/foo
| took: $TIME
| x-powered-by: Dart with package:shelf
| date: $TIME
- | content-length: 281
+ | content-length: 312
| x-frame-options: SAMEORIGIN
| content-type: application/vnd.pub.v2+json
| x-xss-protection: 1; mode=block
| x-content-type-options: nosniff
IO : Writing $N characters to text file $SANDBOX/cache/hosted/localhost%58$PORT/.cache/foo-versions.json.
FINE: Contents:
- | {"name":"foo","uploaders":["nweiz@google.com"],"versions":[{"pubspec":{"name":"foo","version":"1.0.0"},"version":"1.0.0","archive_url":"http://localhost:$PORT/packages/foo/versions/1.0.0.tar.gz","archive_sha256":"439814f59cbc73e1c28ca5ac6e437d5f2af10dfd18db786ce46fe0663e605ccb"}],"_fetchedAt": "$TIME"}
+ | {"name":"foo","uploaders":["nweiz@google.com"],"versions":[{"pubspec":{"name":"foo","version":"1.0.0","environment":{"sdk":"^3.0.0"}},"version":"1.0.0","archive_url":"http://localhost:$PORT/packages/foo/versions/1.0.0.tar.gz","archive_sha256":"4a8df8c695623e81d90f663801ead4a5269b406599b43b90ad558561a6f09c59"}],"_fetchedAt": "$TIME"}
SLVR: selecting foo 1.0.0
SLVR: Version solving took: $TIME
| Tried 1 solutions.
@@ -204,7 +204,7 @@
| X-Pub-Session-ID: $ID
| X-Pub-Environment: test-environment
| X-Pub-Reason: direct
- | user-agent: Dart pub 0.1.2+3
+ | user-agent: Dart pub 3.1.2+3
IO : HTTP response 200 OK for GET http://localhost:$PORT/packages/foo/versions/1.0.0.tar.gz
| took: $TIME
| x-powered-by: Dart with package:shelf
@@ -219,7 +219,7 @@
FINE: Computed checksum $CRC32C for foo 1.0.0 with expected CRC32C of $CRC32C.
IO : Writing $N characters to text file $SANDBOX/cache/hosted-hashes/localhost%58$PORT/foo-1.0.0.sha256.
FINE: Contents:
- | 439814f59cbc73e1c28ca5ac6e437d5f2af10dfd18db786ce46fe0663e605ccb
+ | 4a8df8c695623e81d90f663801ead4a5269b406599b43b90ad558561a6f09c59
FINE: Created $FILE from stream
IO : Created temp directory $DIR
IO : Reading binary file $FILE.
@@ -257,12 +257,12 @@
| dependency: "direct main"
| description:
| name: foo
- | sha256: "439814f59cbc73e1c28ca5ac6e437d5f2af10dfd18db786ce46fe0663e605ccb"
+ | sha256: "4a8df8c695623e81d90f663801ead4a5269b406599b43b90ad558561a6f09c59"
| url: "http://localhost:$PORT"
| source: hosted
| version: "1.0.0"
| sdks:
- | dart: ">=0.1.2 <1.0.0"
+ | dart: ">=3.0.2 <4.0.0"
IO : Writing $N characters to text file .dart_tool/package_config.json.
FINE: Contents:
| {
@@ -272,18 +272,18 @@
| "name": "foo",
| "rootUri": "file://$SANDBOX/cache/hosted/localhost%2558$PORT/foo-1.0.0",
| "packageUri": "lib/",
- | "languageVersion": "2.7"
+ | "languageVersion": "3.0"
| },
| {
| "name": "myapp",
| "rootUri": "../",
| "packageUri": "lib/",
- | "languageVersion": "0.1"
+ | "languageVersion": "3.0"
| }
| ],
| "generated": "$TIME",
| "generator": "pub",
- | "generatorVersion": "0.1.2+3"
+ | "generatorVersion": "3.1.2+3"
| }
---- End log transcript ----
-------------------------------- END OF OUTPUT ---------------------------------
@@ -298,8 +298,8 @@
[E] package:pub/src/utils.dart $LINE:$COL captureErrors
[E] package:pub/src/command.dart $LINE:$COL PubCommand.run
[E] package:args/command_runner.dart $LINE:$COL CommandRunner.runCommand
-[E] tool/test-bin/pub_command_runner.dart $LINE:$COL Runner.runCommand
-[E] tool/test-bin/pub_command_runner.dart $LINE:$COL Runner.run
+[E] tool/test-bin/pub_command_runner.dart $LINE:$COL Runner.runCommand
+[E] tool/test-bin/pub_command_runner.dart $LINE:$COL Runner.run
[E] tool/test-bin/pub_command_runner.dart $LINE:$COL main
[E] This is an unexpected error. The full log and other details are collected in:
[E]
@@ -317,7 +317,7 @@
Before making this file public, make sure to remove any sensitive information!
-Pub version: 0.1.2+3
+Pub version: 3.1.2+3
Created: $TIME
FLUTTER_ROOT: <not set>
PUB_HOSTED_URL: http://localhost:$PORT
@@ -326,7 +326,7 @@
Platform: $OS
---- Log transcript ----
-FINE: Pub 0.1.2+3
+FINE: Pub 3.1.2+3
ERR : Bad state: Pub has crashed
FINE: Exception type: StateError
ERR : tool/test-bin/pub_command_runner.dart $LINE:$COL ThrowingCommand.runProtected
@@ -337,8 +337,8 @@
| package:pub/src/utils.dart $LINE:$COL captureErrors
| package:pub/src/command.dart $LINE:$COL PubCommand.run
| package:args/command_runner.dart $LINE:$COL CommandRunner.runCommand
- | tool/test-bin/pub_command_runner.dart $LINE:$COL Runner.runCommand
- | tool/test-bin/pub_command_runner.dart $LINE:$COL Runner.run
+ | tool/test-bin/pub_command_runner.dart $LINE:$COL Runner.runCommand
+ | tool/test-bin/pub_command_runner.dart $LINE:$COL Runner.run
| tool/test-bin/pub_command_runner.dart $LINE:$COL main
ERR : This is an unexpected error. The full log and other details are collected in:
|
diff --git a/test/testdata/goldens/embedding/embedding_test/run works, though hidden.txt b/test/testdata/goldens/embedding/embedding_test/run works, though hidden.txt
index 214712a..8eea7f3 100644
--- a/test/testdata/goldens/embedding/embedding_test/run works, though hidden.txt
+++ b/test/testdata/goldens/embedding/embedding_test/run works, though hidden.txt
@@ -1,7 +1,7 @@
# GENERATED BY: test/embedding/embedding_test.dart
$ tool/test-bin/pub_command_runner.dart pub get
-Resolving dependencies...
+Resolving dependencies...
Got dependencies!
-------------------------------- END OF OUTPUT ---------------------------------
diff --git a/test/testdata/goldens/help_test/pub add --help.txt b/test/testdata/goldens/help_test/pub add --help.txt
index ecdabff..c4d7aed 100644
--- a/test/testdata/goldens/help_test/pub add --help.txt
+++ b/test/testdata/goldens/help_test/pub add --help.txt
@@ -14,23 +14,23 @@
For example:
* Add a hosted dependency at newest compatible stable version:
- `$topLevelProgram pub add foo`
+ `dart pub add foo`
* Add a hosted dev dependency at newest compatible stable version:
- `$topLevelProgram pub add dev:foo`
+ `dart pub add dev:foo`
* Add a hosted dependency with the given constraint
- `$topLevelProgram pub add foo:^1.2.3`
+ `dart pub add foo:^1.2.3`
* Add multiple dependencies:
- `$topLevelProgram pub add foo dev:bar`
+ `dart pub add foo dev:bar`
* Add a path dependency:
- `$topLevelProgram pub add 'foo{"path":"../foo"}'`
+ `dart pub add 'foo{"path":"../foo"}'`
* Add a hosted dependency:
- `$topLevelProgram pub add 'foo{"hosted":"my-pub.dev"}'`
+ `dart pub add 'foo{"hosted":"my-pub.dev"}'`
* Add an sdk dependency:
- `$topLevelProgram pub add 'foo{"sdk":"flutter"}'`
+ `dart pub add 'foo{"sdk":"flutter"}'`
* Add a git dependency:
- `$topLevelProgram pub add 'foo{"git":"https://github.com/foo/foo"}'`
+ `dart pub add 'foo{"git":"https://github.com/foo/foo"}'`
* Add a git dependency with a path and ref specified:
- `$topLevelProgram pub add \
+ `dart pub add \
'foo{"git":{"url":"../foo.git","ref":"branch","path":"subdir"}}'`
Usage: pub add [options] [dev:]<package>[:descriptor] [[dev:]<package>[:descriptor]
diff --git a/test/testdata/goldens/help_test/pub global run --help.txt b/test/testdata/goldens/help_test/pub global run --help.txt
index f829064..b2d4cf1 100644
--- a/test/testdata/goldens/help_test/pub global run --help.txt
+++ b/test/testdata/goldens/help_test/pub global run --help.txt
@@ -11,8 +11,6 @@
given experiments enabled. (Will disable
snapshotting, resulting in slower
startup).
- --[no-]sound-null-safety Override the default null safety
- execution mode.
Run "pub help" to see global options.
diff --git a/test/testdata/goldens/help_test/pub outdated --help.txt b/test/testdata/goldens/help_test/pub outdated --help.txt
index d0f6bbe..cf411bb 100644
--- a/test/testdata/goldens/help_test/pub outdated --help.txt
+++ b/test/testdata/goldens/help_test/pub outdated --help.txt
@@ -11,16 +11,10 @@
--[no-]dev-dependencies Take dev dependencies into account.
(defaults to on)
--json Output the results using a json format.
- --mode=<PROPERTY> Highlight versions with PROPERTY.
- Only packages currently missing that PROPERTY
- will be included unless --show-all.
- [outdated (default), null-safety]
--[no-]prereleases Include prereleases in latest version.
- (defaults to on in --mode=null-safety).
--[no-]show-all Include dependencies that are already
fullfilling --mode.
--[no-]transitive Show transitive dependencies.
- (defaults to off in --mode=null-safety).
-C, --directory=<dir> Run this in the directory<dir>.
Run "pub help" to see global options.
diff --git a/test/testdata/goldens/help_test/pub run --help.txt b/test/testdata/goldens/help_test/pub run --help.txt
index f2844f3..5a888e9 100644
--- a/test/testdata/goldens/help_test/pub run --help.txt
+++ b/test/testdata/goldens/help_test/pub run --help.txt
@@ -11,8 +11,6 @@
given experiments enabled.
(Will disable snapshotting, resulting in
slower startup).
- --[no-]sound-null-safety Override the default null safety
- execution mode.
-C, --directory=<dir> Run this in the directory<dir>.
Run "pub help" to see global options.
diff --git a/test/testdata/goldens/help_test/pub upgrade --help.txt b/test/testdata/goldens/help_test/pub upgrade --help.txt
index d1a29b9..d33b3fd 100644
--- a/test/testdata/goldens/help_test/pub upgrade --help.txt
+++ b/test/testdata/goldens/help_test/pub upgrade --help.txt
@@ -10,8 +10,6 @@
-n, --dry-run Report what dependencies would change but don't change
any.
--[no-]precompile Precompile executables in immediate dependencies.
- --null-safety Upgrade constraints in pubspec.yaml to null-safety
- versions
--major-versions Upgrades packages to their latest resolvable versions,
and updates pubspec.yaml.
-C, --directory=<dir> Run this in the directory<dir>.
diff --git a/test/testdata/goldens/outdated/outdated_test/Handles SDK dependencies.txt b/test/testdata/goldens/outdated/outdated_test/Handles SDK dependencies.txt
index 5a9578a..2e675b7 100644
--- a/test/testdata/goldens/outdated/outdated_test/Handles SDK dependencies.txt
+++ b/test/testdata/goldens/outdated/outdated_test/Handles SDK dependencies.txt
@@ -6,6 +6,7 @@
"packages": [
{
"package": "foo",
+ "kind": "direct",
"isDiscontinued": false,
"current": {
"version": "1.1.0"
@@ -128,117 +129,12 @@
-------------------------------- END OF OUTPUT ---------------------------------
## Section 7
-$ pub outdated --no-color --mode=null-safety
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-foo ✗1.1.0 ✗1.1.0 ✓2.0.0 ✓2.0.0
-
-dev_dependencies:
-flutter_test ✗(sdk) ✗(sdk) ✗(sdk) ✗(sdk)
-
-1 dependency is constrained to a version that is older than a resolvable version.
-To update it, edit pubspec.yaml, or run `flutter pub upgrade --null-safety`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 8
-$ pub outdated --no-color --mode=null-safety --transitive
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-foo ✗1.1.0 ✗1.1.0 ✓2.0.0 ✓2.0.0
-
-dev_dependencies:
-flutter_test ✗(sdk) ✗(sdk) ✗(sdk) ✗(sdk)
-
-1 dependency is constrained to a version that is older than a resolvable version.
-To update it, edit pubspec.yaml, or run `flutter pub upgrade --null-safety`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 9
-$ pub outdated --no-color --mode=null-safety --no-prereleases
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-foo ✗1.1.0 ✗1.1.0 ✓2.0.0 ✓2.0.0
-
-dev_dependencies:
-flutter_test ✗(sdk) ✗(sdk) ✗(sdk) ✗(sdk)
-
-1 dependency is constrained to a version that is older than a resolvable version.
-To update it, edit pubspec.yaml, or run `flutter pub upgrade --null-safety`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 10
-$ pub outdated --json --mode=null-safety
-{
- "packages": [
- {
- "package": "flutter_test",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "upgradable": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "resolvable": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "latest": {
- "version": "1.0.0",
- "nullSafety": false
- }
- },
- {
- "package": "foo",
- "isDiscontinued": false,
- "current": {
- "version": "1.1.0",
- "nullSafety": false
- },
- "upgradable": {
- "version": "1.1.0",
- "nullSafety": false
- },
- "resolvable": {
- "version": "2.0.0",
- "nullSafety": true
- },
- "latest": {
- "version": "2.0.0",
- "nullSafety": true
- }
- }
- ]
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 11
$ pub outdated --json --no-dev-dependencies
{
"packages": [
{
"package": "foo",
+ "kind": "direct",
"isDiscontinued": false,
"current": {
"version": "1.1.0"
diff --git a/test/testdata/goldens/outdated/outdated_test/circular dependency on root.txt b/test/testdata/goldens/outdated/outdated_test/circular dependency on root.txt
index c01a007..3b5c001 100644
--- a/test/testdata/goldens/outdated/outdated_test/circular dependency on root.txt
+++ b/test/testdata/goldens/outdated/outdated_test/circular dependency on root.txt
@@ -6,6 +6,7 @@
"packages": [
{
"package": "foo",
+ "kind": "direct",
"isDiscontinued": false,
"current": {
"version": "1.2.3"
@@ -116,88 +117,12 @@
-------------------------------- END OF OUTPUT ---------------------------------
## Section 7
-$ pub outdated --no-color --mode=null-safety
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-foo ✗1.2.3 ✗1.3.0 ✗1.3.0 ✗1.3.0
-
-1 upgradable dependency is locked (in pubspec.lock) to an older version.
-To update it, use `dart pub upgrade`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 8
-$ pub outdated --no-color --mode=null-safety --transitive
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-foo ✗1.2.3 ✗1.3.0 ✗1.3.0 ✗1.3.0
-
-1 upgradable dependency is locked (in pubspec.lock) to an older version.
-To update it, use `dart pub upgrade`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 9
-$ pub outdated --no-color --mode=null-safety --no-prereleases
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-foo ✗1.2.3 ✗1.3.0 ✗1.3.0 ✗1.3.0
-
-1 upgradable dependency is locked (in pubspec.lock) to an older version.
-To update it, use `dart pub upgrade`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 10
-$ pub outdated --json --mode=null-safety
-{
- "packages": [
- {
- "package": "foo",
- "isDiscontinued": false,
- "current": {
- "version": "1.2.3",
- "nullSafety": false
- },
- "upgradable": {
- "version": "1.3.0",
- "nullSafety": false
- },
- "resolvable": {
- "version": "1.3.0",
- "nullSafety": false
- },
- "latest": {
- "version": "1.3.0",
- "nullSafety": false
- }
- }
- ]
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 11
$ pub outdated --json --no-dev-dependencies
{
"packages": [
{
"package": "foo",
+ "kind": "direct",
"isDiscontinued": false,
"current": {
"version": "1.2.3"
diff --git a/test/testdata/goldens/outdated/outdated_test/does not allow arguments - handles bad flags.txt b/test/testdata/goldens/outdated/outdated_test/does not allow arguments - handles bad flags.txt
index e9ae621..10fe350 100644
--- a/test/testdata/goldens/outdated/outdated_test/does not allow arguments - handles bad flags.txt
+++ b/test/testdata/goldens/outdated/outdated_test/does not allow arguments - handles bad flags.txt
@@ -11,16 +11,10 @@
[STDERR] --[no-]dev-dependencies Take dev dependencies into account.
[STDERR] (defaults to on)
[STDERR] --json Output the results using a json format.
-[STDERR] --mode=<PROPERTY> Highlight versions with PROPERTY.
-[STDERR] Only packages currently missing that PROPERTY
-[STDERR] will be included unless --show-all.
-[STDERR] [outdated (default), null-safety]
[STDERR] --[no-]prereleases Include prereleases in latest version.
-[STDERR] (defaults to on in --mode=null-safety).
[STDERR] --[no-]show-all Include dependencies that are already
[STDERR] fullfilling --mode.
[STDERR] --[no-]transitive Show transitive dependencies.
-[STDERR] (defaults to off in --mode=null-safety).
[STDERR] -C, --directory=<dir> Run this in the directory<dir>.
[STDERR]
[STDERR] Run "pub help" to see global options.
@@ -40,16 +34,10 @@
[STDERR] --[no-]dev-dependencies Take dev dependencies into account.
[STDERR] (defaults to on)
[STDERR] --json Output the results using a json format.
-[STDERR] --mode=<PROPERTY> Highlight versions with PROPERTY.
-[STDERR] Only packages currently missing that PROPERTY
-[STDERR] will be included unless --show-all.
-[STDERR] [outdated (default), null-safety]
[STDERR] --[no-]prereleases Include prereleases in latest version.
-[STDERR] (defaults to on in --mode=null-safety).
[STDERR] --[no-]show-all Include dependencies that are already
[STDERR] fullfilling --mode.
[STDERR] --[no-]transitive Show transitive dependencies.
-[STDERR] (defaults to off in --mode=null-safety).
[STDERR] -C, --directory=<dir> Run this in the directory<dir>.
[STDERR]
[STDERR] Run "pub help" to see global options.
diff --git a/test/testdata/goldens/outdated/outdated_test/latest version reported while locked on a prerelease can be a prerelease.txt b/test/testdata/goldens/outdated/outdated_test/latest version reported while locked on a prerelease can be a prerelease.txt
index 92a4ba1..1bd3a68 100644
--- a/test/testdata/goldens/outdated/outdated_test/latest version reported while locked on a prerelease can be a prerelease.txt
+++ b/test/testdata/goldens/outdated/outdated_test/latest version reported while locked on a prerelease can be a prerelease.txt
@@ -6,6 +6,7 @@
"packages": [
{
"package": "foo",
+ "kind": "direct",
"isDiscontinued": false,
"current": {
"version": "1.0.0-dev.1"
@@ -22,6 +23,7 @@
},
{
"package": "mop",
+ "kind": "direct",
"isDiscontinued": false,
"current": {
"version": "0.10.0-dev"
@@ -140,134 +142,12 @@
-------------------------------- END OF OUTPUT ---------------------------------
## Section 7
-$ pub outdated --no-color --mode=null-safety
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar ✗0.9.0 ✗0.9.0 ✗0.9.0 ✗1.0.0-dev.2
-foo ✗1.0.0-dev.1 ✗1.0.0-dev.1 ✗1.0.0-dev.2 ✗1.0.0-dev.2
-mop ✗0.10.0-dev ✗0.10.0-dev ✗0.10.0 ✗1.0.0-dev
-
-2 dependencies are constrained to versions that are older than a resolvable version.
-To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --null-safety`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 8
-$ pub outdated --no-color --mode=null-safety --transitive
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar ✗0.9.0 ✗0.9.0 ✗0.9.0 ✗1.0.0-dev.2
-foo ✗1.0.0-dev.1 ✗1.0.0-dev.1 ✗1.0.0-dev.2 ✗1.0.0-dev.2
-mop ✗0.10.0-dev ✗0.10.0-dev ✗0.10.0 ✗1.0.0-dev
-
-2 dependencies are constrained to versions that are older than a resolvable version.
-To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --null-safety`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 9
-$ pub outdated --no-color --mode=null-safety --no-prereleases
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar ✗0.9.0 ✗0.9.0 ✗0.9.0 ✗0.9.0
-foo ✗1.0.0-dev.1 ✗1.0.0-dev.1 ✗1.0.0-dev.2 ✗1.0.0-dev.2
-mop ✗0.10.0-dev ✗0.10.0-dev ✗0.10.0 ✗0.10.0
-
-2 dependencies are constrained to versions that are older than a resolvable version.
-To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --null-safety`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 10
-$ pub outdated --json --mode=null-safety
-{
- "packages": [
- {
- "package": "bar",
- "isDiscontinued": false,
- "current": {
- "version": "0.9.0",
- "nullSafety": false
- },
- "upgradable": {
- "version": "0.9.0",
- "nullSafety": false
- },
- "resolvable": {
- "version": "0.9.0",
- "nullSafety": false
- },
- "latest": {
- "version": "1.0.0-dev.2",
- "nullSafety": false
- }
- },
- {
- "package": "foo",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0-dev.1",
- "nullSafety": false
- },
- "upgradable": {
- "version": "1.0.0-dev.1",
- "nullSafety": false
- },
- "resolvable": {
- "version": "1.0.0-dev.2",
- "nullSafety": false
- },
- "latest": {
- "version": "1.0.0-dev.2",
- "nullSafety": false
- }
- },
- {
- "package": "mop",
- "isDiscontinued": false,
- "current": {
- "version": "0.10.0-dev",
- "nullSafety": false
- },
- "upgradable": {
- "version": "0.10.0-dev",
- "nullSafety": false
- },
- "resolvable": {
- "version": "0.10.0",
- "nullSafety": false
- },
- "latest": {
- "version": "1.0.0-dev",
- "nullSafety": false
- }
- }
- ]
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 11
$ pub outdated --json --no-dev-dependencies
{
"packages": [
{
"package": "foo",
+ "kind": "direct",
"isDiscontinued": false,
"current": {
"version": "1.0.0-dev.1"
@@ -284,6 +164,7 @@
},
{
"package": "mop",
+ "kind": "direct",
"isDiscontinued": false,
"current": {
"version": "0.10.0-dev"
diff --git a/test/testdata/goldens/outdated/outdated_test/mutually incompatible newer versions.txt b/test/testdata/goldens/outdated/outdated_test/mutually incompatible newer versions.txt
index c8d7e0b..1d8d529 100644
--- a/test/testdata/goldens/outdated/outdated_test/mutually incompatible newer versions.txt
+++ b/test/testdata/goldens/outdated/outdated_test/mutually incompatible newer versions.txt
@@ -6,6 +6,7 @@
"packages": [
{
"package": "bar",
+ "kind": "direct",
"isDiscontinued": false,
"current": {
"version": "1.0.0"
@@ -22,6 +23,7 @@
},
{
"package": "foo",
+ "kind": "direct",
"isDiscontinued": false,
"current": {
"version": "1.0.0"
@@ -132,108 +134,12 @@
-------------------------------- END OF OUTPUT ---------------------------------
## Section 7
-$ pub outdated --no-color --mode=null-safety
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar ✗1.0.0 ✗1.0.0 ✗1.0.0 ✗2.0.0
-foo ✗1.0.0 ✗1.0.0 ✗1.0.0 ✗2.0.0
-You are already using the newest resolvable versions listed in the 'Resolvable' column.
-Newer versions, listed in 'Latest', may not be mutually compatible.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 8
-$ pub outdated --no-color --mode=null-safety --transitive
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar ✗1.0.0 ✗1.0.0 ✗1.0.0 ✗2.0.0
-foo ✗1.0.0 ✗1.0.0 ✗1.0.0 ✗2.0.0
-You are already using the newest resolvable versions listed in the 'Resolvable' column.
-Newer versions, listed in 'Latest', may not be mutually compatible.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 9
-$ pub outdated --no-color --mode=null-safety --no-prereleases
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar ✗1.0.0 ✗1.0.0 ✗1.0.0 ✗2.0.0
-foo ✗1.0.0 ✗1.0.0 ✗1.0.0 ✗2.0.0
-You are already using the newest resolvable versions listed in the 'Resolvable' column.
-Newer versions, listed in 'Latest', may not be mutually compatible.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 10
-$ pub outdated --json --mode=null-safety
-{
- "packages": [
- {
- "package": "bar",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "upgradable": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "resolvable": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "latest": {
- "version": "2.0.0",
- "nullSafety": false
- }
- },
- {
- "package": "foo",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "upgradable": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "resolvable": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "latest": {
- "version": "2.0.0",
- "nullSafety": false
- }
- }
- ]
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 11
$ pub outdated --json --no-dev-dependencies
{
"packages": [
{
"package": "bar",
+ "kind": "direct",
"isDiscontinued": false,
"current": {
"version": "1.0.0"
@@ -250,6 +156,7 @@
},
{
"package": "foo",
+ "kind": "direct",
"isDiscontinued": false,
"current": {
"version": "1.0.0"
diff --git a/test/testdata/goldens/outdated/outdated_test/newer versions available.txt b/test/testdata/goldens/outdated/outdated_test/newer versions available.txt
index 3e71426..7d91029 100644
--- a/test/testdata/goldens/outdated/outdated_test/newer versions available.txt
+++ b/test/testdata/goldens/outdated/outdated_test/newer versions available.txt
@@ -6,6 +6,7 @@
"packages": [
{
"package": "builder",
+ "kind": "dev",
"isDiscontinued": false,
"current": {
"version": "1.2.3"
@@ -22,6 +23,7 @@
},
{
"package": "dev_trans",
+ "kind": "transitive",
"isDiscontinued": false,
"current": {
"version": "1.0.0"
@@ -36,6 +38,7 @@
},
{
"package": "foo",
+ "kind": "direct",
"isDiscontinued": false,
"current": {
"version": "1.2.3"
@@ -52,6 +55,7 @@
},
{
"package": "transitive",
+ "kind": "transitive",
"isDiscontinued": false,
"current": {
"version": "1.2.3"
@@ -68,6 +72,7 @@
},
{
"package": "transitive2",
+ "kind": "transitive",
"isDiscontinued": false,
"current": null,
"upgradable": null,
@@ -80,6 +85,7 @@
},
{
"package": "transitive3",
+ "kind": "transitive",
"isDiscontinued": false,
"current": null,
"upgradable": null,
@@ -108,18 +114,10 @@
dev_dependencies:
builder *1.2.3 *1.3.0 2.0.0 2.0.0
-transitive dependencies:
-transitive *1.2.3 *1.3.0 *1.3.0 2.0.0
-transitive2 - - 1.0.0 1.0.0
-
-transitive dev_dependencies:
-dev_trans *1.0.0 - *1.0.0 2.0.0
-transitive3 - - 1.0.0 1.0.0
-
-3 upgradable dependencies are locked (in pubspec.lock) to older versions.
+2 upgradable dependencies are locked (in pubspec.lock) to older versions.
To update these dependencies, use `dart pub upgrade`.
-3 dependencies are constrained to versions that are older than a resolvable version.
+2 dependencies are constrained to versions that are older than a resolvable version.
To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --major-versions`.
-------------------------------- END OF OUTPUT ---------------------------------
@@ -160,18 +158,10 @@
dev_dependencies:
builder *1.2.3 *1.3.0 2.0.0 2.0.0
-transitive dependencies:
-transitive *1.2.3 *1.3.0 *1.3.0 2.0.0
-transitive2 - - 1.0.0 1.0.0
-
-transitive dev_dependencies:
-dev_trans *1.0.0 - *1.0.0 2.0.0
-transitive3 - - 1.0.0 1.0.0
-
-3 upgradable dependencies are locked (in pubspec.lock) to older versions.
+2 upgradable dependencies are locked (in pubspec.lock) to older versions.
To update these dependencies, use `dart pub upgrade`.
-3 dependencies are constrained to versions that are older than a resolvable version.
+2 dependencies are constrained to versions that are older than a resolvable version.
To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --major-versions`.
-------------------------------- END OF OUTPUT ---------------------------------
@@ -189,18 +179,10 @@
dev_dependencies:
builder *1.2.3 *1.3.0 *2.0.0 3.0.0-alpha
-transitive dependencies:
-transitive *1.2.3 *1.3.0 *1.3.0 2.0.0
-transitive2 - - 1.0.0 1.0.0
-
-transitive dev_dependencies:
-dev_trans *1.0.0 - *1.0.0 2.0.0
-transitive3 - - 1.0.0 1.0.0
-
-3 upgradable dependencies are locked (in pubspec.lock) to older versions.
+2 upgradable dependencies are locked (in pubspec.lock) to older versions.
To update these dependencies, use `dart pub upgrade`.
-3 dependencies are constrained to versions that are older than a resolvable version.
+2 dependencies are constrained to versions that are older than a resolvable version.
To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --major-versions`.
-------------------------------- END OF OUTPUT ---------------------------------
@@ -215,11 +197,8 @@
direct dependencies:
foo *1.2.3 *1.3.0 3.0.0 3.0.0
-transitive dependencies:
-transitive *1.2.3 2.0.0 2.0.0 2.0.0
-
-2 upgradable dependencies are locked (in pubspec.lock) to older versions.
-To update these dependencies, use `dart pub upgrade`.
+1 upgradable dependency is locked (in pubspec.lock) to an older version.
+To update it, use `dart pub upgrade`.
1 dependency is constrained to a version that is older than a resolvable version.
To update it, edit pubspec.yaml, or run `dart pub upgrade --major-versions`.
@@ -239,262 +218,21 @@
dev_dependencies:
builder *1.2.3 *1.3.0 2.0.0 2.0.0
-transitive dependencies:
-transitive *1.2.3 *1.3.0 *1.3.0 2.0.0
-transitive2 - - 1.0.0 1.0.0
-
-transitive dev_dependencies:
-dev_trans *1.0.0 - *1.0.0 2.0.0
-transitive3 - - 1.0.0 1.0.0
-
-3 upgradable dependencies are locked (in pubspec.lock) to older versions.
+2 upgradable dependencies are locked (in pubspec.lock) to older versions.
To update these dependencies, use `dart pub upgrade`.
-3 dependencies are constrained to versions that are older than a resolvable version.
+2 dependencies are constrained to versions that are older than a resolvable version.
To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --major-versions`.
-------------------------------- END OF OUTPUT ---------------------------------
## Section 7
-$ pub outdated --no-color --mode=null-safety
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar ✗1.0.0 ✗1.0.0 ✗1.0.0 ✗1.0.0
-foo ✗1.2.3 ✗1.3.0 ✗2.0.0 ✗3.0.0
-local_package ✗0.0.1 (path) ✗0.0.1 (path) ✗0.0.1 (path) ✗0.0.1 (path)
-
-dev_dependencies:
-builder ✗1.2.3 ✗1.3.0 ✗2.0.0 ✗3.0.0-alpha
-
-2 upgradable dependencies are locked (in pubspec.lock) to older versions.
-To update these dependencies, use `dart pub upgrade`.
-
-2 dependencies are constrained to versions that are older than a resolvable version.
-To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --null-safety`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 8
-$ pub outdated --no-color --mode=null-safety --transitive
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar ✗1.0.0 ✗1.0.0 ✗1.0.0 ✗1.0.0
-foo ✗1.2.3 ✗1.3.0 ✗2.0.0 ✗3.0.0
-local_package ✗0.0.1 (path) ✗0.0.1 (path) ✗0.0.1 (path) ✗0.0.1 (path)
-
-dev_dependencies:
-builder ✗1.2.3 ✗1.3.0 ✗2.0.0 ✗3.0.0-alpha
-
-transitive dependencies:
-transitive ✗1.2.3 ✗1.3.0 ✗1.3.0 ✗2.0.0
-transitive2 - - ✗1.0.0 ✗1.0.0
-
-transitive dev_dependencies:
-dev_trans ✗1.0.0 - ✗1.0.0 ✗2.0.0
-transitive3 - - ✗1.0.0 ✗1.0.0
-
-3 upgradable dependencies are locked (in pubspec.lock) to older versions.
-To update these dependencies, use `dart pub upgrade`.
-
-3 dependencies are constrained to versions that are older than a resolvable version.
-To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --null-safety`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 9
-$ pub outdated --no-color --mode=null-safety --no-prereleases
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar ✗1.0.0 ✗1.0.0 ✗1.0.0 ✗1.0.0
-foo ✗1.2.3 ✗1.3.0 ✗2.0.0 ✗3.0.0
-local_package ✗0.0.1 (path) ✗0.0.1 (path) ✗0.0.1 (path) ✗0.0.1 (path)
-
-dev_dependencies:
-builder ✗1.2.3 ✗1.3.0 ✗2.0.0 ✗2.0.0
-
-2 upgradable dependencies are locked (in pubspec.lock) to older versions.
-To update these dependencies, use `dart pub upgrade`.
-
-2 dependencies are constrained to versions that are older than a resolvable version.
-To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --null-safety`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 10
-$ pub outdated --json --mode=null-safety
-{
- "packages": [
- {
- "package": "bar",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "upgradable": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "resolvable": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "latest": {
- "version": "1.0.0",
- "nullSafety": false
- }
- },
- {
- "package": "builder",
- "isDiscontinued": false,
- "current": {
- "version": "1.2.3",
- "nullSafety": false
- },
- "upgradable": {
- "version": "1.3.0",
- "nullSafety": false
- },
- "resolvable": {
- "version": "2.0.0",
- "nullSafety": false
- },
- "latest": {
- "version": "3.0.0-alpha",
- "nullSafety": false
- }
- },
- {
- "package": "dev_trans",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "upgradable": null,
- "resolvable": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "latest": {
- "version": "2.0.0",
- "nullSafety": false
- }
- },
- {
- "package": "foo",
- "isDiscontinued": false,
- "current": {
- "version": "1.2.3",
- "nullSafety": false
- },
- "upgradable": {
- "version": "1.3.0",
- "nullSafety": false
- },
- "resolvable": {
- "version": "2.0.0",
- "nullSafety": false
- },
- "latest": {
- "version": "3.0.0",
- "nullSafety": false
- }
- },
- {
- "package": "local_package",
- "isDiscontinued": false,
- "current": {
- "version": "0.0.1",
- "nullSafety": false
- },
- "upgradable": {
- "version": "0.0.1",
- "nullSafety": false
- },
- "resolvable": {
- "version": "0.0.1",
- "nullSafety": false
- },
- "latest": {
- "version": "0.0.1",
- "nullSafety": false
- }
- },
- {
- "package": "transitive",
- "isDiscontinued": false,
- "current": {
- "version": "1.2.3",
- "nullSafety": false
- },
- "upgradable": {
- "version": "1.3.0",
- "nullSafety": false
- },
- "resolvable": {
- "version": "1.3.0",
- "nullSafety": false
- },
- "latest": {
- "version": "2.0.0",
- "nullSafety": false
- }
- },
- {
- "package": "transitive2",
- "isDiscontinued": false,
- "current": null,
- "upgradable": null,
- "resolvable": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "latest": {
- "version": "1.0.0",
- "nullSafety": false
- }
- },
- {
- "package": "transitive3",
- "isDiscontinued": false,
- "current": null,
- "upgradable": null,
- "resolvable": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "latest": {
- "version": "1.0.0",
- "nullSafety": false
- }
- }
- ]
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 11
$ pub outdated --json --no-dev-dependencies
{
"packages": [
{
"package": "foo",
+ "kind": "direct",
"isDiscontinued": false,
"current": {
"version": "1.2.3"
@@ -511,6 +249,7 @@
},
{
"package": "transitive",
+ "kind": "transitive",
"isDiscontinued": false,
"current": {
"version": "1.2.3"
diff --git a/test/testdata/goldens/outdated/outdated_test/no dependencies.txt b/test/testdata/goldens/outdated/outdated_test/no dependencies.txt
index d256d7f..c999804 100644
--- a/test/testdata/goldens/outdated/outdated_test/no dependencies.txt
+++ b/test/testdata/goldens/outdated/outdated_test/no dependencies.txt
@@ -63,44 +63,6 @@
-------------------------------- END OF OUTPUT ---------------------------------
## Section 7
-$ pub outdated --no-color --mode=null-safety
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-All your dependencies declare support for null-safety.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 8
-$ pub outdated --no-color --mode=null-safety --transitive
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-All your dependencies declare support for null-safety.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 9
-$ pub outdated --no-color --mode=null-safety --no-prereleases
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-All your dependencies declare support for null-safety.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 10
-$ pub outdated --json --mode=null-safety
-{
- "packages": []
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 11
$ pub outdated --json --no-dev-dependencies
{
"packages": []
diff --git a/test/testdata/goldens/outdated/outdated_test/no lockfile.txt b/test/testdata/goldens/outdated/outdated_test/no lockfile.txt
index 70ce88f..62f8c6c 100644
--- a/test/testdata/goldens/outdated/outdated_test/no lockfile.txt
+++ b/test/testdata/goldens/outdated/outdated_test/no lockfile.txt
@@ -6,6 +6,7 @@
"packages": [
{
"package": "bar",
+ "kind": "direct",
"isDiscontinued": false,
"current": null,
"upgradable": {
@@ -20,6 +21,7 @@
},
{
"package": "foo",
+ "kind": "direct",
"isDiscontinued": false,
"current": null,
"upgradable": {
@@ -152,114 +154,12 @@
-------------------------------- END OF OUTPUT ---------------------------------
## Section 7
-$ pub outdated --no-color --mode=null-safety
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar - ✗1.2.3 ✗2.0.0 ✗2.0.0
-foo - ✗1.2.3 ✗1.2.3 ✗1.2.3
-
-No pubspec.lock found. There are no Current versions.
-Run `dart pub get` to create a pubspec.lock with versions matching your pubspec.yaml.
-
-1 dependency is constrained to a version that is older than a resolvable version.
-To update it, edit pubspec.yaml, or run `dart pub upgrade --null-safety`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 8
-$ pub outdated --no-color --mode=null-safety --transitive
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar - ✗1.2.3 ✗2.0.0 ✗2.0.0
-foo - ✗1.2.3 ✗1.2.3 ✗1.2.3
-
-No pubspec.lock found. There are no Current versions.
-Run `dart pub get` to create a pubspec.lock with versions matching your pubspec.yaml.
-
-1 dependency is constrained to a version that is older than a resolvable version.
-To update it, edit pubspec.yaml, or run `dart pub upgrade --null-safety`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 9
-$ pub outdated --no-color --mode=null-safety --no-prereleases
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar - ✗1.2.3 ✗2.0.0 ✗2.0.0
-foo - ✗1.2.3 ✗1.2.3 ✗1.2.3
-
-No pubspec.lock found. There are no Current versions.
-Run `dart pub get` to create a pubspec.lock with versions matching your pubspec.yaml.
-
-1 dependency is constrained to a version that is older than a resolvable version.
-To update it, edit pubspec.yaml, or run `dart pub upgrade --null-safety`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 10
-$ pub outdated --json --mode=null-safety
-{
- "packages": [
- {
- "package": "bar",
- "isDiscontinued": false,
- "current": null,
- "upgradable": {
- "version": "1.2.3",
- "nullSafety": false
- },
- "resolvable": {
- "version": "2.0.0",
- "nullSafety": false
- },
- "latest": {
- "version": "2.0.0",
- "nullSafety": false
- }
- },
- {
- "package": "foo",
- "isDiscontinued": false,
- "current": null,
- "upgradable": {
- "version": "1.2.3",
- "nullSafety": false
- },
- "resolvable": {
- "version": "1.2.3",
- "nullSafety": false
- },
- "latest": {
- "version": "1.2.3",
- "nullSafety": false
- }
- }
- ]
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 11
$ pub outdated --json --no-dev-dependencies
{
"packages": [
{
"package": "bar",
+ "kind": "direct",
"isDiscontinued": false,
"current": null,
"upgradable": {
@@ -274,6 +174,7 @@
},
{
"package": "foo",
+ "kind": "direct",
"isDiscontinued": false,
"current": null,
"upgradable": {
diff --git a/test/testdata/goldens/outdated/outdated_test/null safety compliance.txt b/test/testdata/goldens/outdated/outdated_test/null safety compliance.txt
deleted file mode 100644
index 507d194..0000000
--- a/test/testdata/goldens/outdated/outdated_test/null safety compliance.txt
+++ /dev/null
@@ -1,430 +0,0 @@
-# GENERATED BY: test/outdated/outdated_test.dart
-
-## Section 0
-$ pub outdated --json
-{
- "packages": [
- {
- "package": "bar",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0"
- },
- "upgradable": {
- "version": "1.0.0"
- },
- "resolvable": {
- "version": "2.0.0"
- },
- "latest": {
- "version": "2.0.0"
- }
- },
- {
- "package": "fails_analysis",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0"
- },
- "upgradable": {
- "version": "1.0.0"
- },
- "resolvable": {
- "version": "2.0.0"
- },
- "latest": {
- "version": "2.0.0"
- }
- },
- {
- "package": "fails_analysis_in_dependency",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0"
- },
- "upgradable": {
- "version": "1.0.0"
- },
- "resolvable": {
- "version": "2.0.0"
- },
- "latest": {
- "version": "2.0.0"
- }
- },
- {
- "package": "file_in_dependency_opts_out",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0"
- },
- "upgradable": {
- "version": "1.0.0"
- },
- "resolvable": {
- "version": "2.0.0"
- },
- "latest": {
- "version": "2.0.0"
- }
- },
- {
- "package": "file_opts_out",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0"
- },
- "upgradable": {
- "version": "1.0.0"
- },
- "resolvable": {
- "version": "2.0.0"
- },
- "latest": {
- "version": "2.0.0"
- }
- },
- {
- "package": "foo",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0"
- },
- "upgradable": {
- "version": "1.0.0"
- },
- "resolvable": {
- "version": "2.0.0-nullsafety.0"
- },
- "latest": {
- "version": "2.0.0"
- }
- }
- ]
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 1
-$ pub outdated --no-color
-Showing outdated packages.
-[*] indicates versions that are not the latest available.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar *1.0.0 *1.0.0 2.0.0 2.0.0
-fails_analysis *1.0.0 *1.0.0 2.0.0 2.0.0
-fails_analysis_in_dependency *1.0.0 *1.0.0 2.0.0 2.0.0
-file_in_dependency_opts_out *1.0.0 *1.0.0 2.0.0 2.0.0
-file_opts_out *1.0.0 *1.0.0 2.0.0 2.0.0
-foo *1.0.0 *1.0.0 *2.0.0-nullsafety.0 2.0.0
-
-6 dependencies are constrained to versions that are older than a resolvable version.
-To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --major-versions`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 2
-$ pub outdated --no-color --no-transitive
-Showing outdated packages.
-[*] indicates versions that are not the latest available.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar *1.0.0 *1.0.0 2.0.0 2.0.0
-fails_analysis *1.0.0 *1.0.0 2.0.0 2.0.0
-fails_analysis_in_dependency *1.0.0 *1.0.0 2.0.0 2.0.0
-file_in_dependency_opts_out *1.0.0 *1.0.0 2.0.0 2.0.0
-file_opts_out *1.0.0 *1.0.0 2.0.0 2.0.0
-foo *1.0.0 *1.0.0 *2.0.0-nullsafety.0 2.0.0
-
-6 dependencies are constrained to versions that are older than a resolvable version.
-To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --major-versions`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 3
-$ pub outdated --no-color --up-to-date
-Showing outdated packages.
-[*] indicates versions that are not the latest available.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar *1.0.0 *1.0.0 2.0.0 2.0.0
-fails_analysis *1.0.0 *1.0.0 2.0.0 2.0.0
-fails_analysis_in_dependency *1.0.0 *1.0.0 2.0.0 2.0.0
-file_in_dependency_opts_out *1.0.0 *1.0.0 2.0.0 2.0.0
-file_opts_out *1.0.0 *1.0.0 2.0.0 2.0.0
-foo *1.0.0 *1.0.0 *2.0.0-nullsafety.0 2.0.0
-
-6 dependencies are constrained to versions that are older than a resolvable version.
-To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --major-versions`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 4
-$ pub outdated --no-color --prereleases
-Showing outdated packages.
-[*] indicates versions that are not the latest available.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar *1.0.0 *1.0.0 2.0.0 2.0.0
-fails_analysis *1.0.0 *1.0.0 2.0.0 2.0.0
-fails_analysis_in_dependency *1.0.0 *1.0.0 2.0.0 2.0.0
-file_in_dependency_opts_out *1.0.0 *1.0.0 2.0.0 2.0.0
-file_opts_out *1.0.0 *1.0.0 2.0.0 2.0.0
-foo *1.0.0 *1.0.0 *2.0.0-nullsafety.0 2.0.0
-
-6 dependencies are constrained to versions that are older than a resolvable version.
-To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --major-versions`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 5
-$ pub outdated --no-color --no-dev-dependencies
-Showing outdated packages.
-[*] indicates versions that are not the latest available.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar *1.0.0 *1.0.0 2.0.0 2.0.0
-fails_analysis *1.0.0 *1.0.0 2.0.0 2.0.0
-fails_analysis_in_dependency *1.0.0 *1.0.0 2.0.0 2.0.0
-file_in_dependency_opts_out *1.0.0 *1.0.0 2.0.0 2.0.0
-file_opts_out *1.0.0 *1.0.0 2.0.0 2.0.0
-foo *1.0.0 *1.0.0 *2.0.0-nullsafety.0 2.0.0
-
-6 dependencies are constrained to versions that are older than a resolvable version.
-To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --major-versions`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 6
-$ pub outdated --no-color --no-dependency-overrides
-Showing outdated packages.
-[*] indicates versions that are not the latest available.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar *1.0.0 *1.0.0 2.0.0 2.0.0
-fails_analysis *1.0.0 *1.0.0 2.0.0 2.0.0
-fails_analysis_in_dependency *1.0.0 *1.0.0 2.0.0 2.0.0
-file_in_dependency_opts_out *1.0.0 *1.0.0 2.0.0 2.0.0
-file_opts_out *1.0.0 *1.0.0 2.0.0 2.0.0
-foo *1.0.0 *1.0.0 *2.0.0-nullsafety.0 2.0.0
-
-6 dependencies are constrained to versions that are older than a resolvable version.
-To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --major-versions`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 7
-$ pub outdated --no-color --mode=null-safety
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar ✗1.0.0 ✗1.0.0 ✓2.0.0 ✓2.0.0
-foo ✗1.0.0 ✗1.0.0 ✓2.0.0-nullsafety.0 ✓2.0.0
-
-2 dependencies are constrained to versions that are older than a resolvable version.
-To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --null-safety`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 8
-$ pub outdated --no-color --mode=null-safety --transitive
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar ✗1.0.0 ✗1.0.0 ✓2.0.0 ✓2.0.0
-foo ✗1.0.0 ✗1.0.0 ✓2.0.0-nullsafety.0 ✓2.0.0
-
-2 dependencies are constrained to versions that are older than a resolvable version.
-To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --null-safety`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 9
-$ pub outdated --no-color --mode=null-safety --no-prereleases
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar ✗1.0.0 ✗1.0.0 ✓2.0.0 ✓2.0.0
-foo ✗1.0.0 ✗1.0.0 ✓2.0.0-nullsafety.0 ✓2.0.0
-
-2 dependencies are constrained to versions that are older than a resolvable version.
-To update these dependencies, edit pubspec.yaml, or run `dart pub upgrade --null-safety`.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 10
-$ pub outdated --json --mode=null-safety
-{
- "packages": [
- {
- "package": "bar",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "upgradable": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "resolvable": {
- "version": "2.0.0",
- "nullSafety": true
- },
- "latest": {
- "version": "2.0.0",
- "nullSafety": true
- }
- },
- {
- "package": "foo",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "upgradable": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "resolvable": {
- "version": "2.0.0-nullsafety.0",
- "nullSafety": true
- },
- "latest": {
- "version": "2.0.0",
- "nullSafety": true
- }
- }
- ]
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 11
-$ pub outdated --json --no-dev-dependencies
-{
- "packages": [
- {
- "package": "bar",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0"
- },
- "upgradable": {
- "version": "1.0.0"
- },
- "resolvable": {
- "version": "2.0.0"
- },
- "latest": {
- "version": "2.0.0"
- }
- },
- {
- "package": "fails_analysis",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0"
- },
- "upgradable": {
- "version": "1.0.0"
- },
- "resolvable": {
- "version": "2.0.0"
- },
- "latest": {
- "version": "2.0.0"
- }
- },
- {
- "package": "fails_analysis_in_dependency",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0"
- },
- "upgradable": {
- "version": "1.0.0"
- },
- "resolvable": {
- "version": "2.0.0"
- },
- "latest": {
- "version": "2.0.0"
- }
- },
- {
- "package": "file_in_dependency_opts_out",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0"
- },
- "upgradable": {
- "version": "1.0.0"
- },
- "resolvable": {
- "version": "2.0.0"
- },
- "latest": {
- "version": "2.0.0"
- }
- },
- {
- "package": "file_opts_out",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0"
- },
- "upgradable": {
- "version": "1.0.0"
- },
- "resolvable": {
- "version": "2.0.0"
- },
- "latest": {
- "version": "2.0.0"
- }
- },
- {
- "package": "foo",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0"
- },
- "upgradable": {
- "version": "1.0.0"
- },
- "resolvable": {
- "version": "2.0.0-nullsafety.0"
- },
- "latest": {
- "version": "2.0.0"
- }
- }
- ]
-}
-
diff --git a/test/testdata/goldens/outdated/outdated_test/null-safety already migrated.txt b/test/testdata/goldens/outdated/outdated_test/null-safety already migrated.txt
deleted file mode 100644
index 5d3cf9b..0000000
--- a/test/testdata/goldens/outdated/outdated_test/null-safety already migrated.txt
+++ /dev/null
@@ -1,158 +0,0 @@
-# GENERATED BY: test/outdated/outdated_test.dart
-
-## Section 0
-$ pub outdated --json
-{
- "packages": []
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 1
-$ pub outdated --no-color
-Showing outdated packages.
-[*] indicates versions that are not the latest available.
-
-Found no outdated packages
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 2
-$ pub outdated --no-color --no-transitive
-Showing outdated packages.
-[*] indicates versions that are not the latest available.
-
-Found no outdated packages
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 3
-$ pub outdated --no-color --up-to-date
-Showing outdated packages.
-[*] indicates versions that are not the latest available.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-foo 2.0.0 2.0.0 2.0.0 2.0.0
-
-dev_dependencies:
-bar 2.0.0 2.0.0 2.0.0 2.0.0
-
-transitive dev_dependencies:
-devTransitive 1.0.0 1.0.0 1.0.0 1.0.0
-You are already using the newest resolvable versions listed in the 'Resolvable' column.
-Newer versions, listed in 'Latest', may not be mutually compatible.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 4
-$ pub outdated --no-color --prereleases
-Showing outdated packages.
-[*] indicates versions that are not the latest available.
-
-Found no outdated packages
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 5
-$ pub outdated --no-color --no-dev-dependencies
-Showing outdated packages.
-[*] indicates versions that are not the latest available.
-
-Found no outdated packages
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 6
-$ pub outdated --no-color --no-dependency-overrides
-Showing outdated packages.
-[*] indicates versions that are not the latest available.
-
-Found no outdated packages
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 7
-$ pub outdated --no-color --mode=null-safety
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies: all support null safety.
-
-dev_dependencies: all support null safety.
-All dependencies opt in to null-safety.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 8
-$ pub outdated --no-color --mode=null-safety --transitive
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies: all support null safety.
-
-dev_dependencies: all support null safety.
-
-transitive dev_dependencies:
-devTransitive ✗1.0.0 ✗1.0.0 ✗1.0.0 ✗1.0.0
-All dependencies opt in to null-safety.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 9
-$ pub outdated --no-color --mode=null-safety --no-prereleases
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies: all support null safety.
-
-dev_dependencies: all support null safety.
-All dependencies opt in to null-safety.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 10
-$ pub outdated --json --mode=null-safety
-{
- "packages": [
- {
- "package": "devTransitive",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "upgradable": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "resolvable": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "latest": {
- "version": "1.0.0",
- "nullSafety": false
- }
- }
- ]
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 11
-$ pub outdated --json --no-dev-dependencies
-{
- "packages": []
-}
-
diff --git a/test/testdata/goldens/outdated/outdated_test/null-safety no resolution.txt b/test/testdata/goldens/outdated/outdated_test/null-safety no resolution.txt
deleted file mode 100644
index bc19cb6..0000000
--- a/test/testdata/goldens/outdated/outdated_test/null-safety no resolution.txt
+++ /dev/null
@@ -1,170 +0,0 @@
-# GENERATED BY: test/outdated/outdated_test.dart
-
-## Section 0
-$ pub outdated --json
-{
- "packages": []
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 1
-$ pub outdated --no-color
-Showing outdated packages.
-[*] indicates versions that are not the latest available.
-
-Found no outdated packages
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 2
-$ pub outdated --no-color --no-transitive
-Showing outdated packages.
-[*] indicates versions that are not the latest available.
-
-Found no outdated packages
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 3
-$ pub outdated --no-color --up-to-date
-Showing outdated packages.
-[*] indicates versions that are not the latest available.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar 1.0.0 1.0.0 1.0.0 1.0.0
-foo 1.0.0 1.0.0 1.0.0 1.0.0
-You are already using the newest resolvable versions listed in the 'Resolvable' column.
-Newer versions, listed in 'Latest', may not be mutually compatible.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 4
-$ pub outdated --no-color --prereleases
-Showing outdated packages.
-[*] indicates versions that are not the latest available.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar *1.0.0 *1.0.0 *1.0.0 2.0.0-nullsafety.0
-foo *1.0.0 *1.0.0 *1.0.0 2.0.0-nullsafety.0
-You are already using the newest resolvable versions listed in the 'Resolvable' column.
-Newer versions, listed in 'Latest', may not be mutually compatible.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 5
-$ pub outdated --no-color --no-dev-dependencies
-Showing outdated packages.
-[*] indicates versions that are not the latest available.
-
-Found no outdated packages
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 6
-$ pub outdated --no-color --no-dependency-overrides
-Showing outdated packages.
-[*] indicates versions that are not the latest available.
-
-Found no outdated packages
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 7
-$ pub outdated --no-color --mode=null-safety
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar ✗1.0.0 ✗1.0.0 - ✓2.0.0-nullsafety.0
-foo ✗1.0.0 ✗1.0.0 - ✓2.0.0-nullsafety.0
-No resolution was found. Try running `dart pub upgrade --null-safety --dry-run` to explore why.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 8
-$ pub outdated --no-color --mode=null-safety --transitive
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar ✗1.0.0 ✗1.0.0 - ✓2.0.0-nullsafety.0
-foo ✗1.0.0 ✗1.0.0 - ✓2.0.0-nullsafety.0
-No resolution was found. Try running `dart pub upgrade --null-safety --dry-run` to explore why.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 9
-$ pub outdated --no-color --mode=null-safety --no-prereleases
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar ✗1.0.0 ✗1.0.0 - ✗1.0.0
-foo ✗1.0.0 ✗1.0.0 - ✗1.0.0
-No resolution was found. Try running `dart pub upgrade --null-safety --dry-run` to explore why.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 10
-$ pub outdated --json --mode=null-safety
-{
- "packages": [
- {
- "package": "bar",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "upgradable": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "resolvable": null,
- "latest": {
- "version": "2.0.0-nullsafety.0",
- "nullSafety": true
- }
- },
- {
- "package": "foo",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "upgradable": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "resolvable": null,
- "latest": {
- "version": "2.0.0-nullsafety.0",
- "nullSafety": true
- }
- }
- ]
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 11
-$ pub outdated --json --no-dev-dependencies
-{
- "packages": []
-}
-
diff --git a/test/testdata/goldens/outdated/outdated_test/overridden dependencies - no resolution.txt b/test/testdata/goldens/outdated/outdated_test/overridden dependencies - no resolution.txt
index 521da52..329641d 100644
--- a/test/testdata/goldens/outdated/outdated_test/overridden dependencies - no resolution.txt
+++ b/test/testdata/goldens/outdated/outdated_test/overridden dependencies - no resolution.txt
@@ -6,6 +6,7 @@
"packages": [
{
"package": "bar",
+ "kind": "direct",
"isDiscontinued": false,
"current": {
"version": "1.0.0",
@@ -25,6 +26,7 @@
},
{
"package": "foo",
+ "kind": "direct",
"isDiscontinued": false,
"current": {
"version": "1.0.0",
@@ -137,114 +139,12 @@
-------------------------------- END OF OUTPUT ---------------------------------
## Section 7
-$ pub outdated --no-color --mode=null-safety
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar ✗1.0.0 (overridden) ✗1.0.0 (overridden) ✗1.0.0 (overridden) ✗2.0.0
-foo ✗1.0.0 (overridden) ✗1.0.0 (overridden) ✗1.0.0 (overridden) ✗2.0.0
-You are already using the newest resolvable versions listed in the 'Resolvable' column.
-Newer versions, listed in 'Latest', may not be mutually compatible.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 8
-$ pub outdated --no-color --mode=null-safety --transitive
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar ✗1.0.0 (overridden) ✗1.0.0 (overridden) ✗1.0.0 (overridden) ✗2.0.0
-foo ✗1.0.0 (overridden) ✗1.0.0 (overridden) ✗1.0.0 (overridden) ✗2.0.0
-You are already using the newest resolvable versions listed in the 'Resolvable' column.
-Newer versions, listed in 'Latest', may not be mutually compatible.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 9
-$ pub outdated --no-color --mode=null-safety --no-prereleases
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar ✗1.0.0 (overridden) ✗1.0.0 (overridden) ✗1.0.0 (overridden) ✗2.0.0
-foo ✗1.0.0 (overridden) ✗1.0.0 (overridden) ✗1.0.0 (overridden) ✗2.0.0
-You are already using the newest resolvable versions listed in the 'Resolvable' column.
-Newer versions, listed in 'Latest', may not be mutually compatible.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 10
-$ pub outdated --json --mode=null-safety
-{
- "packages": [
- {
- "package": "bar",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0",
- "overridden": true,
- "nullSafety": false
- },
- "upgradable": {
- "version": "1.0.0",
- "overridden": true,
- "nullSafety": false
- },
- "resolvable": {
- "version": "1.0.0",
- "overridden": true,
- "nullSafety": false
- },
- "latest": {
- "version": "2.0.0",
- "nullSafety": false
- }
- },
- {
- "package": "foo",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0",
- "overridden": true,
- "nullSafety": false
- },
- "upgradable": {
- "version": "1.0.0",
- "overridden": true,
- "nullSafety": false
- },
- "resolvable": {
- "version": "1.0.0",
- "overridden": true,
- "nullSafety": false
- },
- "latest": {
- "version": "2.0.0",
- "nullSafety": false
- }
- }
- ]
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 11
$ pub outdated --json --no-dev-dependencies
{
"packages": [
{
"package": "bar",
+ "kind": "direct",
"isDiscontinued": false,
"current": {
"version": "1.0.0",
@@ -264,6 +164,7 @@
},
{
"package": "foo",
+ "kind": "direct",
"isDiscontinued": false,
"current": {
"version": "1.0.0",
diff --git a/test/testdata/goldens/outdated/outdated_test/overridden dependencies.txt b/test/testdata/goldens/outdated/outdated_test/overridden dependencies.txt
index a761ce0..54bf561 100644
--- a/test/testdata/goldens/outdated/outdated_test/overridden dependencies.txt
+++ b/test/testdata/goldens/outdated/outdated_test/overridden dependencies.txt
@@ -6,6 +6,7 @@
"packages": [
{
"package": "bar",
+ "kind": "direct",
"isDiscontinued": false,
"current": {
"version": "1.0.1",
@@ -25,6 +26,7 @@
},
{
"package": "baz",
+ "kind": "direct",
"isDiscontinued": false,
"current": {
"version": "2.0.0",
@@ -44,6 +46,7 @@
},
{
"package": "foo",
+ "kind": "direct",
"isDiscontinued": false,
"current": {
"version": "1.0.1",
@@ -167,140 +170,12 @@
-------------------------------- END OF OUTPUT ---------------------------------
## Section 7
-$ pub outdated --no-color --mode=null-safety
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar ✗1.0.1 (overridden) ✗1.0.1 (overridden) ✗1.0.1 (overridden) ✗2.0.0
-baz ✗2.0.0 (overridden) ✗2.0.0 (overridden) ✗2.0.0 (overridden) ✗2.0.0
-foo ✗1.0.1 (overridden) ✗1.0.1 (overridden) ✗1.0.1 (overridden) ✗2.0.0
-You are already using the newest resolvable versions listed in the 'Resolvable' column.
-Newer versions, listed in 'Latest', may not be mutually compatible.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 8
-$ pub outdated --no-color --mode=null-safety --transitive
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar ✗1.0.1 (overridden) ✗1.0.1 (overridden) ✗1.0.1 (overridden) ✗2.0.0
-baz ✗2.0.0 (overridden) ✗2.0.0 (overridden) ✗2.0.0 (overridden) ✗2.0.0
-foo ✗1.0.1 (overridden) ✗1.0.1 (overridden) ✗1.0.1 (overridden) ✗2.0.0
-You are already using the newest resolvable versions listed in the 'Resolvable' column.
-Newer versions, listed in 'Latest', may not be mutually compatible.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 9
-$ pub outdated --no-color --mode=null-safety --no-prereleases
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar ✗1.0.1 (overridden) ✗1.0.1 (overridden) ✗1.0.1 (overridden) ✗2.0.0
-baz ✗2.0.0 (overridden) ✗2.0.0 (overridden) ✗2.0.0 (overridden) ✗2.0.0
-foo ✗1.0.1 (overridden) ✗1.0.1 (overridden) ✗1.0.1 (overridden) ✗2.0.0
-You are already using the newest resolvable versions listed in the 'Resolvable' column.
-Newer versions, listed in 'Latest', may not be mutually compatible.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 10
-$ pub outdated --json --mode=null-safety
-{
- "packages": [
- {
- "package": "bar",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.1",
- "overridden": true,
- "nullSafety": false
- },
- "upgradable": {
- "version": "1.0.1",
- "overridden": true,
- "nullSafety": false
- },
- "resolvable": {
- "version": "1.0.1",
- "overridden": true,
- "nullSafety": false
- },
- "latest": {
- "version": "2.0.0",
- "nullSafety": false
- }
- },
- {
- "package": "baz",
- "isDiscontinued": false,
- "current": {
- "version": "2.0.0",
- "overridden": true,
- "nullSafety": false
- },
- "upgradable": {
- "version": "2.0.0",
- "overridden": true,
- "nullSafety": false
- },
- "resolvable": {
- "version": "2.0.0",
- "overridden": true,
- "nullSafety": false
- },
- "latest": {
- "version": "2.0.0",
- "nullSafety": false
- }
- },
- {
- "package": "foo",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.1",
- "overridden": true,
- "nullSafety": false
- },
- "upgradable": {
- "version": "1.0.1",
- "overridden": true,
- "nullSafety": false
- },
- "resolvable": {
- "version": "1.0.1",
- "overridden": true,
- "nullSafety": false
- },
- "latest": {
- "version": "2.0.0",
- "nullSafety": false
- }
- }
- ]
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 11
$ pub outdated --json --no-dev-dependencies
{
"packages": [
{
"package": "bar",
+ "kind": "direct",
"isDiscontinued": false,
"current": {
"version": "1.0.1",
@@ -320,6 +195,7 @@
},
{
"package": "baz",
+ "kind": "direct",
"isDiscontinued": false,
"current": {
"version": "2.0.0",
@@ -339,6 +215,7 @@
},
{
"package": "foo",
+ "kind": "direct",
"isDiscontinued": false,
"current": {
"version": "1.0.1",
diff --git a/test/testdata/goldens/outdated/outdated_test/show discontinued.txt b/test/testdata/goldens/outdated/outdated_test/show discontinued.txt
index 97e2717..10472a0 100644
--- a/test/testdata/goldens/outdated/outdated_test/show discontinued.txt
+++ b/test/testdata/goldens/outdated/outdated_test/show discontinued.txt
@@ -37,9 +37,6 @@
bar 1.0.0 1.0.0 1.0.0 1.0.0
baz 1.0.0 1.0.0 1.0.0 1.0.0 (discontinued)
foo 1.2.3 1.2.3 1.2.3 1.2.3 (discontinued)
-
-transitive dependencies:
-transitive 1.2.3 1.2.3 1.2.3 1.2.3
You are already using the newest resolvable versions listed in the 'Resolvable' column.
Newer versions, listed in 'Latest', may not be mutually compatible.
@@ -78,164 +75,6 @@
-------------------------------- END OF OUTPUT ---------------------------------
## Section 7
-$ pub outdated --no-color --mode=null-safety
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar ✗1.0.0 ✗1.0.0 ✗1.0.0 ✗1.0.0
-baz ✗1.0.0 ✗1.0.0 ✗1.0.0 ✗1.0.0 (discontinued)
-foo ✗1.2.3 ✗1.2.3 ✗1.2.3 ✗1.2.3 (discontinued)
-You are already using the newest resolvable versions listed in the 'Resolvable' column.
-Newer versions, listed in 'Latest', may not be mutually compatible.
-
-baz
- Package baz has been discontinued, replaced by newbaz.
-foo
- Package foo has been discontinued.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 8
-$ pub outdated --no-color --mode=null-safety --transitive
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar ✗1.0.0 ✗1.0.0 ✗1.0.0 ✗1.0.0
-baz ✗1.0.0 ✗1.0.0 ✗1.0.0 ✗1.0.0 (discontinued)
-foo ✗1.2.3 ✗1.2.3 ✗1.2.3 ✗1.2.3 (discontinued)
-
-transitive dependencies:
-transitive ✗1.2.3 ✗1.2.3 ✗1.2.3 ✗1.2.3
-You are already using the newest resolvable versions listed in the 'Resolvable' column.
-Newer versions, listed in 'Latest', may not be mutually compatible.
-
-baz
- Package baz has been discontinued, replaced by newbaz.
-foo
- Package foo has been discontinued.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 9
-$ pub outdated --no-color --mode=null-safety --no-prereleases
-Showing dependencies that are currently not opted in to null-safety.
-[✗] indicates versions without null safety support.
-[✓] indicates versions opting in to null safety.
-
-Package Name Current Upgradable Resolvable Latest
-
-direct dependencies:
-bar ✗1.0.0 ✗1.0.0 ✗1.0.0 ✗1.0.0
-baz ✗1.0.0 ✗1.0.0 ✗1.0.0 ✗1.0.0 (discontinued)
-foo ✗1.2.3 ✗1.2.3 ✗1.2.3 ✗1.2.3 (discontinued)
-You are already using the newest resolvable versions listed in the 'Resolvable' column.
-Newer versions, listed in 'Latest', may not be mutually compatible.
-
-baz
- Package baz has been discontinued, replaced by newbaz.
-foo
- Package foo has been discontinued.
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 10
-$ pub outdated --json --mode=null-safety
-{
- "packages": [
- {
- "package": "bar",
- "isDiscontinued": false,
- "current": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "upgradable": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "resolvable": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "latest": {
- "version": "1.0.0",
- "nullSafety": false
- }
- },
- {
- "package": "baz",
- "isDiscontinued": true,
- "current": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "upgradable": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "resolvable": {
- "version": "1.0.0",
- "nullSafety": false
- },
- "latest": {
- "version": "1.0.0",
- "nullSafety": false
- }
- },
- {
- "package": "foo",
- "isDiscontinued": true,
- "current": {
- "version": "1.2.3",
- "nullSafety": false
- },
- "upgradable": {
- "version": "1.2.3",
- "nullSafety": false
- },
- "resolvable": {
- "version": "1.2.3",
- "nullSafety": false
- },
- "latest": {
- "version": "1.2.3",
- "nullSafety": false
- }
- },
- {
- "package": "transitive",
- "isDiscontinued": false,
- "current": {
- "version": "1.2.3",
- "nullSafety": false
- },
- "upgradable": {
- "version": "1.2.3",
- "nullSafety": false
- },
- "resolvable": {
- "version": "1.2.3",
- "nullSafety": false
- },
- "latest": {
- "version": "1.2.3",
- "nullSafety": false
- }
- }
- ]
-}
-
--------------------------------- END OF OUTPUT ---------------------------------
-
-## Section 11
$ pub outdated --json --no-dev-dependencies
{
"packages": []
diff --git a/test/testdata/goldens/upgrade/example_warns_about_major_versions_test/pub upgrade --null-safety does not update null-safety of dependencies in example~.txt b/test/testdata/goldens/upgrade/example_warns_about_major_versions_test/pub upgrade --null-safety does not update null-safety of dependencies in example~.txt
index cabc0be..32970c8 100644
--- a/test/testdata/goldens/upgrade/example_warns_about_major_versions_test/pub upgrade --null-safety does not update null-safety of dependencies in example~.txt
+++ b/test/testdata/goldens/upgrade/example_warns_about_major_versions_test/pub upgrade --null-safety does not update null-safety of dependencies in example~.txt
@@ -2,27 +2,15 @@
## Section 0
$ pub upgrade --null-safety --example
-Resolving dependencies...
-+ bar 2.0.0
-Changed 1 dependency!
-
-Changed 1 constraint in pubspec.yaml:
- bar: ^1.0.0 -> ^2.0.0
-Resolving dependencies in ./example...
-Got dependencies in ./example.
-[STDERR] Running `upgrade --null-safety` only in `.`. Run `dart pub upgrade --null-safety --directory example/` separately.
+[STDERR] The `--null-safety` flag is no longer supported.
+[STDERR] Consider using the Dart 2.19 sdk to migrate to null safety.
+[EXIT CODE] 65
-------------------------------- END OF OUTPUT ---------------------------------
## Section 1
$ pub upgrade --null-safety --directory example
-Resolving dependencies in example...
-> bar 2.0.0 (was 1.0.0)
-> foo 2.0.0 (was 1.0.0)
- myapp 0.0.0 from path .
-Changed 2 dependencies in example!
-
-Changed 2 constraints in pubspec.yaml:
- foo: ^1.0.0 -> ^2.0.0
- bar: ^1.0.0 -> ^2.0.0
+[STDERR] The `--null-safety` flag is no longer supported.
+[STDERR] Consider using the Dart 2.19 sdk to migrate to null safety.
+[EXIT CODE] 65
diff --git a/test/token/add_token_test.dart b/test/token/add_token_test.dart
index 3fa0d7f..dd5d690 100644
--- a/test/token/add_token_test.dart
+++ b/test/token/add_token_test.dart
@@ -156,7 +156,8 @@
args: ['token', 'add', 'https://pub.dartlang.org'],
input: ['auth-token'],
silent: contains(
- 'Using https://pub.dev instead of https://pub.dartlang.org.'),
+ 'Using https://pub.dev instead of https://pub.dartlang.org.',
+ ),
);
await d.tokensFile({
diff --git a/test/token/error_message_test.dart b/test/token/error_message_test.dart
index 53431a5..0ccce60 100644
--- a/test/token/error_message_test.dart
+++ b/test/token/error_message_test.dart
@@ -55,10 +55,12 @@
var message = List.generate(2048, (_) => 'a').join();
respondWithWwwAuthenticate('bearer realm="pub", message="$message"');
- await expectPubErrorMessage(allOf(
- isNot(contains(message)),
- contains(message.substring(0, 1024)),
- ));
+ await expectPubErrorMessage(
+ allOf(
+ isNot(contains(message)),
+ contains(message.substring(0, 1024)),
+ ),
+ );
});
test('does not prints message if realm is not equals to pub', () async {
diff --git a/test/unknown_source_test.dart b/test/unknown_source_test.dart
index 37591d0..c22b956 100644
--- a/test/unknown_source_test.dart
+++ b/test/unknown_source_test.dart
@@ -12,14 +12,19 @@
void main() {
forBothPubGetAndUpgrade((command) {
test('fails gracefully on a dependency from an unknown source', () async {
- await d.appDir({
- 'foo': {'bad': 'foo'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'bad': 'foo'}
+ },
+ ).create();
- await pubCommand(command, error: equalsIgnoringWhitespace('''
+ await pubCommand(
+ command,
+ error: equalsIgnoringWhitespace('''
Because myapp depends on foo from unknown source "bad", version solving
failed.
- '''));
+ '''),
+ );
});
test(
@@ -27,20 +32,29 @@
'source', () async {
await d.dir('foo', [
d.libDir('foo', 'foo 0.0.1'),
- d.libPubspec('foo', '0.0.1', deps: {
- 'bar': {'bad': 'bar'}
- })
+ d.libPubspec(
+ 'foo',
+ '0.0.1',
+ deps: {
+ 'bar': {'bad': 'bar'}
+ },
+ )
]).create();
- await d.appDir({
- 'foo': {'path': '../foo'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'path': '../foo'}
+ },
+ ).create();
- await pubCommand(command, error: equalsIgnoringWhitespace('''
+ await pubCommand(
+ command,
+ error: equalsIgnoringWhitespace('''
Because every version of foo from path depends on bar from unknown
source "bad", foo from path is forbidden.
So, because myapp depends on foo from path, version solving failed.
- '''));
+ '''),
+ );
});
test('ignores unknown source in lockfile', () async {
@@ -49,24 +63,27 @@
// Depend on "foo" from a valid source.
await d.dir(appPath, [
- d.appPubspec({
- 'foo': {'path': '../foo'}
- })
+ d.appPubspec(
+ dependencies: {
+ 'foo': {'path': '../foo'}
+ },
+ )
]).create();
// But lock it to a bad one.
await d.dir(appPath, [
d.file(
- 'pubspec.lock',
- jsonEncode({
- 'packages': {
- 'foo': {
- 'version': '0.0.0',
- 'source': 'bad',
- 'description': {'name': 'foo'}
- }
+ 'pubspec.lock',
+ jsonEncode({
+ 'packages': {
+ 'foo': {
+ 'version': '0.0.0',
+ 'source': 'bad',
+ 'description': {'name': 'foo'}
}
- }))
+ }
+ }),
+ )
]).create();
await pubCommand(command);
diff --git a/test/upgrade/dry_run_does_not_apply_changes_test.dart b/test/upgrade/dry_run_does_not_apply_changes_test.dart
index 4f514f9..ff3659c 100644
--- a/test/upgrade/dry_run_does_not_apply_changes_test.dart
+++ b/test/upgrade/dry_run_does_not_apply_changes_test.dart
@@ -16,7 +16,7 @@
..serve('foo', '2.0.0');
// Create the first lockfile.
- await d.appDir({'foo': '1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '1.0.0'}).create();
await pubGet();
@@ -26,7 +26,7 @@
]).validate();
// Change the pubspec.
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
// Also delete the ".dart_tool" directory.
deleteEntry(path.join(d.sandbox, appPath, '.dart_tool'));
@@ -53,7 +53,7 @@
..serve('foo', '1.0.0')
..serve('foo', '2.0.0');
- await d.appDir({'foo': '^1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '^1.0.0'}).create();
await pubGet();
@@ -80,7 +80,7 @@
await d.dir(appPath, [
// The pubspec should not be modified.
- d.appPubspec({'foo': '^1.0.0'}),
+ d.appPubspec(dependencies: {'foo': '^1.0.0'}),
// The lockfile should not be modified.
d.file('pubspec.lock', contains('1.0.0')),
// The ".dart_tool" directory should not have been regenerated.
@@ -100,7 +100,7 @@
);
await d.dir(appPath, [
- d.appPubspec({'foo': '^2.0.0'}),
+ d.appPubspec(dependencies: {'foo': '^2.0.0'}),
d.file('pubspec.lock', contains('2.0.0')),
d.dir('.dart_tool')
]).validate();
diff --git a/test/upgrade/example_warns_about_major_versions_test.dart b/test/upgrade/example_warns_about_major_versions_test.dart
index b5c9a67..7c38dee 100644
--- a/test/upgrade/example_warns_about_major_versions_test.dart
+++ b/test/upgrade/example_warns_about_major_versions_test.dart
@@ -40,18 +40,34 @@
'pub upgrade --null-safety does not update null-safety of dependencies in example/',
(ctx) async {
await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'environment': {'sdk': '>=2.7.0 <3.0.0'},
- })
- ..serve('foo', '2.0.0', pubspec: {
- 'environment': {'sdk': '>=2.12.0 <3.0.0'},
- })
- ..serve('bar', '1.0.0', pubspec: {
- 'environment': {'sdk': '>=2.7.0 <3.0.0'},
- })
- ..serve('bar', '2.0.0', pubspec: {
- 'environment': {'sdk': '>=2.12.0 <3.0.0'},
- });
+ ..serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'environment': {'sdk': '>=2.7.0 <3.0.0'},
+ },
+ )
+ ..serve(
+ 'foo',
+ '2.0.0',
+ pubspec: {
+ 'environment': {'sdk': '>=2.12.0 <3.0.0'},
+ },
+ )
+ ..serve(
+ 'bar',
+ '1.0.0',
+ pubspec: {
+ 'environment': {'sdk': '>=2.7.0 <3.0.0'},
+ },
+ )
+ ..serve(
+ 'bar',
+ '2.0.0',
+ pubspec: {
+ 'environment': {'sdk': '>=2.12.0 <3.0.0'},
+ },
+ );
await d.dir(appPath, [
d.pubspec({
'name': 'myapp',
diff --git a/test/upgrade/git/do_not_upgrade_if_unneeded_test.dart b/test/upgrade/git/do_not_upgrade_if_unneeded_test.dart
index 5638fb9..be55dea 100644
--- a/test/upgrade/git/do_not_upgrade_if_unneeded_test.dart
+++ b/test/upgrade/git/do_not_upgrade_if_unneeded_test.dart
@@ -16,21 +16,29 @@
await d.git('foo.git', [
d.libDir('foo'),
- d.libPubspec('foo', '1.0.0', deps: {
- 'foo_dep': {
- 'git': p
- .toUri(p.absolute(d.sandbox, appPath, '../foo_dep.git'))
- .toString()
- }
- })
+ d.libPubspec(
+ 'foo',
+ '1.0.0',
+ deps: {
+ 'foo_dep': {
+ 'git': p
+ .toUri(p.absolute(d.sandbox, appPath, '../foo_dep.git'))
+ .toString()
+ }
+ },
+ )
]).create();
- await d.git('foo_dep.git',
- [d.libDir('foo_dep'), d.libPubspec('foo_dep', '1.0.0')]).create();
+ await d.git(
+ 'foo_dep.git',
+ [d.libDir('foo_dep'), d.libPubspec('foo_dep', '1.0.0')],
+ ).create();
- await d.appDir({
- 'foo': {'git': '../foo.git'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'git': '../foo.git'}
+ },
+ ).create();
await pubGet();
@@ -49,13 +57,17 @@
await d.git('foo.git', [
d.libDir('foo', 'foo 2'),
- d.libPubspec('foo', '1.0.0', deps: {
- 'foo_dep': {
- 'git': p
- .toUri(p.absolute(d.sandbox, appPath, '../foo_dep.git'))
- .toString()
- }
- })
+ d.libPubspec(
+ 'foo',
+ '1.0.0',
+ deps: {
+ 'foo_dep': {
+ 'git': p
+ .toUri(p.absolute(d.sandbox, appPath, '../foo_dep.git'))
+ .toString()
+ }
+ },
+ )
]).create();
await d.git('foo_dep.git', [
diff --git a/test/upgrade/git/upgrade_locked_test.dart b/test/upgrade/git/upgrade_locked_test.dart
index a8e744f..5a1755e 100644
--- a/test/upgrade/git/upgrade_locked_test.dart
+++ b/test/upgrade/git/upgrade_locked_test.dart
@@ -12,22 +12,30 @@
ensureGit();
await d.git(
- 'foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
await d.git(
- 'bar.git', [d.libDir('bar'), d.libPubspec('bar', '1.0.0')]).create();
+ 'bar.git',
+ [d.libDir('bar'), d.libPubspec('bar', '1.0.0')],
+ ).create();
- await d.appDir({
- 'foo': {'git': '../foo.git'},
- 'bar': {'git': '../bar.git'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'git': '../foo.git'},
+ 'bar': {'git': '../bar.git'}
+ },
+ ).create();
await pubGet();
await d.dir(cachePath, [
d.dir('git', [
- d.dir('cache',
- [d.gitPackageRepoCacheDir('foo'), d.gitPackageRepoCacheDir('bar')]),
+ d.dir(
+ 'cache',
+ [d.gitPackageRepoCacheDir('foo'), d.gitPackageRepoCacheDir('bar')],
+ ),
d.gitPackageRevisionCacheDir('foo'),
d.gitPackageRevisionCacheDir('bar'),
])
@@ -36,11 +44,15 @@
var originalFooSpec = packageSpec('foo');
var originalBarSpec = packageSpec('bar');
- await d.git('foo.git',
- [d.libDir('foo', 'foo 2'), d.libPubspec('foo', '1.0.0')]).commit();
+ await d.git(
+ 'foo.git',
+ [d.libDir('foo', 'foo 2'), d.libPubspec('foo', '1.0.0')],
+ ).commit();
- await d.git('bar.git',
- [d.libDir('bar', 'bar 2'), d.libPubspec('bar', '1.0.0')]).commit();
+ await d.git(
+ 'bar.git',
+ [d.libDir('bar', 'bar 2'), d.libPubspec('bar', '1.0.0')],
+ ).commit();
await pubUpgrade();
diff --git a/test/upgrade/git/upgrade_one_locked_test.dart b/test/upgrade/git/upgrade_one_locked_test.dart
index 5c41fa6..3326000 100644
--- a/test/upgrade/git/upgrade_one_locked_test.dart
+++ b/test/upgrade/git/upgrade_one_locked_test.dart
@@ -12,22 +12,30 @@
ensureGit();
await d.git(
- 'foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
await d.git(
- 'bar.git', [d.libDir('bar'), d.libPubspec('bar', '1.0.0')]).create();
+ 'bar.git',
+ [d.libDir('bar'), d.libPubspec('bar', '1.0.0')],
+ ).create();
- await d.appDir({
- 'foo': {'git': '../foo.git'},
- 'bar': {'git': '../bar.git'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'git': '../foo.git'},
+ 'bar': {'git': '../bar.git'}
+ },
+ ).create();
await pubGet();
await d.dir(cachePath, [
d.dir('git', [
- d.dir('cache',
- [d.gitPackageRepoCacheDir('foo'), d.gitPackageRepoCacheDir('bar')]),
+ d.dir(
+ 'cache',
+ [d.gitPackageRepoCacheDir('foo'), d.gitPackageRepoCacheDir('bar')],
+ ),
d.gitPackageRevisionCacheDir('foo'),
d.gitPackageRevisionCacheDir('bar'),
])
@@ -35,11 +43,15 @@
var originalBarSpec = packageSpec('bar');
- await d.git('foo.git',
- [d.libDir('foo', 'foo 2'), d.libPubspec('foo', '1.0.0')]).commit();
+ await d.git(
+ 'foo.git',
+ [d.libDir('foo', 'foo 2'), d.libPubspec('foo', '1.0.0')],
+ ).commit();
- await d.git('bar.git',
- [d.libDir('bar', 'bar 2'), d.libPubspec('bar', '1.0.0')]).commit();
+ await d.git(
+ 'bar.git',
+ [d.libDir('bar', 'bar 2'), d.libPubspec('bar', '1.0.0')],
+ ).commit();
await pubUpgrade(args: ['foo']);
diff --git a/test/upgrade/git/upgrade_to_incompatible_pubspec_test.dart b/test/upgrade/git/upgrade_to_incompatible_pubspec_test.dart
index e74a11e..d8c5fdc 100644
--- a/test/upgrade/git/upgrade_to_incompatible_pubspec_test.dart
+++ b/test/upgrade/git/upgrade_to_incompatible_pubspec_test.dart
@@ -13,11 +13,15 @@
ensureGit();
await d.git(
- 'foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]).create();
+ 'foo.git',
+ [d.libDir('foo'), d.libPubspec('foo', '1.0.0')],
+ ).create();
- await d.appDir({
- 'foo': {'git': '../foo.git'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'git': '../foo.git'}
+ },
+ ).create();
await pubGet();
@@ -33,11 +37,14 @@
var originalFooSpec = packageSpec('foo');
await d.git(
- 'foo.git', [d.libDir('zoo'), d.libPubspec('zoo', '1.0.0')]).commit();
+ 'foo.git',
+ [d.libDir('zoo'), d.libPubspec('zoo', '1.0.0')],
+ ).commit();
await pubUpgrade(
- error: contains('"name" field doesn\'t match expected name "foo".'),
- exitCode: exit_codes.DATA);
+ error: contains('"name" field doesn\'t match expected name "foo".'),
+ exitCode: exit_codes.DATA,
+ );
expect(packageSpec('foo'), originalFooSpec);
});
diff --git a/test/upgrade/git/upgrade_to_nonexistent_pubspec_test.dart b/test/upgrade/git/upgrade_to_nonexistent_pubspec_test.dart
index ae865eb..3a40233 100644
--- a/test/upgrade/git/upgrade_to_nonexistent_pubspec_test.dart
+++ b/test/upgrade/git/upgrade_to_nonexistent_pubspec_test.dart
@@ -15,9 +15,11 @@
d.git('foo.git', [d.libDir('foo'), d.libPubspec('foo', '1.0.0')]);
await repo.create();
- await d.appDir({
- 'foo': {'git': '../foo.git'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'git': '../foo.git'}
+ },
+ ).create();
await pubGet();
@@ -27,8 +29,9 @@
await repo.runGit(['commit', '-m', 'delete']);
await pubUpgrade(
- error: RegExp(r'Could not find a file named "pubspec.yaml" '
- r'in [^\n]*\.'));
+ error: RegExp(r'Could not find a file named "pubspec.yaml" '
+ r'in [^\n]*\.'),
+ );
expect(packageSpec('foo'), originalFooSpec);
});
diff --git a/test/upgrade/hosted/unlock_if_necessary_test.dart b/test/upgrade/hosted/unlock_if_necessary_test.dart
index 2707100..37ed5ec 100644
--- a/test/upgrade/hosted/unlock_if_necessary_test.dart
+++ b/test/upgrade/hosted/unlock_if_necessary_test.dart
@@ -16,7 +16,7 @@
server.serve('foo', '1.0.0', deps: {'foo_dep': 'any'});
server.serve('foo_dep', '1.0.0');
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await pubGet();
diff --git a/test/upgrade/hosted/unlock_single_package_test.dart b/test/upgrade/hosted/unlock_single_package_test.dart
index e443a6a..f95170f 100644
--- a/test/upgrade/hosted/unlock_single_package_test.dart
+++ b/test/upgrade/hosted/unlock_single_package_test.dart
@@ -14,7 +14,7 @@
server.serve('foo', '1.0.0', deps: {'bar': '<2.0.0'});
server.serve('bar', '1.0.0');
- await d.appDir({'foo': 'any', 'bar': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any', 'bar': 'any'}).create();
await pubGet();
diff --git a/test/upgrade/hosted/upgrade_removed_constraints_test.dart b/test/upgrade/hosted/upgrade_removed_constraints_test.dart
index cf72c07..c5fd70e 100644
--- a/test/upgrade/hosted/upgrade_removed_constraints_test.dart
+++ b/test/upgrade/hosted/upgrade_removed_constraints_test.dart
@@ -15,7 +15,7 @@
..serve('shared_dep', '1.0.0')
..serve('shared_dep', '2.0.0');
- await d.appDir({'foo': 'any', 'bar': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any', 'bar': 'any'}).create();
await pubUpgrade();
@@ -25,7 +25,7 @@
d.packageConfigEntry(name: 'shared_dep', version: '1.0.0'),
]).validate();
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await pubUpgrade();
diff --git a/test/upgrade/hosted/warn_about_discontinued_test.dart b/test/upgrade/hosted/warn_about_discontinued_test.dart
index ba7fc57..29f72d1 100644
--- a/test/upgrade/hosted/warn_about_discontinued_test.dart
+++ b/test/upgrade/hosted/warn_about_discontinued_test.dart
@@ -12,29 +12,33 @@
final server = await servePackages()
..serve('foo', '1.2.3', deps: {'transitive': 'any'})
..serve('transitive', '1.0.0');
- await d.appDir({'foo': '1.2.3'}).create();
+ await d.appDir(dependencies: {'foo': '1.2.3'}).create();
await pubGet();
server
..discontinue('foo')
..discontinue('transitive');
// We warn only about the direct dependency here:
- await pubUpgrade(output: '''
+ await pubUpgrade(
+ output: '''
Resolving dependencies...
foo 1.2.3 (discontinued)
transitive 1.0.0
No dependencies changed.
1 package is discontinued.
-''');
+''',
+ );
server.discontinue('foo', replacementText: 'bar');
// We warn only about the direct dependency here:
- await pubUpgrade(output: '''
+ await pubUpgrade(
+ output: '''
Resolving dependencies...
foo 1.2.3 (discontinued replaced by bar)
transitive 1.0.0
No dependencies changed.
1 package is discontinued.
-''');
+''',
+ );
});
test('Warns about discontinued dev_dependencies', () async {
@@ -50,7 +54,7 @@
dev_dependencies:
foo: 1.2.3
environment:
- sdk: '>=0.1.2 <1.0.0'
+ sdk: '^3.1.2'
''')
]).create();
await pubGet();
@@ -60,21 +64,25 @@
..discontinue('transitive');
// We warn only about the direct dependency here:
- await pubUpgrade(output: '''
+ await pubUpgrade(
+ output: '''
Resolving dependencies...
foo 1.2.3 (discontinued)
transitive 1.0.0
No dependencies changed.
1 package is discontinued.
-''');
+''',
+ );
server.discontinue('foo', replacementText: 'bar');
// We warn only about the direct dependency here:
- await pubUpgrade(output: '''
+ await pubUpgrade(
+ output: '''
Resolving dependencies...
foo 1.2.3 (discontinued replaced by bar)
transitive 1.0.0
No dependencies changed.
1 package is discontinued.
-''');
+''',
+ );
});
}
diff --git a/test/upgrade/report/describes_change_test.dart b/test/upgrade/report/describes_change_test.dart
index 2f92618..dbc480c 100644
--- a/test/upgrade/report/describes_change_test.dart
+++ b/test/upgrade/report/describes_change_test.dart
@@ -17,7 +17,7 @@
server.discontinue('foo');
// Create the first lockfile.
- await d.appDir({'foo': '2.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '2.0.0'}).create();
await pubGet();
@@ -62,15 +62,17 @@
]).create();
// Create the first lockfile.
- await d.appDir({
- 'unchanged': 'any',
- 'contents_changed': '1.0.0',
- 'version_upgraded': '1.0.0',
- 'version_downgraded': '2.0.0',
- 'source_changed': 'any',
- 'package_removed': 'any',
- 'description_changed': {'path': '../description_changed_1'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'unchanged': 'any',
+ 'contents_changed': '1.0.0',
+ 'version_upgraded': '1.0.0',
+ 'version_downgraded': '2.0.0',
+ 'source_changed': 'any',
+ 'package_removed': 'any',
+ 'description_changed': {'path': '../description_changed_1'}
+ },
+ ).create();
await pubGet();
server.serve(
@@ -80,31 +82,36 @@
);
// Change the pubspec.
- await d.appDir({
- 'unchanged': 'any',
- 'version_upgraded': 'any',
- 'version_downgraded': '1.0.0',
- 'source_changed': {'path': '../source_changed'},
- 'package_added': 'any',
- 'description_changed': {'path': '../description_changed_2'},
- 'contents_changed': '1.0.0',
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'unchanged': 'any',
+ 'version_upgraded': 'any',
+ 'version_downgraded': '1.0.0',
+ 'source_changed': {'path': '../source_changed'},
+ 'package_added': 'any',
+ 'description_changed': {'path': '../description_changed_2'},
+ 'contents_changed': '1.0.0',
+ },
+ ).create();
// Upgrade everything.
await pubUpgrade(
- output: allOf([
- contains('Resolving dependencies...'),
- contains(
- '* description_changed 1.0.0 from path ..${separator}description_changed_2 (was 1.0.0 from path ..${separator}description_changed_1)'),
- contains(' unchanged 1.0.0'),
- contains(
- '* source_changed 2.0.0 from path ..${separator}source_changed (was 1.0.0)'),
- contains('> version_upgraded 2.0.0 (was 1.0.0'),
- contains('< version_downgraded 1.0.0 (was 2.0.0'),
- contains('+ package_added 1.0.0'),
- contains('- package_removed 1.0.0'),
- contains('~ contents_changed 1.0.0 (was 1.0.0)'),
- ]),
- environment: {'PUB_ALLOW_PRERELEASE_SDK': 'false'});
+ output: allOf([
+ contains('Resolving dependencies...'),
+ contains(
+ '* description_changed 1.0.0 from path ..${separator}description_changed_2 (was 1.0.0 from path ..${separator}description_changed_1)',
+ ),
+ contains(' unchanged 1.0.0'),
+ contains(
+ '* source_changed 2.0.0 from path ..${separator}source_changed (was 1.0.0)',
+ ),
+ contains('> version_upgraded 2.0.0 (was 1.0.0'),
+ contains('< version_downgraded 1.0.0 (was 2.0.0'),
+ contains('+ package_added 1.0.0'),
+ contains('- package_removed 1.0.0'),
+ contains('~ contents_changed 1.0.0 (was 1.0.0)'),
+ ]),
+ environment: {'PUB_ALLOW_PRERELEASE_SDK': 'false'},
+ );
});
}
diff --git a/test/upgrade/report/does_not_show_newer_versions_for_locked_packages_test.dart b/test/upgrade/report/does_not_show_newer_versions_for_locked_packages_test.dart
index ef987b9..b54f87c 100644
--- a/test/upgrade/report/does_not_show_newer_versions_for_locked_packages_test.dart
+++ b/test/upgrade/report/does_not_show_newer_versions_for_locked_packages_test.dart
@@ -20,18 +20,29 @@
..serve('upgraded', '3.0.0-dev');
// Constraint everything to the first version.
- await d.appDir({'not_upgraded': '1.0.0', 'upgraded': '1.0.0'}).create();
+ await d.appDir(
+ dependencies: {'not_upgraded': '1.0.0', 'upgraded': '1.0.0'},
+ ).create();
await pubGet();
// Loosen the constraints.
- await d.appDir({'not_upgraded': 'any', 'upgraded': 'any'}).create();
+ await d.appDir(
+ dependencies: {'not_upgraded': 'any', 'upgraded': 'any'},
+ ).create();
// Only upgrade "upgraded".
- await pubUpgrade(args: ['upgraded'], output: RegExp(r'''
+ await pubUpgrade(
+ args: ['upgraded'],
+ output: RegExp(
+ r'''
Resolving dependencies\.\.\..*
not_upgraded 1\.0\.0 \(2\.0\.0 available\)
. upgraded 2\.0\.0 \(was 1\.0\.0\)
-''', multiLine: true), environment: {'PUB_ALLOW_PRERELEASE_SDK': 'false'});
+''',
+ multiLine: true,
+ ),
+ environment: {'PUB_ALLOW_PRERELEASE_SDK': 'false'},
+ );
});
}
diff --git a/test/upgrade/report/highlights_overrides_test.dart b/test/upgrade/report/highlights_overrides_test.dart
index 93f9f3b..03ae4fd 100644
--- a/test/upgrade/report/highlights_overrides_test.dart
+++ b/test/upgrade/report/highlights_overrides_test.dart
@@ -20,9 +20,14 @@
]).create();
// Upgrade everything.
- await pubUpgrade(output: RegExp(r'''
+ await pubUpgrade(
+ output: RegExp(
+ r'''
Resolving dependencies\.\.\..*
! overridden 1\.0\.0 \(overridden\)
-''', multiLine: true));
+''',
+ multiLine: true,
+ ),
+ );
});
}
diff --git a/test/upgrade/report/leading_character_shows_change_test.dart b/test/upgrade/report/leading_character_shows_change_test.dart
index 88f7ed2..132f3b6 100644
--- a/test/upgrade/report/leading_character_shows_change_test.dart
+++ b/test/upgrade/report/leading_character_shows_change_test.dart
@@ -70,7 +70,9 @@
]).create();
// Upgrade everything.
- await pubUpgrade(output: RegExp(r'''
+ await pubUpgrade(
+ output: RegExp(
+ r'''
Resolving dependencies\.\.\..*
\+ added .*
\* description_changed .*
@@ -81,6 +83,10 @@
> upgraded .*
These packages are no longer being depended on:
- removed .*
-''', multiLine: true), environment: {'PUB_ALLOW_PRERELEASE_SDK': 'false'});
+''',
+ multiLine: true,
+ ),
+ environment: {'PUB_ALLOW_PRERELEASE_SDK': 'false'},
+ );
});
}
diff --git a/test/upgrade/report/shows_newer_available_versions_test.dart b/test/upgrade/report/shows_newer_available_versions_test.dart
index 39d4e1a..1e55795 100644
--- a/test/upgrade/report/shows_newer_available_versions_test.dart
+++ b/test/upgrade/report/shows_newer_available_versions_test.dart
@@ -31,19 +31,23 @@
..serve('one_newer_stable', '1.0.1');
// Constraint everything to the first version.
- await d.appDir({
- 'multiple_newer': '1.0.0',
- 'multiple_newer_stable': '1.0.0',
- 'multiple_newer_unstable': '1.0.0',
- 'multiple_newer_unstable2': '1.0.1-unstable.1',
- 'no_newer': '1.0.0',
- 'one_newer_unstable': '1.0.0',
- 'one_newer_unstable2': '1.0.1-unstable.1',
- 'one_newer_stable': '1.0.0'
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'multiple_newer': '1.0.0',
+ 'multiple_newer_stable': '1.0.0',
+ 'multiple_newer_unstable': '1.0.0',
+ 'multiple_newer_unstable2': '1.0.1-unstable.1',
+ 'no_newer': '1.0.0',
+ 'one_newer_unstable': '1.0.0',
+ 'one_newer_unstable2': '1.0.1-unstable.1',
+ 'one_newer_stable': '1.0.0'
+ },
+ ).create();
// Upgrade everything.
- await pubUpgrade(output: RegExp(r'''
+ await pubUpgrade(
+ output: RegExp(
+ r'''
Resolving dependencies\.\.\..*
. multiple_newer 1\.0\.0 \(1\.0\.1 available\)
. multiple_newer_stable 1\.0\.0 \(1\.0\.2\ available\)
@@ -53,6 +57,10 @@
. one_newer_stable 1\.0\.0 \(1\.0\.1 available\)
. one_newer_unstable 1\.0\.0
. one_newer_unstable2 1\.0\.1-unstable\.1 \(1\.0\.1-unstable\.2 available\)
-''', multiLine: true), environment: {'PUB_ALLOW_PRERELEASE_SDK': 'false'});
+''',
+ multiLine: true,
+ ),
+ environment: {'PUB_ALLOW_PRERELEASE_SDK': 'false'},
+ );
});
}
diff --git a/test/upgrade/report/shows_number_of_changed_dependencies_test.dart b/test/upgrade/report/shows_number_of_changed_dependencies_test.dart
index 91ba5aa..784fc83 100644
--- a/test/upgrade/report/shows_number_of_changed_dependencies_test.dart
+++ b/test/upgrade/report/shows_number_of_changed_dependencies_test.dart
@@ -16,13 +16,13 @@
..serve('b', '1.0.0')
..serve('c', '2.0.0');
- await d.appDir({'a': 'any'}).create();
+ await d.appDir(dependencies: {'a': 'any'}).create();
// One dependency changed.
await pubUpgrade(output: RegExp(r'Changed 1 dependency!$'));
// Remove one and add two.
- await d.appDir({'b': 'any', 'c': 'any'}).create();
+ await d.appDir(dependencies: {'b': 'any', 'c': 'any'}).create();
await pubUpgrade(output: RegExp(r'Changed 3 dependencies!$'));
diff --git a/test/upgrade/report/shows_pub_outdated_test.dart b/test/upgrade/report/shows_pub_outdated_test.dart
index 0fdb322..40b0a29 100644
--- a/test/upgrade/report/shows_pub_outdated_test.dart
+++ b/test/upgrade/report/shows_pub_outdated_test.dart
@@ -28,69 +28,102 @@
..serve('one_newer_stable', '1.0.1');
// Constraint everything to the first version.
- await d.appDir({
- 'multiple_newer': '1.0.0',
- 'multiple_newer_stable': '1.0.0',
- 'multiple_newer_unstable': '1.0.0',
- 'no_newer': '1.0.0',
- 'one_newer_unstable': '1.0.0',
- 'one_newer_stable': '1.0.0'
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'multiple_newer': '1.0.0',
+ 'multiple_newer_stable': '1.0.0',
+ 'multiple_newer_unstable': '1.0.0',
+ 'no_newer': '1.0.0',
+ 'one_newer_unstable': '1.0.0',
+ 'one_newer_stable': '1.0.0'
+ },
+ ).create();
// Upgrade everything.
- await pubUpgrade(output: RegExp(r'''
+ await pubUpgrade(
+ output: RegExp(
+ r'''
3 packages have newer versions incompatible with dependency constraints.
-Try `dart pub outdated` for more information.$''', multiLine: true));
+Try `dart pub outdated` for more information.$''',
+ multiLine: true,
+ ),
+ );
// Running inside Flutter this will recommend the Flutter variant.
await pubUpgrade(
- environment: {'PUB_ENVIRONMENT': 'flutter_cli:get'}, output: RegExp(r'''
+ environment: {'PUB_ENVIRONMENT': 'flutter_cli:get'},
+ output: RegExp(
+ r'''
3 packages have newer versions incompatible with dependency constraints.
-Try `flutter pub outdated` for more information.$''', multiLine: true));
+Try `flutter pub outdated` for more information.$''',
+ multiLine: true,
+ ),
+ );
// Upgrade `multiple_newer` to `1.0.1`.
- await d.appDir({
- 'multiple_newer': '1.0.1',
- 'multiple_newer_stable': '1.0.0',
- 'multiple_newer_unstable': '1.0.0',
- 'no_newer': '1.0.0',
- 'one_newer_unstable': '1.0.0',
- 'one_newer_stable': '1.0.0'
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'multiple_newer': '1.0.1',
+ 'multiple_newer_stable': '1.0.0',
+ 'multiple_newer_unstable': '1.0.0',
+ 'no_newer': '1.0.0',
+ 'one_newer_unstable': '1.0.0',
+ 'one_newer_stable': '1.0.0'
+ },
+ ).create();
// Upgrade everything.
- await pubUpgrade(output: RegExp(r'''
+ await pubUpgrade(
+ output: RegExp(
+ r'''
2 packages have newer versions incompatible with dependency constraints.
-Try `dart pub outdated` for more information.$''', multiLine: true));
+Try `dart pub outdated` for more information.$''',
+ multiLine: true,
+ ),
+ );
// Upgrade `multiple_newer` to `1.0.2-unstable.1`.
- await d.appDir({
- 'multiple_newer': '1.0.2-unstable.1',
- 'multiple_newer_stable': '1.0.0',
- 'multiple_newer_unstable': '1.0.0',
- 'no_newer': '1.0.0',
- 'one_newer_unstable': '1.0.0',
- 'one_newer_stable': '1.0.0'
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'multiple_newer': '1.0.2-unstable.1',
+ 'multiple_newer_stable': '1.0.0',
+ 'multiple_newer_unstable': '1.0.0',
+ 'no_newer': '1.0.0',
+ 'one_newer_unstable': '1.0.0',
+ 'one_newer_stable': '1.0.0'
+ },
+ ).create();
// Upgrade everything.
- await pubUpgrade(output: RegExp(r'''
+ await pubUpgrade(
+ output: RegExp(
+ r'''
3 packages have newer versions incompatible with dependency constraints.
-Try `dart pub outdated` for more information.$''', multiLine: true));
+Try `dart pub outdated` for more information.$''',
+ multiLine: true,
+ ),
+ );
// Upgrade all except `one_newer_stable`.
- await d.appDir({
- 'multiple_newer': '1.0.2-unstable.2',
- 'multiple_newer_stable': '1.0.2',
- 'multiple_newer_unstable': '1.0.1-unstable.2',
- 'no_newer': '1.0.0',
- 'one_newer_unstable': '1.0.1-unstable.1',
- 'one_newer_stable': '1.0.0'
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'multiple_newer': '1.0.2-unstable.2',
+ 'multiple_newer_stable': '1.0.2',
+ 'multiple_newer_unstable': '1.0.1-unstable.2',
+ 'no_newer': '1.0.0',
+ 'one_newer_unstable': '1.0.1-unstable.1',
+ 'one_newer_stable': '1.0.0'
+ },
+ ).create();
// Upgrade everything.
- await pubUpgrade(output: RegExp(r'''
+ await pubUpgrade(
+ output: RegExp(
+ r'''
1 package has newer versions incompatible with dependency constraints.
-Try `dart pub outdated` for more information.$''', multiLine: true));
+Try `dart pub outdated` for more information.$''',
+ multiLine: true,
+ ),
+ );
});
}
diff --git a/test/upgrade/upgrade_major_versions_test.dart b/test/upgrade/upgrade_major_versions_test.dart
index c5f0994..40c23ea 100644
--- a/test/upgrade/upgrade_major_versions_test.dart
+++ b/test/upgrade/upgrade_major_versions_test.dart
@@ -18,11 +18,13 @@
..serve('baz', '1.0.0')
..serve('baz', '1.0.1');
- await d.appDir({
- 'foo': '^1.0.0',
- 'bar': '^0.1.0',
- 'baz': '^1.0.0',
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': '^1.0.0',
+ 'bar': '^0.1.0',
+ 'baz': '^1.0.0',
+ },
+ ).create();
await pubGet();
@@ -36,11 +38,13 @@
]),
);
- await d.appDir({
- 'foo': '^2.0.0',
- 'bar': '^0.2.0',
- 'baz': '^1.0.0',
- }).validate();
+ await d.appDir(
+ dependencies: {
+ 'foo': '^2.0.0',
+ 'bar': '^0.2.0',
+ 'baz': '^1.0.0',
+ },
+ ).validate();
await d.appPackageConfigFile([
d.packageConfigEntry(name: 'foo', version: '2.0.0'),
d.packageConfigEntry(name: 'bar', version: '0.2.0'),
@@ -104,10 +108,12 @@
..serve('foo', '2.0.0')
..serve('bar', '0.1.0');
- await d.appDir({
- 'foo': '^1.0.0',
- 'bar': '^0.1.0',
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': '^1.0.0',
+ 'bar': '^0.1.0',
+ },
+ ).create();
await pubGet();
@@ -122,10 +128,12 @@
]),
);
- await d.appDir({
- 'foo': '^2.0.0', // bumped
- 'bar': '^0.1.0',
- }).validate();
+ await d.appDir(
+ dependencies: {
+ 'foo': '^2.0.0', // bumped
+ 'bar': '^0.1.0',
+ },
+ ).validate();
await d.appPackageConfigFile([
d.packageConfigEntry(name: 'foo', version: '2.0.0'),
@@ -139,7 +147,7 @@
..serve('foo', '2.0.0')
..serve('foo', '3.0.0');
- await d.appDir({'foo': '^1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '^1.0.0'}).create();
await pubGet();
@@ -227,18 +235,24 @@
/// resolved first
await servePackages()
..serve('foo', '1.0.0')
- ..serve('foo', '2.0.0', pubspec: {
- 'dependencies': {'bar': '1.0.0'}
- })
+ ..serve(
+ 'foo',
+ '2.0.0',
+ pubspec: {
+ 'dependencies': {'bar': '1.0.0'}
+ },
+ )
..serve('bar', '1.0.0')
..serve('bar', '2.0.0')
..serve('bar', '3.0.0')
..serve('bar', '4.0.0');
- await d.appDir({
- 'foo': '^1.0.0',
- 'bar': '^2.0.0',
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': '^1.0.0',
+ 'bar': '^2.0.0',
+ },
+ ).create();
await pubGet();
@@ -251,10 +265,12 @@
]),
);
- await d.appDir({
- 'foo': '^1.0.0',
- 'bar': '^4.0.0',
- }).validate();
+ await d.appDir(
+ dependencies: {
+ 'foo': '^1.0.0',
+ 'bar': '^4.0.0',
+ },
+ ).validate();
await d.appPackageConfigFile([
d.packageConfigEntry(name: 'foo', version: '1.0.0'),
diff --git a/test/upgrade/upgrade_null_safety_test.dart b/test/upgrade/upgrade_null_safety_test.dart
deleted file mode 100644
index ad210d8..0000000
--- a/test/upgrade/upgrade_null_safety_test.dart
+++ /dev/null
@@ -1,482 +0,0 @@
-// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'package:test/test.dart';
-import '../descriptor.dart' as d;
-import '../test_pub.dart';
-
-void main() {
- group('pub upgrade --null-safety', () {
- setUp(() async {
- await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'environment': {'sdk': '>=2.10.0<3.0.0'},
- })
- ..serve('foo', '2.0.0', pubspec: {
- 'environment': {'sdk': '>=2.12.0<3.0.0'},
- })
- ..serve('bar', '1.0.0', pubspec: {
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- })
- ..serve('bar', '2.0.0-nullsafety.0', pubspec: {
- 'environment': {'sdk': '>=2.12.0<3.0.0'},
- })
- ..serve('baz', '1.0.0', pubspec: {
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- })
- ..serve('has_conflict', '1.0.0', pubspec: {
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- })
- ..serve('has_conflict', '2.0.0', pubspec: {
- 'environment': {'sdk': '>=2.13.0<3.0.0'},
- });
- });
-
- test('upgrades to null-safety versions', () async {
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'myapp',
- 'dependencies': {
- 'foo': '^1.0.0',
- },
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- ]).create();
-
- await pubGet(environment: {
- '_PUB_TEST_SDK_VERSION': '2.10.0',
- });
- await d.dir(appPath, [
- d.packageConfigFile([
- d.packageConfigEntry(
- name: 'foo',
- version: '1.0.0',
- languageVersion: '2.10',
- ),
- d.packageConfigEntry(
- name: 'myapp',
- languageVersion: '2.9',
- path: '.',
- ),
- ], generatorVersion: '2.10.0'),
- ]).validate();
-
- await pubUpgrade(
- args: ['--null-safety'],
- environment: {
- '_PUB_TEST_SDK_VERSION': '2.12.0',
- },
- output: allOf(
- contains('Changed 1 constraint in pubspec.yaml:'),
- contains('foo: ^1.0.0 -> ^2.0.0'),
- ),
- );
-
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'myapp',
- 'dependencies': {
- 'foo': '^2.0.0',
- },
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- d.packageConfigFile([
- d.packageConfigEntry(
- name: 'foo',
- version: '2.0.0',
- languageVersion: '2.12',
- ),
- d.packageConfigEntry(
- name: 'myapp',
- languageVersion: '2.9',
- path: '.',
- ),
- ], generatorVersion: '2.12.0'),
- ]).validate();
- });
-
- test('upgrades to prereleases when required', () async {
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'myapp',
- 'dependencies': {
- 'bar': '^1.0.0',
- },
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- ]).create();
-
- await pubGet(environment: {
- '_PUB_TEST_SDK_VERSION': '2.10.0',
- });
- await d.dir(appPath, [
- d.packageConfigFile([
- d.packageConfigEntry(
- name: 'bar',
- version: '1.0.0',
- languageVersion: '2.9',
- ),
- d.packageConfigEntry(
- name: 'myapp',
- languageVersion: '2.9',
- path: '.',
- ),
- ], generatorVersion: '2.10.0'),
- ]).validate();
-
- await pubUpgrade(
- args: ['--null-safety'],
- environment: {
- '_PUB_TEST_SDK_VERSION': '2.12.0',
- },
- output: allOf(
- contains('Changed 1 constraint in pubspec.yaml:'),
- contains('bar: ^1.0.0 -> ^2.0.0-nullsafety.0'),
- ),
- );
-
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'myapp',
- 'dependencies': {
- 'bar': '^2.0.0-nullsafety.0',
- },
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- d.packageConfigFile([
- d.packageConfigEntry(
- name: 'bar',
- version: '2.0.0-nullsafety.0',
- languageVersion: '2.12',
- ),
- d.packageConfigEntry(
- name: 'myapp',
- languageVersion: '2.9',
- path: '.',
- ),
- ], generatorVersion: '2.12.0'),
- ]).validate();
- });
-
- test('upgrades multiple dependencies', () async {
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'myapp',
- 'dependencies': {
- 'foo': '^1.0.0',
- 'bar': '^1.0.0',
- },
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- ]).create();
-
- await pubGet(environment: {
- '_PUB_TEST_SDK_VERSION': '2.10.0',
- });
-
- await pubUpgrade(
- args: ['--null-safety'],
- environment: {
- '_PUB_TEST_SDK_VERSION': '2.12.0',
- },
- output: allOf(
- contains('Changed 2 constraints in pubspec.yaml:'),
- contains('foo: ^1.0.0 -> ^2.0.0'),
- contains('bar: ^1.0.0 -> ^2.0.0-nullsafety.0'),
- ),
- );
-
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'myapp',
- 'dependencies': {
- 'foo': '^2.0.0',
- 'bar': '^2.0.0-nullsafety.0',
- },
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- d.packageConfigFile([
- d.packageConfigEntry(
- name: 'foo',
- version: '2.0.0',
- languageVersion: '2.12',
- ),
- d.packageConfigEntry(
- name: 'bar',
- version: '2.0.0-nullsafety.0',
- languageVersion: '2.12',
- ),
- d.packageConfigEntry(
- name: 'myapp',
- languageVersion: '2.9',
- path: '.',
- ),
- ], generatorVersion: '2.12.0'),
- ]).validate();
- });
-
- test('--dry-run does not mutate pubspec.yaml', () async {
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'myapp',
- 'dependencies': {
- 'foo': '^1.0.0',
- 'bar': '^1.0.0',
- },
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- ]).create();
-
- await pubGet(environment: {
- '_PUB_TEST_SDK_VERSION': '2.10.0',
- });
-
- final stateBeforeUpgrade = d.dir(appPath, [
- d.pubspec({
- 'name': 'myapp',
- 'dependencies': {
- 'foo': '^1.0.0',
- 'bar': '^1.0.0',
- },
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- d.packageConfigFile([
- d.packageConfigEntry(
- name: 'foo',
- version: '1.0.0',
- languageVersion: '2.10',
- ),
- d.packageConfigEntry(
- name: 'bar',
- version: '1.0.0',
- languageVersion: '2.9',
- ),
- d.packageConfigEntry(
- name: 'myapp',
- languageVersion: '2.9',
- path: '.',
- ),
- ], generatorVersion: '2.10.0'),
- ]);
- await stateBeforeUpgrade.validate();
-
- await pubUpgrade(
- args: ['--null-safety', '--dry-run'],
- environment: {
- '_PUB_TEST_SDK_VERSION': '2.12.0',
- },
- output: allOf(
- contains('Would change 2 constraints in pubspec.yaml:'),
- contains('foo: ^1.0.0 -> ^2.0.0'),
- contains('bar: ^1.0.0 -> ^2.0.0-nullsafety.0'),
- ),
- );
-
- await stateBeforeUpgrade.validate();
- });
-
- test('ignores path dependencies', () async {
- await d.dir('baz', [
- d.pubspec({
- 'name': 'baz',
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- ]).create();
-
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'myapp',
- 'dependencies': {
- 'foo': '^1.0.0',
- 'bar': '^1.0.0',
- 'baz': {
- 'path': d.path('baz'),
- },
- },
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- ]).create();
-
- await pubGet(environment: {
- '_PUB_TEST_SDK_VERSION': '2.10.0',
- });
-
- await pubUpgrade(
- args: ['--null-safety'],
- environment: {
- '_PUB_TEST_SDK_VERSION': '2.12.0',
- },
- output: allOf(
- contains('Changed 2 constraints in pubspec.yaml:'),
- contains('foo: ^1.0.0 -> ^2.0.0'),
- contains('bar: ^1.0.0 -> ^2.0.0-nullsafety.0'),
- ),
- warning: allOf(
- contains('Following direct \'dependencies\' and'),
- contains('\'dev_dependencies\' are not migrated to'),
- contains('null-safety yet:'),
- contains(' - baz'),
- ),
- );
- });
-
- test('cannot upgrade without null-safety versions', () async {
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'myapp',
- 'dependencies': {
- 'foo': '^1.0.0',
- 'bar': '^1.0.0',
- 'baz': '^1.0.0',
- },
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- ]).create();
-
- await pubUpgrade(
- args: ['--null-safety'],
- environment: {
- '_PUB_TEST_SDK_VERSION': '2.12.0',
- },
- error: allOf(
- contains('null-safety compatible versions do not exist for:'),
- contains(' - baz'),
- contains('You can choose to upgrade only some dependencies'),
- contains('dart pub upgrade --nullsafety'),
- contains('https://dart.dev/null-safety/migration-guide'),
- ),
- );
- });
-
- test('can upgrade partially', () async {
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'myapp',
- 'dependencies': {
- 'foo': '^1.0.0',
- 'bar': '^1.0.0',
- 'baz': '^1.0.0',
- },
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- ]).create();
-
- await pubUpgrade(
- args: ['--null-safety', 'bar', 'foo'],
- environment: {
- '_PUB_TEST_SDK_VERSION': '2.12.0',
- },
- output: allOf(
- contains('Changed 2 constraints in pubspec.yaml:'),
- contains('foo: ^1.0.0 -> ^2.0.0'),
- contains('bar: ^1.0.0 -> ^2.0.0-nullsafety.0'),
- ),
- warning: allOf(
- contains('Following direct \'dependencies\' and'),
- contains('\'dev_dependencies\' are not migrated to'),
- contains('null-safety yet:'),
- contains(' - baz'),
- ),
- );
-
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'myapp',
- 'dependencies': {
- 'foo': '^2.0.0',
- 'bar': '^2.0.0-nullsafety.0',
- 'baz': '^1.0.0',
- },
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- d.packageConfigFile([
- d.packageConfigEntry(
- name: 'foo',
- version: '2.0.0',
- languageVersion: '2.12',
- ),
- d.packageConfigEntry(
- name: 'bar',
- version: '2.0.0-nullsafety.0',
- languageVersion: '2.12',
- ),
- d.packageConfigEntry(
- name: 'baz',
- version: '1.0.0',
- languageVersion: '2.9',
- ),
- d.packageConfigEntry(
- name: 'myapp',
- languageVersion: '2.9',
- path: '.',
- ),
- ], generatorVersion: '2.12.0'),
- ]).validate();
- });
-
- test('can fail to solve', () async {
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'myapp',
- 'dependencies': {
- 'foo': '^1.0.0',
- 'bar': '^1.0.0',
- // This causes a SDK constraint conflict when migrating to
- // null-safety
- 'has_conflict': '^1.0.0',
- },
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- ]).create();
-
- await pubGet(environment: {
- '_PUB_TEST_SDK_VERSION': '2.10.0',
- });
-
- await pubUpgrade(
- args: ['--null-safety'],
- environment: {
- '_PUB_TEST_SDK_VERSION': '2.12.0',
- },
- error: allOf(
- contains('Because myapp depends on has_conflict >=2.0.0 which'),
- contains('requires SDK version >=2.13.0 <4.0.0,'),
- contains('version solving failed.'),
- ),
- );
- });
-
- test('works in 2.14.0', () async {
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'myapp',
- 'dependencies': {
- 'foo': '^1.0.0',
- 'bar': '^1.0.0',
- // This requires SDK >= 2.13.0
- 'has_conflict': '^1.0.0',
- },
- 'environment': {'sdk': '>=2.9.0<3.0.0'},
- }),
- ]).create();
-
- await pubGet(environment: {
- '_PUB_TEST_SDK_VERSION': '2.10.0',
- });
-
- await pubUpgrade(
- args: ['--null-safety'],
- environment: {
- '_PUB_TEST_SDK_VERSION': '2.14.0',
- },
- output: allOf(
- contains('Changed 3 constraints in pubspec.yaml:'),
- contains('foo: ^1.0.0 -> ^2.0.0'),
- contains('bar: ^1.0.0 -> ^2.0.0-nullsafety.0'),
- contains('has_conflict: ^1.0.0 -> ^2.0.0'),
- ),
- );
- });
- });
-}
diff --git a/test/utils_test.dart b/test/utils_test.dart
index cc51066..9d71e31 100644
--- a/test/utils_test.dart
+++ b/test/utils_test.dart
@@ -41,30 +41,37 @@
test('uses indentation for maps', () {
expect(
- yamlToString({
- 'a': {'b': 1, 'c': 2},
- 'd': 3
- }),
- equals('''
+ yamlToString({
+ 'a': {'b': 1, 'c': 2},
+ 'd': 3
+ }),
+ equals('''
a:
b: 1
c: 2
-d: 3'''));
+d: 3'''),
+ );
});
test('sorts map keys', () {
- expect(yamlToString({'a': 1, 'c': 2, 'b': 3, 'd': 4}), equals('''
+ expect(
+ yamlToString({'a': 1, 'c': 2, 'b': 3, 'd': 4}),
+ equals('''
a: 1
b: 3
c: 2
-d: 4'''));
+d: 4'''),
+ );
});
test('quotes map keys as needed', () {
- expect(yamlToString({'no': 1, 'yes!': 2, '123': 3}), equals('''
+ expect(
+ yamlToString({'no': 1, 'yes!': 2, '123': 3}),
+ equals('''
"123": 3
no: 1
-"yes!": 2'''));
+"yes!": 2'''),
+ );
});
test('handles non-string map keys', () {
@@ -73,24 +80,32 @@
map[123] = 'num';
map[true] = 'bool';
- expect(yamlToString(map), equals('''
+ expect(
+ yamlToString(map),
+ equals('''
123: num
null: null
-true: bool'''));
+true: bool'''),
+ );
});
test('handles empty maps', () {
expect(yamlToString({}), equals('{}'));
- expect(yamlToString({'a': {}, 'b': {}}), equals('''
+ expect(
+ yamlToString({'a': {}, 'b': {}}),
+ equals('''
a: {}
-b: {}'''));
+b: {}'''),
+ );
});
});
group('niceDuration()', () {
test('formats duration longer than a minute correctly', () {
- expect(niceDuration(Duration(minutes: 3, seconds: 1, milliseconds: 337)),
- equals('3:01.3s'));
+ expect(
+ niceDuration(Duration(minutes: 3, seconds: 1, milliseconds: 337)),
+ equals('3:01.3s'),
+ );
});
test('does not display extra zero when duration is less than a minute', () {
@@ -135,8 +150,9 @@
}
final w = expectLater(
- minByAsync(['aa', 'a', 'b', 'ccc'], lengthWhenComplete),
- completion('a'));
+ minByAsync(['aa', 'a', 'b', 'ccc'], lengthWhenComplete),
+ completion('a'),
+ );
completer('aa').complete();
completer('b').complete();
completer('a').complete();
@@ -152,8 +168,9 @@
}
final w = expectLater(
- minByAsync(['aa', 'a', 'b', 'ccc'], lengthWhenComplete),
- completion('a'));
+ minByAsync(['aa', 'a', 'b', 'ccc'], lengthWhenComplete),
+ completion('a'),
+ );
completer('ccc').complete();
completer('a').complete();
completer('b').complete();
diff --git a/test/validator/analyze_test.dart b/test/validator/analyze_test.dart
index a5882db..a20f4cd 100644
--- a/test/validator/analyze_test.dart
+++ b/test/validator/analyze_test.dart
@@ -57,10 +57,12 @@
'follows analysis_options.yaml and should warn if package contains errors in pubspec.yaml',
() async {
await d.dir(appPath, [
- d.libPubspec('test_pkg', '1.0.0',
- sdk: '>=1.8.0 <=2.0.0',
- // Using http where https is recommended.
- extras: {'repository': 'http://repo.org/'}),
+ d.libPubspec(
+ 'test_pkg', '1.0.0',
+ sdk: '>=1.8.0 <=2.0.0',
+ // Using http where https is recommended.
+ extras: {'repository': 'http://repo.org/'},
+ ),
d.file('LICENSE', 'Eh, do what you want.'),
d.file('README.md', "This package isn't real."),
d.file('CHANGELOG.md', '# 1.0.0\nFirst version\n'),
@@ -76,7 +78,8 @@
await expectValidation(
allOf([
contains(
- "The url should only use secure protocols. Try using 'https'."),
+ "The 'http' protocol shouldn't be used because it isn't secure. Try using a secure protocol, such as 'https'.",
+ ),
contains('Package has 1 warning.'),
]),
DATA,
diff --git a/test/validator/dependency_test.dart b/test/validator/dependency_test.dart
index 083cbcc..6d8349e 100644
--- a/test/validator/dependency_test.dart
+++ b/test/validator/dependency_test.dart
@@ -13,11 +13,18 @@
import '../descriptor.dart' as d;
import '../test_pub.dart';
-d.DirectoryDescriptor package(
- {String version = '1.0.0', Map? deps, String? sdk}) {
+d.DirectoryDescriptor package({
+ String version = '1.0.0',
+ Map? deps,
+ String? sdk,
+}) {
return d.dir(appPath, [
- d.libPubspec('test_pkg', version,
- sdk: sdk ?? '>=1.8.0 <=2.0.0', deps: deps),
+ d.libPubspec(
+ 'test_pkg',
+ version,
+ sdk: sdk ?? defaultSdkConstraint,
+ deps: deps,
+ ),
d.file('LICENSE', 'Eh, do what you want.'),
d.file('README.md', "This package isn't real."),
d.file('CHANGELOG.md', '# $version\nFirst version\n'),
@@ -25,10 +32,11 @@
]);
}
-Future<void> expectValidation(
- {error,
- int exitCode = 0,
- Map<String, String> environment = const {}}) async {
+Future<void> expectValidation({
+ error,
+ int exitCode = 0,
+ Map<String, String> environment = const {},
+}) async {
await runPub(
error: error ?? contains('Package has 0 warnings.'),
args: ['publish', '--dry-run'],
@@ -38,8 +46,11 @@
);
}
-Future<void> expectValidationWarning(error,
- {int count = 1, Map<String, String> environment = const {}}) async {
+Future<void> expectValidationWarning(
+ error, {
+ int count = 1,
+ Map<String, String> environment = const {},
+}) async {
if (error is String) error = contains(error);
await expectValidation(
error: allOf([error, contains('Package has $count warning')]),
@@ -48,45 +59,50 @@
);
}
-Future<void> expectValidationError(String text,
- {Map<String, String> environment = const {}}) async {
+Future<void> expectValidationError(
+ String text, {
+ Map<String, String> environment = const {},
+}) async {
await expectValidation(
- error: allOf([
- contains(text),
- contains('Package validation found the following error:')
- ]),
- exitCode: DATA,
- environment: environment);
+ error: allOf([
+ contains(text),
+ contains('Package validation found the following error:')
+ ]),
+ exitCode: DATA,
+ environment: environment,
+ );
}
-Future<void> setUpDependency(dep,
- {List<String> hostedVersions = const []}) async {
+Future<void> setUpDependency(
+ dep, {
+ String? sdk,
+ List<String> hostedVersions = const [],
+}) async {
final server = await servePackages();
for (final version in hostedVersions) {
server.serve('foo', version);
}
- await package(deps: {'foo': dep}).create();
+ await package(deps: {'foo': dep}, sdk: sdk).create();
}
void main() {
group('should consider a package valid if it', () {
test('looks normal', () async {
await package().create();
- await expectValidation(environment: {'_PUB_TEST_SDK_VERSION': '1.18.0'});
+ await expectValidation();
});
test('has a ^ constraint with an appropriate SDK constraint', () async {
- (await servePackages()).serve('foo', '1.2.3');
- await package(deps: {'foo': '^1.2.3'}).create();
+ (await servePackages()).serve('foo', '1.2.3', sdk: '^1.8.3');
+ await package(deps: {'foo': '^1.2.3'}, sdk: '^1.8.3').create();
await expectValidation(environment: {'_PUB_TEST_SDK_VERSION': '1.18.0'});
});
test('with a dependency on a pre-release while being one', () async {
(await servePackages()).serve('foo', '1.2.3-dev');
await package(version: '1.0.0-dev', deps: {'foo': '^1.2.3-dev'}).create();
-
- await expectValidation(environment: {'_PUB_TEST_SDK_VERSION': '1.18.0'});
+ await expectValidation();
});
test('has a git path dependency with an appropriate SDK constraint',
@@ -95,30 +111,35 @@
await d.git('foo', [
d.dir('subdir', [d.libPubspec('foo', '1.0.0', sdk: '^2.0.0')]),
]).create();
- await package(deps: {
- 'foo': {
- 'git': {'url': '../foo', 'path': 'subdir'}
- }
- }, sdk: '>=2.0.0 <3.0.0')
- .create();
+ await package(
+ deps: {
+ 'foo': {
+ 'git': {'url': '../foo', 'path': 'subdir'}
+ }
+ },
+ sdk: '>=2.0.0 <3.0.0',
+ ).create();
// We should get a warning for using a git dependency, but not an error.
await expectValidationWarning(
- allOf([
- contains(' foo: any'),
- contains("Publishable packages can't have 'git' dependencies"),
- ]),
- count: 2,
- environment: {'_PUB_TEST_SDK_VERSION': '2.0.0'});
+ allOf([
+ contains(' foo: any'),
+ contains("Publishable packages can't have 'git' dependencies"),
+ ]),
+ count: 2,
+ environment: {'_PUB_TEST_SDK_VERSION': '2.0.0'},
+ );
});
test('depends on Flutter from an SDK source', () async {
await d.dir('flutter', [d.file('version', '1.2.3')]).create();
await flutterPackage('flutter', sdk: '>=1.19.0 <2.0.0').create();
- await package(deps: {
- 'flutter': {'sdk': 'flutter'}
- }, sdk: '>=1.19.0 <2.0.0')
- .create();
+ await package(
+ deps: {
+ 'flutter': {'sdk': 'flutter'}
+ },
+ sdk: '>=1.19.0 <2.0.0',
+ ).create();
await expectValidation(
environment: {
@@ -154,14 +175,19 @@
'depends on a package from Fuchsia with an appropriate Dart SDK constraint',
() async {
await fuschiaPackage('foo', sdk: '>=2.0.0 <3.0.0').create();
- await package(sdk: '>=2.0.0 <3.0.0', deps: {
- 'foo': {'sdk': 'fuchsia', 'version': '>=1.2.3 <2.0.0'}
- }).create();
+ await package(
+ sdk: '>=2.0.0 <3.0.0',
+ deps: {
+ 'foo': {'sdk': 'fuchsia', 'version': '>=1.2.3 <2.0.0'}
+ },
+ ).create();
- await expectValidation(environment: {
- 'FUCHSIA_DART_SDK_ROOT': path.join(d.sandbox, 'fuchsia'),
- '_PUB_TEST_SDK_VERSION': '2.12.0',
- });
+ await expectValidation(
+ environment: {
+ 'FUCHSIA_DART_SDK_ROOT': path.join(d.sandbox, 'fuchsia'),
+ '_PUB_TEST_SDK_VERSION': '2.12.0',
+ },
+ );
},
);
});
@@ -175,8 +201,11 @@
await d.dir('foo', [
d.libPubspec('foo', '1.2.3', sdk: 'any'),
]).create();
- await setUpDependency({'path': path.join(d.sandbox, 'foo')},
- hostedVersions: ['3.0.0-pre', '2.0.0', '1.0.0']);
+ await setUpDependency(
+ sdk: '^1.8.0',
+ {'path': path.join(d.sandbox, 'foo')},
+ hostedVersions: ['3.0.0-pre', '2.0.0', '1.0.0'],
+ );
await expectValidationError(
' foo: ^2.0.0',
environment: {'_PUB_TEST_SDK_VERSION': '1.8.0'},
@@ -184,12 +213,13 @@
});
test(
- 'and should suggest the hosted prerelease version if '
- "it's the only version available", () async {
+ "and should suggest the hosted prerelease version if it's the only version available",
+ () async {
await d.dir('foo', [
d.libPubspec('foo', '1.2.3', sdk: 'any'),
]).create();
await setUpDependency(
+ sdk: '^1.8.0',
{'path': path.join(d.sandbox, 'foo')},
hostedVersions: ['3.0.0-pre', '2.0.0-pre'],
);
@@ -199,13 +229,13 @@
);
});
- test(
- 'and should suggest a tighter constraint if primary is '
- 'pre-1.0.0', () async {
+ test('and should suggest a tighter constraint if primary is pre-1.0.0',
+ () async {
await d.dir('foo', [
d.libPubspec('foo', '1.2.3', sdk: 'any'),
]).create();
await setUpDependency(
+ sdk: '^1.8.0',
{'path': path.join(d.sandbox, 'foo')},
hostedVersions: ['0.0.1', '0.0.2'],
);
@@ -221,7 +251,7 @@
await d.dir('foo', [
d.libPubspec('foo', '1.2.3', sdk: 'any'),
]).create();
- await setUpDependency({
+ await setUpDependency(sdk: '^1.8.0', {
'path': path.join(d.sandbox, 'foo'),
'version': '>=1.0.0 <2.0.0'
});
@@ -238,7 +268,9 @@
d.libPubspec('foo', '0.2.3', sdk: '^1.8.0'),
]).create();
await setUpDependency(
- {'path': path.join(d.sandbox, 'foo'), 'version': '0.2.3'});
+ sdk: '^1.8.0',
+ {'path': path.join(d.sandbox, 'foo'), 'version': '0.2.3'},
+ );
await expectValidationError(
' foo: 0.2.3',
environment: {'_PUB_TEST_SDK_VERSION': '1.8.0'},
@@ -249,9 +281,8 @@
group('has an unconstrained dependency', () {
group('with a lockfile', () {
- test(
- 'and it should suggest a constraint based on the locked '
- 'version', () async {
+ test('and it should suggest a constraint based on the locked version',
+ () async {
(await servePackages()).serve('foo', '1.2.3');
await d.dir(appPath, [
d.libPubspec('test_pkg', '1.0.0', deps: {'foo': 'any'}),
@@ -261,23 +292,24 @@
});
test(
- 'and it should suggest a concrete constraint if the locked '
- 'version is pre-1.0.0', () async {
+ 'and it should suggest a concrete constraint if the locked version is pre-1.0.0',
+ () async {
(await servePackages()).serve('foo', '0.1.2');
await d.dir(appPath, [
d.libPubspec('test_pkg', '1.0.0', deps: {'foo': 'any'}),
d.file(
- 'pubspec.lock',
- jsonEncode({
- 'packages': {
- 'foo': {
- 'version': '0.1.2',
- 'source': 'hosted',
- 'description': {'name': 'foo', 'url': 'https://pub.dev'}
- }
+ 'pubspec.lock',
+ jsonEncode({
+ 'packages': {
+ 'foo': {
+ 'version': '0.1.2',
+ 'source': 'hosted',
+ 'description': {'name': 'foo', 'url': 'https://pub.dev'}
}
- }))
+ }
+ }),
+ )
]).create();
await expectValidationWarning(' foo: ^0.1.2');
@@ -286,7 +318,7 @@
});
test('with a dependency on a pre-release without being one', () async {
- (await servePackages()).serve('foo', '1.2.3-dev');
+ (await servePackages()).serve('foo', '1.2.3-dev', sdk: '^1.8.0');
await d.dir(appPath, [
d.libPubspec(
@@ -297,8 +329,10 @@
)
]).create();
- await expectValidationWarning('Packages dependent on a pre-release',
- environment: {'_PUB_TEST_SDK_VERSION': '1.8.0'});
+ await expectValidationWarning(
+ 'Packages dependent on a pre-release',
+ environment: {'_PUB_TEST_SDK_VERSION': '1.8.0'},
+ );
});
test(
'with a single-version dependency and it should suggest a '
@@ -332,16 +366,17 @@
await d.dir(appPath, [
d.libPubspec('test_pkg', '1.0.0', deps: {'foo': '<=3.0.0'}),
d.file(
- 'pubspec.lock',
- jsonEncode({
- 'packages': {
- 'foo': {
- 'version': '1.2.3',
- 'source': 'hosted',
- 'description': {'name': 'foo', 'url': 'https://pub.dev'}
- }
+ 'pubspec.lock',
+ jsonEncode({
+ 'packages': {
+ 'foo': {
+ 'version': '1.2.3',
+ 'source': 'hosted',
+ 'description': {'name': 'foo', 'url': 'https://pub.dev'}
}
- }))
+ }
+ }),
+ )
]).create();
await expectValidationWarning(' foo: ">=1.2.3 <=3.0.0"');
@@ -355,16 +390,17 @@
await d.dir(appPath, [
d.libPubspec('test_pkg', '1.0.0', deps: {'foo': '<=1.2.3'}),
d.file(
- 'pubspec.lock',
- jsonEncode({
- 'packages': {
- 'foo': {
- 'version': '1.2.3',
- 'source': 'hosted',
- 'description': {'name': 'foo', 'url': 'https://pub.dev'}
- }
+ 'pubspec.lock',
+ jsonEncode({
+ 'packages': {
+ 'foo': {
+ 'version': '1.2.3',
+ 'source': 'hosted',
+ 'description': {'name': 'foo', 'url': 'https://pub.dev'}
}
- }))
+ }
+ }),
+ )
]).create();
await expectValidationWarning(' foo: ^1.2.3');
@@ -394,10 +430,14 @@
group('has a ^ dependency', () {
test('with a too-broad SDK constraint', () async {
- (await servePackages()).serve('foo', '1.2.3');
+ (await servePackages()).serve('foo', '1.2.3', sdk: '^1.4.0');
await d.dir(appPath, [
- d.libPubspec('test_pkg', '1.0.0',
- deps: {'foo': '^1.2.3'}, sdk: '>=1.5.0 <2.0.0')
+ d.libPubspec(
+ 'test_pkg',
+ '1.0.0',
+ deps: {'foo': '^1.2.3'},
+ sdk: '>=1.5.0 <2.0.0',
+ )
]).create();
await expectValidationError(
@@ -412,14 +452,21 @@
// Ensure we don't report anything from the real pub.dev.
await setUpDependency({});
await d.git('foo', [
- d.dir('subdir', [d.libPubspec('foo', '1.0.0')]),
+ d.dir('subdir', [
+ d.libPubspec('foo', '1.0.0', extras: {'dependencies': {}})
+ ]),
]).create();
await d.dir(appPath, [
- d.libPubspec('integration_pkg', '1.0.0', deps: {
- 'foo': {
- 'git': {'url': d.path('foo'), 'path': 'subdir'}
- }
- })
+ d.libPubspec(
+ 'integration_pkg',
+ '1.0.0',
+ deps: {
+ 'foo': {
+ 'git': {'url': d.path('foo'), 'path': 'subdir'}
+ },
+ },
+ sdk: '>=1.0.0 <4.0.0',
+ )
]).create();
await expectValidation(
@@ -436,16 +483,21 @@
await setUpDependency({});
await d.git('foo', [
d.dir(
- 'subdir', [d.libPubspec('foo', '1.0.0', sdk: '>=0.0.0 <3.0.0')]),
+ 'subdir',
+ [d.libPubspec('foo', '1.0.0', sdk: '>=0.0.0 <3.0.0')],
+ ),
]).create();
await d.dir(appPath, [
- d.libPubspec('integration_pkg', '1.0.0',
- deps: {
- 'foo': {
- 'git': {'url': d.path('foo'), 'path': 'subdir'}
- }
- },
- sdk: '>=1.24.0 <3.0.0')
+ d.libPubspec(
+ 'integration_pkg',
+ '1.0.0',
+ deps: {
+ 'foo': {
+ 'git': {'url': d.path('foo'), 'path': 'subdir'}
+ }
+ },
+ sdk: '>=1.24.0 <3.0.0',
+ )
]).create();
await expectValidation(
@@ -479,18 +531,24 @@
sdk: '>=1.18.0 <2.0.0',
).create();
- await expectValidationError('sdk: "^1.19.0"', environment: {
- '_PUB_TEST_SDK_VERSION': '1.19.0',
- 'FLUTTER_ROOT': path.join(d.sandbox, 'flutter'),
- });
+ await expectValidationError(
+ 'sdk: "^1.19.0"',
+ environment: {
+ '_PUB_TEST_SDK_VERSION': '1.19.0',
+ 'FLUTTER_ROOT': path.join(d.sandbox, 'flutter'),
+ },
+ );
});
test('depends on a Flutter package with no SDK constraint', () async {
await d.dir('flutter', [d.file('version', '1.2.3')]).create();
await flutterPackage('foo', sdk: '>=0.0.0 <1.0.0').create();
- await package(sdk: '>=0.0.0 <=0.0.1', deps: {
- 'foo': {'sdk': 'flutter', 'version': '>=1.2.3 <2.0.0'}
- }).create();
+ await package(
+ sdk: '>=0.0.0 <=0.0.1',
+ deps: {
+ 'foo': {'sdk': 'flutter', 'version': '>=1.2.3 <2.0.0'}
+ },
+ ).create();
await expectValidationError(
'sdk: "^1.19.0"',
@@ -512,28 +570,22 @@
},
).create();
- await expectValidationError('sdk: ">=2.0.0 <2.0.2"', environment: {
- 'FUCHSIA_DART_SDK_ROOT': path.join(d.sandbox, 'fuchsia'),
- '_PUB_TEST_SDK_VERSION': '2.0.1-dev.51.0',
- });
- });
-
- test('depends on a Fuchsia package with no SDK constraint', () async {
- await fuschiaPackage('foo').create();
- await package(sdk: '>=0.0.0 <1.0.0', deps: {
- 'foo': {'sdk': 'fuchsia', 'version': '>=1.2.3 <2.0.0'}
- }).create();
-
await expectValidationError(
- 'sdk: "^2.0.0"',
- environment: {'FUCHSIA_DART_SDK_ROOT': path.join(d.sandbox, 'fuchsia')},
+ 'sdk: ">=2.0.0 <2.0.2"',
+ environment: {
+ 'FUCHSIA_DART_SDK_ROOT': path.join(d.sandbox, 'fuchsia'),
+ '_PUB_TEST_SDK_VERSION': '2.0.1-dev.51.0',
+ },
);
});
});
}
-d.Descriptor fuschiaPackage(String name,
- {Map<String, String> deps = const {}, String? sdk}) {
+d.Descriptor fuschiaPackage(
+ String name, {
+ Map<String, String> deps = const {},
+ String? sdk,
+}) {
return d.dir('fuchsia', [
d.dir('packages', [
d.dir(name, [
@@ -544,8 +596,11 @@
]);
}
-d.Descriptor flutterPackage(String name,
- {Map<String, String> deps = const {}, String? sdk}) {
+d.Descriptor flutterPackage(
+ String name, {
+ Map<String, String> deps = const {},
+ String? sdk,
+}) {
return d.dir('flutter', [
d.dir('packages', [
d.dir(name, [
diff --git a/test/validator/deprecated_fields_test.dart b/test/validator/deprecated_fields_test.dart
index 65f3ca0..8fa6820 100644
--- a/test/validator/deprecated_fields_test.dart
+++ b/test/validator/deprecated_fields_test.dart
@@ -15,8 +15,10 @@
void main() {
setUp(d.validPackage.create);
- test('should not warn if neither transformers or web is included',
- () => expectValidation(deprecatedFields));
+ test(
+ 'should not warn if neither transformers or web is included',
+ () => expectValidation(deprecatedFields),
+ );
test('should warn if pubspec has a transformers section', () async {
await d.dir(appPath, [
diff --git a/test/validator/file_case_test.dart b/test/validator/file_case_test.dart
new file mode 100644
index 0000000..67d8200
--- /dev/null
+++ b/test/validator/file_case_test.dart
@@ -0,0 +1,42 @@
+// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// These tests only work on case-sensitive file systems (ie. only on linux).
+@OnPlatform({
+ 'windows': Skip('Windows file system is case-insensitive'),
+ 'mac-os': Skip('MacOS file system is case-insensitive')
+})
+
+import 'package:pub/src/exit_codes.dart';
+import 'package:test/test.dart';
+
+import '../descriptor.dart' as d;
+import '../test_pub.dart';
+
+Future<void> expectValidation(error, int exitCode) async {
+ await runPub(
+ error: error,
+ args: ['publish', '--dry-run'],
+ workingDirectory: d.path(appPath),
+ exitCode: exitCode,
+ );
+}
+
+late d.DirectoryDescriptor fakeFlutterRoot;
+
+void main() {
+ test('Recognizes files that only differ in capitalization.', () async {
+ await d.validPackage.create();
+ await d.dir(appPath, [d.file('Pubspec.yaml')]).create();
+ await expectValidation(
+ allOf(
+ contains('Package validation found the following error:'),
+ contains(
+ 'The file ./pubspec.yaml and ./Pubspec.yaml only differ in capitalization.',
+ ),
+ ),
+ DATA,
+ );
+ });
+}
diff --git a/test/validator/flutter_constraint_test.dart b/test/validator/flutter_constraint_test.dart
index 9e73ef6..f477038 100644
--- a/test/validator/flutter_constraint_test.dart
+++ b/test/validator/flutter_constraint_test.dart
@@ -41,10 +41,12 @@
},
}),
]).create();
- await pubGet(environment: {
- '_PUB_TEST_SDK_VERSION': '2.12.0',
- 'FLUTTER_ROOT': fakeFlutterRoot.io.path
- });
+ await pubGet(
+ environment: {
+ '_PUB_TEST_SDK_VERSION': '2.12.0',
+ 'FLUTTER_ROOT': fakeFlutterRoot.io.path
+ },
+ );
}
void main() {
@@ -59,20 +61,23 @@
test('Warn when upper bound', () async {
await setup(flutterConstraint: '>=1.20.0 <=2.0.0');
await expectValidation(
- allOf([
- contains(
- 'You can replace that with just the lower bound: `>=1.20.0`.'),
- contains('Package has 1 warning.'),
- ]),
- 65);
+ allOf([
+ contains(
+ 'You can replace that with just the lower bound: `>=1.20.0`.',
+ ),
+ contains('Package has 1 warning.'),
+ ]),
+ 65,
+ );
});
test('Warn when only upper bound', () async {
await setup(flutterConstraint: '<2.0.0');
await expectValidation(
- allOf([
- contains('You can replace the constraint with `any`.'),
- contains('Package has 1 warning.'),
- ]),
- 65);
+ allOf([
+ contains('You can replace the constraint with `any`.'),
+ contains('Package has 1 warning.'),
+ ]),
+ 65,
+ );
});
}
diff --git a/test/validator/flutter_plugin_format_test.dart b/test/validator/flutter_plugin_format_test.dart
index 0a5b28c..526944b 100644
--- a/test/validator/flutter_plugin_format_test.dart
+++ b/test/validator/flutter_plugin_format_test.dart
@@ -100,7 +100,8 @@
flutterPluginFormat,
errors: contains(
contains(
- 'Please consider increasing the Flutter SDK requirement to ^1.10.0'),
+ 'Please consider increasing the Flutter SDK requirement to ^1.10.0',
+ ),
),
);
});
@@ -120,10 +121,12 @@
},
};
await d.dir(appPath, [d.pubspec(pkg), d.dir('ios')]).create();
- await expectValidation(flutterPluginFormat,
- errors: contains(
- contains('Instead use the flutter.plugin.platforms key'),
- ));
+ await expectValidation(
+ flutterPluginFormat,
+ errors: contains(
+ contains('Instead use the flutter.plugin.platforms key'),
+ ),
+ );
});
test('is a flutter 1.9.0 plugin with new format', () async {
@@ -148,7 +151,8 @@
flutterPluginFormat,
errors: contains(
contains(
- 'Please consider increasing the Flutter SDK requirement to ^1.10.0'),
+ 'Please consider increasing the Flutter SDK requirement to ^1.10.0',
+ ),
),
);
});
@@ -176,7 +180,8 @@
flutterPluginFormat,
errors: contains(
contains(
- 'Please consider increasing the Flutter SDK requirement to ^1.10.0'),
+ 'Please consider increasing the Flutter SDK requirement to ^1.10.0',
+ ),
),
);
});
@@ -200,7 +205,8 @@
flutterPluginFormat,
errors: contains(
contains(
- 'Please consider increasing the Flutter SDK requirement to ^1.10.0'),
+ 'Please consider increasing the Flutter SDK requirement to ^1.10.0',
+ ),
),
);
});
@@ -223,11 +229,14 @@
},
};
await d.dir(appPath, [d.pubspec(pkg), d.dir('ios')]).create();
- await expectValidation(flutterPluginFormat,
- errors: contains(
- contains(
- 'Please consider increasing the Flutter SDK requirement to ^1.10.0'),
- ));
+ await expectValidation(
+ flutterPluginFormat,
+ errors: contains(
+ contains(
+ 'Please consider increasing the Flutter SDK requirement to ^1.10.0',
+ ),
+ ),
+ );
});
test('is a flutter 1.9.999 plugin with new format', () async {
@@ -248,11 +257,14 @@
},
};
await d.dir(appPath, [d.pubspec(pkg), d.dir('ios')]).create();
- await expectValidation(flutterPluginFormat,
- errors: contains(
- contains(
- 'Please consider increasing the Flutter SDK requirement to ^1.10.0'),
- ));
+ await expectValidation(
+ flutterPluginFormat,
+ errors: contains(
+ contains(
+ 'Please consider increasing the Flutter SDK requirement to ^1.10.0',
+ ),
+ ),
+ );
});
});
}
diff --git a/test/validator/gitignore_test.dart b/test/validator/gitignore_test.dart
index f4ec65c..abd12bd 100644
--- a/test/validator/gitignore_test.dart
+++ b/test/validator/gitignore_test.dart
@@ -42,13 +42,15 @@
]).create();
await expectValidation(
- allOf([
- contains('Package has 1 warning.'),
- contains('foo.txt'),
- contains(
- 'Consider adjusting your `.gitignore` files to not ignore those files'),
- ]),
- exit_codes.DATA);
+ allOf([
+ contains('Package has 1 warning.'),
+ contains('foo.txt'),
+ contains(
+ 'Consider adjusting your `.gitignore` files to not ignore those files',
+ ),
+ ]),
+ exit_codes.DATA,
+ );
});
test('should not fail on missing git', () async {
@@ -61,8 +63,10 @@
await pubGet();
await setUpFakeGitScript(bash: 'echo "Not git"', batch: 'echo "Not git"');
await expectValidation(
- allOf([contains('Package has 0 warnings.')]), exit_codes.SUCCESS,
- environment: extendedPathEnv());
+ allOf([contains('Package has 0 warnings.')]),
+ exit_codes.SUCCESS,
+ environment: extendedPathEnv(),
+ );
});
test('Should also consider gitignores from above the package root', () async {
@@ -78,22 +82,27 @@
final packageRoot = p.join(d.sandbox, 'reporoot', 'myapp');
await pubGet(workingDirectory: packageRoot);
- await expectValidation(contains('Package has 0 warnings.'), 0,
- workingDirectory: packageRoot);
+ await expectValidation(
+ contains('Package has 0 warnings.'),
+ 0,
+ workingDirectory: packageRoot,
+ );
await d.dir('reporoot', [
d.file('.gitignore', '*.txt'),
]).create();
await expectValidation(
- allOf([
- contains('Package has 1 warning.'),
- contains('foo.txt'),
- contains(
- 'Consider adjusting your `.gitignore` files to not ignore those files'),
- ]),
- exit_codes.DATA,
- workingDirectory: packageRoot);
+ allOf([
+ contains('Package has 1 warning.'),
+ contains('foo.txt'),
+ contains(
+ 'Consider adjusting your `.gitignore` files to not ignore those files',
+ ),
+ ]),
+ exit_codes.DATA,
+ workingDirectory: packageRoot,
+ );
});
test('Should not follow symlinks', () async {
@@ -108,7 +117,10 @@
recursive: true,
);
- await expectValidation(contains('Package has 0 warnings.'), 0,
- workingDirectory: packageRoot);
+ await expectValidation(
+ contains('Package has 0 warnings.'),
+ 0,
+ workingDirectory: packageRoot,
+ );
});
}
diff --git a/test/validator/language_version_test.dart b/test/validator/language_version_test.dart
index fc2351e..dea8444 100644
--- a/test/validator/language_version_test.dart
+++ b/test/validator/language_version_test.dart
@@ -12,8 +12,10 @@
Validator validator() => LanguageVersionValidator();
-Future<void> setup(
- {required String sdkConstraint, String? libraryLanguageVersion}) async {
+Future<void> setup({
+ required String sdkConstraint,
+ String? libraryLanguageVersion,
+}) async {
await d.validPackage.create();
await d.dir(appPath, [
d.pubspec({
@@ -38,13 +40,17 @@
test('opts in to older language versions', () async {
await setup(
- sdkConstraint: '>=2.4.0 <3.0.0', libraryLanguageVersion: '2.0');
+ sdkConstraint: '>=2.4.0 <3.0.0',
+ libraryLanguageVersion: '2.0',
+ );
await d.dir(appPath, []).create();
await expectValidation(validator);
});
test('opts in to same language versions', () async {
await setup(
- sdkConstraint: '>=2.4.0 <3.0.0', libraryLanguageVersion: '2.4');
+ sdkConstraint: '>=2.4.0 <3.0.0',
+ libraryLanguageVersion: '2.4',
+ );
await d.dir(appPath, []).create();
await expectValidation(validator);
});
@@ -60,7 +66,9 @@
group('should error if it', () {
test('opts in to a newer version.', () async {
await setup(
- sdkConstraint: '>=2.4.1 <3.0.0', libraryLanguageVersion: '2.5');
+ sdkConstraint: '>=2.4.1 <3.0.0',
+ libraryLanguageVersion: '2.5',
+ );
await expectValidation(validator, errors: isNotEmpty);
});
test('opts in to a newer version, with non-range constraint.', () async {
diff --git a/test/validator/leak_detection_test.dart b/test/validator/leak_detection_test.dart
index fc64c68..f16e145 100644
--- a/test/validator/leak_detection_test.dart
+++ b/test/validator/leak_detection_test.dart
@@ -82,11 +82,13 @@
'''),
])
]).create();
- await expectValidation(leakDetection,
- errors: allOf(
- hasLength(lessThanOrEqualTo(3)),
- contains(contains('10 potential leaks detected in 1 file:')),
- ));
+ await expectValidation(
+ leakDetection,
+ errors: allOf(
+ hasLength(lessThanOrEqualTo(3)),
+ contains(contains('10 potential leaks detected in 1 file:')),
+ ),
+ );
});
test('at-most 3 warnings when multiple files', () async {
@@ -115,11 +117,13 @@
'''),
])
]).create();
- await expectValidation(leakDetection,
- errors: allOf(
- hasLength(lessThanOrEqualTo(3)),
- contains(contains('12 potential leaks detected in 2 files:')),
- ));
+ await expectValidation(
+ leakDetection,
+ errors: allOf(
+ hasLength(lessThanOrEqualTo(3)),
+ contains(contains('12 potential leaks detected in 2 files:')),
+ ),
+ );
});
});
diff --git a/test/validator/null_safety_mixed_mode_test.dart b/test/validator/null_safety_mixed_mode_test.dart
deleted file mode 100644
index d62d051..0000000
--- a/test/validator/null_safety_mixed_mode_test.dart
+++ /dev/null
@@ -1,154 +0,0 @@
-// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'package:test/test.dart';
-
-import '../descriptor.dart' as d;
-import '../test_pub.dart';
-
-Future<void> expectValidation(error, int exitCode) async {
- await runPub(
- error: error,
- args: ['publish', '--dry-run'],
- environment: {'_PUB_TEST_SDK_VERSION': '2.12.0'},
- workingDirectory: d.path(appPath),
- exitCode: exitCode,
- );
-}
-
-Future<void> setup({
- required String sdkConstraint,
- Map dependencies = const {},
- Map devDependencies = const {},
- List<d.Descriptor> extraFiles = const [],
-}) async {
- await d.validPackage.create();
- await d.dir(appPath, [
- d.pubspec({
- 'name': 'test_pkg',
- 'description':
- 'A just long enough decription to fit the requirement of 60 characters',
- 'homepage': 'https://example.com/',
- 'version': '1.0.0',
- 'environment': {'sdk': sdkConstraint},
- 'dependencies': dependencies,
- 'dev_dependencies': devDependencies,
- }),
- ...extraFiles,
- ]).create();
-
- await pubGet(environment: {'_PUB_TEST_SDK_VERSION': '2.12.0'});
-}
-
-void main() {
- group('should consider a package valid if it', () {
- test('is not opting in to null-safety, but depends on package that is',
- () async {
- final server = await servePackages();
- server.serve(
- 'foo',
- '0.0.1',
- pubspec: {
- 'environment': {'sdk': '>=2.12.0<3.0.0'}
- },
- );
-
- await setup(
- sdkConstraint: '>=2.9.0 <3.0.0', dependencies: {'foo': '^0.0.1'});
- await expectValidation(contains('Package has 0 warnings.'), 0);
- });
- test('is opting in to null-safety and depends on package that is',
- () async {
- final server = await servePackages();
- server.serve(
- 'foo',
- '0.0.1',
- pubspec: {
- 'environment': {'sdk': '>=2.12.0<3.0.0'}
- },
- );
-
- await setup(
- sdkConstraint: '>=2.12.0 <3.0.0', dependencies: {'foo': '^0.0.1'});
- await expectValidation(contains('Package has 0 warnings.'), 0);
- });
-
- test('is opting in to null-safety has dev_dependency that is not',
- () async {
- final server = await servePackages();
- server.serve(
- 'foo',
- '0.0.1',
- pubspec: {
- 'environment': {'sdk': '>=2.9.0<3.0.0'}
- },
- );
-
- await setup(sdkConstraint: '>=2.12.0 <3.0.0', devDependencies: {
- 'foo': '^0.0.1',
- });
- await expectValidation(contains('Package has 0 warnings.'), 0);
- });
- });
-
- group('should consider a package invalid if it', () {
- test('is opting in to null-safety, but depends on package that is not',
- () async {
- final server = await servePackages();
- server.serve(
- 'foo',
- '0.0.1',
- pubspec: {
- 'environment': {'sdk': '>=2.9.0<3.0.0'}
- },
- );
-
- await setup(
- sdkConstraint: '>=2.12.0 <3.0.0', dependencies: {'foo': '^0.0.1'});
- await expectValidation(
- allOf(
- contains(
- 'package:foo is not opted into null safety in its pubspec.yaml:'),
- contains('Package has 1 warning.'),
- ),
- 65);
- });
-
- test('is opting in to null-safety, but has file opting out', () async {
- await setup(sdkConstraint: '>=2.12.0 <3.0.0', extraFiles: [
- d.dir('lib', [d.file('a.dart', '// @dart = 2.9\n')])
- ]);
- await expectValidation(
- allOf(
- contains('package:test_pkg/a.dart is opting out of null safety:'),
- contains('Package has 1 warning.'),
- ),
- 65);
- });
-
- test(
- 'is opting in to null-safety, but depends on package has file opting out',
- () async {
- final server = await servePackages();
- server.serve('foo', '0.0.1', pubspec: {
- 'environment': {'sdk': '>=2.12.0<3.0.0'}
- }, contents: [
- d.dir('lib', [
- d.file('foo.dart', '''
-// @dart = 2.9
- ''')
- ])
- ]);
-
- await setup(
- sdkConstraint: '>=2.12.0 <3.0.0', dependencies: {'foo': '^0.0.1'});
- await expectValidation(
- allOf(
- contains('package:foo/foo.dart is opting out of null safety:'),
- contains('Package has 1 warning.'),
- ),
- 65);
- });
- });
-}
diff --git a/test/validator/pubspec_typo_test.dart b/test/validator/pubspec_typo_test.dart
index bbe7db3..ebfacd9 100644
--- a/test/validator/pubspec_typo_test.dart
+++ b/test/validator/pubspec_typo_test.dart
@@ -82,8 +82,10 @@
})
]).create();
- await expectValidation(pubspecTypo,
- warnings: hasLength(lessThanOrEqualTo(3)));
+ await expectValidation(
+ pubspecTypo,
+ warnings: hasLength(lessThanOrEqualTo(3)),
+ );
});
});
}
diff --git a/test/validator/sdk_constraint_test.dart b/test/validator/sdk_constraint_test.dart
index 9f45748..0a0703a 100644
--- a/test/validator/sdk_constraint_test.dart
+++ b/test/validator/sdk_constraint_test.dart
@@ -20,14 +20,18 @@
});
test('has an SDK constraint without ^', () async {
- await d.dir(appPath,
- [d.libPubspec('test_pkg', '1.0.0', sdk: '>=1.8.0 <2.0.0')]).create();
+ await d.dir(
+ appPath,
+ [d.libPubspec('test_pkg', '1.0.0', sdk: '>=1.8.0 <2.0.0')],
+ ).create();
await expectValidation(sdkConstraint);
});
test('has an SDK constraint with ^', () async {
await d.dir(
- appPath, [d.libPubspec('test_pkg', '1.0.0', sdk: '^1.8.0')]).create();
+ appPath,
+ [d.libPubspec('test_pkg', '1.0.0', sdk: '^1.8.0')],
+ ).create();
await expectValidation(sdkConstraint);
});
@@ -67,11 +71,14 @@
group('should consider a package invalid if it', () {
test('has no upper bound SDK constraint', () async {
- await d.dir(appPath,
- [d.libPubspec('test_pkg', '1.0.0', sdk: '>=1.8.0')]).create();
- await expectValidation(sdkConstraint,
- errors:
- anyElement(contains('should have an upper bound constraint')));
+ await d.dir(
+ appPath,
+ [d.libPubspec('test_pkg', '1.0.0', sdk: '>=1.8.0')],
+ ).create();
+ await expectValidation(
+ sdkConstraint,
+ errors: anyElement(contains('should have an upper bound constraint')),
+ );
});
test('has no SDK constraint', () async {
@@ -81,9 +88,10 @@
'version': '1.0.0',
}),
]).create();
- await expectValidation(sdkConstraint,
- errors:
- anyElement(contains('should have an upper bound constraint')));
+ await expectValidation(
+ sdkConstraint,
+ errors: anyElement(contains('should have an upper bound constraint')),
+ );
});
test(
@@ -96,8 +104,10 @@
'environment': {'sdk': '>=1.18.0 <1.50.0', 'flutter': '^1.2.3'}
})
]).create();
- await expectValidation(sdkConstraint,
- errors: anyElement(contains('">=1.19.0 <1.50.0"')));
+ await expectValidation(
+ sdkConstraint,
+ errors: anyElement(contains('">=1.19.0 <1.50.0"')),
+ );
});
test('has a Flutter SDK constraint with no SDK constraint', () async {
@@ -108,8 +118,10 @@
'environment': {'flutter': '^1.2.3'}
})
]).create();
- await expectValidation(sdkConstraint,
- errors: anyElement(contains('"^1.19.0"')));
+ await expectValidation(
+ sdkConstraint,
+ errors: anyElement(contains('"^1.19.0"')),
+ );
});
test(
@@ -122,8 +134,10 @@
'environment': {'sdk': '>=2.0.0-dev.50.0 <2.0.0', 'fuchsia': '^1.2.3'}
})
]).create();
- await expectValidation(sdkConstraint,
- errors: anyElement(contains('"^2.0.0"')));
+ await expectValidation(
+ sdkConstraint,
+ errors: anyElement(contains('"^2.0.0"')),
+ );
});
test('has a Fuchsia SDK constraint with no SDK constraint', () async {
@@ -134,17 +148,24 @@
'environment': {'fuchsia': '^1.2.3'}
})
]).create();
- await expectValidation(sdkConstraint,
- errors: anyElement(contains('"^2.0.0"')));
+ await expectValidation(
+ sdkConstraint,
+ errors: anyElement(contains('"^2.0.0"')),
+ );
});
test('depends on a pre-release sdk from a non-pre-release', () async {
await d.dir(appPath, [
d.libPubspec('test_pkg', '1.0.0', sdk: '>=1.8.0-dev.1 <2.0.0')
]).create();
- await expectValidation(sdkConstraint,
- warnings: anyElement(contains(
- 'consider publishing the package as a pre-release instead')));
+ await expectValidation(
+ sdkConstraint,
+ warnings: anyElement(
+ contains(
+ 'consider publishing the package as a pre-release instead',
+ ),
+ ),
+ );
});
});
}
diff --git a/test/validator/size_test.dart b/test/validator/size_test.dart
index 0773bc1..9ee5013 100644
--- a/test/validator/size_test.dart
+++ b/test/validator/size_test.dart
@@ -33,28 +33,35 @@
await d.validPackage.create();
await expectSizeValidationError(
- equals('Your package is 100.0 MB. Hosted packages must '
- 'be smaller than 100 MB.'));
+ equals('Your package is 100.0 MB. Hosted packages must '
+ 'be smaller than 100 MB.'),
+ );
});
test('package is not under source control and .gitignore exists', () async {
await d.validPackage.create();
await d.dir(appPath, [d.file('.gitignore', 'ignored')]).create();
- await expectSizeValidationError(allOf(
+ await expectSizeValidationError(
+ allOf(
contains('Hosted packages must be smaller than 100 MB.'),
contains('Your .gitignore has no effect since your project '
- 'does not appear to be in version control.')));
+ 'does not appear to be in version control.'),
+ ),
+ );
});
test('package is under source control and no .gitignore exists', () async {
await d.validPackage.create();
await d.git(appPath).create();
- await expectSizeValidationError(allOf(
+ await expectSizeValidationError(
+ allOf(
contains('Hosted packages must be smaller than 100 MB.'),
contains('Consider adding a .gitignore to avoid including '
- 'temporary files.')));
+ 'temporary files.'),
+ ),
+ );
});
test('package is under source control and .gitignore exists', () async {
@@ -62,8 +69,9 @@
await d.git(appPath, [d.file('.gitignore', 'ignored')]).create();
await expectSizeValidationError(
- equals('Your package is 100.0 MB. Hosted packages must '
- 'be smaller than 100 MB.'));
+ equals('Your package is 100.0 MB. Hosted packages must '
+ 'be smaller than 100 MB.'),
+ );
});
});
}
diff --git a/test/validator/strict_dependencies_test.dart b/test/validator/strict_dependencies_test.dart
index 3f30efd..436c0d8 100644
--- a/test/validator/strict_dependencies_test.dart
+++ b/test/validator/strict_dependencies_test.dart
@@ -21,8 +21,12 @@
test('declares an "import" as a dependency in lib/', () async {
await d.dir(appPath, [
- d.libPubspec('test_pkg', '1.0.0',
- deps: {'silly_monkey': '^1.2.3'}, sdk: '>=1.8.0 <2.0.0'),
+ d.libPubspec(
+ 'test_pkg',
+ '1.0.0',
+ deps: {'silly_monkey': '^1.2.3'},
+ sdk: '>=1.8.0 <2.0.0',
+ ),
d.dir('lib', [
d.file('library.dart', r'''
import 'package:silly_monkey/silly_monkey.dart';
@@ -35,8 +39,12 @@
test('declares an "export" as a dependency in lib/', () async {
await d.dir(appPath, [
- d.libPubspec('test_pkg', '1.0.0',
- deps: {'silly_monkey': '^1.2.3'}, sdk: '>=1.8.0 <2.0.0'),
+ d.libPubspec(
+ 'test_pkg',
+ '1.0.0',
+ deps: {'silly_monkey': '^1.2.3'},
+ sdk: '>=1.8.0 <2.0.0',
+ ),
d.dir('lib', [
d.file('library.dart', r'''
export 'package:silly_monkey/silly_monkey.dart';
@@ -49,8 +57,12 @@
test('declares an "import" as a dependency in bin/', () async {
await d.dir(appPath, [
- d.libPubspec('test_pkg', '1.0.0',
- deps: {'silly_monkey': '^1.2.3'}, sdk: '>=1.8.0 <2.0.0'),
+ d.libPubspec(
+ 'test_pkg',
+ '1.0.0',
+ deps: {'silly_monkey': '^1.2.3'},
+ sdk: '>=1.8.0 <2.0.0',
+ ),
d.dir('bin', [
d.file('library.dart', r'''
import 'package:silly_monkey/silly_monkey.dart';
@@ -76,8 +88,13 @@
'declares an "$port" as a '
'${isDev ? 'dev ' : ''}dependency in $devDir/', () async {
await d.dir(appPath, [
- d.libPubspec('test_pkg', '1.0.0',
- deps: deps, devDeps: devDeps, sdk: '>=1.8.0 <2.0.0'),
+ d.libPubspec(
+ 'test_pkg',
+ '1.0.0',
+ deps: deps,
+ devDeps: devDeps,
+ sdk: '>=1.8.0 <2.0.0',
+ ),
d.dir(devDir, [
d.file('library.dart', '''
$port 'package:silly_monkey/silly_monkey.dart';
@@ -151,8 +168,12 @@
test('has analysis_options.yaml that excludes files', () async {
await d.dir(appPath, [
- d.libPubspec('test_pkg', '1.0.0',
- deps: {'silly_monkey': '^1.2.3'}, sdk: '>=1.8.0 <2.0.0'),
+ d.libPubspec(
+ 'test_pkg',
+ '1.0.0',
+ deps: {'silly_monkey': '^1.2.3'},
+ sdk: '>=1.8.0 <2.0.0',
+ ),
d.dir('lib', [
d.file('library.dart', r'''
import 'package:silly_monkey/silly_monkey.dart';
@@ -181,8 +202,12 @@
test('has lib/analysis_options.yaml that excludes files', () async {
await d.dir(appPath, [
- d.libPubspec('test_pkg', '1.0.0',
- deps: {'silly_monkey': '^1.2.3'}, sdk: '>=1.8.0 <2.0.0'),
+ d.libPubspec(
+ 'test_pkg',
+ '1.0.0',
+ deps: {'silly_monkey': '^1.2.3'},
+ sdk: '>=1.8.0 <2.0.0',
+ ),
d.dir('lib', [
d.file('library.dart', r'''
import 'package:silly_monkey/silly_monkey.dart';
@@ -227,9 +252,12 @@
import 'package:silly_monkey/silly_monkey.dart';
''').create();
- await expectValidation(strictDeps, errors: [
- matches('does not have silly_monkey in the `dependencies` section')
- ]);
+ await expectValidation(
+ strictDeps,
+ errors: [
+ matches('does not have silly_monkey in the `dependencies` section')
+ ],
+ );
});
test('does not declare an "export" as a dependency', () async {
@@ -237,9 +265,12 @@
export 'package:silly_monkey/silly_monkey.dart';
''').create();
- await expectValidation(strictDeps, errors: [
- matches('does not have silly_monkey in the `dependencies` section')
- ]);
+ await expectValidation(
+ strictDeps,
+ errors: [
+ matches('does not have silly_monkey in the `dependencies` section')
+ ],
+ );
});
test('has an invalid URI', () async {
@@ -254,8 +285,12 @@
for (var codeDir in ['bin', 'lib']) {
test('declares an "$port" as a devDependency for $codeDir/', () async {
await d.dir(appPath, [
- d.libPubspec('test_pkg', '1.0.0',
- devDeps: {'silly_monkey': '^1.2.3'}, sdk: '>=1.8.0 <2.0.0'),
+ d.libPubspec(
+ 'test_pkg',
+ '1.0.0',
+ devDeps: {'silly_monkey': '^1.2.3'},
+ sdk: '>=1.8.0 <2.0.0',
+ ),
d.dir(codeDir, [
d.file('library.dart', '''
$port 'package:silly_monkey/silly_monkey.dart';
@@ -281,10 +316,14 @@
]),
]).create();
- await expectValidation(strictDeps, warnings: [
- matches(
- 'does not have silly_monkey in the `dependencies` or `dev_dependencies` section')
- ]);
+ await expectValidation(
+ strictDeps,
+ warnings: [
+ matches(
+ 'does not have silly_monkey in the `dependencies` or `dev_dependencies` section',
+ )
+ ],
+ );
});
}
}
@@ -304,8 +343,12 @@
test('"package:silly_monkey"', () async {
await d.dir(appPath, [
- d.libPubspec('test_pkg', '1.0.0',
- deps: {'silly_monkey': '^1.2.3'}, sdk: '>=1.8.0 <2.0.0'),
+ d.libPubspec(
+ 'test_pkg',
+ '1.0.0',
+ deps: {'silly_monkey': '^1.2.3'},
+ sdk: '>=1.8.0 <2.0.0',
+ ),
d.dir('lib', [
d.file('library.dart', r'''
import 'package:silly_monkey';
diff --git a/test/validator/utils.dart b/test/validator/utils.dart
index 8a1c0e2..92fbeff 100644
--- a/test/validator/utils.dart
+++ b/test/validator/utils.dart
@@ -9,8 +9,13 @@
// TODO(sigurdm) consider rewriting all validator tests as integration tests.
// That would make them more robust, and test actual end2end behaviour.
-Future<void> expectValidation(ValidatorCreator fn,
- {hints, warnings, errors, int? size}) async {
+Future<void> expectValidation(
+ ValidatorCreator fn, {
+ hints,
+ warnings,
+ errors,
+ int? size,
+}) async {
final validator = await validatePackage(fn, size);
expect(validator.errors, errors ?? isEmpty);
expect(validator.warnings, warnings ?? isEmpty);
diff --git a/test/version_solver_test.dart b/test/version_solver_test.dart
index a2cbacc..394859e 100644
--- a/test/version_solver_test.dart
+++ b/test/version_solver_test.dart
@@ -48,15 +48,17 @@
..serve('ba', '1.0.0')
..serve('bb', '1.0.0');
- await d.appDir({'a': '1.0.0', 'b': '1.0.0'}).create();
- await expectResolves(result: {
- 'a': '1.0.0',
- 'aa': '1.0.0',
- 'ab': '1.0.0',
- 'b': '1.0.0',
- 'ba': '1.0.0',
- 'bb': '1.0.0'
- });
+ await d.appDir(dependencies: {'a': '1.0.0', 'b': '1.0.0'}).create();
+ await expectResolves(
+ result: {
+ 'a': '1.0.0',
+ 'aa': '1.0.0',
+ 'ab': '1.0.0',
+ 'b': '1.0.0',
+ 'ba': '1.0.0',
+ 'bb': '1.0.0'
+ },
+ );
});
test('shared dependency with overlapping constraints', () async {
@@ -69,9 +71,10 @@
..serve('shared', '4.0.0')
..serve('shared', '5.0.0');
- await d.appDir({'a': '1.0.0', 'b': '1.0.0'}).create();
+ await d.appDir(dependencies: {'a': '1.0.0', 'b': '1.0.0'}).create();
await expectResolves(
- result: {'a': '1.0.0', 'b': '1.0.0', 'shared': '3.6.9'});
+ result: {'a': '1.0.0', 'b': '1.0.0', 'shared': '3.6.9'},
+ );
});
test(
@@ -87,9 +90,10 @@
..serve('whoop', '1.0.0')
..serve('zoop', '1.0.0');
- await d.appDir({'foo': '<=1.0.2', 'bar': '1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '<=1.0.2', 'bar': '1.0.0'}).create();
await expectResolves(
- result: {'foo': '1.0.1', 'bar': '1.0.0', 'bang': '1.0.0'});
+ result: {'foo': '1.0.1', 'bar': '1.0.0', 'bang': '1.0.0'},
+ );
});
test('circular dependency', () async {
@@ -97,7 +101,7 @@
..serve('foo', '1.0.0', deps: {'bar': '1.0.0'})
..serve('bar', '1.0.0', deps: {'foo': '1.0.0'});
- await d.appDir({'foo': '1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '1.0.0'}).create();
await expectResolves(result: {'foo': '1.0.0', 'bar': '1.0.0'});
});
@@ -109,7 +113,7 @@
..serve('bar', '2.0.0', deps: {'baz': '1.0.0'})
..serve('baz', '1.0.0', deps: {'foo': '2.0.0'});
- await d.appDir({'foo': '1.0.0', 'bar': 'any'}).create();
+ await d.appDir(dependencies: {'foo': '1.0.0', 'bar': 'any'}).create();
await expectResolves(result: {'foo': '1.0.0', 'bar': '1.0.0'}, tries: 2);
});
}
@@ -124,10 +128,10 @@
..serve('bar', '1.0.1')
..serve('bar', '1.0.2');
- await d.appDir({'foo': '1.0.1'}).create();
+ await d.appDir(dependencies: {'foo': '1.0.1'}).create();
await expectResolves(result: {'foo': '1.0.1', 'bar': '1.0.1'});
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await expectResolves(result: {'foo': '1.0.1', 'bar': '1.0.1'});
});
@@ -140,10 +144,10 @@
..serve('bar', '1.0.1')
..serve('bar', '1.0.2');
- await d.appDir({'foo': '1.0.1'}).create();
+ await d.appDir(dependencies: {'foo': '1.0.1'}).create();
await expectResolves(result: {'foo': '1.0.1', 'bar': '1.0.1'});
- await d.appDir({'foo': '>1.0.1'}).create();
+ await d.appDir(dependencies: {'foo': '>1.0.1'}).create();
await expectResolves(result: {'foo': '1.0.2', 'bar': '1.0.2'});
});
@@ -157,10 +161,10 @@
..serve('bar', '1.0.2')
..serve('baz', '1.0.0');
- await d.appDir({'baz': '1.0.0'}).create();
+ await d.appDir(dependencies: {'baz': '1.0.0'}).create();
await expectResolves(result: {'baz': '1.0.0'});
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await expectResolves(result: {'foo': '1.0.2', 'bar': '1.0.2'});
});
@@ -178,22 +182,22 @@
..serve('qux', '2.0.0')
..serve('newdep', '2.0.0', deps: {'baz': '>=1.5.0'});
- await d.appDir({'foo': '1.0.0'}).create();
- await expectResolves(result: {
- 'foo': '1.0.0',
- 'bar': '1.0.0',
- 'baz': '1.0.0',
- 'qux': '1.0.0'
- });
+ await d.appDir(dependencies: {'foo': '1.0.0'}).create();
+ await expectResolves(
+ result: {'foo': '1.0.0', 'bar': '1.0.0', 'baz': '1.0.0', 'qux': '1.0.0'},
+ );
- await d.appDir({'foo': 'any', 'newdep': '2.0.0'}).create();
- await expectResolves(result: {
- 'foo': '2.0.0',
- 'bar': '2.0.0',
- 'baz': '2.0.0',
- 'qux': '1.0.0',
- 'newdep': '2.0.0'
- }, tries: 2);
+ await d.appDir(dependencies: {'foo': 'any', 'newdep': '2.0.0'}).create();
+ await expectResolves(
+ result: {
+ 'foo': '2.0.0',
+ 'bar': '2.0.0',
+ 'baz': '2.0.0',
+ 'qux': '1.0.0',
+ 'newdep': '2.0.0'
+ },
+ tries: 2,
+ );
});
// Issue 1853
@@ -205,15 +209,17 @@
..serve('bar', '1.0.0')
..serve('bar', '2.0.0');
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await expectResolves(result: {'foo': '1.0.0', 'bar': '2.0.0'});
- await d.appDir({'foo': 'any', 'bar': '<2.0.0'}).create();
- await expectResolves(error: equalsIgnoringWhitespace('''
+ await d.appDir(dependencies: {'foo': 'any', 'bar': '<2.0.0'}).create();
+ await expectResolves(
+ error: equalsIgnoringWhitespace('''
Because myapp depends on foo any which depends on bar >=2.0.0,
bar >=2.0.0 is required.
So, because myapp depends on bar <2.0.0, version solving failed.
- '''));
+ '''),
+ );
});
}
@@ -222,18 +228,22 @@
final server = await servePackages();
server.serve('foo', '1.0.0', deps: {'myapp': 'any'});
- await d.appDir({'foo': '1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '1.0.0'}).create();
await expectResolves(result: {'foo': '1.0.0'});
});
test('with mismatched sources', () async {
await servePackages()
..serve('foo', '1.0.0', deps: {'myapp': 'any'})
- ..serve('bar', '1.0.0', deps: {
- 'myapp': {'git': 'http://nowhere.com/'}
- });
+ ..serve(
+ 'bar',
+ '1.0.0',
+ deps: {
+ 'myapp': {'git': 'http://nowhere.com/'}
+ },
+ );
- await d.appDir({'foo': '1.0.0', 'bar': '1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '1.0.0', 'bar': '1.0.0'}).create();
await expectResolves(result: {'foo': '1.0.0', 'bar': '1.0.0'});
});
@@ -241,12 +251,14 @@
final server = await servePackages();
server.serve('foo', '1.0.0', deps: {'myapp': '>0.0.0'});
- await d.appDir({'foo': '1.0.0'}).create();
- await expectResolves(error: equalsIgnoringWhitespace('''
+ await d.appDir(dependencies: {'foo': '1.0.0'}).create();
+ await expectResolves(
+ error: equalsIgnoringWhitespace('''
Because myapp depends on foo 1.0.0 which depends on myapp >0.0.0,
myapp >0.0.0 is required.
So, because myapp is 0.0.0, version solving failed.
- '''));
+ '''),
+ );
});
}
@@ -283,11 +295,15 @@
test("ignores transitive dependency's dev dependencies", () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', pubspec: {
- 'dev_dependencies': {'bar': '1.0.0'}
- });
+ server.serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'dev_dependencies': {'bar': '1.0.0'}
+ },
+ );
- await d.appDir({'foo': '1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '1.0.0'}).create();
await expectResolves(result: {'foo': '1.0.0'});
});
@@ -321,11 +337,13 @@
})
]).create();
- await expectResolves(error: equalsIgnoringWhitespace('''
+ await expectResolves(
+ error: equalsIgnoringWhitespace('''
Because no versions of foo match ^2.0.0 and myapp depends on foo
>=1.0.0 <3.0.0, foo ^1.0.0 is required.
So, because myapp depends on foo >=2.0.0 <4.0.0, version solving failed.
- '''));
+ '''),
+ );
});
test("fails when dev dependency isn't satisfied", () async {
@@ -340,11 +358,13 @@
})
]).create();
- await expectResolves(error: equalsIgnoringWhitespace('''
+ await expectResolves(
+ error: equalsIgnoringWhitespace('''
Because no versions of foo match ^2.0.0 and myapp depends on foo
>=1.0.0 <3.0.0, foo ^1.0.0 is required.
So, because myapp depends on foo >=2.0.0 <4.0.0, version solving failed.
- '''));
+ '''),
+ );
});
test('fails when dev and main constraints are incompatible', () async {
@@ -359,10 +379,12 @@
})
]).create();
- await expectResolves(error: equalsIgnoringWhitespace('''
+ await expectResolves(
+ error: equalsIgnoringWhitespace('''
Because myapp depends on both foo ^1.0.0 and foo ^2.0.0, version
solving failed.
- '''));
+ '''),
+ );
});
test('fails when dev and main sources are incompatible', () async {
@@ -379,10 +401,12 @@
})
]).create();
- await expectResolves(error: equalsIgnoringWhitespace('''
+ await expectResolves(
+ error: equalsIgnoringWhitespace('''
Because myapp depends on both foo from hosted and foo from path, version
solving failed.
- '''));
+ '''),
+ );
});
test('fails when dev and main descriptions are incompatible', () async {
@@ -401,10 +425,12 @@
})
]).create();
- await expectResolves(error: equalsIgnoringWhitespace('''
+ await expectResolves(
+ error: equalsIgnoringWhitespace('''
Because myapp depends on both foo from path foo and foo from path
..${Platform.pathSeparator}foo, version solving failed.
- '''));
+ '''),
+ );
});
});
}
@@ -415,11 +441,13 @@
..serve('foo', '2.0.0')
..serve('foo', '2.1.3');
- await d.appDir({'foo': '>=1.0.0 <2.0.0'}).create();
- await expectResolves(error: equalsIgnoringWhitespace("""
+ await d.appDir(dependencies: {'foo': '>=1.0.0 <2.0.0'}).create();
+ await expectResolves(
+ error: equalsIgnoringWhitespace("""
Because myapp depends on foo ^1.0.0 which doesn't match any versions,
version solving failed.
- """));
+ """),
+ );
});
test('no version that matches combined constraint', () async {
@@ -429,8 +457,9 @@
..serve('shared', '2.5.0')
..serve('shared', '3.5.0');
- await d.appDir({'foo': '1.0.0', 'bar': '1.0.0'}).create();
- await expectResolves(error: equalsIgnoringWhitespace('''
+ await d.appDir(dependencies: {'foo': '1.0.0', 'bar': '1.0.0'}).create();
+ await expectResolves(
+ error: equalsIgnoringWhitespace('''
Because every version of foo depends on shared ^2.0.0 and no versions of
shared match ^2.9.0, every version of foo requires
shared >=2.0.0 <2.9.0.
@@ -438,7 +467,8 @@
incompatible with foo.
So, because myapp depends on both foo 1.0.0 and bar 1.0.0, version
solving failed.
- '''));
+ '''),
+ );
});
test('disjoint constraints', () async {
@@ -448,13 +478,15 @@
..serve('shared', '2.0.0')
..serve('shared', '4.0.0');
- await d.appDir({'foo': '1.0.0', 'bar': '1.0.0'}).create();
- await expectResolves(error: equalsIgnoringWhitespace('''
+ await d.appDir(dependencies: {'foo': '1.0.0', 'bar': '1.0.0'}).create();
+ await expectResolves(
+ error: equalsIgnoringWhitespace('''
Because every version of bar depends on shared >3.0.0 and every version
of foo depends on shared <=2.0.0, bar is incompatible with foo.
So, because myapp depends on both foo 1.0.0 and bar 1.0.0, version
solving failed.
- '''));
+ '''),
+ );
});
test('mismatched descriptions', () async {
@@ -463,26 +495,32 @@
await servePackages()
..serve('foo', '1.0.0', deps: {'shared': '1.0.0'})
- ..serve('bar', '1.0.0', deps: {
- 'shared': {
- 'hosted': {'name': 'shared', 'url': otherServer.url},
- 'version': '1.0.0'
- }
- })
+ ..serve(
+ 'bar',
+ '1.0.0',
+ deps: {
+ 'shared': {
+ 'hosted': {'name': 'shared', 'url': otherServer.url},
+ 'version': '1.0.0'
+ }
+ },
+ )
..serve('shared', '1.0.0');
- await d.appDir({'foo': '1.0.0', 'bar': '1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '1.0.0', 'bar': '1.0.0'}).create();
await expectResolves(
- error: allOf([
- contains('Because every version of bar depends on shared from hosted on '
- 'http://localhost:'),
- contains(' and every version of foo depends on shared from hosted on '
- 'http://localhost:'),
- contains(', bar is incompatible with foo.'),
- contains('So, because myapp depends on both foo 1.0.0 and bar 1.0.0, '
- 'version solving failed.')
- ]));
+ error: allOf([
+ contains(
+ 'Because every version of bar depends on shared from hosted on '
+ 'http://localhost:'),
+ contains(' and every version of foo depends on shared from hosted on '
+ 'http://localhost:'),
+ contains(', bar is incompatible with foo.'),
+ contains('So, because myapp depends on both foo 1.0.0 and bar 1.0.0, '
+ 'version solving failed.')
+ ]),
+ );
});
test('mismatched sources', () async {
@@ -490,19 +528,25 @@
await servePackages()
..serve('foo', '1.0.0', deps: {'shared': '1.0.0'})
- ..serve('bar', '1.0.0', deps: {
- 'shared': {'path': p.join(d.sandbox, 'shared')}
- })
+ ..serve(
+ 'bar',
+ '1.0.0',
+ deps: {
+ 'shared': {'path': p.join(d.sandbox, 'shared')}
+ },
+ )
..serve('shared', '1.0.0');
- await d.appDir({'foo': '1.0.0', 'bar': '1.0.0'}).create();
- await expectResolves(error: equalsIgnoringWhitespace('''
+ await d.appDir(dependencies: {'foo': '1.0.0', 'bar': '1.0.0'}).create();
+ await expectResolves(
+ error: equalsIgnoringWhitespace('''
Because every version of bar depends on shared from path and every
version of foo depends on shared from hosted, bar is incompatible with
foo.
So, because myapp depends on both foo 1.0.0 and bar 1.0.0, version
solving failed.
- '''));
+ '''),
+ );
});
test('no valid solution', () async {
@@ -512,15 +556,18 @@
..serve('b', '1.0.0', deps: {'a': '2.0.0'})
..serve('b', '2.0.0', deps: {'a': '1.0.0'});
- await d.appDir({'a': 'any', 'b': 'any'}).create();
- await expectResolves(error: equalsIgnoringWhitespace('''
+ await d.appDir(dependencies: {'a': 'any', 'b': 'any'}).create();
+ await expectResolves(
+ error: equalsIgnoringWhitespace('''
Because b <2.0.0 depends on a 2.0.0 which depends on b 2.0.0, b <2.0.0 is
forbidden.
Because b >=2.0.0 depends on a 1.0.0 which depends on b 1.0.0, b >=2.0.0
is forbidden.
Thus, b is forbidden.
So, because myapp depends on b any, version solving failed.
- '''), tries: 2);
+ '''),
+ tries: 2,
+ );
});
// This is a regression test for #15550.
@@ -529,47 +576,65 @@
..serve('a', '1.0.0')
..serve('b', '1.0.0');
- await d.appDir({'a': 'any', 'b': '>1.0.0'}).create();
- await expectResolves(error: equalsIgnoringWhitespace("""
+ await d.appDir(dependencies: {'a': 'any', 'b': '>1.0.0'}).create();
+ await expectResolves(
+ error: equalsIgnoringWhitespace("""
Because myapp depends on b >1.0.0 which doesn't match any versions,
version solving failed.
- """));
+ """),
+ );
});
// This is a regression test for #18300.
test('issue 18300', () async {
await servePackages()
..serve('analyzer', '0.12.2')
- ..serve('angular', '0.10.0',
- deps: {'di': '>=0.0.32 <0.1.0', 'collection': '>=0.9.1 <1.0.0'})
- ..serve('angular', '0.9.11',
- deps: {'di': '>=0.0.32 <0.1.0', 'collection': '>=0.9.1 <1.0.0'})
- ..serve('angular', '0.9.10',
- deps: {'di': '>=0.0.32 <0.1.0', 'collection': '>=0.9.1 <1.0.0'})
+ ..serve(
+ 'angular',
+ '0.10.0',
+ deps: {'di': '>=0.0.32 <0.1.0', 'collection': '>=0.9.1 <1.0.0'},
+ )
+ ..serve(
+ 'angular',
+ '0.9.11',
+ deps: {'di': '>=0.0.32 <0.1.0', 'collection': '>=0.9.1 <1.0.0'},
+ )
+ ..serve(
+ 'angular',
+ '0.9.10',
+ deps: {'di': '>=0.0.32 <0.1.0', 'collection': '>=0.9.1 <1.0.0'},
+ )
..serve('collection', '0.9.0')
..serve('collection', '0.9.1')
..serve('di', '0.0.37', deps: {'analyzer': '>=0.13.0 <0.14.0'})
..serve('di', '0.0.36', deps: {'analyzer': '>=0.13.0 <0.14.0'});
- await d.appDir({'angular': 'any', 'collection': 'any'}).create();
- await expectResolves(error: equalsIgnoringWhitespace('''
+ await d
+ .appDir(dependencies: {'angular': 'any', 'collection': 'any'}).create();
+ await expectResolves(
+ error: equalsIgnoringWhitespace('''
Because every version of angular depends on di ^0.0.32 which depends on
analyzer ^0.13.0, every version of angular requires analyzer ^0.13.0.
So, because no versions of analyzer match ^0.13.0 and myapp depends on
angular any, version solving failed.
- '''));
+ '''),
+ );
});
}
void badSource() {
test('fail if the root package has a bad source in dep', () async {
- await d.appDir({
- 'foo': {'bad': 'any'}
- }).create();
- await expectResolves(error: equalsIgnoringWhitespace('''
+ await d.appDir(
+ dependencies: {
+ 'foo': {'bad': 'any'}
+ },
+ ).create();
+ await expectResolves(
+ error: equalsIgnoringWhitespace('''
Because myapp depends on foo from unknown source "bad", version solving
failed.
- '''));
+ '''),
+ );
});
test('fail if the root package has a bad source in dev dep', () async {
@@ -582,26 +647,41 @@
})
]).create();
- await expectResolves(error: equalsIgnoringWhitespace('''
+ await expectResolves(
+ error: equalsIgnoringWhitespace('''
Because myapp depends on foo from unknown source "bad", version solving
failed.
- '''));
+ '''),
+ );
});
test('fail if all versions have bad source in dep', () async {
await servePackages()
- ..serve('foo', '1.0.0', deps: {
- 'bar': {'bad': 'any'}
- })
- ..serve('foo', '1.0.1', deps: {
- 'baz': {'bad': 'any'}
- })
- ..serve('foo', '1.0.2', deps: {
- 'bang': {'bad': 'any'}
- });
+ ..serve(
+ 'foo',
+ '1.0.0',
+ deps: {
+ 'bar': {'bad': 'any'}
+ },
+ )
+ ..serve(
+ 'foo',
+ '1.0.1',
+ deps: {
+ 'baz': {'bad': 'any'}
+ },
+ )
+ ..serve(
+ 'foo',
+ '1.0.2',
+ deps: {
+ 'bang': {'bad': 'any'}
+ },
+ );
- await d.appDir({'foo': 'any'}).create();
- await expectResolves(error: equalsIgnoringWhitespace('''
+ await d.appDir(dependencies: {'foo': 'any'}).create();
+ await expectResolves(
+ error: equalsIgnoringWhitespace('''
Because foo <1.0.1 depends on bar from unknown source "bad", foo <1.0.1 is
forbidden.
And because foo >=1.0.1 <1.0.2 depends on baz from bad, foo <1.0.2
@@ -610,21 +690,31 @@
bang from bad, every version of foo requires bang from bad.
So, because bang comes from unknown source "bad" and myapp depends on foo any,
version solving failed.
- '''), tries: 3);
+ '''),
+ tries: 3,
+ );
});
test('ignore versions with bad source in dep', () async {
await servePackages()
..serve('foo', '1.0.0', deps: {'bar': 'any'})
- ..serve('foo', '1.0.1', deps: {
- 'bar': {'bad': 'any'}
- })
- ..serve('foo', '1.0.2', deps: {
- 'bar': {'bad': 'any'}
- })
+ ..serve(
+ 'foo',
+ '1.0.1',
+ deps: {
+ 'bar': {'bad': 'any'}
+ },
+ )
+ ..serve(
+ 'foo',
+ '1.0.2',
+ deps: {
+ 'bar': {'bad': 'any'}
+ },
+ )
..serve('bar', '1.0.0');
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await expectResolves(result: {'foo': '1.0.0', 'bar': '1.0.0'}, tries: 2);
});
@@ -636,16 +726,20 @@
..serve('baz', '1.0.0');
await d.dir('baz', [d.libPubspec('baz', '1.0.0')]).create();
- await d.appDir({
- 'foo': 'any',
- 'baz': {'path': '../baz'}
- }).create();
- await expectResolves(error: equalsIgnoringWhitespace('''
+ await d.appDir(
+ dependencies: {
+ 'foo': 'any',
+ 'baz': {'path': '../baz'}
+ },
+ ).create();
+ await expectResolves(
+ error: equalsIgnoringWhitespace('''
Because every version of foo depends on bar any which depends on baz any,
every version of foo requires baz from hosted.
So, because myapp depends on both foo any and baz from path, version
solving failed.
- '''));
+ '''),
+ );
});
}
@@ -656,7 +750,7 @@
..serve('a', '2.0.0', deps: {'b': '1.0.0'})
..serve('b', '1.0.0', deps: {'a': '1.0.0'});
- await d.appDir({'a': '>=1.0.0'}).create();
+ await d.appDir(dependencies: {'a': '>=1.0.0'}).create();
await expectResolves(result: {'a': '1.0.0'}, tries: 2);
});
@@ -670,7 +764,7 @@
..serve('c', '2.0.0')
..serve('c', '1.0.0');
- await d.appDir({'a': 'any', 'b': 'any'}).create();
+ await d.appDir(dependencies: {'a': 'any', 'b': 'any'}).create();
await expectResolves(result: {'a': '1.0.0', 'b': '2.0.0', 'c': '3.0.0'});
});
@@ -689,7 +783,7 @@
..serve('y', '1.0.0')
..serve('y', '2.0.0');
- await d.appDir({'c': 'any', 'y': '^2.0.0'}).create();
+ await d.appDir(dependencies: {'c': 'any', 'y': '^2.0.0'}).create();
await expectResolves(result: {'c': '1.0.0', 'y': '2.0.0'}, tries: 2);
});
@@ -706,23 +800,24 @@
..serve('y', '1.0.0')
..serve('y', '2.0.0');
- await d.appDir({'foo': '^1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '^1.0.0'}).create();
await expectResolves(
- // We avoid equalsIgnoringWhitespace() here because we want to test the
- // formatting of the line number.
- error: ' Because foo <1.1.0 depends on a ^1.0.0 which depends on b '
- '^2.0.0, foo <1.1.0 requires b ^2.0.0.\n'
- '(1) So, because foo <1.1.0 depends on b ^1.0.0, foo <1.1.0 is '
- 'forbidden.\n'
- '\n'
- ' Because foo >=1.1.0 depends on x ^1.0.0 which depends on y '
- '^2.0.0, foo >=1.1.0 requires y ^2.0.0.\n'
- ' And because foo >=1.1.0 depends on y ^1.0.0, foo >=1.1.0 is '
- 'forbidden.\n'
- ' And because foo <1.1.0 is forbidden (1), foo is forbidden.\n'
- ' So, because myapp depends on foo ^1.0.0, version solving '
- 'failed.',
- tries: 2);
+ // We avoid equalsIgnoringWhitespace() here because we want to test the
+ // formatting of the line number.
+ error: ' Because foo <1.1.0 depends on a ^1.0.0 which depends on b '
+ '^2.0.0, foo <1.1.0 requires b ^2.0.0.\n'
+ '(1) So, because foo <1.1.0 depends on b ^1.0.0, foo <1.1.0 is '
+ 'forbidden.\n'
+ '\n'
+ ' Because foo >=1.1.0 depends on x ^1.0.0 which depends on y '
+ '^2.0.0, foo >=1.1.0 requires y ^2.0.0.\n'
+ ' And because foo >=1.1.0 depends on y ^1.0.0, foo >=1.1.0 is '
+ 'forbidden.\n'
+ ' And because foo <1.1.0 is forbidden (1), foo is forbidden.\n'
+ ' So, because myapp depends on foo ^1.0.0, version solving '
+ 'failed.',
+ tries: 2,
+ );
});
// The latest versions of a and b disagree on c. An older version of either
@@ -737,7 +832,7 @@
..serve('c', '1.0.0')
..serve('c', '2.0.0');
- await d.appDir({'a': 'any'}).create();
+ await d.appDir(dependencies: {'a': 'any'}).create();
await expectResolves(result: {'a': '2.0.0', 'b': '1.0.0', 'c': '2.0.0'});
});
@@ -753,9 +848,11 @@
..serve('bar', '3.0.0', deps: {'baz': '3.0.0'})
..serve('baz', '1.0.0');
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await expectResolves(
- result: {'foo': '1.0.0', 'bar': '1.0.0', 'baz': '1.0.0'}, tries: 3);
+ result: {'foo': '1.0.0', 'bar': '1.0.0', 'baz': '1.0.0'},
+ tries: 3,
+ );
});
// This ensures it doesn't exhaustively search all versions of b when it's
@@ -771,9 +868,11 @@
..serve('b', '3.0.0')
..serve('c', '1.0.0');
- await d.appDir({'a': 'any', 'b': 'any'}).create();
+ await d.appDir(dependencies: {'a': 'any', 'b': 'any'}).create();
await expectResolves(
- result: {'a': '1.0.0', 'b': '3.0.0', 'c': '1.0.0'}, tries: 2);
+ result: {'a': '1.0.0', 'b': '3.0.0', 'c': '1.0.0'},
+ tries: 2,
+ );
});
// Tests that the backjumper will jump past unrelated selections when a
@@ -796,16 +895,20 @@
await servePackages()
..serve('a', '1.0.0')
..serve('b', '1.0.0', deps: {'a': 'any'})
- ..serve('b', '2.0.0', deps: {
- 'a': {'path': p.join(d.sandbox, 'a')}
- })
+ ..serve(
+ 'b',
+ '2.0.0',
+ deps: {
+ 'a': {'path': p.join(d.sandbox, 'a')}
+ },
+ )
..serve('c', '1.0.0')
..serve('c', '2.0.0')
..serve('c', '3.0.0')
..serve('c', '4.0.0')
..serve('c', '5.0.0');
- await d.appDir({'a': 'any', 'b': 'any', 'c': 'any'}).create();
+ await d.appDir(dependencies: {'a': 'any', 'b': 'any', 'c': 'any'}).create();
await expectResolves(result: {'a': '1.0.0', 'b': '1.0.0', 'c': '5.0.0'});
});
@@ -817,18 +920,22 @@
await servePackages()
..serve('a', '1.0.0')
..serve('b', '1.0.0', deps: {'a': 'any'})
- ..serve('b', '2.0.0', deps: {
- 'a': {
- 'hosted': {'name': 'a', 'url': otherServer.url}
- }
- })
+ ..serve(
+ 'b',
+ '2.0.0',
+ deps: {
+ 'a': {
+ 'hosted': {'name': 'a', 'url': otherServer.url}
+ }
+ },
+ )
..serve('c', '1.0.0')
..serve('c', '2.0.0')
..serve('c', '3.0.0')
..serve('c', '4.0.0')
..serve('c', '5.0.0');
- await d.appDir({'a': 'any', 'b': 'any', 'c': 'any'}).create();
+ await d.appDir(dependencies: {'a': 'any', 'b': 'any', 'c': 'any'}).create();
await expectResolves(result: {'a': '1.0.0', 'b': '1.0.0', 'c': '5.0.0'});
});
@@ -839,21 +946,27 @@
await servePackages()
..serve('a', '1.0.0')
- ..serve('b', '1.0.0', deps: {
- 'a': {'path': p.join(d.sandbox, 'shared')}
- })
+ ..serve(
+ 'b',
+ '1.0.0',
+ deps: {
+ 'a': {'path': p.join(d.sandbox, 'shared')}
+ },
+ )
..serve('c', '1.0.0')
..serve('c', '2.0.0')
..serve('c', '3.0.0')
..serve('c', '4.0.0')
..serve('c', '5.0.0');
- await d.appDir({'a': 'any', 'b': 'any', 'c': 'any'}).create();
- await expectResolves(error: equalsIgnoringWhitespace('''
+ await d.appDir(dependencies: {'a': 'any', 'b': 'any', 'c': 'any'}).create();
+ await expectResolves(
+ error: equalsIgnoringWhitespace('''
Because every version of b depends on a from path and myapp depends on
a from hosted, b is forbidden.
So, because myapp depends on b any, version solving failed.
- '''));
+ '''),
+ );
});
test('failing backjump to conflicting description', () async {
@@ -862,26 +975,31 @@
await servePackages()
..serve('a', '1.0.0')
- ..serve('b', '1.0.0', deps: {
- 'a': {
- 'hosted': {'name': 'a', 'url': otherServer.url}
- }
- })
+ ..serve(
+ 'b',
+ '1.0.0',
+ deps: {
+ 'a': {
+ 'hosted': {'name': 'a', 'url': otherServer.url}
+ }
+ },
+ )
..serve('c', '1.0.0')
..serve('c', '2.0.0')
..serve('c', '3.0.0')
..serve('c', '4.0.0')
..serve('c', '5.0.0');
- await d.appDir({'a': 'any', 'b': 'any', 'c': 'any'}).create();
+ await d.appDir(dependencies: {'a': 'any', 'b': 'any', 'c': 'any'}).create();
await expectResolves(
- error: allOf([
- contains('Because every version of b depends on a from hosted on '
- 'http://localhost:'),
- contains(' and myapp depends on a from hosted on http://localhost:'),
- contains(', b is forbidden.'),
- contains('So, because myapp depends on b any, version solving failed.')
- ]));
+ error: allOf([
+ contains('Because every version of b depends on a from hosted on '
+ 'http://localhost:'),
+ contains(' and myapp depends on a from hosted on http://localhost:'),
+ contains(', b is forbidden.'),
+ contains('So, because myapp depends on b any, version solving failed.')
+ ]),
+ );
});
// Dependencies are ordered so that packages with fewer versions are tried
@@ -903,7 +1021,7 @@
..serve('c', '1.0.0')
..serve('c', '2.0.0');
- await d.appDir({'a': 'any', 'b': 'any'}).create();
+ await d.appDir(dependencies: {'a': 'any', 'b': 'any'}).create();
await expectResolves(result: {'a': '4.0.0', 'b': '4.0.0', 'c': '2.0.0'});
});
@@ -922,9 +1040,11 @@
}
}
- await d.appDir({'foo': 'any', 'bar': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any', 'bar': 'any'}).create();
await expectResolves(
- result: {'foo': '0.9.0', 'bar': '9.0.0', 'baz': '0.0.0'}, tries: 10);
+ result: {'foo': '0.9.0', 'bar': '9.0.0', 'baz': '0.0.0'},
+ tries: 10,
+ );
});
// If there's a disjoint constraint on a package, then selecting other
@@ -932,19 +1052,27 @@
// to jump past it to the most recent package that affected the constraint.
test('backjump past failed package on disjoint constraint', () async {
await servePackages()
- ..serve('a', '1.0.0', deps: {
- 'foo': 'any' // ok
- })
- ..serve('a', '2.0.0', deps: {
- 'foo': '<1.0.0' // disjoint with myapp's constraint on foo
- })
+ ..serve(
+ 'a',
+ '1.0.0',
+ deps: {
+ 'foo': 'any' // ok
+ },
+ )
+ ..serve(
+ 'a',
+ '2.0.0',
+ deps: {
+ 'foo': '<1.0.0' // disjoint with myapp's constraint on foo
+ },
+ )
..serve('foo', '2.0.0')
..serve('foo', '2.0.1')
..serve('foo', '2.0.2')
..serve('foo', '2.0.3')
..serve('foo', '2.0.4');
- await d.appDir({'a': 'any', 'foo': '>2.0.0'}).create();
+ await d.appDir(dependencies: {'a': 'any', 'foo': '>2.0.0'}).create();
await expectResolves(result: {'a': '1.0.0', 'foo': '2.0.4'});
});
@@ -961,9 +1089,10 @@
..serve('d', '2.0.0', deps: {'myapp': 'any'})
..serve('d', '1.0.0', deps: {'myapp': '<1.0.0'});
- await d.appDir({'a': 'any', 'c': 'any', 'd': 'any'}).create();
+ await d.appDir(dependencies: {'a': 'any', 'c': 'any', 'd': 'any'}).create();
await expectResolves(
- result: {'a': '1.0.0', 'b': '1.0.0', 'c': '1.0.0', 'd': '2.0.0'});
+ result: {'a': '1.0.0', 'b': '1.0.0', 'c': '1.0.0', 'd': '2.0.0'},
+ );
});
}
@@ -972,7 +1101,7 @@
await d.dir(appPath, [
d.pubspec({
'name': 'myapp',
- 'environment': {'sdk': '0.1.2+3'}
+ 'environment': {'sdk': '3.1.2+3'}
})
]).create();
@@ -983,85 +1112,131 @@
await d.dir(appPath, [
d.pubspec({
'name': 'myapp',
- 'environment': {'sdk': '0.0.0'}
+ 'environment': {'sdk': '2.12.0'}
})
]).create();
- await expectResolves(error: equalsIgnoringWhitespace('''
- The current Dart SDK version is 0.1.2+3.
+ await expectResolves(
+ error: equalsIgnoringWhitespace('''
+ The current Dart SDK version is 3.1.2+3.
- Because myapp requires SDK version 0.0.0, version solving failed.
- '''));
+ Because myapp requires SDK version 2.12.0, version solving failed.
+ '''),
+ );
});
test('dependency does not match SDK', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', pubspec: {
- 'environment': {'sdk': '0.0.0'}
- });
+ server.serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'environment': {'sdk': '2.12.0'}
+ },
+ );
- await d.appDir({'foo': 'any'}).create();
- await expectResolves(error: equalsIgnoringWhitespace('''
- The current Dart SDK version is 0.1.2+3.
+ await d.appDir(dependencies: {'foo': 'any'}).create();
+ await expectResolves(
+ error: equalsIgnoringWhitespace('''
+ The current Dart SDK version is 3.1.2+3.
- Because myapp depends on foo any which requires SDK version 0.0.0, version
+ Because myapp depends on foo any which requires SDK version 2.12.0, version
solving failed.
- '''));
+ '''),
+ );
});
test('transitive dependency does not match SDK', () async {
await servePackages()
..serve('foo', '1.0.0', deps: {'bar': 'any'})
- ..serve('bar', '1.0.0', pubspec: {
- 'environment': {'sdk': '0.0.0'}
- });
+ ..serve(
+ 'bar',
+ '1.0.0',
+ pubspec: {
+ 'environment': {'sdk': '2.12.0'}
+ },
+ );
- await d.appDir({'foo': 'any'}).create();
- await expectResolves(error: equalsIgnoringWhitespace('''
- The current Dart SDK version is 0.1.2+3.
+ await d.appDir(dependencies: {'foo': 'any'}).create();
+ await expectResolves(
+ error: equalsIgnoringWhitespace('''
+ The current Dart SDK version is 3.1.2+3.
Because every version of foo depends on bar any which requires SDK version
- 0.0.0, foo is forbidden.
+ 2.12.0, foo is forbidden.
So, because myapp depends on foo any, version solving failed.
- '''));
+ '''),
+ );
});
test('selects a dependency version that allows the SDK', () async {
await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'environment': {'sdk': '0.1.2+3'}
- })
- ..serve('foo', '2.0.0', pubspec: {
- 'environment': {'sdk': '0.1.2+3'}
- })
- ..serve('foo', '3.0.0', pubspec: {
- 'environment': {'sdk': '0.0.0'}
- })
- ..serve('foo', '4.0.0', pubspec: {
- 'environment': {'sdk': '0.0.0'}
- });
+ ..serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'environment': {'sdk': '3.1.2+3'}
+ },
+ )
+ ..serve(
+ 'foo',
+ '2.0.0',
+ pubspec: {
+ 'environment': {'sdk': '3.1.2+3'}
+ },
+ )
+ ..serve(
+ 'foo',
+ '3.0.0',
+ pubspec: {
+ 'environment': {'sdk': '0.0.0'}
+ },
+ )
+ ..serve(
+ 'foo',
+ '4.0.0',
+ pubspec: {
+ 'environment': {'sdk': '0.0.0'}
+ },
+ );
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await expectResolves(result: {'foo': '2.0.0'});
});
test('selects a transitive dependency version that allows the SDK', () async {
await servePackages()
..serve('foo', '1.0.0', deps: {'bar': 'any'})
- ..serve('bar', '1.0.0', pubspec: {
- 'environment': {'sdk': '0.1.2+3'}
- })
- ..serve('bar', '2.0.0', pubspec: {
- 'environment': {'sdk': '0.1.2+3'}
- })
- ..serve('bar', '3.0.0', pubspec: {
- 'environment': {'sdk': '0.0.0'}
- })
- ..serve('bar', '4.0.0', pubspec: {
- 'environment': {'sdk': '0.0.0'}
- });
+ ..serve(
+ 'bar',
+ '1.0.0',
+ pubspec: {
+ 'environment': {'sdk': '3.1.2+3'}
+ },
+ )
+ ..serve(
+ 'bar',
+ '2.0.0',
+ pubspec: {
+ 'environment': {'sdk': '3.1.2+3'}
+ },
+ )
+ ..serve(
+ 'bar',
+ '3.0.0',
+ pubspec: {
+ 'environment': {'sdk': '0.0.0'}
+ },
+ )
+ ..serve(
+ 'bar',
+ '4.0.0',
+ pubspec: {
+ 'environment': {'sdk': '0.0.0'}
+ },
+ );
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await expectResolves(result: {'foo': '1.0.0', 'bar': '2.0.0'});
});
@@ -1073,20 +1248,36 @@
..serve('foo', '2.0.0', deps: {'bar': '2.0.0'})
..serve('foo', '3.0.0', deps: {'bar': '3.0.0'})
..serve('foo', '4.0.0', deps: {'bar': '4.0.0'})
- ..serve('bar', '1.0.0', pubspec: {
- 'environment': {'sdk': '0.1.2+3'}
- })
- ..serve('bar', '2.0.0', pubspec: {
- 'environment': {'sdk': '0.1.2+3'}
- })
- ..serve('bar', '3.0.0', pubspec: {
- 'environment': {'sdk': '0.0.0'}
- })
- ..serve('bar', '4.0.0', pubspec: {
- 'environment': {'sdk': '0.0.0'}
- });
+ ..serve(
+ 'bar',
+ '1.0.0',
+ pubspec: {
+ 'environment': {'sdk': '3.1.2+3'}
+ },
+ )
+ ..serve(
+ 'bar',
+ '2.0.0',
+ pubspec: {
+ 'environment': {'sdk': '3.1.2+3'}
+ },
+ )
+ ..serve(
+ 'bar',
+ '3.0.0',
+ pubspec: {
+ 'environment': {'sdk': '0.0.0'}
+ },
+ )
+ ..serve(
+ 'bar',
+ '4.0.0',
+ pubspec: {
+ 'environment': {'sdk': '0.0.0'}
+ },
+ );
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await expectResolves(result: {'foo': '2.0.0', 'bar': '2.0.0'}, tries: 2);
});
}
@@ -1101,37 +1292,49 @@
})
]).create();
- await expectResolves(error: equalsIgnoringWhitespace('''
+ await expectResolves(
+ error: equalsIgnoringWhitespace('''
Because myapp requires the Flutter SDK, version solving failed.
Flutter users should run `flutter pub get` instead of `dart pub get`.
- '''));
+ '''),
+ );
});
test('fails for a dependency', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', pubspec: {
- 'environment': {'flutter': '0.0.0'}
- });
+ server.serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'environment': {'flutter': 'any', 'sdk': defaultSdkConstraint}
+ },
+ );
- await d.appDir({'foo': 'any'}).create();
- await expectResolves(error: equalsIgnoringWhitespace('''
+ await d.appDir(dependencies: {'foo': 'any'}).create();
+ await expectResolves(
+ error: equalsIgnoringWhitespace('''
Because myapp depends on foo any which requires the Flutter SDK, version
solving failed.
Flutter users should run `flutter pub get` instead of `dart pub get`.
- '''));
+ '''),
+ );
});
test("chooses a version that doesn't need Flutter", () async {
await servePackages()
..serve('foo', '1.0.0')
..serve('foo', '2.0.0')
- ..serve('foo', '3.0.0', pubspec: {
- 'environment': {'flutter': '0.0.0'}
- });
+ ..serve(
+ 'foo',
+ '3.0.0',
+ pubspec: {
+ 'environment': {'flutter': '0.0.0'}
+ },
+ );
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await expectResolves(result: {'foo': '2.0.0'});
});
@@ -1139,15 +1342,17 @@
await d.dir(appPath, [
d.pubspec({
'name': 'myapp',
- 'environment': {'sdk': '0.1.2+3', 'flutter': '1.2.3'}
+ 'environment': {'sdk': '3.1.2+3', 'flutter': '1.2.3'}
})
]).create();
- await expectResolves(error: equalsIgnoringWhitespace('''
+ await expectResolves(
+ error: equalsIgnoringWhitespace('''
Because myapp requires the Flutter SDK, version solving failed.
Flutter users should run `flutter pub get` instead of `dart pub get`.
- '''));
+ '''),
+ );
});
});
@@ -1159,12 +1364,14 @@
})
]).create();
- await expectResolves(error: equalsIgnoringWhitespace('''
+ await expectResolves(
+ error: equalsIgnoringWhitespace('''
Because myapp requires the Fuchsia SDK, version solving failed.
Please set the FUCHSIA_DART_SDK_ROOT environment variable to point to
the root of the Fuchsia SDK for Dart.
- '''));
+ '''),
+ );
});
group('with a Flutter SDK', () {
@@ -1181,8 +1388,9 @@
]).create();
await expectResolves(
- environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
- result: {});
+ environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
+ result: {},
+ );
});
test('fails with a non-matching constraint', () async {
@@ -1194,44 +1402,47 @@
]).create();
await expectResolves(
- environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
- error: equalsIgnoringWhitespace('''
+ environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
+ error: equalsIgnoringWhitespace('''
The current Flutter SDK version is 1.2.3.
Because myapp requires Flutter SDK version >1.2.3, version solving
failed.
- '''));
+ '''),
+ );
});
test('succeeds if both Flutter and Dart SDKs match', () async {
await d.dir(appPath, [
d.pubspec({
'name': 'myapp',
- 'environment': {'sdk': '0.1.2+3', 'flutter': '1.2.3'}
+ 'environment': {'sdk': '3.1.2+3', 'flutter': '1.2.3'}
})
]).create();
await expectResolves(
- environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
- result: {});
+ environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
+ result: {},
+ );
});
test("fails if Flutter SDK doesn't match but Dart does", () async {
await d.dir(appPath, [
d.pubspec({
'name': 'myapp',
- 'environment': {'sdk': '0.1.2+3', 'flutter': '>1.2.3'}
+ 'environment': {'sdk': '3.1.2+3', 'flutter': '>1.2.3'}
})
]).create();
await expectResolves(
- environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
- error: equalsIgnoringWhitespace('''
+ environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
+ error: equalsIgnoringWhitespace('''
The current Flutter SDK version is 1.2.3.
Because myapp requires Flutter SDK version >1.2.3, version solving
failed.
- '''));
+ '''),
+ );
});
test("fails if Dart SDK doesn't match but Flutter does", () async {
@@ -1239,38 +1450,52 @@
d.pubspec({
'name': 'myapp',
'environment': {
- 'sdk': '>0.1.2+3', // pub will apply a default upper bound <2.0.0
+ 'sdk': '>3.1.2+3',
'flutter': '1.2.3',
},
}),
]).create();
await expectResolves(
- environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
- error: equalsIgnoringWhitespace('''
- The current Dart SDK version is 0.1.2+3.
+ environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
+ error: equalsIgnoringWhitespace('''
+ The current Dart SDK version is 3.1.2+3.
- Because myapp requires SDK version >0.1.2+3 <2.0.0, version solving
+ Because myapp requires SDK version >3.1.2+3, version solving
failed.
- '''));
+ '''),
+ );
});
test('selects the latest dependency with a matching constraint', () async {
await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'environment': {'flutter': '^0.0.0'}
- })
- ..serve('foo', '2.0.0', pubspec: {
- 'environment': {'flutter': '^1.0.0'}
- })
- ..serve('foo', '3.0.0', pubspec: {
- 'environment': {'flutter': '^2.0.0'}
- });
+ ..serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'environment': {'flutter': '^0.0.0', 'sdk': defaultSdkConstraint}
+ },
+ )
+ ..serve(
+ 'foo',
+ '2.0.0',
+ pubspec: {
+ 'environment': {'flutter': '^1.0.0', 'sdk': defaultSdkConstraint}
+ },
+ )
+ ..serve(
+ 'foo',
+ '3.0.0',
+ pubspec: {
+ 'environment': {'flutter': '^2.0.0', 'sdk': defaultSdkConstraint}
+ },
+ );
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await expectResolves(
- environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
- result: {'foo': '2.0.0'});
+ environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
+ result: {'foo': '2.0.0'},
+ );
});
});
}
@@ -1283,7 +1508,7 @@
..serve('a', '2.0.0-dev')
..serve('a', '3.0.0-dev');
- await d.appDir({'a': 'any'}).create();
+ await d.appDir(dependencies: {'a': 'any'}).create();
await expectResolves(result: {'a': '1.0.0'});
});
@@ -1294,7 +1519,7 @@
..serve('a', '1.9.0-dev')
..serve('a', '3.0.0');
- await d.appDir({'a': '<2.0.0'}).create();
+ await d.appDir(dependencies: {'a': '<2.0.0'}).create();
await expectResolves(result: {'a': '1.9.0-dev'});
});
@@ -1305,7 +1530,7 @@
..serve('a', '2.0.0-dev')
..serve('a', '2.0.0');
- await d.appDir({'a': '<2.0.0'}).create();
+ await d.appDir(dependencies: {'a': '<2.0.0'}).create();
await expectResolves(result: {'a': '1.1.0'});
});
@@ -1317,7 +1542,7 @@
..serve('a', '2.0.0-dev')
..serve('a', '2.0.0');
- await d.appDir({'a': '<=2.0.0-dev'}).create();
+ await d.appDir(dependencies: {'a': '<=2.0.0-dev'}).create();
await expectResolves(result: {'a': '1.1.0'});
});
@@ -1326,7 +1551,7 @@
..serve('a', '1.0.0')
..serve('a', '1.1.0-dev');
- await d.appDir({'a': '^1.1.0-dev'}).create();
+ await d.appDir(dependencies: {'a': '^1.1.0-dev'}).create();
await expectResolves(result: {'a': '1.1.0-dev'});
});
@@ -1336,7 +1561,7 @@
..serve('a', '1.1.0-dev')
..serve('a', '1.1.0');
- await d.appDir({'a': '^1.1.0-dev'}).create();
+ await d.appDir(dependencies: {'a': '^1.1.0-dev'}).create();
await expectResolves(result: {'a': '1.1.0'});
});
@@ -1349,11 +1574,13 @@
..serve('b', '1.0.0')
..serve('b', '1.1.0-dev');
- await d.appDir({'a': '^1.0.0'}).create();
- await expectResolves(result: {
- 'a': '1.1.0',
- 'b': '1.1.0-dev',
- });
+ await d.appDir(dependencies: {'a': '^1.0.0'}).create();
+ await expectResolves(
+ result: {
+ 'a': '1.1.0',
+ 'b': '1.1.0-dev',
+ },
+ );
});
test('backtracks pre-release choice with direct dependency', () async {
@@ -1363,14 +1590,19 @@
..serve('b', '1.0.0')
..serve('b', '1.1.0-dev');
- await d.appDir({
- 'a': '^1.0.0',
- 'b': '^1.0.0', // Direct dependency prevents us from using a pre-release.
- }).create();
- await expectResolves(result: {
- 'a': '1.0.0',
- 'b': '1.0.0',
- });
+ await d.appDir(
+ dependencies: {
+ 'a': '^1.0.0',
+ 'b':
+ '^1.0.0', // Direct dependency prevents us from using a pre-release.
+ },
+ ).create();
+ await expectResolves(
+ result: {
+ 'a': '1.0.0',
+ 'b': '1.0.0',
+ },
+ );
});
test('backtracking pre-release fails with indirect dependency', () async {
@@ -1383,15 +1615,19 @@
..serve('b', '1.1.0-dev')
..serve('c', '1.0.0', deps: {'b': '^1.0.0'});
- await d.appDir({
- 'a': '^1.0.0',
- 'c': '^1.0.0', // This doesn't not prevent using a pre-release.
- }).create();
- await expectResolves(result: {
- 'a': '1.1.0',
- 'b': '1.1.0-dev',
- 'c': '1.0.0',
- });
+ await d.appDir(
+ dependencies: {
+ 'a': '^1.0.0',
+ 'c': '^1.0.0', // This doesn't not prevent using a pre-release.
+ },
+ ).create();
+ await expectResolves(
+ result: {
+ 'a': '1.1.0',
+ 'b': '1.1.0-dev',
+ 'c': '1.0.0',
+ },
+ );
});
test('https://github.com/dart-lang/pub/issues/3057 regression', () async {
@@ -1405,15 +1641,17 @@
..serve('c', '2.0.1', deps: {});
await d.appDir(
- {
+ dependencies: {
'a': '0.12.0',
'b': 'any',
},
).create();
await expectResolves(
- error: contains(
- 'So, because myapp depends on both a 0.12.0 and b any, version solving failed.'),
- tries: 2);
+ error: contains(
+ 'So, because myapp depends on both a 0.12.0 and b any, version solving failed.',
+ ),
+ tries: 2,
+ );
});
test('https://github.com/dart-lang/pub/pull/3038 regression', () async {
@@ -1424,9 +1662,11 @@
..serve('b', '1.1.0-alpha')
..serve('a', '1.0.0', deps: {'b': '^1.1.0-alpha'});
- await d.appDir({
- 'a': '^1.0.0',
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'a': '^1.0.0',
+ },
+ ).create();
await expectResolves(tries: 2);
});
}
@@ -1511,7 +1751,7 @@
..serve('bar', '1.0.1')
..serve('bar', '1.0.2');
- await d.appDir({'foo': '1.0.1'}).create();
+ await d.appDir(dependencies: {'foo': '1.0.1'}).create();
await expectResolves(result: {'foo': '1.0.1', 'bar': '1.0.1'});
await d.dir(appPath, [
@@ -1533,7 +1773,7 @@
..serve('bar', '1.0.1')
..serve('bar', '1.0.2');
- await d.appDir({'foo': '1.0.1'}).create();
+ await d.appDir(dependencies: {'foo': '1.0.1'}).create();
await expectResolves(result: {'foo': '1.0.1', 'bar': '1.0.1'});
await d.dir(appPath, [
@@ -1558,10 +1798,12 @@
})
]).create();
- await expectResolves(error: equalsIgnoringWhitespace("""
+ await expectResolves(
+ error: equalsIgnoringWhitespace("""
Because myapp depends on foo ^1.0.0 which doesn't match any versions,
version solving failed.
- """));
+ """),
+ );
});
test('overrides a bad source without error', () async {
@@ -1583,9 +1825,13 @@
test('overrides an unmatched SDK constraint', () async {
final server = await servePackages();
- server.serve('foo', '0.0.0', pubspec: {
- 'environment': {'sdk': '0.0.0'}
- });
+ server.serve(
+ 'foo',
+ '0.0.0',
+ pubspec: {
+ 'environment': {'sdk': '0.0.0'}
+ },
+ );
await d.dir(appPath, [
d.pubspec({
@@ -1619,7 +1865,7 @@
..serve('bar', '1.2.3')
..serve('bar', '0.0.1');
- await d.appDir({'foo': 'any'}).create();
+ await d.appDir(dependencies: {'foo': 'any'}).create();
await expectResolves(result: {'foo': '1.2.3', 'bar': '1.2.3'});
@@ -1681,10 +1927,10 @@
..serve('foo', '2.0.0')
..serve('foo', '2.1.0');
- await d.appDir({'foo': '2.1.0'}).create();
+ await d.appDir(dependencies: {'foo': '2.1.0'}).create();
await expectResolves(result: {'foo': '2.1.0'});
- await d.appDir({'foo': '>=2.0.0 <3.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '>=2.0.0 <3.0.0'}).create();
await expectResolves(result: {'foo': '2.0.0'}, downgrade: true);
});
@@ -1697,7 +1943,7 @@
..serve('a', '2.0.0-dev.2')
..serve('a', '2.0.0-dev.3');
- await d.appDir({'a': '>=2.0.0-dev.1 <3.0.0'}).create();
+ await d.appDir(dependencies: {'a': '>=2.0.0-dev.1 <3.0.0'}).create();
await expectResolves(result: {'a': '2.0.0-dev.1'}, downgrade: true);
});
}
@@ -1705,197 +1951,259 @@
void features() {
test("doesn't enable an opt-in feature by default", () async {
await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'features': {
- 'stuff': {
- 'default': false,
- 'dependencies': {'bar': '1.0.0'}
+ ..serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'default': false,
+ 'dependencies': {'bar': '1.0.0'}
+ }
}
- }
- })
+ },
+ )
..serve('bar', '1.0.0');
- await d.appDir({'foo': '1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '1.0.0'}).create();
await expectResolves(result: {'foo': '1.0.0'});
});
test('enables an opt-out feature by default', () async {
await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'features': {
- 'stuff': {
- 'default': true,
- 'dependencies': {'bar': '1.0.0'}
+ ..serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'default': true,
+ 'dependencies': {'bar': '1.0.0'}
+ }
}
- }
- })
+ },
+ )
..serve('bar', '1.0.0');
- await d.appDir({'foo': '1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '1.0.0'}).create();
await expectResolves(result: {'foo': '1.0.0', 'bar': '1.0.0'});
});
test('features are opt-out by default', () async {
await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'features': {
- 'stuff': {
- 'dependencies': {'bar': '1.0.0'}
+ ..serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'dependencies': {'bar': '1.0.0'}
+ }
}
- }
- })
+ },
+ )
..serve('bar', '1.0.0');
- await d.appDir({'foo': '1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '1.0.0'}).create();
await expectResolves(result: {'foo': '1.0.0', 'bar': '1.0.0'});
});
test("enables an opt-in feature if it's required", () async {
await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'features': {
- 'stuff': {
- 'default': false,
- 'dependencies': {'bar': '1.0.0'}
+ ..serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'default': false,
+ 'dependencies': {'bar': '1.0.0'}
+ }
}
- }
- })
+ },
+ )
..serve('bar', '1.0.0');
- await d.appDir({
- 'foo': {
- 'version': '1.0.0',
- 'features': {'stuff': true}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'version': '1.0.0',
+ 'features': {'stuff': true}
+ }
+ },
+ ).create();
await expectResolves(result: {'foo': '1.0.0', 'bar': '1.0.0'});
});
test("doesn't enable an opt-out feature if it's disabled", () async {
await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'features': {
- 'stuff': {
- 'dependencies': {'bar': '1.0.0'}
+ ..serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'dependencies': {'bar': '1.0.0'}
+ }
}
- }
- })
+ },
+ )
..serve('bar', '1.0.0');
- await d.appDir({
- 'foo': {
- 'version': '1.0.0',
- 'features': {'stuff': false}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'version': '1.0.0',
+ 'features': {'stuff': false}
+ }
+ },
+ ).create();
await expectResolves(result: {'foo': '1.0.0'});
});
test('opting in takes precedence over opting out', () async {
await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'features': {
- 'stuff': {
- 'dependencies': {'bar': '1.0.0'}
+ ..serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'dependencies': {'bar': '1.0.0'}
+ }
}
- }
- })
+ },
+ )
..serve('bar', '1.0.0')
- ..serve('baz', '1.0.0', deps: {
+ ..serve(
+ 'baz',
+ '1.0.0',
+ deps: {
+ 'foo': {
+ 'version': '1.0.0',
+ 'features': {'stuff': true}
+ }
+ },
+ );
+
+ await d.appDir(
+ dependencies: {
'foo': {
'version': '1.0.0',
- 'features': {'stuff': true}
- }
- });
-
- await d.appDir({
- 'foo': {
- 'version': '1.0.0',
- 'features': {'stuff': false}
+ 'features': {'stuff': false}
+ },
+ 'baz': '1.0.0'
},
- 'baz': '1.0.0'
- }).create();
+ ).create();
await expectResolves(
- result: {'foo': '1.0.0', 'bar': '1.0.0', 'baz': '1.0.0'});
+ result: {'foo': '1.0.0', 'bar': '1.0.0', 'baz': '1.0.0'},
+ );
});
test('implicitly opting in takes precedence over opting out', () async {
await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'features': {
- 'stuff': {
- 'dependencies': {'bar': '1.0.0'}
+ ..serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'dependencies': {'bar': '1.0.0'}
+ }
}
- }
- })
+ },
+ )
..serve('bar', '1.0.0')
- ..serve('baz', '1.0.0', deps: {
+ ..serve(
+ 'baz',
+ '1.0.0',
+ deps: {
+ 'foo': {
+ 'version': '1.0.0',
+ }
+ },
+ );
+
+ await d.appDir(
+ dependencies: {
'foo': {
'version': '1.0.0',
- }
- });
-
- await d.appDir({
- 'foo': {
- 'version': '1.0.0',
- 'features': {'stuff': false}
+ 'features': {'stuff': false}
+ },
+ 'baz': '1.0.0'
},
- 'baz': '1.0.0'
- }).create();
+ ).create();
await expectResolves(
- result: {'foo': '1.0.0', 'bar': '1.0.0', 'baz': '1.0.0'});
+ result: {'foo': '1.0.0', 'bar': '1.0.0', 'baz': '1.0.0'},
+ );
});
test("doesn't select a version with an unavailable feature", () async {
await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'features': {
- 'stuff': {
- 'default': false,
- 'dependencies': {'bar': '1.0.0'}
+ ..serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'default': false,
+ 'dependencies': {'bar': '1.0.0'}
+ }
}
- }
- })
+ },
+ )
..serve('foo', '1.1.0')
..serve('bar', '1.0.0');
- await d.appDir({
- 'foo': {
- 'version': '1.0.0',
- 'features': {'stuff': true}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'version': '1.0.0',
+ 'features': {'stuff': true}
+ }
+ },
+ ).create();
await expectResolves(result: {'foo': '1.0.0', 'bar': '1.0.0'});
});
test("doesn't select a version with an incompatible feature", () async {
await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'features': {
- 'stuff': {
- 'default': false,
- 'dependencies': {'bar': '1.0.0'}
+ ..serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'default': false,
+ 'dependencies': {'bar': '1.0.0'}
+ }
}
- }
- })
- ..serve('foo', '1.1.0', pubspec: {
- 'features': {
- 'stuff': {
- 'default': false,
- 'dependencies': {'bar': '2.0.0'}
+ },
+ )
+ ..serve(
+ 'foo',
+ '1.1.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'default': false,
+ 'dependencies': {'bar': '2.0.0'}
+ }
}
- }
- })
+ },
+ )
..serve('bar', '1.0.0')
..serve('bar', '2.0.0');
- await d.appDir({
- 'foo': {
- 'version': '^1.0.0',
- 'features': {'stuff': true}
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'version': '^1.0.0',
+ 'features': {'stuff': true}
+ },
+ 'bar': '1.0.0'
},
- 'bar': '1.0.0'
- }).create();
+ ).create();
await expectResolves(result: {'foo': '1.0.0', 'bar': '1.0.0'});
});
@@ -1903,95 +2211,127 @@
'backtracks if a feature is transitively incompatible with another '
'feature', () async {
await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'features': {
- 'stuff': {
- 'default': false,
- 'dependencies': {
- 'bar': {
- 'version': '1.0.0',
- 'features': {'stuff': false}
+ ..serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'default': false,
+ 'dependencies': {
+ 'bar': {
+ 'version': '1.0.0',
+ 'features': {'stuff': false}
+ }
}
}
}
- }
- })
- ..serve('foo', '1.1.0', pubspec: {
- 'features': {
- 'stuff': {
- 'default': false,
- 'dependencies': {'bar': '1.0.0'}
+ },
+ )
+ ..serve(
+ 'foo',
+ '1.1.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'default': false,
+ 'dependencies': {'bar': '1.0.0'}
+ }
}
- }
- })
- ..serve('bar', '1.0.0', pubspec: {
- 'features': {
- 'stuff': {
- 'dependencies': {'baz': '1.0.0'}
+ },
+ )
+ ..serve(
+ 'bar',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'dependencies': {'baz': '1.0.0'}
+ }
}
- }
- })
+ },
+ )
..serve('baz', '1.0.0')
..serve('baz', '2.0.0');
- await d.appDir({
- 'foo': {
- 'version': '^1.0.0',
- 'features': {'stuff': true}
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'version': '^1.0.0',
+ 'features': {'stuff': true}
+ },
+ 'baz': '2.0.0'
},
- 'baz': '2.0.0'
- }).create();
+ ).create();
await expectResolves(
- result: {'foo': '1.0.0', 'bar': '1.0.0', 'baz': '2.0.0'}, tries: 2);
+ result: {'foo': '1.0.0', 'bar': '1.0.0', 'baz': '2.0.0'},
+ tries: 2,
+ );
});
test("backtracks if a feature's dependencies are transitively incompatible",
() async {
await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'features': {
- 'stuff': {
- 'default': false,
- 'dependencies': {'bar': '1.0.0'}
+ ..serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'default': false,
+ 'dependencies': {'bar': '1.0.0'}
+ }
}
- }
- })
- ..serve('foo', '1.1.0', pubspec: {
- 'features': {
- 'stuff': {
- 'default': false,
- 'dependencies': {'bar': '2.0.0'}
+ },
+ )
+ ..serve(
+ 'foo',
+ '1.1.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'default': false,
+ 'dependencies': {'bar': '2.0.0'}
+ }
}
- }
- })
+ },
+ )
..serve('bar', '1.0.0', deps: {'baz': '1.0.0'})
..serve('bar', '2.0.0', deps: {'baz': '2.0.0'})
..serve('baz', '1.0.0')
..serve('baz', '2.0.0');
- await d.appDir({
- 'foo': {
- 'version': '^1.0.0',
- 'features': {'stuff': true}
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'version': '^1.0.0',
+ 'features': {'stuff': true}
+ },
+ 'baz': '1.0.0'
},
- 'baz': '1.0.0'
- }).create();
+ ).create();
await expectResolves(
- result: {'foo': '1.0.0', 'bar': '1.0.0', 'baz': '1.0.0'}, tries: 2);
+ result: {'foo': '1.0.0', 'bar': '1.0.0', 'baz': '1.0.0'},
+ tries: 2,
+ );
});
test('disables a feature when it backtracks', () async {
await servePackages()
..serve('foo', '1.0.0', deps: {'myapp': '0.0.0'})
- ..serve('foo', '1.1.0', deps: {
- // This is a transitively incompatible dependency with myapp, which will
- // force the solver to backtrack and unselect foo 1.1.0.
- 'bar': '1.0.0',
- 'myapp': {
- 'version': '0.0.0',
- 'features': {'stuff': true}
- }
- })
+ ..serve(
+ 'foo',
+ '1.1.0',
+ deps: {
+ // This is a transitively incompatible dependency with myapp, which will
+ // force the solver to backtrack and unselect foo 1.1.0.
+ 'bar': '1.0.0',
+ 'myapp': {
+ 'version': '0.0.0',
+ 'features': {'stuff': true}
+ }
+ },
+ )
..serve('bar', '1.0.0', deps: {'baz': '2.0.0'})
..serve('baz', '1.0.0')
..serve('baz', '2.0.0')
@@ -2058,11 +2398,15 @@
test("the root package's features can't be disabled by dependencies",
() async {
await servePackages()
- ..serve('foo', '1.0.0', deps: {
- 'myapp': {
- 'features': {'stuff': false}
- }
- })
+ ..serve(
+ 'foo',
+ '1.0.0',
+ deps: {
+ 'myapp': {
+ 'features': {'stuff': false}
+ }
+ },
+ )
..serve('bar', '1.0.0');
await d.dir(appPath, [
@@ -2081,11 +2425,15 @@
test("the root package's features can be enabled by dependencies", () async {
await servePackages()
- ..serve('foo', '1.0.0', deps: {
- 'myapp': {
- 'features': {'stuff': true}
- }
- })
+ ..serve(
+ 'foo',
+ '1.0.0',
+ deps: {
+ 'myapp': {
+ 'features': {'stuff': true}
+ }
+ },
+ )
..serve('bar', '1.0.0');
await d.dir(appPath, [
@@ -2119,29 +2467,36 @@
})
]).create();
await expectResolves(
- error: "foo 1.0.0 doesn't have a feature named stuff:\n"
- '- myapp depends on version ^1.0.0 with stuff');
+ error: "foo 1.0.0 doesn't have a feature named stuff:\n"
+ '- myapp depends on version ^1.0.0 with stuff',
+ );
});
group('an "if available" dependency', () {
test('enables an opt-in feature', () async {
await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'features': {
- 'stuff': {
- 'default': false,
- 'dependencies': {'bar': '1.0.0'}
+ ..serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'default': false,
+ 'dependencies': {'bar': '1.0.0'}
+ }
}
- }
- })
+ },
+ )
..serve('bar', '1.0.0');
- await d.appDir({
- 'foo': {
- 'version': '1.0.0',
- 'features': {'stuff': 'if available'}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'version': '1.0.0',
+ 'features': {'stuff': 'if available'}
+ }
+ },
+ ).create();
await expectResolves(result: {'foo': '1.0.0', 'bar': '1.0.0'});
});
@@ -2149,12 +2504,14 @@
final server = await servePackages();
server.serve('foo', '1.0.0');
- await d.appDir({
- 'foo': {
- 'version': '1.0.0',
- 'features': {'stuff': 'if available'}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'version': '1.0.0',
+ 'features': {'stuff': 'if available'}
+ }
+ },
+ ).create();
await expectResolves(result: {'foo': '1.0.0'});
});
});
@@ -2167,13 +2524,17 @@
group('succeeds when', () {
test('a Dart SDK constraint is matched', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', pubspec: {
- 'features': {
- 'stuff': {
- 'environment': {'sdk': '^0.1.0'}
+ server.serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'environment': {'sdk': '^0.1.0'}
+ }
}
- }
- });
+ },
+ );
await d.dir(appPath, [
d.pubspec({
@@ -2187,13 +2548,17 @@
test('a Flutter SDK constraint is matched', () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', pubspec: {
- 'features': {
- 'stuff': {
- 'environment': {'flutter': '^1.0.0'}
+ server.serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'environment': {'flutter': '^1.0.0'}
+ }
}
- }
- });
+ },
+ );
await d.dir(appPath, [
d.pubspec({
@@ -2203,8 +2568,9 @@
]).create();
await expectResolves(
- environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
- result: {'foo': '1.0.0'});
+ environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
+ result: {'foo': '1.0.0'},
+ );
});
});
@@ -2212,13 +2578,17 @@
test("a Dart SDK constraint isn't matched", () async {
await servePackages()
..serve('foo', '1.0.0')
- ..serve('foo', '1.1.0', pubspec: {
- 'features': {
- 'stuff': {
- 'environment': {'sdk': '0.0.1'}
+ ..serve(
+ 'foo',
+ '1.1.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'environment': {'sdk': '0.0.1'}
+ }
}
- }
- });
+ },
+ );
await d.dir(appPath, [
d.pubspec({
@@ -2233,13 +2603,17 @@
test("Flutter isn't available", () async {
await servePackages()
..serve('foo', '1.0.0')
- ..serve('foo', '1.1.0', pubspec: {
- 'features': {
- 'stuff': {
- 'environment': {'flutter': '1.0.0'}
+ ..serve(
+ 'foo',
+ '1.1.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'environment': {'flutter': '1.0.0'}
+ }
}
- }
- });
+ },
+ );
await d.dir(appPath, [
d.pubspec({
@@ -2254,13 +2628,17 @@
test("a Flutter SDK constraint isn't matched", () async {
await servePackages()
..serve('foo', '1.0.0')
- ..serve('foo', '1.1.0', pubspec: {
- 'features': {
- 'stuff': {
- 'environment': {'flutter': '^2.0.0'}
+ ..serve(
+ 'foo',
+ '1.1.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'environment': {'flutter': '^2.0.0'}
+ }
}
- }
- });
+ },
+ );
await d.dir(appPath, [
d.pubspec({
@@ -2270,21 +2648,26 @@
]).create();
await expectResolves(
- environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
- result: {'foo': '1.0.0'});
+ environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
+ result: {'foo': '1.0.0'},
+ );
});
});
group('resolution fails because', () {
test("a Dart SDK constraint isn't matched", () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', pubspec: {
- 'features': {
- 'stuff': {
- 'environment': {'sdk': '0.0.1'}
+ server.serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'environment': {'sdk': '0.0.1'}
+ }
}
- }
- });
+ },
+ );
await d.dir(appPath, [
d.pubspec({
@@ -2294,20 +2677,24 @@
]).create();
await expectResolves(
- error:
- 'Package foo feature stuff requires SDK version 0.0.1 but the '
- 'current SDK is 0.1.2+3.');
+ error: 'Package foo feature stuff requires SDK version 0.0.1 but the '
+ 'current SDK is 3.1.2+3.',
+ );
});
test("Flutter isn't available", () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', pubspec: {
- 'features': {
- 'stuff': {
- 'environment': {'flutter': '1.0.0'}
+ server.serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'environment': {'flutter': '1.0.0'}
+ }
}
- }
- });
+ },
+ );
await d.dir(appPath, [
d.pubspec({
@@ -2317,19 +2704,24 @@
]).create();
await expectResolves(
- error: 'Package foo feature stuff requires the Flutter SDK, which '
- 'is not available.');
+ error: 'Package foo feature stuff requires the Flutter SDK, which '
+ 'is not available.',
+ );
});
test("a Flutter SDK constraint isn't matched", () async {
final server = await servePackages();
- server.serve('foo', '1.0.0', pubspec: {
- 'features': {
- 'stuff': {
- 'environment': {'flutter': '^2.0.0'}
+ server.serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'environment': {'flutter': '^2.0.0'}
+ }
}
- }
- });
+ },
+ );
await d.dir(appPath, [
d.pubspec({
@@ -2339,9 +2731,10 @@
]).create();
await expectResolves(
- environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
- error: 'Package foo feature stuff requires Flutter SDK version '
- '^2.0.0 but the current SDK is 1.2.3.');
+ environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
+ error: 'Package foo feature stuff requires Flutter SDK version '
+ '^2.0.0 but the current SDK is 1.2.3.',
+ );
});
});
});
@@ -2349,216 +2742,270 @@
group('with overlapping dependencies', () {
test('can enable extra features', () async {
await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'dependencies': {'bar': '1.0.0'},
- 'features': {
- 'stuff': {
- 'default': false,
- 'dependencies': {
- 'bar': {
- 'features': {'stuff': true}
+ ..serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'dependencies': {'bar': '1.0.0'},
+ 'features': {
+ 'stuff': {
+ 'default': false,
+ 'dependencies': {
+ 'bar': {
+ 'features': {'stuff': true}
+ }
}
}
}
- }
- })
- ..serve('bar', '1.0.0', pubspec: {
- 'features': {
- 'stuff': {
- 'default': false,
- 'dependencies': {'baz': '1.0.0'}
+ },
+ )
+ ..serve(
+ 'bar',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'default': false,
+ 'dependencies': {'baz': '1.0.0'}
+ }
}
- }
- })
+ },
+ )
..serve('baz', '1.0.0');
- await d.appDir({
- 'foo': {'version': '1.0.0'}
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {'version': '1.0.0'}
+ },
+ ).create();
await expectResolves(result: {'foo': '1.0.0', 'bar': '1.0.0'});
- await d.appDir({
- 'foo': {
- 'version': '1.0.0',
- 'features': {'stuff': true}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'version': '1.0.0',
+ 'features': {'stuff': true}
+ }
+ },
+ ).create();
await expectResolves(
- result: {'foo': '1.0.0', 'bar': '1.0.0', 'baz': '1.0.0'});
+ result: {'foo': '1.0.0', 'bar': '1.0.0', 'baz': '1.0.0'},
+ );
});
test("can't disable features", () async {
await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'dependencies': {
- 'bar': {
- 'version': '1.0.0',
- 'features': {'stuff': false}
+ ..serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'dependencies': {
+ 'bar': {
+ 'version': '1.0.0',
+ 'features': {'stuff': false}
+ },
},
- },
- 'features': {
- 'stuff': {
- 'default': false,
- 'dependencies': {
- 'bar': {
- 'features': {'stuff': true}
+ 'features': {
+ 'stuff': {
+ 'default': false,
+ 'dependencies': {
+ 'bar': {
+ 'features': {'stuff': true}
+ }
}
}
}
- }
- })
- ..serve('bar', '1.0.0', pubspec: {
- 'features': {
- 'stuff': {
- 'default': true,
- 'dependencies': {'baz': '1.0.0'}
+ },
+ )
+ ..serve(
+ 'bar',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'stuff': {
+ 'default': true,
+ 'dependencies': {'baz': '1.0.0'}
+ }
}
- }
- })
+ },
+ )
..serve('baz', '1.0.0');
- await d.appDir({
- 'foo': {
- 'version': '1.0.0',
- 'features': {'stuff': true}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'version': '1.0.0',
+ 'features': {'stuff': true}
+ }
+ },
+ ).create();
await expectResolves(
- result: {'foo': '1.0.0', 'bar': '1.0.0', 'baz': '1.0.0'});
+ result: {'foo': '1.0.0', 'bar': '1.0.0', 'baz': '1.0.0'},
+ );
});
});
group('with required features', () {
test('enables those features', () async {
await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'features': {
- 'main': {
- 'default': false,
- 'requires': ['required1', 'required2']
- },
- 'required1': {
- 'default': false,
- 'dependencies': {'bar': '1.0.0'}
- },
- 'required2': {
- 'default': true,
- 'dependencies': {'baz': '1.0.0'}
+ ..serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'main': {
+ 'default': false,
+ 'requires': ['required1', 'required2']
+ },
+ 'required1': {
+ 'default': false,
+ 'dependencies': {'bar': '1.0.0'}
+ },
+ 'required2': {
+ 'default': true,
+ 'dependencies': {'baz': '1.0.0'}
+ }
}
- }
- })
+ },
+ )
..serve('bar', '1.0.0')
..serve('baz', '1.0.0');
- await d.appDir({
- 'foo': {
- 'version': '1.0.0',
- 'features': {'main': true}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'version': '1.0.0',
+ 'features': {'main': true}
+ }
+ },
+ ).create();
await expectResolves(
- result: {'foo': '1.0.0', 'bar': '1.0.0', 'baz': '1.0.0'});
+ result: {'foo': '1.0.0', 'bar': '1.0.0', 'baz': '1.0.0'},
+ );
});
test('enables those features by default', () async {
await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'features': {
- 'main': {
- 'requires': ['required1', 'required2']
- },
- 'required1': {
- 'default': false,
- 'dependencies': {'bar': '1.0.0'}
- },
- 'required2': {
- 'default': true,
- 'dependencies': {'baz': '1.0.0'}
+ ..serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'main': {
+ 'requires': ['required1', 'required2']
+ },
+ 'required1': {
+ 'default': false,
+ 'dependencies': {'bar': '1.0.0'}
+ },
+ 'required2': {
+ 'default': true,
+ 'dependencies': {'baz': '1.0.0'}
+ }
}
- }
- })
+ },
+ )
..serve('bar', '1.0.0')
..serve('baz', '1.0.0');
- await d.appDir({'foo': '1.0.0'}).create();
+ await d.appDir(dependencies: {'foo': '1.0.0'}).create();
await expectResolves(
- result: {'foo': '1.0.0', 'bar': '1.0.0', 'baz': '1.0.0'});
+ result: {'foo': '1.0.0', 'bar': '1.0.0', 'baz': '1.0.0'},
+ );
});
test("doesn't enable those features if it's disabled", () async {
await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'features': {
- 'main': {
- 'requires': ['required']
- },
- 'required': {
- 'default': false,
- 'dependencies': {'bar': '1.0.0'}
+ ..serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'main': {
+ 'requires': ['required']
+ },
+ 'required': {
+ 'default': false,
+ 'dependencies': {'bar': '1.0.0'}
+ }
}
- }
- })
+ },
+ )
..serve('bar', '1.0.0');
- await d.appDir({
- 'foo': {
- 'version': '1.0.0',
- 'features': {'main': false}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'version': '1.0.0',
+ 'features': {'main': false}
+ }
+ },
+ ).create();
await expectResolves(result: {'foo': '1.0.0'});
});
test("enables those features even if they'd otherwise be disabled",
() async {
await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'features': {
- 'main': {
- 'requires': ['required']
- },
- 'required': {
- 'default': false,
- 'dependencies': {'bar': '1.0.0'}
+ ..serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'main': {
+ 'requires': ['required']
+ },
+ 'required': {
+ 'default': false,
+ 'dependencies': {'bar': '1.0.0'}
+ }
}
- }
- })
+ },
+ )
..serve('bar', '1.0.0');
- await d.appDir({
- 'foo': {
- 'version': '1.0.0',
- 'features': {'main': true, 'required': false}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'version': '1.0.0',
+ 'features': {'main': true, 'required': false}
+ }
+ },
+ ).create();
await expectResolves(result: {'foo': '1.0.0', 'bar': '1.0.0'});
});
test('enables features transitively', () async {
await servePackages()
- ..serve('foo', '1.0.0', pubspec: {
- 'features': {
- 'main': {
- 'requires': ['required1']
- },
- 'required1': {
- 'default': false,
- 'requires': ['required2']
- },
- 'required2': {
- 'default': false,
- 'dependencies': {'bar': '1.0.0'}
+ ..serve(
+ 'foo',
+ '1.0.0',
+ pubspec: {
+ 'features': {
+ 'main': {
+ 'requires': ['required1']
+ },
+ 'required1': {
+ 'default': false,
+ 'requires': ['required2']
+ },
+ 'required2': {
+ 'default': false,
+ 'dependencies': {'bar': '1.0.0'}
+ }
}
- }
- })
+ },
+ )
..serve('bar', '1.0.0');
- await d.appDir({
- 'foo': {
- 'version': '1.0.0',
- 'features': {'main': true}
- }
- }).create();
+ await d.appDir(
+ dependencies: {
+ 'foo': {
+ 'version': '1.0.0',
+ 'features': {'main': true}
+ }
+ },
+ ).create();
await expectResolves(result: {'foo': '1.0.0', 'bar': '1.0.0'});
});
});
@@ -2583,24 +3030,28 @@
/// pub.
///
/// If [downgrade] is `true`, this runs "pub downgrade" instead of "pub get".
-Future expectResolves(
- {Map? result,
- error,
- output,
- int? tries,
- Map<String, String>? environment,
- bool downgrade = false}) async {
+Future expectResolves({
+ Map? result,
+ error,
+ output,
+ int? tries,
+ Map<String, String>? environment,
+ bool downgrade = false,
+}) async {
await runPub(
- args: [downgrade ? 'downgrade' : 'get'],
- environment: environment,
- output: output ??
- (error == null
- ? anyOf(contains('Got dependencies!'),
- matches(RegExp(r'Changed \d+ dependenc(ies|y)!')))
- : null),
- error: error,
- silent: contains('Tried ${tries ?? 1} solutions'),
- exitCode: error == null ? 0 : 1);
+ args: [downgrade ? 'downgrade' : 'get'],
+ environment: environment,
+ output: output ??
+ (error == null
+ ? anyOf(
+ contains('Got dependencies!'),
+ matches(RegExp(r'Changed \d+ dependenc(ies|y)!')),
+ )
+ : null),
+ error: error,
+ silent: contains('Tried ${tries ?? 1} solutions'),
+ exitCode: error == null ? 0 : 1,
+ );
if (result == null) return;
@@ -2632,12 +3083,18 @@
void regressions() {
test('reformatRanges with a build', () async {
await servePackages()
- ..serve('integration_test', '1.0.1',
- deps: {'vm_service': '>= 4.2.0 <6.0.0'})
- ..serve('integration_test', '1.0.2+2',
- deps: {'vm_service': '>= 4.2.0 <7.0.0'})
+ ..serve(
+ 'integration_test',
+ '1.0.1',
+ deps: {'vm_service': '>= 4.2.0 <6.0.0'},
+ )
+ ..serve(
+ 'integration_test',
+ '1.0.2+2',
+ deps: {'vm_service': '>= 4.2.0 <7.0.0'},
+ )
..serve('vm_service', '7.3.0');
- await d.appDir({'integration_test': '^1.0.2'}).create();
+ await d.appDir(dependencies: {'integration_test': '^1.0.2'}).create();
await expectResolves(
error: contains(
'Because no versions of integration_test match >=1.0.2 <1.0.2+2',
@@ -2649,18 +3106,28 @@
await d.dir('flutter', [
d.dir('bin/cache/pkg', [
d.dir(
- 'baz', [d.libDir('baz', 'foo 0.0.1'), d.libPubspec('baz', '0.0.1')])
+ 'baz',
+ [d.libDir('baz', 'foo 0.0.1'), d.libPubspec('baz', '0.0.1')],
+ )
]),
d.file('version', '1.2.3')
]).create();
await servePackages()
- ..serve('foo', '1.0.0', deps: {
- 'baz': {'sdk': 'flutter'}
- })
- ..serve('bar', '1.0.0', deps: {
- 'baz': {'sdk': 'flutter'}
- });
- await d.appDir({'foo': 'any', 'bar': 'any'}).create();
+ ..serve(
+ 'foo',
+ '1.0.0',
+ deps: {
+ 'baz': {'sdk': 'flutter'}
+ },
+ )
+ ..serve(
+ 'bar',
+ '1.0.0',
+ deps: {
+ 'baz': {'sdk': 'flutter'}
+ },
+ );
+ await d.appDir(dependencies: {'foo': 'any', 'bar': 'any'}).create();
await expectResolves(
environment: {'FLUTTER_ROOT': p.join(d.sandbox, 'flutter')},
);
diff --git a/tool/extract_all_pub_dev.dart b/tool/extract_all_pub_dev.dart
index ca90cd0..5d69ab3 100644
--- a/tool/extract_all_pub_dev.dart
+++ b/tool/extract_all_pub_dev.dart
@@ -82,25 +82,27 @@
try {
final versions = await versionArchiveUrls(packageName);
var allVersionsGood = true;
- await Future.wait(versions.map((archiveUrl) async {
- await withTempDir((tempDir) async {
- log.message('downloading $archiveUrl');
- http.StreamedResponse response;
- try {
- final archiveUri = Uri.parse(archiveUrl);
- final request = http.Request('GET', archiveUri);
- request.attachMetadataHeaders();
- response = await globalHttpClient.fetchAsStream(request);
- await extractTarGz(response.stream, tempDir);
- log.message('Extracted $archiveUrl');
- } catch (e) {
- log.message('Failed to get and extract $archiveUrl $e');
- failures.add({'archive': archiveUrl, 'error': e.toString()});
- allVersionsGood = false;
- return;
- }
- });
- }));
+ await Future.wait(
+ versions.map((archiveUrl) async {
+ await withTempDir((tempDir) async {
+ log.message('downloading $archiveUrl');
+ http.StreamedResponse response;
+ try {
+ final archiveUri = Uri.parse(archiveUrl);
+ final request = http.Request('GET', archiveUri);
+ request.attachMetadataHeaders();
+ response = await globalHttpClient.fetchAsStream(request);
+ await extractTarGz(response.stream, tempDir);
+ log.message('Extracted $archiveUrl');
+ } catch (e) {
+ log.message('Failed to get and extract $archiveUrl $e');
+ failures.add({'archive': archiveUrl, 'error': e.toString()});
+ allVersionsGood = false;
+ return;
+ }
+ });
+ }),
+ );
if (allVersionsGood) alreadyDonePackages.add(packageName);
} finally {
resource.release();
diff --git a/tool/test-bin/pub_command_runner.dart b/tool/test-bin/pub_command_runner.dart
index 756cd91..8e8a8ca 100644
--- a/tool/test-bin/pub_command_runner.dart
+++ b/tool/test-bin/pub_command_runner.dart
@@ -63,12 +63,15 @@
Runner() : super('pub_command_runner', 'Tests the embeddable pub command.') {
final analytics = Platform.environment['_PUB_LOG_ANALYTICS'] == 'true'
- ? PubAnalytics(() => loggingAnalytics,
- dependencyKindCustomDimensionName: 'cd1')
+ ? PubAnalytics(
+ () => loggingAnalytics,
+ dependencyKindCustomDimensionName: 'cd1',
+ )
: null;
addCommand(
- pubCommand(analytics: analytics, isVerbose: () => _options['verbose'])
- ..addSubcommand(ThrowingCommand()));
+ pubCommand(analytics: analytics, isVerbose: () => _options['verbose'])
+ ..addSubcommand(ThrowingCommand()),
+ );
addCommand(RunCommand());
argParser.addFlag('verbose');
}
@@ -115,13 +118,19 @@
}
@override
- Future sendEvent(String category, String action,
- {String? label, int? value, Map<String, String>? parameters}) {
+ Future sendEvent(
+ String category,
+ String action, {
+ String? label,
+ int? value,
+ Map<String, String>? parameters,
+ }) {
parameters ??= <String, String>{};
return _log(
- 'event',
- {'category': category, 'action': action, 'label': label, 'value': value}
- ..addAll(parameters));
+ 'event',
+ {'category': category, 'action': action, 'label': label, 'value': value}
+ ..addAll(parameters),
+ );
}
@override
@@ -129,8 +138,12 @@
_log('social', {'network': network, 'action': action, 'target': target});
@override
- Future sendTiming(String variableName, int time,
- {String? category, String? label}) {
+ Future sendTiming(
+ String variableName,
+ int time, {
+ String? category,
+ String? label,
+ }) {
return _log('timing', {
'variableName': variableName,
'time': time,
diff --git a/tool/test.dart b/tool/test.dart
index e0ef4b0..3fe026d 100755
--- a/tool/test.dart
+++ b/tool/test.dart
@@ -32,11 +32,12 @@
try {
stderr.writeln('Building snapshot');
await precompile(
- executablePath: path.join('bin', 'pub.dart'),
- outputPath: pubSnapshotFilename,
- incrementalDillPath: pubSnapshotIncrementalFilename,
- name: 'bin/pub.dart',
- packageConfigPath: path.join('.dart_tool', 'package_config.json'));
+ executablePath: path.join('bin', 'pub.dart'),
+ outputPath: pubSnapshotFilename,
+ incrementalDillPath: pubSnapshotIncrementalFilename,
+ name: 'bin/pub.dart',
+ packageConfigPath: path.join('.dart_tool', 'package_config.json'),
+ );
testProcess = await Process.start(
Platform.resolvedExecutable,
['run', 'test', ...args],