diff --git a/packages/flutter_tools/lib/src/aot.dart b/packages/flutter_tools/lib/src/aot.dart index 976eb09d22..9a5b207166 100644 --- a/packages/flutter_tools/lib/src/aot.dart +++ b/packages/flutter_tools/lib/src/aot.dart @@ -210,8 +210,8 @@ class AotBuilder { ? const ProfileCopyFlutterAotBundle() : const ReleaseCopyFlutterAotBundle(); - final BuildResult result = await buildSystem.build(target, Environment( - projectDir: flutterProject.directory, + final BuildResult result = await buildSystem.build(target, Environment.test( + flutterProject.directory, outputDir: globals.fs.directory(outputDir), buildDir: flutterProject.directory .childDirectory('.dart_tool') diff --git a/packages/flutter_tools/lib/src/build_system/build_system.dart b/packages/flutter_tools/lib/src/build_system/build_system.dart index 6f4f85a8f4..0ef578693e 100644 --- a/packages/flutter_tools/lib/src/build_system/build_system.dart +++ b/packages/flutter_tools/lib/src/build_system/build_system.dart @@ -277,12 +277,11 @@ abstract class Target { /// } class Environment { /// Create a new [Environment] object. - /// - /// Only [projectDir] is required. The remaining environment locations have - /// defaults based on it. factory Environment({ @required Directory projectDir, @required Directory outputDir, + @required Directory cacheDir, + @required Directory flutterRootDir, Directory buildDir, Map defines = const {}, }) { @@ -308,9 +307,30 @@ class Environment { projectDir: projectDir, buildDir: buildDirectory, rootBuildDir: rootBuildDir, - cacheDir: globals.cache.getRoot(), + cacheDir: cacheDir, + defines: defines, + flutterRootDir: flutterRootDir, + ); + } + + /// Create a new [Environment] object for unit testing. + /// + /// Any directories not provided will fallback to a [testDirectory] + factory Environment.test(Directory testDirectory, { + Directory projectDir, + Directory outputDir, + Directory cacheDir, + Directory flutterRootDir, + Directory buildDir, + Map defines = const {}, + }) { + return Environment( + projectDir: projectDir ?? testDirectory, + outputDir: outputDir ?? testDirectory, + cacheDir: cacheDir ?? testDirectory, + flutterRootDir: flutterRootDir ?? testDirectory, + buildDir: buildDir, defines: defines, - flutterRootDir: globals.fs.directory(Cache.flutterRoot), ); } @@ -410,8 +430,11 @@ class BuildSystem { environment.outputDir.createSync(recursive: true); // Load file hash store from previous builds. - final FileHashStore fileCache = FileHashStore(environment, globals.fs) - ..initialize(); + final FileHashStore fileCache = FileHashStore( + environment: environment, + fileSystem: globals.fs, + logger: globals.logger, + )..initialize(); // Perform sanity checks on build. checkCycles(target); diff --git a/packages/flutter_tools/lib/src/build_system/file_hash_store.dart b/packages/flutter_tools/lib/src/build_system/file_hash_store.dart index 0879c7b3d9..b1b679ec44 100644 --- a/packages/flutter_tools/lib/src/build_system/file_hash_store.dart +++ b/packages/flutter_tools/lib/src/build_system/file_hash_store.dart @@ -7,12 +7,13 @@ import 'dart:collection'; import 'dart:typed_data'; import 'package:crypto/crypto.dart'; +import 'package:meta/meta.dart'; import 'package:pool/pool.dart'; import '../base/file_system.dart'; +import '../base/logger.dart'; import '../base/utils.dart'; import '../convert.dart'; -import '../globals.dart' as globals; import 'build_system.dart'; /// An encoded representation of all file hashes. @@ -71,12 +72,18 @@ class FileHash { /// /// The format of the file store is subject to change and not part of its API. class FileHashStore { - FileHashStore(this.environment, this.fileSystem) : - _cachePath = environment.buildDir.childFile(_kFileCache).path; + FileHashStore({ + @required Environment environment, + @required FileSystem fileSystem, + @required Logger logger, + }) : _cachePath = environment.buildDir.childFile(_kFileCache).path, + _logger = logger, + _fileSystem = fileSystem; - final FileSystem fileSystem; + final FileSystem _fileSystem; final String _cachePath; - final Environment environment; + final Logger _logger; + final HashMap previousHashes = HashMap(); final HashMap currentHashes = HashMap(); @@ -88,8 +95,8 @@ class FileHashStore { /// Read file hashes from disk. void initialize() { - globals.printTrace('Initializing file store'); - final File cacheFile = fileSystem.file(_cachePath); + _logger.printTrace('Initializing file store'); + final File cacheFile = _fileSystem.file(_cachePath); if (!cacheFile.existsSync()) { return; } @@ -97,7 +104,7 @@ class FileHashStore { try { data = cacheFile.readAsBytesSync(); } on FileSystemException catch (err) { - globals.printError( + _logger.printError( 'Failed to read file store at ${cacheFile.path} due to $err.\n' 'Build artifacts will not be cached. Try clearing the cache directories ' 'with "flutter clean"', @@ -109,25 +116,25 @@ class FileHashStore { try { fileStorage = FileStorage.fromBuffer(data); } catch (err) { - globals.printTrace('Filestorage format changed'); + _logger.printTrace('Filestorage format changed'); cacheFile.deleteSync(); return; } if (fileStorage.version != _kVersion) { - globals.printTrace('file cache format updating, clearing old hashes.'); + _logger.printTrace('file cache format updating, clearing old hashes.'); cacheFile.deleteSync(); return; } for (final FileHash fileHash in fileStorage.files) { previousHashes[fileHash.path] = fileHash.hash; } - globals.printTrace('Done initializing file store'); + _logger.printTrace('Done initializing file store'); } /// Persist file hashes to disk. void persist() { - globals.printTrace('Persisting file store'); - final File cacheFile = fileSystem.file(_cachePath); + _logger.printTrace('Persisting file store'); + final File cacheFile = _fileSystem.file(_cachePath); if (!cacheFile.existsSync()) { cacheFile.createSync(recursive: true); } @@ -143,13 +150,13 @@ class FileHashStore { try { cacheFile.writeAsBytesSync(buffer); } on FileSystemException catch (err) { - globals.printError( + _logger.printError( 'Failed to persist file store at ${cacheFile.path} due to $err.\n' 'Build artifacts will not be cached. Try clearing the cache directories ' 'with "flutter clean"', ); } - globals.printTrace('Done persisting file store'); + _logger.printTrace('Done persisting file store'); } /// Computes a hash of the provided files and returns a list of entities diff --git a/packages/flutter_tools/lib/src/bundle.dart b/packages/flutter_tools/lib/src/bundle.dart index b49658704c..cd82e4093c 100644 --- a/packages/flutter_tools/lib/src/bundle.dart +++ b/packages/flutter_tools/lib/src/bundle.dart @@ -15,6 +15,7 @@ import 'build_info.dart'; import 'build_system/build_system.dart'; import 'build_system/depfile.dart'; import 'build_system/targets/dart.dart'; +import 'cache.dart'; import 'dart/package_map.dart'; import 'devfs.dart'; import 'globals.dart' as globals; @@ -113,6 +114,8 @@ Future buildWithAssemble({ projectDir: flutterProject.directory, outputDir: globals.fs.directory(outputDir), buildDir: flutterProject.dartTool.childDirectory('flutter_build'), + cacheDir: globals.cache.getRoot(), + flutterRootDir: globals.fs.directory(Cache.flutterRoot), defines: { kTargetFile: mainPath, kBuildMode: getNameForBuildMode(buildMode), diff --git a/packages/flutter_tools/lib/src/commands/assemble.dart b/packages/flutter_tools/lib/src/commands/assemble.dart index 330832c115..18d1297ec9 100644 --- a/packages/flutter_tools/lib/src/commands/assemble.dart +++ b/packages/flutter_tools/lib/src/commands/assemble.dart @@ -16,6 +16,7 @@ import '../build_system/targets/linux.dart'; import '../build_system/targets/macos.dart'; import '../build_system/targets/web.dart'; import '../build_system/targets/windows.dart'; +import '../cache.dart'; import '../globals.dart' as globals; import '../project.dart'; import '../reporting/reporting.dart'; @@ -147,6 +148,8 @@ class AssembleCommand extends FlutterCommand { .childDirectory('flutter_build'), projectDir: flutterProject.directory, defines: _parseDefines(stringsArg('define')), + cacheDir: globals.cache.getRoot(), + flutterRootDir: globals.fs.directory(Cache.flutterRoot), ); return result; } diff --git a/packages/flutter_tools/lib/src/web/compile.dart b/packages/flutter_tools/lib/src/web/compile.dart index b7cf8a6d2c..0789dd9766 100644 --- a/packages/flutter_tools/lib/src/web/compile.dart +++ b/packages/flutter_tools/lib/src/web/compile.dart @@ -39,9 +39,9 @@ Future buildWeb( final Status status = globals.logger.startProgress('Compiling $target for the Web...', timeout: null); final Stopwatch sw = Stopwatch()..start(); try { - final BuildResult result = await buildSystem.build(const WebServiceWorker(), Environment( + final BuildResult result = await buildSystem.build(const WebServiceWorker(), Environment.test( + globals.fs.currentDirectory, outputDir: globals.fs.directory(getWebBuildDirectory()), - projectDir: globals.fs.currentDirectory, buildDir: flutterProject.directory .childDirectory('.dart_tool') .childDirectory('flutter_build'), 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 a3277a79b7..778fb59791 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 @@ -93,9 +93,8 @@ void main() { ]; testbed = Testbed( setup: () { - environment = Environment( - outputDir: globals.fs.currentDirectory, - projectDir: globals.fs.currentDirectory, + environment = Environment.test( + globals.fs.currentDirectory, ); globals.fs.file('foo.dart') ..createSync(recursive: true) @@ -335,8 +334,8 @@ void main() { })); test('output directory is an input to the build', () => testbed.run(() async { - 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')); + final Environment environmentA = Environment.test(globals.fs.currentDirectory, outputDir: globals.fs.directory('a')); + final Environment environmentB = Environment.test(globals.fs.currentDirectory, outputDir: globals.fs.directory('b')); expect(environmentA.buildDir.path, isNot(environmentB.buildDir.path)); })); 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 c51d0f4f58..8b90884ae4 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 @@ -4,56 +4,68 @@ import 'dart:typed_data'; +import 'package:file/memory.dart'; import 'package:flutter_tools/src/base/file_system.dart'; +import 'package:flutter_tools/src/base/logger.dart'; +import 'package:flutter_tools/src/base/terminal.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 'package:platform/platform.dart'; import '../../src/common.dart'; -import '../../src/context.dart'; -import '../../src/testbed.dart'; void main() { - Testbed testbed; Environment environment; + FileSystem fileSystem; + BufferLogger logger; setUp(() { - testbed = Testbed(setup: () { - globals.fs.directory('build').createSync(); - environment = Environment( - outputDir: globals.fs.currentDirectory, - projectDir: globals.fs.currentDirectory, - ); - environment.buildDir.createSync(recursive: true); - }); + fileSystem = MemoryFileSystem(); + logger = BufferLogger( + outputPreferences: OutputPreferences.test(), + terminal: AnsiTerminal(stdio: null, platform: FakePlatform()) + ); + fileSystem.directory('build').createSync(); + environment = Environment.test( + fileSystem.currentDirectory, + ); + environment.buildDir.createSync(recursive: true); }); - test('Initializes file cache', () => testbed.run(() { - final FileHashStore fileCache = FileHashStore(environment, globals.fs); + test('Initializes file cache', () { + final FileHashStore fileCache = FileHashStore( + environment: environment, + fileSystem: fileSystem, + logger: logger, + ); fileCache.initialize(); fileCache.persist(); - expect(globals.fs.file(globals.fs.path.join(environment.buildDir.path, '.filecache')).existsSync(), true); + expect(fileSystem.file(fileSystem.path.join(environment.buildDir.path, '.filecache')).existsSync(), true); - final Uint8List buffer = globals.fs.file(globals.fs.path.join(environment.buildDir.path, '.filecache')) + final Uint8List buffer = fileSystem.file(fileSystem.path.join(environment.buildDir.path, '.filecache')) .readAsBytesSync(); final FileStorage fileStorage = FileStorage.fromBuffer(buffer); expect(fileStorage.files, isEmpty); expect(fileStorage.version, 2); - })); + }); - test('saves and restores to file cache', () => testbed.run(() async { - final File file = globals.fs.file('foo.dart') + test('saves and restores to file cache', () async { + final File file = fileSystem.file('foo.dart') ..createSync() ..writeAsStringSync('hello'); - final FileHashStore fileCache = FileHashStore(environment, globals.fs); + final FileHashStore fileCache = FileHashStore( + environment: environment, + fileSystem: fileSystem, + logger: logger, + ); fileCache.initialize(); await fileCache.hashFiles([file]); fileCache.persist(); final String currentHash = fileCache.currentHashes[file.path]; - final Uint8List buffer = globals.fs.file(globals.fs.path.join(environment.buildDir.path, '.filecache')) + final Uint8List buffer = fileSystem.file(fileSystem.path.join(environment.buildDir.path, '.filecache')) .readAsBytesSync(); FileStorage fileStorage = FileStorage.fromBuffer(buffer); @@ -61,7 +73,11 @@ void main() { expect(fileStorage.files.single.path, file.path); - final FileHashStore newFileCache = FileHashStore(environment, globals.fs); + final FileHashStore newFileCache = FileHashStore( + environment: environment, + fileSystem: fileSystem, + logger: logger, + ); newFileCache.initialize(); expect(newFileCache.currentHashes, isEmpty); expect(newFileCache.previousHashes['foo.dart'], currentHash); @@ -72,35 +88,47 @@ void main() { expect(fileStorage.files.single.hash, currentHash); expect(fileStorage.files.single.path, file.path); - })); + }); - test('handles persisting with a missing build directory', () => testbed.run(() async { - final File file = globals.fs.file('foo.dart') + test('handles persisting with a missing build directory', () async { + final File file = fileSystem.file('foo.dart') ..createSync() ..writeAsStringSync('hello'); - final FileHashStore fileCache = FileHashStore(environment, globals.fs); + final FileHashStore fileCache = FileHashStore( + environment: environment, + fileSystem: fileSystem, + logger: logger, + ); fileCache.initialize(); environment.buildDir.deleteSync(recursive: true); await fileCache.hashFiles([file]); - // Does not throw. - fileCache.persist(); - })); - test('handles hashing missing files', () => testbed.run(() async { - final FileHashStore fileCache = FileHashStore(environment, globals.fs); + expect(() => fileCache.persist(), returnsNormally); + }); + + test('handles hashing missing files', () async { + final FileHashStore fileCache = FileHashStore( + environment: environment, + fileSystem: fileSystem, + logger: logger, + ); fileCache.initialize(); - final List results = await fileCache.hashFiles([globals.fs.file('hello.dart')]); + final List results = await fileCache.hashFiles([fileSystem.file('hello.dart')]); expect(results, hasLength(1)); expect(results.single.path, 'hello.dart'); - expect(fileCache.currentHashes, isNot(contains(globals.fs.path.absolute('hello.dart')))); - })); + expect(fileCache.currentHashes, isNot(contains(fileSystem.path.absolute('hello.dart')))); + }); - test('handles failure to persist file cache', () => testbed.run(() async { - final FakeForwardingFileSystem fakeForwardingFileSystem = FakeForwardingFileSystem(globals.fs); - final FileHashStore fileCache = FileHashStore(environment, fakeForwardingFileSystem); + test('handles failure to persist file cache', () async { + final FakeForwardingFileSystem fakeForwardingFileSystem = FakeForwardingFileSystem(fileSystem); + final FileHashStore fileCache = FileHashStore( + environment: environment, + fileSystem: fakeForwardingFileSystem, + logger: logger, + ); final String cacheFile = environment.buildDir.childFile('.filecache').path; final MockFile mockFile = MockFile(); when(mockFile.writeAsBytesSync(any)).thenThrow(const FileSystemException('Out of space!')); @@ -110,12 +138,16 @@ void main() { fakeForwardingFileSystem.files[cacheFile] = mockFile; fileCache.persist(); - expect(testLogger.errorText, contains('Out of space!')); - })); + expect(logger.errorText, contains('Out of space!')); + }); - test('handles failure to restore file cache', () => testbed.run(() async { - final FakeForwardingFileSystem fakeForwardingFileSystem = FakeForwardingFileSystem(globals.fs); - final FileHashStore fileCache = FileHashStore(environment, fakeForwardingFileSystem); + test('handles failure to restore file cache', () async { + final FakeForwardingFileSystem fakeForwardingFileSystem = FakeForwardingFileSystem(fileSystem); + final FileHashStore fileCache = FileHashStore( + environment: environment, + fileSystem: fakeForwardingFileSystem, + logger: logger, + ); final String cacheFile = environment.buildDir.childFile('.filecache').path; final MockFile mockFile = MockFile(); when(mockFile.readAsBytesSync()).thenThrow(const FileSystemException('Out of space!')); @@ -124,8 +156,8 @@ void main() { fakeForwardingFileSystem.files[cacheFile] = mockFile; fileCache.initialize(); - expect(testLogger.errorText, contains('Out of space!')); - })); + expect(logger.errorText, contains('Out of space!')); + }); } class FakeForwardingFileSystem extends ForwardingFileSystem { 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 18f6b32d61..a1dd81ab39 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 @@ -29,10 +29,9 @@ void main() { globals.fs.directory('cache').createSync(); final Directory outputs = globals.fs.directory('outputs') ..createSync(); - environment = Environment( + environment = Environment.test( + globals.fs.currentDirectory, outputDir: outputs, - projectDir: globals.fs.currentDirectory, - buildDir: globals.fs.directory('build'), ); visitor = SourceVisitor(environment); environment.buildDir.createSync(recursive: true); 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 d67e6e9b28..e8929c1e5f 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 @@ -22,10 +22,9 @@ void main() { }); testbed.test('debug bundle contains expected resources', () async { - final Environment environment = Environment( + final Environment environment = Environment.test( + globals.fs.currentDirectory, outputDir: globals.fs.directory('out')..createSync(), - projectDir: globals.fs.currentDirectory, - buildDir: globals.fs.currentDirectory, defines: { kBuildMode: 'debug', } @@ -50,10 +49,9 @@ void main() { }); testbed.test('profile bundle contains expected resources', () async { - final Environment environment = Environment( + final Environment environment = Environment.test( + globals.fs.currentDirectory, outputDir: globals.fs.directory('out')..createSync(), - projectDir: globals.fs.currentDirectory, - buildDir: globals.fs.currentDirectory, defines: { kBuildMode: 'profile', } @@ -70,10 +68,9 @@ void main() { }); testbed.test('release bundle contains expected resources', () async { - final Environment environment = Environment( + final Environment environment = Environment.test( + globals.fs.currentDirectory, outputDir: globals.fs.directory('out')..createSync(), - projectDir: globals.fs.currentDirectory, - buildDir: globals.fs.currentDirectory, defines: { kBuildMode: 'release', } @@ -90,10 +87,9 @@ void main() { }); testbed.test('AndroidAot can build provided target platform', () async { - final Environment environment = Environment( + final Environment environment = Environment.test( + globals.fs.currentDirectory, outputDir: globals.fs.directory('out')..createSync(), - projectDir: globals.fs.currentDirectory, - buildDir: globals.fs.currentDirectory, defines: { kBuildMode: 'release', } @@ -126,10 +122,9 @@ void main() { }); testbed.test('kExtraGenSnapshotOptions passes values to gen_snapshot', () async { - final Environment environment = Environment( + final Environment environment = Environment.test( + globals.fs.currentDirectory, outputDir: globals.fs.directory('out')..createSync(), - projectDir: globals.fs.currentDirectory, - buildDir: globals.fs.currentDirectory, defines: { kBuildMode: 'release', kExtraGenSnapshotOptions: 'foo,bar,baz=2', @@ -161,10 +156,9 @@ void main() { }); testbed.test('android aot bundle copies so from abi directory', () async { - final Environment environment = Environment( + final Environment environment = Environment.test( + globals.fs.currentDirectory, outputDir: globals.fs.directory('out')..createSync(), - projectDir: globals.fs.currentDirectory, - buildDir: globals.fs.currentDirectory, defines: { 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 659709cd1e..4a6133e8bf 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 @@ -18,9 +18,8 @@ void main() { setUp(() { testbed = Testbed(setup: () { - environment = Environment( - outputDir: globals.fs.currentDirectory, - projectDir: globals.fs.currentDirectory, + environment = Environment.test( + globals.fs.currentDirectory, ); globals.fs.file(globals.fs.path.join('packages', 'flutter_tools', 'lib', 'src', 'build_system', 'targets', 'assets.dart')) @@ -78,9 +77,8 @@ flutter: globals.fs.file('pubspec.yaml') ..writeAsStringSync('name: foo\ndependencies:\n foo: any\n'); - await const FlutterPlugins().build(Environment( - outputDir: globals.fs.currentDirectory, - projectDir: globals.fs.currentDirectory, + await const FlutterPlugins().build(Environment.test( + globals.fs.currentDirectory, )); 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 9d83b2edc5..fc2391adef 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 @@ -39,17 +39,15 @@ void main() { mockXcode = MockXcode(); mockProcessManager = MockProcessManager(); testbed = Testbed(setup: () { - androidEnvironment = Environment( - outputDir: globals.fs.currentDirectory, - projectDir: globals.fs.currentDirectory, + androidEnvironment = Environment.test( + globals.fs.currentDirectory, defines: { kBuildMode: getNameForBuildMode(BuildMode.profile), kTargetPlatform: getNameForTargetPlatform(TargetPlatform.android_arm), }, ); - iosEnvironment = Environment( - outputDir: globals.fs.currentDirectory, - projectDir: globals.fs.currentDirectory, + iosEnvironment = Environment.test( + globals.fs.currentDirectory, defines: { kBuildMode: getNameForBuildMode(BuildMode.profile), kTargetPlatform: getNameForTargetPlatform(TargetPlatform.ios), @@ -264,9 +262,8 @@ flutter_tools:lib/'''); return const CompilerOutput('example', 0, []); }); - await const KernelSnapshot().build(Environment( - outputDir: globals.fs.currentDirectory, - projectDir: globals.fs.currentDirectory, + await const KernelSnapshot().build(Environment.test( + globals.fs.currentDirectory, defines: { kBuildMode: 'debug', kTargetPlatform: getNameForTargetPlatform(TargetPlatform.android_arm), 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 6eb658ea37..629900417f 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 @@ -33,9 +33,8 @@ void main() { when(mockPlatform.environment).thenReturn(Map.unmodifiable({})); testbed = Testbed(setup: () { Cache.flutterRoot = ''; - environment = Environment( - outputDir: globals.fs.currentDirectory, - projectDir: globals.fs.currentDirectory, + environment = Environment.test( + globals.fs.currentDirectory, defines: { kBuildMode: 'debug', } 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 56f7b3d1fc..e3c86708aa 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 @@ -67,10 +67,9 @@ void main() { globals.fs.file(globals.fs.path.join('bin', 'cache', 'pkg', 'sky_engine', 'sdk_ext', 'vmservice_io.dart')).createSync(recursive: true); - environment = Environment( - outputDir: globals.fs.currentDirectory, - projectDir: globals.fs.currentDirectory, - defines: { + environment = Environment.test( + globals.fs.currentDirectory, + defines: { kBuildMode: 'debug', kTargetPlatform: 'darwin-x64', }, 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 2a59794b9f..23a588013b 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 @@ -45,10 +45,10 @@ void main() { PackageMap.globalPackagesPath = packagesFile.path; globals.fs.currentDirectory.childDirectory('bar').createSync(); - environment = Environment( + environment = Environment.test( + globals.fs.currentDirectory, projectDir: globals.fs.currentDirectory.childDirectory('foo'), outputDir: globals.fs.currentDirectory.childDirectory('bar'), - buildDir: globals.fs.currentDirectory, defines: { kTargetFile: globals.fs.path.join('foo', 'lib', 'main.dart'), } 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 acce757300..bb14140fa1 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 @@ -34,9 +34,8 @@ void main() { when(platform.isLinux).thenReturn(false); when(platform.pathSeparator).thenReturn(r'\'); testbed = Testbed(setup: () { - environment = Environment( - outputDir: globals.fs.currentDirectory, - projectDir: globals.fs.currentDirectory, + environment = Environment.test( + globals.fs.currentDirectory, ); 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();