mirror of
https://github.com/flutter/flutter
synced 2024-10-13 11:42:54 +00:00
[flutter_tools] Refactor Environment and FileStore to be context-free (#48759)
This commit is contained in:
parent
c3124ff2e3
commit
79c286705c
|
@ -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')
|
||||
|
|
|
@ -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<String, String> defines = const <String, String>{},
|
||||
}) {
|
||||
|
@ -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<String, String> defines = const <String, String>{},
|
||||
}) {
|
||||
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);
|
||||
|
|
|
@ -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<String, String> previousHashes = HashMap<String, String>();
|
||||
final HashMap<String, String> currentHashes = HashMap<String, String>();
|
||||
|
||||
|
@ -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
|
||||
|
|
|
@ -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<void> 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: <String, String>{
|
||||
kTargetFile: mainPath,
|
||||
kBuildMode: getNameForBuildMode(buildMode),
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -39,9 +39,9 @@ Future<void> 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'),
|
||||
|
|
|
@ -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));
|
||||
}));
|
||||
|
|
|
@ -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>[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>[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<File> results = await fileCache.hashFiles(<File>[globals.fs.file('hello.dart')]);
|
||||
final List<File> results = await fileCache.hashFiles(<File>[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 {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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: <String, String>{
|
||||
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: <String, String>{
|
||||
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: <String, String>{
|
||||
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: <String, String>{
|
||||
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: <String, String>{
|
||||
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: <String, String>{
|
||||
kBuildMode: 'release',
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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: <String, String>{
|
||||
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: <String, String>{
|
||||
kBuildMode: getNameForBuildMode(BuildMode.profile),
|
||||
kTargetPlatform: getNameForTargetPlatform(TargetPlatform.ios),
|
||||
|
@ -264,9 +262,8 @@ flutter_tools:lib/''');
|
|||
return const CompilerOutput('example', 0, <Uri>[]);
|
||||
});
|
||||
|
||||
await const KernelSnapshot().build(Environment(
|
||||
outputDir: globals.fs.currentDirectory,
|
||||
projectDir: globals.fs.currentDirectory,
|
||||
await const KernelSnapshot().build(Environment.test(
|
||||
globals.fs.currentDirectory,
|
||||
defines: <String, String>{
|
||||
kBuildMode: 'debug',
|
||||
kTargetPlatform: getNameForTargetPlatform(TargetPlatform.android_arm),
|
||||
|
|
|
@ -33,9 +33,8 @@ void main() {
|
|||
when(mockPlatform.environment).thenReturn(Map<String, String>.unmodifiable(<String, String>{}));
|
||||
testbed = Testbed(setup: () {
|
||||
Cache.flutterRoot = '';
|
||||
environment = Environment(
|
||||
outputDir: globals.fs.currentDirectory,
|
||||
projectDir: globals.fs.currentDirectory,
|
||||
environment = Environment.test(
|
||||
globals.fs.currentDirectory,
|
||||
defines: <String, String>{
|
||||
kBuildMode: 'debug',
|
||||
}
|
||||
|
|
|
@ -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: <String, String>{
|
||||
environment = Environment.test(
|
||||
globals.fs.currentDirectory,
|
||||
defines: <String, String>{
|
||||
kBuildMode: 'debug',
|
||||
kTargetPlatform: 'darwin-x64',
|
||||
},
|
||||
|
|
|
@ -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: <String, String>{
|
||||
kTargetFile: globals.fs.path.join('foo', 'lib', 'main.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();
|
||||
|
|
Loading…
Reference in a new issue