From a14be9d2904d4d016881dbdf10d2563cb10c99f7 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Thu, 9 Sep 2021 13:31:37 -0700 Subject: [PATCH] Run the flutter_tools create test in online mode before testing offline mode (#89779) Offline pub assumes that the pub cache contains all needed packages. Running "flutter create" in online mode first will ensure that the pub cache is populated. Fixes https://github.com/flutter/flutter/issues/89759 --- .../test/commands.shard/permeable/create_test.dart | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/flutter_tools/test/commands.shard/permeable/create_test.dart b/packages/flutter_tools/test/commands.shard/permeable/create_test.dart index bdd0735191a..39f184909d7 100755 --- a/packages/flutter_tools/test/commands.shard/permeable/create_test.dart +++ b/packages/flutter_tools/test/commands.shard/permeable/create_test.dart @@ -1702,13 +1702,20 @@ void main() { }); testUsingContext( - 'invokes pub offline when requested', + 'invokes pub in online and offline modes', () async { Cache.flutterRoot = '../..'; final CreateCommand command = CreateCommand(); final CommandRunner runner = createTestCommandRunner(command); + // Run pub online first in order to populate the pub cache. + await runner.run(['create', '--pub', projectDir.path]); + expect(loggingProcessManager.commands.first, contains(matches(r'dart-sdk[\\/]bin[\\/]dart'))); + expect(loggingProcessManager.commands.first, isNot(contains('--offline'))); + + // Run pub offline. + loggingProcessManager.clear(); await runner.run(['create', '--pub', '--offline', projectDir.path]); expect(loggingProcessManager.commands.first, contains(matches(r'dart-sdk[\\/]bin[\\/]dart'))); expect(loggingProcessManager.commands.first, contains('--offline')); @@ -2820,4 +2827,8 @@ class LoggingProcessManager extends LocalProcessManager { mode: mode, ); } + + void clear() { + commands.clear(); + } }