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

Unified Diff: tests/lib/async/catch_errors13_test.dart

Issue 60013013: Make catch_errors13_test non-flaky. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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/lib/async/catch_errors13_test.dart
diff --git a/tests/lib/async/catch_errors13_test.dart b/tests/lib/async/catch_errors13_test.dart
index 0889f2e19340878fa3facd825b97276f41e74842..73f52e3bd71f7cfe21518e91ec6283179aa80e96 100644
--- a/tests/lib/async/catch_errors13_test.dart
+++ b/tests/lib/async/catch_errors13_test.dart
@@ -19,16 +19,28 @@ main() {
// Test that errors are caught by nested `catchErrors`. Also uses
// `scheduleMicrotask` in the body of a Timer.
+ bool outerTimerRan = false;
+ int outerTimerCounterDelayCount = 0;
catchErrors(() {
events.add("catch error entry");
catchErrors(() {
events.add("catch error entry2");
Timer.run(() { throw "timer error"; });
- new Timer(const Duration(milliseconds: 50),
- () {
- scheduleMicrotask(() { throw "scheduleMicrotask"; });
- throw "delayed error";
- });
+
+ void runDelayed() {
+ new Timer(const Duration(milliseconds: 10),
+ () {
+ if (outerTimerRan) {
+ scheduleMicrotask(() { throw "scheduleMicrotask"; });
+ throw "delayed error";
+ } else if (outerTimerCounterDelayCount < 100) {
sra1 2013/11/08 00:09:02 What is significant about "100" ? It seems to me
floitsch 2013/11/08 00:19:52 I prefer making it deterministic. Added a comment.
+ outerTimerCounterDelayCount++;
+ runDelayed();
+ }
+ });
+ }
+
+ runDelayed();
}).listen((x) {
events.add(x);
if (x == "scheduleMicrotask") {
@@ -36,7 +48,10 @@ main() {
}
});
events.add("after inner");
- Timer.run(() { throw "timer outer"; });
+ Timer.run(() {
+ outerTimerRan = true;
+ throw "timer outer";
+ });
throw "inner throw";
}).listen((x) {
events.add(x);
« 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