[flutter_tools] Ensure that global variables are easily identifiable (#47398)
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/analyze_continuously_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/analyze_continuously_test.dart index 6ccca56..cc94e54 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/analyze_continuously_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/analyze_continuously_test.dart
@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/dart/pub.dart'; import 'package:flutter_tools/src/dart/sdk.dart'; import 'package:flutter_tools/src/runner/flutter_command_runner.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../../src/common.dart'; import '../../src/context.dart'; @@ -20,7 +21,7 @@ setUp(() { FlutterCommandRunner.initFlutterRoot(); - tempDir = fs.systemTempDirectory.createTempSync('flutter_analysis_test.'); + tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_analysis_test.'); }); tearDown(() { @@ -92,12 +93,12 @@ } void _createSampleProject(Directory directory, { bool brokenCode = false }) { - final File pubspecFile = fs.file(fs.path.join(directory.path, 'pubspec.yaml')); + final File pubspecFile = globals.fs.file(globals.fs.path.join(directory.path, 'pubspec.yaml')); pubspecFile.writeAsStringSync(''' name: foo_project '''); - final File dartFile = fs.file(fs.path.join(directory.path, 'lib', 'main.dart')); + final File dartFile = globals.fs.file(globals.fs.path.join(directory.path, 'lib', 'main.dart')); dartFile.parent.createSync(); dartFile.writeAsStringSync(''' void main() {
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/analyze_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/analyze_test.dart index 8e5fb42..a2c11be 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/analyze_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/analyze_test.dart
@@ -6,6 +6,7 @@ import 'package:file/memory.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/commands/analyze_base.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../../src/common.dart'; import '../../src/context.dart'; @@ -31,15 +32,15 @@ testUsingContext('inRepo', () { // Absolute paths expect(inRepo(<String>[tempDir.path]), isFalse); - expect(inRepo(<String>[fs.path.join(tempDir.path, 'foo')]), isFalse); + expect(inRepo(<String>[globals.fs.path.join(tempDir.path, 'foo')]), isFalse); expect(inRepo(<String>[Cache.flutterRoot]), isTrue); - expect(inRepo(<String>[fs.path.join(Cache.flutterRoot, 'foo')]), isTrue); + expect(inRepo(<String>[globals.fs.path.join(Cache.flutterRoot, 'foo')]), isTrue); // Relative paths - fs.currentDirectory = Cache.flutterRoot; + globals.fs.currentDirectory = Cache.flutterRoot; expect(inRepo(<String>['.']), isTrue); expect(inRepo(<String>['foo']), isTrue); - fs.currentDirectory = tempDir.path; + globals.fs.currentDirectory = tempDir.path; expect(inRepo(<String>['.']), isFalse); expect(inRepo(<String>['foo']), isFalse);
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/assemble_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/assemble_test.dart index fd7e09d..3eeef20 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/assemble_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/assemble_test.dart
@@ -9,6 +9,7 @@ import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/commands/assemble.dart'; import 'package:mockito/mockito.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../../src/common.dart'; import '../../src/context.dart'; @@ -87,8 +88,8 @@ .thenAnswer((Invocation invocation) async { return BuildResult( success: true, - inputFiles: <File>[fs.file('foo')..createSync()], - outputFiles: <File>[fs.file('bar')..createSync()], + inputFiles: <File>[globals.fs.file('foo')..createSync()], + outputFiles: <File>[globals.fs.file('bar')..createSync()], ); }); @@ -101,8 +102,8 @@ 'debug_macos_bundle_flutter_assets', ]); - final File inputs = fs.file('inputs'); - final File outputs = fs.file('outputs'); + final File inputs = globals.fs.file('inputs'); + final File outputs = globals.fs.file('outputs'); expect(inputs.readAsStringSync(), contains('foo')); expect(outputs.readAsStringSync(), contains('bar')); @@ -124,8 +125,8 @@ .thenAnswer((Invocation invocation) async { return BuildResult( success: true, - inputFiles: <File>[fs.file('foo'), fs.file('fizz')..createSync()], - outputFiles: <File>[fs.file('bar'), fs.file(fs.path.join('.dart_tool', 'fizz2'))..createSync(recursive: true)]); + inputFiles: <File>[globals.fs.file('foo'), globals.fs.file('fizz')..createSync()], + outputFiles: <File>[globals.fs.file('bar'), globals.fs.file(globals.fs.path.join('.dart_tool', 'fizz2'))..createSync(recursive: true)]); }); await commandRunner.run(<String>[ 'assemble',
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart index ccb7249..7c1dec7 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/attach_test.dart
@@ -10,7 +10,7 @@ import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/net.dart'; -import 'package:flutter_tools/src/base/platform.dart'; + import 'package:flutter_tools/src/base/terminal.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/commands/attach.dart'; @@ -26,6 +26,7 @@ import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; import 'package:quiver/testing/async.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../../src/common.dart'; import '../../src/context.dart'; @@ -41,7 +42,7 @@ Cache.disableLocking(); logger = StreamLogger(); testFileSystem = MemoryFileSystem( - style: platform.isWindows + style: globals.platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix, ); @@ -403,11 +404,11 @@ 'Observatory listening on http://127.0.0.1:$devicePort'); return mockLogReader; }); - final File foo = fs.file('lib/foo.dart') + final File foo = globals.fs.file('lib/foo.dart') ..createSync(); // Delete the main.dart file to be sure that attach works without it. - fs.file(fs.path.join('lib', 'main.dart')).deleteSync(); + globals.fs.file(globals.fs.path.join('lib', 'main.dart')).deleteSync(); final AttachCommand command = AttachCommand(hotRunnerFactory: mockHotRunnerFactory); await createTestCommandRunner(command).run(<String>['attach', '-t', foo.path, '-v']); @@ -456,10 +457,10 @@ testDeviceManager.addDevice(device); - final File foo = fs.file('lib/foo.dart')..createSync(); + final File foo = globals.fs.file('lib/foo.dart')..createSync(); // Delete the main.dart file to be sure that attach works without it. - fs.file(fs.path.join('lib', 'main.dart')).deleteSync(); + globals.fs.file(globals.fs.path.join('lib', 'main.dart')).deleteSync(); final AttachCommand command = AttachCommand(hotRunnerFactory: mockHotRunnerFactory); await createTestCommandRunner(command).run(<String>['attach', '-t', foo.path, '-v']);
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/build_aot_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/build_aot_test.dart index d5e5e98..c52fdaa 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/build_aot_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/build_aot_test.dart
@@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/build_system/build_system.dart'; import 'package:flutter_tools/src/build_system/targets/dart.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/commands/build.dart'; import 'package:mockito/mockito.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../../src/common.dart'; import '../../src/mocks.dart'; @@ -31,9 +31,9 @@ }); test('invokes assemble for android aot build.', () => testbed.run(() async { - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); - fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); + globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); when(buildSystem.build(any, any)).thenAnswer((Invocation invocation) async { return BuildResult(success: true); }); @@ -49,7 +49,7 @@ final Environment environment = verify(buildSystem.build(any, captureAny)).captured.single as Environment; expect(environment.defines, <String, String>{ - kTargetFile: fs.path.absolute(fs.path.join('lib', 'main.dart')), + kTargetFile: globals.fs.path.absolute(globals.fs.path.join('lib', 'main.dart')), kBuildMode: 'release', kTargetPlatform: 'android-arm', });
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/build_fuchsia_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/build_fuchsia_test.dart index c95035e..404ab86 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/build_fuchsia_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/build_fuchsia_test.dart
@@ -3,9 +3,10 @@ // found in the LICENSE file. import 'package:file/memory.dart'; +import 'package:platform/platform.dart'; + import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/file_system.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/commands/build.dart'; @@ -16,6 +17,7 @@ import 'package:meta/meta.dart'; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../../src/common.dart'; import '../../src/context.dart'; @@ -58,9 +60,9 @@ testUsingContext('there is no cmx file', () async { final BuildCommand command = BuildCommand(); applyMocksToCommand(command); - fs.directory('fuchsia').createSync(recursive: true); - fs.file('.packages').createSync(); - fs.file('pubspec.yaml').createSync(); + globals.fs.directory('fuchsia').createSync(recursive: true); + globals.fs.file('.packages').createSync(); + globals.fs.file('pubspec.yaml').createSync(); expect( createTestCommandRunner(command) @@ -76,12 +78,12 @@ final BuildCommand command = BuildCommand(); applyMocksToCommand(command); const String appName = 'app_name'; - fs - .file(fs.path.join('fuchsia', 'meta', '$appName.cmx')) + globals.fs + .file(globals.fs.path.join('fuchsia', 'meta', '$appName.cmx')) ..createSync(recursive: true) ..writeAsStringSync('{}'); - fs.file('.packages').createSync(); - final File pubspecFile = fs.file('pubspec.yaml')..createSync(); + globals.fs.file('.packages').createSync(); + final File pubspecFile = globals.fs.file('pubspec.yaml')..createSync(); pubspecFile.writeAsStringSync('name: $appName'); expect( @@ -98,13 +100,13 @@ final BuildCommand command = BuildCommand(); applyMocksToCommand(command); const String appName = 'app_name'; - fs - .file(fs.path.join('fuchsia', 'meta', '$appName.cmx')) + globals.fs + .file(globals.fs.path.join('fuchsia', 'meta', '$appName.cmx')) ..createSync(recursive: true) ..writeAsStringSync('{}'); - fs.file('.packages').createSync(); - fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true); - final File pubspecFile = fs.file('pubspec.yaml')..createSync(); + globals.fs.file('.packages').createSync(); + globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); + final File pubspecFile = globals.fs.file('pubspec.yaml')..createSync(); pubspecFile.writeAsStringSync('name: $appName'); expect( createTestCommandRunner(command) @@ -121,20 +123,20 @@ final BuildCommand command = BuildCommand(); applyMocksToCommand(command); const String appName = 'app_name'; - fs - .file(fs.path.join('fuchsia', 'meta', '$appName.cmx')) + globals.fs + .file(globals.fs.path.join('fuchsia', 'meta', '$appName.cmx')) ..createSync(recursive: true) ..writeAsStringSync('{}'); - fs.file('.packages').createSync(); - fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true); - final File pubspecFile = fs.file('pubspec.yaml')..createSync(); + globals.fs.file('.packages').createSync(); + globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); + final File pubspecFile = globals.fs.file('pubspec.yaml')..createSync(); pubspecFile.writeAsStringSync('name: $appName'); await createTestCommandRunner(command) .run(const <String>['build', 'fuchsia']); final String farPath = - fs.path.join(getFuchsiaBuildDirectory(), 'pkg', 'app_name-0.far'); - expect(fs.file(farPath).existsSync(), isTrue); + globals.fs.path.join(getFuchsiaBuildDirectory(), 'pkg', 'app_name-0.far'); + expect(globals.fs.file(farPath).existsSync(), isTrue); }, overrides: <Type, Generator>{ Platform: () => linuxPlatform, FileSystem: () => MemoryFileSystem(), @@ -155,11 +157,11 @@ @override Future<bool> init(String buildPath, String appName) async { - if (!fs.directory(buildPath).existsSync()) { + if (!globals.fs.directory(buildPath).existsSync()) { return false; } - fs - .file(fs.path.join(buildPath, 'meta', 'package')) + globals.fs + .file(globals.fs.path.join(buildPath, 'meta', 'package')) .createSync(recursive: true); _appName = appName; return true; @@ -167,36 +169,36 @@ @override Future<bool> genkey(String buildPath, String outKeyPath) async { - if (!fs.file(fs.path.join(buildPath, 'meta', 'package')).existsSync()) { + if (!globals.fs.file(globals.fs.path.join(buildPath, 'meta', 'package')).existsSync()) { return false; } - fs.file(outKeyPath).createSync(recursive: true); + globals.fs.file(outKeyPath).createSync(recursive: true); return true; } @override Future<bool> build(String buildPath, String keyPath, String manifestPath) async { - if (!fs.file(fs.path.join(buildPath, 'meta', 'package')).existsSync() || - !fs.file(keyPath).existsSync() || - !fs.file(manifestPath).existsSync()) { + if (!globals.fs.file(globals.fs.path.join(buildPath, 'meta', 'package')).existsSync() || + !globals.fs.file(keyPath).existsSync() || + !globals.fs.file(manifestPath).existsSync()) { return false; } - fs.file(fs.path.join(buildPath, 'meta.far')).createSync(recursive: true); + globals.fs.file(globals.fs.path.join(buildPath, 'meta.far')).createSync(recursive: true); return true; } @override Future<bool> archive(String buildPath, String keyPath, String manifestPath) async { - if (!fs.file(fs.path.join(buildPath, 'meta', 'package')).existsSync() || - !fs.file(keyPath).existsSync() || - !fs.file(manifestPath).existsSync()) { + if (!globals.fs.file(globals.fs.path.join(buildPath, 'meta', 'package')).existsSync() || + !globals.fs.file(keyPath).existsSync() || + !globals.fs.file(manifestPath).existsSync()) { return false; } if (_appName == null) { return false; } - fs - .file(fs.path.join(buildPath, '$_appName-0.far')) + globals.fs + .file(globals.fs.path.join(buildPath, '$_appName-0.far')) .createSync(recursive: true); return true; } @@ -211,8 +213,8 @@ }) async { final String outDir = getFuchsiaBuildDirectory(); final String appName = fuchsiaProject.project.manifest.appName; - final String manifestPath = fs.path.join(outDir, '$appName.dilpmanifest'); - fs.file(manifestPath).createSync(recursive: true); + final String manifestPath = globals.fs.path.join(outDir, '$appName.dilpmanifest'); + globals.fs.file(manifestPath).createSync(recursive: true); } }
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/build_ios_framework_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/build_ios_framework_test.dart index 3c9a557..77fe437 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/build_ios_framework_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/build_ios_framework_test.dart
@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/commands/build_ios_framework.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/version.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import '../../src/common.dart'; @@ -34,7 +35,7 @@ mockCache = MockCache(); when(mockFlutterVersion.gitTagVersion).thenReturn(mockGitTagVersion); - outputDirectory = fs.systemTempDirectory + outputDirectory = globals.fs.systemTempDirectory .createTempSync('flutter_build_ios_framework_test_output.') .childDirectory('Debug') ..createSync();
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/build_linux_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/build_linux_test.dart index 88f0c4d..d2d9354 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/build_linux_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/build_linux_test.dart
@@ -4,10 +4,13 @@ import 'package:args/command_runner.dart'; import 'package:file/memory.dart'; +import 'package:platform/platform.dart'; +import 'package:mockito/mockito.dart'; +import 'package:process/process.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/platform.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/commands/build.dart'; import 'package:flutter_tools/src/commands/build_linux.dart'; @@ -15,8 +18,7 @@ import 'package:flutter_tools/src/features.dart'; import 'package:flutter_tools/src/linux/makefile.dart'; import 'package:flutter_tools/src/project.dart'; -import 'package:mockito/mockito.dart'; -import 'package:process/process.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../../src/common.dart'; import '../../src/context.dart'; @@ -55,10 +57,10 @@ // Creates the mock files necessary to run a build. void setUpMockProjectFilesForBuild() { - fs.file('linux/build.sh').createSync(recursive: true); - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); - fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true); + globals.fs.file('linux/build.sh').createSync(recursive: true); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); + globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); } // Sets up mock expectation for running 'make'. @@ -110,7 +112,7 @@ await createTestCommandRunner(command).run( const <String>['build', 'linux'] ); - expect(fs.file('linux/flutter/ephemeral/generated_config.mk').existsSync(), true); + expect(globals.fs.file('linux/flutter/ephemeral/generated_config.mk').existsSync(), true); }, overrides: <Type, Generator>{ FileSystem: () => MemoryFileSystem(), ProcessManager: () => mockProcessManager, @@ -190,15 +192,15 @@ }); testUsingContext('linux can extract binary name from Makefile', () async { - fs.file('linux/Makefile') + globals.fs.file('linux/Makefile') ..createSync(recursive: true) ..writeAsStringSync(r''' # Comment SOMETHING_ELSE=FOO BINARY_NAME=fizz_bar '''); - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); final FlutterProject flutterProject = FlutterProject.current(); expect(makefileExecutableName(flutterProject.linux), 'fizz_bar'); @@ -236,7 +238,7 @@ }); testUsingContext('hidden when not enabled on Linux host', () { - when(platform.isLinux).thenReturn(true); + when(globals.platform.isLinux).thenReturn(true); expect(BuildLinuxCommand().hidden, true); }, overrides: <Type, Generator>{ @@ -245,7 +247,7 @@ }); testUsingContext('Not hidden when enabled and on Linux host', () { - when(platform.isLinux).thenReturn(true); + when(globals.platform.isLinux).thenReturn(true); expect(BuildLinuxCommand().hidden, false); }, overrides: <Type, Generator>{
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/build_macos_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/build_macos_test.dart index 6d0ca8c..7f6d74f 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/build_macos_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/build_macos_test.dart
@@ -4,10 +4,11 @@ import 'package:args/command_runner.dart'; import 'package:file/memory.dart'; +import 'package:platform/platform.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/platform.dart'; import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/commands/build.dart'; @@ -18,6 +19,7 @@ import 'package:flutter_tools/src/project.dart'; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../../src/common.dart'; import '../../src/context.dart'; @@ -67,17 +69,17 @@ // Sets up the minimal mock project files necessary for macOS builds to succeed. void createMinimalMockProjectFiles() { - fs.directory('macos').createSync(); - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); - fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true); + globals.fs.directory('macos').createSync(); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); + globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); } // Mocks the process manager to handle an xcodebuild call to build the app // in the given configuration. void setUpMockXcodeBuildHandler(String configuration) { - final FlutterProject flutterProject = FlutterProject.fromDirectory(fs.currentDirectory); - final Directory flutterBuildDir = fs.directory(getMacOSBuildDirectory()); + final FlutterProject flutterProject = FlutterProject.fromDirectory(globals.fs.currentDirectory); + final Directory flutterBuildDir = globals.fs.directory(getMacOSBuildDirectory()); when(mockProcessManager.start(<String>[ '/usr/bin/env', 'xcrun', @@ -86,11 +88,11 @@ '-configuration', configuration, '-scheme', 'Runner', '-derivedDataPath', flutterBuildDir.absolute.path, - 'OBJROOT=${fs.path.join(flutterBuildDir.absolute.path, 'Build', 'Intermediates.noindex')}', - 'SYMROOT=${fs.path.join(flutterBuildDir.absolute.path, 'Build', 'Products')}', + 'OBJROOT=${globals.fs.path.join(flutterBuildDir.absolute.path, 'Build', 'Intermediates.noindex')}', + 'SYMROOT=${globals.fs.path.join(flutterBuildDir.absolute.path, 'Build', 'Products')}', 'COMPILER_INDEX_STORE_ENABLE=NO', ])).thenAnswer((Invocation invocation) async { - fs.file(fs.path.join('macos', 'Flutter', 'ephemeral', '.app_filename')) + globals.fs.file(globals.fs.path.join('macos', 'Flutter', 'ephemeral', '.app_filename')) ..createSync(recursive: true) ..writeAsStringSync('example.app'); return mockProcess; @@ -111,9 +113,9 @@ testUsingContext('macOS build fails on non-macOS platform', () async { final BuildCommand command = BuildCommand(); applyMocksToCommand(command); - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); - fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); + globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); expect(createTestCommandRunner(command).run( const <String>['build', 'macos'] @@ -202,7 +204,7 @@ }); testUsingContext('hidden when not enabled on macOS host', () { - when(platform.isMacOS).thenReturn(true); + when(globals.platform.isMacOS).thenReturn(true); expect(BuildMacosCommand().hidden, true); }, overrides: <Type, Generator>{ @@ -211,7 +213,7 @@ }); testUsingContext('Not hidden when enabled and on macOS host', () { - when(platform.isMacOS).thenReturn(true); + when(globals.platform.isMacOS).thenReturn(true); expect(BuildMacosCommand().hidden, false); }, overrides: <Type, Generator>{
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/build_web_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/build_web_test.dart index 00b693d..52922ca 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/build_web_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/build_web_test.dart
@@ -3,9 +3,9 @@ // found in the LICENSE file. import 'package:args/command_runner.dart'; +import 'package:platform/platform.dart'; + import 'package:flutter_tools/src/base/common.dart'; -import 'package:flutter_tools/src/base/file_system.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/build_system/build_system.dart'; import 'package:flutter_tools/src/cache.dart'; @@ -19,6 +19,7 @@ import 'package:flutter_tools/src/version.dart'; import 'package:flutter_tools/src/web/compile.dart'; import 'package:mockito/mockito.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../../src/common.dart'; import '../../src/mocks.dart'; @@ -35,12 +36,12 @@ setUp(() { testbed = Testbed(setup: () { - fs.file('pubspec.yaml') + globals.fs.file('pubspec.yaml') ..createSync() ..writeAsStringSync('name: foo\n'); - fs.file('.packages').createSync(); - fs.file(fs.path.join('web', 'index.html')).createSync(recursive: true); - fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true); + globals.fs.file('.packages').createSync(); + globals.fs.file(globals.fs.path.join('web', 'index.html')).createSync(recursive: true); + globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); }, overrides: <Type, Generator>{ Platform: () => mockPlatform, FlutterVersion: () => MockFlutterVersion(), @@ -50,11 +51,11 @@ }); test('Refuses to build for web when missing index.html', () => testbed.run(() async { - fs.file(fs.path.join('web', 'index.html')).deleteSync(); + globals.fs.file(globals.fs.path.join('web', 'index.html')).deleteSync(); expect(buildWeb( FlutterProject.current(), - fs.path.join('lib', 'main.dart'), + globals.fs.path.join('lib', 'main.dart'), BuildInfo.debug, false, const <String>[], @@ -62,7 +63,7 @@ })); test('Refuses to build using runner when missing index.html', () => testbed.run(() async { - fs.file(fs.path.join('web', 'index.html')).deleteSync(); + globals.fs.file(globals.fs.path.join('web', 'index.html')).deleteSync(); final ResidentWebRunner runner = DwdsWebRunnerFactory().createWebRunner( null, @@ -99,23 +100,23 @@ applyMocksToCommand(buildCommand); final CommandRunner<void> runner = createTestCommandRunner(buildCommand); final List<String> dependencies = <String>[ - fs.path.join('packages', 'flutter_tools', 'lib', 'src', 'build_system', 'targets', 'web.dart'), - fs.path.join('bin', 'cache', 'flutter_web_sdk'), - fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'dart2js.dart.snapshot'), - fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'), - fs.path.join('bin', 'cache', 'dart-sdk '), + globals.fs.path.join('packages', 'flutter_tools', 'lib', 'src', 'build_system', 'targets', 'web.dart'), + globals.fs.path.join('bin', 'cache', 'flutter_web_sdk'), + globals.fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'dart2js.dart.snapshot'), + globals.fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'), + globals.fs.path.join('bin', 'cache', 'dart-sdk '), ]; for (String dependency in dependencies) { - fs.file(dependency).createSync(recursive: true); + globals.fs.file(dependency).createSync(recursive: true); } // Project files. - fs.file('.packages') + globals.fs.file('.packages') ..writeAsStringSync(''' foo:lib/ fizz:bar/lib/ '''); - fs.file('pubspec.yaml') + globals.fs.file('pubspec.yaml') ..writeAsStringSync(''' name: foo @@ -126,7 +127,7 @@ path: bar/ '''); - fs.file(fs.path.join('bar', 'pubspec.yaml')) + globals.fs.file(globals.fs.path.join('bar', 'pubspec.yaml')) ..createSync(recursive: true) ..writeAsStringSync(''' name: bar @@ -138,12 +139,12 @@ pluginClass: UrlLauncherPlugin fileName: url_launcher_web.dart '''); - fs.file(fs.path.join('bar', 'lib', 'url_launcher_web.dart')) + globals.fs.file(globals.fs.path.join('bar', 'lib', 'url_launcher_web.dart')) ..createSync(recursive: true) ..writeAsStringSync(''' class UrlLauncherPlugin {} '''); - fs.file(fs.path.join('lib', 'main.dart')) + globals.fs.file(globals.fs.path.join('lib', 'main.dart')) ..writeAsStringSync('void main() { }'); // Process calls. We're not testing that these invocations are correct because @@ -153,7 +154,7 @@ }); await runner.run(<String>['build', 'web']); - expect(fs.file(fs.path.join('lib', 'generated_plugin_registrant.dart')).existsSync(), true); + expect(globals.fs.file(globals.fs.path.join('lib', 'generated_plugin_registrant.dart')).existsSync(), true); }, overrides: <Type, Generator>{ FeatureFlags: () => TestFeatureFlags(isWebEnabled: true), BuildSystem: () => MockBuildSystem(),
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/build_windows_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/build_windows_test.dart index a78a908..9a81864 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/build_windows_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/build_windows_test.dart
@@ -3,10 +3,11 @@ // found in the LICENSE file. import 'package:file/memory.dart'; +import 'package:platform/platform.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/platform.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/commands/build.dart'; import 'package:flutter_tools/src/commands/build_windows.dart'; @@ -16,6 +17,7 @@ import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; import 'package:xml/xml.dart' as xml; +import 'package:flutter_tools/src/globals.dart' as globals; import '../../src/common.dart'; import '../../src/context.dart'; @@ -59,7 +61,7 @@ testUsingContext('Windows build fails when there is no vcvars64.bat', () async { final BuildCommand command = BuildCommand(); applyMocksToCommand(command); - fs.file(solutionPath).createSync(recursive: true); + globals.fs.file(solutionPath).createSync(recursive: true); expect(createTestCommandRunner(command).run( const <String>['build', 'windows'] ), throwsA(isInstanceOf<ToolExit>())); @@ -89,11 +91,11 @@ testUsingContext('Windows build fails on non windows platform', () async { final BuildCommand command = BuildCommand(); applyMocksToCommand(command); - fs.file(solutionPath).createSync(recursive: true); + globals.fs.file(solutionPath).createSync(recursive: true); when(mockVisualStudio.vcvarsPath).thenReturn(vcvarsPath); - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); - fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); + globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); expect(createTestCommandRunner(command).run( const <String>['build', 'windows'] @@ -109,18 +111,18 @@ testUsingContext('Windows build does not spew stdout to status logger', () async { final BuildCommand command = BuildCommand(); applyMocksToCommand(command); - fs.file(solutionPath).createSync(recursive: true); + globals.fs.file(solutionPath).createSync(recursive: true); when(mockVisualStudio.vcvarsPath).thenReturn(vcvarsPath); - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); - fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); + globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); when(mockProcessManager.start(<String>[ r'C:\packages\flutter_tools\bin\vs_build.bat', vcvarsPath, - fs.path.basename(solutionPath), + globals.fs.path.basename(solutionPath), 'Release', - ], workingDirectory: fs.path.dirname(solutionPath))).thenAnswer((Invocation invocation) async { + ], workingDirectory: globals.fs.path.dirname(solutionPath))).thenAnswer((Invocation invocation) async { return mockProcess; }); @@ -140,18 +142,18 @@ testUsingContext('Windows build invokes msbuild and writes generated files', () async { final BuildCommand command = BuildCommand(); applyMocksToCommand(command); - fs.file(solutionPath).createSync(recursive: true); + globals.fs.file(solutionPath).createSync(recursive: true); when(mockVisualStudio.vcvarsPath).thenReturn(vcvarsPath); - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); - fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); + globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); when(mockProcessManager.start(<String>[ r'C:\packages\flutter_tools\bin\vs_build.bat', vcvarsPath, - fs.path.basename(solutionPath), + globals.fs.path.basename(solutionPath), 'Release', - ], workingDirectory: fs.path.dirname(solutionPath))).thenAnswer((Invocation invocation) async { + ], workingDirectory: globals.fs.path.dirname(solutionPath))).thenAnswer((Invocation invocation) async { return mockProcess; }); @@ -160,7 +162,7 @@ ); // Spot-check important elements from the properties file. - final File propsFile = fs.file(r'C:\windows\flutter\ephemeral\Generated.props'); + final File propsFile = globals.fs.file(r'C:\windows\flutter\ephemeral\Generated.props'); expect(propsFile.existsSync(), true); final xml.XmlDocument props = xml.parse(propsFile.readAsStringSync()); expect(props.findAllElements('PropertyGroup').first.getAttribute('Label'), 'UserMacros'); @@ -177,18 +179,18 @@ testUsingContext('Release build prints an under-construction warning', () async { final BuildCommand command = BuildCommand(); applyMocksToCommand(command); - fs.file(solutionPath).createSync(recursive: true); + globals.fs.file(solutionPath).createSync(recursive: true); when(mockVisualStudio.vcvarsPath).thenReturn(vcvarsPath); - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); - fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); + globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); when(mockProcessManager.start(<String>[ r'C:\packages\flutter_tools\bin\vs_build.bat', vcvarsPath, - fs.path.basename(solutionPath), + globals.fs.path.basename(solutionPath), 'Release', - ], workingDirectory: fs.path.dirname(solutionPath))).thenAnswer((Invocation invocation) async { + ], workingDirectory: globals.fs.path.dirname(solutionPath))).thenAnswer((Invocation invocation) async { return mockProcess; }); @@ -206,7 +208,7 @@ }); testUsingContext('hidden when not enabled on Windows host', () { - when(platform.isWindows).thenReturn(true); + when(globals.platform.isWindows).thenReturn(true); expect(BuildWindowsCommand().hidden, true); }, overrides: <Type, Generator>{ @@ -215,7 +217,7 @@ }); testUsingContext('Not hidden when enabled and on Windows host', () { - when(platform.isWindows).thenReturn(true); + when(globals.platform.isWindows).thenReturn(true); expect(BuildWindowsCommand().hidden, false); }, overrides: <Type, Generator>{
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/clean_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/clean_test.dart index fef7c1c..7145de8 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/clean_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/clean_test.dart
@@ -3,10 +3,11 @@ // found in the LICENSE file. import 'package:file/memory.dart'; +import 'package:platform/platform.dart'; + import 'package:flutter_tools/src/base/context.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/logger.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/commands/clean.dart'; import 'package:flutter_tools/src/ios/xcodeproj.dart'; import 'package:flutter_tools/src/macos/xcode.dart';
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/config_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/config_test.dart index 475b4bc..608c400 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/config_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/config_test.dart
@@ -8,11 +8,11 @@ import 'package:flutter_tools/src/android/android_sdk.dart'; import 'package:flutter_tools/src/android/android_studio.dart'; import 'package:flutter_tools/src/base/common.dart'; -import 'package:flutter_tools/src/base/config.dart'; import 'package:flutter_tools/src/base/context.dart'; import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/commands/config.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/reporting/reporting.dart'; import 'package:flutter_tools/src/version.dart'; import 'package:mockito/mockito.dart'; @@ -120,19 +120,19 @@ '--enable-macos-desktop', ]); - expect(Config.instance.getValue('enable-web'), true); - expect(Config.instance.getValue('enable-linux-desktop'), true); - expect(Config.instance.getValue('enable-windows-desktop'), true); - expect(Config.instance.getValue('enable-macos-desktop'), true); + expect(globals.config.getValue('enable-web'), true); + expect(globals.config.getValue('enable-linux-desktop'), true); + expect(globals.config.getValue('enable-windows-desktop'), true); + expect(globals.config.getValue('enable-macos-desktop'), true); await commandRunner.run(<String>[ 'config', '--clear-features', ]); - expect(Config.instance.getValue('enable-web'), null); - expect(Config.instance.getValue('enable-linux-desktop'), null); - expect(Config.instance.getValue('enable-windows-desktop'), null); - expect(Config.instance.getValue('enable-macos-desktop'), null); + expect(globals.config.getValue('enable-web'), null); + expect(globals.config.getValue('enable-linux-desktop'), null); + expect(globals.config.getValue('enable-windows-desktop'), null); + expect(globals.config.getValue('enable-macos-desktop'), null); await commandRunner.run(<String>[ 'config', @@ -142,10 +142,10 @@ '--no-enable-macos-desktop', ]); - expect(Config.instance.getValue('enable-web'), false); - expect(Config.instance.getValue('enable-linux-desktop'), false); - expect(Config.instance.getValue('enable-windows-desktop'), false); - expect(Config.instance.getValue('enable-macos-desktop'), false); + expect(globals.config.getValue('enable-web'), false); + expect(globals.config.getValue('enable-linux-desktop'), false); + expect(globals.config.getValue('enable-windows-desktop'), false); + expect(globals.config.getValue('enable-macos-desktop'), false); verifyNoAnalytics(); }, overrides: <Type, Generator>{ AndroidStudio: () => mockAndroidStudio,
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/create_usage_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/create_usage_test.dart index 943422b..dc77557 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/create_usage_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/create_usage_test.dart
@@ -3,11 +3,11 @@ // found in the LICENSE file. import 'package:args/command_runner.dart'; -import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/commands/create.dart'; import 'package:flutter_tools/src/doctor.dart'; import 'package:flutter_tools/src/reporting/reporting.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../../src/common.dart'; import '../../src/context.dart'; @@ -24,15 +24,15 @@ setUp(() { testbed = Testbed(setup: () { final List<String> paths = <String>[ - fs.path.join('flutter', 'packages', 'flutter', 'pubspec.yaml'), - fs.path.join('flutter', 'packages', 'flutter_driver', 'pubspec.yaml'), - fs.path.join('flutter', 'packages', 'flutter_test', 'pubspec.yaml'), - fs.path.join('flutter', 'bin', 'cache', 'artifacts', 'gradle_wrapper', 'wrapper'), - fs.path.join('usr', 'local', 'bin', 'adb'), - fs.path.join('Android', 'platform-tools', 'adb.exe'), + globals.fs.path.join('flutter', 'packages', 'flutter', 'pubspec.yaml'), + globals.fs.path.join('flutter', 'packages', 'flutter_driver', 'pubspec.yaml'), + globals.fs.path.join('flutter', 'packages', 'flutter_test', 'pubspec.yaml'), + globals.fs.path.join('flutter', 'bin', 'cache', 'artifacts', 'gradle_wrapper', 'wrapper'), + globals.fs.path.join('usr', 'local', 'bin', 'adb'), + globals.fs.path.join('Android', 'platform-tools', 'adb.exe'), ]; for (String path in paths) { - fs.file(path).createSync(recursive: true); + globals.fs.file(path).createSync(recursive: true); } }, overrides: <Type, Generator>{ DoctorValidatorsProvider: () => FakeDoctorValidatorsProvider(),
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/daemon_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/daemon_test.dart index fd4f51a79..ba5053b 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/daemon_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/daemon_test.dart
@@ -10,7 +10,7 @@ import 'package:flutter_tools/src/base/utils.dart'; import 'package:flutter_tools/src/commands/daemon.dart'; import 'package:flutter_tools/src/fuchsia/fuchsia_workflow.dart'; -import 'package:flutter_tools/src/globals.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/ios/ios_workflow.dart'; import 'package:flutter_tools/src/resident_runner.dart'; @@ -61,7 +61,7 @@ notifyingLogger: notifyingLogger, dartDefines: const <String>[], ); - printError('daemon.logMessage test'); + globals.printError('daemon.logMessage test'); final Map<String, dynamic> response = await responses.stream.firstWhere((Map<String, dynamic> map) { return map['event'] == 'daemon.logMessage' && map['params']['level'] == 'error'; }); @@ -89,7 +89,7 @@ logToStdout: true, dartDefines: const <String>[], ); - printStatus('daemon.logMessage test'); + globals.printStatus('daemon.logMessage test'); // Service the event loop. await Future<void>.value(); }, zoneSpecification: ZoneSpecification(print: (Zone self, ZoneDelegate parent, Zone zone, String line) {
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/doctor_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/doctor_test.dart index d0e28b9..5b3e077 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/doctor_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/doctor_test.dart
@@ -6,15 +6,13 @@ import 'package:flutter_tools/src/artifacts.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/platform.dart'; -import 'package:flutter_tools/src/base/process_manager.dart'; + import 'package:flutter_tools/src/base/terminal.dart'; import 'package:flutter_tools/src/base/user_messages.dart'; import 'package:flutter_tools/src/doctor.dart'; import 'package:flutter_tools/src/features.dart'; -import 'package:flutter_tools/src/globals.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/proxy_validator.dart'; import 'package:flutter_tools/src/reporting/reporting.dart'; import 'package:flutter_tools/src/vscode/vscode.dart'; @@ -24,6 +22,7 @@ import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; import 'package:quiver/testing/async.dart'; +import 'package:platform/platform.dart'; import '../../src/common.dart'; import '../../src/context.dart'; @@ -493,7 +492,7 @@ testUsingContext('gen_snapshot does not work', () async { when(mockProcessManager.runSync( - <String>[artifacts.getArtifactPath(Artifact.genSnapshot)], + <String>[globals.artifacts.getArtifactPath(Artifact.genSnapshot)], workingDirectory: anyNamed('workingDirectory'), environment: anyNamed('environment'), )).thenReturn(ProcessResult(101, 1, '', '')); @@ -503,7 +502,7 @@ for (String msg in userMessages.flutterBinariesDoNotRun.split('\n')) { expect(statusLines, contains(contains(msg))); } - if (platform.isLinux) { + if (globals.platform.isLinux) { for (String msg in userMessages.flutterBinariesLinuxRepairCommands.split('\n')) { expect(statusLines, contains(contains(msg))); } @@ -522,7 +521,7 @@ when(mockFlutterVersion.frameworkDate).thenThrow(versionCheckError); when(mockProcessManager.runSync( - <String>[artifacts.getArtifactPath(Artifact.genSnapshot)], + <String>[globals.artifacts.getArtifactPath(Artifact.genSnapshot)], workingDirectory: anyNamed('workingDirectory'), environment: anyNamed('environment'), )).thenReturn(ProcessResult(101, 255, '', '')); @@ -705,7 +704,7 @@ }); testUsingContext('WebWorkflow is a part of validator workflows if enabled', () async { - when(processManager.canRun(any)).thenReturn(true); + when(globals.processManager.canRun(any)).thenReturn(true); expect(DoctorValidatorsProvider.defaultInstance.workflows.contains(webWorkflow), true); }, overrides: <Type, Generator>{ @@ -720,7 +719,7 @@ IntelliJValidatorTestTarget(String title, String installPath) : super(title, installPath); @override - String get pluginsPath => fs.path.join('test', 'data', 'intellij', 'plugins'); + String get pluginsPath => globals.fs.path.join('test', 'data', 'intellij', 'plugins'); @override String get version => 'test.test.test'; @@ -1046,9 +1045,9 @@ static VsCodeValidatorTestTargets get installedWithoutExtension => VsCodeValidatorTestTargets._(validInstall, missingExtensions); - static final String validInstall = fs.path.join('test', 'data', 'vscode', 'application'); - static final String validExtensions = fs.path.join('test', 'data', 'vscode', 'extensions'); - static final String missingExtensions = fs.path.join('test', 'data', 'vscode', 'notExtensions'); + static final String validInstall = globals.fs.path.join('test', 'data', 'vscode', 'application'); + static final String validExtensions = globals.fs.path.join('test', 'data', 'vscode', 'extensions'); + static final String missingExtensions = globals.fs.path.join('test', 'data', 'vscode', 'notExtensions'); } class MockProcessManager extends Mock implements ProcessManager {}
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart index 3e17f8f..43cb66b 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/drive_test.dart
@@ -5,16 +5,18 @@ import 'dart:async'; import 'package:file/memory.dart'; +import 'package:platform/platform.dart'; + import 'package:flutter_tools/src/android/android_device.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/platform.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/commands/drive.dart'; import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/build_info.dart'; import 'package:mockito/mockito.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../../src/common.dart'; import '../../src/context.dart'; @@ -66,9 +68,9 @@ testUsingContext('returns 1 when test file is not found', () async { testDeviceManager.addDevice(MockDevice()); - final String testApp = fs.path.join(tempDir.path, 'test', 'e2e.dart'); - final String testFile = fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart'); - fs.file(testApp).createSync(recursive: true); + final String testApp = globals.fs.path.join(tempDir.path, 'test', 'e2e.dart'); + final String testFile = globals.fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart'); + globals.fs.file(testApp).createSync(recursive: true); final List<String> args = <String>[ 'drive', @@ -91,8 +93,8 @@ testDeviceManager.addDevice(MockDevice()); appStarter = expectAsync1((DriveCommand command) async => null); - final String testApp = fs.path.join(tempDir.path, 'test_driver', 'e2e.dart'); - final String testFile = fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart'); + final String testApp = globals.fs.path.join(tempDir.path, 'test_driver', 'e2e.dart'); + final String testFile = globals.fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart'); final MemoryFileSystem memFs = fs; await memFs.file(testApp).writeAsString('main() { }'); @@ -116,8 +118,8 @@ }); testUsingContext('returns 1 when app file is outside package', () async { - final String appFile = fs.path.join(tempDir.dirname, 'other_app', 'app.dart'); - fs.file(appFile).createSync(recursive: true); + final String appFile = globals.fs.path.join(tempDir.dirname, 'other_app', 'app.dart'); + globals.fs.file(appFile).createSync(recursive: true); final List<String> args = <String>[ '--no-wrap', 'drive', @@ -139,8 +141,8 @@ }); testUsingContext('returns 1 when app file is in the root dir', () async { - final String appFile = fs.path.join(tempDir.path, 'main.dart'); - fs.file(appFile).createSync(recursive: true); + final String appFile = globals.fs.path.join(tempDir.path, 'main.dart'); + globals.fs.file(appFile).createSync(recursive: true); final List<String> args = <String>[ '--no-wrap', 'drive', @@ -165,8 +167,8 @@ testUsingContext('returns 0 when test ends successfully', () async { testDeviceManager.addDevice(MockDevice()); - final String testApp = fs.path.join(tempDir.path, 'test', 'e2e.dart'); - final String testFile = fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart'); + final String testApp = globals.fs.path.join(tempDir.path, 'test', 'e2e.dart'); + final String testFile = globals.fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart'); appStarter = expectAsync1((DriveCommand command) async { return LaunchResult.succeeded(); @@ -210,8 +212,8 @@ testUsingContext('returns exitCode set by test runner', () async { testDeviceManager.addDevice(MockDevice()); - final String testApp = fs.path.join(tempDir.path, 'test', 'e2e.dart'); - final String testFile = fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart'); + final String testApp = globals.fs.path.join(tempDir.path, 'test', 'e2e.dart'); + final String testFile = globals.fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart'); appStarter = expectAsync1((DriveCommand command) async { return LaunchResult.succeeded(); @@ -370,8 +372,8 @@ )).thenAnswer((_) => Future<LaunchResult>.value(mockLaunchResult)); when(mockDevice.isAppInstalled(any)).thenAnswer((_) => Future<bool>.value(false)); - testApp = fs.path.join(tempDir.path, 'test', 'e2e.dart'); - testFile = fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart'); + testApp = globals.fs.path.join(tempDir.path, 'test', 'e2e.dart'); + testFile = globals.fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart'); testRunner = (List<String> testArgs, Map<String, String> environment) async { throwToolExit(null, exitCode: 123); @@ -503,8 +505,8 @@ when(mockDevice.isAppInstalled(any)) .thenAnswer((_) => Future<bool>.value(false)); - testApp = fs.path.join(tempDir.path, 'test', 'e2e.dart'); - testFile = fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart'); + testApp = globals.fs.path.join(tempDir.path, 'test', 'e2e.dart'); + testFile = globals.fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart'); testRunner = (List<String> testArgs, Map<String, String> environment) async { throwToolExit(null, exitCode: 123);
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/generate_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/generate_test.dart index 68e3223..334d5af 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/generate_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/generate_test.dart
@@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/codegen.dart'; import 'package:flutter_tools/src/commands/generate.dart'; import 'package:flutter_tools/src/convert.dart'; import 'package:mockito/mockito.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../../src/common.dart'; import '../../src/context.dart'; @@ -47,10 +47,10 @@ test('Outputs error information from flutter generate', () => testbed.run(() async { final GenerateCommand command = GenerateCommand(); applyMocksToCommand(command); - fs.file(fs.path.join('lib', 'main.dart')) + globals.fs.file(globals.fs.path.join('lib', 'main.dart')) ..createSync(recursive: true); - fs.currentDirectory + globals.fs.currentDirectory .childDirectory('.dart_tool') .childDirectory('build') .childDirectory('abcdefg')
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/ide_config_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/ide_config_test.dart index 9aec064..3e22868 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/ide_config_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/ide_config_test.dart
@@ -9,6 +9,7 @@ import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/template.dart'; import 'package:flutter_tools/src/commands/ide_config.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../../src/common.dart'; import '../../src/context.dart'; @@ -24,33 +25,33 @@ final String tempPath = tempDir.absolute.path; final List<String> paths = (root ?? tempDir).listSync(recursive: true).map((FileSystemEntity entity) { - final String relativePath = fs.path.relative(entity.path, from: tempPath); + final String relativePath = globals.fs.path.relative(entity.path, from: tempPath); return relativePath; }).toList(); final Map<String, String> contents = <String, String>{}; for (String path in paths) { - final String absPath = fs.path.join(tempPath, path); - if (fs.isDirectorySync(absPath)) { + final String absPath = globals.fs.path.join(tempPath, path); + if (globals.fs.isDirectorySync(absPath)) { contents[path] = 'dir'; - } else if (fs.isFileSync(absPath)) { - contents[path] = fs.file(absPath).readAsStringSync(); + } else if (globals.fs.isFileSync(absPath)) { + contents[path] = globals.fs.file(absPath).readAsStringSync(); } } return contents; } Map<String, String> _getManifest(Directory base, String marker, { bool isTemplate = false }) { - final String basePath = fs.path.relative(base.path, from: tempDir.absolute.path); + final String basePath = globals.fs.path.relative(base.path, from: tempDir.absolute.path); final String suffix = isTemplate ? Template.copyTemplateExtension : ''; return <String, String>{ - fs.path.join(basePath, '.idea'): 'dir', - fs.path.join(basePath, '.idea', 'modules.xml$suffix'): 'modules $marker', - fs.path.join(basePath, '.idea', 'vcs.xml$suffix'): 'vcs $marker', - fs.path.join(basePath, '.idea', '.name$suffix'): 'codeStyleSettings $marker', - fs.path.join(basePath, '.idea', 'runConfigurations'): 'dir', - fs.path.join(basePath, '.idea', 'runConfigurations', 'hello_world.xml$suffix'): 'hello_world $marker', - fs.path.join(basePath, 'flutter.iml$suffix'): 'flutter $marker', - fs.path.join(basePath, 'packages', 'new', 'deep.iml$suffix'): 'deep $marker', + globals.fs.path.join(basePath, '.idea'): 'dir', + globals.fs.path.join(basePath, '.idea', 'modules.xml$suffix'): 'modules $marker', + globals.fs.path.join(basePath, '.idea', 'vcs.xml$suffix'): 'vcs $marker', + globals.fs.path.join(basePath, '.idea', '.name$suffix'): 'codeStyleSettings $marker', + globals.fs.path.join(basePath, '.idea', 'runConfigurations'): 'dir', + globals.fs.path.join(basePath, '.idea', 'runConfigurations', 'hello_world.xml$suffix'): 'hello_world $marker', + globals.fs.path.join(basePath, 'flutter.iml$suffix'): 'flutter $marker', + globals.fs.path.join(basePath, 'packages', 'new', 'deep.iml$suffix'): 'deep $marker', }; } @@ -70,8 +71,8 @@ } bool _fileOrDirectoryExists(String path) { - final String absPath = fs.path.join(tempDir.absolute.path, path); - return fs.file(absPath).existsSync() || fs.directory(absPath).existsSync(); + final String absPath = globals.fs.path.join(tempDir.absolute.path, path); + return globals.fs.file(absPath).existsSync() || globals.fs.directory(absPath).existsSync(); } Future<void> _updateIdeConfig({ @@ -90,16 +91,16 @@ ]); for (String path in expectedContents.keys) { - final String absPath = fs.path.join(tempDir.absolute.path, path); - expect(_fileOrDirectoryExists(fs.path.join(dir.path, path)), true, + final String absPath = globals.fs.path.join(tempDir.absolute.path, path); + expect(_fileOrDirectoryExists(globals.fs.path.join(dir.path, path)), true, reason: "$path doesn't exist"); - if (fs.file(absPath).existsSync()) { - expect(fs.file(absPath).readAsStringSync(), equals(expectedContents[path]), + if (globals.fs.file(absPath).existsSync()) { + expect(globals.fs.file(absPath).readAsStringSync(), equals(expectedContents[path]), reason: "$path contents don't match"); } } for (String path in unexpectedPaths) { - expect(_fileOrDirectoryExists(fs.path.join(dir.path, path)), false, reason: '$path exists'); + expect(_fileOrDirectoryExists(globals.fs.path.join(dir.path, path)), false, reason: '$path exists'); } } @@ -108,7 +109,7 @@ }); setUp(() { - tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_ide_config_test.'); + tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_ide_config_test.'); final Directory packagesDir = tempDir.childDirectory('packages')..createSync(recursive: true); toolsDir = packagesDir.childDirectory('flutter_tools')..createSync(); templateDir = toolsDir.childDirectory('ide_templates')..createSync(); @@ -189,7 +190,7 @@ 'template', isTemplate: true, ); - final String flutterIml = fs.path.join( + final String flutterIml = globals.fs.path.join( 'packages', 'flutter_tools', 'ide_templates', @@ -259,7 +260,7 @@ 'existing', isTemplate: true, ); - final String flutterIml = fs.path.join( + final String flutterIml = globals.fs.path.join( 'packages', 'flutter_tools', 'ide_templates', @@ -288,25 +289,25 @@ tempDir, 'existing', ); - flutterManifest.remove(fs.path.join('packages', 'new', 'deep.iml')); + flutterManifest.remove(globals.fs.path.join('packages', 'new', 'deep.iml')); _populateDir(flutterManifest); final Map<String, String> updatedTemplates = _getManifest( intellijDir, 'existing', isTemplate: true, ); - String deepIml = fs.path.join( + String deepIml = globals.fs.path.join( 'packages', 'flutter_tools', 'ide_templates', 'intellij'); // Remove the all the dir entries too. updatedTemplates.remove(deepIml); - deepIml = fs.path.join(deepIml, 'packages'); + deepIml = globals.fs.path.join(deepIml, 'packages'); updatedTemplates.remove(deepIml); - deepIml = fs.path.join(deepIml, 'new'); + deepIml = globals.fs.path.join(deepIml, 'new'); updatedTemplates.remove(deepIml); - deepIml = fs.path.join(deepIml, 'deep.iml'); + deepIml = globals.fs.path.join(deepIml, 'deep.iml'); updatedTemplates.remove(deepIml); final Map<String, String> expectedContents = <String, String>{ ...flutterManifest,
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart index 9fb909c..466f4c8 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart
@@ -20,7 +20,7 @@ import 'package:flutter_tools/src/commands/run.dart'; import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/features.dart'; -import 'package:flutter_tools/src/globals.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/reporting/reporting.dart'; import 'package:flutter_tools/src/resident_runner.dart'; @@ -61,9 +61,9 @@ }); testUsingContext('does not support "--use-application-binary" and "--fast-start"', () async { - fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true); - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); + globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); final RunCommand command = RunCommand(); applyMocksToCommand(command); @@ -97,9 +97,9 @@ when(deviceManager.getDevices()).thenAnswer((Invocation invocation) { return Stream<Device>.value(mockDevice); }); - fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true); - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); + globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); final RunCommand command = RunCommand(); applyMocksToCommand(command); @@ -114,7 +114,7 @@ expect(e, isInstanceOf<ToolExit>()); } - final BufferLogger bufferLogger = logger as BufferLogger; + final BufferLogger bufferLogger = globals.logger as BufferLogger; expect(bufferLogger.statusText, contains( 'Using --fast-start option with device mockdevice, but this device ' 'does not support it. Overriding the setting to false.' @@ -263,14 +263,14 @@ (Invocation invocation) => Future<List<Device>>.value(<Device>[mockDevice]) ); - final Directory tempDir = fs.systemTempDirectory.createTempSync('flutter_run_test.'); + final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_run_test.'); tempDir.childDirectory('ios').childFile('AppDelegate.swift').createSync(recursive: true); tempDir.childFile('.packages').createSync(); tempDir.childDirectory('lib').childFile('main.dart').createSync(recursive: true); tempDir.childFile('pubspec.yaml') ..createSync() ..writeAsStringSync('# Hello, World'); - fs.currentDirectory = tempDir; + globals.fs.currentDirectory = tempDir; try { await createTestCommandRunner(command).run(<String>[ @@ -482,8 +482,8 @@ }); testUsingContext('populates the environment', () async { - final Directory tempDir = fs.systemTempDirectory.createTempSync('flutter_run_test.'); - fs.currentDirectory = tempDir; + final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_run_test.'); + globals.fs.currentDirectory = tempDir; final Directory libDir = tempDir.childDirectory('lib'); libDir.createSync(); @@ -509,8 +509,8 @@ }); testUsingContext('populates dartDefines in --machine mode', () async { - final Directory tempDir = fs.systemTempDirectory.createTempSync('flutter_run_test.'); - fs.currentDirectory = tempDir; + final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_run_test.'); + globals.fs.currentDirectory = tempDir; final Directory libDir = tempDir.childDirectory('lib'); libDir.createSync();
diff --git a/packages/flutter_tools/test/commands.shard/hermetic/shell_completion_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/shell_completion_test.dart index ac21ec7..d9bb0a4 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/shell_completion_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/shell_completion_test.dart
@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/commands/shell_completion.dart'; import 'package:process/process.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../../src/common.dart'; import '../../src/context.dart'; @@ -48,8 +49,8 @@ await createTestCommandRunner(command).run( <String>['bash-completion', outputFile], ); - expect(fs.isFileSync(outputFile), isTrue); - expect(fs.file(outputFile).readAsStringSync(), contains('__flutter_completion')); + expect(globals.fs.isFileSync(outputFile), isTrue); + expect(globals.fs.file(outputFile).readAsStringSync(), contains('__flutter_completion')); }, overrides: <Type, Generator>{ FileSystem: () => MemoryFileSystem(), ProcessManager: () => FakeProcessManager.any(), @@ -59,7 +60,7 @@ testUsingContext("won't overwrite existing output file ", () async { final ShellCompletionCommand command = ShellCompletionCommand(); const String outputFile = 'bash-setup.sh'; - fs.file(outputFile).createSync(); + globals.fs.file(outputFile).createSync(); try { await createTestCommandRunner(command).run( <String>['bash-completion', outputFile], @@ -69,8 +70,8 @@ expect(error.exitCode ?? 1, 1); expect(error.message, contains('Use --overwrite')); } - expect(fs.isFileSync(outputFile), isTrue); - expect(fs.file(outputFile).readAsStringSync(), isEmpty); + expect(globals.fs.isFileSync(outputFile), isTrue); + expect(globals.fs.file(outputFile).readAsStringSync(), isEmpty); }, overrides: <Type, Generator>{ FileSystem: () => MemoryFileSystem(), ProcessManager: () => FakeProcessManager.any(), @@ -80,12 +81,12 @@ testUsingContext('will overwrite existing output file if given --overwrite', () async { final ShellCompletionCommand command = ShellCompletionCommand(); const String outputFile = 'bash-setup.sh'; - fs.file(outputFile).createSync(); + globals.fs.file(outputFile).createSync(); await createTestCommandRunner(command).run( <String>['bash-completion', '--overwrite', outputFile], ); - expect(fs.isFileSync(outputFile), isTrue); - expect(fs.file(outputFile).readAsStringSync(), contains('__flutter_completion')); + expect(globals.fs.isFileSync(outputFile), isTrue); + expect(globals.fs.file(outputFile).readAsStringSync(), contains('__flutter_completion')); }, overrides: <Type, Generator>{ FileSystem: () => MemoryFileSystem(), ProcessManager: () => FakeProcessManager.any(),
diff --git a/packages/flutter_tools/test/commands.shard/permeable/analyze_once_test.dart b/packages/flutter_tools/test/commands.shard/permeable/analyze_once_test.dart index 5933d47..7d06528 100644 --- a/packages/flutter_tools/test/commands.shard/permeable/analyze_once_test.dart +++ b/packages/flutter_tools/test/commands.shard/permeable/analyze_once_test.dart
@@ -4,14 +4,16 @@ import 'dart:async'; +import 'package:platform/platform.dart'; + import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/file_system.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/commands/analyze.dart'; import 'package:flutter_tools/src/commands/create.dart'; import 'package:flutter_tools/src/dart/pub.dart'; import 'package:flutter_tools/src/runner/flutter_command.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../../src/common.dart'; import '../../src/context.dart'; @@ -22,7 +24,7 @@ }; void main() { - final String analyzerSeparator = platform.isWindows ? '-' : '•'; + final String analyzerSeparator = globals.platform.isWindows ? '-' : '•'; group('analyze once', () { Directory tempDir; @@ -31,9 +33,9 @@ setUpAll(() { Cache.disableLocking(); - tempDir = fs.systemTempDirectory.createTempSync('flutter_analyze_once_test_1.').absolute; - projectPath = fs.path.join(tempDir.path, 'flutter_project'); - libMain = fs.file(fs.path.join(projectPath, 'lib', 'main.dart')); + tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_analyze_once_test_1.').absolute; + projectPath = globals.fs.path.join(tempDir.path, 'flutter_project'); + libMain = globals.fs.file(globals.fs.path.join(projectPath, 'lib', 'main.dart')); }); tearDownAll(() { @@ -47,7 +49,7 @@ arguments: <String>['--no-wrap', 'create', projectPath], statusTextContains: <String>[ 'All done!', - 'Your application code is in ${fs.path.normalize(fs.path.join(fs.path.relative(projectPath), 'lib', 'main.dart'))}', + 'Your application code is in ${globals.fs.path.normalize(globals.fs.path.join(globals.fs.path.relative(projectPath), 'lib', 'main.dart'))}', ], ); expect(libMain.existsSync(), isTrue); @@ -58,7 +60,7 @@ // Analyze in the current directory - no arguments testUsingContext('working directory', () async { await runCommand( - command: AnalyzeCommand(workingDirectory: fs.directory(projectPath)), + command: AnalyzeCommand(workingDirectory: globals.fs.directory(projectPath)), arguments: <String>['analyze'], statusTextContains: <String>['No issues found!'], ); @@ -98,7 +100,7 @@ // Analyze in the current directory - no arguments await runCommand( - command: AnalyzeCommand(workingDirectory: fs.directory(projectPath)), + command: AnalyzeCommand(workingDirectory: globals.fs.directory(projectPath)), arguments: <String>['analyze'], statusTextContains: <String>[ 'Analyzing', @@ -117,7 +119,7 @@ testUsingContext('working directory with local options', () async { // Insert an analysis_options.yaml file in the project // which will trigger a lint for broken code that was inserted earlier - final File optionsFile = fs.file(fs.path.join(projectPath, 'analysis_options.yaml')); + final File optionsFile = globals.fs.file(globals.fs.path.join(projectPath, 'analysis_options.yaml')); await optionsFile.writeAsString(''' include: package:flutter/analysis_options_user.yaml linter: @@ -127,7 +129,7 @@ // Analyze in the current directory - no arguments await runCommand( - command: AnalyzeCommand(workingDirectory: fs.directory(projectPath)), + command: AnalyzeCommand(workingDirectory: globals.fs.directory(projectPath)), arguments: <String>['analyze'], statusTextContains: <String>[ 'Analyzing', @@ -144,17 +146,17 @@ }); testUsingContext('no duplicate issues', () async { - final Directory tempDir = fs.systemTempDirectory.createTempSync('flutter_analyze_once_test_2.').absolute; + final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_analyze_once_test_2.').absolute; try { - final File foo = fs.file(fs.path.join(tempDir.path, 'foo.dart')); + final File foo = globals.fs.file(globals.fs.path.join(tempDir.path, 'foo.dart')); foo.writeAsStringSync(''' import 'bar.dart'; void foo() => bar(); '''); - final File bar = fs.file(fs.path.join(tempDir.path, 'bar.dart')); + final File bar = globals.fs.file(globals.fs.path.join(tempDir.path, 'bar.dart')); bar.writeAsStringSync(''' import 'dart:async'; // unused @@ -184,11 +186,11 @@ const String contents = ''' StringBuffer bar = StringBuffer('baz'); '''; - final Directory tempDir = fs.systemTempDirectory.createTempSync('flutter_analyze_once_test_3.'); + final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_analyze_once_test_3.'); tempDir.childFile('main.dart').writeAsStringSync(contents); try { await runCommand( - command: AnalyzeCommand(workingDirectory: fs.directory(tempDir)), + command: AnalyzeCommand(workingDirectory: globals.fs.directory(tempDir)), arguments: <String>['analyze'], statusTextContains: <String>['No issues found!'], ); @@ -205,11 +207,11 @@ // TODO(foobar): StringBuffer bar = StringBuffer('baz'); '''; - final Directory tempDir = fs.systemTempDirectory.createTempSync('flutter_analyze_once_test_4.'); + final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_analyze_once_test_4.'); tempDir.childFile('main.dart').writeAsStringSync(contents); try { await runCommand( - command: AnalyzeCommand(workingDirectory: fs.directory(tempDir)), + command: AnalyzeCommand(workingDirectory: globals.fs.directory(tempDir)), arguments: <String>['analyze'], statusTextContains: <String>['No issues found!'], );
diff --git a/packages/flutter_tools/test/commands.shard/permeable/build_bundle_test.dart b/packages/flutter_tools/test/commands.shard/permeable/build_bundle_test.dart index 5254a36..3018b67 100644 --- a/packages/flutter_tools/test/commands.shard/permeable/build_bundle_test.dart +++ b/packages/flutter_tools/test/commands.shard/permeable/build_bundle_test.dart
@@ -15,6 +15,7 @@ import 'package:flutter_tools/src/reporting/reporting.dart'; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../../src/common.dart'; import '../../src/context.dart'; @@ -26,7 +27,7 @@ MockBundleBuilder mockBundleBuilder; setUp(() { - tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.'); + tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.'); mockBundleBuilder = MockBundleBuilder(); when( @@ -98,9 +99,9 @@ }); testUsingContext('bundle fails to build for Windows if feature is disabled', () async { - fs.file('lib/main.dart').createSync(recursive: true); - fs.file('pubspec.yaml').createSync(recursive: true); - fs.file('.packages').createSync(recursive: true); + globals.fs.file('lib/main.dart').createSync(recursive: true); + globals.fs.file('pubspec.yaml').createSync(recursive: true); + globals.fs.file('.packages').createSync(recursive: true); final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand() ..bundleBuilder = MockBundleBuilder()); @@ -116,9 +117,9 @@ }); testUsingContext('bundle fails to build for Linux if feature is disabled', () async { - fs.file('lib/main.dart').createSync(recursive: true); - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); + globals.fs.file('lib/main.dart').createSync(recursive: true); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand() ..bundleBuilder = MockBundleBuilder()); @@ -134,9 +135,9 @@ }); testUsingContext('bundle fails to build for macOS if feature is disabled', () async { - fs.file('lib/main.dart').createSync(recursive: true); - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); + globals.fs.file('lib/main.dart').createSync(recursive: true); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand() ..bundleBuilder = MockBundleBuilder()); @@ -152,9 +153,9 @@ }); testUsingContext('bundle can build for Windows if feature is enabled', () async { - fs.file('lib/main.dart').createSync(recursive: true); - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); + globals.fs.file('lib/main.dart').createSync(recursive: true); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand() ..bundleBuilder = MockBundleBuilder()); @@ -170,9 +171,9 @@ }); testUsingContext('bundle can build for Linux if feature is enabled', () async { - fs.file('lib/main.dart').createSync(recursive: true); - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); + globals.fs.file('lib/main.dart').createSync(recursive: true); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand() ..bundleBuilder = MockBundleBuilder()); @@ -188,9 +189,9 @@ }); testUsingContext('bundle can build for macOS if feature is enabled', () async { - fs.file('lib/main.dart').createSync(recursive: true); - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); + globals.fs.file('lib/main.dart').createSync(recursive: true); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand() ..bundleBuilder = MockBundleBuilder()); @@ -206,14 +207,14 @@ }); testUsingContext('passes track widget creation through', () async { - fs.file('lib/main.dart').createSync(recursive: true); - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); + globals.fs.file('lib/main.dart').createSync(recursive: true); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); final CommandRunner<void> runner = createTestCommandRunner(BuildBundleCommand()); when(buildSystem.build(any, any)).thenAnswer((Invocation invocation) async { final Environment environment = invocation.positionalArguments[1] as Environment; expect(environment.defines, <String, String>{ - kTargetFile: fs.path.join('lib', 'main.dart'), + kTargetFile: globals.fs.path.join('lib', 'main.dart'), kBuildMode: 'debug', kTargetPlatform: 'android-arm', kTrackWidgetCreation: 'true',
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 102c0de..b1d284e 100644 --- a/packages/flutter_tools/test/commands.shard/permeable/create_test.dart +++ b/packages/flutter_tools/test/commands.shard/permeable/create_test.dart
@@ -7,10 +7,11 @@ import 'dart:typed_data'; import 'package:args/command_runner.dart'; +import 'package:platform/platform.dart'; + import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/net.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/commands/create.dart'; import 'package:flutter_tools/src/dart/pub.dart'; @@ -18,6 +19,7 @@ import 'package:flutter_tools/src/features.dart'; import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/version.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; @@ -50,7 +52,7 @@ setUp(() { loggingProcessManager = LoggingProcessManager(); - tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_create_test.'); + tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_create_test.'); projectDir = tempDir.childDirectory('flutter_project'); mockFlutterVersion = MockFlutterVersion(); }); @@ -455,12 +457,12 @@ await runner.run(<String>['create', '--no-pub', projectDir.path]); void expectExists(String relPath) { - expect(fs.isFileSync('${projectDir.path}/$relPath'), true); + expect(globals.fs.isFileSync('${projectDir.path}/$relPath'), true); } expectExists('android/gradle.properties'); - final String actualContents = await fs.file(projectDir.path + '/android/gradle.properties').readAsString(); + final String actualContents = await globals.fs.file(projectDir.path + '/android/gradle.properties').readAsString(); expect(actualContents.contains('useAndroidX'), true); }); @@ -476,12 +478,12 @@ await runner.run(<String>['create', '--no-pub', '--no-androidx', projectDir.path]); void expectExists(String relPath) { - expect(fs.isFileSync('${projectDir.path}/$relPath'), true); + expect(globals.fs.isFileSync('${projectDir.path}/$relPath'), true); } expectExists('android/gradle.properties'); - final String actualContents = await fs.file(projectDir.path + '/android/gradle.properties').readAsString(); + final String actualContents = await globals.fs.file(projectDir.path + '/android/gradle.properties').readAsString(); expect(actualContents.contains('useAndroidX'), false); }); @@ -531,12 +533,12 @@ await runner.run(<String>['create', '--no-pub', '--template=plugin', projectDir.path]); void expectExists(String relPath) { - expect(fs.isFileSync('${projectDir.path}/$relPath'), true); + expect(globals.fs.isFileSync('${projectDir.path}/$relPath'), true); } expectExists('android/gradle.properties'); - final String actualContents = await fs.file(projectDir.path + '/android/gradle.properties').readAsString(); + final String actualContents = await globals.fs.file(projectDir.path + '/android/gradle.properties').readAsString(); expect(actualContents.contains('useAndroidX'), true); }); @@ -552,12 +554,12 @@ await runner.run(<String>['create', '--no-pub', '--template=plugin', '--no-androidx', projectDir.path]); void expectExists(String relPath) { - expect(fs.isFileSync('${projectDir.path}/$relPath'), true); + expect(globals.fs.isFileSync('${projectDir.path}/$relPath'), true); } expectExists('android/gradle.properties'); - final String actualContents = await fs.file(projectDir.path + '/android/gradle.properties').readAsString(); + final String actualContents = await globals.fs.file(projectDir.path + '/android/gradle.properties').readAsString(); expect(actualContents.contains('useAndroidX'), false); }); @@ -633,13 +635,13 @@ await runner.run(<String>['create', '--template=module', '--no-pub', '--org', 'com.foo.bar', projectDir.path]); void expectExists(String relPath, [bool expectation = true]) { - expect(fs.isFileSync('${projectDir.path}/$relPath'), expectation); + expect(globals.fs.isFileSync('${projectDir.path}/$relPath'), expectation); } expectExists('lib/main.dart'); expectExists('test/widget_test.dart'); - final String actualContents = await fs.file(projectDir.path + '/test/widget_test.dart').readAsString(); + final String actualContents = await globals.fs.file(projectDir.path + '/test/widget_test.dart').readAsString(); expect(actualContents.contains('flutter_test.dart'), true); @@ -658,55 +660,55 @@ } } - await _runFlutterTest(projectDir, target: fs.path.join(projectDir.path, 'test', 'widget_test.dart')); + await _runFlutterTest(projectDir, target: globals.fs.path.join(projectDir.path, 'test', 'widget_test.dart')); // Generated Xcode settings - final String xcodeConfigPath = fs.path.join('.ios', 'Flutter', 'Generated.xcconfig'); + final String xcodeConfigPath = globals.fs.path.join('.ios', 'Flutter', 'Generated.xcconfig'); expectExists(xcodeConfigPath); - final File xcodeConfigFile = fs.file(fs.path.join(projectDir.path, xcodeConfigPath)); + final File xcodeConfigFile = globals.fs.file(globals.fs.path.join(projectDir.path, xcodeConfigPath)); final String xcodeConfig = xcodeConfigFile.readAsStringSync(); expect(xcodeConfig, contains('FLUTTER_ROOT=')); expect(xcodeConfig, contains('FLUTTER_APPLICATION_PATH=')); expect(xcodeConfig, contains('FLUTTER_TARGET=')); // Generated export environment variables script - final String buildPhaseScriptPath = fs.path.join('.ios', 'Flutter', 'flutter_export_environment.sh'); + final String buildPhaseScriptPath = globals.fs.path.join('.ios', 'Flutter', 'flutter_export_environment.sh'); expectExists(buildPhaseScriptPath); - final File buildPhaseScriptFile = fs.file(fs.path.join(projectDir.path, buildPhaseScriptPath)); + final File buildPhaseScriptFile = globals.fs.file(globals.fs.path.join(projectDir.path, buildPhaseScriptPath)); final String buildPhaseScript = buildPhaseScriptFile.readAsStringSync(); expect(buildPhaseScript, contains('FLUTTER_ROOT=')); expect(buildPhaseScript, contains('FLUTTER_APPLICATION_PATH=')); expect(buildPhaseScript, contains('FLUTTER_TARGET=')); // Generated podspec - final String podspecPath = fs.path.join('.ios', 'Flutter', 'flutter_project.podspec'); + final String podspecPath = globals.fs.path.join('.ios', 'Flutter', 'flutter_project.podspec'); expectExists(podspecPath); - final File podspecFile = fs.file(fs.path.join(projectDir.path, podspecPath)); + final File podspecFile = globals.fs.file(globals.fs.path.join(projectDir.path, podspecPath)); final String podspec = podspecFile.readAsStringSync(); expect(podspec, contains('Flutter module - flutter_project')); // App identification - final String xcodeProjectPath = fs.path.join('.ios', 'Runner.xcodeproj', 'project.pbxproj'); + final String xcodeProjectPath = globals.fs.path.join('.ios', 'Runner.xcodeproj', 'project.pbxproj'); expectExists(xcodeProjectPath); - final File xcodeProjectFile = fs.file(fs.path.join(projectDir.path, xcodeProjectPath)); + final File xcodeProjectFile = globals.fs.file(globals.fs.path.join(projectDir.path, xcodeProjectPath)); final String xcodeProject = xcodeProjectFile.readAsStringSync(); expect(xcodeProject, contains('PRODUCT_BUNDLE_IDENTIFIER = com.foo.bar.flutterProject')); // Xcode build system - final String xcodeWorkspaceSettingsPath = fs.path.join('.ios', 'Runner.xcworkspace', 'xcshareddata', 'WorkspaceSettings.xcsettings'); + final String xcodeWorkspaceSettingsPath = globals.fs.path.join('.ios', 'Runner.xcworkspace', 'xcshareddata', 'WorkspaceSettings.xcsettings'); expectExists(xcodeWorkspaceSettingsPath, false); - final String versionPath = fs.path.join('.metadata'); + final String versionPath = globals.fs.path.join('.metadata'); expectExists(versionPath); - final String version = fs.file(fs.path.join(projectDir.path, versionPath)).readAsStringSync(); + final String version = globals.fs.file(globals.fs.path.join(projectDir.path, versionPath)).readAsStringSync(); expect(version, contains('version:')); expect(version, contains('revision: 12345678')); expect(version, contains('channel: omega')); // IntelliJ metadata - final String intelliJSdkMetadataPath = fs.path.join('.idea', 'libraries', 'Dart_SDK.xml'); + final String intelliJSdkMetadataPath = globals.fs.path.join('.idea', 'libraries', 'Dart_SDK.xml'); expectExists(intelliJSdkMetadataPath); - final String sdkMetaContents = fs - .file(fs.path.join( + final String sdkMetaContents = globals.fs + .file(globals.fs.path.join( projectDir.path, intelliJSdkMetadataPath, )) @@ -729,7 +731,7 @@ await runner.run(<String>['create', '--template=app', '--no-pub', '--org', 'com.foo.bar', projectDir.path]); void expectExists(String relPath) { - expect(fs.isFileSync('${projectDir.path}/$relPath'), true); + expect(globals.fs.isFileSync('${projectDir.path}/$relPath'), true); } expectExists('lib/main.dart'); @@ -750,34 +752,34 @@ } } - await _runFlutterTest(projectDir, target: fs.path.join(projectDir.path, 'test', 'widget_test.dart')); + await _runFlutterTest(projectDir, target: globals.fs.path.join(projectDir.path, 'test', 'widget_test.dart')); // Generated Xcode settings - final String xcodeConfigPath = fs.path.join('ios', 'Flutter', 'Generated.xcconfig'); + final String xcodeConfigPath = globals.fs.path.join('ios', 'Flutter', 'Generated.xcconfig'); expectExists(xcodeConfigPath); - final File xcodeConfigFile = fs.file(fs.path.join(projectDir.path, xcodeConfigPath)); + final File xcodeConfigFile = globals.fs.file(globals.fs.path.join(projectDir.path, xcodeConfigPath)); final String xcodeConfig = xcodeConfigFile.readAsStringSync(); expect(xcodeConfig, contains('FLUTTER_ROOT=')); expect(xcodeConfig, contains('FLUTTER_APPLICATION_PATH=')); // App identification - final String xcodeProjectPath = fs.path.join('ios', 'Runner.xcodeproj', 'project.pbxproj'); + final String xcodeProjectPath = globals.fs.path.join('ios', 'Runner.xcodeproj', 'project.pbxproj'); expectExists(xcodeProjectPath); - final File xcodeProjectFile = fs.file(fs.path.join(projectDir.path, xcodeProjectPath)); + final File xcodeProjectFile = globals.fs.file(globals.fs.path.join(projectDir.path, xcodeProjectPath)); final String xcodeProject = xcodeProjectFile.readAsStringSync(); expect(xcodeProject, contains('PRODUCT_BUNDLE_IDENTIFIER = com.foo.bar.flutterProject')); - final String versionPath = fs.path.join('.metadata'); + final String versionPath = globals.fs.path.join('.metadata'); expectExists(versionPath); - final String version = fs.file(fs.path.join(projectDir.path, versionPath)).readAsStringSync(); + final String version = globals.fs.file(globals.fs.path.join(projectDir.path, versionPath)).readAsStringSync(); expect(version, contains('version:')); expect(version, contains('revision: 12345678')); expect(version, contains('channel: omega')); // IntelliJ metadata - final String intelliJSdkMetadataPath = fs.path.join('.idea', 'libraries', 'Dart_SDK.xml'); + final String intelliJSdkMetadataPath = globals.fs.path.join('.idea', 'libraries', 'Dart_SDK.xml'); expectExists(intelliJSdkMetadataPath); - final String sdkMetaContents = fs - .file(fs.path.join( + final String sdkMetaContents = globals.fs + .file(globals.fs.path.join( projectDir.path, intelliJSdkMetadataPath, )) @@ -797,9 +799,9 @@ final CreateCommand command = CreateCommand(); final CommandRunner<void> runner = createTestCommandRunner(command); - String tmpProjectDir = fs.path.join(tempDir.path, 'hello_flutter'); + String tmpProjectDir = globals.fs.path.join(tempDir.path, 'hello_flutter'); await runner.run(<String>['create', '--template=app', '--no-pub', '--org', 'com.example', tmpProjectDir]); - FlutterProject project = FlutterProject.fromDirectory(fs.directory(tmpProjectDir)); + FlutterProject project = FlutterProject.fromDirectory(globals.fs.directory(tmpProjectDir)); expect( await project.ios.productBundleIdentifier, 'com.example.helloFlutter', @@ -809,9 +811,9 @@ 'com.example.hello_flutter', ); - tmpProjectDir = fs.path.join(tempDir.path, 'test_abc'); + tmpProjectDir = globals.fs.path.join(tempDir.path, 'test_abc'); await runner.run(<String>['create', '--template=app', '--no-pub', '--org', 'abc^*.1#@', tmpProjectDir]); - project = FlutterProject.fromDirectory(fs.directory(tmpProjectDir)); + project = FlutterProject.fromDirectory(globals.fs.directory(tmpProjectDir)); expect( await project.ios.productBundleIdentifier, 'abc.1.testAbc', @@ -821,9 +823,9 @@ 'abc.u1.test_abc', ); - tmpProjectDir = fs.path.join(tempDir.path, 'flutter_project'); + tmpProjectDir = globals.fs.path.join(tempDir.path, 'flutter_project'); await runner.run(<String>['create', '--template=app', '--no-pub', '--org', '#+^%', tmpProjectDir]); - project = FlutterProject.fromDirectory(fs.directory(tmpProjectDir)); + project = FlutterProject.fromDirectory(globals.fs.directory(tmpProjectDir)); expect( await project.ios.productBundleIdentifier, 'flutterProject.untitled', @@ -847,7 +849,7 @@ await runner.run(<String>['create', '--no-pub', projectDir.path]); - final String metadata = fs.file(fs.path.join(projectDir.path, '.metadata')).readAsStringSync(); + final String metadata = globals.fs.file(globals.fs.path.join(projectDir.path, '.metadata')).readAsStringSync(); expect(metadata, contains('project_type: app\n')); }); @@ -860,11 +862,11 @@ await runner.run(<String>['create', '--no-pub', '--template=app', projectDir.path]); // Remove the .metadata to simulate an older instantiation that didn't generate those. - fs.file(fs.path.join(projectDir.path, '.metadata')).deleteSync(); + globals.fs.file(globals.fs.path.join(projectDir.path, '.metadata')).deleteSync(); await runner.run(<String>['create', '--no-pub', projectDir.path]); - final String metadata = fs.file(fs.path.join(projectDir.path, '.metadata')).readAsStringSync(); + final String metadata = globals.fs.file(globals.fs.path.join(projectDir.path, '.metadata')).readAsStringSync(); expect(metadata, contains('project_type: app\n')); }); @@ -878,7 +880,7 @@ await runner.run(<String>['create', '--no-pub', projectDir.path]); - final String metadata = fs.file(fs.path.join(projectDir.path, '.metadata')).readAsStringSync(); + final String metadata = globals.fs.file(globals.fs.path.join(projectDir.path, '.metadata')).readAsStringSync(); expect(metadata, contains('project_type: app\n')); }); @@ -892,7 +894,7 @@ await runner.run(<String>['create', '--no-pub', projectDir.path]); - final String metadata = fs.file(fs.path.join(projectDir.path, '.metadata')).readAsStringSync(); + final String metadata = globals.fs.file(globals.fs.path.join(projectDir.path, '.metadata')).readAsStringSync(); expect(metadata, contains('project_type: module\n')); }); @@ -906,7 +908,7 @@ await runner.run(<String>['create', '--no-pub', projectDir.path]); - final String metadata = fs.file(fs.path.join(projectDir.path, '.metadata')).readAsStringSync(); + final String metadata = globals.fs.file(globals.fs.path.join(projectDir.path, '.metadata')).readAsStringSync(); expect(metadata, contains('project_type: plugin')); }); @@ -920,7 +922,7 @@ await runner.run(<String>['create', '--no-pub', projectDir.path]); - final String metadata = fs.file(fs.path.join(projectDir.path, '.metadata')).readAsStringSync(); + final String metadata = globals.fs.file(globals.fs.path.join(projectDir.path, '.metadata')).readAsStringSync(); expect(metadata, contains('project_type: package')); }); @@ -1038,7 +1040,7 @@ <String>['--no-pub', '--template=app', '--org', 'com.bar.foo'], <String>[], ); - fs.directory(fs.path.join(projectDir.path, 'ios')).deleteSync(recursive: true); + globals.fs.directory(globals.fs.path.join(projectDir.path, 'ios')).deleteSync(recursive: true); await _createProject( projectDir, <String>['--no-pub', '--template=app', '--org', 'com.bar.baz'], @@ -1067,7 +1069,7 @@ Cache.flutterRoot = '../..'; final CreateCommand command = CreateCommand(); final CommandRunner<void> runner = createTestCommandRunner(command); - final File existingFile = fs.file(fs.path.join(projectDir.path, 'bad')); + final File existingFile = globals.fs.file(globals.fs.path.join(projectDir.path, 'bad')); if (!existingFile.existsSync()) { existingFile.createSync(recursive: true); } @@ -1081,7 +1083,7 @@ Cache.flutterRoot = '../..'; final CreateCommand command = CreateCommand(); final CommandRunner<void> runner = createTestCommandRunner(command); - final File existingFile = fs.file(fs.path.join(projectDir.path, 'bad')); + final File existingFile = globals.fs.file(globals.fs.path.join(projectDir.path, 'bad')); if (!existingFile.existsSync()) { existingFile.createSync(recursive: true); } @@ -1093,14 +1095,14 @@ testUsingContext('overwrites existing directory when requested', () async { Cache.flutterRoot = '../..'; - final Directory existingDirectory = fs.directory(fs.path.join(projectDir.path, 'bad')); + final Directory existingDirectory = globals.fs.directory(globals.fs.path.join(projectDir.path, 'bad')); if (!existingDirectory.existsSync()) { existingDirectory.createSync(recursive: true); } - final File existingFile = fs.file(fs.path.join(existingDirectory.path, 'lib', 'main.dart')); + final File existingFile = globals.fs.file(globals.fs.path.join(existingDirectory.path, 'lib', 'main.dart')); existingFile.createSync(recursive: true); await _createProject( - fs.directory(existingDirectory.path), + globals.fs.directory(existingDirectory.path), <String>['--overwrite', '-i', 'objc', '-a', 'java'], <String>[ 'android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java', @@ -1169,7 +1171,7 @@ }); testUsingContext('can write samples index to disk', () async { - final String outputFile = fs.path.join(tempDir.path, 'flutter_samples.json'); + final String outputFile = globals.fs.path.join(tempDir.path, 'flutter_samples.json'); final CreateCommand command = CreateCommand(); final CommandRunner<void> runner = createTestCommandRunner(command); final List<String> args = <String>[ @@ -1179,7 +1181,7 @@ ]; await runner.run(args); - final File expectedFile = fs.file(outputFile); + final File expectedFile = globals.fs.file(outputFile); expect(expectedFile.existsSync(), isTrue); expect(expectedFile.readAsStringSync(), equals(samplesIndexJson)); }, overrides: <Type, Generator>{ @@ -1187,7 +1189,7 @@ () => MockHttpClient(200, result: samplesIndexJson), }); testUsingContext('provides an error to the user if samples json download fails', () async { - final String outputFile = fs.path.join(tempDir.path, 'flutter_samples.json'); + final String outputFile = globals.fs.path.join(tempDir.path, 'flutter_samples.json'); final CreateCommand command = CreateCommand(); final CommandRunner<void> runner = createTestCommandRunner(command); final List<String> args = <String>[ @@ -1197,7 +1199,7 @@ ]; await expectLater(runner.run(args), throwsToolExit(exitCode: 2, message: 'Failed to write samples')); - expect(fs.file(outputFile).existsSync(), isFalse); + expect(globals.fs.file(outputFile).existsSync(), isFalse); }, overrides: <Type, Generator>{ HttpClientFactory: () => () => MockHttpClient(404, result: 'not found'), @@ -1220,8 +1222,8 @@ ]); bool pathExists(String path) { - final String fullPath = fs.path.join(dir.path, path); - return fs.typeSync(fullPath) != FileSystemEntityType.notFound; + final String fullPath = globals.fs.path.join(dir.path, path); + return globals.fs.typeSync(fullPath) != FileSystemEntityType.notFound; } final List<String> failures = <String>[ @@ -1246,22 +1248,22 @@ } Future<void> _ensureFlutterToolsSnapshot() async { - final String flutterToolsPath = fs.path.absolute(fs.path.join( + final String flutterToolsPath = globals.fs.path.absolute(globals.fs.path.join( 'bin', 'flutter_tools.dart', )); - final String flutterToolsSnapshotPath = fs.path.absolute(fs.path.join( + final String flutterToolsSnapshotPath = globals.fs.path.absolute(globals.fs.path.join( '..', '..', 'bin', 'cache', 'flutter_tools.snapshot', )); - final String dotPackages = fs.path.absolute(fs.path.join( + final String dotPackages = globals.fs.path.absolute(globals.fs.path.join( '.packages', )); - final File snapshotFile = fs.file(flutterToolsSnapshotPath); + final File snapshotFile = globals.fs.file(flutterToolsSnapshotPath); if (snapshotFile.existsSync()) { snapshotFile.renameSync(flutterToolsSnapshotPath + '.bak'); } @@ -1284,7 +1286,7 @@ } Future<void> _restoreFlutterToolsSnapshot() async { - final String flutterToolsSnapshotPath = fs.path.absolute(fs.path.join( + final String flutterToolsSnapshotPath = globals.fs.path.absolute(globals.fs.path.join( '..', '..', 'bin', @@ -1292,7 +1294,7 @@ 'flutter_tools.snapshot', )); - final File snapshotBackup = fs.file(flutterToolsSnapshotPath + '.bak'); + final File snapshotBackup = globals.fs.file(flutterToolsSnapshotPath + '.bak'); if (!snapshotBackup.existsSync()) { // No backup to restore. return; @@ -1302,7 +1304,7 @@ } Future<void> _analyzeProject(String workingDir) async { - final String flutterToolsSnapshotPath = fs.path.absolute(fs.path.join( + final String flutterToolsSnapshotPath = globals.fs.path.absolute(globals.fs.path.join( '..', '..', 'bin', @@ -1329,7 +1331,7 @@ } Future<void> _runFlutterTest(Directory workingDir, { String target }) async { - final String flutterToolsSnapshotPath = fs.path.absolute(fs.path.join( + final String flutterToolsSnapshotPath = globals.fs.path.absolute(globals.fs.path.join( '..', '..', 'bin',
diff --git a/packages/flutter_tools/test/commands.shard/permeable/format_test.dart b/packages/flutter_tools/test/commands.shard/permeable/format_test.dart index 2b6d0b1..b591275 100644 --- a/packages/flutter_tools/test/commands.shard/permeable/format_test.dart +++ b/packages/flutter_tools/test/commands.shard/permeable/format_test.dart
@@ -6,6 +6,7 @@ import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/commands/format.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../../src/common.dart'; import '../../src/context.dart'; @@ -16,7 +17,7 @@ setUp(() { Cache.disableLocking(); - tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_format_test.'); + tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_format_test.'); }); tearDown(() { @@ -26,7 +27,7 @@ testUsingContext('a file', () async { final String projectPath = await createProject(tempDir); - final File srcFile = fs.file(fs.path.join(projectPath, 'lib', 'main.dart')); + final File srcFile = globals.fs.file(globals.fs.path.join(projectPath, 'lib', 'main.dart')); final String original = srcFile.readAsStringSync(); srcFile.writeAsStringSync(original.replaceFirst('main()', 'main( )')); @@ -41,8 +42,8 @@ testUsingContext('dry-run', () async { final String projectPath = await createProject(tempDir); - final File srcFile = fs.file( - fs.path.join(projectPath, 'lib', 'main.dart')); + final File srcFile = globals.fs.file( + globals.fs.path.join(projectPath, 'lib', 'main.dart')); final String nonFormatted = srcFile.readAsStringSync().replaceFirst( 'main()', 'main( )'); srcFile.writeAsStringSync(nonFormatted); @@ -58,8 +59,8 @@ testUsingContext('dry-run with set-exit-if-changed', () async { final String projectPath = await createProject(tempDir); - final File srcFile = fs.file( - fs.path.join(projectPath, 'lib', 'main.dart')); + final File srcFile = globals.fs.file( + globals.fs.path.join(projectPath, 'lib', 'main.dart')); final String nonFormatted = srcFile.readAsStringSync().replaceFirst( 'main()', 'main( )'); srcFile.writeAsStringSync(nonFormatted); @@ -80,8 +81,8 @@ const int lineLengthLong = 120; final String projectPath = await createProject(tempDir); - final File srcFile = fs.file( - fs.path.join(projectPath, 'lib', 'main.dart')); + final File srcFile = globals.fs.file( + globals.fs.path.join(projectPath, 'lib', 'main.dart')); final String nonFormatted = srcFile.readAsStringSync(); srcFile.writeAsStringSync( nonFormatted.replaceFirst('main()',
diff --git a/packages/flutter_tools/test/commands.shard/permeable/packages_test.dart b/packages/flutter_tools/test/commands.shard/permeable/packages_test.dart index 375a390..657b580 100644 --- a/packages/flutter_tools/test/commands.shard/permeable/packages_test.dart +++ b/packages/flutter_tools/test/commands.shard/permeable/packages_test.dart
@@ -14,6 +14,7 @@ import 'package:flutter_tools/src/features.dart'; import 'package:flutter_tools/src/reporting/reporting.dart'; import 'package:process/process.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../../src/common.dart'; import '../../src/context.dart'; @@ -42,7 +43,7 @@ Directory tempDir; setUp(() { - tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.'); + tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.'); }); tearDown(() { @@ -51,7 +52,7 @@ Future<String> createProjectWithPlugin(String plugin, { List<String> arguments }) async { final String projectPath = await createProject(tempDir, arguments: arguments); - final File pubspec = fs.file(fs.path.join(projectPath, 'pubspec.yaml')); + final File pubspec = globals.fs.file(globals.fs.path.join(projectPath, 'pubspec.yaml')); String content = await pubspec.readAsString(); content = content.replaceFirst( '\ndependencies:\n', @@ -75,7 +76,7 @@ void expectExists(String projectPath, String relPath) { expect( - fs.isFileSync(fs.path.join(projectPath, relPath)), + globals.fs.isFileSync(globals.fs.path.join(projectPath, relPath)), true, reason: '$projectPath/$relPath should exist, but does not', ); @@ -84,7 +85,7 @@ void expectContains(String projectPath, String relPath, String substring) { expectExists(projectPath, relPath); expect( - fs.file(fs.path.join(projectPath, relPath)).readAsStringSync(), + globals.fs.file(globals.fs.path.join(projectPath, relPath)).readAsStringSync(), contains(substring), reason: '$projectPath/$relPath has unexpected content', ); @@ -92,7 +93,7 @@ void expectNotExists(String projectPath, String relPath) { expect( - fs.isFileSync(fs.path.join(projectPath, relPath)), + globals.fs.isFileSync(globals.fs.path.join(projectPath, relPath)), false, reason: '$projectPath/$relPath should not exist, but does', ); @@ -101,7 +102,7 @@ void expectNotContains(String projectPath, String relPath, String substring) { expectExists(projectPath, relPath); expect( - fs.file(fs.path.join(projectPath, relPath)).readAsStringSync(), + globals.fs.file(globals.fs.path.join(projectPath, relPath)).readAsStringSync(), isNot(contains(substring)), reason: '$projectPath/$relPath has unexpected content', ); @@ -193,7 +194,7 @@ pluginWitnesses, ].expand<String>((List<String> list) => list); for (String path in allFiles) { - final File file = fs.file(fs.path.join(projectPath, path)); + final File file = globals.fs.file(globals.fs.path.join(projectPath, path)); if (file.existsSync()) { file.deleteSync(); } @@ -329,7 +330,7 @@ tempDir, arguments: <String>['--template=plugin', '--no-pub'], ); - final String exampleProjectPath = fs.path.join(projectPath, 'example'); + final String exampleProjectPath = globals.fs.path.join(projectPath, 'example'); removeGeneratedFiles(projectPath); removeGeneratedFiles(exampleProjectPath);
diff --git a/packages/flutter_tools/test/commands.shard/permeable/test_test.dart b/packages/flutter_tools/test/commands.shard/permeable/test_test.dart index 78924d8..b35dc7f 100644 --- a/packages/flutter_tools/test/commands.shard/permeable/test_test.dart +++ b/packages/flutter_tools/test/commands.shard/permeable/test_test.dart
@@ -9,6 +9,7 @@ import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/dart/sdk.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../../src/common.dart'; import '../../src/context.dart'; @@ -18,8 +19,8 @@ Future<void> _testExclusionLock; void main() { - final String automatedTestsDirectory = fs.path.join('..', '..', 'dev', 'automated_tests'); - final String flutterTestDirectory = fs.path.join(automatedTestsDirectory, 'flutter_test'); + final String automatedTestsDirectory = globals.fs.path.join('..', '..', 'dev', 'automated_tests'); + final String flutterTestDirectory = globals.fs.path.join(automatedTestsDirectory, 'flutter_test'); testUsingContext('flutter test should not have extraneous error messages', () async { Cache.flutterRoot = '../..'; @@ -47,7 +48,7 @@ }); testUsingContext('flutter test should report a nice error when a pubspec.yaml is missing a flutter_test dependency', () async { - final String missingDependencyTests = fs.path.join('..', '..', 'dev', 'missing_dependency_tests'); + final String missingDependencyTests = globals.fs.path.join('..', '..', 'dev', 'missing_dependency_tests'); Cache.flutterRoot = '../..'; return _testFile('trivial', missingDependencyTests, missingDependencyTests); }); @@ -140,8 +141,8 @@ List<String> extraArguments = const <String>[], }) async { exitCode ??= isNonZero; - final String fullTestExpectation = fs.path.join(testDirectory, '${testName}_expectation.txt'); - final File expectationFile = fs.file(fullTestExpectation); + final String fullTestExpectation = globals.fs.path.join(testDirectory, '${testName}_expectation.txt'); + final File expectationFile = globals.fs.file(fullTestExpectation); if (!expectationFile.existsSync()) { fail('missing expectation file: $expectationFile'); } @@ -167,7 +168,7 @@ } output.add('<<stderr>>'); output.addAll((exec.stderr as String).split('\n')); - final List<String> expectations = fs.file(fullTestExpectation).readAsLinesSync(); + final List<String> expectations = globals.fs.file(fullTestExpectation).readAsLinesSync(); bool allowSkip = false; int expectationLineNumber = 0; int outputLineNumber = 0; @@ -229,14 +230,14 @@ if (testName == null) { // Test everything in the directory. testPath = testDirectory; - final Directory directoryToTest = fs.directory(testPath); + final Directory directoryToTest = globals.fs.directory(testPath); if (!directoryToTest.existsSync()) { fail('missing test directory: $directoryToTest'); } } else { // Test just a specific test file. - testPath = fs.path.join(testDirectory, '${testName}_test.dart'); - final File testFile = fs.file(testPath); + testPath = globals.fs.path.join(testDirectory, '${testName}_test.dart'); + final File testFile = globals.fs.file(testPath); if (!testFile.existsSync()) { fail('missing test file: $testFile'); } @@ -244,7 +245,7 @@ final List<String> args = <String>[ ...dartVmFlags, - fs.path.absolute(fs.path.join('bin', 'flutter_tools.dart')), + globals.fs.path.absolute(globals.fs.path.join('bin', 'flutter_tools.dart')), 'test', '--no-color', ...extraArguments, @@ -259,7 +260,7 @@ _testExclusionLock = testExclusionCompleter.future; try { return await Process.run( - fs.path.join(dartSdkPath, 'bin', 'dart'), + globals.fs.path.join(dartSdkPath, 'bin', 'dart'), args, workingDirectory: workingDirectory, stdoutEncoding: utf8,
diff --git a/packages/flutter_tools/test/commands.shard/permeable/upgrade_test.dart b/packages/flutter_tools/test/commands.shard/permeable/upgrade_test.dart index b911682..e8961e0 100644 --- a/packages/flutter_tools/test/commands.shard/permeable/upgrade_test.dart +++ b/packages/flutter_tools/test/commands.shard/permeable/upgrade_test.dart
@@ -5,7 +5,7 @@ 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/platform.dart'; + import 'package:flutter_tools/src/base/os.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/commands/upgrade.dart'; @@ -16,6 +16,7 @@ import 'package:mockito/mockito.dart'; import 'package:platform/platform.dart'; import 'package:process/process.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../../src/common.dart'; import '../../src/context.dart'; @@ -38,7 +39,7 @@ processManager = MockProcessManager(); when(processManager.start( <String>[ - fs.path.join('bin', 'flutter'), + globals.fs.path.join('bin', 'flutter'), 'upgrade', '--continue', '--no-version-check', @@ -130,9 +131,9 @@ flutterVersion, ); expect(await result, null); - verifyNever(processManager.start( + verifyNever(globals.processManager.start( <String>[ - fs.path.join('bin', 'flutter'), + globals.fs.path.join('bin', 'flutter'), 'upgrade', '--continue', '--no-version-check', @@ -147,7 +148,7 @@ }); testUsingContext('verifyUpstreamConfigured', () async { - when(processManager.run( + when(globals.processManager.run( <String>['git', 'rev-parse', '@{u}'], environment:anyNamed('environment'), workingDirectory: anyNamed('workingDirectory')), @@ -164,9 +165,9 @@ testUsingContext('flutterUpgradeContinue passes env variables to child process', () async { await realCommandRunner.flutterUpgradeContinue(); - final VerificationResult result = verify(processManager.start( + final VerificationResult result = verify(globals.processManager.start( <String>[ - fs.path.join('bin', 'flutter'), + globals.fs.path.join('bin', 'flutter'), 'upgrade', '--continue', '--no-version-check', @@ -184,13 +185,13 @@ testUsingContext('precacheArtifacts passes env variables to child process', () async { final List<String> precacheCommand = <String>[ - fs.path.join('bin', 'flutter'), + globals.fs.path.join('bin', 'flutter'), '--no-color', '--no-version-check', 'precache', ]; - when(processManager.start( + when(globals.processManager.start( precacheCommand, environment: anyNamed('environment'), workingDirectory: anyNamed('workingDirectory'), @@ -200,7 +201,7 @@ await realCommandRunner.precacheArtifacts(); - final VerificationResult result = verify(processManager.start( + final VerificationResult result = verify(globals.processManager.start( precacheCommand, environment: captureAnyNamed('environment'), workingDirectory: anyNamed('workingDirectory'), @@ -230,7 +231,7 @@ stdout: 'v1.12.16-19-gb45b676af', ), ]); - tempDir = fs.systemTempDirectory.createTempSync('flutter_upgrade_test.'); + tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_upgrade_test.'); flutterToolState = tempDir.childFile('.flutter_tool_state'); mockFlutterVersion = MockFlutterVersion(isStable: true); }); @@ -288,7 +289,7 @@ Directory tempDir; setUp(() async { - tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_upgrade_test.'); + tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_upgrade_test.'); }); tearDown(() { @@ -298,16 +299,16 @@ testUsingContext('in project', () async { final String projectPath = await createProject(tempDir); expect(findProjectRoot(projectPath), projectPath); - expect(findProjectRoot(fs.path.join(projectPath, 'lib')), projectPath); + expect(findProjectRoot(globals.fs.path.join(projectPath, 'lib')), projectPath); - final String hello = fs.path.join(Cache.flutterRoot, 'examples', 'hello_world'); + final String hello = globals.fs.path.join(Cache.flutterRoot, 'examples', 'hello_world'); expect(findProjectRoot(hello), hello); - expect(findProjectRoot(fs.path.join(hello, 'lib')), hello); + expect(findProjectRoot(globals.fs.path.join(hello, 'lib')), hello); }); testUsingContext('outside project', () async { final String projectPath = await createProject(tempDir); - expect(findProjectRoot(fs.directory(projectPath).parent.path), null); + expect(findProjectRoot(globals.fs.directory(projectPath).parent.path), null); expect(findProjectRoot(Cache.flutterRoot), null); }); });
diff --git a/packages/flutter_tools/test/general.shard/analytics_test.dart b/packages/flutter_tools/test/general.shard/analytics_test.dart index a6accb3..1bc5d2e 100644 --- a/packages/flutter_tools/test/general.shard/analytics_test.dart +++ b/packages/flutter_tools/test/general.shard/analytics_test.dart
@@ -7,7 +7,7 @@ import 'package:flutter_tools/src/base/config.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; -import 'package:flutter_tools/src/base/platform.dart'; + import 'package:flutter_tools/src/base/time.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/commands/build.dart'; @@ -18,6 +18,7 @@ import 'package:flutter_tools/src/reporting/reporting.dart'; import 'package:flutter_tools/src/runner/flutter_command.dart'; import 'package:flutter_tools/src/version.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import 'package:platform/platform.dart'; @@ -36,7 +37,7 @@ setUp(() { Cache.flutterRoot = '../..'; - tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_analytics_test.'); + tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_analytics_test.'); mockFlutterConfig = MockFlutterConfig(); }); @@ -100,7 +101,7 @@ usage.sendCommand('test'); final String featuresKey = cdKey(CustomDimensions.enabledFlutterFeatures); - expect(fs.file('test').readAsStringSync(), contains('$featuresKey: enable-web')); + expect(globals.fs.file('test').readAsStringSync(), contains('$featuresKey: enable-web')); }, overrides: <Type, Generator>{ FlutterVersion: () => FlutterVersion(const SystemClock()), Config: () => mockFlutterConfig, @@ -122,7 +123,7 @@ usage.sendCommand('test'); final String featuresKey = cdKey(CustomDimensions.enabledFlutterFeatures); - expect(fs.file('test').readAsStringSync(), contains('$featuresKey: enable-web,enable-linux-desktop,enable-macos-desktop')); + expect(globals.fs.file('test').readAsStringSync(), contains('$featuresKey: enable-web,enable-linux-desktop,enable-macos-desktop')); }, overrides: <Type, Generator>{ FlutterVersion: () => FlutterVersion(const SystemClock()), Config: () => mockFlutterConfig, @@ -218,7 +219,7 @@ usage.sendCommand('test'); - final String log = fs.file('analytics.log').readAsStringSync(); + final String log = globals.fs.file('analytics.log').readAsStringSync(); final DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(kMillis); expect(log.contains(formatDateTime(dateTime)), isTrue); }, overrides: <Type, Generator>{ @@ -244,7 +245,7 @@ usage.sendEvent('test', 'test'); - final String log = fs.file('analytics.log').readAsStringSync(); + final String log = globals.fs.file('analytics.log').readAsStringSync(); final DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(kMillis); expect(log.contains(formatDateTime(dateTime)), isTrue); }, overrides: <Type, Generator>{ @@ -264,7 +265,7 @@ Directory tempDir; setUp(() { - tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_analytics_bots_test.'); + tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_analytics_bots_test.'); }); tearDown(() {
diff --git a/packages/flutter_tools/test/general.shard/android/android_device_test.dart b/packages/flutter_tools/test/general.shard/android/android_device_test.dart index 110f902..d2d82a7 100644 --- a/packages/flutter_tools/test/general.shard/android/android_device_test.dart +++ b/packages/flutter_tools/test/general.shard/android/android_device_test.dart
@@ -11,16 +11,16 @@ import 'package:flutter_tools/src/android/android_device.dart'; import 'package:flutter_tools/src/android/android_sdk.dart'; import 'package:flutter_tools/src/application_package.dart'; -import 'package:flutter_tools/src/base/config.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/process.dart'; import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/project.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; +import 'package:platform/platform.dart'; import '../../src/common.dart'; import '../../src/context.dart'; @@ -111,8 +111,8 @@ final AndroidDevice device = AndroidDevice(deviceId, modelID: 'TestModel'); final Directory sdkDir = MockAndroidSdk.createSdkDirectory(); - Config.instance.setValue('android-sdk', sdkDir.path); - final File adbExe = fs.file(getAdbPath(androidSdk)); + globals.config.setValue('android-sdk', sdkDir.path); + final File adbExe = globals.fs.file(getAdbPath(androidSdk)); when(mockAndroidSdk.licensesAvailable).thenReturn(true); when(mockAndroidSdk.latestVersion).thenReturn(MockAndroidSdkVersion()); @@ -153,8 +153,8 @@ final AndroidDevice device = AndroidDevice(deviceId, modelID: 'TestModel'); final Directory sdkDir = MockAndroidSdk.createSdkDirectory(); - Config.instance.setValue('android-sdk', sdkDir.path); - final File adbExe = fs.file(getAdbPath(androidSdk)); + globals.config.setValue('android-sdk', sdkDir.path); + final File adbExe = globals.fs.file(getAdbPath(androidSdk)); when(mockAndroidSdk.licensesAvailable).thenReturn(true); when(mockAndroidSdk.latestVersion).thenReturn(MockAndroidSdkVersion()); @@ -194,9 +194,9 @@ testUsingContext('throws on missing adb path', () { final Directory sdkDir = MockAndroidSdk.createSdkDirectory(); - Config.instance.setValue('android-sdk', sdkDir.path); + globals.config.setValue('android-sdk', sdkDir.path); - final File adbExe = fs.file(getAdbPath(androidSdk)); + final File adbExe = globals.fs.file(getAdbPath(androidSdk)); when(mockProcessManager.runSync( <String>[adbExe.path, 'devices', '-l'], )).thenThrow(ArgumentError(adbExe.path)); @@ -209,9 +209,9 @@ testUsingContext('throws on failing adb', () { final Directory sdkDir = MockAndroidSdk.createSdkDirectory(); - Config.instance.setValue('android-sdk', sdkDir.path); + globals.config.setValue('android-sdk', sdkDir.path); - final File adbExe = fs.file(getAdbPath(androidSdk)); + final File adbExe = globals.fs.file(getAdbPath(androidSdk)); when(mockProcessManager.runSync( <String>[adbExe.path, 'devices', '-l'], )).thenThrow(ProcessException(adbExe.path, <String>['devices', '-l'])); @@ -497,7 +497,7 @@ }); testUsingContext('isSupportedForProject is true on module project', () async { - fs.file('pubspec.yaml') + globals.fs.file('pubspec.yaml') ..createSync() ..writeAsStringSync(r''' name: example @@ -505,7 +505,7 @@ flutter: module: {} '''); - fs.file('.packages').createSync(); + globals.fs.file('.packages').createSync(); final FlutterProject flutterProject = FlutterProject.current(); expect(AndroidDevice('test').isSupportedForProject(flutterProject), true); @@ -515,9 +515,9 @@ }); testUsingContext('isSupportedForProject is true with editable host app', () async { - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); - fs.directory('android').createSync(); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); + globals.fs.directory('android').createSync(); final FlutterProject flutterProject = FlutterProject.current(); expect(AndroidDevice('test').isSupportedForProject(flutterProject), true); @@ -527,8 +527,8 @@ }); testUsingContext('isSupportedForProject is false with no host app and no module', () async { - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); final FlutterProject flutterProject = FlutterProject.current(); expect(AndroidDevice('test').isSupportedForProject(flutterProject), false);
diff --git a/packages/flutter_tools/test/general.shard/android/android_sdk_test.dart b/packages/flutter_tools/test/general.shard/android/android_sdk_test.dart index 56baf77..736531b 100644 --- a/packages/flutter_tools/test/general.shard/android/android_sdk_test.dart +++ b/packages/flutter_tools/test/general.shard/android/android_sdk_test.dart
@@ -6,10 +6,10 @@ import 'package:flutter_tools/src/android/android_sdk.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart' show ProcessResult; -import 'package:flutter_tools/src/base/platform.dart'; -import 'package:flutter_tools/src/base/config.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; +import 'package:platform/platform.dart'; import '../../src/common.dart'; import '../../src/context.dart'; @@ -38,7 +38,7 @@ testUsingContext('parse sdk', () { sdkDir = MockAndroidSdk.createSdkDirectory(); - Config.instance.setValue('android-sdk', sdkDir.path); + globals.config.setValue('android-sdk', sdkDir.path); final AndroidSdk sdk = AndroidSdk.locateAndroidSdk(); expect(sdk.latestVersion, isNotNull); @@ -50,7 +50,7 @@ testUsingContext('parse sdk N', () { sdkDir = MockAndroidSdk.createSdkDirectory(withAndroidN: true); - Config.instance.setValue('android-sdk', sdkDir.path); + globals.config.setValue('android-sdk', sdkDir.path); final AndroidSdk sdk = AndroidSdk.locateAndroidSdk(); expect(sdk.latestVersion, isNotNull); @@ -62,10 +62,10 @@ testUsingContext('returns sdkmanager path', () { sdkDir = MockAndroidSdk.createSdkDirectory(); - Config.instance.setValue('android-sdk', sdkDir.path); + globals.config.setValue('android-sdk', sdkDir.path); final AndroidSdk sdk = AndroidSdk.locateAndroidSdk(); - expect(sdk.sdkManagerPath, fs.path.join(sdk.directory, 'tools', 'bin', 'sdkmanager')); + expect(sdk.sdkManagerPath, globals.fs.path.join(sdk.directory, 'tools', 'bin', 'sdkmanager')); }, overrides: <Type, Generator>{ FileSystem: () => fs, ProcessManager: () => FakeProcessManager.any(), @@ -73,11 +73,11 @@ testUsingContext('returns sdkmanager version', () { sdkDir = MockAndroidSdk.createSdkDirectory(); - Config.instance.setValue('android-sdk', sdkDir.path); + globals.config.setValue('android-sdk', sdkDir.path); final AndroidSdk sdk = AndroidSdk.locateAndroidSdk(); - when(processManager.canRun(sdk.sdkManagerPath)).thenReturn(true); - when(processManager.runSync(<String>[sdk.sdkManagerPath, '--version'], + when(globals.processManager.canRun(sdk.sdkManagerPath)).thenReturn(true); + when(globals.processManager.runSync(<String>[sdk.sdkManagerPath, '--version'], environment: argThat(isNotNull, named: 'environment'))) .thenReturn(ProcessResult(1, 0, '26.1.1\n', '')); expect(sdk.sdkManagerVersion, '26.1.1'); @@ -88,10 +88,10 @@ testUsingContext('returns validate sdk is well formed', () { sdkDir = MockBrokenAndroidSdk.createSdkDirectory(); - Config.instance.setValue('android-sdk', sdkDir.path); + globals.config.setValue('android-sdk', sdkDir.path); final AndroidSdk sdk = AndroidSdk.locateAndroidSdk(); - when(processManager.canRun(sdk.adbPath)).thenReturn(true); + when(globals.processManager.canRun(sdk.adbPath)).thenReturn(true); final List<String> validationIssues = sdk.validateSdkWellFormed(); expect(validationIssues.first, 'No valid Android SDK platforms found in' @@ -105,11 +105,11 @@ testUsingContext('does not throw on sdkmanager version check failure', () { sdkDir = MockAndroidSdk.createSdkDirectory(); - Config.instance.setValue('android-sdk', sdkDir.path); + globals.config.setValue('android-sdk', sdkDir.path); final AndroidSdk sdk = AndroidSdk.locateAndroidSdk(); - when(processManager.canRun(sdk.sdkManagerPath)).thenReturn(true); - when(processManager.runSync(<String>[sdk.sdkManagerPath, '--version'], + when(globals.processManager.canRun(sdk.sdkManagerPath)).thenReturn(true); + when(globals.processManager.runSync(<String>[sdk.sdkManagerPath, '--version'], environment: argThat(isNotNull, named: 'environment'))) .thenReturn(ProcessResult(1, 1, '26.1.1\n', 'Mystery error')); expect(sdk.sdkManagerVersion, isNull); @@ -120,10 +120,10 @@ testUsingContext('throws on sdkmanager version check if sdkmanager not found', () { sdkDir = MockAndroidSdk.createSdkDirectory(withSdkManager: false); - Config.instance.setValue('android-sdk', sdkDir.path); + globals.config.setValue('android-sdk', sdkDir.path); final AndroidSdk sdk = AndroidSdk.locateAndroidSdk(); - when(processManager.canRun(sdk.sdkManagerPath)).thenReturn(false); + when(globals.processManager.canRun(sdk.sdkManagerPath)).thenReturn(false); expect(() => sdk.sdkManagerVersion, throwsToolExit()); }, overrides: <Type, Generator>{ FileSystem: () => fs, @@ -138,11 +138,11 @@ testUsingContext('detection on $os', () { sdkDir = MockAndroidSdk.createSdkDirectory( withAndroidN: true, withNdkDir: osDir, withNdkSysroot: true); - Config.instance.setValue('android-sdk', sdkDir.path); + globals.config.setValue('android-sdk', sdkDir.path); final String realSdkDir = sdkDir.path; - final String realNdkDir = fs.path.join(realSdkDir, 'ndk-bundle'); - final String realNdkCompiler = fs.path.join( + final String realNdkDir = globals.fs.path.join(realSdkDir, 'ndk-bundle'); + final String realNdkCompiler = globals.fs.path.join( realNdkDir, 'toolchains', 'arm-linux-androideabi-4.9', @@ -151,7 +151,7 @@ 'bin', 'arm-linux-androideabi-gcc'); final String realNdkSysroot = - fs.path.join(realNdkDir, 'platforms', 'android-9', 'arch-arm'); + globals.fs.path.join(realNdkDir, 'platforms', 'android-9', 'arch-arm'); final AndroidSdk sdk = AndroidSdk.locateAndroidSdk(); expect(sdk.directory, realSdkDir); @@ -168,25 +168,25 @@ testUsingContext('newer NDK require explicit -fuse-ld on $os', () { sdkDir = MockAndroidSdk.createSdkDirectory( withAndroidN: true, withNdkDir: osDir, withNdkSysroot: true, ndkVersion: 18); - Config.instance.setValue('android-sdk', sdkDir.path); + globals.config.setValue('android-sdk', sdkDir.path); final String realSdkDir = sdkDir.path; - final String realNdkDir = fs.path.join(realSdkDir, 'ndk-bundle'); - final String realNdkToolchainBin = fs.path.join( + final String realNdkDir = globals.fs.path.join(realSdkDir, 'ndk-bundle'); + final String realNdkToolchainBin = globals.fs.path.join( realNdkDir, 'toolchains', 'arm-linux-androideabi-4.9', 'prebuilt', osDir, 'bin'); - final String realNdkCompiler = fs.path.join( + final String realNdkCompiler = globals.fs.path.join( realNdkToolchainBin, 'arm-linux-androideabi-gcc'); - final String realNdkLinker = fs.path.join( + final String realNdkLinker = globals.fs.path.join( realNdkToolchainBin, 'arm-linux-androideabi-ld'); final String realNdkSysroot = - fs.path.join(realNdkDir, 'platforms', 'android-9', 'arch-arm'); + globals.fs.path.join(realNdkDir, 'platforms', 'android-9', 'arch-arm'); final AndroidSdk sdk = AndroidSdk.locateAndroidSdk(); expect(sdk.directory, realSdkDir); @@ -204,7 +204,7 @@ for (String os in <String>['linux', 'macos']) { testUsingContext('detection on $os (no ndk available)', () { sdkDir = MockAndroidSdk.createSdkDirectory(withAndroidN: true); - Config.instance.setValue('android-sdk', sdkDir.path); + globals.config.setValue('android-sdk', sdkDir.path); final String realSdkDir = sdkDir.path; final AndroidSdk sdk = AndroidSdk.locateAndroidSdk(); @@ -230,8 +230,8 @@ bool withNdkSysroot = false, bool withSdkManager = true, }) { - final Directory dir = fs.systemTempDirectory.createTempSync('flutter_mock_android_sdk.'); - final String exe = platform.isWindows ? '.exe' : ''; + final Directory dir = globals.fs.systemTempDirectory.createTempSync('flutter_mock_android_sdk.'); + final String exe = globals.platform.isWindows ? '.exe' : ''; _createSdkFile(dir, 'licenses/dummy'); _createSdkFile(dir, 'platform-tools/adb$exe');
diff --git a/packages/flutter_tools/test/general.shard/android/android_studio_test.dart b/packages/flutter_tools/test/general.shard/android/android_studio_test.dart index e36dbce..7f39b2e 100644 --- a/packages/flutter_tools/test/general.shard/android/android_studio_test.dart +++ b/packages/flutter_tools/test/general.shard/android/android_studio_test.dart
@@ -5,9 +5,11 @@ import 'package:file/memory.dart'; import 'package:flutter_tools/src/android/android_studio.dart'; import 'package:flutter_tools/src/base/file_system.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/ios/plist_parser.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; + import 'package:mockito/mockito.dart'; +import 'package:platform/platform.dart'; import '../../src/common.dart'; import '../../src/context.dart'; @@ -55,12 +57,12 @@ const String installPath = '/opt/android-studio-with-cheese-5.0'; const String studioHome = '$homeLinux/.AndroidStudioWithCheese5.0'; const String homeFile = '$studioHome/system/.home'; - fs.directory(installPath).createSync(recursive: true); - fs.file(homeFile).createSync(recursive: true); - fs.file(homeFile).writeAsStringSync(installPath); + globals.fs.directory(installPath).createSync(recursive: true); + globals.fs.file(homeFile).createSync(recursive: true); + globals.fs.file(homeFile).writeAsStringSync(installPath); final AndroidStudio studio = - AndroidStudio.fromHomeDot(fs.directory(studioHome)); + AndroidStudio.fromHomeDot(globals.fs.directory(studioHome)); expect(studio, isNotNull); expect(studio.pluginsPath, equals('/home/me/.AndroidStudioWithCheese5.0/config/plugins')); @@ -75,15 +77,15 @@ group('pluginsPath on Mac', () { testUsingContext('extracts custom paths for directly downloaded Android Studio on Mac', () { - final String studioInApplicationPlistFolder = fs.path.join('/', 'Application', 'Android Studio.app', 'Contents'); - fs.directory(studioInApplicationPlistFolder).createSync(recursive: true); + final String studioInApplicationPlistFolder = globals.fs.path.join('/', 'Application', 'Android Studio.app', 'Contents'); + globals.fs.directory(studioInApplicationPlistFolder).createSync(recursive: true); - final String plistFilePath = fs.path.join(studioInApplicationPlistFolder, 'Info.plist'); + final String plistFilePath = globals.fs.path.join(studioInApplicationPlistFolder, 'Info.plist'); when(plistUtils.parseFile(plistFilePath)).thenReturn(macStudioInfoPlist); - final AndroidStudio studio = AndroidStudio.fromMacOSBundle(fs.directory(studioInApplicationPlistFolder)?.parent?.path); + final AndroidStudio studio = AndroidStudio.fromMacOSBundle(globals.fs.directory(studioInApplicationPlistFolder)?.parent?.path); expect(studio, isNotNull); expect(studio.pluginsPath, - equals(fs.path.join(homeMac, 'Library', 'Application Support', 'AndroidStudio3.3'))); + equals(globals.fs.path.join(homeMac, 'Library', 'Application Support', 'AndroidStudio3.3'))); }, overrides: <Type, Generator>{ FileSystem: () => fs, ProcessManager: () => FakeProcessManager.any(), @@ -94,26 +96,26 @@ }); testUsingContext('extracts custom paths for Android Studio downloaded by JetBrainsToolbox on Mac', () { - final String jetbrainsStudioInApplicationPlistFolder = fs.path.join(homeMac, 'Application', 'JetBrains Toolbox', 'Android Studio.app', 'Contents'); - fs.directory(jetbrainsStudioInApplicationPlistFolder).createSync(recursive: true); + final String jetbrainsStudioInApplicationPlistFolder = globals.fs.path.join(homeMac, 'Application', 'JetBrains Toolbox', 'Android Studio.app', 'Contents'); + globals.fs.directory(jetbrainsStudioInApplicationPlistFolder).createSync(recursive: true); const Map<String, dynamic> jetbrainsInfoPlist = <String, dynamic>{ 'CFBundleLongVersionString': '3.3', 'CFBundleShortVersionString': '3.3', 'CFBundleVersion': '3.3', 'JetBrainsToolboxApp': '$homeMac/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/183.5256920/Android Studio 3.3.app', }; - final String jetbrainsPlistFilePath = fs.path.join(jetbrainsStudioInApplicationPlistFolder, 'Info.plist'); + final String jetbrainsPlistFilePath = globals.fs.path.join(jetbrainsStudioInApplicationPlistFolder, 'Info.plist'); when(plistUtils.parseFile(jetbrainsPlistFilePath)).thenReturn(jetbrainsInfoPlist); - final String studioInApplicationPlistFolder = fs.path.join(fs.path.join(homeMac, 'Library', 'Application Support'), 'JetBrains', 'Toolbox', 'apps', 'AndroidStudio', 'ch-0', '183.5256920', fs.path.join('Android Studio 3.3.app', 'Contents')); - fs.directory(studioInApplicationPlistFolder).createSync(recursive: true); - final String studioPlistFilePath = fs.path.join(studioInApplicationPlistFolder, 'Info.plist'); + final String studioInApplicationPlistFolder = globals.fs.path.join(globals.fs.path.join(homeMac, 'Library', 'Application Support'), 'JetBrains', 'Toolbox', 'apps', 'AndroidStudio', 'ch-0', '183.5256920', globals.fs.path.join('Android Studio 3.3.app', 'Contents')); + globals.fs.directory(studioInApplicationPlistFolder).createSync(recursive: true); + final String studioPlistFilePath = globals.fs.path.join(studioInApplicationPlistFolder, 'Info.plist'); when(plistUtils.parseFile(studioPlistFilePath)).thenReturn(macStudioInfoPlist); - final AndroidStudio studio = AndroidStudio.fromMacOSBundle(fs.directory(jetbrainsStudioInApplicationPlistFolder)?.parent?.path); + final AndroidStudio studio = AndroidStudio.fromMacOSBundle(globals.fs.directory(jetbrainsStudioInApplicationPlistFolder)?.parent?.path); expect(studio, isNotNull); expect(studio.pluginsPath, - equals(fs.path.join(homeMac, 'Library', 'Application Support', 'AndroidStudio3.3'))); + equals(globals.fs.path.join(homeMac, 'Library', 'Application Support', 'AndroidStudio3.3'))); }, overrides: <Type, Generator>{ FileSystem: () => fs, ProcessManager: () => FakeProcessManager.any(),
diff --git a/packages/flutter_tools/test/general.shard/android/android_studio_validator_test.dart b/packages/flutter_tools/test/general.shard/android/android_studio_validator_test.dart index 89e4ecb..b56103a 100644 --- a/packages/flutter_tools/test/general.shard/android/android_studio_validator_test.dart +++ b/packages/flutter_tools/test/general.shard/android/android_studio_validator_test.dart
@@ -4,7 +4,7 @@ import 'package:flutter_tools/src/doctor.dart'; import 'package:flutter_tools/src/android/android_studio_validator.dart'; -import 'package:flutter_tools/src/base/platform.dart'; +import 'package:platform/platform.dart'; import '../../src/common.dart'; import '../../src/context.dart';
diff --git a/packages/flutter_tools/test/general.shard/android/android_workflow_test.dart b/packages/flutter_tools/test/general.shard/android/android_workflow_test.dart index 8945c1b..67db28c 100644 --- a/packages/flutter_tools/test/general.shard/android/android_workflow_test.dart +++ b/packages/flutter_tools/test/general.shard/android/android_workflow_test.dart
@@ -12,6 +12,8 @@ import 'package:flutter_tools/src/base/user_messages.dart'; import 'package:flutter_tools/src/base/version.dart'; import 'package:flutter_tools/src/doctor.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; + import 'package:mockito/mockito.dart'; import 'package:platform/platform.dart'; import 'package:process/process.dart'; @@ -291,7 +293,7 @@ //Test with older version of JDK const String javaVersionText = 'openjdk version "1.7.0_212"'; - when(processManager.run(argThat(contains('-version')))).thenAnswer((_) => + when(globals.processManager.run(argThat(contains('-version')))).thenAnswer((_) => Future<ProcessResult>.value(ProcessResult(0, 0, null, javaVersionText))); final String errorMessage = userMessages.androidJavaMinimumVersion(javaVersionText);
diff --git a/packages/flutter_tools/test/general.shard/android/gradle_errors_test.dart b/packages/flutter_tools/test/general.shard/android/gradle_errors_test.dart index 6735fea..0c7a01c 100644 --- a/packages/flutter_tools/test/general.shard/android/gradle_errors_test.dart +++ b/packages/flutter_tools/test/general.shard/android/gradle_errors_test.dart
@@ -8,9 +8,11 @@ import 'package:flutter_tools/src/base/context.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; -import 'package:flutter_tools/src/base/platform.dart'; + import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/reporting/reporting.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; + import 'package:mockito/mockito.dart'; import 'package:platform/platform.dart'; import 'package:process/process.dart'; @@ -284,7 +286,7 @@ }); testUsingContext('handler - plugins and no AndroidX', () async { - fs.file('.flutter-plugins').createSync(recursive: true); + globals.fs.file('.flutter-plugins').createSync(recursive: true); final GradleBuildStatus status = await androidXFailureHandler .handler( @@ -316,7 +318,7 @@ }); testUsingContext('handler - plugins, AndroidX, and AAR', () async { - fs.file('.flutter-plugins').createSync(recursive: true); + globals.fs.file('.flutter-plugins').createSync(recursive: true); final GradleBuildStatus status = await androidXFailureHandler.handler( line: '', @@ -342,7 +344,7 @@ }); testUsingContext('handler - plugins, AndroidX, and no AAR', () async { - fs.file('.flutter-plugins').createSync(recursive: true); + globals.fs.file('.flutter-plugins').createSync(recursive: true); final GradleBuildStatus status = await androidXFailureHandler.handler( line: '',
diff --git a/packages/flutter_tools/test/general.shard/android/gradle_test.dart b/packages/flutter_tools/test/general.shard/android/gradle_test.dart index 1c026bf..17cb651 100644 --- a/packages/flutter_tools/test/general.shard/android/gradle_test.dart +++ b/packages/flutter_tools/test/general.shard/android/gradle_test.dart
@@ -16,13 +16,13 @@ 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'; import 'package:flutter_tools/src/base/terminal.dart'; import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/ios/xcodeproj.dart'; import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/reporting/reporting.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import 'package:platform/platform.dart'; import 'package:process/process.dart'; @@ -41,11 +41,11 @@ final AndroidProject androidProject = MockAndroidProject(); when(project.android).thenReturn(androidProject); when(project.isModule).thenReturn(false); - when(androidProject.buildDirectory).thenReturn(fs.directory('foo')); + when(androidProject.buildDirectory).thenReturn(globals.fs.directory('foo')); expect( getApkDirectory(project).path, - equals(fs.path.join('foo', 'app', 'outputs', 'apk')), + equals(globals.fs.path.join('foo', 'app', 'outputs', 'apk')), ); }); @@ -54,11 +54,11 @@ final AndroidProject androidProject = MockAndroidProject(); when(project.android).thenReturn(androidProject); when(project.isModule).thenReturn(true); - when(androidProject.buildDirectory).thenReturn(fs.directory('foo')); + when(androidProject.buildDirectory).thenReturn(globals.fs.directory('foo')); expect( getApkDirectory(project).path, - equals(fs.path.join('foo', 'host', 'outputs', 'apk')), + equals(globals.fs.path.join('foo', 'host', 'outputs', 'apk')), ); }); @@ -67,11 +67,11 @@ final AndroidProject androidProject = MockAndroidProject(); when(project.android).thenReturn(androidProject); when(project.isModule).thenReturn(false); - when(androidProject.buildDirectory).thenReturn(fs.directory('foo')); + when(androidProject.buildDirectory).thenReturn(globals.fs.directory('foo')); expect( getBundleDirectory(project).path, - equals(fs.path.join('foo', 'app', 'outputs', 'bundle')), + equals(globals.fs.path.join('foo', 'app', 'outputs', 'bundle')), ); }); @@ -80,18 +80,18 @@ final AndroidProject androidProject = MockAndroidProject(); when(project.android).thenReturn(androidProject); when(project.isModule).thenReturn(true); - when(androidProject.buildDirectory).thenReturn(fs.directory('foo')); + when(androidProject.buildDirectory).thenReturn(globals.fs.directory('foo')); expect( getBundleDirectory(project).path, - equals(fs.path.join('foo', 'host', 'outputs', 'bundle')), + equals(globals.fs.path.join('foo', 'host', 'outputs', 'bundle')), ); }); test('getRepoDirectory', () { expect( - getRepoDirectory(fs.directory('foo')).path, - equals(fs.path.join('foo','outputs', 'repo')), + getRepoDirectory(globals.fs.directory('foo')).path, + equals(globals.fs.path.join('foo','outputs', 'repo')), ); }); }); @@ -138,7 +138,7 @@ final FlutterProject project = generateFakeAppBundle('foo_barRelease', 'app.aab'); final File bundle = findBundleFile(project, const BuildInfo(BuildMode.release, 'foo_bar')); expect(bundle, isNotNull); - expect(bundle.path, fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'foo_barRelease', 'app.aab')); + expect(bundle.path, globals.fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'foo_barRelease', 'app.aab')); }, overrides: <Type, Generator>{ FileSystem: () => MemoryFileSystem(), ProcessManager: () => FakeProcessManager.any(), @@ -148,7 +148,7 @@ final FlutterProject project = generateFakeAppBundle('fooRelease', 'app.aab'); final File bundle = findBundleFile(project, const BuildInfo(BuildMode.release, 'foo')); expect(bundle, isNotNull); - expect(bundle.path, fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'fooRelease', 'app.aab')); + expect(bundle.path, globals.fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'fooRelease', 'app.aab')); }, overrides: <Type, Generator>{ FileSystem: () => MemoryFileSystem(), ProcessManager: () => FakeProcessManager.any(), @@ -158,7 +158,7 @@ final FlutterProject project = generateFakeAppBundle('release', 'app.aab'); final File bundle = findBundleFile(project, const BuildInfo(BuildMode.release, null)); expect(bundle, isNotNull); - expect(bundle.path, fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'release', 'app.aab')); + expect(bundle.path, globals.fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'release', 'app.aab')); }, overrides: <Type, Generator>{ FileSystem: () => MemoryFileSystem(), ProcessManager: () => FakeProcessManager.any(), @@ -168,7 +168,7 @@ final FlutterProject project = generateFakeAppBundle('foo_barDebug', 'app.aab'); final File bundle = findBundleFile(project, const BuildInfo(BuildMode.debug, 'foo_bar')); expect(bundle, isNotNull); - expect(bundle.path, fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'foo_barDebug', 'app.aab')); + expect(bundle.path, globals.fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'foo_barDebug', 'app.aab')); }, overrides: <Type, Generator>{ FileSystem: () => MemoryFileSystem(), ProcessManager: () => FakeProcessManager.any(), @@ -178,7 +178,7 @@ final FlutterProject project = generateFakeAppBundle('fooDebug', 'app.aab'); final File bundle = findBundleFile(project, const BuildInfo(BuildMode.debug, 'foo')); expect(bundle, isNotNull); - expect(bundle.path, fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'fooDebug', 'app.aab')); + expect(bundle.path, globals.fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'fooDebug', 'app.aab')); }, overrides: <Type, Generator>{ FileSystem: () => MemoryFileSystem(), ProcessManager: () => FakeProcessManager.any(), @@ -188,7 +188,7 @@ final FlutterProject project = generateFakeAppBundle('debug', 'app.aab'); final File bundle = findBundleFile(project, const BuildInfo(BuildMode.debug, null)); expect(bundle, isNotNull); - expect(bundle.path, fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'debug', 'app.aab')); + expect(bundle.path, globals.fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'debug', 'app.aab')); }, overrides: <Type, Generator>{ FileSystem: () => MemoryFileSystem(), ProcessManager: () => FakeProcessManager.any(), @@ -198,7 +198,7 @@ final FlutterProject project = generateFakeAppBundle('foo_barProfile', 'app.aab'); final File bundle = findBundleFile(project, const BuildInfo(BuildMode.profile, 'foo_bar')); expect(bundle, isNotNull); - expect(bundle.path, fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'foo_barProfile', 'app.aab')); + expect(bundle.path, globals.fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'foo_barProfile', 'app.aab')); }, overrides: <Type, Generator>{ FileSystem: () => MemoryFileSystem(), ProcessManager: () => FakeProcessManager.any(), @@ -208,7 +208,7 @@ final FlutterProject project = generateFakeAppBundle('fooProfile', 'app.aab'); final File bundle = findBundleFile(project, const BuildInfo(BuildMode.profile, 'foo')); expect(bundle, isNotNull); - expect(bundle.path, fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'fooProfile', 'app.aab')); + expect(bundle.path, globals.fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'fooProfile', 'app.aab')); }, overrides: <Type, Generator>{ FileSystem: () => MemoryFileSystem(), ProcessManager: () => FakeProcessManager.any(), @@ -218,7 +218,7 @@ final FlutterProject project = generateFakeAppBundle('profile', 'app.aab'); final File bundle = findBundleFile(project, const BuildInfo(BuildMode.profile, null)); expect(bundle, isNotNull); - expect(bundle.path, fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'profile', 'app.aab')); + expect(bundle.path, globals.fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'profile', 'app.aab')); }, overrides: <Type, Generator>{ FileSystem: () => MemoryFileSystem(), ProcessManager: () => FakeProcessManager.any(), @@ -228,7 +228,7 @@ final FlutterProject project = generateFakeAppBundle('release', 'app-release.aab'); final File bundle = findBundleFile(project, const BuildInfo(BuildMode.release, null)); expect(bundle, isNotNull); - expect(bundle.path, fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'release', 'app-release.aab')); + expect(bundle.path, globals.fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'release', 'app-release.aab')); }, overrides: <Type, Generator>{ FileSystem: () => MemoryFileSystem(), ProcessManager: () => FakeProcessManager.any(), @@ -238,7 +238,7 @@ final FlutterProject project = generateFakeAppBundle('profile', 'app-profile.aab'); final File bundle = findBundleFile(project, const BuildInfo(BuildMode.profile, null)); expect(bundle, isNotNull); - expect(bundle.path, fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'profile', 'app-profile.aab')); + expect(bundle.path, globals.fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'profile', 'app-profile.aab')); }, overrides: <Type, Generator>{ FileSystem: () => MemoryFileSystem(), ProcessManager: () => FakeProcessManager.any(), @@ -248,7 +248,7 @@ final FlutterProject project = generateFakeAppBundle('debug', 'app-debug.aab'); final File bundle = findBundleFile(project, const BuildInfo(BuildMode.debug, null)); expect(bundle, isNotNull); - expect(bundle.path, fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'debug', 'app-debug.aab')); + expect(bundle.path, globals.fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'debug', 'app-debug.aab')); }, overrides: <Type, Generator>{ FileSystem: () => MemoryFileSystem(), ProcessManager: () => FakeProcessManager.any(), @@ -258,7 +258,7 @@ final FlutterProject project = generateFakeAppBundle('foo_barRelease', 'app-foo_bar-release.aab'); final File bundle = findBundleFile(project, const BuildInfo(BuildMode.release, 'foo_bar')); expect(bundle, isNotNull); - expect(bundle.path, fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'foo_barRelease', 'app-foo_bar-release.aab')); + expect(bundle.path, globals.fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'foo_barRelease', 'app-foo_bar-release.aab')); }, overrides: <Type, Generator>{ FileSystem: () => MemoryFileSystem(), ProcessManager: () => FakeProcessManager.any(), @@ -268,7 +268,7 @@ final FlutterProject project = generateFakeAppBundle('foo_barProfile', 'app-foo_bar-profile.aab'); final File bundle = findBundleFile(project, const BuildInfo(BuildMode.profile, 'foo_bar')); expect(bundle, isNotNull); - expect(bundle.path, fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'foo_barProfile', 'app-foo_bar-profile.aab')); + expect(bundle.path, globals.fs.path.join('irrelevant', 'app', 'outputs', 'bundle', 'foo_barProfile', 'app-foo_bar-profile.aab')); }, overrides: <Type, Generator>{ FileSystem: () => MemoryFileSystem(), ProcessManager: () => FakeProcessManager.any(), @@ -278,7 +278,7 @@ final FlutterProject project = generateFakeAppBundle('foo_barDebug', 'app-foo_bar-debug.aab'); final File bundle = findBundleFile(project, const BuildInfo(BuildMode.debug, 'foo_bar')); expect(bundle, isNotNull); - expect(bundle.path, fs.path.join('irrelevant','app', 'outputs', 'bundle', 'foo_barDebug', 'app-foo_bar-debug.aab')); + expect(bundle.path, globals.fs.path.join('irrelevant','app', 'outputs', 'bundle', 'foo_barDebug', 'app-foo_bar-debug.aab')); }, overrides: <Type, Generator>{ FileSystem: () => MemoryFileSystem(), ProcessManager: () => FakeProcessManager.any(), @@ -322,9 +322,9 @@ when(project.android).thenReturn(androidProject); when(project.isModule).thenReturn(false); - when(androidProject.buildDirectory).thenReturn(fs.directory('irrelevant')); + when(androidProject.buildDirectory).thenReturn(globals.fs.directory('irrelevant')); - final Directory apkDirectory = fs.directory(fs.path.join('irrelevant', 'app', 'outputs', 'apk', 'release')); + final Directory apkDirectory = globals.fs.directory(globals.fs.path.join('irrelevant', 'app', 'outputs', 'apk', 'release')); apkDirectory.createSync(recursive: true); apkDirectory.childFile('app-release.apk').createSync(); @@ -333,7 +333,7 @@ const AndroidBuildInfo(BuildInfo(BuildMode.release, '')), ); expect(apks.isNotEmpty, isTrue); - expect(apks.first.path, equals(fs.path.join('irrelevant', 'app', 'outputs', 'apk', 'release', 'app-release.apk'))); + expect(apks.first.path, equals(globals.fs.path.join('irrelevant', 'app', 'outputs', 'apk', 'release', 'app-release.apk'))); }, overrides: <Type, Generator>{ FileSystem: () => MemoryFileSystem(), ProcessManager: () => FakeProcessManager.any(), @@ -345,9 +345,9 @@ when(project.android).thenReturn(androidProject); when(project.isModule).thenReturn(false); - when(androidProject.buildDirectory).thenReturn(fs.directory('irrelevant')); + when(androidProject.buildDirectory).thenReturn(globals.fs.directory('irrelevant')); - final Directory apkDirectory = fs.directory(fs.path.join('irrelevant', 'app', 'outputs', 'apk', 'release')); + final Directory apkDirectory = globals.fs.directory(globals.fs.path.join('irrelevant', 'app', 'outputs', 'apk', 'release')); apkDirectory.createSync(recursive: true); apkDirectory.childFile('app-flavor1-release.apk').createSync(); @@ -356,7 +356,7 @@ const AndroidBuildInfo(BuildInfo(BuildMode.release, 'flavor1')), ); expect(apks.isNotEmpty, isTrue); - expect(apks.first.path, equals(fs.path.join('irrelevant', 'app', 'outputs', 'apk', 'release', 'app-flavor1-release.apk'))); + expect(apks.first.path, equals(globals.fs.path.join('irrelevant', 'app', 'outputs', 'apk', 'release', 'app-flavor1-release.apk'))); }, overrides: <Type, Generator>{ FileSystem: () => MemoryFileSystem(), ProcessManager: () => FakeProcessManager.any(), @@ -368,9 +368,9 @@ when(project.android).thenReturn(androidProject); when(project.isModule).thenReturn(false); - when(androidProject.buildDirectory).thenReturn(fs.directory('irrelevant')); + when(androidProject.buildDirectory).thenReturn(globals.fs.directory('irrelevant')); - final Directory apkDirectory = fs.directory(fs.path.join('irrelevant', 'app', 'outputs', 'apk', 'flavor1', 'release')); + final Directory apkDirectory = globals.fs.directory(globals.fs.path.join('irrelevant', 'app', 'outputs', 'apk', 'flavor1', 'release')); apkDirectory.createSync(recursive: true); apkDirectory.childFile('app-flavor1-release.apk').createSync(); @@ -379,7 +379,7 @@ const AndroidBuildInfo(BuildInfo(BuildMode.release, 'flavor1')), ); expect(apks.isNotEmpty, isTrue); - expect(apks.first.path, equals(fs.path.join('irrelevant', 'app', 'outputs', 'apk', 'flavor1', 'release', 'app-flavor1-release.apk'))); + expect(apks.first.path, equals(globals.fs.path.join('irrelevant', 'app', 'outputs', 'apk', 'flavor1', 'release', 'app-flavor1-release.apk'))); }, overrides: <Type, Generator>{ FileSystem: () => MemoryFileSystem(), ProcessManager: () => FakeProcessManager.any(), @@ -456,7 +456,7 @@ setUp(() { mockLogger = BufferLogger(); - tempDir = fs.systemTempDirectory.createTempSync('flutter_settings_aar_test.'); + tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_settings_aar_test.'); }); testUsingContext('create settings_aar.gradle when current settings.gradle loads plugins', () { @@ -484,16 +484,16 @@ tempDir.childFile('settings.gradle').writeAsStringSync(currentSettingsGradle); - final String toolGradlePath = fs.path.join( - fs.path.absolute(Cache.flutterRoot), + final String toolGradlePath = globals.fs.path.join( + globals.fs.path.absolute(Cache.flutterRoot), 'packages', 'flutter_tools', 'gradle'); - fs.directory(toolGradlePath).createSync(recursive: true); - fs.file(fs.path.join(toolGradlePath, 'deprecated_settings.gradle')) + globals.fs.directory(toolGradlePath).createSync(recursive: true); + globals.fs.file(globals.fs.path.join(toolGradlePath, 'deprecated_settings.gradle')) .writeAsStringSync(currentSettingsGradle); - fs.file(fs.path.join(toolGradlePath, 'settings_aar.gradle.tmpl')) + globals.fs.file(globals.fs.path.join(toolGradlePath, 'settings_aar.gradle.tmpl')) .writeAsStringSync(settingsAarFile); createSettingsAarGradle(tempDir); @@ -518,16 +518,16 @@ tempDir.childFile('settings.gradle').writeAsStringSync(currentSettingsGradle); - final String toolGradlePath = fs.path.join( - fs.path.absolute(Cache.flutterRoot), + final String toolGradlePath = globals.fs.path.join( + globals.fs.path.absolute(Cache.flutterRoot), 'packages', 'flutter_tools', 'gradle'); - fs.directory(toolGradlePath).createSync(recursive: true); - fs.file(fs.path.join(toolGradlePath, 'deprecated_settings.gradle')) + globals.fs.directory(toolGradlePath).createSync(recursive: true); + globals.fs.file(globals.fs.path.join(toolGradlePath, 'deprecated_settings.gradle')) .writeAsStringSync(currentSettingsGradle); - fs.file(fs.path.join(toolGradlePath, 'settings_aar.gradle.tmpl')) + globals.fs.file(globals.fs.path.join(toolGradlePath, 'settings_aar.gradle.tmpl')) .writeAsStringSync(settingsAarFile); createSettingsAarGradle(tempDir); @@ -579,9 +579,9 @@ }) async { when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, platform: TargetPlatform.android_arm, mode: anyNamed('mode'))).thenReturn('engine'); - when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'android_arm')); + when(mockArtifacts.engineOutPath).thenReturn(globals.fs.path.join('out', 'android_arm')); - final File manifestFile = fs.file('path/to/project/pubspec.yaml'); + final File manifestFile = globals.fs.file('path/to/project/pubspec.yaml'); manifestFile.createSync(recursive: true); manifestFile.writeAsStringSync(manifest); @@ -594,7 +594,7 @@ requireAndroidSdk: false, ); - final File localPropertiesFile = fs.file('path/to/project/android/local.properties'); + final File localPropertiesFile = globals.fs.file('path/to/project/android/local.properties'); expect(propertyFor('flutter.versionName', localPropertiesFile), expectedBuildName); expect(propertyFor('flutter.versionCode', localPropertiesFile), expectedBuildNumber); } @@ -822,7 +822,7 @@ }); testUsingContext('returns true when the project is using AndroidX', () async { - final Directory androidDirectory = fs.systemTempDirectory.createTempSync('flutter_android.'); + final Directory androidDirectory = globals.fs.systemTempDirectory.createTempSync('flutter_android.'); androidDirectory .childFile('gradle.properties') @@ -836,7 +836,7 @@ }); testUsingContext('returns false when the project is not using AndroidX', () async { - final Directory androidDirectory = fs.systemTempDirectory.createTempSync('flutter_android.'); + final Directory androidDirectory = globals.fs.systemTempDirectory.createTempSync('flutter_android.'); androidDirectory .childFile('gradle.properties') @@ -850,7 +850,7 @@ }); testUsingContext('returns false when gradle.properties does not exist', () async { - final Directory androidDirectory = fs.systemTempDirectory.createTempSync('flutter_android.'); + final Directory androidDirectory = globals.fs.systemTempDirectory.createTempSync('flutter_android.'); expect(isAppUsingAndroidX(androidDirectory), isFalse); @@ -880,13 +880,13 @@ }); testUsingContext('calls gradle', () async { - final Directory androidDirectory = fs.directory('android.'); + final Directory androidDirectory = globals.fs.directory('android.'); androidDirectory.createSync(); androidDirectory .childFile('pubspec.yaml') .writeAsStringSync('name: irrelevant'); - final Directory plugin1 = fs.directory('plugin1.'); + final Directory plugin1 = globals.fs.directory('plugin1.'); plugin1 ..createSync() ..childFile('pubspec.yaml') @@ -902,7 +902,7 @@ .childFile('build.gradle') .createSync(recursive: true); - final Directory plugin2 = fs.directory('plugin2.'); + final Directory plugin2 = globals.fs.directory('plugin2.'); plugin2 ..createSync() ..childFile('pubspec.yaml') @@ -937,8 +937,8 @@ buildDirectory: buildDirectory, ); - final String flutterRoot = fs.path.absolute(Cache.flutterRoot); - final String initScript = fs.path.join( + final String flutterRoot = globals.fs.path.absolute(Cache.flutterRoot); + final String initScript = globals.fs.path.join( flutterRoot, 'packages', 'flutter_tools', @@ -983,13 +983,13 @@ }); testUsingContext('skips plugin without a android/build.gradle file', () async { - final Directory androidDirectory = fs.directory('android.'); + final Directory androidDirectory = globals.fs.directory('android.'); androidDirectory.createSync(); androidDirectory .childFile('pubspec.yaml') .writeAsStringSync('name: irrelevant'); - final Directory plugin1 = fs.directory('plugin1.'); + final Directory plugin1 = globals.fs.directory('plugin1.'); plugin1 ..createSync() ..childFile('pubspec.yaml') @@ -1022,8 +1022,8 @@ buildDirectory: buildDirectory, ); - final String flutterRoot = fs.path.absolute(Cache.flutterRoot); - final String initScript = fs.path.join( + final String flutterRoot = globals.fs.path.absolute(Cache.flutterRoot); + final String initScript = globals.fs.path.join( flutterRoot, 'packages', 'flutter_tools', @@ -1103,15 +1103,15 @@ environment: anyNamed('environment'))) .thenAnswer((_) => Future<Process>.value(process)); - fs.directory('android') + globals.fs.directory('android') .childFile('build.gradle') .createSync(recursive: true); - fs.directory('android') + globals.fs.directory('android') .childFile('gradle.properties') .createSync(recursive: true); - fs.directory('android') + globals.fs.directory('android') .childDirectory('app') .childFile('build.gradle') ..createSync(recursive: true) @@ -1182,15 +1182,15 @@ return Future<Process>.value(process); }); - fs.directory('android') + globals.fs.directory('android') .childFile('build.gradle') .createSync(recursive: true); - fs.directory('android') + globals.fs.directory('android') .childFile('gradle.properties') .createSync(recursive: true); - fs.directory('android') + globals.fs.directory('android') .childDirectory('app') .childFile('build.gradle') ..createSync(recursive: true) @@ -1257,15 +1257,15 @@ environment: anyNamed('environment'))) .thenThrow(const ProcessException('', <String>[], 'Some gradle message')); - fs.directory('android') + globals.fs.directory('android') .childFile('build.gradle') .createSync(recursive: true); - fs.directory('android') + globals.fs.directory('android') .childFile('gradle.properties') .createSync(recursive: true); - fs.directory('android') + globals.fs.directory('android') .childDirectory('app') .childFile('build.gradle') ..createSync(recursive: true) @@ -1330,15 +1330,15 @@ environment: anyNamed('environment'))) .thenThrow(const ProcessException('', <String>[], 'Unrecognized')); - fs.directory('android') + globals.fs.directory('android') .childFile('build.gradle') .createSync(recursive: true); - fs.directory('android') + globals.fs.directory('android') .childFile('gradle.properties') .createSync(recursive: true); - fs.directory('android') + globals.fs.directory('android') .childDirectory('app') .childFile('build.gradle') ..createSync(recursive: true) @@ -1390,21 +1390,21 @@ return Future<Process>.value(process); }); - fs.directory('android') + globals.fs.directory('android') .childFile('build.gradle') .createSync(recursive: true); - fs.directory('android') + globals.fs.directory('android') .childFile('gradle.properties') .createSync(recursive: true); - fs.directory('android') + globals.fs.directory('android') .childDirectory('app') .childFile('build.gradle') ..createSync(recursive: true) ..writeAsStringSync('apply from: irrelevant/flutter.gradle'); - fs.directory('build') + globals.fs.directory('build') .childDirectory('app') .childDirectory('outputs') .childDirectory('apk') @@ -1468,15 +1468,15 @@ return Future<Process>.value(process); }); - fs.directory('android') + globals.fs.directory('android') .childFile('build.gradle') .createSync(recursive: true); - fs.directory('android') + globals.fs.directory('android') .childFile('gradle.properties') .createSync(recursive: true); - fs.directory('android') + globals.fs.directory('android') .childDirectory('app') .childFile('build.gradle') ..createSync(recursive: true) @@ -1554,21 +1554,21 @@ )); }); - fs.directory('android') + globals.fs.directory('android') .childFile('build.gradle') .createSync(recursive: true); - fs.directory('android') + globals.fs.directory('android') .childFile('gradle.properties') .createSync(recursive: true); - fs.directory('android') + globals.fs.directory('android') .childDirectory('app') .childFile('build.gradle') ..createSync(recursive: true) ..writeAsStringSync('apply from: irrelevant/flutter.gradle'); - fs.directory('build') + globals.fs.directory('build') .childDirectory('app') .childDirectory('outputs') .childDirectory('apk') @@ -1603,7 +1603,7 @@ }); testUsingContext('doesn\'t indicate how to consume an AAR when printHowToConsumeAaar is false', () async { - final File manifestFile = fs.file('pubspec.yaml'); + final File manifestFile = globals.fs.file('pubspec.yaml'); manifestFile.createSync(recursive: true); manifestFile.writeAsStringSync(''' flutter: @@ -1612,12 +1612,12 @@ ''' ); - fs.file('.android/gradlew').createSync(recursive: true); + globals.fs.file('.android/gradlew').createSync(recursive: true); - fs.file('.android/gradle.properties') + globals.fs.file('.android/gradle.properties') .writeAsStringSync('irrelevant'); - fs.file('.android/build.gradle') + globals.fs.file('.android/build.gradle') .createSync(recursive: true); // Let any process start. Assert after. @@ -1627,12 +1627,12 @@ workingDirectory: anyNamed('workingDirectory'), )).thenAnswer((_) async => ProcessResult(1, 0, '', '')); - fs.directory('build/outputs/repo').createSync(recursive: true); + globals.fs.directory('build/outputs/repo').createSync(recursive: true); await buildGradleAar( androidBuildInfo: const AndroidBuildInfo(BuildInfo(BuildMode.release, null)), project: FlutterProject.current(), - outputDirectory: fs.directory('build/'), + outputDirectory: globals.fs.directory('build/'), target: '', buildNumber: '1.0', ); @@ -1658,9 +1658,9 @@ testUsingContext('build apk uses selected local engine', () async { when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, platform: TargetPlatform.android_arm, mode: anyNamed('mode'))).thenReturn('engine'); - when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'android_arm')); + when(mockArtifacts.engineOutPath).thenReturn(globals.fs.path.join('out', 'android_arm')); - fs.file('out/android_arm/flutter_embedding_release.pom') + globals.fs.file('out/android_arm/flutter_embedding_release.pom') ..createSync(recursive: true) ..writeAsStringSync( '''<?xml version="1.0" encoding="UTF-8"?> @@ -1670,21 +1670,21 @@ </dependencies> </project> '''); - fs.file('out/android_arm/armeabi_v7a_release.pom').createSync(recursive: true); - fs.file('out/android_arm/armeabi_v7a_release.jar').createSync(recursive: true); - fs.file('out/android_arm/flutter_embedding_release.jar').createSync(recursive: true); - fs.file('out/android_arm/flutter_embedding_release.pom').createSync(recursive: true); + globals.fs.file('out/android_arm/armeabi_v7a_release.pom').createSync(recursive: true); + globals.fs.file('out/android_arm/armeabi_v7a_release.jar').createSync(recursive: true); + globals.fs.file('out/android_arm/flutter_embedding_release.jar').createSync(recursive: true); + globals.fs.file('out/android_arm/flutter_embedding_release.pom').createSync(recursive: true); - fs.file('android/gradlew').createSync(recursive: true); + globals.fs.file('android/gradlew').createSync(recursive: true); - fs.directory('android') + globals.fs.directory('android') .childFile('gradle.properties') .createSync(recursive: true); - fs.file('android/build.gradle') + globals.fs.file('android/build.gradle') .createSync(recursive: true); - fs.directory('android') + globals.fs.directory('android') .childDirectory('app') .childFile('build.gradle') ..createSync(recursive: true) @@ -1749,9 +1749,9 @@ testUsingContext('build aar uses selected local engine', () async { when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, platform: TargetPlatform.android_arm, mode: anyNamed('mode'))).thenReturn('engine'); - when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'android_arm')); + when(mockArtifacts.engineOutPath).thenReturn(globals.fs.path.join('out', 'android_arm')); - fs.file('out/android_arm/flutter_embedding_release.pom') + globals.fs.file('out/android_arm/flutter_embedding_release.pom') ..createSync(recursive: true) ..writeAsStringSync( '''<?xml version="1.0" encoding="UTF-8"?> @@ -1761,12 +1761,12 @@ </dependencies> </project> '''); - fs.file('out/android_arm/armeabi_v7a_release.pom').createSync(recursive: true); - fs.file('out/android_arm/armeabi_v7a_release.jar').createSync(recursive: true); - fs.file('out/android_arm/flutter_embedding_release.jar').createSync(recursive: true); - fs.file('out/android_arm/flutter_embedding_release.pom').createSync(recursive: true); + globals.fs.file('out/android_arm/armeabi_v7a_release.pom').createSync(recursive: true); + globals.fs.file('out/android_arm/armeabi_v7a_release.jar').createSync(recursive: true); + globals.fs.file('out/android_arm/flutter_embedding_release.jar').createSync(recursive: true); + globals.fs.file('out/android_arm/flutter_embedding_release.pom').createSync(recursive: true); - final File manifestFile = fs.file('pubspec.yaml'); + final File manifestFile = globals.fs.file('pubspec.yaml'); manifestFile.createSync(recursive: true); manifestFile.writeAsStringSync(''' flutter: @@ -1775,12 +1775,12 @@ ''' ); - fs.file('.android/gradlew').createSync(recursive: true); + globals.fs.file('.android/gradlew').createSync(recursive: true); - fs.file('.android/gradle.properties') + globals.fs.file('.android/gradle.properties') .writeAsStringSync('irrelevant'); - fs.file('.android/build.gradle') + globals.fs.file('.android/build.gradle') .createSync(recursive: true); // Let any process start. Assert after. @@ -1790,12 +1790,12 @@ workingDirectory: anyNamed('workingDirectory'), )).thenAnswer((_) async => ProcessResult(1, 0, '', '')); - fs.directory('build/outputs/repo').createSync(recursive: true); + globals.fs.directory('build/outputs/repo').createSync(recursive: true); await buildGradleAar( androidBuildInfo: const AndroidBuildInfo(BuildInfo(BuildMode.release, null)), project: FlutterProject.current(), - outputDirectory: fs.directory('build/'), + outputDirectory: globals.fs.directory('build/'), target: '', buildNumber: '2.0', ); @@ -1830,7 +1830,7 @@ printHowToConsumeAar( buildModes: const <String>{'release', 'debug', 'profile'}, androidPackage: 'com.mycompany', - repoDirectory: fs.directory('build/'), + repoDirectory: globals.fs.directory('build/'), buildNumber: '2.2', ); @@ -1883,7 +1883,7 @@ printHowToConsumeAar( buildModes: const <String>{'release'}, androidPackage: 'com.mycompany', - repoDirectory: fs.directory('build/'), + repoDirectory: globals.fs.directory('build/'), ); expect( @@ -1922,7 +1922,7 @@ printHowToConsumeAar( buildModes: const <String>{'debug'}, androidPackage: 'com.mycompany', - repoDirectory: fs.directory('build/'), + repoDirectory: globals.fs.directory('build/'), ); expect( @@ -1961,7 +1961,7 @@ printHowToConsumeAar( buildModes: const <String>{'profile'}, androidPackage: 'com.mycompany', - repoDirectory: fs.directory('build/'), + repoDirectory: globals.fs.directory('build/'), buildNumber: '1.0', ); @@ -2017,7 +2017,7 @@ when(project.isModule).thenReturn(false); when(project.android).thenReturn(androidProject); - when(androidProject.buildDirectory).thenReturn(fs.directory('irrelevant')); + when(androidProject.buildDirectory).thenReturn(globals.fs.directory('irrelevant')); final Directory bundleDirectory = getBundleDirectory(project); bundleDirectory
diff --git a/packages/flutter_tools/test/general.shard/android/gradle_utils_test.dart b/packages/flutter_tools/test/general.shard/android/gradle_utils_test.dart index d0cca2a..f405124 100644 --- a/packages/flutter_tools/test/general.shard/android/gradle_utils_test.dart +++ b/packages/flutter_tools/test/general.shard/android/gradle_utils_test.dart
@@ -6,9 +6,9 @@ import 'package:flutter_tools/src/android/gradle_utils.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/os.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/project.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; @@ -42,7 +42,7 @@ }); testUsingContext('injects the wrapper when all files are missing', () { - final Directory sampleAppAndroid = fs.directory('/sample-app/android'); + final Directory sampleAppAndroid = globals.fs.directory('/sample-app/android'); sampleAppAndroid.createSync(recursive: true); gradleUtils.injectGradleWrapperIfNeeded(sampleAppAndroid); @@ -78,7 +78,7 @@ }); testUsingContext('injects the wrapper when some files are missing', () { - final Directory sampleAppAndroid = fs.directory('/sample-app/android'); + final Directory sampleAppAndroid = globals.fs.directory('/sample-app/android'); sampleAppAndroid.createSync(recursive: true); // There's an existing gradlew @@ -128,7 +128,7 @@ }); testUsingContext('throws ToolExit if gradle.properties doesn\'t exist', () { - final Directory sampleAppAndroid = fs.directory('/sample-app/android'); + final Directory sampleAppAndroid = globals.fs.directory('/sample-app/android'); sampleAppAndroid.createSync(recursive: true); expect(() { @@ -162,7 +162,7 @@ }); testUsingContext('does not update gradle.properties if it already uses R8', () { - final Directory sampleAppAndroid = fs.directory('/sample-app/android'); + final Directory sampleAppAndroid = globals.fs.directory('/sample-app/android'); sampleAppAndroid.createSync(recursive: true); sampleAppAndroid.childFile('gradle.properties') .writeAsStringSync('android.enableR8=true'); @@ -179,7 +179,7 @@ }); testUsingContext('sets android.enableR8=true', () { - final Directory sampleAppAndroid = fs.directory('/sample-app/android'); + final Directory sampleAppAndroid = globals.fs.directory('/sample-app/android'); sampleAppAndroid.createSync(recursive: true); sampleAppAndroid.childFile('gradle.properties') .writeAsStringSync('org.gradle.jvmargs=-Xmx1536M\n'); @@ -200,7 +200,7 @@ }); testUsingContext('appends android.enableR8=true to the new line', () { - final Directory sampleAppAndroid = fs.directory('/sample-app/android'); + final Directory sampleAppAndroid = globals.fs.directory('/sample-app/android'); sampleAppAndroid.createSync(recursive: true); sampleAppAndroid.childFile('gradle.properties') .writeAsStringSync('org.gradle.jvmargs=-Xmx1536M'); @@ -222,7 +222,7 @@ }); group('GradleUtils.getExecutable', () { - final String gradlewFilename = platform.isWindows ? 'gradlew.bat' : 'gradlew'; + final String gradlewFilename = globals.platform.isWindows ? 'gradlew.bat' : 'gradlew'; MemoryFileSystem memoryFileSystem; OperatingSystemUtils operatingSystemUtils; @@ -235,7 +235,7 @@ }); testUsingContext('returns the gradlew path', () { - final Directory androidDirectory = fs.directory('/android')..createSync(); + final Directory androidDirectory = globals.fs.directory('/android')..createSync(); androidDirectory.childFile('gradlew')..createSync(); androidDirectory.childFile('gradlew.bat')..createSync(); androidDirectory.childFile('gradle.properties').createSync();
diff --git a/packages/flutter_tools/test/general.shard/application_package_test.dart b/packages/flutter_tools/test/general.shard/application_package_test.dart index d049188..cfa21ee 100644 --- a/packages/flutter_tools/test/general.shard/application_package_test.dart +++ b/packages/flutter_tools/test/general.shard/application_package_test.dart
@@ -12,14 +12,15 @@ import 'package:flutter_tools/src/base/context.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/os.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/fuchsia/application_package.dart'; import 'package:flutter_tools/src/ios/plist_parser.dart'; import 'package:flutter_tools/src/project.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; +import 'package:platform/platform.dart'; import '../src/common.dart'; import '../src/context.dart'; @@ -62,14 +63,14 @@ )).thenAnswer((_) async => ProcessResult(1, 0, 'stdout', 'stderr')); when(mockProcessManager.runSync(any)).thenReturn(ProcessResult(1, 0, 'stdout', 'stderr')); final FlutterProject project = FlutterProject.current(); - gradle = fs.file(project.android.hostAppGradleRoot.childFile( - platform.isWindows ? 'gradlew.bat' : 'gradlew', + gradle = globals.fs.file(project.android.hostAppGradleRoot.childFile( + globals.platform.isWindows ? 'gradlew.bat' : 'gradlew', ).path)..createSync(recursive: true); }); testUsingContext('Licenses not available, platform and buildtools available, apk exists', () async { const String aaptPath = 'aaptPath'; - final File apkFile = fs.file('app.apk'); + final File apkFile = globals.fs.file('app.apk'); final AndroidSdkVersion sdkVersion = MockitoAndroidSdkVersion(); when(sdkVersion.aaptPath).thenReturn(aaptPath); when(sdk.latestVersion).thenReturn(sdkVersion); @@ -99,24 +100,24 @@ when(sdk.latestVersion).thenReturn(null); final FlutterProject project = FlutterProject.current(); final File gradle = project.android.hostAppGradleRoot.childFile( - platform.isWindows ? 'gradlew.bat' : 'gradlew', + globals.platform.isWindows ? 'gradlew.bat' : 'gradlew', )..createSync(recursive: true); project.android.hostAppGradleRoot .childFile('gradle.properties') .writeAsStringSync('irrelevant'); - final Directory gradleWrapperDir = fs.systemTempDirectory.createTempSync('flutter_application_package_test_gradle_wrapper.'); + final Directory gradleWrapperDir = globals.fs.systemTempDirectory.createTempSync('flutter_application_package_test_gradle_wrapper.'); when(mockCache.getArtifactDirectory('gradle_wrapper')).thenReturn(gradleWrapperDir); - fs.directory(gradleWrapperDir.childDirectory('gradle').childDirectory('wrapper')) + globals.fs.directory(gradleWrapperDir.childDirectory('gradle').childDirectory('wrapper')) .createSync(recursive: true); - fs.file(fs.path.join(gradleWrapperDir.path, 'gradlew')).writeAsStringSync('irrelevant'); - fs.file(fs.path.join(gradleWrapperDir.path, 'gradlew.bat')).writeAsStringSync('irrelevant'); + globals.fs.file(globals.fs.path.join(gradleWrapperDir.path, 'gradlew')).writeAsStringSync('irrelevant'); + globals.fs.file(globals.fs.path.join(gradleWrapperDir.path, 'gradlew.bat')).writeAsStringSync('irrelevant'); await ApplicationPackageFactory.instance.getPackageForPlatform( TargetPlatform.android_arm, - applicationBinary: fs.file('app.apk'), + applicationBinary: globals.fs.file('app.apk'), ); verify( mockProcessManager.run( @@ -215,7 +216,7 @@ testUsingContext('Error on non-existing file', () { final PrebuiltIOSApp iosApp = - IOSApp.fromPrebuiltApp(fs.file('not_existing.ipa')) as PrebuiltIOSApp; + IOSApp.fromPrebuiltApp(globals.fs.file('not_existing.ipa')) as PrebuiltIOSApp; expect(iosApp, isNull); expect( testLogger.errorText, @@ -224,17 +225,17 @@ }, overrides: overrides); testUsingContext('Error on non-app-bundle folder', () { - fs.directory('regular_folder').createSync(); + globals.fs.directory('regular_folder').createSync(); final PrebuiltIOSApp iosApp = - IOSApp.fromPrebuiltApp(fs.file('regular_folder')) as PrebuiltIOSApp; + IOSApp.fromPrebuiltApp(globals.fs.file('regular_folder')) as PrebuiltIOSApp; expect(iosApp, isNull); expect( testLogger.errorText, 'Folder "regular_folder" is not an app bundle.\n'); }, overrides: overrides); testUsingContext('Error on no info.plist', () { - fs.directory('bundle.app').createSync(); - final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(fs.file('bundle.app')) as PrebuiltIOSApp; + globals.fs.directory('bundle.app').createSync(); + final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('bundle.app')) as PrebuiltIOSApp; expect(iosApp, isNull); expect( testLogger.errorText, @@ -243,9 +244,9 @@ }, overrides: overrides); testUsingContext('Error on bad info.plist', () { - fs.directory('bundle.app').createSync(); - fs.file('bundle.app/Info.plist').writeAsStringSync(badPlistData); - final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(fs.file('bundle.app')) as PrebuiltIOSApp; + globals.fs.directory('bundle.app').createSync(); + globals.fs.file('bundle.app/Info.plist').writeAsStringSync(badPlistData); + final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('bundle.app')) as PrebuiltIOSApp; expect(iosApp, isNull); expect( testLogger.errorText, @@ -255,9 +256,9 @@ }, overrides: overrides); testUsingContext('Success with app bundle', () { - fs.directory('bundle.app').createSync(); - fs.file('bundle.app/Info.plist').writeAsStringSync(plistData); - final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(fs.file('bundle.app')) as PrebuiltIOSApp; + globals.fs.directory('bundle.app').createSync(); + globals.fs.file('bundle.app/Info.plist').writeAsStringSync(plistData); + final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('bundle.app')) as PrebuiltIOSApp; expect(testLogger.errorText, isEmpty); expect(iosApp.bundleDir.path, 'bundle.app'); expect(iosApp.id, 'fooBundleId'); @@ -265,9 +266,9 @@ }, overrides: overrides); testUsingContext('Bad ipa zip-file, no payload dir', () { - fs.file('app.ipa').createSync(); - when(os.unzip(fs.file('app.ipa'), any)).thenAnswer((Invocation _) { }); - final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(fs.file('app.ipa')) as PrebuiltIOSApp; + globals.fs.file('app.ipa').createSync(); + when(os.unzip(globals.fs.file('app.ipa'), any)).thenAnswer((Invocation _) { }); + final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('app.ipa')) as PrebuiltIOSApp; expect(iosApp, isNull); expect( testLogger.errorText, @@ -276,7 +277,7 @@ }, overrides: overrides); testUsingContext('Bad ipa zip-file, two app bundles', () { - fs.file('app.ipa').createSync(); + globals.fs.file('app.ipa').createSync(); when(os.unzip(any, any)).thenAnswer((Invocation invocation) { final File zipFile = invocation.positionalArguments[0] as File; if (zipFile.path != 'app.ipa') { @@ -284,34 +285,34 @@ } final Directory targetDirectory = invocation.positionalArguments[1] as Directory; final String bundlePath1 = - fs.path.join(targetDirectory.path, 'Payload', 'bundle1.app'); + globals.fs.path.join(targetDirectory.path, 'Payload', 'bundle1.app'); final String bundlePath2 = - fs.path.join(targetDirectory.path, 'Payload', 'bundle2.app'); - fs.directory(bundlePath1).createSync(recursive: true); - fs.directory(bundlePath2).createSync(recursive: true); + globals.fs.path.join(targetDirectory.path, 'Payload', 'bundle2.app'); + globals.fs.directory(bundlePath1).createSync(recursive: true); + globals.fs.directory(bundlePath2).createSync(recursive: true); }); - final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(fs.file('app.ipa')) as PrebuiltIOSApp; + final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('app.ipa')) as PrebuiltIOSApp; expect(iosApp, isNull); expect(testLogger.errorText, 'Invalid prebuilt iOS ipa. Does not contain a single app bundle.\n'); }, overrides: overrides); testUsingContext('Success with ipa', () { - fs.file('app.ipa').createSync(); + globals.fs.file('app.ipa').createSync(); when(os.unzip(any, any)).thenAnswer((Invocation invocation) { final File zipFile = invocation.positionalArguments[0] as File; if (zipFile.path != 'app.ipa') { return null; } final Directory targetDirectory = invocation.positionalArguments[1] as Directory; - final Directory bundleAppDir = fs.directory( - fs.path.join(targetDirectory.path, 'Payload', 'bundle.app')); + final Directory bundleAppDir = globals.fs.directory( + globals.fs.path.join(targetDirectory.path, 'Payload', 'bundle.app')); bundleAppDir.createSync(recursive: true); - fs - .file(fs.path.join(bundleAppDir.path, 'Info.plist')) + globals.fs + .file(globals.fs.path.join(bundleAppDir.path, 'Info.plist')) .writeAsStringSync(plistData); }); - final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(fs.file('app.ipa')) as PrebuiltIOSApp; + final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(globals.fs.file('app.ipa')) as PrebuiltIOSApp; expect(testLogger.errorText, isEmpty); expect(iosApp.bundleDir.path, endsWith('bundle.app')); expect(iosApp.id, 'fooBundleId'); @@ -319,30 +320,30 @@ }, overrides: overrides); testUsingContext('returns null when there is no ios or .ios directory', () async { - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); final BuildableIOSApp iosApp = await IOSApp.fromIosProject( - FlutterProject.fromDirectory(fs.currentDirectory).ios) as BuildableIOSApp; + FlutterProject.fromDirectory(globals.fs.currentDirectory).ios) as BuildableIOSApp; expect(iosApp, null); }, overrides: overrides); testUsingContext('returns null when there is no Runner.xcodeproj', () async { - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); - fs.file('ios/FooBar.xcodeproj').createSync(recursive: true); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); + globals.fs.file('ios/FooBar.xcodeproj').createSync(recursive: true); final BuildableIOSApp iosApp = await IOSApp.fromIosProject( - FlutterProject.fromDirectory(fs.currentDirectory).ios) as BuildableIOSApp; + FlutterProject.fromDirectory(globals.fs.currentDirectory).ios) as BuildableIOSApp; expect(iosApp, null); }, overrides: overrides); testUsingContext('returns null when there is no Runner.xcodeproj/project.pbxproj', () async { - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); - fs.file('ios/Runner.xcodeproj').createSync(recursive: true); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); + globals.fs.file('ios/Runner.xcodeproj').createSync(recursive: true); final BuildableIOSApp iosApp = await IOSApp.fromIosProject( - FlutterProject.fromDirectory(fs.currentDirectory).ios) as BuildableIOSApp; + FlutterProject.fromDirectory(globals.fs.currentDirectory).ios) as BuildableIOSApp; expect(iosApp, null); }, overrides: overrides); @@ -358,7 +359,7 @@ testUsingContext('Error on non-existing file', () { final PrebuiltFuchsiaApp fuchsiaApp = - FuchsiaApp.fromPrebuiltApp(fs.file('not_existing.far')) as PrebuiltFuchsiaApp; + FuchsiaApp.fromPrebuiltApp(globals.fs.file('not_existing.far')) as PrebuiltFuchsiaApp; expect(fuchsiaApp, isNull); expect( testLogger.errorText, @@ -367,9 +368,9 @@ }, overrides: overrides); testUsingContext('Error on non-far file', () { - fs.directory('regular_folder').createSync(); + globals.fs.directory('regular_folder').createSync(); final PrebuiltFuchsiaApp fuchsiaApp = - FuchsiaApp.fromPrebuiltApp(fs.file('regular_folder')) as PrebuiltFuchsiaApp; + FuchsiaApp.fromPrebuiltApp(globals.fs.file('regular_folder')) as PrebuiltFuchsiaApp; expect(fuchsiaApp, isNull); expect( testLogger.errorText, @@ -378,16 +379,16 @@ }, overrides: overrides); testUsingContext('Success with far file', () { - fs.file('bundle.far').createSync(); - final PrebuiltFuchsiaApp fuchsiaApp = FuchsiaApp.fromPrebuiltApp(fs.file('bundle.far')) as PrebuiltFuchsiaApp; + globals.fs.file('bundle.far').createSync(); + final PrebuiltFuchsiaApp fuchsiaApp = FuchsiaApp.fromPrebuiltApp(globals.fs.file('bundle.far')) as PrebuiltFuchsiaApp; expect(testLogger.errorText, isEmpty); expect(fuchsiaApp.id, 'bundle.far'); }, overrides: overrides); testUsingContext('returns null when there is no fuchsia', () async { - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); - final BuildableFuchsiaApp fuchsiaApp = FuchsiaApp.fromFuchsiaProject(FlutterProject.fromDirectory(fs.currentDirectory).fuchsia) as BuildableFuchsiaApp; + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); + final BuildableFuchsiaApp fuchsiaApp = FuchsiaApp.fromFuchsiaProject(FlutterProject.fromDirectory(globals.fs.currentDirectory).fuchsia) as BuildableFuchsiaApp; expect(fuchsiaApp, null); }, overrides: overrides); @@ -639,7 +640,7 @@ class MockPlistUtils extends Mock implements PlistParser { @override String getValueFromFile(String path, String key) { - final File file = fs.file(path); + final File file = globals.fs.file(path); if (!file.existsSync()) { return null; }
diff --git a/packages/flutter_tools/test/general.shard/artifacts_test.dart b/packages/flutter_tools/test/general.shard/artifacts_test.dart index da35d1c..d902357 100644 --- a/packages/flutter_tools/test/general.shard/artifacts_test.dart +++ b/packages/flutter_tools/test/general.shard/artifacts_test.dart
@@ -3,11 +3,13 @@ // found in the LICENSE file. import 'package:file/memory.dart'; +import 'package:platform/platform.dart'; + import 'package:flutter_tools/src/artifacts.dart'; import 'package:flutter_tools/src/base/file_system.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/cache.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../src/common.dart'; import '../src/context.dart'; @@ -36,11 +38,11 @@ testUsingContext('getArtifactPath', () { expect( artifacts.getArtifactPath(Artifact.flutterFramework, platform: TargetPlatform.ios, mode: BuildMode.release), - fs.path.join(tempDir.path, 'bin', 'cache', 'artifacts', 'engine', 'ios-release', 'Flutter.framework'), + globals.fs.path.join(tempDir.path, 'bin', 'cache', 'artifacts', 'engine', 'ios-release', 'Flutter.framework'), ); expect( artifacts.getArtifactPath(Artifact.flutterTester), - fs.path.join(tempDir.path, 'bin', 'cache', 'artifacts', 'engine', 'linux-x64', 'flutter_tester'), + globals.fs.path.join(tempDir.path, 'bin', 'cache', 'artifacts', 'engine', 'linux-x64', 'flutter_tester'), ); }, overrides: <Type, Generator>{ Cache: () => Cache(rootOverride: tempDir), @@ -83,15 +85,15 @@ testUsingContext('getArtifactPath', () { expect( artifacts.getArtifactPath(Artifact.flutterFramework, platform: TargetPlatform.ios, mode: BuildMode.release), - fs.path.join(tempDir.path, 'out', 'android_debug_unopt', 'Flutter.framework'), + globals.fs.path.join(tempDir.path, 'out', 'android_debug_unopt', 'Flutter.framework'), ); expect( artifacts.getArtifactPath(Artifact.flutterTester), - fs.path.join(tempDir.path, 'out', 'android_debug_unopt', 'flutter_tester'), + globals.fs.path.join(tempDir.path, 'out', 'android_debug_unopt', 'flutter_tester'), ); expect( artifacts.getArtifactPath(Artifact.engineDartSdkPath), - fs.path.join(tempDir.path, 'out', 'host_debug_unopt', 'dart-sdk'), + globals.fs.path.join(tempDir.path, 'out', 'host_debug_unopt', 'dart-sdk'), ); }, overrides: <Type, Generator>{ FileSystem: () => memoryFileSystem,
diff --git a/packages/flutter_tools/test/general.shard/asset_bundle_package_fonts_test.dart b/packages/flutter_tools/test/general.shard/asset_bundle_package_fonts_test.dart index c6e26fd..222c96f 100644 --- a/packages/flutter_tools/test/general.shard/asset_bundle_package_fonts_test.dart +++ b/packages/flutter_tools/test/general.shard/asset_bundle_package_fonts_test.dart
@@ -10,8 +10,9 @@ import 'package:flutter_tools/src/asset.dart'; import 'package:flutter_tools/src/base/file_system.dart'; -import 'package:flutter_tools/src/base/platform.dart'; + import 'package:flutter_tools/src/cache.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../src/common.dart'; import '../src/context.dart'; @@ -24,7 +25,7 @@ // fixed we fix them here. // TODO(dantup): Remove this function once the above issue is fixed and // rolls into Flutter. - return path?.replaceAll('/', fs.path.separator); + return path?.replaceAll('/', globals.fs.path.separator); } void writePubspecFile(String path, String name, { String fontsSection }) { if (fontsSection == null) { @@ -37,7 +38,7 @@ '''; } - fs.file(fixPath(path)) + globals.fs.file(fixPath(path)) ..createSync(recursive: true) ..writeAsStringSync(''' name: $name @@ -55,7 +56,7 @@ } void writePackagesFile(String packages) { - fs.file('.packages') + globals.fs.file('.packages') ..createSync() ..writeAsStringSync(packages); } @@ -95,7 +96,7 @@ } void writeFontAsset(String path, String font) { - fs.file(fixPath('$path$font')) + globals.fs.file(fixPath('$path$font')) ..createSync(recursive: true) ..writeAsStringSync(font); } @@ -105,7 +106,7 @@ setUp(() async { testFileSystem = MemoryFileSystem( - style: platform.isWindows + style: globals.platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix, ); @@ -114,7 +115,7 @@ testUsingContext('App includes neither font manifest nor fonts when no defines fonts', () async { establishFlutterRoot(); - writeEmptySchemaFile(fs); + writeEmptySchemaFile(globals.fs); writePubspecFile('pubspec.yaml', 'test'); writePackagesFile('test_package:p/p/lib/'); @@ -131,7 +132,7 @@ testUsingContext('App font uses font file from package', () async { establishFlutterRoot(); - writeEmptySchemaFile(fs); + writeEmptySchemaFile(globals.fs); const String fontsSection = ''' - family: foo @@ -160,7 +161,7 @@ testUsingContext('App font uses local font file and package font file', () async { establishFlutterRoot(); - writeEmptySchemaFile(fs); + writeEmptySchemaFile(globals.fs); const String fontsSection = ''' - family: foo @@ -193,7 +194,7 @@ testUsingContext('App uses package font with own font file', () async { establishFlutterRoot(); - writeEmptySchemaFile(fs); + writeEmptySchemaFile(globals.fs); writePubspecFile('pubspec.yaml', 'test'); writePackagesFile('test_package:p/p/lib/'); @@ -227,7 +228,7 @@ testUsingContext('App uses package font with font file from another package', () async { establishFlutterRoot(); - writeEmptySchemaFile(fs); + writeEmptySchemaFile(globals.fs); writePubspecFile('pubspec.yaml', 'test'); writePackagesFile('test_package:p/p/lib/\ntest_package2:p2/p/lib/'); @@ -262,7 +263,7 @@ testUsingContext('App uses package font with properties and own font file', () async { establishFlutterRoot(); - writeEmptySchemaFile(fs); + writeEmptySchemaFile(globals.fs); writePubspecFile('pubspec.yaml', 'test'); writePackagesFile('test_package:p/p/lib/'); @@ -298,7 +299,7 @@ testUsingContext('App uses local font and package font with own font file.', () async { establishFlutterRoot(); - writeEmptySchemaFile(fs); + writeEmptySchemaFile(globals.fs); const String fontsSection = ''' - family: foo
diff --git a/packages/flutter_tools/test/general.shard/asset_bundle_package_test.dart b/packages/flutter_tools/test/general.shard/asset_bundle_package_test.dart index eb1f72d..25e2089 100644 --- a/packages/flutter_tools/test/general.shard/asset_bundle_package_test.dart +++ b/packages/flutter_tools/test/general.shard/asset_bundle_package_test.dart
@@ -10,8 +10,9 @@ import 'package:flutter_tools/src/asset.dart'; import 'package:flutter_tools/src/base/file_system.dart'; -import 'package:flutter_tools/src/base/platform.dart'; + import 'package:flutter_tools/src/cache.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../src/common.dart'; import '../src/context.dart'; @@ -24,7 +25,7 @@ // fixed we fix them here. // TODO(dantup): Remove this function once the above issue is fixed and // rolls into Flutter. - return path?.replaceAll('/', fs.path.separator); + return path?.replaceAll('/', globals.fs.path.separator); } void writePubspecFile(String path, String name, { List<String> assets }) { String assetsSection; @@ -45,7 +46,7 @@ assetsSection = buffer.toString(); } - fs.file(fixPath(path)) + globals.fs.file(fixPath(path)) ..createSync(recursive: true) ..writeAsStringSync(''' name: $name @@ -61,7 +62,7 @@ } void writePackagesFile(String packages) { - fs.file('.packages') + globals.fs.file('.packages') ..createSync() ..writeAsStringSync(packages); } @@ -93,9 +94,9 @@ void writeAssets(String path, List<String> assets) { for (String asset in assets) { - final String fullPath = fixPath(fs.path.join(path, asset)); + final String fullPath = fixPath(globals.fs.path.join(path, asset)); - fs.file(fullPath) + globals.fs.file(fullPath) ..createSync(recursive: true) ..writeAsStringSync(asset); } @@ -105,7 +106,7 @@ setUp(() async { testFileSystem = MemoryFileSystem( - style: platform.isWindows + style: globals.platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix, ); @@ -115,7 +116,7 @@ group('AssetBundle assets from packages', () { testUsingContext('No assets are bundled when the package has no assets', () async { establishFlutterRoot(); - writeEmptySchemaFile(fs); + writeEmptySchemaFile(globals.fs); writePubspecFile('pubspec.yaml', 'test'); writePackagesFile('test_package:p/p/lib/'); @@ -140,7 +141,7 @@ testUsingContext('No assets are bundled when the package has an asset that is not listed', () async { establishFlutterRoot(); - writeEmptySchemaFile(fs); + writeEmptySchemaFile(globals.fs); writePubspecFile('pubspec.yaml', 'test'); writePackagesFile('test_package:p/p/lib/'); @@ -168,7 +169,7 @@ testUsingContext('One asset is bundled when the package has and lists one asset its pubspec', () async { establishFlutterRoot(); - writeEmptySchemaFile(fs); + writeEmptySchemaFile(globals.fs); writePubspecFile('pubspec.yaml', 'test'); writePackagesFile('test_package:p/p/lib/'); @@ -196,7 +197,7 @@ testUsingContext("One asset is bundled when the package has one asset, listed in the app's pubspec", () async { establishFlutterRoot(); - writeEmptySchemaFile(fs); + writeEmptySchemaFile(globals.fs); final List<String> assetEntries = <String>['packages/test_package/a/foo']; writePubspecFile( @@ -224,7 +225,7 @@ testUsingContext('One asset and its variant are bundled when the package has an asset and a variant, and lists the asset in its pubspec', () async { establishFlutterRoot(); - writeEmptySchemaFile(fs); + writeEmptySchemaFile(globals.fs); writePubspecFile('pubspec.yaml', 'test'); writePackagesFile('test_package:p/p/lib/'); @@ -252,7 +253,7 @@ testUsingContext('One asset and its variant are bundled when the package has an asset and a variant, and the app lists the asset in its pubspec', () async { establishFlutterRoot(); - writeEmptySchemaFile(fs); + writeEmptySchemaFile(globals.fs); writePubspecFile( 'pubspec.yaml', @@ -283,7 +284,7 @@ testUsingContext('Two assets are bundled when the package has and lists two assets in its pubspec', () async { establishFlutterRoot(); - writeEmptySchemaFile(fs); + writeEmptySchemaFile(globals.fs); writePubspecFile('pubspec.yaml', 'test'); writePackagesFile('test_package:p/p/lib/'); @@ -312,7 +313,7 @@ testUsingContext("Two assets are bundled when the package has two assets, listed in the app's pubspec", () async { establishFlutterRoot(); - writeEmptySchemaFile(fs); + writeEmptySchemaFile(globals.fs); final List<String> assetEntries = <String>[ 'packages/test_package/a/foo', @@ -348,7 +349,7 @@ testUsingContext('Two assets are bundled when two packages each have and list an asset their pubspec', () async { establishFlutterRoot(); - writeEmptySchemaFile(fs); + writeEmptySchemaFile(globals.fs); writePubspecFile( 'pubspec.yaml', @@ -388,7 +389,7 @@ testUsingContext("Two assets are bundled when two packages each have an asset, listed in the app's pubspec", () async { establishFlutterRoot(); - writeEmptySchemaFile(fs); + writeEmptySchemaFile(globals.fs); final List<String> assetEntries = <String>[ 'packages/test_package/a/foo', @@ -431,7 +432,7 @@ testUsingContext('One asset is bundled when the app depends on a package, listing in its pubspec an asset from another package', () async { establishFlutterRoot(); - writeEmptySchemaFile(fs); + writeEmptySchemaFile(globals.fs); writePubspecFile( 'pubspec.yaml', 'test', @@ -467,7 +468,7 @@ testUsingContext('Asset paths can contain URL reserved characters', () async { establishFlutterRoot(); - writeEmptySchemaFile(fs); + writeEmptySchemaFile(globals.fs); writePubspecFile('pubspec.yaml', 'test'); writePackagesFile('test_package:p/p/lib/'); @@ -497,7 +498,7 @@ group('AssetBundle assets from scanned paths', () { testUsingContext('Two assets are bundled when scanning their directory', () async { establishFlutterRoot(); - writeEmptySchemaFile(fs); + writeEmptySchemaFile(globals.fs); writePubspecFile('pubspec.yaml', 'test'); writePackagesFile('test_package:p/p/lib/'); @@ -528,7 +529,7 @@ testUsingContext('Two assets are bundled when listing one and scanning second directory', () async { establishFlutterRoot(); - writeEmptySchemaFile(fs); + writeEmptySchemaFile(globals.fs); writePubspecFile('pubspec.yaml', 'test'); writePackagesFile('test_package:p/p/lib/'); @@ -559,7 +560,7 @@ testUsingContext('One asset is bundled with variant, scanning wrong directory', () async { establishFlutterRoot(); - writeEmptySchemaFile(fs); + writeEmptySchemaFile(globals.fs); writePubspecFile('pubspec.yaml', 'test'); writePackagesFile('test_package:p/p/lib/'); @@ -587,7 +588,7 @@ group('AssetBundle assets from scanned paths with MemoryFileSystem', () { testUsingContext('One asset is bundled with variant, scanning directory', () async { establishFlutterRoot(); - writeEmptySchemaFile(fs); + writeEmptySchemaFile(globals.fs); writePubspecFile('pubspec.yaml', 'test'); writePackagesFile('test_package:p/p/lib/'); @@ -617,7 +618,7 @@ testUsingContext('No asset is bundled with variant, no assets or directories are listed', () async { establishFlutterRoot(); - writeEmptySchemaFile(fs); + writeEmptySchemaFile(globals.fs); writePubspecFile('pubspec.yaml', 'test'); writePackagesFile('test_package:p/p/lib/'); @@ -646,7 +647,7 @@ testUsingContext('Expect error generating manifest, wrong non-existing directory is listed', () async { establishFlutterRoot(); - writeEmptySchemaFile(fs); + writeEmptySchemaFile(globals.fs); writePubspecFile('pubspec.yaml', 'test'); writePackagesFile('test_package:p/p/lib/');
diff --git a/packages/flutter_tools/test/general.shard/asset_bundle_test.dart b/packages/flutter_tools/test/general.shard/asset_bundle_test.dart index c530ea4..39c8b02 100644 --- a/packages/flutter_tools/test/general.shard/asset_bundle_test.dart +++ b/packages/flutter_tools/test/general.shard/asset_bundle_test.dart
@@ -10,10 +10,10 @@ import 'package:flutter_tools/src/asset.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/logger.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/bundle.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/devfs.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import '../src/common.dart'; @@ -29,7 +29,7 @@ setUp(() async { testFileSystem = MemoryFileSystem( - style: platform.isWindows + style: globals.platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix, ); @@ -46,7 +46,7 @@ }); testUsingContext('empty pubspec', () async { - fs.file('pubspec.yaml') + globals.fs.file('pubspec.yaml') ..createSync() ..writeAsStringSync(''); @@ -64,9 +64,9 @@ }); testUsingContext('wildcard directories are updated when filesystem changes', () async { - final File packageFile = fs.file('.packages')..createSync(); - fs.file(fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true); - fs.file('pubspec.yaml') + final File packageFile = globals.fs.file('.packages')..createSync(); + globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true); + globals.fs.file('pubspec.yaml') ..createSync() ..writeAsStringSync(r''' name: example @@ -85,7 +85,7 @@ expect(bundle.needsBuild(manifestPath: 'pubspec.yaml'), false); // Simulate modifying the files by updating the filestat time manually. - fs.file(fs.path.join('assets', 'foo', 'fizz.txt')) + globals.fs.file(globals.fs.path.join('assets', 'foo', 'fizz.txt')) ..createSync(recursive: true) ..setLastModifiedSync(packageFile.lastModifiedSync().add(const Duration(hours: 1))); @@ -104,8 +104,8 @@ }); testUsingContext('handle removal of wildcard directories', () async { - fs.file(fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true); - final File pubspec = fs.file('pubspec.yaml') + globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true); + final File pubspec = globals.fs.file('pubspec.yaml') ..createSync() ..writeAsStringSync(r''' name: example @@ -113,7 +113,7 @@ assets: - assets/foo/ '''); - fs.file('.packages').createSync(); + globals.fs.file('.packages').createSync(); final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); await bundle.build(manifestPath: 'pubspec.yaml'); // Expected assets: @@ -126,15 +126,15 @@ // Delete the wildcard directory and update pubspec file. final DateTime modifiedTime = pubspec.lastModifiedSync().add(const Duration(hours: 1)); - fs.directory(fs.path.join('assets', 'foo')).deleteSync(recursive: true); - fs.file('pubspec.yaml') + globals.fs.directory(globals.fs.path.join('assets', 'foo')).deleteSync(recursive: true); + globals.fs.file('pubspec.yaml') ..createSync() ..writeAsStringSync(r''' name: example''') ..setLastModifiedSync(modifiedTime); // touch .packages to make sure its change time is after pubspec.yaml's - fs.file('.packages') + globals.fs.file('.packages') ..setLastModifiedSync(modifiedTime); // Even though the previous file was removed, it is left in the @@ -155,11 +155,11 @@ // https://github.com/flutter/flutter/issues/42723 testUsingContext('Test regression for mistyped file', () async { - fs.file(fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true); + globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.txt')).createSync(recursive: true); // Create a directory in the same path to test that we're only looking at File // objects. - fs.directory(fs.path.join('assets', 'foo', 'bar')).createSync(); - fs.file('pubspec.yaml') + globals.fs.directory(globals.fs.path.join('assets', 'foo', 'bar')).createSync(); + globals.fs.file('pubspec.yaml') ..createSync() ..writeAsStringSync(r''' name: example @@ -167,7 +167,7 @@ assets: - assets/foo/ '''); - fs.file('.packages').createSync(); + globals.fs.file('.packages').createSync(); final AssetBundle bundle = AssetBundleFactory.instance.createBundle(); await bundle.build(manifestPath: 'pubspec.yaml'); // Expected assets:
diff --git a/packages/flutter_tools/test/general.shard/asset_bundle_variant_test.dart b/packages/flutter_tools/test/general.shard/asset_bundle_variant_test.dart index 2dab3d3..dcd7627 100644 --- a/packages/flutter_tools/test/general.shard/asset_bundle_variant_test.dart +++ b/packages/flutter_tools/test/general.shard/asset_bundle_variant_test.dart
@@ -9,8 +9,9 @@ import 'package:flutter_tools/src/asset.dart'; import 'package:flutter_tools/src/base/file_system.dart'; -import 'package:flutter_tools/src/base/platform.dart'; + import 'package:flutter_tools/src/cache.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../src/common.dart'; import '../src/context.dart'; @@ -23,14 +24,14 @@ // fixed we fix them here. // TODO(dantup): Remove this function once the above issue is fixed and // rolls into Flutter. - return path?.replaceAll('/', fs.path.separator); + return path?.replaceAll('/', globals.fs.path.separator); } group('AssetBundle asset variants', () { FileSystem testFileSystem; setUp(() async { testFileSystem = MemoryFileSystem( - style: platform.isWindows + style: globals.platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix, ); @@ -41,9 +42,9 @@ // Setting flutterRoot here so that it picks up the MemoryFileSystem's // path separator. Cache.flutterRoot = getFlutterRoot(); - writeEmptySchemaFile(fs); + writeEmptySchemaFile(globals.fs); - fs.file('pubspec.yaml') + globals.fs.file('pubspec.yaml') ..createSync() ..writeAsStringSync( ''' @@ -56,7 +57,7 @@ - a/b/c/foo ''' ); - fs.file('.packages')..createSync(); + globals.fs.file('.packages')..createSync(); final List<String> assets = <String>[ 'a/b/c/foo', @@ -65,7 +66,7 @@ 'a/b/c/var3/foo', ]; for (String asset in assets) { - fs.file(fixPath(asset)) + globals.fs.file(fixPath(asset)) ..createSync(recursive: true) ..writeAsStringSync(asset); } @@ -79,7 +80,7 @@ expect(utf8.decode(await bundle.entries[asset].contentsAsBytes()), asset); } - fs.file(fixPath('a/b/c/foo')).deleteSync(); + globals.fs.file(fixPath('a/b/c/foo')).deleteSync(); bundle = AssetBundleFactory.instance.createBundle(); await bundle.build(manifestPath: 'pubspec.yaml');
diff --git a/packages/flutter_tools/test/general.shard/asset_test.dart b/packages/flutter_tools/test/general.shard/asset_test.dart index 25cc64e..73e0a46 100644 --- a/packages/flutter_tools/test/general.shard/asset_test.dart +++ b/packages/flutter_tools/test/general.shard/asset_test.dart
@@ -5,15 +5,15 @@ import 'dart:async'; import 'package:flutter_tools/src/asset.dart'; -import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/cache.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../src/common.dart'; import '../src/context.dart'; void main() { group('Assets', () { - final String dataPath = fs.path.join( + final String dataPath = globals.fs.path.join( getFlutterRoot(), 'packages', 'flutter_tools', @@ -31,8 +31,8 @@ testUsingContext('app font uses local font file', () async { final AssetBundle asset = AssetBundleFactory.instance.createBundle(); await asset.build( - manifestPath : fs.path.join(dataPath, 'main', 'pubspec.yaml'), - packagesPath: fs.path.join(dataPath, 'main', '.packages'), + manifestPath : globals.fs.path.join(dataPath, 'main', 'pubspec.yaml'), + packagesPath: globals.fs.path.join(dataPath, 'main', '.packages'), includeDefaultFonts: false, ); @@ -45,7 +45,7 @@ }); testUsingContext('handles empty pubspec with .packages', () async { - final String dataPath = fs.path.join( + final String dataPath = globals.fs.path.join( getFlutterRoot(), 'packages', 'flutter_tools', @@ -55,8 +55,8 @@ ); final AssetBundle asset = AssetBundleFactory.instance.createBundle(); await asset.build( - manifestPath : fs.path.join(dataPath, 'main', 'pubspec.yaml'), // file doesn't exist - packagesPath: fs.path.join(dataPath, 'main', '.packages'), + manifestPath : globals.fs.path.join(dataPath, 'main', 'pubspec.yaml'), // file doesn't exist + packagesPath: globals.fs.path.join(dataPath, 'main', '.packages'), includeDefaultFonts: false, ); expect(asset.wasBuiltOnce(), true);
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 ecea2c3..62c4c18 100644 --- a/packages/flutter_tools/test/general.shard/base/build_test.dart +++ b/packages/flutter_tools/test/general.shard/base/build_test.dart
@@ -17,6 +17,7 @@ import 'package:flutter_tools/src/base/process.dart'; import 'package:flutter_tools/src/macos/xcode.dart'; import 'package:flutter_tools/src/version.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; @@ -66,7 +67,7 @@ return 1; } outputs.forEach((String filePath, String fileContent) { - fs.file(filePath).writeAsString(fileContent); + globals.fs.file(filePath).writeAsString(fileContent); }); return 0; } @@ -264,7 +265,7 @@ }; testUsingContext('iOS debug AOT snapshot is invalid', () async { - final String outputPath = fs.path.join('build', 'foo'); + final String outputPath = globals.fs.path.join('build', 'foo'); expect(await snapshotter.build( platform: TargetPlatform.ios, buildMode: BuildMode.debug, @@ -276,7 +277,7 @@ }, overrides: contextOverrides); testUsingContext('Android arm debug AOT snapshot is invalid', () async { - final String outputPath = fs.path.join('build', 'foo'); + final String outputPath = globals.fs.path.join('build', 'foo'); expect(await snapshotter.build( platform: TargetPlatform.android_arm, buildMode: BuildMode.debug, @@ -288,7 +289,7 @@ }, overrides: contextOverrides); testUsingContext('Android arm64 debug AOT snapshot is invalid', () async { - final String outputPath = fs.path.join('build', 'foo'); + final String outputPath = globals.fs.path.join('build', 'foo'); expect(await snapshotter.build( platform: TargetPlatform.android_arm64, buildMode: BuildMode.debug, @@ -300,12 +301,12 @@ }, overrides: contextOverrides); testUsingContext('iOS profile AOT with bitcode uses right flags', () async { - fs.file('main.dill').writeAsStringSync('binary magic'); + globals.fs.file('main.dill').writeAsStringSync('binary magic'); - final String outputPath = fs.path.join('build', 'foo'); - fs.directory(outputPath).createSync(recursive: true); + final String outputPath = globals.fs.path.join('build', 'foo'); + globals.fs.directory(outputPath).createSync(recursive: true); - final String assembly = fs.path.join(outputPath, 'snapshot_assembly.S'); + final String assembly = globals.fs.path.join(outputPath, 'snapshot_assembly.S'); genSnapshot.outputs = <String, String>{ assembly: 'blah blah\n.section __DWARF\nblah blah\n', }; @@ -351,18 +352,18 @@ expect(clangArgs, contains('-isysroot')); expect(clangArgs, contains(kSDKPath)); - final File assemblyFile = fs.file(assembly); + final File assemblyFile = globals.fs.file(assembly); expect(assemblyFile.existsSync(), true); expect(assemblyFile.readAsStringSync().contains('.section __DWARF'), true); }, overrides: contextOverrides); testUsingContext('iOS release AOT with bitcode uses right flags', () async { - fs.file('main.dill').writeAsStringSync('binary magic'); + globals.fs.file('main.dill').writeAsStringSync('binary magic'); - final String outputPath = fs.path.join('build', 'foo'); - fs.directory(outputPath).createSync(recursive: true); + final String outputPath = globals.fs.path.join('build', 'foo'); + globals.fs.directory(outputPath).createSync(recursive: true); - final String assembly = fs.path.join(outputPath, 'snapshot_assembly.S'); + final String assembly = globals.fs.path.join(outputPath, 'snapshot_assembly.S'); genSnapshot.outputs = <String, String>{ assembly: 'blah blah\n.section __DWARF\nblah blah\n', }; @@ -408,8 +409,8 @@ expect(clangArgs, contains('-isysroot')); expect(clangArgs, contains(kSDKPath)); - final File assemblyFile = fs.file(assembly); - final File assemblyBitcodeFile = fs.file('$assembly.stripped.S'); + final File assemblyFile = globals.fs.file(assembly); + final File assemblyBitcodeFile = globals.fs.file('$assembly.stripped.S'); expect(assemblyFile.existsSync(), true); expect(assemblyBitcodeFile.existsSync(), true); expect(assemblyFile.readAsStringSync().contains('.section __DWARF'), true); @@ -417,12 +418,12 @@ }, overrides: contextOverrides); testUsingContext('builds iOS armv7 profile AOT snapshot', () async { - fs.file('main.dill').writeAsStringSync('binary magic'); + globals.fs.file('main.dill').writeAsStringSync('binary magic'); - final String outputPath = fs.path.join('build', 'foo'); - fs.directory(outputPath).createSync(recursive: true); + final String outputPath = globals.fs.path.join('build', 'foo'); + globals.fs.directory(outputPath).createSync(recursive: true); - final String assembly = fs.path.join(outputPath, 'snapshot_assembly.S'); + final String assembly = globals.fs.path.join(outputPath, 'snapshot_assembly.S'); genSnapshot.outputs = <String, String>{ assembly: 'blah blah\n.section __DWARF\nblah blah\n', }; @@ -459,19 +460,19 @@ verify(xcode.cc(argThat(contains('-isysroot')))).called(1); verify(xcode.clang(argThat(contains('-isysroot')))).called(1); - final File assemblyFile = fs.file(assembly); + final File assemblyFile = globals.fs.file(assembly); expect(assemblyFile.existsSync(), true); expect(assemblyFile.readAsStringSync().contains('.section __DWARF'), true); }, overrides: contextOverrides); testUsingContext('builds iOS arm64 profile AOT snapshot', () async { - fs.file('main.dill').writeAsStringSync('binary magic'); + globals.fs.file('main.dill').writeAsStringSync('binary magic'); - final String outputPath = fs.path.join('build', 'foo'); - fs.directory(outputPath).createSync(recursive: true); + final String outputPath = globals.fs.path.join('build', 'foo'); + globals.fs.directory(outputPath).createSync(recursive: true); genSnapshot.outputs = <String, String>{ - fs.path.join(outputPath, 'snapshot_assembly.S'): '', + globals.fs.path.join(outputPath, 'snapshot_assembly.S'): '', }; final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), <String>['command name', 'arguments...']); @@ -495,19 +496,19 @@ expect(genSnapshot.additionalArgs, <String>[ '--deterministic', '--snapshot_kind=app-aot-assembly', - '--assembly=${fs.path.join(outputPath, 'snapshot_assembly.S')}', + '--assembly=${globals.fs.path.join(outputPath, 'snapshot_assembly.S')}', 'main.dill', ]); }, overrides: contextOverrides); testUsingContext('builds iOS release armv7 AOT snapshot', () async { - fs.file('main.dill').writeAsStringSync('binary magic'); + globals.fs.file('main.dill').writeAsStringSync('binary magic'); - final String outputPath = fs.path.join('build', 'foo'); - fs.directory(outputPath).createSync(recursive: true); + final String outputPath = globals.fs.path.join('build', 'foo'); + globals.fs.directory(outputPath).createSync(recursive: true); genSnapshot.outputs = <String, String>{ - fs.path.join(outputPath, 'snapshot_assembly.S'): '', + globals.fs.path.join(outputPath, 'snapshot_assembly.S'): '', }; final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), <String>['command name', 'arguments...']); @@ -531,7 +532,7 @@ expect(genSnapshot.additionalArgs, <String>[ '--deterministic', '--snapshot_kind=app-aot-assembly', - '--assembly=${fs.path.join(outputPath, 'snapshot_assembly.S')}', + '--assembly=${globals.fs.path.join(outputPath, 'snapshot_assembly.S')}', '--no-sim-use-hardfp', '--no-use-integer-division', 'main.dill', @@ -539,13 +540,13 @@ }, overrides: contextOverrides); testUsingContext('builds iOS release arm64 AOT snapshot', () async { - fs.file('main.dill').writeAsStringSync('binary magic'); + globals.fs.file('main.dill').writeAsStringSync('binary magic'); - final String outputPath = fs.path.join('build', 'foo'); - fs.directory(outputPath).createSync(recursive: true); + final String outputPath = globals.fs.path.join('build', 'foo'); + globals.fs.directory(outputPath).createSync(recursive: true); genSnapshot.outputs = <String, String>{ - fs.path.join(outputPath, 'snapshot_assembly.S'): '', + globals.fs.path.join(outputPath, 'snapshot_assembly.S'): '', }; final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), <String>['command name', 'arguments...']); @@ -569,16 +570,16 @@ expect(genSnapshot.additionalArgs, <String>[ '--deterministic', '--snapshot_kind=app-aot-assembly', - '--assembly=${fs.path.join(outputPath, 'snapshot_assembly.S')}', + '--assembly=${globals.fs.path.join(outputPath, 'snapshot_assembly.S')}', 'main.dill', ]); }, overrides: contextOverrides); testUsingContext('builds shared library for android-arm', () async { - fs.file('main.dill').writeAsStringSync('binary magic'); + globals.fs.file('main.dill').writeAsStringSync('binary magic'); - final String outputPath = fs.path.join('build', 'foo'); - fs.directory(outputPath).createSync(recursive: true); + final String outputPath = globals.fs.path.join('build', 'foo'); + globals.fs.directory(outputPath).createSync(recursive: true); final int genSnapshotExitCode = await snapshotter.build( platform: TargetPlatform.android_arm, @@ -605,10 +606,10 @@ }, overrides: contextOverrides); testUsingContext('builds shared library for android-arm64', () async { - fs.file('main.dill').writeAsStringSync('binary magic'); + globals.fs.file('main.dill').writeAsStringSync('binary magic'); - final String outputPath = fs.path.join('build', 'foo'); - fs.directory(outputPath).createSync(recursive: true); + final String outputPath = globals.fs.path.join('build', 'foo'); + globals.fs.directory(outputPath).createSync(recursive: true); final int genSnapshotExitCode = await snapshotter.build( platform: TargetPlatform.android_arm64, @@ -633,13 +634,13 @@ }, overrides: contextOverrides); testUsingContext('reports timing', () async { - fs.file('main.dill').writeAsStringSync('binary magic'); + globals.fs.file('main.dill').writeAsStringSync('binary magic'); - final String outputPath = fs.path.join('build', 'foo'); - fs.directory(outputPath).createSync(recursive: true); + final String outputPath = globals.fs.path.join('build', 'foo'); + globals.fs.directory(outputPath).createSync(recursive: true); genSnapshot.outputs = <String, String>{ - fs.path.join(outputPath, 'app.so'): '', + globals.fs.path.join(outputPath, 'app.so'): '', }; final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), <String>['command name', 'arguments...']);
diff --git a/packages/flutter_tools/test/general.shard/base/file_system_test.dart b/packages/flutter_tools/test/general.shard/base/file_system_test.dart index 96bd310..2cb94fd 100644 --- a/packages/flutter_tools/test/general.shard/base/file_system_test.dart +++ b/packages/flutter_tools/test/general.shard/base/file_system_test.dart
@@ -4,6 +4,7 @@ import 'package:file/memory.dart'; import 'package:flutter_tools/src/base/file_system.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:platform/platform.dart'; import '../../src/common.dart'; @@ -66,14 +67,14 @@ }); testUsingContext('Skip files if shouldCopyFile returns false', () { - final Directory origin = fs.directory('/origin'); + final Directory origin = globals.fs.directory('/origin'); origin.createSync(); - fs.file(fs.path.join('origin', 'a.txt')).writeAsStringSync('irrelevant'); - fs.directory('/origin/nested').createSync(); - fs.file(fs.path.join('origin', 'nested', 'a.txt')).writeAsStringSync('irrelevant'); - fs.file(fs.path.join('origin', 'nested', 'b.txt')).writeAsStringSync('irrelevant'); + globals.fs.file(globals.fs.path.join('origin', 'a.txt')).writeAsStringSync('irrelevant'); + globals.fs.directory('/origin/nested').createSync(); + globals.fs.file(globals.fs.path.join('origin', 'nested', 'a.txt')).writeAsStringSync('irrelevant'); + globals.fs.file(globals.fs.path.join('origin', 'nested', 'b.txt')).writeAsStringSync('irrelevant'); - final Directory destination = fs.directory('/destination'); + final Directory destination = globals.fs.directory('/destination'); copyDirectorySync(origin, destination, shouldCopyFile: (File origin, File dest) { return origin.basename == 'b.txt'; }); @@ -94,24 +95,24 @@ test('does not lowercase on Windows', () { String path = 'C:\\Foo\\bAr\\cOOL.dart'; expect(canonicalizePath(path), path); - // fs.path.canonicalize does lowercase on Windows - expect(fs.path.canonicalize(path), isNot(path)); + // globals.fs.path.canonicalize does lowercase on Windows + expect(globals.fs.path.canonicalize(path), isNot(path)); path = '..\\bar\\.\\\\Foo'; - final String expected = fs.path.join(fs.currentDirectory.parent.absolute.path, 'bar', 'Foo'); + final String expected = globals.fs.path.join(globals.fs.currentDirectory.parent.absolute.path, 'bar', 'Foo'); expect(canonicalizePath(path), expected); - // fs.path.canonicalize should return the same result (modulo casing) - expect(fs.path.canonicalize(path), expected.toLowerCase()); + // globals.fs.path.canonicalize should return the same result (modulo casing) + expect(globals.fs.path.canonicalize(path), expected.toLowerCase()); }, testOn: 'windows'); test('does not lowercase on posix', () { String path = '/Foo/bAr/cOOL.dart'; expect(canonicalizePath(path), path); - // fs.path.canonicalize and canonicalizePath should be the same on Posix - expect(fs.path.canonicalize(path), path); + // globals.fs.path.canonicalize and canonicalizePath should be the same on Posix + expect(globals.fs.path.canonicalize(path), path); path = '../bar/.//Foo'; - final String expected = fs.path.join(fs.currentDirectory.parent.absolute.path, 'bar', 'Foo'); + final String expected = globals.fs.path.join(globals.fs.currentDirectory.parent.absolute.path, 'bar', 'Foo'); expect(canonicalizePath(path), expected); }, testOn: 'posix'); });
diff --git a/packages/flutter_tools/test/general.shard/base/fingerprint_test.dart b/packages/flutter_tools/test/general.shard/base/fingerprint_test.dart index c83e5ca..f57c970 100644 --- a/packages/flutter_tools/test/general.shard/base/fingerprint_test.dart +++ b/packages/flutter_tools/test/general.shard/base/fingerprint_test.dart
@@ -5,12 +5,13 @@ import 'dart:convert' show json; import 'package:file/memory.dart'; -import 'package:flutter_tools/src/base/platform.dart'; +import 'package:platform/platform.dart'; import 'package:flutter_tools/src/base/utils.dart'; import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/fingerprint.dart'; import 'package:flutter_tools/src/version.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import '../../src/common.dart'; @@ -35,9 +36,9 @@ }; testUsingContext('throws when depfile is malformed', () { - fs.file('a.dart').createSync(); - fs.file('b.dart').createSync(); - fs.file('depfile').createSync(); + globals.fs.file('a.dart').createSync(); + globals.fs.file('b.dart').createSync(); + globals.fs.file('depfile').createSync(); final Fingerprinter fingerprinter = Fingerprinter( fingerprintPath: 'out.fingerprint', @@ -52,7 +53,7 @@ }, overrides: contextOverrides); testUsingContext('creates fingerprint with specified properties and files', () { - fs.file('a.dart').createSync(); + globals.fs.file('a.dart').createSync(); final Fingerprinter fingerprinter = Fingerprinter( fingerprintPath: 'out.fingerprint', @@ -70,9 +71,9 @@ }, overrides: contextOverrides); testUsingContext('creates fingerprint with file checksums', () { - fs.file('a.dart').createSync(); - fs.file('b.dart').createSync(); - fs.file('depfile').writeAsStringSync('depfile : b.dart'); + globals.fs.file('a.dart').createSync(); + globals.fs.file('b.dart').createSync(); + globals.fs.file('depfile').writeAsStringSync('depfile : b.dart'); final Fingerprinter fingerprinter = Fingerprinter( fingerprintPath: 'out.fingerprint', @@ -91,8 +92,8 @@ }, overrides: contextOverrides); testUsingContext('fingerprint does not match if not present', () { - fs.file('a.dart').createSync(); - fs.file('b.dart').createSync(); + globals.fs.file('a.dart').createSync(); + globals.fs.file('b.dart').createSync(); final Fingerprinter fingerprinter = Fingerprinter( fingerprintPath: 'out.fingerprint', @@ -106,8 +107,8 @@ }, overrides: contextOverrides); testUsingContext('fingerprint does match if different', () { - fs.file('a.dart').createSync(); - fs.file('b.dart').createSync(); + globals.fs.file('a.dart').createSync(); + globals.fs.file('b.dart').createSync(); final Fingerprinter fingerprinter1 = Fingerprinter( fingerprintPath: 'out.fingerprint', @@ -131,9 +132,9 @@ }, overrides: contextOverrides); testUsingContext('fingerprint does not match if depfile is malformed', () { - fs.file('a.dart').createSync(); - fs.file('b.dart').createSync(); - fs.file('depfile').writeAsStringSync('depfile : b.dart'); + globals.fs.file('a.dart').createSync(); + globals.fs.file('b.dart').createSync(); + globals.fs.file('depfile').writeAsStringSync('depfile : b.dart'); // Write a valid fingerprint final Fingerprinter fingerprinter = Fingerprinter( @@ -148,7 +149,7 @@ fingerprinter.writeFingerprint(); // Write a corrupt depfile. - fs.file('depfile').writeAsStringSync(''); + globals.fs.file('depfile').writeAsStringSync(''); final Fingerprinter badFingerprinter = Fingerprinter( fingerprintPath: 'out.fingerprint', paths: <String>['a.dart', 'b.dart'], @@ -163,9 +164,9 @@ }, overrides: contextOverrides); testUsingContext('fingerprint does not match if previous fingerprint is malformed', () { - fs.file('a.dart').createSync(); - fs.file('b.dart').createSync(); - fs.file('out.fingerprint').writeAsStringSync('** not JSON **'); + globals.fs.file('a.dart').createSync(); + globals.fs.file('b.dart').createSync(); + globals.fs.file('out.fingerprint').writeAsStringSync('** not JSON **'); final Fingerprinter fingerprinter = Fingerprinter( fingerprintPath: 'out.fingerprint', @@ -180,8 +181,8 @@ }, overrides: contextOverrides); testUsingContext('fingerprint does match if identical', () { - fs.file('a.dart').createSync(); - fs.file('b.dart').createSync(); + globals.fs.file('a.dart').createSync(); + globals.fs.file('b.dart').createSync(); final Fingerprinter fingerprinter = Fingerprinter( fingerprintPath: 'out.fingerprint', @@ -205,13 +206,13 @@ }, ); fingerprinter.writeFingerprint(); - expect(fs.file('out.fingerprint').existsSync(), isFalse); + expect(globals.fs.file('out.fingerprint').existsSync(), isFalse); }, overrides: contextOverrides); testUsingContext('applies path filter to inputs paths', () { - fs.file('a.dart').createSync(); - fs.file('ab.dart').createSync(); - fs.file('depfile').writeAsStringSync('depfile : ab.dart c.dart'); + globals.fs.file('a.dart').createSync(); + globals.fs.file('ab.dart').createSync(); + globals.fs.file('depfile').writeAsStringSync('depfile : ab.dart c.dart'); final Fingerprinter fingerprinter = Fingerprinter( fingerprintPath: 'out.fingerprint', @@ -224,7 +225,7 @@ pathFilter: (String path) => path.startsWith('a'), ); fingerprinter.writeFingerprint(); - expect(fs.file('out.fingerprint').existsSync(), isTrue); + expect(globals.fs.file('out.fingerprint').existsSync(), isTrue); }, overrides: contextOverrides); }); @@ -245,7 +246,7 @@ }); testUsingContext('throws if any input file does not exist', () { - fs.file('a.dart').createSync(); + globals.fs.file('a.dart').createSync(); expect( () => Fingerprint.fromBuildInputs(<String, String>{}, <String>['a.dart', 'b.dart']), throwsArgumentError, @@ -256,8 +257,8 @@ }); testUsingContext('populates checksums for valid files', () { - fs.file('a.dart').writeAsStringSync('This is a'); - fs.file('b.dart').writeAsStringSync('This is b'); + globals.fs.file('a.dart').writeAsStringSync('This is a'); + globals.fs.file('b.dart').writeAsStringSync('This is b'); final Fingerprint fingerprint = Fingerprint.fromBuildInputs(<String, String>{}, <String>['a.dart', 'b.dart']); final Map<String, dynamic> jsonObject = castStringKeyedMap(json.decode(fingerprint.toJson())); @@ -452,12 +453,12 @@ }; testUsingContext('returns one file if only one is listed', () { - fs.file('a.d').writeAsStringSync('snapshot.d: /foo/a.dart'); + globals.fs.file('a.d').writeAsStringSync('snapshot.d: /foo/a.dart'); expect(readDepfile('a.d'), unorderedEquals(<String>['/foo/a.dart'])); }, overrides: contextOverrides); testUsingContext('returns multiple files', () { - fs.file('a.d').writeAsStringSync('snapshot.d: /foo/a.dart /foo/b.dart'); + globals.fs.file('a.d').writeAsStringSync('snapshot.d: /foo/a.dart /foo/b.dart'); expect(readDepfile('a.d'), unorderedEquals(<String>[ '/foo/a.dart', '/foo/b.dart', @@ -465,7 +466,7 @@ }, overrides: contextOverrides); testUsingContext('trims extra spaces between files', () { - fs.file('a.d').writeAsStringSync('snapshot.d: /foo/a.dart /foo/b.dart /foo/c.dart'); + globals.fs.file('a.d').writeAsStringSync('snapshot.d: /foo/a.dart /foo/b.dart /foo/c.dart'); expect(readDepfile('a.d'), unorderedEquals(<String>[ '/foo/a.dart', '/foo/b.dart', @@ -474,7 +475,7 @@ }, overrides: contextOverrides); testUsingContext('returns files with spaces and backslashes', () { - fs.file('a.d').writeAsStringSync(r'snapshot.d: /foo/a\ a.dart /foo/b\\b.dart /foo/c\\ c.dart'); + globals.fs.file('a.d').writeAsStringSync(r'snapshot.d: /foo/a\ a.dart /foo/b\\b.dart /foo/c\\ c.dart'); expect(readDepfile('a.d'), unorderedEquals(<String>[ r'/foo/a a.dart', r'/foo/b\b.dart',
diff --git a/packages/flutter_tools/test/general.shard/base/logger_test.dart b/packages/flutter_tools/test/general.shard/base/logger_test.dart index e9caf38..b30772b 100644 --- a/packages/flutter_tools/test/general.shard/base/logger_test.dart +++ b/packages/flutter_tools/test/general.shard/base/logger_test.dart
@@ -4,11 +4,12 @@ import 'dart:convert' show jsonEncode; +import 'package:platform/platform.dart'; import 'package:flutter_tools/src/base/context.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'; import 'package:flutter_tools/src/base/terminal.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:quiver/testing/async.dart'; import '../../src/common.dart'; @@ -113,7 +114,7 @@ doWhileAsync(time, () => ansiSpinner.ticks < 10); List<String> lines = outputStdout(); expect(lines[0], startsWith( - platform.isWindows + globals.platform.isWindows ? ' \b\\\b|\b/\b-\b\\\b|\b/\b-' : ' \b⣽\b⣻\b⢿\b⡿\b⣟\b⣯\b⣷\b⣾\b⣽\b⣻' ), @@ -181,10 +182,10 @@ expect(outputStderr().length, equals(1)); expect(outputStderr().first, isEmpty); // the 5 below is the margin that is always included between the message and the time. - expect(outputStdout().join('\n'), matches(platform.isWindows ? r'^Hello {15} {5} {8}[\b]{8} {7}\\$' : + expect(outputStdout().join('\n'), matches(globals.platform.isWindows ? r'^Hello {15} {5} {8}[\b]{8} {7}\\$' : r'^Hello {15} {5} {8}[\b]{8} {7}⣽$')); status.stop(); - expect(outputStdout().join('\n'), matches(platform.isWindows ? r'^Hello {15} {5} {8}[\b]{8} {7}\\[\b]{8} {8}[\b]{8}[\d, ]{4}[\d]\.[\d]s[\n]$' : + expect(outputStdout().join('\n'), matches(globals.platform.isWindows ? r'^Hello {15} {5} {8}[\b]{8} {7}\\[\b]{8} {8}[\b]{8}[\d, ]{4}[\d]\.[\d]s[\n]$' : r'^Hello {15} {5} {8}[\b]{8} {7}⣽[\b]{8} {8}[\b]{8}[\d, ]{4}[\d]\.[\d]s[\n]$')); done = true; }); @@ -208,8 +209,8 @@ ); logger.printStatus('Rude Interrupting Cow'); status.stop(); - final String a = platform.isWindows ? '\\' : '⣽'; - final String b = platform.isWindows ? '|' : '⣻'; + final String a = globals.platform.isWindows ? '\\' : '⣽'; + final String b = globals.platform.isWindows ? '|' : '⣻'; expect( outputStdout().join('\n'), 'Knock Knock, Who\'s There ' // initial message @@ -281,7 +282,7 @@ mockStopwatch.elapsed = const Duration(seconds: 1); doWhileAsync(time, () => ansiStatus.ticks < 10); List<String> lines = outputStdout(); - expect(lines[0], startsWith(platform.isWindows + expect(lines[0], startsWith(globals.platform.isWindows ? 'Hello world \b\b\b\b\b\b\b\b \\\b\b\b\b\b\b\b\b |\b\b\b\b\b\b\b\b /\b\b\b\b\b\b\b\b -\b\b\b\b\b\b\b\b \\\b\b\b\b\b\b\b\b |\b\b\b\b\b\b\b\b /\b\b\b\b\b\b\b\b -\b\b\b\b\b\b\b\b \\\b\b\b\b\b\b\b\b |' : 'Hello world \b\b\b\b\b\b\b\b ⣽\b\b\b\b\b\b\b\b ⣻\b\b\b\b\b\b\b\b ⢿\b\b\b\b\b\b\b\b ⡿\b\b\b\b\b\b\b\b ⣟\b\b\b\b\b\b\b\b ⣯\b\b\b\b\b\b\b\b ⣷\b\b\b\b\b\b\b\b ⣾\b\b\b\b\b\b\b\b ⣽\b\b\b\b\b\b\b\b ⣻')); expect(lines.length, equals(1)); @@ -292,7 +293,7 @@ lines = outputStdout(); final List<Match> matches = secondDigits.allMatches(lines[0]).toList(); expect(matches, isEmpty); - final String x = platform.isWindows ? '|' : '⣻'; + final String x = globals.platform.isWindows ? '|' : '⣻'; expect(lines[0], endsWith('$x\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b')); expect(called, equals(1)); expect(lines.length, equals(2)); @@ -320,7 +321,7 @@ List<String> lines = outputStdout(); expect(lines, hasLength(1)); expect(lines[0], - platform.isWindows + globals.platform.isWindows ? 'Hello world \b\b\b\b\b\b\b\b \\\b\b\b\b\b\b\b\b |\b\b\b\b\b\b\b\b /\b\b\b\b\b\b\b\b -\b\b\b\b\b\b\b\b \\\b\b\b\b\b\b\b\b |\b\b\b\b\b\b\b\b /\b\b\b\b\b\b\b\b -\b\b\b\b\b\b\b\b \\\b\b\b\b\b\b\b\b |' : 'Hello world \b\b\b\b\b\b\b\b ⣽\b\b\b\b\b\b\b\b ⣻\b\b\b\b\b\b\b\b ⢿\b\b\b\b\b\b\b\b ⡿\b\b\b\b\b\b\b\b ⣟\b\b\b\b\b\b\b\b ⣯\b\b\b\b\b\b\b\b ⣷\b\b\b\b\b\b\b\b ⣾\b\b\b\b\b\b\b\b ⣽\b\b\b\b\b\b\b\b ⣻', ); @@ -330,7 +331,7 @@ lines = outputStdout(); expect(lines, hasLength(2)); expect(lines[0], matches( - platform.isWindows + globals.platform.isWindows ? r'Hello world {8}[\b]{8} {7}\\[\b]{8} {7}|[\b]{8} {7}/[\b]{8} {7}-[\b]{8} {7}\\[\b]{8} {7}|[\b]{8} {7}/[\b]{8} {7}-[\b]{8} {7}\\[\b]{8} {7}|[\b]{8} {7} [\b]{8}[\d., ]{6}[\d]ms$' : r'Hello world {8}[\b]{8} {7}⣽[\b]{8} {7}⣻[\b]{8} {7}⢿[\b]{8} {7}⡿[\b]{8} {7}⣟[\b]{8} {7}⣯[\b]{8} {7}⣷[\b]{8} {7}⣾[\b]{8} {7}⣽[\b]{8} {7}⣻[\b]{8} {7} [\b]{8}[\d., ]{5}[\d]ms$' )); @@ -610,10 +611,10 @@ expect(outputStderr().length, equals(1)); expect(outputStderr().first, isEmpty); // the 5 below is the margin that is always included between the message and the time. - expect(outputStdout().join('\n'), matches(platform.isWindows ? r'^Hello {15} {5}$' : + expect(outputStdout().join('\n'), matches(globals.platform.isWindows ? r'^Hello {15} {5}$' : r'^Hello {15} {5}$')); status.stop(); - expect(outputStdout().join('\n'), matches(platform.isWindows ? r'^Hello {15} {5}[\d, ]{4}[\d]\.[\d]s[\n]$' : + expect(outputStdout().join('\n'), matches(globals.platform.isWindows ? r'^Hello {15} {5}[\d, ]{4}[\d]\.[\d]s[\n]$' : r'^Hello {15} {5}[\d, ]{4}[\d]\.[\d]s[\n]$')); done = true; });
diff --git a/packages/flutter_tools/test/general.shard/base/net_test.dart b/packages/flutter_tools/test/general.shard/base/net_test.dart index 8a20822..7f4e78f 100644 --- a/packages/flutter_tools/test/general.shard/base/net_test.dart +++ b/packages/flutter_tools/test/general.shard/base/net_test.dart
@@ -7,10 +7,12 @@ import 'package:file/file.dart'; import 'package:file/memory.dart'; +import 'package:platform/platform.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart' as io; import 'package:flutter_tools/src/base/net.dart'; -import 'package:flutter_tools/src/base/platform.dart'; + +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:quiver/testing/async.dart'; import '../../src/common.dart'; @@ -33,7 +35,7 @@ }); testUsingContext('fetchUrl(destFile) writes the data to a file', () async { - final File destFile = fs.file('dest_file')..createSync(); + final File destFile = globals.fs.file('dest_file')..createSync(); final List<int> data = await fetchUrl( Uri.parse('http://example.invalid/'), destFile: destFile,
diff --git a/packages/flutter_tools/test/general.shard/base/os_utils_test.dart b/packages/flutter_tools/test/general.shard/base/os_utils_test.dart index 8a6d983..9c407d5 100644 --- a/packages/flutter_tools/test/general.shard/base/os_utils_test.dart +++ b/packages/flutter_tools/test/general.shard/base/os_utils_test.dart
@@ -4,7 +4,7 @@ import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/os.dart'; -import 'package:flutter_tools/src/base/platform.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../../src/common.dart'; import '../../src/context.dart'; @@ -14,7 +14,7 @@ Directory tempDir; setUp(() { - tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_os_utils_test.'); + tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_os_utils_test.'); }); tearDown(() { @@ -22,12 +22,12 @@ }); testUsingContext('makeExecutable', () async { - final File file = fs.file(fs.path.join(tempDir.path, 'foo.script')); + final File file = globals.fs.file(globals.fs.path.join(tempDir.path, 'foo.script')); file.writeAsStringSync('hello world'); os.makeExecutable(file); // Skip this test on windows. - if (!platform.isWindows) { + if (!globals.platform.isWindows) { final String mode = file.statSync().modeString(); // rwxr--r-- expect(mode.substring(0, 3), endsWith('x'));
diff --git a/packages/flutter_tools/test/general.shard/base/process_test.dart b/packages/flutter_tools/test/general.shard/base/process_test.dart index f415ffe..bc4383c 100644 --- a/packages/flutter_tools/test/general.shard/base/process_test.dart +++ b/packages/flutter_tools/test/general.shard/base/process_test.dart
@@ -4,9 +4,9 @@ import 'dart:async'; +import 'package:platform/platform.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'; import 'package:flutter_tools/src/base/process.dart'; import 'package:flutter_tools/src/base/terminal.dart'; import 'package:mockito/mockito.dart';
diff --git a/packages/flutter_tools/test/general.shard/base/terminal_test.dart b/packages/flutter_tools/test/general.shard/base/terminal_test.dart index 99af7fa..f6bc675 100644 --- a/packages/flutter_tools/test/general.shard/base/terminal_test.dart +++ b/packages/flutter_tools/test/general.shard/base/terminal_test.dart
@@ -4,10 +4,10 @@ import 'dart:async'; +import 'package:platform/platform.dart'; import 'package:flutter_tools/src/base/io.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/terminal.dart'; -import 'package:flutter_tools/src/globals.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import '../../src/common.dart'; @@ -16,7 +16,7 @@ void main() { group('output preferences', () { testUsingContext('can wrap output', () async { - printStatus('0123456789' * 8); + globals.printStatus('0123456789' * 8); expect(testLogger.statusText, equals(('0123456789' * 4 + '\n') * 2)); }, overrides: <Type, Generator>{ OutputPreferences: () => OutputPreferences(wrapText: true, wrapColumn: 40), @@ -24,7 +24,7 @@ testUsingContext('can turn off wrapping', () async { final String testString = '0123456789' * 20; - printStatus(testString); + globals.printStatus(testString); expect(testLogger.statusText, equals('$testString\n')); }, overrides: <Type, Generator>{ Platform: () => FakePlatform()..stdoutSupportsAnsi = true, @@ -174,7 +174,7 @@ when(stdio.stdin).thenThrow(StateError('This should not be called')); when(stdio.stdinHasTerminal).thenReturn(false); - terminal.singleCharMode = true; + globals.terminal.singleCharMode = true; }, overrides: <Type, Generator>{ Stdio: () => MockStdio(), });
diff --git a/packages/flutter_tools/test/general.shard/base/utils_test.dart b/packages/flutter_tools/test/general.shard/base/utils_test.dart index d5287a2..c4e5f1d 100644 --- a/packages/flutter_tools/test/general.shard/base/utils_test.dart +++ b/packages/flutter_tools/test/general.shard/base/utils_test.dart
@@ -3,7 +3,7 @@ // found in the LICENSE file. import 'package:flutter_tools/src/base/io.dart'; -import 'package:flutter_tools/src/base/platform.dart'; + import 'package:flutter_tools/src/base/utils.dart'; import 'package:platform/platform.dart';
diff --git a/packages/flutter_tools/test/general.shard/build_runner/multiroot_asset_reader_test.dart b/packages/flutter_tools/test/general.shard/build_runner/multiroot_asset_reader_test.dart index 8bbf230..adeba5c 100644 --- a/packages/flutter_tools/test/general.shard/build_runner/multiroot_asset_reader_test.dart +++ b/packages/flutter_tools/test/general.shard/build_runner/multiroot_asset_reader_test.dart
@@ -7,8 +7,8 @@ import 'package:build/build.dart'; import 'package:build_runner_core/build_runner_core.dart'; -import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/build_runner/web_compilation_delegate.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:glob/glob.dart'; import '../../src/common.dart'; @@ -22,15 +22,15 @@ setUp(() { testbed = Testbed(setup: () { - final PackageNode root = PackageNode('foobar', fs.currentDirectory.path, DependencyType.path); + final PackageNode root = PackageNode('foobar', globals.fs.currentDirectory.path, DependencyType.path); packageGraph = FakePackageGraph(root, <String, PackageNode>{'foobar': root}); - fs.file(fs.path.join('lib', 'main.dart')) + globals.fs.file(globals.fs.path.join('lib', 'main.dart')) ..createSync(recursive: true) ..writeAsStringSync('main'); - fs.file(fs.path.join('.dart_tool', 'build', 'generated', 'foobar', 'lib', 'bar.dart')) + globals.fs.file(globals.fs.path.join('.dart_tool', 'build', 'generated', 'foobar', 'lib', 'bar.dart')) ..createSync(recursive: true) ..writeAsStringSync('bar'); - fs.file('pubspec.yaml') + globals.fs.file('pubspec.yaml') ..createSync() ..writeAsStringSync('name: foobar'); }); @@ -40,7 +40,7 @@ await IOOverrides.runWithIOOverrides(() async { final MultirootFileBasedAssetReader reader = MultirootFileBasedAssetReader( packageGraph, - fs.directory(fs.path.join('.dart_tool', 'build', 'generated')), + globals.fs.directory(globals.fs.path.join('.dart_tool', 'build', 'generated')), ); expect(await reader.canRead(AssetId('foobar', 'lib/bar.dart')), true); expect(await reader.canRead(AssetId('foobar', 'lib/main.dart')), true); @@ -56,7 +56,7 @@ AssetId('foobar', 'lib/bar.dart'), AssetId('foobar', 'lib/main.dart'), ])); - }, FlutterIOOverrides(fileSystem: fs)); + }, FlutterIOOverrides(fileSystem: globals.fs)); // Some component of either dart:io or build_runner normalizes file uris // into file paths for windows. This doesn't seem to work with IOOverrides // leaving all filepaths on windows with forward slashes.
diff --git a/packages/flutter_tools/test/general.shard/build_system/build_system_test.dart b/packages/flutter_tools/test/general.shard/build_system/build_system_test.dart index f1535a3..a3277a7 100644 --- a/packages/flutter_tools/test/general.shard/build_system/build_system_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/build_system_test.dart
@@ -2,13 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'package:platform/platform.dart'; import 'package:flutter_tools/src/base/file_system.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/utils.dart'; import 'package:flutter_tools/src/build_system/build_system.dart'; import 'package:flutter_tools/src/build_system/exceptions.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:mockito/mockito.dart'; import '../../src/common.dart'; @@ -93,13 +94,13 @@ testbed = Testbed( setup: () { environment = Environment( - outputDir: fs.currentDirectory, - projectDir: fs.currentDirectory, + outputDir: globals.fs.currentDirectory, + projectDir: globals.fs.currentDirectory, ); - fs.file('foo.dart') + globals.fs.file('foo.dart') ..createSync(recursive: true) ..writeAsStringSync(''); - fs.file('pubspec.yaml').createSync(); + globals.fs.file('pubspec.yaml').createSync(); }, overrides: <Type, Generator>{ Platform: () => mockPlatform, @@ -109,7 +110,7 @@ test('Does not throw exception if asked to build with missing inputs', () => testbed.run(() async { // Delete required input file. - fs.file('foo.dart').deleteSync(); + globals.fs.file('foo.dart').deleteSync(); final BuildResult buildResult = await buildSystem.build(fooTarget, environment); expect(buildResult.hasException, false); @@ -131,7 +132,7 @@ test('Saves a stamp file with inputs and outputs', () => testbed.run(() async { await buildSystem.build(fooTarget, environment); - final File stampFile = fs.file(fs.path.join(environment.buildDir.path, 'foo.stamp')); + final File stampFile = globals.fs.file(globals.fs.path.join(environment.buildDir.path, 'foo.stamp')); expect(stampFile.existsSync(), true); final Map<String, dynamic> stampContents = castStringKeyedMap(json.decode(stampFile.readAsStringSync())); @@ -141,9 +142,9 @@ test('Creates a BuildResult with inputs and outputs', () => testbed.run(() async { final BuildResult result = await buildSystem.build(fooTarget, environment); - expect(result.inputFiles.single.path, fs.path.absolute('foo.dart')); + expect(result.inputFiles.single.path, globals.fs.path.absolute('foo.dart')); expect(result.outputFiles.single.path, - fs.path.absolute(fs.path.join(environment.buildDir.path, 'out'))); + globals.fs.path.absolute(globals.fs.path.join(environment.buildDir.path, 'out'))); })); test('Does not re-invoke build if stamp is valid', () => testbed.run(() async { @@ -156,7 +157,7 @@ test('Re-invoke build if input is modified', () => testbed.run(() async { await buildSystem.build(fooTarget, environment); - fs.file('foo.dart').writeAsStringSync('new contents'); + globals.fs.file('foo.dart').writeAsStringSync('new contents'); await buildSystem.build(fooTarget, environment); expect(fooInvocations, 2); @@ -165,7 +166,7 @@ test('does not re-invoke build if input timestamp changes', () => testbed.run(() async { await buildSystem.build(fooTarget, environment); - fs.file('foo.dart').writeAsStringSync(''); + globals.fs.file('foo.dart').writeAsStringSync(''); await buildSystem.build(fooTarget, environment); expect(fooInvocations, 1); @@ -195,7 +196,7 @@ await buildSystem.build(barTarget, environment); - expect(fs.file(fs.path.join(environment.buildDir.path, 'bar')).existsSync(), true); + expect(globals.fs.file(globals.fs.path.join(environment.buildDir.path, 'bar')).existsSync(), true); expect(fooInvocations, 1); expect(barInvocations, 1); })); @@ -216,7 +217,7 @@ }) ..inputs = const <Source>[Source.pattern('{PROJECT_DIR}/foo.dart')] ..outputs = const <Source>[Source.pattern('{BUILD_DIR}/foo.out')]; - fs.file('foo.dart').createSync(); + globals.fs.file('foo.dart').createSync(); await buildSystem.build(testTarget, environment); @@ -240,7 +241,7 @@ }) ..inputs = const <Source>[Source.pattern('{PROJECT_DIR}/foo.dart')] ..outputs = const <Source>[Source.pattern('{BUILD_DIR}/foo.out')]; - fs.file('foo.dart').createSync(); + globals.fs.file('foo.dart').createSync(); await buildSystem.build(testTarget, environment); @@ -265,7 +266,7 @@ }) ..inputs = const <Source>[Source.pattern('{PROJECT_DIR}/foo.dart')] ..outputs = const <Source>[Source.pattern('{BUILD_DIR}/foo.out')]; - fs.file('foo.dart').createSync(); + globals.fs.file('foo.dart').createSync(); await buildSystem.build(testTarget, environment); // invalid JSON @@ -295,11 +296,11 @@ '/foo.dart', ], 'outputs': <Object>[ - fs.path.join(environment.buildDir.path, 'out'), + globals.fs.path.join(environment.buildDir.path, 'out'), ], 'dependencies': <Object>[], 'name': 'foo', - 'stamp': fs.path.join(environment.buildDir.path, 'foo.stamp'), + 'stamp': globals.fs.path.join(environment.buildDir.path, 'foo.stamp'), }); })); @@ -317,15 +318,15 @@ final TestTarget target = TestTarget((Environment environment) async { environment.buildDir.childFile('example.d') .writeAsStringSync('a.txt: b.txt'); - fs.file('a.txt').writeAsStringSync('a'); + globals.fs.file('a.txt').writeAsStringSync('a'); called += 1; }) ..depfiles = <String>['example.d']; - fs.file('b.txt').writeAsStringSync('b'); + globals.fs.file('b.txt').writeAsStringSync('b'); await buildSystem.build(target, environment); - expect(fs.file('a.txt').existsSync(), true); + expect(globals.fs.file('a.txt').existsSync(), true); expect(called, 1); // Second build is up to date due to depfil parse. @@ -334,8 +335,8 @@ })); test('output directory is an input to the build', () => testbed.run(() async { - final Environment environmentA = Environment(projectDir: fs.currentDirectory, outputDir: fs.directory('a')); - final Environment environmentB = Environment(projectDir: fs.currentDirectory, outputDir: fs.directory('b')); + final Environment environmentA = Environment(projectDir: globals.fs.currentDirectory, outputDir: globals.fs.directory('a')); + final Environment environmentB = Environment(projectDir: globals.fs.currentDirectory, outputDir: globals.fs.directory('b')); expect(environmentA.buildDir.path, isNot(environmentB.buildDir.path)); })); @@ -346,31 +347,31 @@ if (called == 0) { environment.buildDir.childFile('example.d') .writeAsStringSync('a.txt c.txt: b.txt'); - fs.file('a.txt').writeAsStringSync('a'); - fs.file('c.txt').writeAsStringSync('a'); + globals.fs.file('a.txt').writeAsStringSync('a'); + globals.fs.file('c.txt').writeAsStringSync('a'); } else { // On second run, we no longer claim c.txt as an output. environment.buildDir.childFile('example.d') .writeAsStringSync('a.txt: b.txt'); - fs.file('a.txt').writeAsStringSync('a'); + globals.fs.file('a.txt').writeAsStringSync('a'); } called += 1; }) ..depfiles = const <String>['example.d']; - fs.file('b.txt').writeAsStringSync('b'); + globals.fs.file('b.txt').writeAsStringSync('b'); await buildSystem.build(target, environment); - expect(fs.file('a.txt').existsSync(), true); - expect(fs.file('c.txt').existsSync(), true); + expect(globals.fs.file('a.txt').existsSync(), true); + expect(globals.fs.file('c.txt').existsSync(), true); expect(called, 1); // rewrite an input to force a rerun, espect that the old c.txt is deleted. - fs.file('b.txt').writeAsStringSync('ba'); + globals.fs.file('b.txt').writeAsStringSync('ba'); await buildSystem.build(target, environment); - expect(fs.file('a.txt').existsSync(), true); - expect(fs.file('c.txt').existsSync(), false); + expect(globals.fs.file('a.txt').existsSync(), true); + expect(globals.fs.file('c.txt').existsSync(), false); expect(called, 2); })); }
diff --git a/packages/flutter_tools/test/general.shard/build_system/depfile_test.dart b/packages/flutter_tools/test/general.shard/build_system/depfile_test.dart index b7b4cf6..60331fa 100644 --- a/packages/flutter_tools/test/general.shard/build_system/depfile_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/depfile_test.dart
@@ -5,6 +5,7 @@ import 'package:file/memory.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/build_system/depfile.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../../src/common.dart'; import '../../src/testbed.dart'; @@ -16,7 +17,7 @@ testbed = Testbed(); }); test('Can parse depfile from file', () => testbed.run(() { - final File depfileSource = fs.file('example.d')..writeAsStringSync(''' + final File depfileSource = globals.fs.file('example.d')..writeAsStringSync(''' a.txt: b.txt '''); final Depfile depfile = Depfile.parse(depfileSource); @@ -26,7 +27,7 @@ })); test('Can parse depfile with multiple inputs', () => testbed.run(() { - final File depfileSource = fs.file('example.d')..writeAsStringSync(''' + final File depfileSource = globals.fs.file('example.d')..writeAsStringSync(''' a.txt: b.txt c.txt d.txt '''); final Depfile depfile = Depfile.parse(depfileSource); @@ -40,7 +41,7 @@ })); test('Can parse depfile with multiple outputs', () => testbed.run(() { - final File depfileSource = fs.file('example.d')..writeAsStringSync(''' + final File depfileSource = globals.fs.file('example.d')..writeAsStringSync(''' a.txt c.txt d.txt: b.txt '''); final Depfile depfile = Depfile.parse(depfileSource); @@ -54,7 +55,7 @@ })); test('Can parse depfile with windows file paths', () => testbed.run(() { - final File depfileSource = fs.file('example.d')..writeAsStringSync(r''' + final File depfileSource = globals.fs.file('example.d')..writeAsStringSync(r''' C:\\a.txt: C:\\b.txt '''); final Depfile depfile = Depfile.parse(depfileSource); @@ -66,7 +67,7 @@ })); test('Resillient to weird whitespace', () => testbed.run(() { - final File depfileSource = fs.file('example.d')..writeAsStringSync(r''' + final File depfileSource = globals.fs.file('example.d')..writeAsStringSync(r''' a.txt : b.txt c.txt @@ -79,7 +80,7 @@ })); test('Resillient to duplicate files', () => testbed.run(() { - final File depfileSource = fs.file('example.d')..writeAsStringSync(r''' + final File depfileSource = globals.fs.file('example.d')..writeAsStringSync(r''' a.txt: b.txt b.txt '''); final Depfile depfile = Depfile.parse(depfileSource); @@ -89,7 +90,7 @@ })); test('Resillient to malformed file, missing :', () => testbed.run(() { - final File depfileSource = fs.file('example.d')..writeAsStringSync(r''' + final File depfileSource = globals.fs.file('example.d')..writeAsStringSync(r''' a.text b.txt '''); final Depfile depfile = Depfile.parse(depfileSource); @@ -99,18 +100,18 @@ })); test('Can parse dart2js output format', () => testbed.run(() { - final File dart2jsDependencyFile = fs.file('main.dart.js.deps')..writeAsStringSync(r''' + final File dart2jsDependencyFile = globals.fs.file('main.dart.js.deps')..writeAsStringSync(r''' file:///Users/foo/collection.dart file:///Users/foo/algorithms.dart file:///Users/foo/canonicalized_map.dart '''); - final Depfile depfile = Depfile.parseDart2js(dart2jsDependencyFile, fs.file('foo.dart.js')); + final Depfile depfile = Depfile.parseDart2js(dart2jsDependencyFile, globals.fs.file('foo.dart.js')); expect(depfile.inputs.map((File file) => file.path), <String>[ - fs.path.absolute(fs.path.join('Users', 'foo', 'collection.dart')), - fs.path.absolute(fs.path.join('Users', 'foo', 'algorithms.dart')), - fs.path.absolute(fs.path.join('Users', 'foo', 'canonicalized_map.dart')), + globals.fs.path.absolute(globals.fs.path.join('Users', 'foo', 'collection.dart')), + globals.fs.path.absolute(globals.fs.path.join('Users', 'foo', 'algorithms.dart')), + globals.fs.path.absolute(globals.fs.path.join('Users', 'foo', 'canonicalized_map.dart')), ]); expect(depfile.outputs.single.path, 'foo.dart.js'); }, overrides: <Type, Generator>{ @@ -118,17 +119,17 @@ })); test('Can parse handle invalid uri', () => testbed.run(() { - final File dart2jsDependencyFile = fs.file('main.dart.js.deps')..writeAsStringSync(''' + final File dart2jsDependencyFile = globals.fs.file('main.dart.js.deps')..writeAsStringSync(''' file:///Users/foo/collection.dart abcdevf file:///Users/foo/canonicalized_map.dart '''); - final Depfile depfile = Depfile.parseDart2js(dart2jsDependencyFile, fs.file('foo.dart.js')); + final Depfile depfile = Depfile.parseDart2js(dart2jsDependencyFile, globals.fs.file('foo.dart.js')); expect(depfile.inputs.map((File file) => file.path), <String>[ - fs.path.absolute(fs.path.join('Users', 'foo', 'collection.dart')), - fs.path.absolute(fs.path.join('Users', 'foo', 'canonicalized_map.dart')), + globals.fs.path.absolute(globals.fs.path.join('Users', 'foo', 'collection.dart')), + globals.fs.path.absolute(globals.fs.path.join('Users', 'foo', 'canonicalized_map.dart')), ]); expect(depfile.outputs.single.path, 'foo.dart.js'); }, overrides: <Type, Generator>{
diff --git a/packages/flutter_tools/test/general.shard/build_system/exceptions_test.dart b/packages/flutter_tools/test/general.shard/build_system/exceptions_test.dart index 6675ab3..66e0405 100644 --- a/packages/flutter_tools/test/general.shard/build_system/exceptions_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/exceptions_test.dart
@@ -5,13 +5,14 @@ import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/build_system/build_system.dart'; import 'package:flutter_tools/src/build_system/exceptions.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../../src/common.dart'; void main() { test('Exceptions', () { final MissingInputException missingInputException = MissingInputException( - <File>[fs.file('foo'), fs.file('bar')], 'example'); + <File>[globals.fs.file('foo'), globals.fs.file('bar')], 'example'); final CycleException cycleException = CycleException(<Target>{ TestTarget()..name = 'foo', TestTarget()..name = 'bar', @@ -20,7 +21,7 @@ 'ABC' ); final MissingOutputException missingOutputException = MissingOutputException( - <File>[ fs.file('foo'), fs.file('bar') ], + <File>[ globals.fs.file('foo'), globals.fs.file('bar') ], 'example', ); final MisplacedOutputException misplacedOutputException = MisplacedOutputException(
diff --git a/packages/flutter_tools/test/general.shard/build_system/filecache_test.dart b/packages/flutter_tools/test/general.shard/build_system/filecache_test.dart index 02c225d..c51d0f4 100644 --- a/packages/flutter_tools/test/general.shard/build_system/filecache_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/filecache_test.dart
@@ -7,6 +7,7 @@ import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/build_system/build_system.dart'; import 'package:flutter_tools/src/build_system/file_hash_store.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import '../../src/common.dart'; @@ -19,23 +20,23 @@ setUp(() { testbed = Testbed(setup: () { - fs.directory('build').createSync(); + globals.fs.directory('build').createSync(); environment = Environment( - outputDir: fs.currentDirectory, - projectDir: fs.currentDirectory, + outputDir: globals.fs.currentDirectory, + projectDir: globals.fs.currentDirectory, ); environment.buildDir.createSync(recursive: true); }); }); test('Initializes file cache', () => testbed.run(() { - final FileHashStore fileCache = FileHashStore(environment, fs); + final FileHashStore fileCache = FileHashStore(environment, globals.fs); fileCache.initialize(); fileCache.persist(); - expect(fs.file(fs.path.join(environment.buildDir.path, '.filecache')).existsSync(), true); + expect(globals.fs.file(globals.fs.path.join(environment.buildDir.path, '.filecache')).existsSync(), true); - final Uint8List buffer = fs.file(fs.path.join(environment.buildDir.path, '.filecache')) + final Uint8List buffer = globals.fs.file(globals.fs.path.join(environment.buildDir.path, '.filecache')) .readAsBytesSync(); final FileStorage fileStorage = FileStorage.fromBuffer(buffer); @@ -44,15 +45,15 @@ })); test('saves and restores to file cache', () => testbed.run(() async { - final File file = fs.file('foo.dart') + final File file = globals.fs.file('foo.dart') ..createSync() ..writeAsStringSync('hello'); - final FileHashStore fileCache = FileHashStore(environment, fs); + final FileHashStore fileCache = FileHashStore(environment, globals.fs); fileCache.initialize(); await fileCache.hashFiles(<File>[file]); fileCache.persist(); final String currentHash = fileCache.currentHashes[file.path]; - final Uint8List buffer = fs.file(fs.path.join(environment.buildDir.path, '.filecache')) + final Uint8List buffer = globals.fs.file(globals.fs.path.join(environment.buildDir.path, '.filecache')) .readAsBytesSync(); FileStorage fileStorage = FileStorage.fromBuffer(buffer); @@ -60,7 +61,7 @@ expect(fileStorage.files.single.path, file.path); - final FileHashStore newFileCache = FileHashStore(environment, fs); + final FileHashStore newFileCache = FileHashStore(environment, globals.fs); newFileCache.initialize(); expect(newFileCache.currentHashes, isEmpty); expect(newFileCache.previousHashes['foo.dart'], currentHash); @@ -74,10 +75,10 @@ })); test('handles persisting with a missing build directory', () => testbed.run(() async { - final File file = fs.file('foo.dart') + final File file = globals.fs.file('foo.dart') ..createSync() ..writeAsStringSync('hello'); - final FileHashStore fileCache = FileHashStore(environment, fs); + final FileHashStore fileCache = FileHashStore(environment, globals.fs); fileCache.initialize(); environment.buildDir.deleteSync(recursive: true); @@ -87,18 +88,18 @@ })); test('handles hashing missing files', () => testbed.run(() async { - final FileHashStore fileCache = FileHashStore(environment, fs); + final FileHashStore fileCache = FileHashStore(environment, globals.fs); fileCache.initialize(); - final List<File> results = await fileCache.hashFiles(<File>[fs.file('hello.dart')]); + final List<File> results = await fileCache.hashFiles(<File>[globals.fs.file('hello.dart')]); expect(results, hasLength(1)); expect(results.single.path, 'hello.dart'); - expect(fileCache.currentHashes, isNot(contains(fs.path.absolute('hello.dart')))); + expect(fileCache.currentHashes, isNot(contains(globals.fs.path.absolute('hello.dart')))); })); test('handles failure to persist file cache', () => testbed.run(() async { - final FakeForwardingFileSystem fakeForwardingFileSystem = FakeForwardingFileSystem(fs); + final FakeForwardingFileSystem fakeForwardingFileSystem = FakeForwardingFileSystem(globals.fs); final FileHashStore fileCache = FileHashStore(environment, fakeForwardingFileSystem); final String cacheFile = environment.buildDir.childFile('.filecache').path; final MockFile mockFile = MockFile(); @@ -113,7 +114,7 @@ })); test('handles failure to restore file cache', () => testbed.run(() async { - final FakeForwardingFileSystem fakeForwardingFileSystem = FakeForwardingFileSystem(fs); + final FakeForwardingFileSystem fakeForwardingFileSystem = FakeForwardingFileSystem(globals.fs); final FileHashStore fileCache = FileHashStore(environment, fakeForwardingFileSystem); final String cacheFile = environment.buildDir.childFile('.filecache').path; final MockFile mockFile = MockFile();
diff --git a/packages/flutter_tools/test/general.shard/build_system/source_test.dart b/packages/flutter_tools/test/general.shard/build_system/source_test.dart index afc0506..18f6b32 100644 --- a/packages/flutter_tools/test/general.shard/build_system/source_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/source_test.dart
@@ -4,13 +4,14 @@ import 'package:flutter_tools/src/artifacts.dart'; import 'package:flutter_tools/src/base/file_system.dart'; -import 'package:flutter_tools/src/base/platform.dart'; + import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/build_system/build_system.dart'; import 'package:flutter_tools/src/build_system/exceptions.dart'; import 'package:flutter_tools/src/build_system/source.dart'; -import 'package:flutter_tools/src/cache.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; +import 'package:platform/platform.dart'; import '../../src/common.dart'; import '../../src/testbed.dart'; @@ -25,13 +26,13 @@ mockPlatform = MockPlatform(); when(mockPlatform.isWindows).thenReturn(true); testbed = Testbed(setup: () { - fs.directory('cache').createSync(); - final Directory outputs = fs.directory('outputs') + globals.fs.directory('cache').createSync(); + final Directory outputs = globals.fs.directory('outputs') ..createSync(); environment = Environment( outputDir: outputs, - projectDir: fs.currentDirectory, - buildDir: fs.directory('build'), + projectDir: globals.fs.currentDirectory, + buildDir: globals.fs.directory('build'), ); visitor = SourceVisitor(environment); environment.buildDir.createSync(recursive: true); @@ -44,51 +45,51 @@ })); test('can substitute {PROJECT_DIR}/foo', () => testbed.run(() { - fs.file('foo').createSync(); + globals.fs.file('foo').createSync(); const Source fooSource = Source.pattern('{PROJECT_DIR}/foo'); fooSource.accept(visitor); - expect(visitor.sources.single.path, fs.path.absolute('foo')); + expect(visitor.sources.single.path, globals.fs.path.absolute('foo')); })); test('can substitute {OUTPUT_DIR}/foo', () => testbed.run(() { - fs.file('foo').createSync(); + globals.fs.file('foo').createSync(); const Source fooSource = Source.pattern('{OUTPUT_DIR}/foo'); fooSource.accept(visitor); - expect(visitor.sources.single.path, fs.path.absolute(fs.path.join('outputs', 'foo'))); + expect(visitor.sources.single.path, globals.fs.path.absolute(globals.fs.path.join('outputs', 'foo'))); })); test('can substitute {BUILD_DIR}/bar', () => testbed.run(() { - final String path = fs.path.join(environment.buildDir.path, 'bar'); - fs.file(path).createSync(); + final String path = globals.fs.path.join(environment.buildDir.path, 'bar'); + globals.fs.file(path).createSync(); const Source barSource = Source.pattern('{BUILD_DIR}/bar'); barSource.accept(visitor); - expect(visitor.sources.single.path, fs.path.absolute(path)); + expect(visitor.sources.single.path, globals.fs.path.absolute(path)); })); test('can substitute {FLUTTER_ROOT}/foo', () => testbed.run(() { - final String path = fs.path.join(environment.flutterRootDir.path, 'foo'); - fs.file(path).createSync(); + final String path = globals.fs.path.join(environment.flutterRootDir.path, 'foo'); + globals.fs.file(path).createSync(); const Source barSource = Source.pattern('{FLUTTER_ROOT}/foo'); barSource.accept(visitor); - expect(visitor.sources.single.path, fs.path.absolute(path)); + expect(visitor.sources.single.path, globals.fs.path.absolute(path)); })); test('can substitute Artifact', () => testbed.run(() { - final String path = fs.path.join( - Cache.instance.getArtifactDirectory('engine').path, + final String path = globals.fs.path.join( + globals.cache.getArtifactDirectory('engine').path, 'windows-x64', 'foo', ); - fs.file(path).createSync(recursive: true); + globals.fs.file(path).createSync(recursive: true); const Source fizzSource = Source.artifact(Artifact.windowsDesktopPath, platform: TargetPlatform.windows_x64); fizzSource.accept(visitor); - expect(visitor.sources.single.resolveSymbolicLinksSync(), fs.path.absolute(path)); + expect(visitor.sources.single.resolveSymbolicLinksSync(), globals.fs.path.absolute(path)); })); test('can substitute {PROJECT_DIR}/*.fizz', () => testbed.run(() { @@ -97,13 +98,13 @@ expect(visitor.sources, isEmpty); - fs.file('foo.fizz').createSync(); - fs.file('foofizz').createSync(); + globals.fs.file('foo.fizz').createSync(); + globals.fs.file('foofizz').createSync(); fizzSource.accept(visitor); - expect(visitor.sources.single.path, fs.path.absolute('foo.fizz')); + expect(visitor.sources.single.path, globals.fs.path.absolute('foo.fizz')); })); test('can substitute {PROJECT_DIR}/fizz.*', () => testbed.run(() { @@ -112,12 +113,12 @@ expect(visitor.sources, isEmpty); - fs.file('fizz.foo').createSync(); - fs.file('fizz').createSync(); + globals.fs.file('fizz.foo').createSync(); + globals.fs.file('fizz').createSync(); fizzSource.accept(visitor); - expect(visitor.sources.single.path, fs.path.absolute('fizz.foo')); + expect(visitor.sources.single.path, globals.fs.path.absolute('fizz.foo')); })); @@ -127,19 +128,19 @@ expect(visitor.sources, isEmpty); - fs.file('bcbc').createSync(); - fs.file('bc').createSync(); + globals.fs.file('bcbc').createSync(); + globals.fs.file('bc').createSync(); fizzSource.accept(visitor); - expect(visitor.sources.single.path, fs.path.absolute('bcbc')); + expect(visitor.sources.single.path, globals.fs.path.absolute('bcbc')); })); test('crashes on bad substitute of two **', () => testbed.run(() { const Source fizzSource = Source.pattern('{PROJECT_DIR}/*.*bar'); - fs.file('abcd.bar').createSync(); + globals.fs.file('abcd.bar').createSync(); expect(() => fizzSource.accept(visitor), throwsA(isInstanceOf<InvalidPatternException>())); })); @@ -154,7 +155,7 @@ test('can substitute optional files', () => testbed.run(() { const Source missingSource = Source.pattern('{PROJECT_DIR}/foo', optional: true); - expect(fs.file('foo').existsSync(), false); + expect(globals.fs.file('foo').existsSync(), false); missingSource.accept(visitor); expect(visitor.sources, isEmpty); }));
diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/android_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/android_test.dart index e690ead..d67e6e9 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/android_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/android_test.dart
@@ -8,7 +8,9 @@ import 'package:flutter_tools/src/build_system/build_system.dart'; import 'package:flutter_tools/src/build_system/targets/android.dart'; import 'package:flutter_tools/src/build_system/targets/dart.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/cache.dart'; + import 'package:mockito/mockito.dart'; import '../../../src/common.dart'; @@ -21,9 +23,9 @@ testbed.test('debug bundle contains expected resources', () async { final Environment environment = Environment( - outputDir: fs.directory('out')..createSync(), - projectDir: fs.currentDirectory, - buildDir: fs.currentDirectory, + outputDir: globals.fs.directory('out')..createSync(), + projectDir: globals.fs.currentDirectory, + buildDir: globals.fs.currentDirectory, defines: <String, String>{ kBuildMode: 'debug', } @@ -33,7 +35,7 @@ // create pre-requisites. environment.buildDir.childFile('app.dill') ..writeAsStringSync('abcd'); - final Directory hostDirectory = fs.currentDirectory + final Directory hostDirectory = globals.fs.currentDirectory .childDirectory(getNameForHostPlatform(getCurrentHostPlatform())) ..createSync(recursive: true); hostDirectory.childFile('vm_isolate_snapshot.bin').createSync(); @@ -42,16 +44,16 @@ await const DebugAndroidApplication().build(environment); - expect(fs.file(fs.path.join('out', 'flutter_assets', 'isolate_snapshot_data')).existsSync(), true); - expect(fs.file(fs.path.join('out', 'flutter_assets', 'vm_snapshot_data')).existsSync(), true); - expect(fs.file(fs.path.join('out', 'flutter_assets', 'kernel_blob.bin')).existsSync(), true); + expect(globals.fs.file(globals.fs.path.join('out', 'flutter_assets', 'isolate_snapshot_data')).existsSync(), true); + expect(globals.fs.file(globals.fs.path.join('out', 'flutter_assets', 'vm_snapshot_data')).existsSync(), true); + expect(globals.fs.file(globals.fs.path.join('out', 'flutter_assets', 'kernel_blob.bin')).existsSync(), true); }); testbed.test('profile bundle contains expected resources', () async { final Environment environment = Environment( - outputDir: fs.directory('out')..createSync(), - projectDir: fs.currentDirectory, - buildDir: fs.currentDirectory, + outputDir: globals.fs.directory('out')..createSync(), + projectDir: globals.fs.currentDirectory, + buildDir: globals.fs.currentDirectory, defines: <String, String>{ kBuildMode: 'profile', } @@ -64,14 +66,14 @@ await const ProfileAndroidApplication().build(environment); - expect(fs.file(fs.path.join('out', 'app.so')).existsSync(), true); + expect(globals.fs.file(globals.fs.path.join('out', 'app.so')).existsSync(), true); }); testbed.test('release bundle contains expected resources', () async { final Environment environment = Environment( - outputDir: fs.directory('out')..createSync(), - projectDir: fs.currentDirectory, - buildDir: fs.currentDirectory, + outputDir: globals.fs.directory('out')..createSync(), + projectDir: globals.fs.currentDirectory, + buildDir: globals.fs.currentDirectory, defines: <String, String>{ kBuildMode: 'release', } @@ -84,14 +86,14 @@ await const ReleaseAndroidApplication().build(environment); - expect(fs.file(fs.path.join('out', 'app.so')).existsSync(), true); + expect(globals.fs.file(globals.fs.path.join('out', 'app.so')).existsSync(), true); }); testbed.test('AndroidAot can build provided target platform', () async { final Environment environment = Environment( - outputDir: fs.directory('out')..createSync(), - projectDir: fs.currentDirectory, - buildDir: fs.currentDirectory, + outputDir: globals.fs.directory('out')..createSync(), + projectDir: globals.fs.currentDirectory, + buildDir: globals.fs.currentDirectory, defines: <String, String>{ kBuildMode: 'release', } @@ -125,9 +127,9 @@ testbed.test('kExtraGenSnapshotOptions passes values to gen_snapshot', () async { final Environment environment = Environment( - outputDir: fs.directory('out')..createSync(), - projectDir: fs.currentDirectory, - buildDir: fs.currentDirectory, + outputDir: globals.fs.directory('out')..createSync(), + projectDir: globals.fs.currentDirectory, + buildDir: globals.fs.currentDirectory, defines: <String, String>{ kBuildMode: 'release', kExtraGenSnapshotOptions: 'foo,bar,baz=2', @@ -160,9 +162,9 @@ testbed.test('android aot bundle copies so from abi directory', () async { final Environment environment = Environment( - outputDir: fs.directory('out')..createSync(), - projectDir: fs.currentDirectory, - buildDir: fs.currentDirectory, + outputDir: globals.fs.directory('out')..createSync(), + projectDir: globals.fs.currentDirectory, + buildDir: globals.fs.currentDirectory, defines: <String, String>{ kBuildMode: 'release', }
diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/assets_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/assets_test.dart index 7b3b091..659709c 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/assets_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/assets_test.dart
@@ -4,9 +4,9 @@ import 'dart:io'; -import 'package:flutter_tools/src/base/file_system.dart'; 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/globals.dart' as globals; import '../../../src/common.dart'; import '../../../src/testbed.dart'; @@ -19,19 +19,19 @@ setUp(() { testbed = Testbed(setup: () { environment = Environment( - outputDir: fs.currentDirectory, - projectDir: fs.currentDirectory, + outputDir: globals.fs.currentDirectory, + projectDir: globals.fs.currentDirectory, ); - fs.file(fs.path.join('packages', 'flutter_tools', 'lib', 'src', + globals.fs.file(globals.fs.path.join('packages', 'flutter_tools', 'lib', 'src', 'build_system', 'targets', 'assets.dart')) ..createSync(recursive: true); - fs.file(fs.path.join('assets', 'foo', 'bar.png')) + globals.fs.file(globals.fs.path.join('assets', 'foo', 'bar.png')) ..createSync(recursive: true); - fs.file(fs.path.join('assets', 'wildcard', '#bar.png')) + globals.fs.file(globals.fs.path.join('assets', 'wildcard', '#bar.png')) ..createSync(recursive: true); - fs.file('.packages') + globals.fs.file('.packages') ..createSync(); - fs.file('pubspec.yaml') + globals.fs.file('pubspec.yaml') ..createSync() ..writeAsStringSync(''' name: example @@ -47,21 +47,21 @@ test('Copies files to correct asset directory', () => testbed.run(() async { await buildSystem.build(const CopyAssets(), environment); - expect(fs.file(fs.path.join(environment.buildDir.path, 'flutter_assets', 'AssetManifest.json')).existsSync(), true); - expect(fs.file(fs.path.join(environment.buildDir.path, 'flutter_assets', 'FontManifest.json')).existsSync(), true); - expect(fs.file(fs.path.join(environment.buildDir.path, 'flutter_assets', 'LICENSE')).existsSync(), true); + expect(globals.fs.file(globals.fs.path.join(environment.buildDir.path, 'flutter_assets', 'AssetManifest.json')).existsSync(), true); + expect(globals.fs.file(globals.fs.path.join(environment.buildDir.path, 'flutter_assets', 'FontManifest.json')).existsSync(), true); + expect(globals.fs.file(globals.fs.path.join(environment.buildDir.path, 'flutter_assets', 'LICENSE')).existsSync(), true); // See https://github.com/flutter/flutter/issues/35293 - expect(fs.file(fs.path.join(environment.buildDir.path, 'flutter_assets', 'assets/foo/bar.png')).existsSync(), true); + expect(globals.fs.file(globals.fs.path.join(environment.buildDir.path, 'flutter_assets', 'assets/foo/bar.png')).existsSync(), true); // See https://github.com/flutter/flutter/issues/46163 - expect(fs.file(fs.path.join(environment.buildDir.path, 'flutter_assets', 'assets/wildcard/%23bar.png')).existsSync(), true); + expect(globals.fs.file(globals.fs.path.join(environment.buildDir.path, 'flutter_assets', 'assets/wildcard/%23bar.png')).existsSync(), true); })); test('Does not leave stale files in build directory', () => testbed.run(() async { await buildSystem.build(const CopyAssets(), environment); - expect(fs.file(fs.path.join(environment.buildDir.path, 'flutter_assets', 'assets/foo/bar.png')).existsSync(), true); + expect(globals.fs.file(globals.fs.path.join(environment.buildDir.path, 'flutter_assets', 'assets/foo/bar.png')).existsSync(), true); // Modify manifest to remove asset. - fs.file('pubspec.yaml') + globals.fs.file('pubspec.yaml') ..createSync() ..writeAsStringSync(''' name: example @@ -71,18 +71,18 @@ await buildSystem.build(const CopyAssets(), environment); // See https://github.com/flutter/flutter/issues/35293 - expect(fs.file(fs.path.join(environment.buildDir.path, 'flutter_assets', 'assets/foo/bar.png')).existsSync(), false); + expect(globals.fs.file(globals.fs.path.join(environment.buildDir.path, 'flutter_assets', 'assets/foo/bar.png')).existsSync(), false); }), skip: Platform.isWindows); // See https://github.com/google/file.dart/issues/131 test('FlutterPlugins updates required files as needed', () => testbed.run(() async { - fs.file('pubspec.yaml') + globals.fs.file('pubspec.yaml') ..writeAsStringSync('name: foo\ndependencies:\n foo: any\n'); await const FlutterPlugins().build(Environment( - outputDir: fs.currentDirectory, - projectDir: fs.currentDirectory, + outputDir: globals.fs.currentDirectory, + projectDir: globals.fs.currentDirectory, )); - expect(fs.file('.flutter-plugins').existsSync(), true); + expect(globals.fs.file('.flutter-plugins').existsSync(), true); })); }
diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/dart_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/dart_test.dart index 82e56be..b83b51b 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/dart_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/dart_test.dart
@@ -4,7 +4,6 @@ import 'package:flutter_tools/src/base/build.dart'; import 'package:flutter_tools/src/base/file_system.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/process.dart'; import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/build_system/build_system.dart'; @@ -15,6 +14,8 @@ import 'package:flutter_tools/src/compile.dart'; import 'package:flutter_tools/src/macos/xcode.dart'; import 'package:flutter_tools/src/project.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; + import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; @@ -39,64 +40,64 @@ mockProcessManager = MockProcessManager(); testbed = Testbed(setup: () { androidEnvironment = Environment( - outputDir: fs.currentDirectory, - projectDir: fs.currentDirectory, + outputDir: globals.fs.currentDirectory, + projectDir: globals.fs.currentDirectory, defines: <String, String>{ kBuildMode: getNameForBuildMode(BuildMode.profile), kTargetPlatform: getNameForTargetPlatform(TargetPlatform.android_arm), }, ); iosEnvironment = Environment( - outputDir: fs.currentDirectory, - projectDir: fs.currentDirectory, + outputDir: globals.fs.currentDirectory, + projectDir: globals.fs.currentDirectory, defines: <String, String>{ kBuildMode: getNameForBuildMode(BuildMode.profile), kTargetPlatform: getNameForTargetPlatform(TargetPlatform.ios), }, ); HostPlatform hostPlatform; - if (platform.isWindows) { + if (globals.platform.isWindows) { hostPlatform = HostPlatform.windows_x64; - } else if (platform.isLinux) { + } else if (globals.platform.isLinux) { hostPlatform = HostPlatform.linux_x64; - } else if (platform.isMacOS) { + } else if (globals.platform.isMacOS) { hostPlatform = HostPlatform.darwin_x64; } else { assert(false); } - final String skyEngineLine = platform.isWindows + final String skyEngineLine = globals.platform.isWindows ? r'sky_engine:file:///C:/bin/cache/pkg/sky_engine/lib/' : 'sky_engine:file:///bin/cache/pkg/sky_engine/lib/'; - fs.file('.packages') + globals.fs.file('.packages') ..createSync() ..writeAsStringSync(''' # Generated $skyEngineLine flutter_tools:lib/'''); - final String engineArtifacts = fs.path.join('bin', 'cache', + final String engineArtifacts = globals.fs.path.join('bin', 'cache', 'artifacts', 'engine'); final List<String> paths = <String>[ - fs.path.join('bin', 'cache', 'pkg', 'sky_engine', 'lib', 'ui', + globals.fs.path.join('bin', 'cache', 'pkg', 'sky_engine', 'lib', 'ui', 'ui.dart'), - fs.path.join('bin', 'cache', 'pkg', 'sky_engine', 'sdk_ext', + globals.fs.path.join('bin', 'cache', 'pkg', 'sky_engine', 'sdk_ext', 'vmservice_io.dart'), - fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'), - fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart.exe'), - fs.path.join(engineArtifacts, getNameForHostPlatform(hostPlatform), + globals.fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'), + globals.fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart.exe'), + globals.fs.path.join(engineArtifacts, getNameForHostPlatform(hostPlatform), 'frontend_server.dart.snapshot'), - fs.path.join(engineArtifacts, 'android-arm-profile', + globals.fs.path.join(engineArtifacts, 'android-arm-profile', getNameForHostPlatform(hostPlatform), 'gen_snapshot'), - fs.path.join(engineArtifacts, 'ios-profile', 'gen_snapshot'), - fs.path.join(engineArtifacts, 'common', 'flutter_patched_sdk', + globals.fs.path.join(engineArtifacts, 'ios-profile', 'gen_snapshot'), + globals.fs.path.join(engineArtifacts, 'common', 'flutter_patched_sdk', 'platform_strong.dill'), - fs.path.join('lib', 'foo.dart'), - fs.path.join('lib', 'bar.dart'), - fs.path.join('lib', 'fizz'), - fs.path.join('packages', 'flutter_tools', 'lib', 'src', 'build_system', 'targets', 'dart.dart'), - fs.path.join('packages', 'flutter_tools', 'lib', 'src', 'build_system', 'targets', 'ios.dart'), + globals.fs.path.join('lib', 'foo.dart'), + globals.fs.path.join('lib', 'bar.dart'), + globals.fs.path.join('lib', 'fizz'), + globals.fs.path.join('packages', 'flutter_tools', 'lib', 'src', 'build_system', 'targets', 'dart.dart'), + globals.fs.path.join('packages', 'flutter_tools', 'lib', 'src', 'build_system', 'targets', 'ios.dart'), ]; for (String path in paths) { - fs.file(path).createSync(recursive: true); + globals.fs.file(path).createSync(recursive: true); } }, overrides: <Type, Generator>{ KernelCompilerFactory: () => FakeKernelCompilerFactory(), @@ -107,7 +108,7 @@ test('kernel_snapshot Produces correct output directory', () => testbed.run(() async { await buildSystem.build(const KernelSnapshot(), androidEnvironment); - expect(fs.file(fs.path.join(androidEnvironment.buildDir.path,'app.dill')).existsSync(), true); + expect(globals.fs.file(globals.fs.path.join(androidEnvironment.buildDir.path,'app.dill')).existsSync(), true); })); test('kernel_snapshot throws error if missing build mode', () => testbed.run(() async { @@ -264,8 +265,8 @@ }); await const KernelSnapshot().build(Environment( - outputDir: fs.currentDirectory, - projectDir: fs.currentDirectory, + outputDir: globals.fs.currentDirectory, + projectDir: globals.fs.currentDirectory, defines: <String, String>{ kBuildMode: 'debug', kTargetPlatform: getNameForTargetPlatform(TargetPlatform.android_arm), @@ -277,8 +278,8 @@ test('aot_elf_profile Produces correct output directory', () => testbed.run(() async { await buildSystem.build(const AotElfProfile(), androidEnvironment); - expect(fs.file(fs.path.join(androidEnvironment.buildDir.path, 'app.dill')).existsSync(), true); - expect(fs.file(fs.path.join(androidEnvironment.buildDir.path, 'app.so')).existsSync(), true); + expect(globals.fs.file(globals.fs.path.join(androidEnvironment.buildDir.path, 'app.dill')).existsSync(), true); + expect(globals.fs.file(globals.fs.path.join(androidEnvironment.buildDir.path, 'app.so')).existsSync(), true); })); test('aot_elf_profile throws error if missing build mode', () => testbed.run(() async { @@ -319,7 +320,7 @@ test('aot_assembly_profile will lipo binaries together when multiple archs are requested', () => testbed.run(() async { iosEnvironment.defines[kIosArchs] ='armv7,arm64'; when(mockProcessManager.run(any)).thenAnswer((Invocation invocation) async { - fs.file(fs.path.join(iosEnvironment.buildDir.path, 'App.framework', 'App')) + globals.fs.file(globals.fs.path.join(iosEnvironment.buildDir.path, 'App.framework', 'App')) .createSync(recursive: true); return FakeProcessResult( stdout: '', @@ -343,7 +344,7 @@ ); final RunResult fakeRunResult = RunResult(fakeProcessResult, const <String>['foo']); when(mockProcessManager.run(any)).thenAnswer((Invocation invocation) async { - fs.file(fs.path.join(iosEnvironment.buildDir.path, 'App.framework', 'App')) + globals.fs.file(globals.fs.path.join(iosEnvironment.buildDir.path, 'App.framework', 'App')) .createSync(recursive: true); return fakeProcessResult; }); @@ -371,7 +372,7 @@ ); final RunResult fakeRunResult = RunResult(fakeProcessResult, const <String>['foo']); when(mockProcessManager.run(any)).thenAnswer((Invocation invocation) async { - fs.file(fs.path.join(iosEnvironment.buildDir.path, 'App.framework', 'App')) + globals.fs.file(globals.fs.path.join(iosEnvironment.buildDir.path, 'App.framework', 'App')) .createSync(recursive: true); return fakeProcessResult; }); @@ -392,7 +393,7 @@ test('aot_assembly_profile will lipo binaries together when multiple archs are requested', () => testbed.run(() async { iosEnvironment.defines[kIosArchs] = 'armv7,arm64'; when(mockProcessManager.run(any)).thenAnswer((Invocation invocation) async { - fs.file(fs.path.join(iosEnvironment.buildDir.path, 'App.framework', 'App')) + globals.fs.file(globals.fs.path.join(iosEnvironment.buildDir.path, 'App.framework', 'App')) .createSync(recursive: true); return FakeProcessResult( stdout: '', @@ -446,7 +447,7 @@ @override Future<int> run({SnapshotType snapshotType, DarwinArch darwinArch, Iterable<String> additionalArgs = const <String>[]}) async { lastCallAdditionalArgs = additionalArgs.toList(); - final Directory out = fs.file(lastCallAdditionalArgs.last).parent; + final Directory out = globals.fs.file(lastCallAdditionalArgs.last).parent; if (darwinArch == null) { out.childFile('app.so').createSync(); out.childFile('gen_snapshot.d').createSync(); @@ -457,8 +458,8 @@ final String assembly = lastCallAdditionalArgs .firstWhere((String arg) => arg.startsWith('--assembly')) .substring('--assembly='.length); - fs.file(assembly).createSync(); - fs.file(assembly.replaceAll('.S', '.o')).createSync(); + globals.fs.file(assembly).createSync(); + globals.fs.file(assembly.replaceAll('.S', '.o')).createSync(); return 0; } } @@ -493,7 +494,7 @@ String initializeFromDill, List<String> dartDefines, }) async { - fs.file(outputFilePath).createSync(recursive: true); + globals.fs.file(outputFilePath).createSync(recursive: true); return CompilerOutput(outputFilePath, 0, null); } }
diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/linux_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/linux_test.dart index 045a284..6eb658e 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/linux_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/linux_test.dart
@@ -2,12 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'package:platform/platform.dart'; import 'package:flutter_tools/src/base/file_system.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/build_system/build_system.dart'; import 'package:flutter_tools/src/build_system/targets/dart.dart'; import 'package:flutter_tools/src/build_system/targets/linux.dart'; import 'package:flutter_tools/src/cache.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import '../../../src/common.dart'; @@ -33,22 +34,22 @@ testbed = Testbed(setup: () { Cache.flutterRoot = ''; environment = Environment( - outputDir: fs.currentDirectory, - projectDir: fs.currentDirectory, + outputDir: globals.fs.currentDirectory, + projectDir: globals.fs.currentDirectory, defines: <String, String>{ kBuildMode: 'debug', } ); - fs.file('bin/cache/artifacts/engine/linux-x64/unrelated-stuff').createSync(recursive: true); - fs.file('bin/cache/artifacts/engine/linux-x64/libflutter_linux_glfw.so').createSync(recursive: true); - fs.file('bin/cache/artifacts/engine/linux-x64/flutter_export.h').createSync(); - fs.file('bin/cache/artifacts/engine/linux-x64/flutter_messenger.h').createSync(); - fs.file('bin/cache/artifacts/engine/linux-x64/flutter_plugin_registrar.h').createSync(); - fs.file('bin/cache/artifacts/engine/linux-x64/flutter_glfw.h').createSync(); - fs.file('bin/cache/artifacts/engine/linux-x64/icudtl.dat').createSync(); - fs.file('bin/cache/artifacts/engine/linux-x64/cpp_client_wrapper_glfw/foo').createSync(recursive: true); - fs.file('packages/flutter_tools/lib/src/build_system/targets/linux.dart').createSync(recursive: true); - fs.directory('linux').createSync(); + globals.fs.file('bin/cache/artifacts/engine/linux-x64/unrelated-stuff').createSync(recursive: true); + globals.fs.file('bin/cache/artifacts/engine/linux-x64/libflutter_linux_glfw.so').createSync(recursive: true); + globals.fs.file('bin/cache/artifacts/engine/linux-x64/flutter_export.h').createSync(); + globals.fs.file('bin/cache/artifacts/engine/linux-x64/flutter_messenger.h').createSync(); + globals.fs.file('bin/cache/artifacts/engine/linux-x64/flutter_plugin_registrar.h').createSync(); + globals.fs.file('bin/cache/artifacts/engine/linux-x64/flutter_glfw.h').createSync(); + globals.fs.file('bin/cache/artifacts/engine/linux-x64/icudtl.dat').createSync(); + globals.fs.file('bin/cache/artifacts/engine/linux-x64/cpp_client_wrapper_glfw/foo').createSync(recursive: true); + globals.fs.file('packages/flutter_tools/lib/src/build_system/targets/linux.dart').createSync(recursive: true); + globals.fs.directory('linux').createSync(); }, overrides: <Type, Generator>{ Platform: () => mockPlatform, }); @@ -58,14 +59,14 @@ final BuildResult result = await buildSystem.build(const UnpackLinuxDebug(), environment); expect(result.hasException, false); - expect(fs.file('linux/flutter/ephemeral/libflutter_linux_glfw.so').existsSync(), true); - expect(fs.file('linux/flutter/ephemeral/flutter_export.h').existsSync(), true); - expect(fs.file('linux/flutter/ephemeral/flutter_messenger.h').existsSync(), true); - expect(fs.file('linux/flutter/ephemeral/flutter_plugin_registrar.h').existsSync(), true); - expect(fs.file('linux/flutter/ephemeral/flutter_glfw.h').existsSync(), true); - expect(fs.file('linux/flutter/ephemeral/icudtl.dat').existsSync(), true); - expect(fs.file('linux/flutter/ephemeral/cpp_client_wrapper_glfw/foo').existsSync(), true); - expect(fs.file('linux/flutter/ephemeral/unrelated-stuff').existsSync(), false); + expect(globals.fs.file('linux/flutter/ephemeral/libflutter_linux_glfw.so').existsSync(), true); + expect(globals.fs.file('linux/flutter/ephemeral/flutter_export.h').existsSync(), true); + expect(globals.fs.file('linux/flutter/ephemeral/flutter_messenger.h').existsSync(), true); + expect(globals.fs.file('linux/flutter/ephemeral/flutter_plugin_registrar.h').existsSync(), true); + expect(globals.fs.file('linux/flutter/ephemeral/flutter_glfw.h').existsSync(), true); + expect(globals.fs.file('linux/flutter/ephemeral/icudtl.dat').existsSync(), true); + expect(globals.fs.file('linux/flutter/ephemeral/cpp_client_wrapper_glfw/foo').existsSync(), true); + expect(globals.fs.file('linux/flutter/ephemeral/unrelated-stuff').existsSync(), false); })); test('Does not re-copy files unecessarily', () => testbed.run(() async { @@ -73,19 +74,19 @@ // Set a date in the far distant past to deal with the limited resolution // of the windows filesystem. final DateTime theDistantPast = DateTime(1991, 8, 23); - fs.file('linux/flutter/ephemeral/libflutter_linux_glfw.so').setLastModifiedSync(theDistantPast); + globals.fs.file('linux/flutter/ephemeral/libflutter_linux_glfw.so').setLastModifiedSync(theDistantPast); await buildSystem.build(const UnpackLinuxDebug(), environment); - expect(fs.file('linux/flutter/ephemeral/libflutter_linux_glfw.so').statSync().modified, equals(theDistantPast)); + expect(globals.fs.file('linux/flutter/ephemeral/libflutter_linux_glfw.so').statSync().modified, equals(theDistantPast)); })); test('Detects changes in input cache files', () => testbed.run(() async { await buildSystem.build(const UnpackLinuxDebug(), environment); - fs.file('bin/cache/artifacts/engine/linux-x64/libflutter_linux_glfw.so').writeAsStringSync('asd'); // modify cache. + globals.fs.file('bin/cache/artifacts/engine/linux-x64/libflutter_linux_glfw.so').writeAsStringSync('asd'); // modify cache. await buildSystem.build(const UnpackLinuxDebug(), environment); - expect(fs.file('linux/flutter/ephemeral/libflutter_linux_glfw.so').readAsStringSync(), 'asd'); + expect(globals.fs.file('linux/flutter/ephemeral/libflutter_linux_glfw.so').readAsStringSync(), 'asd'); })); test('Copies artifacts to out directory', () => testbed.run(() async {
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 b5ef7dd..cd09381 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
@@ -5,17 +5,17 @@ import 'package:flutter_tools/src/base/build.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/process.dart'; -import 'package:flutter_tools/src/base/process_manager.dart'; import 'package:flutter_tools/src/build_system/build_system.dart'; import 'package:flutter_tools/src/build_system/targets/dart.dart'; import 'package:flutter_tools/src/build_system/targets/macos.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/macos/cocoapods.dart'; import 'package:flutter_tools/src/macos/xcode.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; +import 'package:platform/platform.dart'; import '../../../src/common.dart'; import '../../../src/testbed.dart'; @@ -24,25 +24,25 @@ const String _kOutputPrefix = 'FlutterMacOS.framework'; final List<File> inputs = <File>[ - fs.file('$_kInputPrefix/FlutterMacOS'), + globals.fs.file('$_kInputPrefix/FlutterMacOS'), // Headers - fs.file('$_kInputPrefix/Headers/FlutterDartProject.h'), - fs.file('$_kInputPrefix/Headers/FlutterEngine.h'), - fs.file('$_kInputPrefix/Headers/FlutterViewController.h'), - fs.file('$_kInputPrefix/Headers/FlutterBinaryMessenger.h'), - fs.file('$_kInputPrefix/Headers/FlutterChannels.h'), - fs.file('$_kInputPrefix/Headers/FlutterCodecs.h'), - fs.file('$_kInputPrefix/Headers/FlutterMacros.h'), - fs.file('$_kInputPrefix/Headers/FlutterPluginMacOS.h'), - fs.file('$_kInputPrefix/Headers/FlutterPluginRegistrarMacOS.h'), - fs.file('$_kInputPrefix/Headers/FlutterMacOS.h'), + 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'), // Modules - fs.file('$_kInputPrefix/Modules/module.modulemap'), + globals.fs.file('$_kInputPrefix/Modules/module.modulemap'), // Resources - fs.file('$_kInputPrefix/Resources/icudtl.dat'), - fs.file('$_kInputPrefix/Resources/Info.plist'), + globals.fs.file('$_kInputPrefix/Resources/icudtl.dat'), + globals.fs.file('$_kInputPrefix/Resources/Info.plist'), // Ignore Versions folder for now - fs.file('packages/flutter_tools/lib/src/build_system/targets/macos.dart'), + globals.fs.file('packages/flutter_tools/lib/src/build_system/targets/macos.dart'), ]; void main() { @@ -62,14 +62,14 @@ when(mockPlatform.isLinux).thenReturn(false); when(mockPlatform.environment).thenReturn(const <String, String>{}); testbed = Testbed(setup: () { - fs.file(fs.path.join('bin', 'cache', 'pkg', 'sky_engine', 'lib', 'ui', + globals.fs.file(globals.fs.path.join('bin', 'cache', 'pkg', 'sky_engine', 'lib', 'ui', 'ui.dart')).createSync(recursive: true); - fs.file(fs.path.join('bin', 'cache', 'pkg', 'sky_engine', 'sdk_ext', + globals.fs.file(globals.fs.path.join('bin', 'cache', 'pkg', 'sky_engine', 'sdk_ext', 'vmservice_io.dart')).createSync(recursive: true); environment = Environment( - outputDir: fs.currentDirectory, - projectDir: fs.currentDirectory, + outputDir: globals.fs.currentDirectory, + projectDir: globals.fs.currentDirectory, defines: <String, String>{ kBuildMode: 'debug', kTargetPlatform: 'darwin-x64', @@ -89,12 +89,12 @@ environment.outputDir.childDirectory(_kOutputPrefix) .createSync(recursive: true); - when(processManager.run(any)).thenAnswer((Invocation invocation) async { + when(globals.processManager.run(any)).thenAnswer((Invocation invocation) async { final List<String> arguments = invocation.positionalArguments.first as List<String>; final String sourcePath = arguments[arguments.length - 2]; final String targetPath = arguments.last; - final Directory source = fs.directory(sourcePath); - final Directory target = fs.directory(targetPath); + final Directory source = globals.fs.directory(sourcePath); + final Directory target = globals.fs.directory(targetPath); // verify directory was deleted by command. expect(target.existsSync(), false); @@ -102,10 +102,10 @@ for (FileSystemEntity entity in source.listSync(recursive: true)) { if (entity is File) { - final String relative = fs.path.relative(entity.path, from: source.path); - final String destination = fs.path.join(target.path, relative); - if (!fs.file(destination).parent.existsSync()) { - fs.file(destination).parent.createSync(); + final String relative = globals.fs.path.relative(entity.path, from: source.path); + final String destination = globals.fs.path.join(target.path, relative); + if (!globals.fs.file(destination).parent.existsSync()) { + globals.fs.file(destination).parent.createSync(); } entity.copySync(destination); } @@ -114,15 +114,15 @@ }); await const DebugUnpackMacOS().build(environment); - expect(fs.directory('$_kOutputPrefix').existsSync(), true); + expect(globals.fs.directory('$_kOutputPrefix').existsSync(), true); for (File file in inputs) { - expect(fs.file(file.path.replaceFirst(_kInputPrefix, _kOutputPrefix)).existsSync(), true); + expect(globals.fs.file(file.path.replaceFirst(_kInputPrefix, _kOutputPrefix)).existsSync(), true); } })); test('debug macOS application fails if App.framework missing', () => testbed.run(() async { - final String inputKernel = fs.path.join(environment.buildDir.path, 'app.dill'); - fs.file(inputKernel) + final String inputKernel = globals.fs.path.join(environment.buildDir.path, 'app.dill'); + globals.fs.file(inputKernel) ..createSync(recursive: true) ..writeAsStringSync('testing'); @@ -131,59 +131,59 @@ })); test('debug macOS application creates correctly structured framework', () => testbed.run(() async { - fs.file(fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64', + globals.fs.file(globals.fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64', 'vm_isolate_snapshot.bin')).createSync(recursive: true); - fs.file(fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64', + globals.fs.file(globals.fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64', 'isolate_snapshot.bin')).createSync(recursive: true); - fs.file(fs.path.join(environment.buildDir.path, 'App.framework', 'App')) + globals.fs.file(globals.fs.path.join(environment.buildDir.path, 'App.framework', 'App')) ..createSync(recursive: true); - final String inputKernel = fs.path.join(environment.buildDir.path, 'app.dill'); - final String outputKernel = fs.path.join('App.framework', 'Versions', 'A', 'Resources', + final String inputKernel = globals.fs.path.join(environment.buildDir.path, 'app.dill'); + final String outputKernel = globals.fs.path.join('App.framework', 'Versions', 'A', 'Resources', 'flutter_assets', 'kernel_blob.bin'); - final String outputPlist = fs.path.join('App.framework', 'Versions', 'A', 'Resources', + final String outputPlist = globals.fs.path.join('App.framework', 'Versions', 'A', 'Resources', 'Info.plist'); - fs.file(inputKernel) + globals.fs.file(inputKernel) ..createSync(recursive: true) ..writeAsStringSync('testing'); await const DebugMacOSBundleFlutterAssets().build(environment); - expect(fs.file(outputKernel).readAsStringSync(), 'testing'); - expect(fs.file(outputPlist).readAsStringSync(), contains('io.flutter.flutter.app')); + expect(globals.fs.file(outputKernel).readAsStringSync(), 'testing'); + expect(globals.fs.file(outputPlist).readAsStringSync(), contains('io.flutter.flutter.app')); })); test('release/profile macOS application has no blob or precompiled runtime', () => testbed.run(() async { - fs.file(fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64', + globals.fs.file(globals.fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64', 'vm_isolate_snapshot.bin')).createSync(recursive: true); - fs.file(fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64', + globals.fs.file(globals.fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64', 'isolate_snapshot.bin')).createSync(recursive: true); - fs.file(fs.path.join(environment.buildDir.path, 'App.framework', 'App')) + globals.fs.file(globals.fs.path.join(environment.buildDir.path, 'App.framework', 'App')) ..createSync(recursive: true); - final String outputKernel = fs.path.join('App.framework', 'Resources', + final String outputKernel = globals.fs.path.join('App.framework', 'Resources', 'flutter_assets', 'kernel_blob.bin'); - final String precompiledVm = fs.path.join('App.framework', 'Resources', + final String precompiledVm = globals.fs.path.join('App.framework', 'Resources', 'flutter_assets', 'vm_snapshot_data'); - final String precompiledIsolate = fs.path.join('App.framework', 'Resources', + final String precompiledIsolate = globals.fs.path.join('App.framework', 'Resources', 'flutter_assets', 'isolate_snapshot_data'); await const ProfileMacOSBundleFlutterAssets().build(environment..defines[kBuildMode] = 'profile'); - expect(fs.file(outputKernel).existsSync(), false); - expect(fs.file(precompiledVm).existsSync(), false); - expect(fs.file(precompiledIsolate).existsSync(), false); + expect(globals.fs.file(outputKernel).existsSync(), false); + expect(globals.fs.file(precompiledVm).existsSync(), false); + expect(globals.fs.file(precompiledIsolate).existsSync(), false); })); test('release/profile macOS application updates when App.framework updates', () => testbed.run(() async { - fs.file(fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64', + globals.fs.file(globals.fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64', 'vm_isolate_snapshot.bin')).createSync(recursive: true); - fs.file(fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64', + globals.fs.file(globals.fs.path.join('bin', 'cache', 'artifacts', 'engine', 'darwin-x64', 'isolate_snapshot.bin')).createSync(recursive: true); - final File inputFramework = fs.file(fs.path.join(environment.buildDir.path, 'App.framework', 'App')) + final File inputFramework = globals.fs.file(globals.fs.path.join(environment.buildDir.path, 'App.framework', 'App')) ..createSync(recursive: true) ..writeAsStringSync('ABC'); await const ProfileMacOSBundleFlutterAssets().build(environment..defines[kBuildMode] = 'profile'); - final File outputFramework = fs.file(fs.path.join(environment.outputDir.path, 'App.framework', 'App')); + final File outputFramework = globals.fs.file(globals.fs.path.join(environment.outputDir.path, 'App.framework', 'App')); expect(outputFramework.readAsStringSync(), 'ABC'); @@ -210,7 +210,7 @@ return Future<RunResult>.value(RunResult(FakeProcessResult()..exitCode = 0, <String>['test'])); }); environment.buildDir.childFile('app.dill').createSync(recursive: true); - fs.file('.packages') + globals.fs.file('.packages') ..createSync() ..writeAsStringSync(''' # Generated
diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/web_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/web_test.dart index d5b1e44..4c3b261 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/web_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/web_test.dart
@@ -3,15 +3,16 @@ // found in the LICENSE file. import 'package:flutter_tools/src/base/file_system.dart'; -import 'package:flutter_tools/src/base/platform.dart'; -import 'package:flutter_tools/src/base/process_manager.dart'; + import 'package:flutter_tools/src/build_system/build_system.dart'; import 'package:flutter_tools/src/build_system/depfile.dart'; import 'package:flutter_tools/src/build_system/targets/dart.dart'; import 'package:flutter_tools/src/build_system/targets/web.dart'; import 'package:flutter_tools/src/dart/package_map.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; +import 'package:platform/platform.dart'; import '../../../src/common.dart'; import '../../../src/mocks.dart'; @@ -36,17 +37,17 @@ when(mockWindowsPlatform.isLinux).thenReturn(false); testbed = Testbed(setup: () { - final File packagesFile = fs.file(fs.path.join('foo', '.packages')) + final File packagesFile = globals.fs.file(globals.fs.path.join('foo', '.packages')) ..createSync(recursive: true) ..writeAsStringSync('foo:lib/\n'); PackageMap.globalPackagesPath = packagesFile.path; environment = Environment( - projectDir: fs.currentDirectory.childDirectory('foo'), - outputDir: fs.currentDirectory, - buildDir: fs.currentDirectory, + projectDir: globals.fs.currentDirectory.childDirectory('foo'), + outputDir: globals.fs.currentDirectory, + buildDir: globals.fs.currentDirectory, defines: <String, String>{ - kTargetFile: fs.path.join('foo', 'lib', 'main.dart'), + kTargetFile: globals.fs.path.join('foo', 'lib', 'main.dart'), } ); environment.buildDir.createSync(recursive: true); @@ -77,7 +78,7 @@ })); test('WebEntrypointTarget generates an entrypoint for a file outside of main', () => testbed.run(() async { - environment.defines[kTargetFile] = fs.path.join('other', 'lib', 'main.dart'); + environment.defines[kTargetFile] = globals.fs.path.join('other', 'lib', 'main.dart'); await const WebEntrypointTarget().build(environment); final String generated = environment.buildDir.childFile('main.dart').readAsStringSync(); @@ -166,47 +167,47 @@ test('Dart2JSTarget calls dart2js with expected args in profile mode', () => testbed.run(() async { environment.defines[kBuildMode] = 'profile'; - when(processManager.run(any)).thenAnswer((Invocation invocation) async { + when(globals.processManager.run(any)).thenAnswer((Invocation invocation) async { return FakeProcessResult(exitCode: 0); }); await const Dart2JSTarget().build(environment); final List<String> expected = <String>[ - fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'), - fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'dart2js.dart.snapshot'), - '--libraries-spec=' + fs.path.join('bin', 'cache', 'flutter_web_sdk', 'libraries.json'), + globals.fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'), + globals.fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'dart2js.dart.snapshot'), + '--libraries-spec=' + globals.fs.path.join('bin', 'cache', 'flutter_web_sdk', 'libraries.json'), '-O4', // highest optimizations '--no-minify', // but uses unminified names for debugging '-o', environment.buildDir.childFile('main.dart.js').absolute.path, - '--packages=${fs.path.join('foo', '.packages')}', + '--packages=${globals.fs.path.join('foo', '.packages')}', '-Ddart.vm.profile=true', environment.buildDir.childFile('main.dart').absolute.path, ]; - verify(processManager.run(expected)).called(1); + verify(globals.processManager.run(expected)).called(1); }, overrides: <Type, Generator>{ ProcessManager: () => MockProcessManager(), })); test('Dart2JSTarget calls dart2js with expected args in release mode', () => testbed.run(() async { environment.defines[kBuildMode] = 'release'; - when(processManager.run(any)).thenAnswer((Invocation invocation) async { + when(globals.processManager.run(any)).thenAnswer((Invocation invocation) async { return FakeProcessResult(exitCode: 0); }); await const Dart2JSTarget().build(environment); final List<String> expected = <String>[ - fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'), - fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'dart2js.dart.snapshot'), - '--libraries-spec=' + fs.path.join('bin', 'cache', 'flutter_web_sdk', 'libraries.json'), + globals.fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'), + globals.fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'dart2js.dart.snapshot'), + '--libraries-spec=' + globals.fs.path.join('bin', 'cache', 'flutter_web_sdk', 'libraries.json'), '-O4', // highest optimizations. '-o', environment.buildDir.childFile('main.dart.js').absolute.path, - '--packages=${fs.path.join('foo', '.packages')}', + '--packages=${globals.fs.path.join('foo', '.packages')}', '-Ddart.vm.product=true', environment.buildDir.childFile('main.dart').absolute.path, ]; - verify(processManager.run(expected)).called(1); + verify(globals.processManager.run(expected)).called(1); }, overrides: <Type, Generator>{ ProcessManager: () => MockProcessManager(), })); @@ -214,30 +215,30 @@ test('Dart2JSTarget calls dart2js with expected args in release with dart2js optimization override', () => testbed.run(() async { environment.defines[kBuildMode] = 'release'; environment.defines[kDart2jsOptimization] = 'O3'; - when(processManager.run(any)).thenAnswer((Invocation invocation) async { + when(globals.processManager.run(any)).thenAnswer((Invocation invocation) async { return FakeProcessResult(exitCode: 0); }); await const Dart2JSTarget().build(environment); final List<String> expected = <String>[ - fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'), - fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'dart2js.dart.snapshot'), - '--libraries-spec=' + fs.path.join('bin', 'cache', 'flutter_web_sdk', 'libraries.json'), + globals.fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'), + globals.fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'dart2js.dart.snapshot'), + '--libraries-spec=' + globals.fs.path.join('bin', 'cache', 'flutter_web_sdk', 'libraries.json'), '-O3', // configured optimizations. '-o', environment.buildDir.childFile('main.dart.js').absolute.path, - '--packages=${fs.path.join('foo', '.packages')}', + '--packages=${globals.fs.path.join('foo', '.packages')}', '-Ddart.vm.product=true', environment.buildDir.childFile('main.dart').absolute.path, ]; - verify(processManager.run(expected)).called(1); + verify(globals.processManager.run(expected)).called(1); }, overrides: <Type, Generator>{ ProcessManager: () => MockProcessManager(), })); test('Dart2JSTarget produces expected depfile', () => testbed.run(() async { environment.defines[kBuildMode] = 'release'; - when(processManager.run(any)).thenAnswer((Invocation invocation) async { + when(globals.processManager.run(any)).thenAnswer((Invocation invocation) async { environment.buildDir.childFile('main.dart.js.deps') ..writeAsStringSync('file:///a.dart'); return FakeProcessResult(exitCode: 0); @@ -247,7 +248,7 @@ expect(environment.buildDir.childFile('dart2js.d').existsSync(), true); final Depfile depfile = Depfile.parse(environment.buildDir.childFile('dart2js.d')); - expect(depfile.inputs.single.path, fs.path.absolute('a.dart')); + expect(depfile.inputs.single.path, globals.fs.path.absolute('a.dart')); expect(depfile.outputs.single.path, environment.buildDir.childFile('main.dart.js').absolute.path); }, overrides: <Type, Generator>{ @@ -257,25 +258,25 @@ test('Dart2JSTarget calls dart2js with Dart defines in release mode', () => testbed.run(() async { environment.defines[kBuildMode] = 'release'; environment.defines[kDartDefines] = '["FOO=bar","BAZ=qux"]'; - when(processManager.run(any)).thenAnswer((Invocation invocation) async { + when(globals.processManager.run(any)).thenAnswer((Invocation invocation) async { return FakeProcessResult(exitCode: 0); }); await const Dart2JSTarget().build(environment); final List<String> expected = <String>[ - fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'), - fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'dart2js.dart.snapshot'), - '--libraries-spec=' + fs.path.join('bin', 'cache', 'flutter_web_sdk', 'libraries.json'), + globals.fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'), + globals.fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'dart2js.dart.snapshot'), + '--libraries-spec=' + globals.fs.path.join('bin', 'cache', 'flutter_web_sdk', 'libraries.json'), '-O4', '-o', environment.buildDir.childFile('main.dart.js').absolute.path, - '--packages=${fs.path.join('foo', '.packages')}', + '--packages=${globals.fs.path.join('foo', '.packages')}', '-Ddart.vm.product=true', '-DFOO=bar', '-DBAZ=qux', environment.buildDir.childFile('main.dart').absolute.path, ]; - verify(processManager.run(expected)).called(1); + verify(globals.processManager.run(expected)).called(1); }, overrides: <Type, Generator>{ ProcessManager: () => MockProcessManager(), })); @@ -283,26 +284,26 @@ test('Dart2JSTarget calls dart2js with Dart defines in profile mode', () => testbed.run(() async { environment.defines[kBuildMode] = 'profile'; environment.defines[kDartDefines] = '["FOO=bar","BAZ=qux"]'; - when(processManager.run(any)).thenAnswer((Invocation invocation) async { + when(globals.processManager.run(any)).thenAnswer((Invocation invocation) async { return FakeProcessResult(exitCode: 0); }); await const Dart2JSTarget().build(environment); final List<String> expected = <String>[ - fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'), - fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'dart2js.dart.snapshot'), - '--libraries-spec=' + fs.path.join('bin', 'cache', 'flutter_web_sdk', 'libraries.json'), + globals.fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'dart'), + globals.fs.path.join('bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'dart2js.dart.snapshot'), + '--libraries-spec=' + globals.fs.path.join('bin', 'cache', 'flutter_web_sdk', 'libraries.json'), '-O4', '--no-minify', '-o', environment.buildDir.childFile('main.dart.js').absolute.path, - '--packages=${fs.path.join('foo', '.packages')}', + '--packages=${globals.fs.path.join('foo', '.packages')}', '-Ddart.vm.profile=true', '-DFOO=bar', '-DBAZ=qux', environment.buildDir.childFile('main.dart').absolute.path, ]; - verify(processManager.run(expected)).called(1); + verify(globals.processManager.run(expected)).called(1); }, overrides: <Type, Generator>{ ProcessManager: () => MockProcessManager(), })); @@ -323,7 +324,7 @@ } // Should not attempt to run any processes. - verifyNever(processManager.run(any)); + verifyNever(globals.processManager.run(any)); }, overrides: <Type, Generator>{ ProcessManager: () => MockProcessManager(), }));
diff --git a/packages/flutter_tools/test/general.shard/build_system/targets/windows_test.dart b/packages/flutter_tools/test/general.shard/build_system/targets/windows_test.dart index 4e28a9e..acce757 100644 --- a/packages/flutter_tools/test/general.shard/build_system/targets/windows_test.dart +++ b/packages/flutter_tools/test/general.shard/build_system/targets/windows_test.dart
@@ -4,11 +4,13 @@ import 'package:file/memory.dart'; import 'package:flutter_tools/src/base/file_system.dart'; -import 'package:flutter_tools/src/base/platform.dart'; + import 'package:flutter_tools/src/build_system/build_system.dart'; import 'package:flutter_tools/src/build_system/targets/windows.dart'; import 'package:flutter_tools/src/cache.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; +import 'package:platform/platform.dart'; import '../../../src/common.dart'; import '../../../src/fake_process_manager.dart'; @@ -33,23 +35,23 @@ when(platform.pathSeparator).thenReturn(r'\'); testbed = Testbed(setup: () { environment = Environment( - outputDir: fs.currentDirectory, - projectDir: fs.currentDirectory, + outputDir: globals.fs.currentDirectory, + projectDir: globals.fs.currentDirectory, ); - fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_export.h').createSync(recursive: true); - fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_messenger.h').createSync(); - fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_windows.dll').createSync(); - fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_windows.dll.exp').createSync(); - fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_windows.dll.lib').createSync(); - fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_windows.dll.pdb').createSync(); - fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\lutter_export.h').createSync(); - fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_messenger.h').createSync(); - fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_plugin_registrar.h').createSync(); - fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_windows.h').createSync(); - fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\icudtl.dat').createSync(); - fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\cpp_client_wrapper\foo').createSync(recursive: true); - fs.file(r'C:\packages\flutter_tools\lib\src\build_system\targets\windows.dart').createSync(recursive: true); - fs.directory('windows').createSync(); + globals.fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_export.h').createSync(recursive: true); + globals.fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_messenger.h').createSync(); + globals.fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_windows.dll').createSync(); + globals.fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_windows.dll.exp').createSync(); + globals.fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_windows.dll.lib').createSync(); + globals.fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_windows.dll.pdb').createSync(); + globals.fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\lutter_export.h').createSync(); + globals.fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_messenger.h').createSync(); + globals.fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_plugin_registrar.h').createSync(); + globals.fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_windows.h').createSync(); + globals.fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\icudtl.dat').createSync(); + globals.fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\cpp_client_wrapper\foo').createSync(recursive: true); + globals.fs.file(r'C:\packages\flutter_tools\lib\src\build_system\targets\windows.dart').createSync(recursive: true); + globals.fs.directory('windows').createSync(); }, overrides: <Type, Generator>{ FileSystem: () => MemoryFileSystem(style: FileSystemStyle.windows), ProcessManager: () => FakeProcessManager.any(), @@ -60,18 +62,18 @@ test('Copies files to correct cache directory', () => testbed.run(() async { await buildSystem.build(const UnpackWindows(), environment); - expect(fs.file(r'C:\windows\flutter\flutter_export.h').existsSync(), true); - expect(fs.file(r'C:\windows\flutter\flutter_messenger.h').existsSync(), true); - expect(fs.file(r'C:\windows\flutter\flutter_windows.dll').existsSync(), true); - expect(fs.file(r'C:\windows\flutter\flutter_windows.dll.exp').existsSync(), true); - expect(fs.file(r'C:\windows\flutter\flutter_windows.dll.lib').existsSync(), true); - expect(fs.file(r'C:\windows\flutter\flutter_windows.dll.pdb').existsSync(), true); - expect(fs.file(r'C:\windows\flutter\flutter_export.h').existsSync(), true); - expect(fs.file(r'C:\windows\flutter\flutter_messenger.h').existsSync(), true); - expect(fs.file(r'C:\windows\flutter\flutter_plugin_registrar.h').existsSync(), true); - expect(fs.file(r'C:\windows\flutter\flutter_windows.h').existsSync(), true); - expect(fs.file(r'C:\windows\flutter\icudtl.dat').existsSync(), true); - expect(fs.file(r'C:\windows\flutter\cpp_client_wrapper\foo').existsSync(), true); + expect(globals.fs.file(r'C:\windows\flutter\flutter_export.h').existsSync(), true); + expect(globals.fs.file(r'C:\windows\flutter\flutter_messenger.h').existsSync(), true); + expect(globals.fs.file(r'C:\windows\flutter\flutter_windows.dll').existsSync(), true); + expect(globals.fs.file(r'C:\windows\flutter\flutter_windows.dll.exp').existsSync(), true); + expect(globals.fs.file(r'C:\windows\flutter\flutter_windows.dll.lib').existsSync(), true); + expect(globals.fs.file(r'C:\windows\flutter\flutter_windows.dll.pdb').existsSync(), true); + expect(globals.fs.file(r'C:\windows\flutter\flutter_export.h').existsSync(), true); + expect(globals.fs.file(r'C:\windows\flutter\flutter_messenger.h').existsSync(), true); + expect(globals.fs.file(r'C:\windows\flutter\flutter_plugin_registrar.h').existsSync(), true); + expect(globals.fs.file(r'C:\windows\flutter\flutter_windows.h').existsSync(), true); + expect(globals.fs.file(r'C:\windows\flutter\icudtl.dat').existsSync(), true); + expect(globals.fs.file(r'C:\windows\flutter\cpp_client_wrapper\foo').existsSync(), true); })); test('Does not re-copy files unecessarily', () => testbed.run(() async { @@ -79,10 +81,10 @@ // Set a date in the far distant past to deal with the limited resolution // of the windows filesystem. final DateTime theDistantPast = DateTime(1991, 8, 23); - fs.file(r'C:\windows\flutter\flutter_export.h').setLastModifiedSync(theDistantPast); + globals.fs.file(r'C:\windows\flutter\flutter_export.h').setLastModifiedSync(theDistantPast); await buildSystem.build(const UnpackWindows(), environment); - expect(fs.file(r'C:\windows\flutter\flutter_export.h').statSync().modified, equals(theDistantPast)); + expect(globals.fs.file(r'C:\windows\flutter\flutter_export.h').statSync().modified, equals(theDistantPast)); })); test('Detects changes in input cache files', () => testbed.run(() async { @@ -90,13 +92,13 @@ // Set a date in the far distant past to deal with the limited resolution // of the windows filesystem. final DateTime theDistantPast = DateTime(1991, 8, 23); - fs.file(r'C:\windows\flutter\flutter_export.h').setLastModifiedSync(theDistantPast); - final DateTime modified = fs.file(r'C:\windows\flutter\flutter_export.h').statSync().modified; - fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_export.h').writeAsStringSync('asd'); // modify cache. + globals.fs.file(r'C:\windows\flutter\flutter_export.h').setLastModifiedSync(theDistantPast); + final DateTime modified = globals.fs.file(r'C:\windows\flutter\flutter_export.h').statSync().modified; + globals.fs.file(r'C:\bin\cache\artifacts\engine\windows-x64\flutter_export.h').writeAsStringSync('asd'); // modify cache. await buildSystem.build(const UnpackWindows(), environment); - expect(fs.file(r'C:\windows\flutter\flutter_export.h').statSync().modified, isNot(modified)); + expect(globals.fs.file(r'C:\windows\flutter\flutter_export.h').statSync().modified, isNot(modified)); })); }
diff --git a/packages/flutter_tools/test/general.shard/bundle_shim_test.dart b/packages/flutter_tools/test/general.shard/bundle_shim_test.dart index b4c1376..706bf73 100644 --- a/packages/flutter_tools/test/general.shard/bundle_shim_test.dart +++ b/packages/flutter_tools/test/general.shard/bundle_shim_test.dart
@@ -3,11 +3,11 @@ // found in the LICENSE file. import 'package:flutter_tools/src/base/common.dart'; -import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/build_system/build_system.dart'; import 'package:flutter_tools/src/bundle.dart'; import 'package:flutter_tools/src/project.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import '../src/common.dart'; @@ -35,15 +35,15 @@ await buildWithAssemble( buildMode: BuildMode.debug, flutterProject: FlutterProject.current(), - mainPath: fs.path.join('lib', 'main.dart'), + mainPath: globals.fs.path.join('lib', 'main.dart'), outputDir: 'example', targetPlatform: TargetPlatform.ios, depfilePath: 'example.d', precompiled: false, ); - expect(fs.file(fs.path.join('example', 'kernel_blob.bin')).existsSync(), true); - expect(fs.file(fs.path.join('example', 'LICENSE')).existsSync(), true); - expect(fs.file(fs.path.join('example.d')).existsSync(), false); + expect(globals.fs.file(globals.fs.path.join('example', 'kernel_blob.bin')).existsSync(), true); + expect(globals.fs.file(globals.fs.path.join('example', 'LICENSE')).existsSync(), true); + expect(globals.fs.file(globals.fs.path.join('example.d')).existsSync(), false); })); test('Handles build system failure', () => testbed.run(() {
diff --git a/packages/flutter_tools/test/general.shard/cache_test.dart b/packages/flutter_tools/test/general.shard/cache_test.dart index f77cf52..c0aaf67 100644 --- a/packages/flutter_tools/test/general.shard/cache_test.dart +++ b/packages/flutter_tools/test/general.shard/cache_test.dart
@@ -5,7 +5,7 @@ import 'package:file/file.dart'; import 'package:file/memory.dart'; import 'package:file_testing/file_testing.dart'; -import 'package:flutter_tools/src/base/platform.dart'; + import 'package:meta/meta.dart'; import 'package:mockito/mockito.dart'; import 'package:platform/platform.dart'; @@ -19,6 +19,7 @@ import 'package:flutter_tools/src/base/io.dart' show InternetAddress, SocketException; import 'package:flutter_tools/src/base/net.dart'; import 'package:flutter_tools/src/base/os.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../src/common.dart'; import '../src/context.dart'; @@ -94,8 +95,8 @@ }); testUsingContext('Continues on failed delete', () async { - final Directory artifactDir = fs.systemTempDirectory.createTempSync('flutter_cache_test_artifact.'); - final Directory downloadDir = fs.systemTempDirectory.createTempSync('flutter_cache_test_download.'); + final Directory artifactDir = globals.fs.systemTempDirectory.createTempSync('flutter_cache_test_artifact.'); + final Directory downloadDir = globals.fs.systemTempDirectory.createTempSync('flutter_cache_test_download.'); when(mockCache.getArtifactDirectory(any)).thenReturn(artifactDir); when(mockCache.getDownloadDir()).thenReturn(downloadDir); final File mockFile = MockFile(); @@ -116,10 +117,10 @@ testUsingContext('Gradle wrapper should not be up to date, if some cached artifact is not available', () { final GradleWrapper gradleWrapper = GradleWrapper(mockCache); - final Directory directory = fs.directory('/Applications/flutter/bin/cache'); + final Directory directory = globals.fs.directory('/Applications/flutter/bin/cache'); directory.createSync(recursive: true); - fs.file(fs.path.join(directory.path, 'artifacts', 'gradle_wrapper', 'gradle', 'wrapper', 'gradle-wrapper.jar')).createSync(recursive: true); - when(mockCache.getCacheDir(fs.path.join('artifacts', 'gradle_wrapper'))).thenReturn(fs.directory(fs.path.join(directory.path, 'artifacts', 'gradle_wrapper'))); + globals.fs.file(globals.fs.path.join(directory.path, 'artifacts', 'gradle_wrapper', 'gradle', 'wrapper', 'gradle-wrapper.jar')).createSync(recursive: true); + when(mockCache.getCacheDir(globals.fs.path.join('artifacts', 'gradle_wrapper'))).thenReturn(globals.fs.directory(globals.fs.path.join(directory.path, 'artifacts', 'gradle_wrapper'))); expect(gradleWrapper.isUpToDateInner(), false); }, overrides: <Type, Generator>{ Cache: () => mockCache, @@ -129,13 +130,13 @@ testUsingContext('Gradle wrapper should be up to date, only if all cached artifact are available', () { final GradleWrapper gradleWrapper = GradleWrapper(mockCache); - final Directory directory = fs.directory('/Applications/flutter/bin/cache'); + final Directory directory = globals.fs.directory('/Applications/flutter/bin/cache'); directory.createSync(recursive: true); - fs.file(fs.path.join(directory.path, 'artifacts', 'gradle_wrapper', 'gradle', 'wrapper', 'gradle-wrapper.jar')).createSync(recursive: true); - fs.file(fs.path.join(directory.path, 'artifacts', 'gradle_wrapper', 'gradlew')).createSync(recursive: true); - fs.file(fs.path.join(directory.path, 'artifacts', 'gradle_wrapper', 'gradlew.bat')).createSync(recursive: true); + globals.fs.file(globals.fs.path.join(directory.path, 'artifacts', 'gradle_wrapper', 'gradle', 'wrapper', 'gradle-wrapper.jar')).createSync(recursive: true); + globals.fs.file(globals.fs.path.join(directory.path, 'artifacts', 'gradle_wrapper', 'gradlew')).createSync(recursive: true); + globals.fs.file(globals.fs.path.join(directory.path, 'artifacts', 'gradle_wrapper', 'gradlew.bat')).createSync(recursive: true); - when(mockCache.getCacheDir(fs.path.join('artifacts', 'gradle_wrapper'))).thenReturn(fs.directory(fs.path.join(directory.path, 'artifacts', 'gradle_wrapper'))); + when(mockCache.getCacheDir(globals.fs.path.join('artifacts', 'gradle_wrapper'))).thenReturn(globals.fs.directory(globals.fs.path.join(directory.path, 'artifacts', 'gradle_wrapper'))); expect(gradleWrapper.isUpToDateInner(), true); }, overrides: <Type, Generator>{ Cache: () => mockCache, @@ -226,7 +227,7 @@ }); testUsingContext('Invalid URI for FLUTTER_STORAGE_BASE_URL throws ToolExit', () async { - when(platform.environment).thenReturn(const <String, String>{ + when(globals.platform.environment).thenReturn(const <String, String>{ 'FLUTTER_STORAGE_BASE_URL': ' http://foo', }); final Cache cache = Cache(); @@ -271,8 +272,8 @@ }); testUsingContext('makes binary dirs readable and executable by all', () async { - final Directory artifactDir = fs.systemTempDirectory.createTempSync('flutter_cache_test_artifact.'); - final Directory downloadDir = fs.systemTempDirectory.createTempSync('flutter_cache_test_download.'); + final Directory artifactDir = globals.fs.systemTempDirectory.createTempSync('flutter_cache_test_artifact.'); + final Directory downloadDir = globals.fs.systemTempDirectory.createTempSync('flutter_cache_test_download.'); when(mockCache.getArtifactDirectory(any)).thenReturn(artifactDir); when(mockCache.getDownloadDir()).thenReturn(downloadDir); final FakeCachedArtifact artifact = FakeCachedArtifact( @@ -320,15 +321,15 @@ final AndroidMavenArtifacts mavenArtifacts = AndroidMavenArtifacts(); expect(mavenArtifacts.isUpToDate(), isFalse); - final Directory gradleWrapperDir = fs.systemTempDirectory.createTempSync('flutter_cache_test_gradle_wrapper.'); + final Directory gradleWrapperDir = globals.fs.systemTempDirectory.createTempSync('flutter_cache_test_gradle_wrapper.'); when(mockCache.getArtifactDirectory('gradle_wrapper')).thenReturn(gradleWrapperDir); - fs.directory(gradleWrapperDir.childDirectory('gradle').childDirectory('wrapper')) + globals.fs.directory(gradleWrapperDir.childDirectory('gradle').childDirectory('wrapper')) .createSync(recursive: true); - fs.file(fs.path.join(gradleWrapperDir.path, 'gradlew')).writeAsStringSync('irrelevant'); - fs.file(fs.path.join(gradleWrapperDir.path, 'gradlew.bat')).writeAsStringSync('irrelevant'); + globals.fs.file(globals.fs.path.join(gradleWrapperDir.path, 'gradlew')).writeAsStringSync('irrelevant'); + globals.fs.file(globals.fs.path.join(gradleWrapperDir.path, 'gradlew.bat')).writeAsStringSync('irrelevant'); - when(processManager.run(any, environment: captureAnyNamed('environment'))) + when(globals.processManager.run(any, environment: captureAnyNamed('environment'))) .thenAnswer((Invocation invocation) { final List<String> args = invocation.positionalArguments[0] as List<String>; expect(args.length, 6); @@ -358,7 +359,7 @@ testUsingContext('verifies executables for libimobiledevice in isUpToDateInner', () async { final IosUsbArtifacts iosUsbArtifacts = IosUsbArtifacts('libimobiledevice', mockCache); - when(mockCache.getArtifactDirectory(any)).thenReturn(fs.currentDirectory); + when(mockCache.getArtifactDirectory(any)).thenReturn(globals.fs.currentDirectory); iosUsbArtifacts.location.createSync(); final File ideviceIdFile = iosUsbArtifacts.location.childFile('idevice_id') ..createSync(); @@ -378,7 +379,7 @@ testUsingContext('Does not verify executables for openssl in isUpToDateInner', () async { final IosUsbArtifacts iosUsbArtifacts = IosUsbArtifacts('openssl', mockCache); - when(mockCache.getArtifactDirectory(any)).thenReturn(fs.currentDirectory); + when(mockCache.getArtifactDirectory(any)).thenReturn(globals.fs.currentDirectory); iosUsbArtifacts.location.createSync(); expect(iosUsbArtifacts.isUpToDateInner(), true); @@ -427,7 +428,7 @@ mockPackageResolver.resolveUrl('fuchsia-debug-symbols-arm64', any), ]); }); - }, skip: !platform.isLinux); + }, skip: !globals.platform.isLinux); } class FakeCachedArtifact extends EngineCachedArtifact {
diff --git a/packages/flutter_tools/test/general.shard/channel_test.dart b/packages/flutter_tools/test/general.shard/channel_test.dart index dbd87fa..51e7cb5 100644 --- a/packages/flutter_tools/test/general.shard/channel_test.dart +++ b/packages/flutter_tools/test/general.shard/channel_test.dart
@@ -9,6 +9,7 @@ import 'package:file/memory.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/cache.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/commands/channel.dart'; import 'package:flutter_tools/src/version.dart'; import 'package:mockito/mockito.dart'; @@ -180,7 +181,7 @@ environment: anyNamed('environment'), )).thenAnswer((_) => Future<Process>.value(createMockProcess())); - final File versionCheckFile = Cache.instance.getStampFileFor( + final File versionCheckFile = globals.cache.getStampFileFor( VersionCheckStamp.flutterVersionCheckStampFile, );
diff --git a/packages/flutter_tools/test/general.shard/commands/build_aar_test.dart b/packages/flutter_tools/test/general.shard/commands/build_aar_test.dart index 303dcd0..cfb15a4 100644 --- a/packages/flutter_tools/test/general.shard/commands/build_aar_test.dart +++ b/packages/flutter_tools/test/general.shard/commands/build_aar_test.dart
@@ -12,6 +12,7 @@ import 'package:flutter_tools/src/commands/build_aar.dart'; import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/reporting/reporting.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; @@ -27,7 +28,7 @@ Directory tempDir; setUp(() { - tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.'); + tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.'); }); tearDown(() { @@ -94,7 +95,7 @@ mockUsage = MockUsage(); when(mockUsage.isFirstRun).thenReturn(true); - tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.'); + tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.'); mockProcessManager = MockProcessManager(); when(mockProcessManager.run(any, @@ -149,7 +150,7 @@ arguments: <String>['--no-pub'], ); }, throwsToolExit( - message: '[!] No Android SDK found. Try setting the ANDROID_HOME environment variable', + message: 'No Android SDK found. Try setting the ANDROID_HOME environment variable', )); }, overrides: <Type, Generator>{ @@ -171,7 +172,7 @@ 'aar', '--no-pub', ...?arguments, - fs.path.join(target, 'lib', 'main.dart'), + globals.fs.path.join(target, 'lib', 'main.dart'), ]); return command; }
diff --git a/packages/flutter_tools/test/general.shard/commands/build_apk_test.dart b/packages/flutter_tools/test/general.shard/commands/build_apk_test.dart index 88900ab..50569cb 100644 --- a/packages/flutter_tools/test/general.shard/commands/build_apk_test.dart +++ b/packages/flutter_tools/test/general.shard/commands/build_apk_test.dart
@@ -9,11 +9,12 @@ import 'package:flutter_tools/src/android/android_sdk.dart'; import 'package:flutter_tools/src/base/context.dart'; import 'package:flutter_tools/src/base/file_system.dart'; -import 'package:flutter_tools/src/base/platform.dart'; + import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/commands/build_apk.dart'; import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/reporting/reporting.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; @@ -29,7 +30,7 @@ Directory tempDir; setUp(() { - tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.'); + tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.'); }); tearDown(() { @@ -104,9 +105,9 @@ mockUsage = MockUsage(); when(mockUsage.isFirstRun).thenReturn(true); - tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.'); - gradlew = fs.path.join(tempDir.path, 'flutter_project', 'android', - platform.isWindows ? 'gradlew.bat' : 'gradlew'); + tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.'); + gradlew = globals.fs.path.join(tempDir.path, 'flutter_project', 'android', + globals.platform.isWindows ? 'gradlew.bat' : 'gradlew'); mockProcessManager = MockProcessManager(); when(mockProcessManager.run(<String>[gradlew, '-v'], @@ -170,7 +171,7 @@ arguments: <String>['--no-pub'], ); }, throwsToolExit( - message: '[!] No Android SDK found. Try setting the ANDROID_HOME environment variable', + message: 'No Android SDK found. Try setting the ANDROID_HOME environment variable', )); }, overrides: <Type, Generator>{ @@ -192,7 +193,7 @@ <String>[ gradlew, '-q', - '-Ptarget=${fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', + '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', '-Ptrack-widget-creation=true', '-Pshrink=true', '-Ptarget-platform=android-arm,android-arm64,android-x64', @@ -223,7 +224,7 @@ <String>[ gradlew, '-q', - '-Ptarget=${fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', + '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', '-Ptrack-widget-creation=true', '-Ptarget-platform=android-arm,android-arm64,android-x64', 'assembleRelease', @@ -246,7 +247,7 @@ <String>[ gradlew, '-q', - '-Ptarget=${fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', + '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', '-Ptrack-widget-creation=true', '-Pshrink=true', '-Ptarget-platform=android-arm,android-arm64,android-x64', @@ -301,7 +302,7 @@ <String>[ gradlew, '-q', - '-Ptarget=${fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', + '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', '-Ptrack-widget-creation=true', '-Pshrink=true', '-Ptarget-platform=android-arm,android-arm64,android-x64', @@ -352,7 +353,7 @@ <String>[ gradlew, '-q', - '-Ptarget=${fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', + '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', '-Ptrack-widget-creation=true', '-Pshrink=true', '-Ptarget-platform=android-arm,android-arm64,android-x64', @@ -409,7 +410,7 @@ 'apk', ...?arguments, '--no-pub', - fs.path.join(target, 'lib', 'main.dart'), + globals.fs.path.join(target, 'lib', 'main.dart'), ]); return command; }
diff --git a/packages/flutter_tools/test/general.shard/commands/build_appbundle_test.dart b/packages/flutter_tools/test/general.shard/commands/build_appbundle_test.dart index bccbd0d..fc48b8d 100644 --- a/packages/flutter_tools/test/general.shard/commands/build_appbundle_test.dart +++ b/packages/flutter_tools/test/general.shard/commands/build_appbundle_test.dart
@@ -9,11 +9,12 @@ import 'package:flutter_tools/src/android/android_sdk.dart'; import 'package:flutter_tools/src/base/context.dart'; import 'package:flutter_tools/src/base/file_system.dart'; -import 'package:flutter_tools/src/base/platform.dart'; + import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/commands/build_appbundle.dart'; import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/reporting/reporting.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; @@ -29,7 +30,7 @@ Directory tempDir; setUp(() { - tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.'); + tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.'); }); tearDown(() { @@ -83,14 +84,13 @@ String gradlew; Usage mockUsage; - setUp(() { mockUsage = MockUsage(); when(mockUsage.isFirstRun).thenReturn(true); - tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.'); - gradlew = fs.path.join(tempDir.path, 'flutter_project', 'android', - platform.isWindows ? 'gradlew.bat' : 'gradlew'); + tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_packages_test.'); + gradlew = globals.fs.path.join(tempDir.path, 'flutter_project', 'android', + globals.platform.isWindows ? 'gradlew.bat' : 'gradlew'); mockProcessManager = MockProcessManager(); when(mockProcessManager.run(<String>[gradlew, '-v'], @@ -155,7 +155,7 @@ arguments: <String>['--no-pub'], ); }, throwsToolExit( - message: '[!] No Android SDK found. Try setting the ANDROID_HOME environment variable', + message: 'No Android SDK found. Try setting the ANDROID_HOME environment variable', )); }, overrides: <Type, Generator>{ @@ -179,7 +179,7 @@ <String>[ gradlew, '-q', - '-Ptarget=${fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', + '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', '-Ptrack-widget-creation=false', '-Pshrink=true', '-Ptarget-platform=android-arm,android-arm64,android-x64', @@ -212,7 +212,7 @@ <String>[ gradlew, '-q', - '-Ptarget=${fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', + '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', '-Ptrack-widget-creation=false', '-Ptarget-platform=android-arm,android-arm64,android-x64', 'bundleRelease', @@ -235,7 +235,7 @@ <String>[ gradlew, '-q', - '-Ptarget=${fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', + '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', '-Ptrack-widget-creation=false', '-Pshrink=true', '-Ptarget-platform=android-arm,android-arm64,android-x64', @@ -290,7 +290,7 @@ <String>[ gradlew, '-q', - '-Ptarget=${fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', + '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', '-Ptrack-widget-creation=false', '-Pshrink=true', '-Ptarget-platform=android-arm,android-arm64,android-x64', @@ -341,7 +341,7 @@ <String>[ gradlew, '-q', - '-Ptarget=${fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', + '-Ptarget=${globals.fs.path.join(tempDir.path, 'flutter_project', 'lib', 'main.dart')}', '-Ptrack-widget-creation=false', '-Pshrink=true', '-Ptarget-platform=android-arm,android-arm64,android-x64', @@ -398,7 +398,7 @@ 'appbundle', ...?arguments, '--no-pub', - fs.path.join(target, 'lib', 'main.dart'), + globals.fs.path.join(target, 'lib', 'main.dart'), ]); return command; }
diff --git a/packages/flutter_tools/test/general.shard/compile_batch_test.dart b/packages/flutter_tools/test/general.shard/compile_batch_test.dart index 4b498a3..adf6027 100644 --- a/packages/flutter_tools/test/general.shard/compile_batch_test.dart +++ b/packages/flutter_tools/test/general.shard/compile_batch_test.dart
@@ -5,13 +5,14 @@ import 'dart:async'; import 'package:flutter_tools/src/base/io.dart'; -import 'package:flutter_tools/src/base/platform.dart'; + import 'package:flutter_tools/src/base/terminal.dart'; import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/compile.dart'; import 'package:flutter_tools/src/convert.dart'; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; +import 'package:platform/platform.dart'; import '../src/common.dart'; import '../src/context.dart';
diff --git a/packages/flutter_tools/test/general.shard/compile_expression_test.dart b/packages/flutter_tools/test/general.shard/compile_expression_test.dart index fbb654b..eaa7f25 100644 --- a/packages/flutter_tools/test/general.shard/compile_expression_test.dart +++ b/packages/flutter_tools/test/general.shard/compile_expression_test.dart
@@ -7,13 +7,13 @@ import 'package:flutter_tools/src/base/common.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'; import 'package:flutter_tools/src/base/terminal.dart'; import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/compile.dart'; import 'package:flutter_tools/src/convert.dart'; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; +import 'package:platform/platform.dart'; import '../src/common.dart'; import '../src/context.dart';
diff --git a/packages/flutter_tools/test/general.shard/compile_incremental_test.dart b/packages/flutter_tools/test/general.shard/compile_incremental_test.dart index f11e9c6..9279c8b 100644 --- a/packages/flutter_tools/test/general.shard/compile_incremental_test.dart +++ b/packages/flutter_tools/test/general.shard/compile_incremental_test.dart
@@ -7,13 +7,13 @@ import 'package:flutter_tools/src/base/async_guard.dart'; import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/io.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/terminal.dart'; import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/compile.dart'; import 'package:flutter_tools/src/convert.dart'; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; +import 'package:platform/platform.dart'; import '../src/common.dart'; import '../src/context.dart';
diff --git a/packages/flutter_tools/test/general.shard/crash_reporting_test.dart b/packages/flutter_tools/test/general.shard/crash_reporting_test.dart index 134a914..7a86004 100644 --- a/packages/flutter_tools/test/general.shard/crash_reporting_test.dart +++ b/packages/flutter_tools/test/general.shard/crash_reporting_test.dart
@@ -12,14 +12,15 @@ import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/context.dart'; import 'package:flutter_tools/src/base/io.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/doctor.dart'; import 'package:flutter_tools/src/reporting/reporting.dart'; import 'package:flutter_tools/src/runner/flutter_command.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:http/http.dart'; import 'package:http/testing.dart'; import 'package:quiver/testing/async.dart'; +import 'package:platform/platform.dart'; import '../src/common.dart'; import '../src/context.dart'; @@ -251,7 +252,7 @@ expect(crashInfo.fields['uuid'], '00000000-0000-4000-0000-000000000000'); expect(crashInfo.fields['product'], 'Flutter_Tools'); expect(crashInfo.fields['version'], 'test-version'); - expect(crashInfo.fields['osName'], platform.operatingSystem); + expect(crashInfo.fields['osName'], globals.platform.operatingSystem); expect(crashInfo.fields['osVersion'], 'fake OS name and version'); expect(crashInfo.fields['type'], 'DartError'); expect(crashInfo.fields['error_runtime_type'], 'StateError');
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 8b5eae7..3e6911c 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
@@ -11,15 +11,16 @@ import 'package:flutter_tools/src/base/context.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/utils.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/dart/pub.dart'; import 'package:flutter_tools/src/reporting/reporting.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; import 'package:quiver/testing/async.dart'; +import 'package:platform/platform.dart'; import '../../src/common.dart'; import '../../src/context.dart'; @@ -258,7 +259,7 @@ '--no-precompile', ], onRun: () { - fs.file('.packages') + globals.fs.file('.packages') ..setLastModifiedSync(DateTime(2002)); } ), @@ -278,7 +279,7 @@ '--no-precompile', ], onRun: () { - fs.file('pubspec.yaml') + globals.fs.file('pubspec.yaml') ..setLastModifiedSync(DateTime(2002)); } ), @@ -293,35 +294,35 @@ ]); await Testbed().run(() async { // the good scenario: .packages is old, pub updates the file. - fs.file('.packages') + globals.fs.file('.packages') ..createSync() ..setLastModifiedSync(DateTime(2000)); - fs.file('pubspec.yaml') + globals.fs.file('pubspec.yaml') ..createSync() ..setLastModifiedSync(DateTime(2001)); await pub.get(context: PubContext.flutterTests, checkLastModified: true); // pub sets date of .packages to 2002 expect(testLogger.statusText, 'Running "flutter pub get" in /...\n'); expect(testLogger.errorText, isEmpty); - expect(fs.file('pubspec.yaml').lastModifiedSync(), DateTime(2001)); // because nothing should touch it - expect(fs.file('.packages').lastModifiedSync(), isNot(DateTime(2000))); // because pub changes it to 2002 - expect(fs.file('.packages').lastModifiedSync(), isNot(DateTime(2002))); // because we set the timestamp again after pub + expect(globals.fs.file('pubspec.yaml').lastModifiedSync(), DateTime(2001)); // because nothing should touch it + expect(globals.fs.file('.packages').lastModifiedSync(), isNot(DateTime(2000))); // because pub changes it to 2002 + expect(globals.fs.file('.packages').lastModifiedSync(), isNot(DateTime(2002))); // because we set the timestamp again after pub testLogger.clear(); // bad scenario 1: pub doesn't update file; doesn't matter, because we do instead - fs.file('.packages') + globals.fs.file('.packages') ..setLastModifiedSync(DateTime(2000)); - fs.file('pubspec.yaml') + globals.fs.file('pubspec.yaml') ..setLastModifiedSync(DateTime(2001)); await pub.get(context: PubContext.flutterTests, checkLastModified: true); // pub does nothing expect(testLogger.statusText, 'Running "flutter pub get" in /...\n'); expect(testLogger.errorText, isEmpty); - expect(fs.file('pubspec.yaml').lastModifiedSync(), DateTime(2001)); // because nothing should touch it - expect(fs.file('.packages').lastModifiedSync(), isNot(DateTime(2000))); // because we set the timestamp - expect(fs.file('.packages').lastModifiedSync(), isNot(DateTime(2002))); // just in case FakeProcessManager is buggy + expect(globals.fs.file('pubspec.yaml').lastModifiedSync(), DateTime(2001)); // because nothing should touch it + expect(globals.fs.file('.packages').lastModifiedSync(), isNot(DateTime(2000))); // because we set the timestamp + expect(globals.fs.file('.packages').lastModifiedSync(), isNot(DateTime(2002))); // just in case FakeProcessManager is buggy testLogger.clear(); // bad scenario 2: pub changes pubspec.yaml instead - fs.file('.packages') + globals.fs.file('.packages') ..setLastModifiedSync(DateTime(2000)); - fs.file('pubspec.yaml') + globals.fs.file('pubspec.yaml') ..setLastModifiedSync(DateTime(2001)); try { await pub.get(context: PubContext.flutterTests, checkLastModified: true); @@ -332,12 +333,12 @@ } expect(testLogger.statusText, 'Running "flutter pub get" in /...\n'); expect(testLogger.errorText, isEmpty); - expect(fs.file('pubspec.yaml').lastModifiedSync(), DateTime(2002)); // because fake pub above touched it - expect(fs.file('.packages').lastModifiedSync(), DateTime(2000)); // because nothing touched it + expect(globals.fs.file('pubspec.yaml').lastModifiedSync(), DateTime(2002)); // because fake pub above touched it + expect(globals.fs.file('.packages').lastModifiedSync(), DateTime(2000)); // because nothing touched it // bad scenario 3: pubspec.yaml was created in the future - fs.file('.packages') + globals.fs.file('.packages') ..setLastModifiedSync(DateTime(2000)); - fs.file('pubspec.yaml') + globals.fs.file('pubspec.yaml') ..setLastModifiedSync(DateTime(9999)); assert(DateTime(9999).isAfter(DateTime.now())); await pub.get(context: PubContext.flutterTests, checkLastModified: true); // pub does nothing
diff --git a/packages/flutter_tools/test/general.shard/dart/sdk_validation_test.dart b/packages/flutter_tools/test/general.shard/dart/sdk_validation_test.dart index 90f3535..9d864c1 100644 --- a/packages/flutter_tools/test/general.shard/dart/sdk_validation_test.dart +++ b/packages/flutter_tools/test/general.shard/dart/sdk_validation_test.dart
@@ -9,6 +9,7 @@ import 'package:flutter_tools/src/dart/analysis.dart'; import 'package:flutter_tools/src/dart/pub.dart'; import 'package:flutter_tools/src/dart/sdk.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../../src/common.dart'; import '../../src/context.dart'; @@ -23,10 +24,10 @@ void testSampleProject(String lib, String member) { testUsingContext('contains dart:$lib', () async { Cache.disableLocking(); - final Directory projectDirectory = fs.systemTempDirectory.createTempSync('flutter_sdk_validation_${lib}_test.').absolute; + final Directory projectDirectory = globals.fs.systemTempDirectory.createTempSync('flutter_sdk_validation_${lib}_test.').absolute; try { - final File pubspecFile = fs.file(fs.path.join(projectDirectory.path, 'pubspec.yaml')); + final File pubspecFile = globals.fs.file(globals.fs.path.join(projectDirectory.path, 'pubspec.yaml')); pubspecFile.writeAsStringSync(''' name: ${lib}_project dependencies: @@ -34,7 +35,7 @@ sdk: flutter '''); - final File dartFile = fs.file(fs.path.join(projectDirectory.path, 'lib', 'main.dart')); + final File dartFile = globals.fs.file(globals.fs.path.join(projectDirectory.path, 'lib', 'main.dart')); dartFile.parent.createSync(); dartFile.writeAsStringSync(''' import 'dart:$lib' as $lib;
diff --git a/packages/flutter_tools/test/general.shard/devfs_test.dart b/packages/flutter_tools/test/general.shard/devfs_test.dart index ce6e0e5..f56b6f0 100644 --- a/packages/flutter_tools/test/general.shard/devfs_test.dart +++ b/packages/flutter_tools/test/general.shard/devfs_test.dart
@@ -14,6 +14,7 @@ import 'package:flutter_tools/src/compile.dart'; import 'package:flutter_tools/src/devfs.dart'; import 'package:flutter_tools/src/vmservice.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:json_rpc_2/json_rpc_2.dart' as rpc; import 'package:mockito/mockito.dart'; @@ -29,7 +30,7 @@ setUpAll(() { fs = MemoryFileSystem(); - filePath = fs.path.join('lib', 'foo.txt'); + filePath = globals.fs.path.join('lib', 'foo.txt'); }); group('DevFSContent', () { @@ -61,7 +62,7 @@ expect(content.isModified, isFalse); }); testUsingContext('file', () async { - final File file = fs.file(filePath); + final File file = globals.fs.file(filePath); final DevFSFileContent content = DevFSFileContent(file); expect(content.isModified, isFalse); expect(content.isModified, isFalse); @@ -110,7 +111,7 @@ }); testUsingContext('retry uploads when failure', () async { - final File file = fs.file(fs.path.join(basePath, filePath)); + final File file = globals.fs.file(globals.fs.path.join(basePath, filePath)); await file.parent.create(recursive: true); file.writeAsBytesSync(<int>[1, 2, 3]); // simulate package @@ -188,7 +189,7 @@ testUsingContext('create dev file system', () async { // simulate workspace - final File file = fs.file(fs.path.join(basePath, filePath)); + final File file = globals.fs.file(globals.fs.path.join(basePath, filePath)); await file.parent.create(recursive: true); file.writeAsBytesSync(<int>[1, 2, 3]); @@ -230,7 +231,7 @@ testUsingContext('cleanup preexisting file system', () async { // simulate workspace - final File file = fs.file(fs.path.join(basePath, filePath)); + final File file = globals.fs.file(globals.fs.path.join(basePath, filePath)); await file.parent.create(recursive: true); file.writeAsBytesSync(<int>[1, 2, 3]); @@ -297,7 +298,7 @@ outputPath: anyNamed('outputPath'), packagesFilePath: anyNamed('packagesFilePath'), )).thenAnswer((Invocation invocation) { - fs.file('example').createSync(); + globals.fs.file('example').createSync(); return Future<CompilerOutput>.value(CompilerOutput('example', 0, <Uri>[sourceFile.uri])); }); @@ -417,7 +418,7 @@ final Map <String, Uri> _packages = <String, Uri>{}; Directory _newTempDir(FileSystem fs) { - final Directory tempDir = fs.systemTempDirectory.createTempSync('flutter_devfs${_tempDirs.length}_test.'); + final Directory tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_devfs${_tempDirs.length}_test.'); _tempDirs.add(tempDir); return tempDir; } @@ -430,21 +431,21 @@ Future<File> _createPackage(FileSystem fs, String pkgName, String pkgFileName, { bool doubleSlash = false }) async { final Directory pkgTempDir = _newTempDir(fs); - String pkgFilePath = fs.path.join(pkgTempDir.path, pkgName, 'lib', pkgFileName); + String pkgFilePath = globals.fs.path.join(pkgTempDir.path, pkgName, 'lib', pkgFileName); if (doubleSlash) { // Force two separators into the path. - final String doubleSlash = fs.path.separator + fs.path.separator; - pkgFilePath = pkgTempDir.path + doubleSlash + fs.path.join(pkgName, 'lib', pkgFileName); + final String doubleSlash = globals.fs.path.separator + globals.fs.path.separator; + pkgFilePath = pkgTempDir.path + doubleSlash + globals.fs.path.join(pkgName, 'lib', pkgFileName); } - final File pkgFile = fs.file(pkgFilePath); + final File pkgFile = globals.fs.file(pkgFilePath); await pkgFile.parent.create(recursive: true); pkgFile.writeAsBytesSync(<int>[11, 12, 13]); - _packages[pkgName] = fs.path.toUri(pkgFile.parent.path); + _packages[pkgName] = globals.fs.path.toUri(pkgFile.parent.path); final StringBuffer sb = StringBuffer(); _packages.forEach((String pkgName, Uri pkgUri) { sb.writeln('$pkgName:$pkgUri'); }); - return fs.file(fs.path.join(_tempDirs[0].path, '.packages')) + return globals.fs.file(globals.fs.path.join(_tempDirs[0].path, '.packages')) ..writeAsStringSync(sb.toString()); }
diff --git a/packages/flutter_tools/test/general.shard/features_test.dart b/packages/flutter_tools/test/general.shard/features_test.dart index 5891260..8dea6b0 100644 --- a/packages/flutter_tools/test/general.shard/features_test.dart +++ b/packages/flutter_tools/test/general.shard/features_test.dart
@@ -4,9 +4,9 @@ import 'package:flutter_tools/src/base/config.dart'; import 'package:flutter_tools/src/features.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/version.dart'; import 'package:mockito/mockito.dart'; +import 'package:platform/platform.dart'; import '../src/common.dart'; import '../src/testbed.dart';
diff --git a/packages/flutter_tools/test/general.shard/flutter_platform_test.dart b/packages/flutter_tools/test/general.shard/flutter_platform_test.dart index 26d00d6..fb9f9f1 100644 --- a/packages/flutter_tools/test/general.shard/flutter_platform_test.dart +++ b/packages/flutter_tools/test/general.shard/flutter_platform_test.dart
@@ -5,10 +5,10 @@ import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/io.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/test/flutter_platform.dart'; import 'package:meta/meta.dart'; +import 'package:platform/platform.dart'; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; import 'package:test_core/backend.dart'; // ignore: deprecated_member_use
diff --git a/packages/flutter_tools/test/general.shard/forbidden_imports_test.dart b/packages/flutter_tools/test/general.shard/forbidden_imports_test.dart index bd74954..dce6b55 100644 --- a/packages/flutter_tools/test/general.shard/forbidden_imports_test.dart +++ b/packages/flutter_tools/test/general.shard/forbidden_imports_test.dart
@@ -3,20 +3,21 @@ // found in the LICENSE file. import 'package:flutter_tools/src/base/file_system.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../src/common.dart'; void main() { - final String flutterTools = fs.path.join(getFlutterRoot(), 'packages', 'flutter_tools'); + final String flutterTools = globals.fs.path.join(getFlutterRoot(), 'packages', 'flutter_tools'); test('no imports of commands/* or test/* in lib/src/*', () { final List<String> skippedPaths = <String> [ - fs.path.join(flutterTools, 'lib', 'src', 'commands'), - fs.path.join(flutterTools, 'lib', 'src', 'test'), + globals.fs.path.join(flutterTools, 'lib', 'src', 'commands'), + globals.fs.path.join(flutterTools, 'lib', 'src', 'test'), ]; bool _isNotSkipped(FileSystemEntity entity) => skippedPaths.every((String path) => !entity.path.startsWith(path)); - final Iterable<File> files = fs.directory(fs.path.join(flutterTools, 'lib', 'src')) + final Iterable<File> files = globals.fs.directory(globals.fs.path.join(flutterTools, 'lib', 'src')) .listSync(recursive: true) .where(_isDartFile) .where(_isNotSkipped) @@ -28,7 +29,7 @@ } if (line.startsWith(RegExp(r'import.*commands/')) || line.startsWith(RegExp(r'import.*test/'))) { - final String relativePath = fs.path.relative(file.path, from:flutterTools); + final String relativePath = globals.fs.path.relative(file.path, from:flutterTools); fail('$relativePath imports $line. This import introduces a layering violation. ' 'Please find another way to access the information you are using.'); } @@ -36,15 +37,36 @@ } }); + test('no imports of globals without a global prefix', () { + final List<String> skippedPaths = <String> []; + bool _isNotSkipped(FileSystemEntity entity) => skippedPaths.every((String path) => !entity.path.startsWith(path)); + + final Iterable<File> files = globals.fs.directory(globals.fs.path.join(flutterTools, 'lib', 'src')) + .listSync(recursive: true) + .followedBy(globals.fs.directory(globals.fs.path.join(flutterTools, 'test',)).listSync(recursive: true)) + .where(_isDartFile) + .where(_isNotSkipped) + .map(_asFile); + for (File file in files) { + for (String line in file.readAsLinesSync()) { + if (line.startsWith(RegExp(r'import.*globals.dart')) + && !line.contains(r'as globals')) { + final String relativePath = globals.fs.path.relative(file.path, from:flutterTools); + fail('$relativePath imports globals.dart without a globals prefix.'); + } + } + } + }); + test('no unauthorized imports of dart:io', () { final List<String> whitelistedPaths = <String>[ - fs.path.join(flutterTools, 'lib', 'src', 'base', 'io.dart'), - fs.path.join(flutterTools, 'lib', 'src', 'base', 'error_handling_file_system.dart'), + globals.fs.path.join(flutterTools, 'lib', 'src', 'base', 'io.dart'), + globals.fs.path.join(flutterTools, 'lib', 'src', 'base', 'error_handling_file_system.dart'), ]; bool _isNotWhitelisted(FileSystemEntity entity) => whitelistedPaths.every((String path) => path != entity.path); for (String dirName in <String>['lib', 'bin']) { - final Iterable<File> files = fs.directory(fs.path.join(flutterTools, dirName)) + final Iterable<File> files = globals.fs.directory(globals.fs.path.join(flutterTools, dirName)) .listSync(recursive: true) .where(_isDartFile) .where(_isNotWhitelisted) @@ -53,7 +75,7 @@ for (String line in file.readAsLinesSync()) { if (line.startsWith(RegExp(r'import.*dart:io')) && !line.contains('ignore: dart_io_import')) { - final String relativePath = fs.path.relative(file.path, from:flutterTools); + final String relativePath = globals.fs.path.relative(file.path, from:flutterTools); fail("$relativePath imports 'dart:io'; import 'lib/src/base/io.dart' instead"); } } @@ -63,15 +85,15 @@ test('no unauthorized imports of test_api', () { final List<String> whitelistedPaths = <String>[ - fs.path.join(flutterTools, 'lib', 'src', 'build_runner', 'build_script.dart'), - fs.path.join(flutterTools, 'lib', 'src', 'test', 'flutter_platform.dart'), - fs.path.join(flutterTools, 'lib', 'src', 'test', 'flutter_web_platform.dart'), - fs.path.join(flutterTools, 'lib', 'src', 'test', 'test_wrapper.dart'), + globals.fs.path.join(flutterTools, 'lib', 'src', 'build_runner', 'build_script.dart'), + globals.fs.path.join(flutterTools, 'lib', 'src', 'test', 'flutter_platform.dart'), + globals.fs.path.join(flutterTools, 'lib', 'src', 'test', 'flutter_web_platform.dart'), + globals.fs.path.join(flutterTools, 'lib', 'src', 'test', 'test_wrapper.dart'), ]; bool _isNotWhitelisted(FileSystemEntity entity) => whitelistedPaths.every((String path) => path != entity.path); for (String dirName in <String>['lib']) { - final Iterable<File> files = fs.directory(fs.path.join(flutterTools, dirName)) + final Iterable<File> files = globals.fs.directory(globals.fs.path.join(flutterTools, dirName)) .listSync(recursive: true) .where(_isDartFile) .where(_isNotWhitelisted) @@ -80,7 +102,7 @@ for (String line in file.readAsLinesSync()) { if (line.startsWith(RegExp(r'import.*package:test_api')) && !line.contains('ignore: test_api_import')) { - final String relativePath = fs.path.relative(file.path, from:flutterTools); + final String relativePath = globals.fs.path.relative(file.path, from:flutterTools); fail("$relativePath imports 'package:test_api/test_api.dart';"); } } @@ -89,9 +111,9 @@ }); test('no unauthorized imports of package:path', () { - final String whitelistedPath = fs.path.join(flutterTools, 'lib', 'src', 'build_runner', 'web_compilation_delegate.dart'); + final String whitelistedPath = globals.fs.path.join(flutterTools, 'lib', 'src', 'build_runner', 'web_compilation_delegate.dart'); for (String dirName in <String>['lib', 'bin', 'test']) { - final Iterable<File> files = fs.directory(fs.path.join(flutterTools, dirName)) + final Iterable<File> files = globals.fs.directory(globals.fs.path.join(flutterTools, dirName)) .listSync(recursive: true) .where(_isDartFile) .where((FileSystemEntity entity) => entity.path != whitelistedPath) @@ -100,8 +122,8 @@ for (String line in file.readAsLinesSync()) { if (line.startsWith(RegExp(r'import.*package:path/path.dart')) && !line.contains('ignore: package_path_import')) { - final String relativePath = fs.path.relative(file.path, from:flutterTools); - fail("$relativePath imports 'package:path/path.dart'; use 'fs.path' instead"); + final String relativePath = globals.fs.path.relative(file.path, from:flutterTools); + fail("$relativePath imports 'package:path/path.dart'; use 'globals.fs.path' instead"); } } } @@ -110,13 +132,13 @@ test('no unauthorized imports of dart:convert', () { final List<String> whitelistedPaths = <String>[ - fs.path.join(flutterTools, 'lib', 'src', 'convert.dart'), - fs.path.join(flutterTools, 'lib', 'src', 'base', 'error_handling_file_system.dart'), + globals.fs.path.join(flutterTools, 'lib', 'src', 'convert.dart'), + globals.fs.path.join(flutterTools, 'lib', 'src', 'base', 'error_handling_file_system.dart'), ]; bool _isNotWhitelisted(FileSystemEntity entity) => whitelistedPaths.every((String path) => path != entity.path); for (String dirName in <String>['lib']) { - final Iterable<File> files = fs.directory(fs.path.join(flutterTools, dirName)) + final Iterable<File> files = globals.fs.directory(globals.fs.path.join(flutterTools, dirName)) .listSync(recursive: true) .where(_isDartFile) .where(_isNotWhitelisted) @@ -125,7 +147,7 @@ for (String line in file.readAsLinesSync()) { if (line.startsWith(RegExp(r'import.*dart:convert')) && !line.contains('ignore: dart_convert_import')) { - final String relativePath = fs.path.relative(file.path, from:flutterTools); + final String relativePath = globals.fs.path.relative(file.path, from:flutterTools); fail("$relativePath imports 'dart:convert'; import 'lib/src/convert.dart' instead"); } } @@ -135,14 +157,14 @@ test('no unauthorized imports of build_runner', () { final List<String> whitelistedPaths = <String>[ - fs.path.join(flutterTools, 'test', 'src', 'build_runner'), - fs.path.join(flutterTools, 'lib', 'src', 'build_runner'), - fs.path.join(flutterTools, 'lib', 'executable.dart'), + globals.fs.path.join(flutterTools, 'test', 'src', 'build_runner'), + globals.fs.path.join(flutterTools, 'lib', 'src', 'build_runner'), + globals.fs.path.join(flutterTools, 'lib', 'executable.dart'), ]; bool _isNotWhitelisted(FileSystemEntity entity) => whitelistedPaths.every((String path) => !entity.path.contains(path)); for (String dirName in <String>['lib']) { - final Iterable<File> files = fs.directory(fs.path.join(flutterTools, dirName)) + final Iterable<File> files = globals.fs.directory(globals.fs.path.join(flutterTools, dirName)) .listSync(recursive: true) .where(_isDartFile) .where(_isNotWhitelisted) @@ -153,7 +175,7 @@ line.startsWith(RegExp(r'import.*package:build_runner/build_runner.dart')) || line.startsWith(RegExp(r'import.*package:build_config/build_config.dart')) || line.startsWith(RegExp(r'import.*build_runner/.*.dart'))) { - final String relativePath = fs.path.relative(file.path, from:flutterTools); + final String relativePath = globals.fs.path.relative(file.path, from:flutterTools); fail('$relativePath imports a build_runner package'); } }
diff --git a/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart b/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart index d009ea3..d5b4e58 100644 --- a/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart +++ b/packages/flutter_tools/test/general.shard/fuchsia/fuchsia_device_test.dart
@@ -25,7 +25,7 @@ import 'package:flutter_tools/src/fuchsia/fuchsia_pm.dart'; import 'package:flutter_tools/src/fuchsia/fuchsia_sdk.dart'; import 'package:flutter_tools/src/fuchsia/tiles_ctl.dart'; -import 'package:flutter_tools/src/globals.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/vmservice.dart'; import 'package:meta/meta.dart'; @@ -81,8 +81,8 @@ testUsingContext('default capabilities', () async { final FuchsiaDevice device = FuchsiaDevice('123'); - fs.directory('fuchsia').createSync(recursive: true); - fs.file('pubspec.yaml').createSync(); + globals.fs.directory('fuchsia').createSync(recursive: true); + globals.fs.file('pubspec.yaml').createSync(); expect(device.supportsHotReload, true); expect(device.supportsHotRestart, false); @@ -95,8 +95,8 @@ testUsingContext('supported for project', () async { final FuchsiaDevice device = FuchsiaDevice('123'); - fs.directory('fuchsia').createSync(recursive: true); - fs.file('pubspec.yaml').createSync(); + globals.fs.directory('fuchsia').createSync(recursive: true); + globals.fs.file('pubspec.yaml').createSync(); expect(device.isSupportedForProject(FlutterProject.current()), true); }, overrides: <Type, Generator>{ FileSystem: () => memoryFileSystem, @@ -105,7 +105,7 @@ testUsingContext('not supported for project', () async { final FuchsiaDevice device = FuchsiaDevice('123'); - fs.file('pubspec.yaml').createSync(); + globals.fs.file('pubspec.yaml').createSync(); expect(device.isSupportedForProject(FlutterProject.current()), false); }, overrides: <Type, Generator>{ FileSystem: () => memoryFileSystem, @@ -391,28 +391,28 @@ }); testUsingContext('Correct flutter runner', () async { - expect(artifacts.getArtifactPath( + expect(globals.artifacts.getArtifactPath( Artifact.fuchsiaFlutterRunner, platform: TargetPlatform.fuchsia_x64, mode: BuildMode.debug, ), contains('flutter_jit_runner'), ); - expect(artifacts.getArtifactPath( + expect(globals.artifacts.getArtifactPath( Artifact.fuchsiaFlutterRunner, platform: TargetPlatform.fuchsia_x64, mode: BuildMode.profile, ), contains('flutter_aot_runner'), ); - expect(artifacts.getArtifactPath( + expect(globals.artifacts.getArtifactPath( Artifact.fuchsiaFlutterRunner, platform: TargetPlatform.fuchsia_x64, mode: BuildMode.release, ), contains('flutter_aot_product_runner'), ); - expect(artifacts.getArtifactPath( + expect(globals.artifacts.getArtifactPath( Artifact.fuchsiaFlutterRunner, platform: TargetPlatform.fuchsia_x64, mode: BuildMode.jitRelease, @@ -475,20 +475,20 @@ }) async { const String appName = 'app_name'; final FuchsiaDevice device = FuchsiaDeviceWithFakeDiscovery('123'); - fs.directory('fuchsia').createSync(recursive: true); - final File pubspecFile = fs.file('pubspec.yaml')..createSync(); + globals.fs.directory('fuchsia').createSync(recursive: true); + final File pubspecFile = globals.fs.file('pubspec.yaml')..createSync(); pubspecFile.writeAsStringSync('name: $appName'); FuchsiaApp app; if (prebuilt) { - final File far = fs.file('app_name-0.far')..createSync(); + final File far = globals.fs.file('app_name-0.far')..createSync(); app = FuchsiaApp.fromPrebuiltApp(far); } else { - fs.file(fs.path.join('fuchsia', 'meta', '$appName.cmx')) + globals.fs.file(globals.fs.path.join('fuchsia', 'meta', '$appName.cmx')) ..createSync(recursive: true) ..writeAsStringSync('{}'); - fs.file('.packages').createSync(); - fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true); + globals.fs.file('.packages').createSync(); + globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); app = BuildableFuchsiaApp(project: FlutterProject.current().fuchsia); } @@ -518,10 +518,10 @@ testUsingContext('start and stop prebuilt in release mode', () async { const String appName = 'app_name'; final FuchsiaDevice device = FuchsiaDeviceWithFakeDiscovery('123'); - fs.directory('fuchsia').createSync(recursive: true); - final File pubspecFile = fs.file('pubspec.yaml')..createSync(); + globals.fs.directory('fuchsia').createSync(recursive: true); + final File pubspecFile = globals.fs.file('pubspec.yaml')..createSync(); pubspecFile.writeAsStringSync('name: $appName'); - final File far = fs.file('app_name-0.far')..createSync(); + final File far = globals.fs.file('app_name-0.far')..createSync(); final FuchsiaApp app = FuchsiaApp.fromPrebuiltApp(far); final DebuggingOptions debuggingOptions = @@ -983,11 +983,11 @@ @override Future<bool> init(String buildPath, String appName) async { - if (!fs.directory(buildPath).existsSync()) { + if (!globals.fs.directory(buildPath).existsSync()) { return false; } - fs - .file(fs.path.join(buildPath, 'meta', 'package')) + globals.fs + .file(globals.fs.path.join(buildPath, 'meta', 'package')) .createSync(recursive: true); _appName = appName; return true; @@ -995,43 +995,43 @@ @override Future<bool> genkey(String buildPath, String outKeyPath) async { - if (!fs.file(fs.path.join(buildPath, 'meta', 'package')).existsSync()) { + if (!globals.fs.file(globals.fs.path.join(buildPath, 'meta', 'package')).existsSync()) { return false; } - fs.file(outKeyPath).createSync(recursive: true); + globals.fs.file(outKeyPath).createSync(recursive: true); return true; } @override Future<bool> build(String buildPath, String keyPath, String manifestPath) async { - if (!fs.file(fs.path.join(buildPath, 'meta', 'package')).existsSync() || - !fs.file(keyPath).existsSync() || - !fs.file(manifestPath).existsSync()) { + if (!globals.fs.file(globals.fs.path.join(buildPath, 'meta', 'package')).existsSync() || + !globals.fs.file(keyPath).existsSync() || + !globals.fs.file(manifestPath).existsSync()) { return false; } - fs.file(fs.path.join(buildPath, 'meta.far')).createSync(recursive: true); + globals.fs.file(globals.fs.path.join(buildPath, 'meta.far')).createSync(recursive: true); return true; } @override Future<bool> archive(String buildPath, String keyPath, String manifestPath) async { - if (!fs.file(fs.path.join(buildPath, 'meta', 'package')).existsSync() || - !fs.file(keyPath).existsSync() || - !fs.file(manifestPath).existsSync()) { + if (!globals.fs.file(globals.fs.path.join(buildPath, 'meta', 'package')).existsSync() || + !globals.fs.file(keyPath).existsSync() || + !globals.fs.file(manifestPath).existsSync()) { return false; } if (_appName == null) { return false; } - fs - .file(fs.path.join(buildPath, '$_appName-0.far')) + globals.fs + .file(globals.fs.path.join(buildPath, '$_appName-0.far')) .createSync(recursive: true); return true; } @override Future<bool> newrepo(String repoPath) async { - if (!fs.directory(repoPath).existsSync()) { + if (!globals.fs.directory(repoPath).existsSync()) { return false; } return true; @@ -1044,10 +1044,10 @@ @override Future<bool> publish(String repoPath, String packagePath) async { - if (!fs.directory(repoPath).existsSync()) { + if (!globals.fs.directory(repoPath).existsSync()) { return false; } - if (!fs.file(packagePath).existsSync()) { + if (!globals.fs.file(packagePath).existsSync()) { return false; } return true; @@ -1100,8 +1100,8 @@ }) async { final String outDir = getFuchsiaBuildDirectory(); final String appName = fuchsiaProject.project.manifest.appName; - final String manifestPath = fs.path.join(outDir, '$appName.dilpmanifest'); - fs.file(manifestPath).createSync(recursive: true); + final String manifestPath = globals.fs.path.join(outDir, '$appName.dilpmanifest'); + globals.fs.file(manifestPath).createSync(recursive: true); } }
diff --git a/packages/flutter_tools/test/general.shard/intellij/intellij_test.dart b/packages/flutter_tools/test/general.shard/intellij/intellij_test.dart index 18b2c80..a0ff560 100644 --- a/packages/flutter_tools/test/general.shard/intellij/intellij_test.dart +++ b/packages/flutter_tools/test/general.shard/intellij/intellij_test.dart
@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/doctor.dart'; import 'package:flutter_tools/src/intellij/intellij.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../../src/common.dart'; import '../../src/context.dart'; @@ -18,7 +19,7 @@ FileSystem fs; void writeFileCreatingDirectories(String path, List<int> bytes) { - final File file = fs.file(path); + final File file = globals.fs.file(path); file.parent.createSync(recursive: true); file.writeAsBytesSync(bytes); } @@ -40,7 +41,7 @@ </idea-plugin> '''); writeFileCreatingDirectories( - fs.path.join(_kPluginsPath, 'Dart', 'lib', 'Dart.jar'), + globals.fs.path.join(_kPluginsPath, 'Dart', 'lib', 'Dart.jar'), ZipEncoder().encode(dartJarArchive)); final Archive flutterJarArchive = @@ -51,7 +52,7 @@ </idea-plugin> '''); writeFileCreatingDirectories( - fs.path.join(_kPluginsPath, 'flutter-intellij.jar'), + globals.fs.path.join(_kPluginsPath, 'flutter-intellij.jar'), ZipEncoder().encode(flutterJarArchive)); final List<ValidationMessage> messages = <ValidationMessage>[];
diff --git a/packages/flutter_tools/test/general.shard/ios/code_signing_test.dart b/packages/flutter_tools/test/general.shard/ios/code_signing_test.dart index ff57bab..973bfa1 100644 --- a/packages/flutter_tools/test/general.shard/ios/code_signing_test.dart +++ b/packages/flutter_tools/test/general.shard/ios/code_signing_test.dart
@@ -13,7 +13,7 @@ import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/terminal.dart'; import 'package:flutter_tools/src/ios/code_signing.dart'; -import 'package:flutter_tools/src/globals.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:process/process.dart'; import '../../src/common.dart'; @@ -316,7 +316,7 @@ verify(mockOpenSslStdIn.write('This is a mock certificate')); expect(signingConfigs, <String, String>{'DEVELOPMENT_TEAM': '4444DDDD44'}); - verify(config.setValue('ios-signing-cert', 'iPhone Developer: Profile 3 (3333CCCC33)')); + verify(globals.config.setValue('ios-signing-cert', 'iPhone Developer: Profile 3 (3333CCCC33)')); }, overrides: <Type, Generator>{ ProcessManager: () => mockProcessManager, @@ -549,7 +549,7 @@ contains('Certificate choice "iPhone Developer: Profile 3 (3333CCCC33)"'), ); expect(signingConfigs, <String, String>{'DEVELOPMENT_TEAM': '4444DDDD44'}); - verify(config.setValue('ios-signing-cert', 'iPhone Developer: Profile 3 (3333CCCC33)')); + verify(globals.config.setValue('ios-signing-cert', 'iPhone Developer: Profile 3 (3333CCCC33)')); }, overrides: <Type, Generator>{ ProcessManager: () => mockProcessManager,
diff --git a/packages/flutter_tools/test/general.shard/ios/devices_test.dart b/packages/flutter_tools/test/general.shard/ios/devices_test.dart index f584891..4820ae2 100644 --- a/packages/flutter_tools/test/general.shard/ios/devices_test.dart +++ b/packages/flutter_tools/test/general.shard/ios/devices_test.dart
@@ -24,6 +24,8 @@ import 'package:flutter_tools/src/mdns_discovery.dart'; import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/reporting/reporting.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; + import 'package:meta/meta.dart'; import 'package:mockito/mockito.dart'; import 'package:platform/platform.dart'; @@ -193,7 +195,7 @@ mockIosDeploy = MockIOSDeploy(); mockUsage = MockUsage(); - tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_create_test.'); + tempDir = globals.fs.systemTempDirectory.createTempSync('flutter_tools_create_test.'); projectDir = tempDir.childDirectory('flutter_project'); when( @@ -527,7 +529,7 @@ projectDir.childDirectory('build/ios/iphoneos/Debug-arm64'); // The -showBuildSettings calls have a timeout and so go through - // processManager.start(). + // globals.processManager.start(). mockProcessManager.processFactory = flakyProcessFactory( flakes: showBuildSettingsFlakes ? 1 : 0, delay: const Duration(seconds: 62), @@ -919,7 +921,7 @@ }); }); testUsingContext('IOSDevice.isSupportedForProject is true on module project', () async { - fs.file('pubspec.yaml') + globals.fs.file('pubspec.yaml') ..createSync() ..writeAsStringSync(r''' name: example @@ -927,7 +929,7 @@ flutter: module: {} '''); - fs.file('.packages').createSync(); + globals.fs.file('.packages').createSync(); final FlutterProject flutterProject = FlutterProject.current(); expect(IOSDevice('test').isSupportedForProject(flutterProject), true); @@ -937,9 +939,9 @@ Platform: () => macPlatform, }); testUsingContext('IOSDevice.isSupportedForProject is true with editable host app', () async { - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); - fs.directory('ios').createSync(); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); + globals.fs.directory('ios').createSync(); final FlutterProject flutterProject = FlutterProject.current(); expect(IOSDevice('test').isSupportedForProject(flutterProject), true); @@ -950,8 +952,8 @@ }); testUsingContext('IOSDevice.isSupportedForProject is false with no host app and no module', () async { - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); final FlutterProject flutterProject = FlutterProject.current(); expect(IOSDevice('test').isSupportedForProject(flutterProject), false); @@ -973,7 +975,7 @@ @override String get deviceBundlePath => - fs.path.join(project.parent.directory.path, 'build', 'ios', 'iphoneos', name); + globals.fs.path.join(project.parent.directory.path, 'build', 'ios', 'iphoneos', name); }
diff --git a/packages/flutter_tools/test/general.shard/ios/mac_test.dart b/packages/flutter_tools/test/general.shard/ios/mac_test.dart index 7a87dfa..ae846bf 100644 --- a/packages/flutter_tools/test/general.shard/ios/mac_test.dart +++ b/packages/flutter_tools/test/general.shard/ios/mac_test.dart
@@ -13,6 +13,8 @@ import 'package:flutter_tools/src/ios/xcodeproj.dart'; import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/reporting/reporting.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; + import 'package:mockito/mockito.dart'; import 'package:platform/platform.dart'; import 'package:process/process.dart'; @@ -37,10 +39,10 @@ final FakePlatform osx = FakePlatform.fromPlatform(const LocalPlatform()) ..operatingSystem = 'macos'; MockProcessManager mockProcessManager; - final String libimobiledevicePath = fs.path.join('bin', 'cache', 'artifacts', 'libimobiledevice'); - final String ideviceIdPath = fs.path.join(libimobiledevicePath, 'idevice_id'); - final String ideviceInfoPath = fs.path.join(libimobiledevicePath, 'ideviceinfo'); - final String idevicescreenshotPath = fs.path.join(libimobiledevicePath, 'idevicescreenshot'); + final String libimobiledevicePath = globals.fs.path.join('bin', 'cache', 'artifacts', 'libimobiledevice'); + final String ideviceIdPath = globals.fs.path.join(libimobiledevicePath, 'idevice_id'); + final String ideviceInfoPath = globals.fs.path.join(libimobiledevicePath, 'ideviceinfo'); + final String idevicescreenshotPath = globals.fs.path.join(libimobiledevicePath, 'idevicescreenshot'); MockArtifacts mockArtifacts; MockCache mockCache; @@ -177,7 +179,7 @@ }); group('screenshot', () { - final String outputPath = fs.path.join('some', 'test', 'path', 'image.png'); + final String outputPath = globals.fs.path.join('some', 'test', 'path', 'image.png'); MockProcessManager mockProcessManager; MockFile mockOutputFile;
diff --git a/packages/flutter_tools/test/general.shard/ios/plist_parser_test.dart b/packages/flutter_tools/test/general.shard/ios/plist_parser_test.dart index 6d4c74b..4f32aaf 100644 --- a/packages/flutter_tools/test/general.shard/ios/plist_parser_test.dart +++ b/packages/flutter_tools/test/general.shard/ios/plist_parser_test.dart
@@ -8,6 +8,8 @@ import 'package:file/file.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/ios/plist_parser.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; + import 'package:process/process.dart'; import '../../src/common.dart'; @@ -48,7 +50,7 @@ File file; setUp(() { - file = fs.file('foo.plist')..createSync(); + file = globals.fs.file('foo.plist')..createSync(); }); tearDown(() {
diff --git a/packages/flutter_tools/test/general.shard/ios/simulators_test.dart b/packages/flutter_tools/test/general.shard/ios/simulators_test.dart index 7eb77ef..153ac57 100644 --- a/packages/flutter_tools/test/general.shard/ios/simulators_test.dart +++ b/packages/flutter_tools/test/general.shard/ios/simulators_test.dart
@@ -18,6 +18,8 @@ import 'package:flutter_tools/src/ios/simulators.dart'; import 'package:flutter_tools/src/macos/xcode.dart'; import 'package:flutter_tools/src/project.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; + import 'package:mockito/mockito.dart'; import 'package:platform/platform.dart'; import 'package:process/process.dart'; @@ -239,7 +241,7 @@ when(mockXcode.minorVersion).thenReturn(2); expect(deviceUnderTest.supportsScreenshot, true); final MockFile mockFile = MockFile(); - when(mockFile.path).thenReturn(fs.path.join('some', 'path', 'to', 'screenshot.png')); + when(mockFile.path).thenReturn(globals.fs.path.join('some', 'path', 'to', 'screenshot.png')); await deviceUnderTest.takeScreenshot(mockFile); verify(mockProcessManager.run( <String>[ @@ -248,7 +250,7 @@ 'io', 'x', 'screenshot', - fs.path.join('some', 'path', 'to', 'screenshot.png'), + globals.fs.path.join('some', 'path', 'to', 'screenshot.png'), ], environment: null, workingDirectory: null, @@ -478,7 +480,7 @@ final IOSSimulator device = IOSSimulator('x', name: 'iPhone SE', simulatorCategory: 'iOS 11.2'); when(PlistParser.instance.getValueFromFile(any, any)).thenReturn('correct'); - final Directory mockDir = fs.currentDirectory; + final Directory mockDir = globals.fs.currentDirectory; final IOSApp package = PrebuiltIOSApp(projectBundleId: 'incorrect', bundleName: 'name', bundleDir: mockDir); const BuildInfo mockInfo = BuildInfo(BuildMode.debug, 'flavor'); @@ -493,7 +495,7 @@ }); testUsingContext('IOSDevice.isSupportedForProject is true on module project', () async { - fs.file('pubspec.yaml') + globals.fs.file('pubspec.yaml') ..createSync() ..writeAsStringSync(r''' name: example @@ -501,7 +503,7 @@ flutter: module: {} '''); - fs.file('.packages').createSync(); + globals.fs.file('.packages').createSync(); final FlutterProject flutterProject = FlutterProject.current(); expect(IOSSimulator('test').isSupportedForProject(flutterProject), true); @@ -511,9 +513,9 @@ }); testUsingContext('IOSDevice.isSupportedForProject is true with editable host app', () async { - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); - fs.directory('ios').createSync(); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); + globals.fs.directory('ios').createSync(); final FlutterProject flutterProject = FlutterProject.current(); expect(IOSSimulator('test').isSupportedForProject(flutterProject), true); @@ -523,8 +525,8 @@ }); testUsingContext('IOSDevice.isSupportedForProject is false with no host app and no module', () async { - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); final FlutterProject flutterProject = FlutterProject.current(); expect(IOSSimulator('test').isSupportedForProject(flutterProject), false);
diff --git a/packages/flutter_tools/test/general.shard/ios/xcodeproj_test.dart b/packages/flutter_tools/test/general.shard/ios/xcodeproj_test.dart index 17119f9..98544ec 100644 --- a/packages/flutter_tools/test/general.shard/ios/xcodeproj_test.dart +++ b/packages/flutter_tools/test/general.shard/ios/xcodeproj_test.dart
@@ -11,6 +11,8 @@ import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/ios/xcodeproj.dart'; import 'package:flutter_tools/src/project.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; + import 'package:mockito/mockito.dart'; import 'package:platform/platform.dart'; import 'package:process/process.dart'; @@ -418,7 +420,7 @@ mockArtifacts = MockLocalEngineArtifacts(); mockProcessManager = MockProcessManager(); macOS = fakePlatform('macos'); - fs.file(xcodebuild).createSync(recursive: true); + globals.fs.file(xcodebuild).createSync(recursive: true); }); void testUsingOsxContext(String description, dynamic testMethod()) { @@ -433,7 +435,7 @@ testUsingOsxContext('sets ARCHS=armv7 when armv7 local engine is set', () async { when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine'); - when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm')); + when(mockArtifacts.engineOutPath).thenReturn(globals.fs.path.join('out', 'ios_profile_arm')); const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null); final FlutterProject project = FlutterProject.fromPath('path/to/project'); @@ -442,13 +444,13 @@ buildInfo: buildInfo, ); - final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig'); + final File config = globals.fs.file('path/to/project/ios/Flutter/Generated.xcconfig'); expect(config.existsSync(), isTrue); final String contents = config.readAsStringSync(); expect(contents.contains('ARCHS=armv7'), isTrue); - final File buildPhaseScript = fs.file('path/to/project/ios/Flutter/flutter_export_environment.sh'); + final File buildPhaseScript = globals.fs.file('path/to/project/ios/Flutter/flutter_export_environment.sh'); expect(buildPhaseScript.existsSync(), isTrue); final String buildPhaseScriptContents = buildPhaseScript.readAsStringSync(); @@ -458,7 +460,7 @@ testUsingOsxContext('sets TRACK_WIDGET_CREATION=true when trackWidgetCreation is true', () async { when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine'); - when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm')); + when(mockArtifacts.engineOutPath).thenReturn(globals.fs.path.join('out', 'ios_profile_arm')); const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null, trackWidgetCreation: true); final FlutterProject project = FlutterProject.fromPath('path/to/project'); await updateGeneratedXcodeProperties( @@ -466,13 +468,13 @@ buildInfo: buildInfo, ); - final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig'); + final File config = globals.fs.file('path/to/project/ios/Flutter/Generated.xcconfig'); expect(config.existsSync(), isTrue); final String contents = config.readAsStringSync(); expect(contents.contains('TRACK_WIDGET_CREATION=true'), isTrue); - final File buildPhaseScript = fs.file('path/to/project/ios/Flutter/flutter_export_environment.sh'); + final File buildPhaseScript = globals.fs.file('path/to/project/ios/Flutter/flutter_export_environment.sh'); expect(buildPhaseScript.existsSync(), isTrue); final String buildPhaseScriptContents = buildPhaseScript.readAsStringSync(); @@ -482,7 +484,7 @@ testUsingOsxContext('does not set TRACK_WIDGET_CREATION when trackWidgetCreation is false', () async { when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine'); - when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile_arm')); + when(mockArtifacts.engineOutPath).thenReturn(globals.fs.path.join('out', 'ios_profile_arm')); const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null); final FlutterProject project = FlutterProject.fromPath('path/to/project'); await updateGeneratedXcodeProperties( @@ -490,13 +492,13 @@ buildInfo: buildInfo, ); - final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig'); + final File config = globals.fs.file('path/to/project/ios/Flutter/Generated.xcconfig'); expect(config.existsSync(), isTrue); final String contents = config.readAsStringSync(); expect(contents.contains('TRACK_WIDGET_CREATION=true'), isFalse); - final File buildPhaseScript = fs.file('path/to/project/ios/Flutter/flutter_export_environment.sh'); + final File buildPhaseScript = globals.fs.file('path/to/project/ios/Flutter/flutter_export_environment.sh'); expect(buildPhaseScript.existsSync(), isTrue); final String buildPhaseScriptContents = buildPhaseScript.readAsStringSync(); @@ -506,7 +508,7 @@ testUsingOsxContext('sets ARCHS=armv7 when armv7 local engine is set', () async { when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine'); - when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios_profile')); + when(mockArtifacts.engineOutPath).thenReturn(globals.fs.path.join('out', 'ios_profile')); const BuildInfo buildInfo = BuildInfo(BuildMode.debug, null); final FlutterProject project = FlutterProject.fromPath('path/to/project'); @@ -515,7 +517,7 @@ buildInfo: buildInfo, ); - final File config = fs.file('path/to/project/ios/Flutter/Generated.xcconfig'); + final File config = globals.fs.file('path/to/project/ios/Flutter/Generated.xcconfig'); expect(config.existsSync(), isTrue); final String contents = config.readAsStringSync(); @@ -539,9 +541,9 @@ }) async { when(mockArtifacts.getArtifactPath(Artifact.flutterFramework, platform: TargetPlatform.ios, mode: anyNamed('mode'))).thenReturn('engine'); - when(mockArtifacts.engineOutPath).thenReturn(fs.path.join('out', 'ios')); + when(mockArtifacts.engineOutPath).thenReturn(globals.fs.path.join('out', 'ios')); - final File manifestFile = fs.file('path/to/project/pubspec.yaml'); + final File manifestFile = globals.fs.file('path/to/project/pubspec.yaml'); manifestFile.createSync(recursive: true); manifestFile.writeAsStringSync(manifestString); @@ -553,7 +555,7 @@ buildInfo: buildInfo, ); - final File localPropertiesFile = fs.file('path/to/project/ios/Flutter/Generated.xcconfig'); + final File localPropertiesFile = globals.fs.file('path/to/project/ios/Flutter/Generated.xcconfig'); expect(propertyFor('FLUTTER_BUILD_NAME', localPropertiesFile), expectedBuildName); expect(propertyFor('FLUTTER_BUILD_NUMBER', localPropertiesFile), expectedBuildNumber); expect(propertyFor('FLUTTER_BUILD_NUMBER', localPropertiesFile), isNotNull);
diff --git a/packages/flutter_tools/test/general.shard/linux/linux_device_test.dart b/packages/flutter_tools/test/general.shard/linux/linux_device_test.dart index e8628e8..5bfe7b4 100644 --- a/packages/flutter_tools/test/general.shard/linux/linux_device_test.dart +++ b/packages/flutter_tools/test/general.shard/linux/linux_device_test.dart
@@ -4,13 +4,15 @@ import 'package:file/memory.dart'; import 'package:flutter_tools/src/base/file_system.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/linux/application_package.dart'; import 'package:flutter_tools/src/linux/linux_device.dart'; import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/project.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; + import 'package:mockito/mockito.dart'; +import 'package:platform/platform.dart'; import '../../src/common.dart'; import '../../src/context.dart'; @@ -40,9 +42,9 @@ }); testUsingContext('LinuxDevice.isSupportedForProject is true with editable host app', () async { - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); - fs.directory('linux').createSync(); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); + globals.fs.directory('linux').createSync(); final FlutterProject flutterProject = FlutterProject.current(); expect(LinuxDevice().isSupportedForProject(flutterProject), true); @@ -52,8 +54,8 @@ }); testUsingContext('LinuxDevice.isSupportedForProject is false with no host app', () async { - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); final FlutterProject flutterProject = FlutterProject.current(); expect(LinuxDevice().isSupportedForProject(flutterProject), false);
diff --git a/packages/flutter_tools/test/general.shard/linux/linux_doctor_test.dart b/packages/flutter_tools/test/general.shard/linux/linux_doctor_test.dart index dc4b761..095fcdc 100644 --- a/packages/flutter_tools/test/general.shard/linux/linux_doctor_test.dart +++ b/packages/flutter_tools/test/general.shard/linux/linux_doctor_test.dart
@@ -3,6 +3,7 @@ // found in the LICENSE file. import 'package:flutter_tools/src/doctor.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/linux/linux_doctor.dart'; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; @@ -22,13 +23,13 @@ }); testUsingContext('Returns full validation when clang++ and make are availibe', () async { - when(processManager.run(<String>['clang++', '--version'])).thenAnswer((_) async { + when(globals.processManager.run(<String>['clang++', '--version'])).thenAnswer((_) async { return FakeProcessResult( stdout: 'clang version 4.0.1-10 (tags/RELEASE_401/final)\njunk', exitCode: 0, ); }); - when(processManager.run(<String>[ + when(globals.processManager.run(<String>[ 'make', '--version', ])).thenAnswer((_) async { @@ -49,13 +50,13 @@ }); testUsingContext('Returns partial validation when clang++ version is too old', () async { - when(processManager.run(<String>['clang++', '--version'])).thenAnswer((_) async { + when(globals.processManager.run(<String>['clang++', '--version'])).thenAnswer((_) async { return FakeProcessResult( stdout: 'clang version 2.0.1-10 (tags/RELEASE_401/final)\njunk', exitCode: 0, ); }); - when(processManager.run(<String>[ + when(globals.processManager.run(<String>[ 'make', '--version', ])).thenAnswer((_) async { @@ -76,13 +77,13 @@ }); testUsingContext('Returns mising validation when make is not availible', () async { - when(processManager.run(<String>['clang++', '--version'])).thenAnswer((_) async { + when(globals.processManager.run(<String>['clang++', '--version'])).thenAnswer((_) async { return FakeProcessResult( stdout: 'clang version 4.0.1-10 (tags/RELEASE_401/final)\njunk', exitCode: 0, ); }); - when(processManager.run(<String>[ + when(globals.processManager.run(<String>[ 'make', '--version', ])).thenAnswer((_) async { @@ -103,13 +104,13 @@ }); testUsingContext('Returns mising validation when clang++ is not availible', () async { - when(processManager.run(<String>['clang++', '--version'])).thenAnswer((_) async { + when(globals.processManager.run(<String>['clang++', '--version'])).thenAnswer((_) async { return FakeProcessResult( stdout: '', exitCode: 1, ); }); - when(processManager.run(<String>[ + when(globals.processManager.run(<String>[ 'make', '--version', ])).thenAnswer((_) async { @@ -131,13 +132,13 @@ testUsingContext('Returns missing validation when clang and make are not availible', () async { - when(processManager.run(<String>['clang++', '--version'])).thenAnswer((_) async { + when(globals.processManager.run(<String>['clang++', '--version'])).thenAnswer((_) async { return FakeProcessResult( stdout: '', exitCode: 1, ); }); - when(processManager.run(<String>[ + when(globals.processManager.run(<String>[ 'make', '--version', ])).thenAnswer((_) async {
diff --git a/packages/flutter_tools/test/general.shard/linux/linux_workflow_test.dart b/packages/flutter_tools/test/general.shard/linux/linux_workflow_test.dart index 0028765..5630431 100644 --- a/packages/flutter_tools/test/general.shard/linux/linux_workflow_test.dart +++ b/packages/flutter_tools/test/general.shard/linux/linux_workflow_test.dart
@@ -4,8 +4,9 @@ import 'package:flutter_tools/src/features.dart'; import 'package:mockito/mockito.dart'; +import 'package:platform/platform.dart'; + import 'package:flutter_tools/src/linux/linux_workflow.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import '../../src/common.dart'; import '../../src/context.dart';
diff --git a/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart b/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart index 19ae134..ecd7e47 100644 --- a/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart +++ b/packages/flutter_tools/test/general.shard/macos/cocoapods_test.dart
@@ -6,16 +6,17 @@ import 'package:file/file.dart'; import 'package:file/memory.dart'; +import 'package:platform/platform.dart'; +import 'package:mockito/mockito.dart'; +import 'package:process/process.dart'; + import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/io.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/ios/xcodeproj.dart'; import 'package:flutter_tools/src/macos/cocoapods.dart'; import 'package:flutter_tools/src/plugins.dart'; import 'package:flutter_tools/src/project.dart'; -import 'package:mockito/mockito.dart'; -import 'package:process/process.dart'; import '../../src/common.dart'; import '../../src/context.dart';
diff --git a/packages/flutter_tools/test/general.shard/macos/macos_device_test.dart b/packages/flutter_tools/test/general.shard/macos/macos_device_test.dart index ed3affb..f88ebb1 100644 --- a/packages/flutter_tools/test/general.shard/macos/macos_device_test.dart +++ b/packages/flutter_tools/test/general.shard/macos/macos_device_test.dart
@@ -7,14 +7,15 @@ import 'package:flutter_tools/src/project.dart'; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; +import 'package:platform/platform.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/macos/application_package.dart'; import 'package:flutter_tools/src/macos/macos_device.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../../src/common.dart'; import '../../src/context.dart'; @@ -48,9 +49,9 @@ }); testUsingContext('isSupportedForProject is true with editable host app', () async { - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); - fs.directory('macos').createSync(); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); + globals.fs.directory('macos').createSync(); final FlutterProject flutterProject = FlutterProject.current(); expect(MacOSDevice().isSupportedForProject(flutterProject), true); @@ -60,8 +61,8 @@ }); testUsingContext('isSupportedForProject is false with no host app', () async { - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); final FlutterProject flutterProject = FlutterProject.current(); expect(MacOSDevice().isSupportedForProject(flutterProject), false);
diff --git a/packages/flutter_tools/test/general.shard/macos/macos_workflow_test.dart b/packages/flutter_tools/test/general.shard/macos/macos_workflow_test.dart index 6edd62e..b845326 100644 --- a/packages/flutter_tools/test/general.shard/macos/macos_workflow_test.dart +++ b/packages/flutter_tools/test/general.shard/macos/macos_workflow_test.dart
@@ -4,10 +4,9 @@ import 'package:flutter_tools/src/features.dart'; import 'package:mockito/mockito.dart'; - -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/macos/macos_workflow.dart'; import 'package:process/process.dart'; +import 'package:platform/platform.dart'; import '../../src/common.dart'; import '../../src/context.dart';
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 8a56721..90407de 100644 --- a/packages/flutter_tools/test/general.shard/macos/xcode_test.dart +++ b/packages/flutter_tools/test/general.shard/macos/xcode_test.dart
@@ -3,11 +3,11 @@ // found in the LICENSE file. import 'package:flutter_tools/src/base/io.dart' show ProcessException, ProcessResult; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/ios/xcodeproj.dart'; import 'package:flutter_tools/src/macos/xcode.dart'; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; +import 'package:platform/platform.dart'; import '../../src/common.dart'; import '../../src/context.dart';
diff --git a/packages/flutter_tools/test/general.shard/package_uri_mapper_test.dart b/packages/flutter_tools/test/general.shard/package_uri_mapper_test.dart index 9c86f7b..c03f3df 100644 --- a/packages/flutter_tools/test/general.shard/package_uri_mapper_test.dart +++ b/packages/flutter_tools/test/general.shard/package_uri_mapper_test.dart
@@ -7,6 +7,7 @@ import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/compile.dart'; import 'package:flutter_tools/src/convert.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import '../src/common.dart'; @@ -31,7 +32,7 @@ setUp(() { mockFileSystem = MockFileSystem(); mockFile = MockFile(); - when(mockFileSystem.path).thenReturn(fs.path); + when(mockFileSystem.path).thenReturn(globals.fs.path); when(mockFileSystem.file(any)).thenReturn(mockFile); when(mockFile.readAsBytesSync()).thenReturn(utf8.encode(packagesContents) as Uint8List); }); @@ -65,7 +66,7 @@ testUsingContext('multi-root maps main file from same package on multiroot scheme', () async { final MockFileSystem mockFileSystem = MockFileSystem(); final MockFile mockFile = MockFile(); - when(mockFileSystem.path).thenReturn(fs.path); + when(mockFileSystem.path).thenReturn(globals.fs.path); when(mockFileSystem.file(any)).thenReturn(mockFile); when(mockFile.readAsBytesSync()) .thenReturn(utf8.encode(multiRootPackagesContents) as Uint8List);
diff --git a/packages/flutter_tools/test/general.shard/persistent_tool_state_test.dart b/packages/flutter_tools/test/general.shard/persistent_tool_state_test.dart index f1778c9..b27257e 100644 --- a/packages/flutter_tools/test/general.shard/persistent_tool_state_test.dart +++ b/packages/flutter_tools/test/general.shard/persistent_tool_state_test.dart
@@ -4,6 +4,7 @@ import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/persistent_tool_state.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../src/common.dart'; import '../src/testbed.dart'; @@ -16,7 +17,7 @@ }); test('state can be set and persists', () => testbed.run(() { - final File stateFile = fs.file('.flutter_tool_state'); + final File stateFile = globals.fs.file('.flutter_tool_state'); final PersistentToolState state1 = PersistentToolState(stateFile); expect(state1.redisplayWelcomeMessage, null); state1.redisplayWelcomeMessage = true;
diff --git a/packages/flutter_tools/test/general.shard/project_file_invalidator_test.dart b/packages/flutter_tools/test/general.shard/project_file_invalidator_test.dart index 9d6dd39..3d251a5 100644 --- a/packages/flutter_tools/test/general.shard/project_file_invalidator_test.dart +++ b/packages/flutter_tools/test/general.shard/project_file_invalidator_test.dart
@@ -4,9 +4,10 @@ import 'package:file/memory.dart'; import 'package:flutter_tools/src/base/logger.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/run_hot.dart'; +import 'package:platform/platform.dart'; + import '../src/common.dart'; // assumption: tests have a timeout less than 100 days
diff --git a/packages/flutter_tools/test/general.shard/project_test.dart b/packages/flutter_tools/test/general.shard/project_test.dart index c8d3a09..d42a617 100644 --- a/packages/flutter_tools/test/general.shard/project_test.dart +++ b/packages/flutter_tools/test/general.shard/project_test.dart
@@ -9,13 +9,13 @@ import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/context.dart'; import 'package:flutter_tools/src/base/file_system.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/features.dart'; import 'package:flutter_tools/src/flutter_manifest.dart'; import 'package:flutter_tools/src/ios/plist_parser.dart'; import 'package:flutter_tools/src/ios/xcodeproj.dart'; import 'package:flutter_tools/src/project.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:meta/meta.dart'; import 'package:mockito/mockito.dart'; @@ -34,7 +34,7 @@ }); testInMemory('fails on invalid pubspec.yaml', () async { - final Directory directory = fs.directory('myproject'); + final Directory directory = globals.fs.directory('myproject'); directory.childFile('pubspec.yaml') ..createSync(recursive: true) ..writeAsStringSync(invalidPubspec); @@ -46,7 +46,7 @@ }); testInMemory('fails on pubspec.yaml parse failure', () async { - final Directory directory = fs.directory('myproject'); + final Directory directory = globals.fs.directory('myproject'); directory.childFile('pubspec.yaml') ..createSync(recursive: true) ..writeAsStringSync(parseErrorPubspec); @@ -58,7 +58,7 @@ }); testInMemory('fails on invalid example/pubspec.yaml', () async { - final Directory directory = fs.directory('myproject'); + final Directory directory = globals.fs.directory('myproject'); directory.childDirectory('example').childFile('pubspec.yaml') ..createSync(recursive: true) ..writeAsStringSync(invalidPubspec); @@ -70,7 +70,7 @@ }); testInMemory('treats missing pubspec.yaml as empty', () async { - final Directory directory = fs.directory('myproject') + final Directory directory = globals.fs.directory('myproject') ..createSync(recursive: true); expect((FlutterProject.fromDirectory(directory)).manifest.isEmpty, true, @@ -78,7 +78,7 @@ }); testInMemory('reads valid pubspec.yaml', () async { - final Directory directory = fs.directory('myproject'); + final Directory directory = globals.fs.directory('myproject'); directory.childFile('pubspec.yaml') ..createSync(recursive: true) ..writeAsStringSync(validPubspec); @@ -89,7 +89,7 @@ }); testInMemory('sets up location', () async { - final Directory directory = fs.directory('myproject'); + final Directory directory = globals.fs.directory('myproject'); expect( FlutterProject.fromDirectory(directory).directory.absolute.path, directory.absolute.path, @@ -100,7 +100,7 @@ ); expect( FlutterProject.current().directory.absolute.path, - fs.currentDirectory.absolute.path, + globals.fs.currentDirectory.absolute.path, ); }); }); @@ -154,7 +154,7 @@ group('ensure ready for platform-specific tooling', () { testInMemory('does nothing, if project is not created', () async { final FlutterProject project = FlutterProject( - fs.directory('not_created'), + globals.fs.directory('not_created'), FlutterManifest.empty(), FlutterManifest.empty(), ); @@ -513,7 +513,7 @@ }); test('Handles asking for builders from an invalid pubspec', () => testbed.run(() { - fs.file('pubspec.yaml') + globals.fs.file('pubspec.yaml') ..createSync() ..writeAsStringSync(r''' # Hello, World @@ -526,7 +526,7 @@ })); test('Handles asking for builders from a trivial pubspec', () => testbed.run(() { - fs.file('pubspec.yaml') + globals.fs.file('pubspec.yaml') ..createSync() ..writeAsStringSync(r''' # Hello, World @@ -542,7 +542,7 @@ } Future<FlutterProject> someProject() async { - final Directory directory = fs.directory('some_project'); + final Directory directory = globals.fs.directory('some_project'); directory.childFile('.packages').createSync(recursive: true); directory.childDirectory('ios').createSync(recursive: true); final Directory androidDirectory = directory @@ -555,7 +555,7 @@ } Future<FlutterProject> aPluginProject({bool legacy = true}) async { - final Directory directory = fs.directory('plugin_project'); + final Directory directory = globals.fs.directory('plugin_project'); directory.childDirectory('ios').createSync(recursive: true); directory.childDirectory('android').createSync(recursive: true); directory.childDirectory('example').createSync(recursive: true); @@ -593,7 +593,7 @@ } Future<FlutterProject> aModuleProject() async { - final Directory directory = fs.directory('module_project'); + final Directory directory = globals.fs.directory('module_project'); directory.childFile('.packages').createSync(recursive: true); directory.childFile('pubspec.yaml').writeAsStringSync(''' name: my_module @@ -610,16 +610,16 @@ void testInMemory(String description, Future<void> testMethod()) { Cache.flutterRoot = getFlutterRoot(); final FileSystem testFileSystem = MemoryFileSystem( - style: platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix, + style: globals.platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix, ); // Transfer needed parts of the Flutter installation folder // to the in-memory file system used during testing. transfer(Cache().getArtifactDirectory('gradle_wrapper'), testFileSystem); - transfer(fs.directory(Cache.flutterRoot) + transfer(globals.fs.directory(Cache.flutterRoot) .childDirectory('packages') .childDirectory('flutter_tools') .childDirectory('templates'), testFileSystem); - transfer(fs.directory(Cache.flutterRoot) + transfer(globals.fs.directory(Cache.flutterRoot) .childDirectory('packages') .childDirectory('flutter_tools') .childDirectory('schema'), testFileSystem);
diff --git a/packages/flutter_tools/test/general.shard/resident_runner_test.dart b/packages/flutter_tools/test/general.shard/resident_runner_test.dart index 187991f..19c4593 100644 --- a/packages/flutter_tools/test/general.shard/resident_runner_test.dart +++ b/packages/flutter_tools/test/general.shard/resident_runner_test.dart
@@ -15,7 +15,7 @@ import 'package:flutter_tools/src/devfs.dart'; import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/features.dart'; -import 'package:flutter_tools/src/globals.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/reporting/reporting.dart'; import 'package:flutter_tools/src/resident_runner.dart'; @@ -42,7 +42,7 @@ setUp(() { testbed = Testbed(setup: () { - fs.file(fs.path.join('build', 'app.dill')) + globals.fs.file(globals.fs.path.join('build', 'app.dill')) ..createSync(recursive: true) ..writeAsStringSync('ABC'); residentRunner = HotRunner( @@ -352,7 +352,7 @@ ], stayResident: false, debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug), - dillOutputPath: fs.path.join('foobar', 'app.dill'), + dillOutputPath: globals.fs.path.join('foobar', 'app.dill'), ); expect(otherRunner.artifactDirectory.path, contains('foobar')); })); @@ -566,7 +566,7 @@ })); test('HotRunner writes vm service file when providing debugging option', () => testbed.run(() async { - fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true); + globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); residentRunner = HotRunner( <FlutterDevice>[ mockFlutterDevice, @@ -582,13 +582,13 @@ }); await residentRunner.run(); - expect(await fs.file('foo').readAsString(), testUri.toString()); + expect(await globals.fs.file('foo').readAsString(), testUri.toString()); })); test('HotRunner unforwards device ports', () => testbed.run(() async { final MockDevicePortForwarder mockPortForwarder = MockDevicePortForwarder(); when(mockDevice.portForwarder).thenReturn(mockPortForwarder); - fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true); + globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); residentRunner = HotRunner( <FlutterDevice>[ mockFlutterDevice, @@ -613,7 +613,7 @@ })); test('HotRunner handles failure to write vmservice file', () => testbed.run(() async { - fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true); + globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); residentRunner = HotRunner( <FlutterDevice>[ mockFlutterDevice, @@ -636,7 +636,7 @@ test('ColdRunner writes vm service file when providing debugging option', () => testbed.run(() async { - fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true); + globals.fs.file(globals.fs.path.join('lib', 'main.dart')).createSync(recursive: true); residentRunner = ColdRunner( <FlutterDevice>[ mockFlutterDevice, @@ -652,7 +652,7 @@ }); await residentRunner.run(); - expect(await fs.file('foo').readAsString(), testUri.toString()); + expect(await globals.fs.file('foo').readAsString(), testUri.toString()); })); test('FlutterDevice uses dartdevc configuration when targeting web', () => testbed.run(() async { @@ -671,10 +671,10 @@ expect(residentCompiler.targetModel, TargetModel.dartdevc); expect(residentCompiler.sdkRoot, - artifacts.getArtifactPath(Artifact.flutterWebSdk, mode: BuildMode.debug) + '/'); + globals.artifacts.getArtifactPath(Artifact.flutterWebSdk, mode: BuildMode.debug) + '/'); expect( residentCompiler.platformDill, - fs.file(artifacts.getArtifactPath(Artifact.webPlatformKernelDill, mode: BuildMode.debug)) + globals.fs.file(globals.artifacts.getArtifactPath(Artifact.webPlatformKernelDill, mode: BuildMode.debug)) .absolute.uri.toString(), ); }, overrides: <Type, Generator>{
diff --git a/packages/flutter_tools/test/general.shard/resident_web_runner_cold_test.dart b/packages/flutter_tools/test/general.shard/resident_web_runner_cold_test.dart index ebf2127..854c39f 100644 --- a/packages/flutter_tools/test/general.shard/resident_web_runner_cold_test.dart +++ b/packages/flutter_tools/test/general.shard/resident_web_runner_cold_test.dart
@@ -6,12 +6,11 @@ import 'package:dwds/dwds.dart'; import 'package:flutter_tools/src/base/common.dart'; -import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/net.dart'; import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/device.dart'; -import 'package:flutter_tools/src/globals.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/resident_runner.dart'; import 'package:flutter_tools/src/build_runner/resident_web_runner.dart'; @@ -65,15 +64,15 @@ }); void _setupMocks() { - fs.file('pubspec.yaml').createSync(); - fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true); - fs.file(fs.path.join('web', 'index.html')).createSync(recursive: true); + 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); when(mockWebFs.connect(any)).thenThrow(StateError('debugging not supported')); } test('Can successfully run and connect without vmservice', () => testbed.run(() async { _setupMocks(); - final DelegateLogger delegateLogger = logger as DelegateLogger; + final DelegateLogger delegateLogger = globals.logger as DelegateLogger; final MockStatus mockStatus = MockStatus(); delegateLogger.status = mockStatus; final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
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 9633014..da322c4 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
@@ -8,7 +8,6 @@ import 'package:build_daemon/client.dart'; import 'package:dwds/dwds.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/net.dart'; @@ -19,7 +18,7 @@ import 'package:flutter_tools/src/devfs.dart'; import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/features.dart'; -import 'package:flutter_tools/src/globals.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/reporting/reporting.dart'; import 'package:flutter_tools/src/resident_runner.dart'; @@ -102,9 +101,9 @@ }); void _setupMocks() { - fs.file('pubspec.yaml').createSync(); - fs.file(fs.path.join('lib', 'main.dart')).createSync(recursive: true); - fs.file(fs.path.join('web', 'index.html')).createSync(recursive: true); + 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); when(mockWebFs.connect(any)).thenAnswer((Invocation _) async { return ConnectionResult(mockAppConnection, mockDebugConnection); }); @@ -224,24 +223,24 @@ })); test('Exits on run if application does not support the web', () => testbed.run(() async { - fs.file('pubspec.yaml').createSync(); + globals.fs.file('pubspec.yaml').createSync(); expect(await residentWebRunner.run(), 1); expect(testLogger.errorText, contains('This application is not configured to build on the web')); })); test('Exits on run if target file does not exist', () => testbed.run(() async { - fs.file('pubspec.yaml').createSync(); - fs.file(fs.path.join('web', 'index.html')).createSync(recursive: true); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file(globals.fs.path.join('web', 'index.html')).createSync(recursive: true); expect(await residentWebRunner.run(), 1); - final String absoluteMain = fs.path.absolute(fs.path.join('lib', 'main.dart')); + final String absoluteMain = globals.fs.path.absolute(globals.fs.path.join('lib', 'main.dart')); expect(testLogger.errorText, contains('Tried to run $absoluteMain, but that file does not exist.')); })); test('Can successfully run and connect to vmservice', () => testbed.run(() async { _setupMocks(); - final DelegateLogger delegateLogger = logger as DelegateLogger; + final DelegateLogger delegateLogger = globals.logger as DelegateLogger; final BufferLogger bufferLogger = delegateLogger.delegate as BufferLogger; final MockStatus status = MockStatus(); delegateLogger.status = status; @@ -832,14 +831,14 @@ )); await connectionInfoCompleter.future; - expect(testLogger.statusText, contains('Launching ${fs.path.join('lib', 'main.dart')} on Chromez in debug mode')); + expect(testLogger.statusText, contains('Launching ${globals.fs.path.join('lib', 'main.dart')} on Chromez in debug mode')); })); test('Sends launched app.webLaunchUrl event for Chrome device', () => testbed.run(() async { _setupMocks(); when(mockFlutterDevice.device).thenReturn(ChromeDevice()); - final DelegateLogger delegateLogger = logger as DelegateLogger; + final DelegateLogger delegateLogger = globals.logger as DelegateLogger; final MockStatus mockStatus = MockStatus(); delegateLogger.status = mockStatus; final ResidentWebRunner runner = DwdsWebRunnerFactory().createWebRunner( @@ -859,7 +858,7 @@ await connectionInfoCompleter.future; // Ensure we got the URL and that it was already launched. - verify(logger.sendEvent( + verify(globals.logger.sendEvent( 'app.webLaunchUrl', argThat(allOf( containsPair('url', 'http://localhost:8765/app/'), @@ -875,7 +874,7 @@ _setupMocks(); when(mockFlutterDevice.device).thenReturn(WebServerDevice()); - final DelegateLogger delegateLogger = logger as DelegateLogger; + final DelegateLogger delegateLogger = globals.logger as DelegateLogger; final MockStatus mockStatus = MockStatus(); delegateLogger.status = mockStatus; final ResidentWebRunner runner = DwdsWebRunnerFactory().createWebRunner( @@ -895,7 +894,7 @@ await connectionInfoCompleter.future; // Ensure we got the URL and that it was not already launched. - verify(logger.sendEvent( + verify(globals.logger.sendEvent( 'app.webLaunchUrl', argThat(allOf( containsPair('url', 'http://localhost:8765/app/'), @@ -1061,7 +1060,7 @@ test('Rethrows unknown exception type from web tooling', () => testbed.run(() async { _setupMocks(); - final DelegateLogger delegateLogger = logger as DelegateLogger; + final DelegateLogger delegateLogger = globals.logger as DelegateLogger; final MockStatus mockStatus = MockStatus(); delegateLogger.status = mockStatus; final Completer<DebugConnectionInfo> connectionInfoCompleter = Completer<DebugConnectionInfo>();
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 6bd474f..a1ae4e8 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
@@ -7,7 +7,6 @@ import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/error_handling_file_system.dart'; -import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/signals.dart'; import 'package:flutter_tools/src/base/time.dart'; @@ -15,6 +14,7 @@ import 'package:flutter_tools/src/reporting/reporting.dart'; import 'package:flutter_tools/src/runner/flutter_command.dart'; import 'package:flutter_tools/src/version.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import '../../src/common.dart'; @@ -70,7 +70,7 @@ testUsingContext('uses the error handling file system', () async { final DummyFlutterCommand flutterCommand = DummyFlutterCommand( commandFunction: () async { - expect(fs, isA<ErrorHandlingFileSystem>()); + expect(globals.fs, isA<ErrorHandlingFileSystem>()); return const FlutterCommandResult(ExitStatus.success); } );
diff --git a/packages/flutter_tools/test/general.shard/test_compiler_test.dart b/packages/flutter_tools/test/general.shard/test_compiler_test.dart index 115e122..c6bc637 100644 --- a/packages/flutter_tools/test/general.shard/test_compiler_test.dart +++ b/packages/flutter_tools/test/general.shard/test_compiler_test.dart
@@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/compile.dart'; import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/test/test_compiler.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import '../src/common.dart'; @@ -21,9 +21,9 @@ setUp(() { testbed = Testbed( setup: () async { - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); - fs.file('test/foo.dart').createSync(recursive: true); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); + globals.fs.file('test/foo.dart').createSync(recursive: true); residentCompiler = MockResidentCompiler(); testCompiler = FakeTestCompiler( BuildMode.debug, @@ -41,12 +41,12 @@ <Uri>[Uri.parse('test/foo.dart')], outputPath: testCompiler.outputDill.path, )).thenAnswer((Invocation invocation) async { - fs.file('abc.dill').createSync(); + globals.fs.file('abc.dill').createSync(); return const CompilerOutput('abc.dill', 0, <Uri>[]); }); expect(await testCompiler.compile('test/foo.dart'), 'test/foo.dart.dill'); - expect(fs.file('test/foo.dart.dill').existsSync(), true); + expect(globals.fs.file('test/foo.dart.dill').existsSync(), true); })); test('Reports null when a compile fails', () => testbed.run(() async { @@ -55,12 +55,12 @@ <Uri>[Uri.parse('test/foo.dart')], outputPath: testCompiler.outputDill.path, )).thenAnswer((Invocation invocation) async { - fs.file('abc.dill').createSync(); + globals.fs.file('abc.dill').createSync(); return const CompilerOutput('abc.dill', 1, <Uri>[]); }); expect(await testCompiler.compile('test/foo.dart'), null); - expect(fs.file('test/foo.dart.dill').existsSync(), false); + expect(globals.fs.file('test/foo.dart.dill').existsSync(), false); verify(residentCompiler.shutdown()).called(1); }));
diff --git a/packages/flutter_tools/test/general.shard/testbed_test.dart b/packages/flutter_tools/test/general.shard/testbed_test.dart index 7d1c396..6e10a6b 100644 --- a/packages/flutter_tools/test/general.shard/testbed_test.dart +++ b/packages/flutter_tools/test/general.shard/testbed_test.dart
@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/base/context.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/error_handling_file_system.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../src/common.dart'; import '../src/testbed.dart'; @@ -22,7 +23,7 @@ FileSystem localFileSystem; await testbed.run(() { - localFileSystem = fs; + localFileSystem = globals.fs; }); expect(localFileSystem, isA<ErrorHandlingFileSystem>());
diff --git a/packages/flutter_tools/test/general.shard/tester/flutter_tester_test.dart b/packages/flutter_tools/test/general.shard/tester/flutter_tester_test.dart index a16ea4d..ea2eed1 100644 --- a/packages/flutter_tools/test/general.shard/tester/flutter_tester_test.dart +++ b/packages/flutter_tools/test/general.shard/tester/flutter_tester_test.dart
@@ -7,36 +7,36 @@ import 'package:file/file.dart'; import 'package:file/memory.dart'; import 'package:flutter_tools/src/artifacts.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/build_system/build_system.dart'; import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/tester/flutter_tester.dart'; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; +import 'package:platform/platform.dart'; import '../../src/common.dart'; import '../../src/context.dart'; import '../../src/mocks.dart'; void main() { - MemoryFileSystem fs; + MemoryFileSystem fileSystem; setUp(() { - fs = MemoryFileSystem(); + fileSystem = MemoryFileSystem(); }); group('FlutterTesterApp', () { testUsingContext('fromCurrentDirectory', () async { const String projectPath = '/home/my/projects/my_project'; - await fs.directory(projectPath).create(recursive: true); - fs.currentDirectory = projectPath; + await fileSystem.directory(projectPath).create(recursive: true); + fileSystem.currentDirectory = projectPath; final FlutterTesterApp app = FlutterTesterApp.fromCurrentDirectory(); expect(app.name, 'my_project'); - expect(app.packagesFile.path, fs.path.join(projectPath, '.packages')); + expect(app.packagesFile.path, fileSystem.path.join(projectPath, '.packages')); }, overrides: <Type, Generator>{ - FileSystem: () => fs, + FileSystem: () => fileSystem, ProcessManager: () => FakeProcessManager.any(), }); }); @@ -106,7 +106,7 @@ final Map<Type, Generator> startOverrides = <Type, Generator>{ Platform: () => FakePlatform(operatingSystem: 'linux'), - FileSystem: () => fs, + FileSystem: () => fileSystem, ProcessManager: () => mockProcessManager, Artifacts: () => mockArtifacts, BuildSystem: () => mockBuildSystem, @@ -114,23 +114,23 @@ setUp(() { mockBuildSystem = MockBuildSystem(); - flutterRoot = fs.path.join('home', 'me', 'flutter'); - flutterTesterPath = fs.path.join(flutterRoot, 'bin', 'cache', + flutterRoot = fileSystem.path.join('home', 'me', 'flutter'); + flutterTesterPath = fileSystem.path.join(flutterRoot, 'bin', 'cache', 'artifacts', 'engine', 'linux-x64', 'flutter_tester'); - final File flutterTesterFile = fs.file(flutterTesterPath); + final File flutterTesterFile = fileSystem.file(flutterTesterPath); flutterTesterFile.parent.createSync(recursive: true); flutterTesterFile.writeAsBytesSync(const <int>[]); - projectPath = fs.path.join('home', 'me', 'hello'); - mainPath = fs.path.join(projectPath, 'lin', 'main.dart'); + projectPath = fileSystem.path.join('home', 'me', 'hello'); + mainPath = fileSystem.path.join(projectPath, 'lin', 'main.dart'); mockProcessManager = MockProcessManager(); mockProcessManager.processFactory = (List<String> commands) => mockProcess; mockArtifacts = MockArtifacts(); - final String artifactPath = fs.path.join(flutterRoot, 'artifact'); - fs.file(artifactPath).createSync(recursive: true); + final String artifactPath = fileSystem.path.join(flutterRoot, 'artifact'); + fileSystem.file(artifactPath).createSync(recursive: true); when(mockArtifacts.getArtifactPath( any, mode: anyNamed('mode') @@ -140,7 +140,7 @@ any, any, )).thenAnswer((_) async { - fs.file('$mainPath.dill').createSync(recursive: true); + fileSystem.file('$mainPath.dill').createSync(recursive: true); return BuildResult(success: true); }); });
diff --git a/packages/flutter_tools/test/general.shard/vscode_test.dart b/packages/flutter_tools/test/general.shard/vscode_test.dart index afc4744..8e58859 100644 --- a/packages/flutter_tools/test/general.shard/vscode_test.dart +++ b/packages/flutter_tools/test/general.shard/vscode_test.dart
@@ -7,7 +7,7 @@ import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/version.dart'; -import 'package:flutter_tools/src/globals.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/vscode/vscode.dart'; import '../src/common.dart'; @@ -15,9 +15,9 @@ void main() { testUsingContext('VsCode.fromDirectory does not crash when packages.json is malformed', () { - final BufferLogger bufferLogger = logger as BufferLogger; + final BufferLogger bufferLogger = globals.logger as BufferLogger; // Create invalid JSON file. - fs.file(fs.path.join('', 'resources', 'app', 'package.json')) + globals.fs.file(globals.fs.path.join('', 'resources', 'app', 'package.json')) ..createSync(recursive: true) ..writeAsStringSync('{');
diff --git a/packages/flutter_tools/test/general.shard/web/asset_server_test.dart b/packages/flutter_tools/test/general.shard/web/asset_server_test.dart index c51b93c..d964a5b 100644 --- a/packages/flutter_tools/test/general.shard/web/asset_server_test.dart +++ b/packages/flutter_tools/test/general.shard/web/asset_server_test.dart
@@ -6,7 +6,7 @@ import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/build_runner/web_fs.dart'; -import 'package:flutter_tools/src/globals.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/project.dart'; import 'package:shelf/shelf.dart'; @@ -28,18 +28,18 @@ setUp(() { testbed = Testbed( setup: () { - fs.file(fs.path.join('lib', 'main.dart')) + globals.fs.file(globals.fs.path.join('lib', 'main.dart')) .createSync(recursive: true); - fs.file(fs.path.join('web', 'index.html')) + globals.fs.file(globals.fs.path.join('web', 'index.html')) ..createSync(recursive: true) ..writeAsStringSync('hello'); - fs.file(fs.path.join('build', 'flutter_assets', 'foo.png')) + globals.fs.file(globals.fs.path.join('build', 'flutter_assets', 'foo.png')) ..createSync(recursive: true) ..writeAsBytesSync(kTransparentImage); - fs.file(fs.path.join('build', 'flutter_assets', 'bar')) + globals.fs.file(globals.fs.path.join('build', 'flutter_assets', 'bar')) ..createSync(recursive: true) ..writeAsBytesSync(<int>[1, 2, 3]); - assetServer = DebugAssetServer(FlutterProject.current(), fs.path.join('main')); + assetServer = DebugAssetServer(FlutterProject.current(), globals.fs.path.join('main')); } ); }); @@ -56,8 +56,8 @@ })); test('can serve a sourcemap from dart:ui', () => testbed.run(() async { - final String flutterWebSdkPath = artifacts.getArtifactPath(Artifact.flutterWebSdk); - final File windowSourceFile = fs.file(fs.path.join(flutterWebSdkPath, 'lib', 'ui', 'src', 'ui', 'window.dart')) + final String flutterWebSdkPath = globals.artifacts.getArtifactPath(Artifact.flutterWebSdk); + final File windowSourceFile = globals.fs.file(globals.fs.path.join(flutterWebSdkPath, 'lib', 'ui', 'src', 'ui', 'window.dart')) ..createSync(recursive: true) ..writeAsStringSync('test'); final Response response = await assetServer @@ -70,8 +70,8 @@ })); test('can serve a sourcemap from the dart:sdk', () => testbed.run(() async { - final String dartSdkPath = artifacts.getArtifactPath(Artifact.engineDartSdkPath); - final File listSourceFile = fs.file(fs.path.join(dartSdkPath, 'lib', 'core', 'list.dart')) + final String dartSdkPath = globals.artifacts.getArtifactPath(Artifact.engineDartSdkPath); + final File listSourceFile = globals.fs.file(globals.fs.path.join(dartSdkPath, 'lib', 'core', 'list.dart')) ..createSync(recursive: true) ..writeAsStringSync('test'); @@ -113,7 +113,7 @@ test('release asset server serves correct mime type and content length for png', () => testbed.run(() async { assetServer = ReleaseAssetServer(); - fs.file(fs.path.join('build', 'web', 'assets', 'foo.png')) + globals.fs.file(globals.fs.path.join('build', 'web', 'assets', 'foo.png')) ..createSync(recursive: true) ..writeAsBytesSync(kTransparentImage); final Response response = await assetServer @@ -127,7 +127,7 @@ test('release asset server serves correct mime type and content length for JavaScript', () => testbed.run(() async { assetServer = ReleaseAssetServer(); - fs.file(fs.path.join('build', 'web', 'assets', 'foo.js')) + globals.fs.file(globals.fs.path.join('build', 'web', 'assets', 'foo.js')) ..createSync(recursive: true) ..writeAsStringSync('function main() {}'); final Response response = await assetServer @@ -141,7 +141,7 @@ test('release asset server serves correct mime type and content length for html', () => testbed.run(() async { assetServer = ReleaseAssetServer(); - fs.file(fs.path.join('build', 'web', 'assets', 'foo.html')) + globals.fs.file(globals.fs.path.join('build', 'web', 'assets', 'foo.html')) ..createSync(recursive: true) ..writeAsStringSync('<!doctype html><html></html>'); final Response response = await assetServer @@ -155,7 +155,7 @@ test('release asset server serves content from flutter root', () => testbed.run(() async { assetServer = ReleaseAssetServer(); - fs.file(fs.path.join('flutter', 'bar.dart')) + globals.fs.file(globals.fs.path.join('flutter', 'bar.dart')) ..createSync(recursive: true) ..writeAsStringSync('void main() { }'); final Response response = await assetServer @@ -166,7 +166,7 @@ test('release asset server serves content from project directory', () => testbed.run(() async { assetServer = ReleaseAssetServer(); - fs.file(fs.path.join('lib', 'bar.dart')) + globals.fs.file(globals.fs.path.join('lib', 'bar.dart')) ..createSync(recursive: true) ..writeAsStringSync('void main() { }'); final Response response = await assetServer
diff --git a/packages/flutter_tools/test/general.shard/web/chrome_test.dart b/packages/flutter_tools/test/general.shard/web/chrome_test.dart index 48ad64c..3e10239 100644 --- a/packages/flutter_tools/test/general.shard/web/chrome_test.dart +++ b/packages/flutter_tools/test/general.shard/web/chrome_test.dart
@@ -6,12 +6,12 @@ import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/os.dart'; -import 'package:flutter_tools/src/base/platform.dart'; -import 'package:flutter_tools/src/base/process_manager.dart'; import 'package:flutter_tools/src/convert.dart'; import 'package:flutter_tools/src/web/chrome.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; +import 'package:platform/platform.dart'; import '../../src/common.dart'; import '../../src/mocks.dart'; @@ -36,7 +36,7 @@ when(platform.environment).thenReturn(<String, String>{ kChromeEnvironment: 'example_chrome', }); - when(processManager.start(any)) + when(globals.processManager.start(any)) .thenAnswer((Invocation invocation) async { return FakeProcess( exitCode: exitCompleter.future, @@ -69,13 +69,13 @@ ]; await chromeLauncher.launch('example_url', skipCheck: true); - final VerificationResult result = verify(processManager.start(captureAny)); + final VerificationResult result = verify(globals.processManager.start(captureAny)); expect(result.captured.single, containsAll(expected)); })); test('can seed chrome temp directory with existing preferences', () => testbed.run(() async { - final Directory dataDir = fs.directory('chrome-stuff'); + final Directory dataDir = globals.fs.directory('chrome-stuff'); final File preferencesFile = dataDir .childDirectory('Default') .childFile('preferences'); @@ -84,10 +84,10 @@ ..writeAsStringSync('example'); await chromeLauncher.launch('example_url', skipCheck: true, dataDir: dataDir); - final VerificationResult result = verify(processManager.start(captureAny)); + final VerificationResult result = verify(globals.processManager.start(captureAny)); final String arg = (result.captured.single as List<String>) .firstWhere((String arg) => arg.startsWith('--user-data-dir=')); - final Directory tempDirectory = fs.directory(arg.split('=')[1]); + final Directory tempDirectory = globals.fs.directory(arg.split('=')[1]); final File tempFile = tempDirectory .childDirectory('Default') .childFile('preferences');
diff --git a/packages/flutter_tools/test/general.shard/web/devfs_web_test.dart b/packages/flutter_tools/test/general.shard/web/devfs_web_test.dart index 3b735e7..1c63148 100644 --- a/packages/flutter_tools/test/general.shard/web/devfs_web_test.dart +++ b/packages/flutter_tools/test/general.shard/web/devfs_web_test.dart
@@ -8,10 +8,11 @@ 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/platform.dart'; import 'package:flutter_tools/src/convert.dart'; import 'package:flutter_tools/src/web/devfs_web.dart'; import 'package:mockito/mockito.dart'; +import 'package:platform/platform.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../../src/common.dart'; import '../../src/testbed.dart'; @@ -87,18 +88,18 @@ })); test('Handles against malformed manifest', () => testbed.run(() async { - final File source = fs.file('source') + final File source = globals.fs.file('source') ..writeAsStringSync('main() {}'); - final File sourcemap = fs.file('sourcemap') + final File sourcemap = globals.fs.file('sourcemap') ..writeAsStringSync('{}'); // Missing ending offset. - final File manifestMissingOffset = fs.file('manifestA') + final File manifestMissingOffset = globals.fs.file('manifestA') ..writeAsStringSync(json.encode(<String, Object>{'/foo.js': <String, Object>{ 'code': <int>[0], 'sourcemap': <int>[0], }})); - final File manifestOutOfBounds = fs.file('manifest') + final File manifestOutOfBounds = globals.fs.file('manifest') ..writeAsStringSync(json.encode(<String, Object>{'/foo.js': <String, Object>{ 'code': <int>[0, 100], 'sourcemap': <int>[0], @@ -109,11 +110,11 @@ })); test('serves JavaScript files from in memory cache', () => testbed.run(() async { - final File source = fs.file('source') + final File source = globals.fs.file('source') ..writeAsStringSync('main() {}'); - final File sourcemap = fs.file('sourcemap') + final File sourcemap = globals.fs.file('sourcemap') ..writeAsStringSync('{}'); - final File manifest = fs.file('manifest') + final File manifest = globals.fs.file('manifest') ..writeAsStringSync(json.encode(<String, Object>{'/foo.js': <String, Object>{ 'code': <int>[0, source.lengthSync()], 'sourcemap': <int>[0, 2], @@ -132,11 +133,11 @@ })); test('serves JavaScript files from in memory cache on Windows', () => testbed.run(() async { - final File source = fs.file('source') + final File source = globals.fs.file('source') ..writeAsStringSync('main() {}'); - final File sourcemap = fs.file('sourcemap') + final File sourcemap = globals.fs.file('sourcemap') ..writeAsStringSync('{}'); - final File manifest = fs.file('manifest') + final File manifest = globals.fs.file('manifest') ..writeAsStringSync(json.encode(<String, Object>{'/C:/foo.js': <String, Object>{ 'code': <int>[0, source.lengthSync()], 'sourcemap': <int>[0, 2], @@ -167,11 +168,11 @@ })); test('handles missing JavaScript files from in memory cache', () => testbed.run(() async { - final File source = fs.file('source') + final File source = globals.fs.file('source') ..writeAsStringSync('main() {}'); - final File sourcemap = fs.file('sourcemap') + final File sourcemap = globals.fs.file('sourcemap') ..writeAsStringSync('{}'); - final File manifest = fs.file('manifest') + final File manifest = globals.fs.file('manifest') ..writeAsStringSync(json.encode(<String, Object>{'/foo.js': <String, Object>{ 'code': <int>[0, source.lengthSync()], 'sourcemap': <int>[0, 2], @@ -186,7 +187,7 @@ })); test('serves Dart files from in filesystem on Windows', () => testbed.run(() async { - final File source = fs.file('foo.dart').absolute + final File source = globals.fs.file('foo.dart').absolute ..createSync(recursive: true) ..writeAsStringSync('void main() {}'); @@ -201,7 +202,7 @@ })); test('serves Dart files from in filesystem on Linux/macOS', () => testbed.run(() async { - final File source = fs.file('foo.dart').absolute + final File source = globals.fs.file('foo.dart').absolute ..createSync(recursive: true) ..writeAsStringSync('void main() {}'); @@ -224,7 +225,7 @@ })); test('serves asset files from in filesystem with known mime type', () => testbed.run(() async { - final File source = fs.file(fs.path.join('build', 'flutter_assets', 'foo.png')) + final File source = globals.fs.file(globals.fs.path.join('build', 'flutter_assets', 'foo.png')) ..createSync(recursive: true) ..writeAsBytesSync(kTransparentImage); @@ -238,7 +239,7 @@ })); test('serves asset files from in filesystem with known mime type on Windows', () => testbed.run(() async { - final File source = fs.file(fs.path.join('build', 'flutter_assets', 'foo.png')) + final File source = globals.fs.file(globals.fs.path.join('build', 'flutter_assets', 'foo.png')) ..createSync(recursive: true) ..writeAsBytesSync(kTransparentImage); @@ -255,7 +256,7 @@ test('serves asset files files from in filesystem with unknown mime type and length > 12', () => testbed.run(() async { - final File source = fs.file(fs.path.join('build', 'flutter_assets', 'foo')) + final File source = globals.fs.file(globals.fs.path.join('build', 'flutter_assets', 'foo')) ..createSync(recursive: true) ..writeAsBytesSync(List<int>.filled(100, 0)); @@ -269,7 +270,7 @@ })); test('serves asset files files from in filesystem with unknown mime type and length < 12', () => testbed.run(() async { - final File source = fs.file(fs.path.join('build', 'flutter_assets', 'foo')) + final File source = globals.fs.file(globals.fs.path.join('build', 'flutter_assets', 'foo')) ..createSync(recursive: true) ..writeAsBytesSync(<int>[1, 2, 3]);
diff --git a/packages/flutter_tools/test/general.shard/web/devices_test.dart b/packages/flutter_tools/test/general.shard/web/devices_test.dart index 20afe07..47958a7 100644 --- a/packages/flutter_tools/test/general.shard/web/devices_test.dart +++ b/packages/flutter_tools/test/general.shard/web/devices_test.dart
@@ -3,12 +3,12 @@ // found in the LICENSE file. import 'package:flutter_tools/src/base/io.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/web/chrome.dart'; import 'package:flutter_tools/src/web/web_device.dart'; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; +import 'package:platform/platform.dart'; import '../../src/common.dart'; import '../../src/context.dart';
diff --git a/packages/flutter_tools/test/general.shard/web/golden_comparator_process_test.dart b/packages/flutter_tools/test/general.shard/web/golden_comparator_process_test.dart index 2cc377b..127a635 100644 --- a/packages/flutter_tools/test/general.shard/web/golden_comparator_process_test.dart +++ b/packages/flutter_tools/test/general.shard/web/golden_comparator_process_test.dart
@@ -6,6 +6,7 @@ import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/test/flutter_web_platform.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../../src/common.dart'; import '../../src/mocks.dart'; @@ -22,9 +23,9 @@ MockProcess Function(String) createMockProcess; setUpAll(() { - imageFile = fs.file('test_image_file'); + imageFile = globals.fs.file('test_image_file'); goldenKey = Uri.parse('file://golden_key'); - imageFile2 = fs.file('second_test_image_file'); + imageFile2 = globals.fs.file('second_test_image_file'); goldenKey2 = Uri.parse('file://second_golden_key'); createMockProcess = (String stdout) => MockProcess( exitCode: Future<int>.value(0),
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 e2e1c74..eab269e 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
@@ -6,9 +6,9 @@ import 'dart:convert'; import 'dart:typed_data'; -import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/test/flutter_web_platform.dart'; import 'package:flutter_tools/src/test/test_compiler.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; @@ -175,7 +175,7 @@ expect(result, null); await comparator.close(); - expect(fs.systemTempDirectory.listSync(recursive: true), isEmpty); + expect(globals.fs.systemTempDirectory.listSync(recursive: true), isEmpty); })); }); }
diff --git a/packages/flutter_tools/test/general.shard/web/web_fs_test.dart b/packages/flutter_tools/test/general.shard/web/web_fs_test.dart index dd372e3..a81216d 100644 --- a/packages/flutter_tools/test/general.shard/web/web_fs_test.dart +++ b/packages/flutter_tools/test/general.shard/web/web_fs_test.dart
@@ -7,7 +7,6 @@ import 'package:built_collection/built_collection.dart'; import 'package:dwds/asset_handler.dart'; import 'package:dwds/dwds.dart'; -import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/os.dart'; import 'package:flutter_tools/src/base/process.dart'; import 'package:flutter_tools/src/build_info.dart'; @@ -15,6 +14,7 @@ import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/web/chrome.dart'; import 'package:flutter_tools/src/build_runner/web_fs.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:http_multi_server/http_multi_server.dart'; import 'package:meta/meta.dart'; import 'package:mockito/mockito.dart'; @@ -61,7 +61,7 @@ environment: anyNamed('environment'), )).thenAnswer((Invocation invocation) async { final String workingDirectory = invocation.namedArguments[#workingDirectory] as String; - fs.file(fs.path.join(workingDirectory, '.packages')).createSync(recursive: true); + globals.fs.file(globals.fs.path.join(workingDirectory, '.packages')).createSync(recursive: true); return 0; }); when(mockBuildDaemonClient.buildResults).thenAnswer((Invocation _) { @@ -81,12 +81,12 @@ when(mockBuildDaemonCreator.assetServerPort(any)).thenReturn(4321); testbed = Testbed( setup: () { - fs.file(fs.path.join('packages', 'flutter_tools', 'pubspec.yaml')) + globals.fs.file(globals.fs.path.join('packages', 'flutter_tools', 'pubspec.yaml')) ..createSync(recursive: true) ..setLastModifiedSync(DateTime(1991, 08, 23)); // Create an empty .packages file so we can read it when we check for - // plugins on WebFs.start() - fs.file('.packages').createSync(); + // plugins on Webglobals.fs.start() + globals.fs.file('.packages').createSync(); }, overrides: <Type, Generator>{ Pub: () => MockPub(), @@ -121,7 +121,7 @@ final FlutterProject flutterProject = FlutterProject.current(); await WebFs.start( skipDwds: false, - target: fs.path.join('lib', 'main.dart'), + target: globals.fs.path.join('lib', 'main.dart'), buildInfo: BuildInfo.debug, flutterProject: flutterProject, initializePlatform: true, @@ -152,7 +152,7 @@ final FlutterProject flutterProject = FlutterProject.current(); await WebFs.start( skipDwds: false, - target: fs.path.join('lib', 'main.dart'), + target: globals.fs.path.join('lib', 'main.dart'), buildInfo: BuildInfo.debug, flutterProject: flutterProject, initializePlatform: false, @@ -174,7 +174,7 @@ final FlutterProject flutterProject = FlutterProject.current(); final WebFs webFs = await WebFs.start( skipDwds: false, - target: fs.path.join('lib', 'main.dart'), + target: globals.fs.path.join('lib', 'main.dart'), buildInfo: BuildInfo.debug, flutterProject: flutterProject, initializePlatform: false, @@ -208,7 +208,7 @@ expect(WebFs.start( skipDwds: false, - target: fs.path.join('lib', 'main.dart'), + target: globals.fs.path.join('lib', 'main.dart'), buildInfo: BuildInfo.debug, flutterProject: flutterProject, initializePlatform: false,
diff --git a/packages/flutter_tools/test/general.shard/web/web_validator_test.dart b/packages/flutter_tools/test/general.shard/web/web_validator_test.dart index 4717ba6..2bcdb9d 100644 --- a/packages/flutter_tools/test/general.shard/web/web_validator_test.dart +++ b/packages/flutter_tools/test/general.shard/web/web_validator_test.dart
@@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/doctor.dart'; import 'package:flutter_tools/src/web/chrome.dart'; import 'package:flutter_tools/src/web/web_validator.dart'; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; +import 'package:platform/platform.dart'; import '../../src/common.dart'; import '../../src/testbed.dart';
diff --git a/packages/flutter_tools/test/general.shard/web/workflow_test.dart b/packages/flutter_tools/test/general.shard/web/workflow_test.dart index 483c3cb..0adeac2 100644 --- a/packages/flutter_tools/test/general.shard/web/workflow_test.dart +++ b/packages/flutter_tools/test/general.shard/web/workflow_test.dart
@@ -2,13 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter_tools/src/base/file_system.dart'; -import 'package:flutter_tools/src/base/platform.dart'; + import 'package:flutter_tools/src/features.dart'; import 'package:flutter_tools/src/web/chrome.dart'; import 'package:flutter_tools/src/web/workflow.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; +import 'package:platform/platform.dart'; import '../../src/common.dart'; import '../../src/context.dart'; @@ -32,7 +33,7 @@ workflow = const WebWorkflow(); mockProcessManager = MockProcessManager(); testbed = Testbed(setup: () async { - fs.file('chrome').createSync(); + globals.fs.file('chrome').createSync(); when(mockProcessManager.canRun('chrome')).thenReturn(true); }, overrides: <Type, Generator>{ FeatureFlags: () => TestFeatureFlags(isWebEnabled: true),
diff --git a/packages/flutter_tools/test/general.shard/windows/visual_studio_test.dart b/packages/flutter_tools/test/general.shard/windows/visual_studio_test.dart index 6a9935e..008d1b0 100644 --- a/packages/flutter_tools/test/general.shard/windows/visual_studio_test.dart +++ b/packages/flutter_tools/test/general.shard/windows/visual_studio_test.dart
@@ -5,11 +5,13 @@ import 'package:file/memory.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart' show ProcessException, ProcessResult; -import 'package:flutter_tools/src/base/platform.dart'; + import 'package:flutter_tools/src/convert.dart'; import 'package:flutter_tools/src/windows/visual_studio.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; +import 'package:platform/platform.dart'; import '../../src/common.dart'; import '../../src/context.dart'; @@ -73,8 +75,8 @@ Map<String, dynamic> response, String responseOverride, ]) { - fs.file(vswherePath).createSync(recursive: true); - fs.file(vcvarsPath).createSync(recursive: true); + globals.fs.file(vswherePath).createSync(recursive: true); + globals.fs.file(vcvarsPath).createSync(recursive: true); final MockProcessResult result = MockProcessResult(); when(result.exitCode).thenReturn(0);
diff --git a/packages/flutter_tools/test/general.shard/windows/windows_device_test.dart b/packages/flutter_tools/test/general.shard/windows/windows_device_test.dart index f59642f..319cf55 100644 --- a/packages/flutter_tools/test/general.shard/windows/windows_device_test.dart +++ b/packages/flutter_tools/test/general.shard/windows/windows_device_test.dart
@@ -4,13 +4,14 @@ import 'package:file/memory.dart'; import 'package:flutter_tools/src/base/file_system.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/windows/application_package.dart'; import 'package:flutter_tools/src/windows/windows_device.dart'; import 'package:flutter_tools/src/device.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; +import 'package:platform/platform.dart'; import '../../src/common.dart'; import '../../src/context.dart'; @@ -41,9 +42,9 @@ }); testUsingContext('isSupportedForProject is true with editable host app', () async { - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); - fs.directory('windows').createSync(); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); + globals.fs.directory('windows').createSync(); final FlutterProject flutterProject = FlutterProject.current(); expect(WindowsDevice().isSupportedForProject(flutterProject), true); @@ -53,8 +54,8 @@ }); testUsingContext('isSupportedForProject is false with no host app', () async { - fs.file('pubspec.yaml').createSync(); - fs.file('.packages').createSync(); + globals.fs.file('pubspec.yaml').createSync(); + globals.fs.file('.packages').createSync(); final FlutterProject flutterProject = FlutterProject.current(); expect(WindowsDevice().isSupportedForProject(flutterProject), false);
diff --git a/packages/flutter_tools/test/general.shard/windows/windows_workflow_test.dart b/packages/flutter_tools/test/general.shard/windows/windows_workflow_test.dart index 93a6e30..2a047d0 100644 --- a/packages/flutter_tools/test/general.shard/windows/windows_workflow_test.dart +++ b/packages/flutter_tools/test/general.shard/windows/windows_workflow_test.dart
@@ -4,8 +4,7 @@ import 'package:flutter_tools/src/features.dart'; import 'package:mockito/mockito.dart'; - -import 'package:flutter_tools/src/base/platform.dart'; +import 'package:platform/platform.dart'; import 'package:flutter_tools/src/windows/windows_workflow.dart'; import '../../src/common.dart';
diff --git a/packages/flutter_tools/test/integration.shard/daemon_mode_test.dart b/packages/flutter_tools/test/integration.shard/daemon_mode_test.dart index 571da8a..fbf4163 100644 --- a/packages/flutter_tools/test/integration.shard/daemon_mode_test.dart +++ b/packages/flutter_tools/test/integration.shard/daemon_mode_test.dart
@@ -9,6 +9,7 @@ import 'package:file/file.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:process/process.dart'; import '../src/common.dart'; @@ -23,7 +24,7 @@ final BasicProject _project = BasicProject(); await _project.setUpIn(tempDir); - final String flutterBin = fs.path.join(getFlutterRoot(), 'bin', 'flutter'); + final String flutterBin = globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter'); const ProcessManager processManager = LocalProcessManager(); final Process process = await processManager.start(
diff --git a/packages/flutter_tools/test/integration.shard/flutter_run_test.dart b/packages/flutter_tools/test/integration.shard/flutter_run_test.dart index d4d1902..e1bfcab 100644 --- a/packages/flutter_tools/test/integration.shard/flutter_run_test.dart +++ b/packages/flutter_tools/test/integration.shard/flutter_run_test.dart
@@ -5,6 +5,7 @@ import 'package:file/file.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:process/process.dart'; import '../src/common.dart'; @@ -33,7 +34,7 @@ // like https://github.com/flutter/flutter/issues/21418 which were skipped // over because other integration tests run using flutter-tester which short-cuts // some of the checks for devices. - final String flutterBin = fs.path.join(getFlutterRoot(), 'bin', 'flutter'); + final String flutterBin = globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter'); const ProcessManager _processManager = LocalProcessManager(); final ProcessResult _proc = await _processManager.run(
diff --git a/packages/flutter_tools/test/integration.shard/test_data/hot_reload_project.dart b/packages/flutter_tools/test/integration.shard/test_data/hot_reload_project.dart index 7462ffa..47ae295 100644 --- a/packages/flutter_tools/test/integration.shard/test_data/hot_reload_project.dart +++ b/packages/flutter_tools/test/integration.shard/test_data/hot_reload_project.dart
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'package:flutter_tools/src/base/file_system.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../test_utils.dart'; import 'project.dart'; @@ -86,6 +86,6 @@ '// printHotReloadWorked();', 'printHotReloadWorked();', ); - writeFile(fs.path.join(dir.path, 'lib', 'main.dart'), newMainContents); + writeFile(globals.fs.path.join(dir.path, 'lib', 'main.dart'), newMainContents); } }
diff --git a/packages/flutter_tools/test/integration.shard/test_data/project.dart b/packages/flutter_tools/test/integration.shard/test_data/project.dart index d98147f..cee6092 100644 --- a/packages/flutter_tools/test/integration.shard/test_data/project.dart +++ b/packages/flutter_tools/test/integration.shard/test_data/project.dart
@@ -6,6 +6,7 @@ import 'package:file/file.dart'; import 'package:flutter_tools/src/base/file_system.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../test_utils.dart'; @@ -19,9 +20,9 @@ Future<void> setUpIn(Directory dir) async { this.dir = dir; - writeFile(fs.path.join(dir.path, 'pubspec.yaml'), pubspec); + writeFile(globals.fs.path.join(dir.path, 'pubspec.yaml'), pubspec); if (main != null) { - writeFile(fs.path.join(dir.path, 'lib', 'main.dart'), main); + writeFile(globals.fs.path.join(dir.path, 'lib', 'main.dart'), main); } await getPackages(dir.path); }
diff --git a/packages/flutter_tools/test/integration.shard/test_data/tests_project.dart b/packages/flutter_tools/test/integration.shard/test_data/tests_project.dart index 0abad69..c452bb6 100644 --- a/packages/flutter_tools/test/integration.shard/test_data/tests_project.dart +++ b/packages/flutter_tools/test/integration.shard/test_data/tests_project.dart
@@ -5,6 +5,7 @@ import 'package:file/file.dart'; import 'package:flutter_tools/src/base/file_system.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../test_utils.dart'; import 'project.dart'; @@ -45,7 +46,7 @@ return super.setUpIn(dir); } - String get testFilePath => fs.path.join(dir.path, 'test', 'test.dart'); + String get testFilePath => globals.fs.path.join(dir.path, 'test', 'test.dart'); Uri get breakpointUri => Uri.file(testFilePath);
diff --git a/packages/flutter_tools/test/integration.shard/test_driver.dart b/packages/flutter_tools/test/integration.shard/test_driver.dart index ff881e1..8dc062f 100644 --- a/packages/flutter_tools/test/integration.shard/test_driver.dart +++ b/packages/flutter_tools/test/integration.shard/test_driver.dart
@@ -10,6 +10,7 @@ import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/utils.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:meta/meta.dart'; import 'package:process/process.dart'; import 'package:vm_service/vm_service.dart'; @@ -83,7 +84,7 @@ bool withDebugger = false, File pidFile, }) async { - final String flutterBin = fs.path.join(getFlutterRoot(), 'bin', 'flutter'); + final String flutterBin = globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter'); if (withDebugger) { arguments.add('--start-paused'); }
diff --git a/packages/flutter_tools/test/integration.shard/test_utils.dart b/packages/flutter_tools/test/integration.shard/test_utils.dart index 1833a2d..5aa7549 100644 --- a/packages/flutter_tools/test/integration.shard/test_utils.dart +++ b/packages/flutter_tools/test/integration.shard/test_utils.dart
@@ -6,7 +6,7 @@ import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/io.dart'; -import 'package:flutter_tools/src/base/process_manager.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import '../src/common.dart'; @@ -15,24 +15,24 @@ /// https://github.com/flutter/flutter/pull/21741 Directory createResolvedTempDirectorySync(String prefix) { assert(prefix.endsWith('.')); - final Directory tempDirectory = fs.systemTempDirectory.createTempSync('flutter_$prefix'); - return fs.directory(tempDirectory.resolveSymbolicLinksSync()); + final Directory tempDirectory = globals.fs.systemTempDirectory.createTempSync('flutter_$prefix'); + return globals.fs.directory(tempDirectory.resolveSymbolicLinksSync()); } void writeFile(String path, String content) { - fs.file(path) + globals.fs.file(path) ..createSync(recursive: true) ..writeAsStringSync(content); } void writePackages(String folder) { - writeFile(fs.path.join(folder, '.packages'), ''' -test:${fs.path.join(fs.currentDirectory.path, 'lib')}/ + writeFile(globals.fs.path.join(folder, '.packages'), ''' +test:${globals.fs.path.join(globals.fs.currentDirectory.path, 'lib')}/ '''); } void writePubspec(String folder) { - writeFile(fs.path.join(folder, 'pubspec.yaml'), ''' + writeFile(globals.fs.path.join(folder, 'pubspec.yaml'), ''' name: test dependencies: flutter: @@ -42,11 +42,11 @@ Future<void> getPackages(String folder) async { final List<String> command = <String>[ - fs.path.join(getFlutterRoot(), 'bin', 'flutter'), + globals.fs.path.join(getFlutterRoot(), 'bin', 'flutter'), 'pub', 'get', ]; - final ProcessResult result = await processManager.run(command, workingDirectory: folder); + final ProcessResult result = await globals.processManager.run(command, workingDirectory: folder); if (result.exitCode != 0) { throw Exception('flutter pub get failed: ${result.stderr}\n${result.stdout}'); }
diff --git a/packages/flutter_tools/test/src/common.dart b/packages/flutter_tools/test/src/common.dart index c693e52..419674a 100644 --- a/packages/flutter_tools/test/src/common.dart +++ b/packages/flutter_tools/test/src/common.dart
@@ -8,11 +8,12 @@ import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/context.dart'; import 'package:flutter_tools/src/base/file_system.dart'; -import 'package:flutter_tools/src/base/platform.dart'; + import 'package:flutter_tools/src/base/process.dart'; import 'package:flutter_tools/src/commands/create.dart'; import 'package:flutter_tools/src/runner/flutter_command.dart'; import 'package:flutter_tools/src/runner/flutter_command_runner.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:meta/meta.dart'; import 'package:test_api/test_api.dart' as test_package show TypeMatcher, test; // ignore: deprecated_member_use import 'package:test_api/test_api.dart' hide TypeMatcher, isInstanceOf; // ignore: deprecated_member_use @@ -40,20 +41,20 @@ /// environment variable is set, it will be returned. Otherwise, this will /// deduce the path from `platform.script`. String getFlutterRoot() { - if (platform.environment.containsKey('FLUTTER_ROOT')) { - return platform.environment['FLUTTER_ROOT']; + if (globals.platform.environment.containsKey('FLUTTER_ROOT')) { + return globals.platform.environment['FLUTTER_ROOT']; } - Error invalidScript() => StateError('Could not determine flutter_tools/ path from script URL (${platform.script}); consider setting FLUTTER_ROOT explicitly.'); + Error invalidScript() => StateError('Could not determine flutter_tools/ path from script URL (${globals.platform.script}); consider setting FLUTTER_ROOT explicitly.'); Uri scriptUri; - switch (platform.script.scheme) { + switch (globals.platform.script.scheme) { case 'file': - scriptUri = platform.script; + scriptUri = globals.platform.script; break; case 'data': final RegExp flutterTools = RegExp(r'(file://[^"]*[/\\]flutter_tools[/\\][^"]+\.dart)', multiLine: true); - final Match match = flutterTools.firstMatch(Uri.decodeFull(platform.script.path)); + final Match match = flutterTools.firstMatch(Uri.decodeFull(globals.platform.script.path)); if (match == null) { throw invalidScript(); } @@ -63,13 +64,13 @@ throw invalidScript(); } - final List<String> parts = fs.path.split(fs.path.fromUri(scriptUri)); + final List<String> parts = globals.fs.path.split(globals.fs.path.fromUri(scriptUri)); final int toolsIndex = parts.indexOf('flutter_tools'); if (toolsIndex == -1) { throw invalidScript(); } - final String toolsPath = fs.path.joinAll(parts.sublist(0, toolsIndex + 1)); - return fs.path.normalize(fs.path.join(toolsPath, '..', '..')); + final String toolsPath = globals.fs.path.joinAll(parts.sublist(0, toolsIndex + 1)); + return globals.fs.path.normalize(globals.fs.path.join(toolsPath, '..', '..')); } CommandRunner<void> createTestCommandRunner([ FlutterCommand command ]) { @@ -87,7 +88,7 @@ int seconds, ) { final DateTime modificationTime = baseTime.add(Duration(seconds: seconds)); - fs.file(path).setLastModifiedSync(modificationTime); + globals.fs.file(path).setLastModifiedSync(modificationTime); } /// Matcher for functions that throw [ToolExit]. @@ -120,12 +121,12 @@ /// Returns the path to the flutter project. Future<String> createProject(Directory temp, { List<String> arguments }) async { arguments ??= <String>['--no-pub']; - final String projectPath = fs.path.join(temp.path, 'flutter_project'); + final String projectPath = globals.fs.path.join(temp.path, 'flutter_project'); final CreateCommand command = CreateCommand(); final CommandRunner<void> runner = createTestCommandRunner(command); await runner.run(<String>['create', ...arguments, projectPath]); // Created `.packages` since it's not created when the flag `--no-pub` is passed. - fs.file(fs.path.join(projectPath, '.packages')).createSync(); + globals.fs.file(globals.fs.path.join(projectPath, '.packages')).createSync(); return projectPath; }
diff --git a/packages/flutter_tools/test/src/context.dart b/packages/flutter_tools/test/src/context.dart index 4229d2b..8c29688 100644 --- a/packages/flutter_tools/test/src/context.dart +++ b/packages/flutter_tools/test/src/context.dart
@@ -28,6 +28,7 @@ import 'package:flutter_tools/src/reporting/github_template.dart'; import 'package:flutter_tools/src/reporting/reporting.dart'; import 'package:flutter_tools/src/version.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:meta/meta.dart'; import 'package:mockito/mockito.dart'; @@ -73,16 +74,16 @@ } }); Config buildConfig(FileSystem fs) { - configDir ??= fs.systemTempDirectory.createTempSync('flutter_config_dir_test.'); - final File settingsFile = fs.file( - fs.path.join(configDir.path, '.flutter_settings') + configDir ??= globals.fs.systemTempDirectory.createTempSync('flutter_config_dir_test.'); + final File settingsFile = globals.fs.file( + globals.fs.path.join(configDir.path, '.flutter_settings') ); return Config(settingsFile); } PersistentToolState buildPersistentToolState(FileSystem fs) { - configDir ??= fs.systemTempDirectory.createTempSync('flutter_config_dir_test.'); - final File toolStateFile = fs.file( - fs.path.join(configDir.path, '.flutter_tool_state')); + configDir ??= globals.fs.systemTempDirectory.createTempSync('flutter_config_dir_test.'); + final File toolStateFile = globals.fs.file( + globals.fs.path.join(configDir.path, '.flutter_tool_state')); return PersistentToolState(toolStateFile); } @@ -91,7 +92,7 @@ return context.run<dynamic>( name: 'mocks', overrides: <Type, Generator>{ - Config: () => buildConfig(fs), + Config: () => buildConfig(globals.fs), DeviceManager: () => FakeDeviceManager(), Doctor: () => FakeDoctor(), FlutterVersion: () => MockFlutterVersion(), @@ -104,7 +105,7 @@ OutputPreferences: () => OutputPreferences.test(), Logger: () => BufferLogger(), OperatingSystemUtils: () => FakeOperatingSystemUtils(), - PersistentToolState: () => buildPersistentToolState(fs), + PersistentToolState: () => buildPersistentToolState(globals.fs), SimControl: () => MockSimControl(), Usage: () => FakeUsage(), XcodeProjectInterpreter: () => FakeXcodeProjectInterpreter(), @@ -410,10 +411,10 @@ @override set currentDirectory(dynamic value) { - throw 'fs.currentDirectory should not be set on the local file system during ' + throw 'globals.fs.currentDirectory should not be set on the local file system during ' 'tests as this can cause race conditions with concurrent tests. ' 'Consider using a MemoryFileSystem for testing if possible or refactor ' - 'code to not require setting fs.currentDirectory.'; + 'code to not require setting globals.fs.currentDirectory.'; } }
diff --git a/packages/flutter_tools/test/src/mocks.dart b/packages/flutter_tools/test/src/mocks.dart index 539f8ab..95fdd64 100644 --- a/packages/flutter_tools/test/src/mocks.dart +++ b/packages/flutter_tools/test/src/mocks.dart
@@ -6,13 +6,14 @@ import 'dart:convert'; import 'dart:io' as io show IOSink, ProcessSignal, Stdout, StdoutException; +import 'package:platform/platform.dart'; + import 'package:flutter_tools/src/android/android_device.dart'; import 'package:flutter_tools/src/android/android_sdk.dart' show AndroidSdk; import 'package:flutter_tools/src/application_package.dart'; import 'package:flutter_tools/src/base/context.dart'; import 'package:flutter_tools/src/base/file_system.dart' hide IOSink; import 'package:flutter_tools/src/base/io.dart'; -import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/build_info.dart'; import 'package:flutter_tools/src/compile.dart'; import 'package:flutter_tools/src/devfs.dart'; @@ -21,6 +22,7 @@ import 'package:flutter_tools/src/ios/simulators.dart'; import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/runner/flutter_command.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import 'package:process/process.dart'; @@ -36,7 +38,7 @@ MockApplicationPackageStore() : super( android: AndroidApk( id: 'io.flutter.android.mock', - file: fs.file('/mock/path/to/android/SkyShell.apk'), + file: globals.fs.file('/mock/path/to/android/SkyShell.apk'), versionCode: 1, launchActivity: 'io.flutter.android.mock.MockActivity', ), @@ -67,9 +69,9 @@ bool withPlatformTools = true, bool withBuildTools = true, }) { - final Directory dir = fs.systemTempDirectory.createTempSync('flutter_mock_android_sdk.'); - final String exe = platform.isWindows ? '.exe' : ''; - final String bat = platform.isWindows ? '.bat' : ''; + final Directory dir = globals.fs.systemTempDirectory.createTempSync('flutter_mock_android_sdk.'); + final String exe = globals.platform.isWindows ? '.exe' : ''; + final String bat = globals.platform.isWindows ? '.bat' : ''; _createDir(dir, 'licenses'); @@ -98,7 +100,7 @@ } if (withNdkDir != null) { - final String ndkToolchainBin = fs.path.join( + final String ndkToolchainBin = globals.fs.path.join( 'ndk-bundle', 'toolchains', 'arm-linux-androideabi-4.9', @@ -106,24 +108,24 @@ withNdkDir, 'bin', ); - final String ndkCompiler = fs.path.join( + final String ndkCompiler = globals.fs.path.join( ndkToolchainBin, 'arm-linux-androideabi-gcc', ); - final String ndkLinker = fs.path.join( + final String ndkLinker = globals.fs.path.join( ndkToolchainBin, 'arm-linux-androideabi-ld', ); _createSdkFile(dir, ndkCompiler); _createSdkFile(dir, ndkLinker); - _createSdkFile(dir, fs.path.join('ndk-bundle', 'source.properties'), contents: ''' + _createSdkFile(dir, globals.fs.path.join('ndk-bundle', 'source.properties'), contents: ''' Pkg.Desc = Android NDK[] Pkg.Revision = $ndkVersion.1.5063045 '''); } if (withNdkSysroot) { - final String armPlatform = fs.path.join( + final String armPlatform = globals.fs.path.join( 'ndk-bundle', 'platforms', 'android-9', @@ -144,7 +146,7 @@ } static void _createDir(Directory dir, String path) { - final Directory directory = fs.directory(fs.path.join(dir.path, path)); + final Directory directory = globals.fs.directory(globals.fs.path.join(dir.path, path)); directory.createSync(recursive: true); } @@ -675,8 +677,8 @@ } @override Future<CompilerOutput> recompile(String mainPath, List<Uri> invalidatedFiles, { String outputPath, String packagesFilePath }) async { - fs.file(outputPath).createSync(recursive: true); - fs.file(outputPath).writeAsStringSync('compiled_kernel_output'); + globals.fs.file(outputPath).createSync(recursive: true); + globals.fs.file(outputPath).writeAsStringSync('compiled_kernel_output'); return CompilerOutput(outputPath, 0, <Uri>[]); } }
diff --git a/packages/flutter_tools/test/src/testbed.dart b/packages/flutter_tools/test/src/testbed.dart index 476bb72..2022ebf 100644 --- a/packages/flutter_tools/test/src/testbed.dart +++ b/packages/flutter_tools/test/src/testbed.dart
@@ -12,7 +12,7 @@ import 'package:flutter_tools/src/base/io.dart'; import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/os.dart'; -import 'package:flutter_tools/src/base/platform.dart'; + import 'package:flutter_tools/src/base/signals.dart'; import 'package:flutter_tools/src/base/terminal.dart'; import 'package:flutter_tools/src/cache.dart'; @@ -21,6 +21,7 @@ import 'package:flutter_tools/src/features.dart'; import 'package:flutter_tools/src/reporting/reporting.dart'; import 'package:flutter_tools/src/version.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:meta/meta.dart'; import 'package:process/process.dart'; @@ -35,7 +36,7 @@ // this provider. For example, [BufferLogger], [MemoryFileSystem]. final Map<Type, Generator> _testbedDefaults = <Type, Generator>{ // Keeps tests fast by avoiding the actual file system. - FileSystem: () => MemoryFileSystem(style: platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix), + FileSystem: () => MemoryFileSystem(style: globals.platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix), ProcessManager: () => FakeProcessManager.any(), Logger: () => BufferLogger(), // Allows reading logs and prevents stdout. OperatingSystemUtils: () => FakeOperatingSystemUtils(), @@ -61,14 +62,14 @@ /// /// setUp(() { /// testbed = Testbed(setUp: () { -/// fs.file('foo').createSync() +/// globals.fs.file('foo').createSync() /// }); /// }) /// /// test('Can delete a file', () => testbed.run(() { -/// expect(fs.file('foo').existsSync(), true); -/// fs.file('foo').deleteSync(); -/// expect(fs.file('foo').existsSync(), false); +/// expect(globals.fs.file('foo').existsSync(), true); +/// globals.fs.file('foo').deleteSync(); +/// expect(globals.fs.file('foo').existsSync(), false); /// })); /// }); /// } @@ -843,32 +844,32 @@ @override Directory getArtifactDirectory(String name) { - return fs.currentDirectory; + return globals.fs.currentDirectory; } @override Directory getCacheArtifacts() { - return fs.currentDirectory; + return globals.fs.currentDirectory; } @override Directory getCacheDir(String name) { - return fs.currentDirectory; + return globals.fs.currentDirectory; } @override Directory getDownloadDir() { - return fs.currentDirectory; + return globals.fs.currentDirectory; } @override Directory getRoot() { - return fs.currentDirectory; + return globals.fs.currentDirectory; } @override File getLicenseFile() { - return fs.currentDirectory.childFile('LICENSE'); + return globals.fs.currentDirectory.childFile('LICENSE'); } @override @@ -893,7 +894,7 @@ @override Directory getWebSdkDirectory() { - return fs.currentDirectory; + return globals.fs.currentDirectory; } @override
diff --git a/packages/flutter_tools/test/template_test.dart b/packages/flutter_tools/test/template_test.dart index 8c042c9..2aedd4e 100644 --- a/packages/flutter_tools/test/template_test.dart +++ b/packages/flutter_tools/test/template_test.dart
@@ -5,6 +5,7 @@ import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/template.dart'; +import 'package:flutter_tools/src/globals.dart' as globals; import 'package:mockito/mockito.dart'; import 'src/common.dart'; @@ -18,7 +19,7 @@ }); test('Template.render throws ToolExit when FileSystem exception is raised', () => testbed.run(() { - final Template template = Template(fs.directory('examples'), fs.currentDirectory); + final Template template = Template(globals.fs.directory('examples'), globals.fs.currentDirectory); final MockDirectory mockDirectory = MockDirectory(); when(mockDirectory.createSync(recursive: true)).thenThrow(const FileSystemException());