Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Unified Diff: tests/html/async_test.dart

Issue 22976006: Rewrite async test to make it non-flaky. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/html/async_test.dart
diff --git a/tests/html/async_test.dart b/tests/html/async_test.dart
index 1d7768f878c1d2c23a3d751856ecc4ccbefc6265..616258cd17dbd607711a83d11d2be774843a361c 100644
--- a/tests/html/async_test.dart
+++ b/tests/html/async_test.dart
@@ -40,10 +40,8 @@ periodicTimerIsolate() {
cancellingIsolate() {
port.receive((msg, replyTo) {
expect(msg, 'START');
- final oneshot = new Timer(const Duration(milliseconds: 30), () {
- fail('Should never be invoked');
- });
bool shot = false;
+ var oneshot;
var periodic;
periodic = new Timer.periodic(const Duration(milliseconds: 10), (timer) {
expect(shot, isFalse);
@@ -57,6 +55,13 @@ cancellingIsolate() {
replyTo.send('DONE');
});
});
+ // We launch the oneshot timer after the periodic timer. Otherwise a
+ // (very long) context switch could make this test flaky: assume the
+ // oneshot timer is created first and then there is a 30ms context switch.
+ // when the periodic timer is scheduled it would execute after the oneshot.
+ oneshot = new Timer(const Duration(milliseconds: 30), () {
+ fail('Should never be invoked');
+ });
});
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698