diff --git a/packages/flutter_tools/lib/src/dart/pub.dart b/packages/flutter_tools/lib/src/dart/pub.dart index 15b4a6fed9..36714c2b75 100644 --- a/packages/flutter_tools/lib/src/dart/pub.dart +++ b/packages/flutter_tools/lib/src/dart/pub.dart @@ -609,7 +609,6 @@ class _DefaultPub implements Pub { /// We only want to inform about existing caches on first run of a freshly /// downloaded Flutter SDK. Therefore it is conditioned on the existence /// of the .pub-preload-cache dir. - _informAboutExistingCaches(); final Iterable cacheFiles = preloadCacheDir .listSync() @@ -620,50 +619,6 @@ class _DefaultPub implements Pub { } } - /// Issues a log message if there is an existing pub cache and or an existing - /// Dart Analysis Server cache. - void _informAboutExistingCaches() { - final String? pubCachePath = _pubCacheDefaultLocation(); - if (pubCachePath != null) { - final Directory pubCacheDirectory = _fileSystem.directory(pubCachePath); - if (pubCacheDirectory.existsSync()) { - _logger.printStatus(''' -Found an existing Pub cache at $pubCachePath. -It can be repaired by running `dart pub cache repair`. -It can be reset by running `dart pub cache clean`.'''); - } - } - final String? home = _platform.environment['HOME']; - if (home != null) { - final String dartServerCachePath = _fileSystem.path.join(home, '.dartServer'); - if (_fileSystem.directory(dartServerCachePath).existsSync()) { - _logger.printStatus(''' -Found an existing Dart Analysis Server cache at $dartServerCachePath. -It can be reset by deleting $dartServerCachePath.'''); - } - } - } - - /// The default location of the Pub cache if the PUB_CACHE environment variable - /// is not set. - /// - /// Returns null if the appropriate environment variables are unset. - String? _pubCacheDefaultLocation () { - if (_platform.isWindows) { - final String? localAppData = _platform.environment['LOCALAPPDATA']; - if (localAppData == null) { - return null; - } - return _fileSystem.path.join(localAppData, 'Pub', 'Cache'); - } else { - final String? home = _platform.environment['HOME']; - if (home == null) { - return null; - } - return _fileSystem.path.join(home, '.pub-cache'); - } - } - /// The full environment used when running pub. /// /// [context] provides extra information to package server requests to 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 515cf6321f..4e08a75500 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 @@ -866,98 +866,11 @@ exit code: 66 await pub.get( project: FlutterProject.fromDirectoryTest(fileSystem.currentDirectory), context: PubContext.flutterTests); - expect(logger.statusText, isNot(contains('Found an existing Pub cache'))); - expect(logger.statusText, - isNot(contains('Found an existing Dart Analysis Server cache'))); expect(processManager, hasNoRemainingExpectations); expect(preloadCache.existsSync(), false); }); - testWithoutContext('Notifies about existing caches, on first run only', - () async { - final FileSystem fileSystem = MemoryFileSystem.test(); - final Directory preloadCache = - fileSystem.currentDirectory.childDirectory('.pub-preload-cache'); - preloadCache.childFile('a.tar.gz').createSync(recursive: true); - fileSystem.currentDirectory.childFile('version').createSync(); - fileSystem.directory('/global/.pub-cache').createSync(recursive: true); - fileSystem.directory('/global/.dartServer').createSync(recursive: true); - - const FakeCommand dartPreloadCommand = FakeCommand( - command: [ - 'bin/cache/dart-sdk/bin/dart', - 'pub', - '--suppress-analytics', - 'cache', - 'preload', - '.pub-preload-cache/a.tar.gz', - ], - ); - final FakeCommand dartPubGetCommand = FakeCommand( - command: const [ - 'bin/cache/dart-sdk/bin/dart', - 'pub', - '--suppress-analytics', - '--directory', - '.', - 'get', - '--example', - ], - environment: const { - 'FLUTTER_ROOT': '', - 'PUB_ENVIRONMENT': 'flutter_cli:flutter_tests', - }, - onRun: (_) { - fileSystem.currentDirectory - .childDirectory('.dart_tool') - .childFile('package_config.json') - .createSync(recursive: true); - }); - - final FakeProcessManager processManager = - FakeProcessManager.list([ - dartPreloadCommand, - dartPubGetCommand, - dartPubGetCommand, - ]); - - final Platform platform = - FakePlatform(environment: {'HOME': '/global'}); - final BufferLogger logger = BufferLogger.test(); - final Pub pub = Pub.test( - platform: platform, - usage: TestUsage(), - fileSystem: fileSystem, - logger: logger, - processManager: processManager, - botDetector: const BotDetectorAlwaysNo(), - stdio: FakeStdio(), - ); - - await pub.get( - project: FlutterProject.fromDirectoryTest(fileSystem.currentDirectory), - context: PubContext.flutterTests); - expect(logger.statusText, - contains('Found an existing Pub cache at /global/.pub-cache')); - expect(logger.statusText, - contains('It can be reset by running `dart pub cache clean`')); - expect( - logger.statusText, - contains( - 'Found an existing Dart Analysis Server cache at /global/.dartServer'), - ); - expect(preloadCache.existsSync(), false); - logger.clear(); - await pub.get( - project: FlutterProject.fromDirectoryTest(fileSystem.currentDirectory), - context: PubContext.flutterTests); - expect(logger.statusText, isNot(contains('Found an existing Pub cache'))); - expect(logger.statusText, - isNot(contains('Found an existing Dart Analysis Server cache'))); - expect(processManager, hasNoRemainingExpectations); - }); - testWithoutContext('pub cache in environment is used', () async { final FileSystem fileSystem = MemoryFileSystem.test(); fileSystem.directory('custom/pub-cache/path').createSync(recursive: true);