[web] Fix 'felt test' watch mode (flutter/engine#36423)
This commit is contained in:
@@ -38,7 +38,7 @@ class RunTestsStep implements PipelineStep {
|
||||
required this.requireSkiaGold,
|
||||
this.testFiles,
|
||||
required this.overridePathToCanvasKit,
|
||||
}) : _browserEnvironment = getBrowserEnvironment(browserName);
|
||||
});
|
||||
|
||||
final String browserName;
|
||||
final List<FilePath>? testFiles;
|
||||
@@ -49,8 +49,6 @@ class RunTestsStep implements PipelineStep {
|
||||
/// Require Skia Gold to be available and reachable.
|
||||
final bool requireSkiaGold;
|
||||
|
||||
final BrowserEnvironment _browserEnvironment;
|
||||
|
||||
@override
|
||||
String get description => 'run_tests';
|
||||
|
||||
@@ -63,14 +61,16 @@ class RunTestsStep implements PipelineStep {
|
||||
@override
|
||||
Future<void> run() async {
|
||||
await _prepareTestResultsDirectory();
|
||||
await _browserEnvironment.prepare();
|
||||
|
||||
final BrowserEnvironment browserEnvironment = getBrowserEnvironment(browserName);
|
||||
await browserEnvironment.prepare();
|
||||
|
||||
final SkiaGoldClient? skiaClient = await _createSkiaClient();
|
||||
final List<FilePath> testFiles = this.testFiles ?? findAllTests();
|
||||
|
||||
await _runTestBatch(
|
||||
testFiles: testFiles,
|
||||
browserEnvironment: _browserEnvironment,
|
||||
browserEnvironment: browserEnvironment,
|
||||
expectFailure: false,
|
||||
isDebug: isDebug,
|
||||
doUpdateScreenshotGoldens: doUpdateScreenshotGoldens,
|
||||
@@ -78,7 +78,7 @@ class RunTestsStep implements PipelineStep {
|
||||
overridePathToCanvasKit: overridePathToCanvasKit,
|
||||
);
|
||||
|
||||
await _browserEnvironment.cleanup();
|
||||
await browserEnvironment.cleanup();
|
||||
|
||||
if (io.exitCode != 0) {
|
||||
throw ToolExit('Some tests failed');
|
||||
|
||||
@@ -141,12 +141,30 @@ class TestCommand extends Command<bool> with ArgUtils<bool> {
|
||||
overridePathToCanvasKit: overridePathToCanvasKit,
|
||||
),
|
||||
]);
|
||||
await testPipeline.run();
|
||||
|
||||
try {
|
||||
await testPipeline.run();
|
||||
if (isWatchMode) {
|
||||
print('');
|
||||
print('Initial test succeeded!');
|
||||
}
|
||||
} catch(error, stackTrace) {
|
||||
if (isWatchMode) {
|
||||
// The error is printed but not rethrown in watch mode because
|
||||
// failures are expected. The idea is that the developer corrects the
|
||||
// error, saves the file, and the pipeline reruns.
|
||||
print('');
|
||||
print('Initial test failed!\n');
|
||||
print(error);
|
||||
print(stackTrace);
|
||||
} else {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
if (isWatchMode) {
|
||||
final FilePath dir = FilePath.fromWebUi('');
|
||||
print('');
|
||||
print('Initial test run is done!');
|
||||
print(
|
||||
'Watching ${dir.relativeToCwd}/lib and ${dir.relativeToCwd}/test to re-run tests');
|
||||
print('');
|
||||
|
||||
Reference in New Issue
Block a user