diff --git a/packages/flutter_tools/lib/src/dart/package_map.dart b/packages/flutter_tools/lib/src/dart/package_map.dart index cd5f14b721..b078f43761 100644 --- a/packages/flutter_tools/lib/src/dart/package_map.dart +++ b/packages/flutter_tools/lib/src/dart/package_map.dart @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:async'; import 'dart:typed_data'; import 'package:meta/meta.dart'; @@ -32,9 +33,10 @@ String _globalPackagesPath; Future loadPackageConfigWithLogging(File file, { @required Logger logger, bool throwOnError = true, -}) { +}) async { final FileSystem fileSystem = file.fileSystem; - return loadPackageConfigUri( + bool didError = false; + final PackageConfig result = await loadPackageConfigUri( file.absolute.uri, loader: (Uri uri) { final File configFile = fileSystem.file(uri); @@ -56,7 +58,11 @@ Future loadPackageConfigWithLogging(File file, { message += '\nDid you run this command from the same directory as your pubspec.yaml file?'; } logger.printError(message); - throwToolExit(file.path); + didError = true; } ); + if (didError) { + throwToolExit(null); + } + return result; } diff --git a/packages/flutter_tools/lib/src/globals.dart b/packages/flutter_tools/lib/src/globals.dart index 88b803e01d..874874dee2 100644 --- a/packages/flutter_tools/lib/src/globals.dart +++ b/packages/flutter_tools/lib/src/globals.dart @@ -66,13 +66,11 @@ FileSystem get fs => ErrorHandlingFileSystem( platform: platform, ); -final FileSystemUtils _defaultFileSystemUtils = FileSystemUtils( +FileSystemUtils get fsUtils => context.get() ?? FileSystemUtils( fileSystem: fs, platform: platform, ); -FileSystemUtils get fsUtils => context.get() ?? _defaultFileSystemUtils; - const ProcessManager _kLocalProcessManager = LocalProcessManager(); /// The active process manager. diff --git a/packages/flutter_tools/lib/src/run_hot.dart b/packages/flutter_tools/lib/src/run_hot.dart index 6a05ccc203..219c56c03d 100644 --- a/packages/flutter_tools/lib/src/run_hot.dart +++ b/packages/flutter_tools/lib/src/run_hot.dart @@ -26,8 +26,7 @@ import 'reporting/reporting.dart'; import 'resident_runner.dart'; import 'vmservice.dart'; -ProjectFileInvalidator get projectFileInvalidator => context.get() ?? _defaultInvalidator; -final ProjectFileInvalidator _defaultInvalidator = ProjectFileInvalidator( +ProjectFileInvalidator get projectFileInvalidator => context.get() ?? ProjectFileInvalidator( fileSystem: globals.fs, platform: globals.platform, logger: globals.logger, diff --git a/packages/flutter_tools/test/general.shard/base/logs_test.dart b/packages/flutter_tools/test/general.shard/base/logs_test.dart index c29ef2726c..acd8a92d54 100644 --- a/packages/flutter_tools/test/general.shard/base/logs_test.dart +++ b/packages/flutter_tools/test/general.shard/base/logs_test.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'package:flutter_tools/src/base/common.dart'; +import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/commands/logs.dart'; import '../../src/common.dart'; @@ -11,6 +12,14 @@ import '../../src/mocks.dart'; void main() { group('logs', () { + setUp(() { + Cache.disableLocking(); + }); + + tearDown(() { + Cache.enableLocking(); + }); + testUsingContext('fail with a bad device id', () async { final LogsCommand command = LogsCommand(); applyMocksToCommand(command); diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart index f62b268e76..d5b093fd5c 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/macos_test.dart @@ -12,7 +12,6 @@ import 'package:flutter_tools/src/build_system/build_system.dart'; import 'package:flutter_tools/src/build_system/targets/assets.dart'; import 'package:flutter_tools/src/build_system/targets/common.dart'; import 'package:flutter_tools/src/build_system/targets/macos.dart'; -import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/convert.dart'; import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/macos/xcode.dart'; @@ -26,26 +25,26 @@ import '../../../src/testbed.dart'; const String _kInputPrefix = 'bin/cache/artifacts/engine/darwin-x64/FlutterMacOS.framework'; const String _kOutputPrefix = 'FlutterMacOS.framework'; -final List inputs = [ - globals.fs.file('$_kInputPrefix/FlutterMacOS'), +final List inputs = [ + '$_kInputPrefix/FlutterMacOS', // Headers - globals.fs.file('$_kInputPrefix/Headers/FlutterDartProject.h'), - globals.fs.file('$_kInputPrefix/Headers/FlutterEngine.h'), - globals.fs.file('$_kInputPrefix/Headers/FlutterViewController.h'), - globals.fs.file('$_kInputPrefix/Headers/FlutterBinaryMessenger.h'), - globals.fs.file('$_kInputPrefix/Headers/FlutterChannels.h'), - globals.fs.file('$_kInputPrefix/Headers/FlutterCodecs.h'), - globals.fs.file('$_kInputPrefix/Headers/FlutterMacros.h'), - globals.fs.file('$_kInputPrefix/Headers/FlutterPluginMacOS.h'), - globals.fs.file('$_kInputPrefix/Headers/FlutterPluginRegistrarMacOS.h'), - globals.fs.file('$_kInputPrefix/Headers/FlutterMacOS.h'), + '$_kInputPrefix/Headers/FlutterDartProject.h', + '$_kInputPrefix/Headers/FlutterEngine.h', + '$_kInputPrefix/Headers/FlutterViewController.h', + '$_kInputPrefix/Headers/FlutterBinaryMessenger.h', + '$_kInputPrefix/Headers/FlutterChannels.h', + '$_kInputPrefix/Headers/FlutterCodecs.h', + '$_kInputPrefix/Headers/FlutterMacros.h', + '$_kInputPrefix/Headers/FlutterPluginMacOS.h', + '$_kInputPrefix/Headers/FlutterPluginRegistrarMacOS.h', + '$_kInputPrefix/Headers/FlutterMacOS.h', // Modules - globals.fs.file('$_kInputPrefix/Modules/module.modulemap'), + '$_kInputPrefix/Modules/module.modulemap', // Resources - globals.fs.file('$_kInputPrefix/Resources/icudtl.dat'), - globals.fs.file('$_kInputPrefix/Resources/Info.plist'), + '$_kInputPrefix/Resources/icudtl.dat', + '$_kInputPrefix/Resources/Info.plist', // Ignore Versions folder for now - globals.fs.file('packages/flutter_tools/lib/src/build_system/targets/macos.dart'), + 'packages/flutter_tools/lib/src/build_system/targets/macos.dart', ]; void main() { @@ -53,11 +52,6 @@ void main() { Environment environment; Platform platform; - setUpAll(() { - Cache.disableLocking(); - Cache.flutterRoot = ''; - }); - setUp(() { platform = FakePlatform(operatingSystem: 'macos', environment: {}); testbed = Testbed(setup: () { @@ -82,8 +76,8 @@ void main() { }); test('Copies files to correct cache directory', () => testbed.run(() async { - for (final File input in inputs) { - input.createSync(recursive: true); + for (final String input in inputs) { + globals.fs.file(input).createSync(recursive: true); } // Create output directory so we can test that it is deleted. environment.outputDir.childDirectory(_kOutputPrefix) @@ -111,8 +105,8 @@ void main() { await const DebugUnpackMacOS().build(environment); expect(globals.fs.directory(_kOutputPrefix).existsSync(), true); - for (final File file in inputs) { - expect(globals.fs.file(file.path.replaceFirst(_kInputPrefix, _kOutputPrefix)), exists); + for (final String path in inputs) { + expect(globals.fs.file(path.replaceFirst(_kInputPrefix, _kOutputPrefix)), exists); } })); diff --git a/packages/flutter_tools/test/general.shard/macos/xcode_test.dart b/packages/flutter_tools/test/general.shard/macos/xcode_test.dart index afbaa644c8..4f9008c715 100644 --- a/packages/flutter_tools/test/general.shard/macos/xcode_test.dart +++ b/packages/flutter_tools/test/general.shard/macos/xcode_test.dart @@ -538,6 +538,7 @@ void main() { expect(fakeProcessManager.hasRemainingExpectations, isFalse); }, overrides: { Platform: () => macPlatform, + Artifacts: () => Artifacts.test(), }); testWithoutContext('uses timeout', () async { @@ -596,6 +597,7 @@ void main() { expect(fakeProcessManager.hasRemainingExpectations, isFalse); }, overrides: { Platform: () => macPlatform, + Artifacts: () => Artifacts.test(), }); testUsingContext('handles unknown architectures', () async { @@ -644,6 +646,7 @@ void main() { expect(fakeProcessManager.hasRemainingExpectations, isFalse); }, overrides: { Platform: () => macPlatform, + Artifacts: () => Artifacts.test(), }); }); diff --git a/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart b/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart index 813fbc8cb2..666ad2f23c 100644 --- a/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart +++ b/packages/flutter_tools/test/general.shard/resident_web_runner_test.dart @@ -7,7 +7,9 @@ import 'dart:convert'; import 'dart:io'; import 'package:dwds/dwds.dart'; +import 'package:file/memory.dart'; import 'package:flutter_tools/src/base/common.dart'; +import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/platform.dart'; @@ -78,8 +80,6 @@ const List kAttachExpectations = [ ]; void main() { - Testbed testbed; - ResidentWebRunner residentWebRunner; MockDebugConnection mockDebugConnection; MockChromeDevice mockChromeDevice; MockAppConnection mockAppConnection; @@ -94,8 +94,12 @@ void main() { MockWebServerDevice mockWebServerDevice; MockDevice mockDevice; FakeVmServiceHost fakeVmServiceHost; + FileSystem fileSystem; + ProcessManager processManager; setUp(() { + fileSystem = MemoryFileSystem.test(); + processManager = FakeProcessManager.any(); mockDebugConnection = MockDebugConnection(); mockDevice = MockDevice(); mockAppConnection = MockAppConnection(); @@ -113,30 +117,13 @@ void main() { when(mockWebDevFS.connect(any)).thenAnswer((Invocation invocation) async { return ConnectionResult(mockAppConnection, mockDebugConnection); }); - testbed = Testbed( - setup: () { - globals.fs.file('.packages') - ..createSync(recursive: true) - ..writeAsStringSync('\n'); - residentWebRunner = DwdsWebRunnerFactory().createWebRunner( - mockFlutterDevice, - flutterProject: FlutterProject.current(), - debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug), - ipv6: true, - stayResident: true, - urlTunneller: null, - ) as ResidentWebRunner; - }, - overrides: { - Pub: () => MockPub(), - } - ); + fileSystem.file('.packages').writeAsStringSync('\n'); }); void _setupMocks() { - globals.fs.file('pubspec.yaml').createSync(); - globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); - globals.fs.file(globals.fs.path.join('web', 'index.html')).createSync(recursive: true); + fileSystem.file('pubspec.yaml').createSync(); + fileSystem.file('lib/main.dart').createSync(recursive: true); + fileSystem.file('web/index.html').createSync(recursive: true); when(mockWebDevFS.update( mainUri: anyNamed('mainUri'), target: anyNamed('target'), @@ -175,7 +162,8 @@ void main() { when(mockWipConnection.debugger).thenReturn(mockWipDebugger); } - test('runner with web server device does not support debugging without --start-paused', () => testbed.run(() { + testUsingContext('runner with web server device does not support debugging without --start-paused', () { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); when(mockFlutterDevice.device).thenReturn(WebServerDevice( logger: BufferLogger.test(), )); @@ -192,11 +180,20 @@ void main() { expect(profileResidentWebRunner.debuggingEnabled, false); when(mockFlutterDevice.device).thenReturn(MockChromeDevice()); + expect(residentWebRunner.debuggingEnabled, true); expect(fakeVmServiceHost.hasRemainingExpectations, false); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('runner with web server device supports debugging with --start-paused', () => testbed.run(() { + testUsingContext('runner with web server device supports debugging with --start-paused', () { + fileSystem.file('.packages') + ..createSync(recursive: true) + ..writeAsStringSync('\n'); fakeVmServiceHost = FakeVmServiceHost(requests: []); _setupMocks(); when(mockFlutterDevice.device).thenReturn(WebServerDevice( @@ -213,9 +210,24 @@ void main() { expect(profileResidentWebRunner.uri, mockWebDevFS.baseUri); expect(profileResidentWebRunner.debuggingEnabled, true); - })); - - test('profile does not supportsServiceProtocol', () => testbed.run(() { + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); + testUsingContext('profile does not supportsServiceProtocol', () { + fileSystem.file('.packages') + ..createSync(recursive: true) + ..writeAsStringSync('\n'); + final ResidentRunner residentWebRunner = DwdsWebRunnerFactory().createWebRunner( + mockFlutterDevice, + flutterProject: FlutterProject.current(), + debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug), + ipv6: true, + stayResident: true, + urlTunneller: null, + ) as ResidentWebRunner; fakeVmServiceHost = FakeVmServiceHost(requests: []); when(mockFlutterDevice.device).thenReturn(mockChromeDevice); final ResidentRunner profileResidentWebRunner = DwdsWebRunnerFactory().createWebRunner( @@ -229,20 +241,45 @@ void main() { expect(profileResidentWebRunner.supportsServiceProtocol, false); expect(residentWebRunner.supportsServiceProtocol, true); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('Exits on run if target file does not exist', () => testbed.run(() async { + testUsingContext('Exits on run if target file does not exist', () async { + fileSystem.file('.packages') + ..createSync(recursive: true) + ..writeAsStringSync('\n'); + final ResidentRunner residentWebRunner = DwdsWebRunnerFactory().createWebRunner( + mockFlutterDevice, + flutterProject: FlutterProject.current(), + debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug), + ipv6: true, + stayResident: true, + urlTunneller: null, + ) as ResidentWebRunner; fakeVmServiceHost = FakeVmServiceHost(requests: []); - globals.fs.file('pubspec.yaml').createSync(); - globals.fs.file(globals.fs.path.join('web', 'index.html')) + fileSystem.file('pubspec.yaml').createSync(); + fileSystem.file(fileSystem.path.join('web', 'index.html')) .createSync(recursive: true); expect(await residentWebRunner.run(), 1); - final String absoluteMain = globals.fs.path.absolute(globals.fs.path.join('lib', 'main.dart')); + final String absoluteMain = fileSystem.path.absolute(fileSystem.path.join('lib', 'main.dart')); expect(testLogger.errorText, contains('Tried to run $absoluteMain, but that file does not exist.')); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('Can successfully run and connect to vmservice', () => testbed.run(() async { + testUsingContext('Can successfully run and connect to vmservice', () async { + fileSystem.file('.packages') + ..createSync(recursive: true) + ..writeAsStringSync('\n'); + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList()); _setupMocks(); final DelegateLogger delegateLogger = globals.logger as DelegateLogger; @@ -259,16 +296,21 @@ void main() { verify(status.stop()).called(1); verify(pub.get( context: PubContext.pubGet, - directory: globals.fs.path.join('packages', 'flutter_tools') + directory: anyNamed('directory'), )).called(1); expect(bufferLogger.statusText, contains('Debug service listening on ws://127.0.0.1/abcd/')); expect(debugConnectionInfo.wsUri.toString(), 'ws://127.0.0.1/abcd/'); }, overrides: { Logger: () => DelegateLogger(BufferLogger.test()), - })); + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('WebRunner copies compiled app.dill to cache during startup', () => testbed.run(() async { + testUsingContext('WebRunner copies compiled app.dill to cache during startup', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList()); _setupMocks(); @@ -279,32 +321,42 @@ void main() { )); await connectionInfoCompleter.future; - expect(await globals.fs.file(globals.fs.path.join('build', 'cache.dill')).readAsString(), 'ABC'); - })); + expect(await fileSystem.file(fileSystem.path.join('build', 'cache.dill')).readAsString(), 'ABC'); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('Can successfully run without an index.html including status warning', () => testbed.run(() async { + testUsingContext('Can successfully run without an index.html including status warning', () async { fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList()); _setupMocks(); - globals.fs.file(globals.fs.path.join('web', 'index.html')) + fileSystem.file(fileSystem.path.join('web', 'index.html')) .deleteSync(); - residentWebRunner = DwdsWebRunnerFactory().createWebRunner( - mockFlutterDevice, - flutterProject: FlutterProject.current(), - debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug), - ipv6: true, - stayResident: false, - urlTunneller: null, - ) as ResidentWebRunner; + final ResidentWebRunner residentWebRunner = DwdsWebRunnerFactory().createWebRunner( + mockFlutterDevice, + flutterProject: FlutterProject.current(), + debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug), + ipv6: true, + stayResident: false, + urlTunneller: null, + ) as ResidentWebRunner; expect(await residentWebRunner.run(), 0); expect(testLogger.statusText, contains('This application is not configured to build on the web')); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('Can successfully run and disconnect with --no-resident', () => testbed.run(() async { + testUsingContext('Can successfully run and disconnect with --no-resident', () async { fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList()); _setupMocks(); - residentWebRunner = DwdsWebRunnerFactory().createWebRunner( + final ResidentRunner residentWebRunner = DwdsWebRunnerFactory().createWebRunner( mockFlutterDevice, flutterProject: FlutterProject.current(), debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug), @@ -314,9 +366,15 @@ void main() { ) as ResidentWebRunner; expect(await residentWebRunner.run(), 0); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('Listens to stdout and stderr streams before running main', () => testbed.run(() async { + testUsingContext('Listens to stdout and stderr streams before running main', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: [ ...kAttachLogExpectations, FakeVmServiceStreamResponse( @@ -346,9 +404,15 @@ void main() { expect(testLogger.statusText, contains('THIS MESSAGE IS IMPORTANT')); expect(testLogger.statusText, contains('SO IS THIS')); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('Listens to extension events with structured errors', () => testbed.run(() async { + testUsingContext('Listens to extension events with structured errors', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); final Map extensionData = { 'test': 'data', 'renderedErrorText': 'error text', @@ -408,11 +472,15 @@ void main() { expect(testLogger.statusText, contains('\nerror text')); expect(testLogger.statusText, isNot(contains('other stuff'))); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('Does not run main with --start-paused', () => testbed.run(() async { - fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList()); - residentWebRunner = DwdsWebRunnerFactory().createWebRunner( + testUsingContext('Does not run main with --start-paused', () async { + final ResidentRunner residentWebRunner = DwdsWebRunnerFactory().createWebRunner( mockFlutterDevice, flutterProject: FlutterProject.current(), debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug, startPaused: true), @@ -420,6 +488,7 @@ void main() { stayResident: true, urlTunneller: null, ) as ResidentWebRunner; + fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList()); _setupMocks(); final Completer connectionInfoCompleter = Completer(); @@ -429,9 +498,15 @@ void main() { await connectionInfoCompleter.future; verifyNever(mockAppConnection.runMain()); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('Can hot reload after attaching', () => testbed.run(() async { + testUsingContext('Can hot reload after attaching', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: [ ...kAttachExpectations, const FakeVmServiceRequest( @@ -451,7 +526,7 @@ void main() { return mockChrome; }); when(mockFlutterDevice.device).thenReturn(GoogleChromeDevice( - fileSystem: globals.fs, + fileSystem: fileSystem, chromiumLauncher: chromiumLauncher, logger: globals.logger, platform: FakePlatform(operatingSystem: 'linux'), @@ -505,9 +580,14 @@ void main() { verify(globals.flutterUsage.sendTiming('hot', 'web-incremental-restart', any)).called(1); }, overrides: { Usage: () => MockFlutterUsage(), - })); + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('Can hot restart after attaching', () => testbed.run(() async { + testUsingContext('Can hot restart after attaching', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: [ ...kAttachExpectations, const FakeVmServiceRequest( @@ -528,7 +608,7 @@ void main() { }); when(chromiumLauncher.canFindExecutable()).thenReturn(true); when(mockFlutterDevice.device).thenReturn(GoogleChromeDevice( - fileSystem: globals.fs, + fileSystem: fileSystem, chromiumLauncher: chromiumLauncher, logger: globals.logger, platform: FakePlatform(operatingSystem: 'linux'), @@ -564,7 +644,7 @@ void main() { // Ensure that generated entrypoint is generated correctly. expect(entrypointFileUri, isNotNull); - final String entrypointContents = globals.fs.file(entrypointFileUri).readAsStringSync(); + final String entrypointContents = fileSystem.file(entrypointFileUri).readAsStringSync(); expect(entrypointContents, contains('// Flutter web bootstrap script')); expect(entrypointContents, contains("import 'dart:ui' as ui;")); expect(entrypointContents, contains('await ui.webOnlyInitializePlatform();')); @@ -585,9 +665,14 @@ void main() { verify(globals.flutterUsage.sendTiming('hot', 'web-incremental-restart', any)).called(1); }, overrides: { Usage: () => MockFlutterUsage(), - })); + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('Can hot restart after attaching with web-server device', () => testbed.run(() async { + testUsingContext('Can hot restart after attaching with web-server device', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests :kAttachExpectations); _setupMocks(); when(mockFlutterDevice.device).thenReturn(mockWebServerDevice); @@ -623,15 +708,26 @@ void main() { verifyNever(globals.flutterUsage.sendTiming('hot', 'web-incremental-restart', any)); }, overrides: { Usage: () => MockFlutterUsage(), - })); + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('web resident runner is debuggable', () => testbed.run(() { + testUsingContext('web resident runner is debuggable', () { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList()); expect(residentWebRunner.debuggingEnabled, true); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('web resident runner can toggle CanvasKit', () => testbed.run(() async { + testUsingContext('web resident runner can toggle CanvasKit', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: []); final WebAssetServer webAssetServer = WebAssetServer(null, null, null, null, null); when(mockWebDevFS.webAssetServer).thenReturn(webAssetServer); @@ -643,9 +739,15 @@ void main() { expect(webAssetServer.canvasKitRendering, true); expect(toggleResult, true); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('Exits when initial compile fails', () => testbed.run(() async { + testUsingContext('Exits when initial compile fails', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: []); _setupMocks(); when(mockWebDevFS.update( @@ -674,9 +776,14 @@ void main() { verifyNever(globals.flutterUsage.sendTiming('hot', 'web-restart', any)); }, overrides: { Usage: () => MockFlutterUsage(), - })); + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('Faithfully displays stdout messages with leading/trailing spaces', () => testbed.run(() async { + testUsingContext('Faithfully displays stdout messages with leading/trailing spaces', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: [ ...kAttachLogExpectations, FakeVmServiceStreamResponse( @@ -701,9 +808,15 @@ void main() { expect(testLogger.statusText, contains(' This is a message with 4 leading and trailing spaces ')); expect(fakeVmServiceHost.hasRemainingExpectations, false); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('Fails on compilation errors in hot restart', () => testbed.run(() async { + testUsingContext('Fails on compilation errors in hot restart', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: kAttachExpectations.toList()); _setupMocks(); final Completer connectionInfoCompleter = Completer(); @@ -736,9 +849,14 @@ void main() { verifyNever(globals.flutterUsage.sendTiming('hot', 'web-restart', any)); }, overrides: { Usage: () => MockFlutterUsage(), - })); + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('Fails non-fatally on vmservice response error for hot restart', () => testbed.run(() async { + testUsingContext('Fails non-fatally on vmservice response error for hot restart', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: [ ...kAttachExpectations, const FakeVmServiceRequest( @@ -758,9 +876,15 @@ void main() { final OperationResult result = await residentWebRunner.restart(fullRestart: false); expect(result.code, 0); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('Fails fatally on Vm Service error response', () => testbed.run(() async { + testUsingContext('Fails fatally on Vm Service error response', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: [ ...kAttachExpectations, const FakeVmServiceRequest( @@ -780,18 +904,30 @@ void main() { expect(result.code, 1); expect(result.message, contains(RPCErrorCodes.kInternalError.toString())); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('printHelp without details has web warning', () => testbed.run(() async { + testUsingContext('printHelp without details has web warning', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: []); residentWebRunner.printHelp(details: false); expect(testLogger.statusText, contains('Warning')); expect(testLogger.statusText, contains('https://flutter.dev/web')); expect(testLogger.statusText, isNot(contains('https://flutter.dev/web.'))); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('debugDumpApp', () => testbed.run(() async { + testUsingContext('debugDumpApp', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: [ ...kAttachExpectations, const FakeVmServiceRequest( @@ -810,9 +946,15 @@ void main() { await residentWebRunner.debugDumpApp(); expect(fakeVmServiceHost.hasRemainingExpectations, false); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('debugDumpLayerTree', () => testbed.run(() async { + testUsingContext('debugDumpLayerTree', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: [ ...kAttachExpectations, const FakeVmServiceRequest( @@ -831,9 +973,15 @@ void main() { await residentWebRunner.debugDumpLayerTree(); expect(fakeVmServiceHost.hasRemainingExpectations, false); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('debugDumpRenderTree', () => testbed.run(() async { + testUsingContext('debugDumpRenderTree', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: [ ...kAttachExpectations, const FakeVmServiceRequest( @@ -852,9 +1000,15 @@ void main() { await residentWebRunner.debugDumpRenderTree(); expect(fakeVmServiceHost.hasRemainingExpectations, false); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('debugDumpSemanticsTreeInTraversalOrder', () => testbed.run(() async { + testUsingContext('debugDumpSemanticsTreeInTraversalOrder', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: [ ...kAttachExpectations, const FakeVmServiceRequest( @@ -873,9 +1027,15 @@ void main() { await residentWebRunner.debugDumpSemanticsTreeInTraversalOrder(); expect(fakeVmServiceHost.hasRemainingExpectations, false); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('debugDumpSemanticsTreeInInverseHitTestOrder', () => testbed.run(() async { + testUsingContext('debugDumpSemanticsTreeInInverseHitTestOrder', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: [ ...kAttachExpectations, const FakeVmServiceRequest( @@ -895,9 +1055,15 @@ void main() { await residentWebRunner.debugDumpSemanticsTreeInInverseHitTestOrder(); expect(fakeVmServiceHost.hasRemainingExpectations, false); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('debugToggleDebugPaintSizeEnabled', () => testbed.run(() async { + testUsingContext('debugToggleDebugPaintSizeEnabled', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: [ ...kAttachExpectations, const FakeVmServiceRequest( @@ -930,10 +1096,15 @@ void main() { await residentWebRunner.debugToggleDebugPaintSizeEnabled(); expect(fakeVmServiceHost.hasRemainingExpectations, false); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - - test('debugTogglePerformanceOverlayOverride', () => testbed.run(() async { + testUsingContext('debugTogglePerformanceOverlayOverride', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: [ ...kAttachExpectations, const FakeVmServiceRequest( @@ -966,9 +1137,15 @@ void main() { await residentWebRunner.debugTogglePerformanceOverlayOverride(); expect(fakeVmServiceHost.hasRemainingExpectations, false); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('debugToggleWidgetInspector', () => testbed.run(() async { + testUsingContext('debugToggleWidgetInspector', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: [ ...kAttachExpectations, const FakeVmServiceRequest( @@ -1001,9 +1178,15 @@ void main() { await residentWebRunner.debugToggleWidgetInspector(); expect(fakeVmServiceHost.hasRemainingExpectations, false); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('debugToggleProfileWidgetBuilds', () => testbed.run(() async { + testUsingContext('debugToggleProfileWidgetBuilds', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: [ ...kAttachExpectations, const FakeVmServiceRequest( @@ -1036,9 +1219,15 @@ void main() { await residentWebRunner.debugToggleProfileWidgetBuilds(); expect(fakeVmServiceHost.hasRemainingExpectations, false); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('debugTogglePlatform', () => testbed.run(() async { + testUsingContext('debugTogglePlatform', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: [ ...kAttachExpectations, const FakeVmServiceRequest( @@ -1073,9 +1262,15 @@ void main() { expect(testLogger.statusText, contains('Switched operating system to fuchsia')); expect(fakeVmServiceHost.hasRemainingExpectations, false); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('debugToggleBrightness', () => testbed.run(() async { + testUsingContext('debugToggleBrightness', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: [ ...kAttachExpectations, const FakeVmServiceRequest( @@ -1110,9 +1305,15 @@ void main() { expect(testLogger.statusText, contains('Changed brightness to Brightness.dark.')); expect(fakeVmServiceHost.hasRemainingExpectations, false); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('cleanup of resources is safe to call multiple times', () => testbed.run(() async { + testUsingContext('cleanup of resources is safe to call multiple times', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: [ ...kAttachExpectations, ]); @@ -1136,9 +1337,15 @@ void main() { verifyNever(mockDebugConnection.close()); expect(fakeVmServiceHost.hasRemainingExpectations, false); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('cleans up Chrome if tab is closed', () => testbed.run(() async { + testUsingContext('cleans up Chrome if tab is closed', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: [ ...kAttachExpectations, ]); @@ -1156,9 +1363,15 @@ void main() { await result; expect(fakeVmServiceHost.hasRemainingExpectations, false); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('Prints target and device name on run', () => testbed.run(() async { + testUsingContext('Prints target and device name on run', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: [ ...kAttachExpectations, ]); @@ -1171,13 +1384,18 @@ void main() { await connectionInfoCompleter.future; expect(testLogger.statusText, contains( - 'Launching ${globals.fs.path.join('lib', 'main.dart')} on ' + 'Launching ${fileSystem.path.join('lib', 'main.dart')} on ' 'Chromez in debug mode', )); expect(fakeVmServiceHost.hasRemainingExpectations, false); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('Sends launched app.webLaunchUrl event for Chrome device', () => testbed.run(() async { + testUsingContext('Sends launched app.webLaunchUrl event for Chrome device', () async { fakeVmServiceHost = FakeVmServiceHost(requests: [ ...kAttachLogExpectations, ...kAttachIsolateExpectations, @@ -1192,7 +1410,7 @@ void main() { return mockChrome; }); when(mockFlutterDevice.device).thenReturn(GoogleChromeDevice( - fileSystem: globals.fs, + fileSystem: fileSystem, chromiumLauncher: chromiumLauncher, logger: globals.logger, platform: FakePlatform(operatingSystem: 'linux'), @@ -1246,9 +1464,13 @@ void main() { expect(fakeVmServiceHost.hasRemainingExpectations, false); }, overrides: { Logger: () => DelegateLogger(BufferLogger.test()), - })); + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('Sends unlaunched app.webLaunchUrl event for Web Server device', () => testbed.run(() async { + testUsingContext('Sends unlaunched app.webLaunchUrl event for Web Server device', () async { fakeVmServiceHost = FakeVmServiceHost(requests: []); _setupMocks(); when(mockFlutterDevice.device).thenReturn(WebServerDevice( @@ -1288,10 +1510,15 @@ void main() { ))); expect(fakeVmServiceHost.hasRemainingExpectations, false); }, overrides: { - Logger: () => DelegateLogger(BufferLogger.test()) - })); + Logger: () => DelegateLogger(BufferLogger.test()), + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('Successfully turns WebSocketException into ToolExit', () => testbed.run(() async { + testUsingContext('Successfully turns WebSocketException into ToolExit', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: []); _setupMocks(); @@ -1300,9 +1527,15 @@ void main() { await expectLater(() => residentWebRunner.run(), throwsToolExit()); expect(fakeVmServiceHost.hasRemainingExpectations, false); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('Successfully turns AppConnectionException into ToolExit', () => testbed.run(() async { + testUsingContext('Successfully turns AppConnectionException into ToolExit', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: []); _setupMocks(); @@ -1311,9 +1544,15 @@ void main() { await expectLater(() => residentWebRunner.run(), throwsToolExit()); expect(fakeVmServiceHost.hasRemainingExpectations, false); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('Successfully turns ChromeDebugError into ToolExit', () => testbed.run(() async { + testUsingContext('Successfully turns ChromeDebugError into ToolExit', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: []); _setupMocks(); @@ -1322,18 +1561,30 @@ void main() { await expectLater(() => residentWebRunner.run(), throwsToolExit()); expect(fakeVmServiceHost.hasRemainingExpectations, false); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('Rethrows unknown Exception type from dwds', () => testbed.run(() async { + testUsingContext('Rethrows unknown Exception type from dwds', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: []); _setupMocks(); when(mockWebDevFS.connect(any)).thenThrow(Exception()); await expectLater(() => residentWebRunner.run(), throwsException); expect(fakeVmServiceHost.hasRemainingExpectations, false); - })); + }, overrides: { + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); - test('Rethrows unknown Error type from dwds tooling', () => testbed.run(() async { + testUsingContext('Rethrows unknown Error type from dwds tooling', () async { + final ResidentRunner residentWebRunner = setUpResidentRunner(mockFlutterDevice); fakeVmServiceHost = FakeVmServiceHost(requests: []); _setupMocks(); final DelegateLogger delegateLogger = globals.logger as DelegateLogger; @@ -1352,8 +1603,23 @@ void main() { platform: const LocalPlatform(), ), outputPreferences: OutputPreferences.test(), - )) - })); + )), + FileSystem: () => fileSystem, + ProcessManager: () => processManager, + Pub: () => MockPub(), + Platform: () => FakePlatform(operatingSystem: 'linux', environment: {}), + }); +} + +ResidentRunner setUpResidentRunner(FlutterDevice flutterDevice) { + return DwdsWebRunnerFactory().createWebRunner( + flutterDevice, + flutterProject: FlutterProject.current(), + debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug), + ipv6: true, + stayResident: true, + urlTunneller: null, + ) as ResidentWebRunner; } class MockChromeLauncher extends Mock implements ChromiumLauncher {} diff --git a/packages/flutter_tools/test/general.shard/runner/flutter_command_test.dart b/packages/flutter_tools/test/general.shard/runner/flutter_command_test.dart index 0b638c6415..c99916a1b9 100644 --- a/packages/flutter_tools/test/general.shard/runner/flutter_command_test.dart +++ b/packages/flutter_tools/test/general.shard/runner/flutter_command_test.dart @@ -31,6 +31,7 @@ void main() { List mockTimes; setUp(() { + Cache.disableLocking(); cache = MockitoCache(); usage = MockitoUsage(); clock = MockClock(); @@ -43,6 +44,10 @@ void main() { when(mockProcessInfo.maxRss).thenReturn(10); }); + tearDown(() { + Cache.enableLocking(); + }); + testUsingContext('help text contains global options', () { final FakeDeprecatedCommand fake = FakeDeprecatedCommand(); createTestCommandRunner(fake); diff --git a/packages/flutter_tools/test/general.shard/web/golden_comparator_test.dart b/packages/flutter_tools/test/general.shard/web/golden_comparator_test.dart index eab269ee65..13f461bc0b 100644 --- a/packages/flutter_tools/test/general.shard/web/golden_comparator_test.dart +++ b/packages/flutter_tools/test/general.shard/web/golden_comparator_test.dart @@ -40,7 +40,6 @@ void main() { testbed = Testbed(overrides: { ProcessManager: () { - print('in get process manager'); return mockProcessManager; } }); diff --git a/packages/flutter_tools/test/general.shard/ios/plist_parser_test.dart b/packages/flutter_tools/test/integration.shard/plist_parser_test.dart similarity index 98% rename from packages/flutter_tools/test/general.shard/ios/plist_parser_test.dart rename to packages/flutter_tools/test/integration.shard/plist_parser_test.dart index 6c229eda9b..937e1ca6a4 100644 --- a/packages/flutter_tools/test/general.shard/ios/plist_parser_test.dart +++ b/packages/flutter_tools/test/integration.shard/plist_parser_test.dart @@ -13,8 +13,8 @@ import 'package:flutter_tools/src/base/terminal.dart'; import 'package:flutter_tools/src/ios/plist_parser.dart'; import 'package:process/process.dart'; -import '../../src/common.dart'; -import '../../src/context.dart'; +import '../src/common.dart'; +import '../src/context.dart'; const String base64PlistXml = 'PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPCFET0NUWVBFIHBsaXN0I' diff --git a/packages/flutter_tools/test/src/context.dart b/packages/flutter_tools/test/src/context.dart index 5b36c17ca5..b8d1414237 100644 --- a/packages/flutter_tools/test/src/context.dart +++ b/packages/flutter_tools/test/src/context.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'dart:async'; -import 'dart:io' as io; import 'package:flutter_tools/src/android/android_workflow.dart'; import 'package:flutter_tools/src/base/bot_detector.dart'; @@ -158,8 +157,8 @@ void testUsingContext( rethrow; } }, onError: (Object error, StackTrace stackTrace) { // ignore: deprecated_member_use - io.stdout.writeln(error); - io.stdout.writeln(stackTrace); + print(error); + print(stackTrace); _printBufferedErrors(context); throw error; });