[dartdev] Fix webdev integration test

Closes: https://github.com/dart-lang/sdk/issues/51106
Closes: https://github.com/dart-lang/sdk/issues/51037
Change-Id: If88b3e800764dbf0be4e294dc996fa2bc74be1f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280561
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Anna Gringauze <annagrin@google.com>
This commit is contained in:
Anna Gringauze 2023-02-04 01:05:45 +00:00 committed by Commit Queue
parent dae49a0ca2
commit b6bcdeaa5f
2 changed files with 32 additions and 6 deletions

View file

@ -133,20 +133,31 @@ void defineCreateTests() {
// if they've executed correctly. These templates won't exit on their // if they've executed correctly. These templates won't exit on their
// own, so we'll need to terminate the process once we've verified it // own, so we'll need to terminate the process once we've verified it
// runs correctly. // runs correctly.
var hasError = false;
stdoutSub = process.stdout.transform(utf8.decoder).listen((e) { stdoutSub = process.stdout.transform(utf8.decoder).listen((e) {
print('stdout: $e'); print('stdout: $e');
if ((isServerTemplate && e.contains('Server listening on port')) || if (e.contains('[SEVERE]') ||
(isServerTemplate && e.contains('Server listening on port')) ||
(isWebTemplate && e.contains('Succeeded after'))) { (isWebTemplate && e.contains('Succeeded after'))) {
if (e.contains('[SEVERE]')) {
hasError = true;
}
stderrSub.cancel(); stderrSub.cancel();
stdoutSub.cancel(); stdoutSub.cancel();
process.kill(); process.kill();
completer.complete(); completer.complete();
} }
}); });
stderrSub = process.stderr stderrSub = process.stderr.transform(utf8.decoder).listen((e) {
.transform(utf8.decoder) print('stderr: $e');
.listen((e) => print('stderr: $e')); hasError = true;
stderrSub.cancel();
stdoutSub.cancel();
process.kill();
completer.complete();
});
await completer.future; await completer.future;
expect(hasError, isFalse, reason: 'Command $command failed.');
// Since we had to terminate the process manually, we aren't certain // Since we had to terminate the process manually, we aren't certain
// as to what the exit code will be on all platforms (should be -15 // as to what the exit code will be on all platforms (should be -15
@ -154,9 +165,25 @@ void defineCreateTests() {
// here. // here.
await process.exitCode; await process.exitCode;
} else { } else {
final output = <String>[];
final errors = <String>[];
process.stdout.transform(utf8.decoder).listen(output.add);
process.stderr.transform(utf8.decoder).listen(errors.add);
// If the sample should exit on its own, it should always result in // If the sample should exit on its own, it should always result in
// an exit code of 0. // an exit code of 0.
expect(await process.exitCode, 0); final duration = const Duration(seconds: 30);
final exitCode =
await process.exitCode.timeout(duration, onTimeout: () {
print('Command $command timed out');
return -1;
});
if (exitCode != 0) {
print('Command $command exited with code $exitCode');
print('Output: \n${output.join('\n')}');
print('Errors: \n${errors.join('\n')}');
}
expect(exitCode, 0);
} }
print('[${i + 1} / ${runCommands.length}] Done "$command".'); print('[${i + 1} / ${runCommands.length}] Done "$command".');
} }

View file

@ -147,7 +147,6 @@ vm_service/test/*: SkipByDesign # Uses dart:io
vm_snapshot_analysis/test/*: SkipByDesign # Only meant to run on vm vm_snapshot_analysis/test/*: SkipByDesign # Only meant to run on vm
[ $system == windows ] [ $system == windows ]
dartdev/test/commands/create_integration_test: Skip # dartbug.com/51037 until fix lands for windows
front_end/test/fasta/bootstrap_test: Skip # Issue 31902 front_end/test/fasta/bootstrap_test: Skip # Issue 31902
front_end/test/fasta/strong_test: Pass, Slow, Timeout front_end/test/fasta/strong_test: Pass, Slow, Timeout
front_end/test/incremental_dart2js_load_from_dill_test: Pass, Slow front_end/test/incremental_dart2js_load_from_dill_test: Pass, Slow