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

Unified Diff: test/codegen/async_helper.dart

Issue 1289673007: fixes #292, report async_helper test failures (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 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 | « test/browser/language_tests.js ('k') | test/codegen/expect/async_helper.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/codegen/async_helper.dart
diff --git a/test/codegen/async_helper.dart b/test/codegen/async_helper.dart
index 37496bcb76bda9156c55f57b6accd2ec6b35895f..be5014fd6efdb7e09e602a8e9a1f62bb3d66bf34 100644
--- a/test/codegen/async_helper.dart
+++ b/test/codegen/async_helper.dart
@@ -23,20 +23,29 @@
library async_helper;
-// TODO(kustermann): This is problematic because we rely on a working
-// 'dart:isolate' (i.e. it is in particular problematic with dart2js).
-// It would be nice if we could use a different mechanism for different
-// runtimes.
-import 'dart:isolate';
-
bool _initialized = false;
-ReceivePort _port = null;
+
+typedef void _Action0();
+_Action0 _onAsyncEnd;
+
int _asyncLevel = 0;
Exception _buildException(String msg) {
return new Exception('Fatal: $msg. This is most likely a bug in your test.');
}
+/// Implementation method called from language_tests.js.
+/// Registers the callback that will be used complete the test.
+void asyncTestInitialize(_Action0 callback) {
+ _asyncLevel = 0;
+ _initialized = false;
+ _onAsyncEnd = callback;
+}
+
+/// Implementation method called from language_tests.js.
+/// Returns true if an asyncTest was started.
+bool get asyncTestStarted => _initialized;
+
/// Call this method before an asynchronous test is created.
void asyncStart() {
if (_initialized && _asyncLevel == 0) {
@@ -44,9 +53,14 @@ void asyncStart() {
'with testing.');
}
if (!_initialized) {
+ if (_onAsyncEnd == null) {
+ throw _buildException(
+ 'asyncStart() was called before asyncTestInitialize()');
+ }
+
print('unittest-suite-wait-for-done');
_initialized = true;
- _port = new ReceivePort();
+
}
_asyncLevel++;
}
@@ -63,8 +77,9 @@ void asyncEnd() {
}
_asyncLevel--;
if (_asyncLevel == 0) {
- _port.close();
- _port = null;
+ var callback = _onAsyncEnd;
+ _onAsyncEnd = null;
+ callback();
print('unittest-suite-success');
}
}
« no previous file with comments | « test/browser/language_tests.js ('k') | test/codegen/expect/async_helper.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698