From 993f3947da0437d92a1a809419bdcbe264299d1a Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Tue, 24 Apr 2018 15:51:10 -0700 Subject: [PATCH] Generalise FakeGenSnapshot output generation (#16938) Pre-factoring for addition of AOT snapshotting unit tests, which emit a different set of expected outputs. --- .../flutter_tools/test/base/build_test.dart | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/flutter_tools/test/base/build_test.dart b/packages/flutter_tools/test/base/build_test.dart index 49f21c0a3b..27aeed556e 100644 --- a/packages/flutter_tools/test/base/build_test.dart +++ b/packages/flutter_tools/test/base/build_test.dart @@ -24,15 +24,14 @@ class MockArtifacts extends Mock implements Artifacts {} class _FakeGenSnapshot implements GenSnapshot { _FakeGenSnapshot({ this.succeed: true, - this.snapshotPath: 'output.snapshot', - this.snapshotContent: '', - this.depfileContent: 'output.snapshot.d : main.dart', + this.outputs: const { + 'output.snapshot': '', + 'output.snapshot.d': 'output.snapshot.d : main.dart', + }, }); final bool succeed; - final String snapshotPath; - final String snapshotContent; - final String depfileContent; + final Map outputs; int _callCount = 0; SnapshotType _snapshotType; String _packagesPath; @@ -64,8 +63,9 @@ class _FakeGenSnapshot implements GenSnapshot { 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 @@ void main() { expect(new SnapshotType(null, BuildMode.release), isNotNull); }); }); + group('Fingerprint', () { MockFlutterVersion mockVersion; const String kVersion = '123456abcdef'; @@ -457,8 +458,10 @@ void main() { 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: { + 'output.snapshot': '', + 'output.snapshot.d': 'output.snapshot : main.dart other.dart', + }, ); await context.run(