Commit 7b69d137 authored by Dan Field's avatar Dan Field Committed by Flutter GitHub Bot

reset state between runs of devFS tests (#48101)

parent d7c347f0
...@@ -26,7 +26,6 @@ void main() { ...@@ -26,7 +26,6 @@ void main() {
String filePath; String filePath;
Directory tempDir; Directory tempDir;
String basePath; String basePath;
DevFS devFS;
setUpAll(() { setUpAll(() {
fs = MemoryFileSystem(); fs = MemoryFileSystem();
...@@ -142,7 +141,7 @@ void main() { ...@@ -142,7 +141,7 @@ void main() {
return Future<HttpClientResponse>.value(httpClientResponse); return Future<HttpClientResponse>.value(httpClientResponse);
}); });
devFS = DevFS(vmService, 'test', tempDir); final DevFS devFS = DevFS(vmService, 'test', tempDir);
await devFS.create(); await devFS.create();
final MockResidentCompiler residentCompiler = MockResidentCompiler(); final MockResidentCompiler residentCompiler = MockResidentCompiler();
...@@ -168,6 +167,7 @@ void main() { ...@@ -168,6 +167,7 @@ void main() {
group('devfs remote', () { group('devfs remote', () {
MockVMService vmService; MockVMService vmService;
final MockResidentCompiler residentCompiler = MockResidentCompiler(); final MockResidentCompiler residentCompiler = MockResidentCompiler();
DevFS devFS;
setUpAll(() async { setUpAll(() async {
tempDir = _newTempDir(fs); tempDir = _newTempDir(fs);
...@@ -176,6 +176,11 @@ void main() { ...@@ -176,6 +176,11 @@ void main() {
await vmService.setUp(); await vmService.setUp();
}); });
setUp(() {
vmService.resetState();
devFS = DevFS(vmService, 'test', tempDir);
});
tearDownAll(() async { tearDownAll(() async {
await vmService.tearDown(); await vmService.tearDown();
_cleanupTempDirs(); _cleanupTempDirs();
...@@ -190,7 +195,6 @@ void main() { ...@@ -190,7 +195,6 @@ void main() {
// simulate package // simulate package
await _createPackage(fs, 'somepkg', 'somefile.txt'); await _createPackage(fs, 'somepkg', 'somefile.txt');
devFS = DevFS(vmService, 'test', tempDir);
await devFS.create(); await devFS.create();
vmService.expectMessages(<String>['create test']); vmService.expectMessages(<String>['create test']);
expect(devFS.assetPathsToEvict, isEmpty); expect(devFS.assetPathsToEvict, isEmpty);
...@@ -232,8 +236,6 @@ void main() { ...@@ -232,8 +236,6 @@ void main() {
// simulate package // simulate package
await _createPackage(fs, 'somepkg', 'somefile.txt'); await _createPackage(fs, 'somepkg', 'somefile.txt');
devFS = DevFS(vmService, 'test', tempDir);
await devFS.create(); await devFS.create();
vmService.expectMessages(<String>['create test']); vmService.expectMessages(<String>['create test']);
expect(devFS.assetPathsToEvict, isEmpty); expect(devFS.assetPathsToEvict, isEmpty);
...@@ -253,7 +255,6 @@ void main() { ...@@ -253,7 +255,6 @@ void main() {
}); });
testUsingContext('reports unsuccessful compile when errors are returned', () async { testUsingContext('reports unsuccessful compile when errors are returned', () async {
devFS = DevFS(vmService, 'test', tempDir);
await devFS.create(); await devFS.create();
final DateTime previousCompile = devFS.lastCompiled; final DateTime previousCompile = devFS.lastCompiled;
...@@ -283,7 +284,6 @@ void main() { ...@@ -283,7 +284,6 @@ void main() {
}); });
testUsingContext('correctly updates last compiled time when compilation does not fail', () async { testUsingContext('correctly updates last compiled time when compilation does not fail', () async {
devFS = DevFS(vmService, 'test', tempDir);
// simulate package // simulate package
final File sourceFile = await _createPackage(fs, 'somepkg', 'main.dart'); final File sourceFile = await _createPackage(fs, 'somepkg', 'main.dart');
...@@ -359,8 +359,14 @@ class MockVMService extends BasicMock implements VMService { ...@@ -359,8 +359,14 @@ class MockVMService extends BasicMock implements VMService {
await _server?.close(); await _server?.close();
} }
void resetState() {
_vm = MockVM(this);
messages.clear();
}
@override @override
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
} }
class MockVM implements VM { class MockVM implements VM {
......
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