From cb67513f29dbf7f41818c9eb8cc42d845e243fca Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Fri, 23 Oct 2020 10:00:56 -0700 Subject: [PATCH] [flutter_tools] Reland: simplify pub cache logic (#67589) There have been some more additional reports of a missing 'package:characters' import after upgrading flutter. This has me concerned that our pub caching logic is incorrect. Instead of the tool attempting to guess when pub should be run, always delegate to pub. Also takes an opportunity to fix the kernel snapshot depending on the .packages or package_config. Due to the generated: date field this causes extra rebuilds. Instead when pub get is run, write out an additional file with just the package contents and version. Fixes #66777 Fixes #65723 --- .../flutter_tools/lib/src/base/build.dart | 1 - .../lib/src/build_system/targets/android.dart | 1 - .../lib/src/build_system/targets/common.dart | 1 - .../lib/src/build_system/targets/ios.dart | 3 - .../lib/src/build_system/targets/macos.dart | 1 - .../lib/src/build_system/targets/web.dart | 2 +- packages/flutter_tools/lib/src/cache.dart | 2 - .../lib/src/commands/packages.dart | 1 - .../flutter_tools/lib/src/commands/test.dart | 29 ----- .../lib/src/commands/update_packages.dart | 2 - .../lib/src/commands/upgrade.dart | 1 - .../flutter_tools/lib/src/context_runner.dart | 2 - packages/flutter_tools/lib/src/dart/pub.dart | 121 +++++------------- .../lib/src/runner/flutter_command.dart | 6 +- .../test/general.shard/base/build_test.dart | 13 -- .../test/general.shard/cache_test.dart | 3 - .../test/general.shard/dart/pub_get_test.dart | 50 ++------ .../downgrade_upgrade_integration_test.dart | 3 +- 18 files changed, 43 insertions(+), 199 deletions(-) diff --git a/packages/flutter_tools/lib/src/base/build.dart b/packages/flutter_tools/lib/src/base/build.dart index cb71b38873..086711aef4 100644 --- a/packages/flutter_tools/lib/src/base/build.dart +++ b/packages/flutter_tools/lib/src/base/build.dart @@ -109,7 +109,6 @@ class AOTSnapshotter { @required TargetPlatform platform, @required BuildMode buildMode, @required String mainPath, - @required String packagesPath, @required String outputPath, DarwinArch darwinArch, List extraGenSnapshotOptions = const [], diff --git a/packages/flutter_tools/lib/src/build_system/targets/android.dart b/packages/flutter_tools/lib/src/build_system/targets/android.dart index eb6a1206c5..8d9d0c84b8 100644 --- a/packages/flutter_tools/lib/src/build_system/targets/android.dart +++ b/packages/flutter_tools/lib/src/build_system/targets/android.dart @@ -233,7 +233,6 @@ class AndroidAot extends AotElfBase { platform: targetPlatform, buildMode: buildMode, mainPath: environment.buildDir.childFile('app.dill').path, - packagesPath: environment.projectDir.childFile('.packages').path, outputPath: output.path, bitcode: false, extraGenSnapshotOptions: extraGenSnapshotOptions, diff --git a/packages/flutter_tools/lib/src/build_system/targets/common.dart b/packages/flutter_tools/lib/src/build_system/targets/common.dart index 965316b418..6631e69140 100644 --- a/packages/flutter_tools/lib/src/build_system/targets/common.dart +++ b/packages/flutter_tools/lib/src/build_system/targets/common.dart @@ -323,7 +323,6 @@ abstract class AotElfBase extends Target { platform: targetPlatform, buildMode: buildMode, mainPath: environment.buildDir.childFile('app.dill').path, - packagesPath: environment.projectDir.childFile('.packages').path, outputPath: outputPath, bitcode: false, extraGenSnapshotOptions: extraGenSnapshotOptions, diff --git a/packages/flutter_tools/lib/src/build_system/targets/ios.dart b/packages/flutter_tools/lib/src/build_system/targets/ios.dart index 3c01632099..370fa55339 100644 --- a/packages/flutter_tools/lib/src/build_system/targets/ios.dart +++ b/packages/flutter_tools/lib/src/build_system/targets/ios.dart @@ -87,7 +87,6 @@ abstract class AotAssemblyBase extends Target { platform: targetPlatform, buildMode: buildMode, mainPath: environment.buildDir.childFile('app.dill').path, - packagesPath: environment.projectDir.childFile('.packages').path, outputPath: environment.fileSystem.path.join(buildOutputPath, getNameForDarwinArch(darwinArch)), darwinArch: darwinArch, bitcode: bitcode, @@ -128,7 +127,6 @@ class AotAssemblyRelease extends AotAssemblyBase { List get inputs => const [ Source.pattern('{FLUTTER_ROOT}/packages/flutter_tools/lib/src/build_system/targets/ios.dart'), Source.pattern('{BUILD_DIR}/app.dill'), - Source.pattern('{PROJECT_DIR}/.packages'), Source.artifact(Artifact.engineDartBinary), Source.artifact(Artifact.skyEnginePath), // TODO(jonahwilliams): cannot reference gen_snapshot with artifacts since @@ -163,7 +161,6 @@ class AotAssemblyProfile extends AotAssemblyBase { List get inputs => const [ Source.pattern('{FLUTTER_ROOT}/packages/flutter_tools/lib/src/build_system/targets/ios.dart'), Source.pattern('{BUILD_DIR}/app.dill'), - Source.pattern('{PROJECT_DIR}/.packages'), Source.artifact(Artifact.engineDartBinary), Source.artifact(Artifact.skyEnginePath), // TODO(jonahwilliams): cannot reference gen_snapshot with artifacts since diff --git a/packages/flutter_tools/lib/src/build_system/targets/macos.dart b/packages/flutter_tools/lib/src/build_system/targets/macos.dart index 349e33bde6..53883e2ee1 100644 --- a/packages/flutter_tools/lib/src/build_system/targets/macos.dart +++ b/packages/flutter_tools/lib/src/build_system/targets/macos.dart @@ -227,7 +227,6 @@ class CompileMacOSFramework extends Target { outputPath: environment.buildDir.path, platform: TargetPlatform.darwin_x64, darwinArch: DarwinArch.x86_64, - packagesPath: environment.projectDir.childFile('.packages').path, splitDebugInfo: splitDebugInfo, dartObfuscation: dartObfuscation, extraGenSnapshotOptions: extraGenSnapshotOptions, diff --git a/packages/flutter_tools/lib/src/build_system/targets/web.dart b/packages/flutter_tools/lib/src/build_system/targets/web.dart index 17db0721c8..9b1f86b6f2 100644 --- a/packages/flutter_tools/lib/src/build_system/targets/web.dart +++ b/packages/flutter_tools/lib/src/build_system/targets/web.dart @@ -183,7 +183,7 @@ class Dart2JSTarget extends Target { Source.artifact(Artifact.dart2jsSnapshot), Source.artifact(Artifact.engineDartBinary), Source.pattern('{BUILD_DIR}/main.dart'), - Source.pattern('{PROJECT_DIR}/.packages'), + Source.pattern('{PROJECT_DIR}/.dart_tool/package_config_subset'), ]; @override diff --git a/packages/flutter_tools/lib/src/cache.dart b/packages/flutter_tools/lib/src/cache.dart index e31acad3c6..6588cd16c8 100644 --- a/packages/flutter_tools/lib/src/cache.dart +++ b/packages/flutter_tools/lib/src/cache.dart @@ -703,8 +703,6 @@ class PubDependencies extends ArtifactSet { context: PubContext.pubGet, directory: _fileSystem.path.join(_flutterRoot(), 'packages', 'flutter_tools'), generateSyntheticPackage: false, - skipPubspecYamlCheck: true, - checkLastModified: false, ); } } diff --git a/packages/flutter_tools/lib/src/commands/packages.dart b/packages/flutter_tools/lib/src/commands/packages.dart index 583233dc91..3714deb2cc 100644 --- a/packages/flutter_tools/lib/src/commands/packages.dart +++ b/packages/flutter_tools/lib/src/commands/packages.dart @@ -117,7 +117,6 @@ class PackagesGetCommand extends FlutterCommand { directory: directory, upgrade: upgrade , offline: boolArg('offline'), - checkLastModified: false, generateSyntheticPackage: flutterProject.manifest.generateSyntheticPackage, ); pubGetTimer.stop(); diff --git a/packages/flutter_tools/lib/src/commands/test.dart b/packages/flutter_tools/lib/src/commands/test.dart index 6724b450fd..12a32b516e 100644 --- a/packages/flutter_tools/lib/src/commands/test.dart +++ b/packages/flutter_tools/lib/src/commands/test.dart @@ -8,11 +8,8 @@ import '../asset.dart'; import '../base/common.dart'; import '../base/file_system.dart'; import '../build_info.dart'; -import '../build_system/build_system.dart'; import '../bundle.dart'; import '../cache.dart'; -import '../dart/generate_synthetic_packages.dart'; -import '../dart/pub.dart'; import '../devfs.dart'; import '../globals.dart' as globals; import '../project.dart'; @@ -169,32 +166,6 @@ class TestCommand extends FlutterCommand { 'directory (or one of its subdirectories).'); } final FlutterProject flutterProject = FlutterProject.current(); - if (shouldRunPub) { - if (flutterProject.manifest.generateSyntheticPackage) { - final Environment environment = Environment( - artifacts: globals.artifacts, - logger: globals.logger, - cacheDir: globals.cache.getRoot(), - engineVersion: globals.flutterVersion.engineRevision, - fileSystem: globals.fs, - flutterRootDir: globals.fs.directory(Cache.flutterRoot), - outputDir: globals.fs.directory(getBuildDirectory()), - processManager: globals.processManager, - projectDir: flutterProject.directory, - ); - - await generateLocalizationsSyntheticPackage( - environment: environment, - buildSystem: globals.buildSystem, - ); - } - - await pub.get( - context: PubContext.getVerifyContext(name), - skipPubspecYamlCheck: true, - generateSyntheticPackage: flutterProject.manifest.generateSyntheticPackage, - ); - } final bool buildTestAssets = boolArg('test-assets'); final List names = stringsArg('name'); final List plainNames = stringsArg('plain-name'); diff --git a/packages/flutter_tools/lib/src/commands/update_packages.dart b/packages/flutter_tools/lib/src/commands/update_packages.dart index c52d5e30d7..defcea7cb8 100644 --- a/packages/flutter_tools/lib/src/commands/update_packages.dart +++ b/packages/flutter_tools/lib/src/commands/update_packages.dart @@ -329,7 +329,6 @@ class UpdatePackagesCommand extends FlutterCommand { context: PubContext.updatePackages, directory: tempDir.path, upgrade: true, - checkLastModified: false, offline: offline, flutterRootOverride: upgrade ? temporaryFlutterSdk.path @@ -412,7 +411,6 @@ class UpdatePackagesCommand extends FlutterCommand { await pub.get( context: PubContext.updatePackages, directory: dir.path, - checkLastModified: false, offline: offline, generateSyntheticPackage: false, ); diff --git a/packages/flutter_tools/lib/src/commands/upgrade.dart b/packages/flutter_tools/lib/src/commands/upgrade.dart index 4b2b364c26..19e91f818f 100644 --- a/packages/flutter_tools/lib/src/commands/upgrade.dart +++ b/packages/flutter_tools/lib/src/commands/upgrade.dart @@ -296,7 +296,6 @@ class UpgradeCommandRunner { context: PubContext.pubUpgrade, directory: projectRoot, upgrade: true, - checkLastModified: false, generateSyntheticPackage: false, ); } diff --git a/packages/flutter_tools/lib/src/context_runner.dart b/packages/flutter_tools/lib/src/context_runner.dart index 4e7908f283..f0ec8b0959 100644 --- a/packages/flutter_tools/lib/src/context_runner.dart +++ b/packages/flutter_tools/lib/src/context_runner.dart @@ -234,8 +234,6 @@ Future runInContext( botDetector: globals.botDetector, platform: globals.platform, usage: globals.flutterUsage, - // Avoid a circular dependency by making this access lazy. - toolStampFile: () => globals.cache.getStampFileFor('flutter_tools'), ), ShutdownHooks: () => ShutdownHooks(logger: globals.logger), Stdio: () => Stdio(), diff --git a/packages/flutter_tools/lib/src/dart/pub.dart b/packages/flutter_tools/lib/src/dart/pub.dart index 1e1e31ac30..e9524f3291 100644 --- a/packages/flutter_tools/lib/src/dart/pub.dart +++ b/packages/flutter_tools/lib/src/dart/pub.dart @@ -80,7 +80,6 @@ abstract class Pub { @required Platform platform, @required BotDetector botDetector, @required Usage usage, - File Function() toolStampFile, }) = _DefaultPub; /// Runs `pub get`. @@ -93,8 +92,6 @@ abstract class Pub { bool skipIfAbsent = false, bool upgrade = false, bool offline = false, - bool checkLastModified = true, - bool skipPubspecYamlCheck = false, bool generateSyntheticPackage = false, String flutterRootOverride, }); @@ -141,9 +138,7 @@ class _DefaultPub implements Pub { @required Platform platform, @required BotDetector botDetector, @required Usage usage, - File Function() toolStampFile, - }) : _toolStampFile = toolStampFile, - _fileSystem = fileSystem, + }) : _fileSystem = fileSystem, _logger = logger, _platform = platform, _botDetector = botDetector, @@ -159,7 +154,6 @@ class _DefaultPub implements Pub { final Platform _platform; final BotDetector _botDetector; final Usage _usage; - final File Function() _toolStampFile; @override Future get({ @@ -168,87 +162,51 @@ class _DefaultPub implements Pub { bool skipIfAbsent = false, bool upgrade = false, bool offline = false, - bool checkLastModified = true, - bool skipPubspecYamlCheck = false, bool generateSyntheticPackage = false, String flutterRootOverride, }) async { directory ??= _fileSystem.currentDirectory.path; - - final File pubSpecYaml = _fileSystem.file( - _fileSystem.path.join(directory, 'pubspec.yaml')); final File packageConfigFile = _fileSystem.file( _fileSystem.path.join(directory, '.dart_tool', 'package_config.json')); final Directory generatedDirectory = _fileSystem.directory( _fileSystem.path.join(directory, '.dart_tool', 'flutter_gen')); - if (!skipPubspecYamlCheck && !pubSpecYaml.existsSync()) { - if (!skipIfAbsent) { - throwToolExit('$directory: no pubspec.yaml found'); - } - return; - } - - final DateTime originalPubspecYamlModificationTime = pubSpecYaml.lastModifiedSync(); - - if (!checkLastModified || _shouldRunPubGet( - pubSpecYaml: pubSpecYaml, - packageConfigFile: packageConfigFile, - )) { - final String command = upgrade ? 'upgrade' : 'get'; - final Status status = _logger.startProgress( - 'Running "flutter pub $command" in ${_fileSystem.path.basename(directory)}...', + final String command = upgrade ? 'upgrade' : 'get'; + final Status status = _logger.startProgress( + 'Running "flutter pub $command" in ${_fileSystem.path.basename(directory)}...', + ); + final bool verbose = _logger.isVerbose; + final List args = [ + if (verbose) + '--verbose' + else + '--verbosity=warning', + ...[ + command, + '--no-precompile', + ], + if (offline) + '--offline', + ]; + try { + await batch( + args, + context: context, + directory: directory, + failureMessage: 'pub $command failed', + retry: true, + flutterRootOverride: flutterRootOverride, ); - final bool verbose = _logger.isVerbose; - final List args = [ - if (verbose) - '--verbose' - else - '--verbosity=warning', - ...[ - command, - '--no-precompile', - ], - if (offline) - '--offline', - ]; - try { - await batch( - args, - context: context, - directory: directory, - failureMessage: 'pub $command failed', - retry: true, - flutterRootOverride: flutterRootOverride, - ); - status.stop(); - // The exception is rethrown, so don't catch only Exceptions. - } catch (exception) { // ignore: avoid_catches_without_on_clauses - status.cancel(); - rethrow; - } + status.stop(); + // The exception is rethrown, so don't catch only Exceptions. + } catch (exception) { // ignore: avoid_catches_without_on_clauses + status.cancel(); + rethrow; } if (!packageConfigFile.existsSync()) { throwToolExit('$directory: pub did not create .dart_tools/package_config.json file.'); } - if (pubSpecYaml.lastModifiedSync() != originalPubspecYamlModificationTime) { - throwToolExit( - '$directory: unexpected concurrent modification of ' - 'pubspec.yaml while running pub.'); - } - // We don't check if dotPackages was actually modified, because as far as we can tell sometimes - // pub will decide it does not need to actually modify it. - final DateTime now = DateTime.now(); - if (now.isBefore(originalPubspecYamlModificationTime)) { - _logger.printError( - 'Warning: File "${_fileSystem.path.absolute(pubSpecYaml.path)}" was created in the future. ' - 'Optimizations that rely on comparing time stamps will be unreliable. Check your ' - 'system clock for accuracy.\n' - 'The timestamp was: $originalPubspecYamlModificationTime\n' - 'The time now is: $now' - ); - } await _updatePackageConfig( packageConfigFile, generatedDirectory, @@ -391,23 +349,6 @@ class _DefaultPub implements Pub { return [sdkPath, ...arguments]; } - bool _shouldRunPubGet({ @required File pubSpecYaml, @required File packageConfigFile }) { - if (!packageConfigFile.existsSync()) { - return true; - } - final DateTime dotPackagesLastModified = packageConfigFile.lastModifiedSync(); - if (pubSpecYaml.lastModifiedSync().isAfter(dotPackagesLastModified)) { - return true; - } - final File toolStampFile = _toolStampFile != null ? _toolStampFile() : null; - if (toolStampFile != null && - toolStampFile.existsSync() && - toolStampFile.lastModifiedSync().isAfter(dotPackagesLastModified)) { - return true; - } - return false; - } - // Returns the environment value that should be used when running pub. // // Includes any existing environment variable, if one exists. diff --git a/packages/flutter_tools/lib/src/runner/flutter_command.dart b/packages/flutter_tools/lib/src/runner/flutter_command.dart index e654bf45a8..3174ccda94 100644 --- a/packages/flutter_tools/lib/src/runner/flutter_command.dart +++ b/packages/flutter_tools/lib/src/runner/flutter_command.dart @@ -982,9 +982,9 @@ abstract class FlutterCommand extends Command { // First always update universal artifacts, as some of these (e.g. // ios-deploy on macOS) are required to determine `requiredArtifacts`. await globals.cache.updateAll({DevelopmentArtifact.universal}); - await globals.cache.updateAll(await requiredArtifacts); } + Cache.releaseLock(); await validateCommand(); @@ -1011,11 +1011,7 @@ abstract class FlutterCommand extends Command { context: PubContext.getVerifyContext(name), generateSyntheticPackage: project.manifest.generateSyntheticPackage, ); - // All done updating dependencies. Release the cache lock. - Cache.releaseLock(); await project.regeneratePlatformSpecificTooling(); - } else { - Cache.releaseLock(); } setupApplicationPackages(); diff --git a/packages/flutter_tools/test/general.shard/base/build_test.dart b/packages/flutter_tools/test/general.shard/base/build_test.dart index b061e3c7c1..a73029708e 100644 --- a/packages/flutter_tools/test/general.shard/base/build_test.dart +++ b/packages/flutter_tools/test/general.shard/base/build_test.dart @@ -225,7 +225,6 @@ void main() { darwinArch: DarwinArch.arm64, buildMode: BuildMode.debug, mainPath: 'main.dill', - packagesPath: '.packages', outputPath: outputPath, bitcode: false, splitDebugInfo: null, @@ -240,7 +239,6 @@ void main() { platform: TargetPlatform.android_arm, buildMode: BuildMode.debug, mainPath: 'main.dill', - packagesPath: '.packages', outputPath: outputPath, bitcode: false, splitDebugInfo: null, @@ -255,7 +253,6 @@ void main() { platform: TargetPlatform.android_arm64, buildMode: BuildMode.debug, mainPath: 'main.dill', - packagesPath: '.packages', outputPath: outputPath, bitcode: false, splitDebugInfo: null, @@ -311,7 +308,6 @@ void main() { platform: TargetPlatform.ios, buildMode: BuildMode.profile, mainPath: 'main.dill', - packagesPath: '.packages', outputPath: outputPath, darwinArch: DarwinArch.armv7, bitcode: true, @@ -373,7 +369,6 @@ void main() { platform: TargetPlatform.ios, buildMode: BuildMode.profile, mainPath: 'main.dill', - packagesPath: '.packages', outputPath: outputPath, darwinArch: DarwinArch.armv7, bitcode: false, @@ -433,7 +428,6 @@ void main() { platform: TargetPlatform.ios, buildMode: BuildMode.profile, mainPath: 'main.dill', - packagesPath: '.packages', outputPath: outputPath, darwinArch: DarwinArch.armv7, bitcode: false, @@ -492,7 +486,6 @@ void main() { platform: TargetPlatform.ios, buildMode: BuildMode.release, mainPath: 'main.dill', - packagesPath: '.packages', outputPath: outputPath, darwinArch: DarwinArch.armv7, bitcode: false, @@ -548,7 +541,6 @@ void main() { platform: TargetPlatform.ios, buildMode: BuildMode.release, mainPath: 'main.dill', - packagesPath: '.packages', outputPath: outputPath, darwinArch: DarwinArch.arm64, bitcode: false, @@ -581,7 +573,6 @@ void main() { platform: TargetPlatform.android_arm, buildMode: BuildMode.release, mainPath: 'main.dill', - packagesPath: '.packages', outputPath: outputPath, bitcode: false, splitDebugInfo: null, @@ -616,7 +607,6 @@ void main() { platform: TargetPlatform.android_arm, buildMode: BuildMode.release, mainPath: 'main.dill', - packagesPath: '.packages', outputPath: outputPath, bitcode: false, splitDebugInfo: 'foo', @@ -649,7 +639,6 @@ void main() { platform: TargetPlatform.android_arm, buildMode: BuildMode.release, mainPath: 'main.dill', - packagesPath: '.packages', outputPath: outputPath, bitcode: false, splitDebugInfo: null, @@ -681,7 +670,6 @@ void main() { platform: TargetPlatform.android_arm, buildMode: BuildMode.release, mainPath: 'main.dill', - packagesPath: '.packages', outputPath: outputPath, bitcode: false, splitDebugInfo: '', @@ -711,7 +699,6 @@ void main() { platform: TargetPlatform.android_arm64, buildMode: BuildMode.release, mainPath: 'main.dill', - packagesPath: '.packages', outputPath: outputPath, bitcode: false, splitDebugInfo: null, diff --git a/packages/flutter_tools/test/general.shard/cache_test.dart b/packages/flutter_tools/test/general.shard/cache_test.dart index 0e2bca75c5..e12efc1077 100644 --- a/packages/flutter_tools/test/general.shard/cache_test.dart +++ b/packages/flutter_tools/test/general.shard/cache_test.dart @@ -743,9 +743,6 @@ void main() { verify(pub.get( context: PubContext.pubGet, directory: 'packages/flutter_tools', - generateSyntheticPackage: false, - skipPubspecYamlCheck: true, - checkLastModified: false, )).called(1); }); } diff --git a/packages/flutter_tools/test/general.shard/dart/pub_get_test.dart b/packages/flutter_tools/test/general.shard/dart/pub_get_test.dart index 1b76f9d8e8..6919771558 100644 --- a/packages/flutter_tools/test/general.shard/dart/pub_get_test.dart +++ b/packages/flutter_tools/test/general.shard/dart/pub_get_test.dart @@ -49,7 +49,7 @@ void main() { FakeAsync().run((FakeAsync time) { expect(processMock.lastPubEnvironment, isNull); expect(logger.statusText, ''); - pub.get(context: PubContext.flutterTests, checkLastModified: false).then((void value) { + pub.get(context: PubContext.flutterTests).then((void value) { error = 'test completed unexpectedly'; }, onError: (dynamic thrownError) { error = 'test failed unexpectedly: $thrownError'; @@ -114,7 +114,7 @@ void main() { processManager: MockProcessManager(66, stderr: 'err1\nerr2\nerr3\n', stdout: 'out1\nout2\nout3\n'), ); try { - await pub.get(context: PubContext.flutterTests, checkLastModified: false); + await pub.get(context: PubContext.flutterTests); throw AssertionError('pubGet did not fail'); } on ToolExit catch (error) { expect(error.message, 'pub get failed (66; err3)'); @@ -149,7 +149,7 @@ void main() { MockDirectory.findCache = true; expect(processMock.lastPubEnvironment, isNull); expect(processMock.lastPubCache, isNull); - pub.get(context: PubContext.flutterTests, checkLastModified: false).then((void value) { + pub.get(context: PubContext.flutterTests).then((void value) { error = 'test completed unexpectedly'; }, onError: (dynamic thrownError) { error = 'test failed unexpectedly: $thrownError'; @@ -182,7 +182,7 @@ void main() { expect(processMock.lastPubCache, isNull); String error; - pub.get(context: PubContext.flutterTests, checkLastModified: false).then((void value) { + pub.get(context: PubContext.flutterTests).then((void value) { error = 'test completed unexpectedly'; }, onError: (dynamic thrownError) { error = 'test failed unexpectedly: $thrownError'; @@ -217,7 +217,6 @@ void main() { await pub.get( context: PubContext.flutterTests, generateSyntheticPackage: true, - checkLastModified: false, ); verify(usage.sendEvent('pub-result', 'flutter-tests', label: 'success')).called(1); @@ -255,7 +254,6 @@ void main() { await pub.get( context: PubContext.flutterTests, generateSyntheticPackage: true, - checkLastModified: false, ); expect( @@ -285,7 +283,7 @@ void main() { ), ); try { - await pub.get(context: PubContext.flutterTests, checkLastModified: false); + await pub.get(context: PubContext.flutterTests); } on ToolExit { // Ignore. } @@ -314,7 +312,7 @@ void main() { fileSystem.file('pubspec.yaml').writeAsStringSync('name: foo'); try { - await pub.get(context: PubContext.flutterTests, checkLastModified: false); + await pub.get(context: PubContext.flutterTests); } on ToolExit { // Ignore. } @@ -386,7 +384,7 @@ void main() { fileSystem.file('pubspec.yaml') ..createSync() ..setLastModifiedSync(DateTime(2001)); - await pub.get(context: PubContext.flutterTests, checkLastModified: true); // pub sets date of .packages to 2002 + await pub.get(context: PubContext.flutterTests); // pub sets date of .packages to 2002 expect(logger.statusText, 'Running "flutter pub get" in /...\n'); expect(logger.errorText, isEmpty); @@ -398,44 +396,12 @@ void main() { .setLastModifiedSync(DateTime(2000)); fileSystem.file('pubspec.yaml') .setLastModifiedSync(DateTime(2001)); - await pub.get(context: PubContext.flutterTests, checkLastModified: true); // pub does nothing + await pub.get(context: PubContext.flutterTests); // pub does nothing expect(logger.statusText, 'Running "flutter pub get" in /...\n'); expect(logger.errorText, isEmpty); expect(fileSystem.file('pubspec.yaml').lastModifiedSync(), DateTime(2001)); // because nothing should touch it logger.clear(); - - // bad scenario 2: pub changes pubspec.yaml instead - fileSystem.file('.dart_tool/package_config.json') - .setLastModifiedSync(DateTime(2000)); - fileSystem.file('pubspec.yaml') - .setLastModifiedSync(DateTime(2001)); - try { - await pub.get(context: PubContext.flutterTests, checkLastModified: true); - expect(true, isFalse, reason: 'pub.get did not throw'); - } on ToolExit catch (error) { - expect(error.message, '/: unexpected concurrent modification of pubspec.yaml while running pub.'); - } - expect(logger.statusText, 'Running "flutter pub get" in /...\n'); - expect(logger.errorText, isEmpty); - expect(fileSystem.file('pubspec.yaml').lastModifiedSync(), DateTime(2002)); // because fake pub above touched it - - // bad scenario 3: pubspec.yaml was created in the future - fileSystem.file('.dart_tool/package_config.json') - .setLastModifiedSync(DateTime(2000)); - fileSystem.file('pubspec.yaml') - .setLastModifiedSync(DateTime(9999)); - assert(DateTime(9999).isAfter(DateTime.now())); - - await pub.get(context: PubContext.flutterTests, checkLastModified: true); // pub does nothing - - expect(logger.statusText, contains('Running "flutter pub get" in /...\n')); - expect(logger.errorText, startsWith( - 'Warning: File "/pubspec.yaml" was created in the future. Optimizations that rely on ' - 'comparing time stamps will be unreliable. Check your system clock for accuracy.\n' - 'The timestamp was:' - )); - logger.clear(); }); } diff --git a/packages/flutter_tools/test/integration.shard/downgrade_upgrade_integration_test.dart b/packages/flutter_tools/test/integration.shard/downgrade_upgrade_integration_test.dart index f5e71ed1b1..0d07c6c2f8 100644 --- a/packages/flutter_tools/test/integration.shard/downgrade_upgrade_integration_test.dart +++ b/packages/flutter_tools/test/integration.shard/downgrade_upgrade_integration_test.dart @@ -23,7 +23,8 @@ final ProcessUtils processUtils = ProcessUtils(processManager: processManager, l stdio: stdio, outputPreferences: OutputPreferences.test(wrapText: true), )); -final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter'); +final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', platform.isWindows ? 'flutter.bat' : 'flutter'); +final String dartBin = fileSystem.path.join(getFlutterRoot(), 'bin', platform.isWindows ? 'dart.bat' : 'dart'); /// A test for flutter upgrade & downgrade that checks out a parallel flutter repo. void main() {