Generalise FakeGenSnapshot output generation (#16938)
Pre-factoring for addition of AOT snapshotting unit tests, which emit a
different set of expected outputs.
diff --git a/packages/flutter_tools/test/base/build_test.dart b/packages/flutter_tools/test/base/build_test.dart
index 49f21c0..27aeed5 100644
--- a/packages/flutter_tools/test/base/build_test.dart
+++ b/packages/flutter_tools/test/base/build_test.dart
@@ -24,15 +24,14 @@
class _FakeGenSnapshot implements GenSnapshot {
_FakeGenSnapshot({
this.succeed: true,
- this.snapshotPath: 'output.snapshot',
- this.snapshotContent: '',
- this.depfileContent: 'output.snapshot.d : main.dart',
+ this.outputs: const <String, String>{
+ 'output.snapshot': '',
+ 'output.snapshot.d': 'output.snapshot.d : main.dart',
+ },
});
final bool succeed;
- final String snapshotPath;
- final String snapshotContent;
- final String depfileContent;
+ final Map<String, String> outputs;
int _callCount = 0;
SnapshotType _snapshotType;
String _packagesPath;
@@ -64,8 +63,9 @@
if (!succeed)
return 1;
- await fs.file(snapshotPath).writeAsString(snapshotContent);
- await fs.file(depfilePath).writeAsString(depfileContent);
+ outputs.forEach((String filePath, String fileContent) {
+ fs.file(filePath).writeAsString(fileContent);
+ });
return 0;
}
}
@@ -82,6 +82,7 @@
expect(new SnapshotType(null, BuildMode.release), isNotNull);
});
});
+
group('Fingerprint', () {
MockFlutterVersion mockVersion;
const String kVersion = '123456abcdef';
@@ -457,8 +458,10 @@
testUsingContext('builds snapshot and fingerprint when main entry point changes to other dependency', () async {
final _FakeGenSnapshot genSnapshot = new _FakeGenSnapshot(
- snapshotPath: 'output.snapshot',
- depfileContent: 'output.snapshot : main.dart other.dart',
+ outputs: <String, String>{
+ 'output.snapshot': '',
+ 'output.snapshot.d': 'output.snapshot : main.dart other.dart',
+ },
);
await context.run<void>(