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

Unified Diff: pkg/dev_compiler/tool/run.js

Issue 2768233002: Add better support for async tests in run.js (Closed)
Patch Set: Created 3 years, 9 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: pkg/dev_compiler/tool/run.js
diff --git a/pkg/dev_compiler/tool/run.js b/pkg/dev_compiler/tool/run.js
index 90a2c8ab02f313e8c1e66136e46ca1eb525086f6..a7de6ca85cbfd703943baf0489f90e3a4371d759 100644
--- a/pkg/dev_compiler/tool/run.js
+++ b/pkg/dev_compiler/tool/run.js
@@ -43,12 +43,33 @@ requirejs.config({
// and use here. Async tests and unittests won't work without it.
var sdk = requirejs('dart_sdk');
sdk.dart.ignoreWhitelistedErrors(false);
+
+function finish(e) {
+ if (e) {
+ console.log('Test ' + test + ' failed:\n' + e.toString());
+ sdk.dart.stackPrint(e);
+ } else {
+ console.log('Test ' + test + ' passed.');
+ }
+}
+
+var async_helper = requirejs('async_helper').async_helper;
+async_helper.asyncTestInitialize(finish);
+
var module = requirejs(test);
var lib = test.split('/').slice(-1)[0];
try {
- sdk._isolate_helper.startRootIsolate(module[lib].main, []);
- console.log('Test ' + test + ' passed.');
+ var result = sdk._isolate_helper.startRootIsolate(module[lib].main, []);
+ // async_helper tests call finish directly - call here for all other
+ // tests.
+ if (!async_helper.asyncTestStarted) {
+ if (!result || !(result instanceof dart_sdk.async.Future)) {
+ finish();
+ } else {
+ // Wait iff result is a future
+ result.then(dart_sdk.dart.dynamic)(() => finish());
+ }
+ }
} catch (e) {
- console.log('Test ' + test + ' failed:\n' + e.toString());
- sdk.dart.stackPrint(e);
+ finish(e);
}
« 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