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

Unified Diff: pkg/unittest/lib/test_controller.js

Issue 25514002: Implement testing support for "--compiler=none --runtime=dartium" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 | runtime/tests/vm/vm.status » ('j') | tools/testing/dart/test_suite.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/unittest/lib/test_controller.js
diff --git a/pkg/unittest/lib/test_controller.js b/pkg/unittest/lib/test_controller.js
index 4862e03fa9f7130ccf2a1d9f838b23ac7fb0c3cd..af9398ef032c93bebb6a9b6e9caaaf158261634a 100644
--- a/pkg/unittest/lib/test_controller.js
+++ b/pkg/unittest/lib/test_controller.js
@@ -67,7 +67,7 @@ function notifyDone() {
// TODO(ricow): REMOVE, debug info, see issue 13292
if (!testRunner) {
- dartPrint('Calling notifyDone()');
+ printMessage('Calling notifyDone()');
}
// To support in browser launching of tests we post back start and result
// messages to the window.opener.
@@ -80,7 +80,7 @@ function notifyDone() {
function processMessage(msg) {
// TODO(ricow): REMOVE, debug info, see issue 13292
if (!testRunner) {
- dartPrint('processMessage(): ' + msg);
+ printMessage('processMessage(): ' + msg);
}
if (typeof msg != 'string') return;
if (msg == 'unittest-suite-done') {
@@ -95,7 +95,7 @@ function processMessage(msg) {
window.postMessage('unittest-suite-success', '*');
}
} else if (msg == 'unittest-suite-success') {
- dartPrint('PASS');
+ printMessage('PASS');
notifyDone();
} else if (msg == 'unittest-suite-fail') {
showErrorAndExit('Some tests failed.');
@@ -114,11 +114,11 @@ window.addEventListener("message", onReceive, false);
function showErrorAndExit(message) {
if (message) {
- dartPrint('Error: ' + String(message));
+ printMessage('Error: ' + String(message));
}
// dart/tools/testing/run_selenium.py is looking for either PASS or
// FAIL and will continue polling until one of these words show up.
- dartPrint('FAIL');
+ printMessage('FAIL');
notifyDone();
}
@@ -158,27 +158,50 @@ document.addEventListener('readystatechange', function () {
});
// dart2js will generate code to call this function to handle the Dart
-// [print] method. The base [Configuration] (config.html) calls
-// [print] with the secret messages "unittest-suite-success" and
-// "unittest-suite-wait-for-done". These messages are then posted so
-// processMessage above will see them.
+// [print] method.
+//
+// dartium will invoke this method for [print] calls if the environment variable
+// "DART_FORWARDING_PRINT" was set when launching dartium.
+//
+// Our tests will be wrapped, so we can detect when [main] is called and when
+// it has ended.
+// The wrapping happens either via "dartMainRunner" (for dart2js) or wrapped
+// tests for dartium.
+//
+// The following messages are handled specially:
+// dart-calling-main: signals that the dart [main] function will be invoked
+// dart-main-done: signals that the dart [main] function has finished
+// unittest-suite-wait-for-done: signals the start of an asynchronous test
+// unittest-suite-success: signals the end of an asynchrounous test
+//
+// These messages are used to communicate with the test and will be posted so
+// [processMessage] above can see it.
function dartPrint(msg) {
if ((msg === 'unittest-suite-success')
|| (msg === 'unittest-suite-done')
- || (msg === 'unittest-suite-wait-for-done')) {
+ || (msg === 'unittest-suite-wait-for-done')
+ || (msg === 'dart-calling-main')
+ || (msg === 'dart-main-done')) {
window.postMessage(msg, '*');
return;
}
+ printMessage(msg);
+}
+
+// Prints 'msg' to the console (if available) and to the body of the html
+// document.
+function printMessage(msg) {
if (typeof console === 'object') console.warn(msg);
- var pre = document.createElement("pre");
+ var pre = document.createElement('pre');
pre.appendChild(document.createTextNode(String(msg)));
document.body.appendChild(pre);
+ document.body.appendChild(document.createTextNode('\n'));
}
// dart2js will generate code to call this function instead of calling
// Dart [main] directly. The argument is a closure that invokes main.
function dartMainRunner(main) {
- window.postMessage('dart-calling-main', '*');
+ dartPrint('dart-calling-main');
try {
main();
} catch (e) {
@@ -187,5 +210,5 @@ function dartMainRunner(main) {
window.postMessage('unittest-suite-fail', '*');
return;
}
- window.postMessage('dart-main-done', '*');
+ dartPrint('dart-main-done');
}
« no previous file with comments | « no previous file | runtime/tests/vm/vm.status » ('j') | tools/testing/dart/test_suite.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698