[ 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:
Ben Konyi 2021-06-29 01:36:32 +00:00 committed by commit-bot@chromium.org
parent 7e64685c10
commit 71c61ea24c
2 changed files with 20 additions and 58 deletions

View file

@ -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();
print(event);
if (event.contains('child: Got a SIGINT')) {
++count;
if (count == 3) {
sub.cancel();
}
});
// 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;
}
process.kill(ProcessSignal.sigint);
});
await process.exitCode;
}

View file

@ -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();
print(event);
if (event.contains('child: Got a SIGINT')) {
++count;
if (count == 3) {
sub.cancel();
}
});
// 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;
}
process.kill(ProcessSignal.sigint);
});
await process.exitCode;
}