Unverified Commit 993f3947 authored by Chris Bracken's avatar Chris Bracken Committed by GitHub

Generalise FakeGenSnapshot output generation (#16938)

Pre-factoring for addition of AOT snapshotting unit tests, which emit a
different set of expected outputs.
parent 7ffcd3d2
...@@ -24,15 +24,14 @@ class MockArtifacts extends Mock implements Artifacts {} ...@@ -24,15 +24,14 @@ class MockArtifacts extends Mock implements Artifacts {}
class _FakeGenSnapshot implements GenSnapshot { class _FakeGenSnapshot implements GenSnapshot {
_FakeGenSnapshot({ _FakeGenSnapshot({
this.succeed: true, this.succeed: true,
this.snapshotPath: 'output.snapshot', this.outputs: const <String, String>{
this.snapshotContent: '', 'output.snapshot': '',
this.depfileContent: 'output.snapshot.d : main.dart', 'output.snapshot.d': 'output.snapshot.d : main.dart',
},
}); });
final bool succeed; final bool succeed;
final String snapshotPath; final Map<String, String> outputs;
final String snapshotContent;
final String depfileContent;
int _callCount = 0; int _callCount = 0;
SnapshotType _snapshotType; SnapshotType _snapshotType;
String _packagesPath; String _packagesPath;
...@@ -64,8 +63,9 @@ class _FakeGenSnapshot implements GenSnapshot { ...@@ -64,8 +63,9 @@ class _FakeGenSnapshot implements GenSnapshot {
if (!succeed) if (!succeed)
return 1; return 1;
await fs.file(snapshotPath).writeAsString(snapshotContent); outputs.forEach((String filePath, String fileContent) {
await fs.file(depfilePath).writeAsString(depfileContent); fs.file(filePath).writeAsString(fileContent);
});
return 0; return 0;
} }
} }
...@@ -82,6 +82,7 @@ void main() { ...@@ -82,6 +82,7 @@ void main() {
expect(new SnapshotType(null, BuildMode.release), isNotNull); expect(new SnapshotType(null, BuildMode.release), isNotNull);
}); });
}); });
group('Fingerprint', () { group('Fingerprint', () {
MockFlutterVersion mockVersion; MockFlutterVersion mockVersion;
const String kVersion = '123456abcdef'; const String kVersion = '123456abcdef';
...@@ -457,8 +458,10 @@ void main() { ...@@ -457,8 +458,10 @@ void main() {
testUsingContext('builds snapshot and fingerprint when main entry point changes to other dependency', () async { testUsingContext('builds snapshot and fingerprint when main entry point changes to other dependency', () async {
final _FakeGenSnapshot genSnapshot = new _FakeGenSnapshot( final _FakeGenSnapshot genSnapshot = new _FakeGenSnapshot(
snapshotPath: 'output.snapshot', outputs: <String, String>{
depfileContent: 'output.snapshot : main.dart other.dart', 'output.snapshot': '',
'output.snapshot.d': 'output.snapshot : main.dart other.dart',
},
); );
await context.run<void>( await context.run<void>(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment