From 7b69d137c8b4dbcafa62df3a7d7a4fafd929c4c8 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Fri, 3 Jan 2020 08:18:02 -0800 Subject: [PATCH] reset state between runs of devFS tests (#48101) --- .../test/general.shard/devfs_test.dart | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/flutter_tools/test/general.shard/devfs_test.dart b/packages/flutter_tools/test/general.shard/devfs_test.dart index ca1a669886..ce6e0e55e6 100644 --- a/packages/flutter_tools/test/general.shard/devfs_test.dart +++ b/packages/flutter_tools/test/general.shard/devfs_test.dart @@ -26,7 +26,6 @@ void main() { String filePath; Directory tempDir; String basePath; - DevFS devFS; setUpAll(() { fs = MemoryFileSystem(); @@ -142,7 +141,7 @@ void main() { return Future.value(httpClientResponse); }); - devFS = DevFS(vmService, 'test', tempDir); + final DevFS devFS = DevFS(vmService, 'test', tempDir); await devFS.create(); final MockResidentCompiler residentCompiler = MockResidentCompiler(); @@ -168,6 +167,7 @@ void main() { group('devfs remote', () { MockVMService vmService; final MockResidentCompiler residentCompiler = MockResidentCompiler(); + DevFS devFS; setUpAll(() async { tempDir = _newTempDir(fs); @@ -176,6 +176,11 @@ void main() { await vmService.setUp(); }); + setUp(() { + vmService.resetState(); + devFS = DevFS(vmService, 'test', tempDir); + }); + tearDownAll(() async { await vmService.tearDown(); _cleanupTempDirs(); @@ -190,7 +195,6 @@ void main() { // simulate package await _createPackage(fs, 'somepkg', 'somefile.txt'); - devFS = DevFS(vmService, 'test', tempDir); await devFS.create(); vmService.expectMessages(['create test']); expect(devFS.assetPathsToEvict, isEmpty); @@ -232,8 +236,6 @@ void main() { // simulate package await _createPackage(fs, 'somepkg', 'somefile.txt'); - - devFS = DevFS(vmService, 'test', tempDir); await devFS.create(); vmService.expectMessages(['create test']); expect(devFS.assetPathsToEvict, isEmpty); @@ -253,7 +255,6 @@ void main() { }); testUsingContext('reports unsuccessful compile when errors are returned', () async { - devFS = DevFS(vmService, 'test', tempDir); await devFS.create(); final DateTime previousCompile = devFS.lastCompiled; @@ -283,7 +284,6 @@ void main() { }); testUsingContext('correctly updates last compiled time when compilation does not fail', () async { - devFS = DevFS(vmService, 'test', tempDir); // simulate package final File sourceFile = await _createPackage(fs, 'somepkg', 'main.dart'); @@ -359,8 +359,14 @@ class MockVMService extends BasicMock implements VMService { await _server?.close(); } + void resetState() { + _vm = MockVM(this); + messages.clear(); + } + @override dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); + } class MockVM implements VM {