mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 08:31:29 +00:00
[ VM ] Add delay between SIGINTs to fix flakiness of regress_42092_test
Change-Id: I1cce3f37491567bd13c9f64d4d15afed23a35a10 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204901 Auto-Submit: Ben Konyi <bkonyi@google.com> Reviewed-by: Siva Annamalai <asiva@google.com> Commit-Queue: Ben Konyi <bkonyi@google.com>
This commit is contained in:
parent
7e64685c10
commit
71c61ea24c
|
@ -8,44 +8,25 @@ import 'dart:io';
|
|||
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
late Process process;
|
||||
bool lastKill = false;
|
||||
|
||||
Future<void> sigint(int iterations) async {
|
||||
for (int i = 0; i < iterations; ++i) {
|
||||
if (i + 1 == iterations) {
|
||||
lastKill = true;
|
||||
}
|
||||
process.kill(ProcessSignal.sigint);
|
||||
// Yield to the event loop to allow for the signal to be sent.
|
||||
await Future.value(null);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
process = await Process.start(
|
||||
final process = await Process.start(
|
||||
Platform.resolvedExecutable,
|
||||
[
|
||||
Platform.script.resolve('regress_42092_script.dart').toString(),
|
||||
],
|
||||
);
|
||||
final startCompleter = Completer<void>();
|
||||
late StreamSubscription sub;
|
||||
int count = 0;
|
||||
sub = process.stdout.transform(Utf8Decoder()).listen((event) {
|
||||
if (event.contains('Waiting...')) {
|
||||
startCompleter.complete();
|
||||
sub.cancel();
|
||||
print(event);
|
||||
if (event.contains('child: Got a SIGINT')) {
|
||||
++count;
|
||||
if (count == 3) {
|
||||
sub.cancel();
|
||||
}
|
||||
}
|
||||
process.kill(ProcessSignal.sigint);
|
||||
});
|
||||
|
||||
// Wait for target script to setup its signal handling.
|
||||
await startCompleter.future;
|
||||
|
||||
final exitCompleter = Completer<void>();
|
||||
process.exitCode.then((code) {
|
||||
Expect.isTrue(lastKill);
|
||||
exitCompleter.complete();
|
||||
});
|
||||
await sigint(3);
|
||||
await exitCompleter.future;
|
||||
await process.exitCode;
|
||||
}
|
||||
|
|
|
@ -10,44 +10,25 @@ import 'dart:io';
|
|||
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
Process process;
|
||||
bool lastKill = false;
|
||||
|
||||
Future<void> sigint(int iterations) async {
|
||||
for (int i = 0; i < iterations; ++i) {
|
||||
if (i + 1 == iterations) {
|
||||
lastKill = true;
|
||||
}
|
||||
process.kill(ProcessSignal.sigint);
|
||||
// Yield to the event loop to allow for the signal to be sent.
|
||||
await Future.value(null);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
process = await Process.start(
|
||||
final process = await Process.start(
|
||||
Platform.resolvedExecutable,
|
||||
[
|
||||
Platform.script.resolve('regress_42092_script.dart').toString(),
|
||||
],
|
||||
);
|
||||
final startCompleter = Completer<void>();
|
||||
StreamSubscription sub;
|
||||
int count = 0;
|
||||
sub = process.stdout.transform(Utf8Decoder()).listen((event) {
|
||||
if (event.contains('Waiting...')) {
|
||||
startCompleter.complete();
|
||||
sub.cancel();
|
||||
print(event);
|
||||
if (event.contains('child: Got a SIGINT')) {
|
||||
++count;
|
||||
if (count == 3) {
|
||||
sub.cancel();
|
||||
}
|
||||
}
|
||||
process.kill(ProcessSignal.sigint);
|
||||
});
|
||||
|
||||
// Wait for target script to setup its signal handling.
|
||||
await startCompleter.future;
|
||||
|
||||
final exitCompleter = Completer<void>();
|
||||
process.exitCode.then((code) {
|
||||
Expect.isTrue(lastKill);
|
||||
exitCompleter.complete();
|
||||
});
|
||||
await sigint(3);
|
||||
await exitCompleter.future;
|
||||
await process.exitCode;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue