Make FlutterTestDriver.stop() safe to call if it didn't spawn a process (#24393)

This means we can just always add it to test teardowns without having to add try/catches if there are any tests that don't spawn a process.
This commit is contained in:
Danny Tuppeny
2018-11-19 07:16:32 +00:00
committed by GitHub
parent 08e7f26510
commit 113f8f1a8d
2 changed files with 7 additions and 7 deletions

View File

@@ -25,6 +25,7 @@ void main() {
});
tearDown(() async {
await _flutter.stop();
tryToDelete(tempDir);
});
@@ -52,11 +53,7 @@ void main() {
test('writes pid-file', () async {
final File pidFile = tempDir.childFile('test.pid');
await _flutter.run(pidFile: pidFile);
try {
expect(pidFile.existsSync(), isTrue);
} finally {
await _flutter.stop();
}
expect(pidFile.existsSync(), isTrue);
});
}, timeout: const Timeout.factor(6));
}

View File

@@ -220,8 +220,11 @@ class FlutterTestDriver {
);
_currentRunningAppId = null;
}
_debugPrint('Waiting for process to end');
return _proc.exitCode.timeout(quitTimeout, onTimeout: _killGracefully);
if (_proc != null) {
_debugPrint('Waiting for process to end');
return _proc.exitCode.timeout(quitTimeout, onTimeout: _killGracefully);
}
return 0;
}
Future<int> quit() => _killGracefully();