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

Unified Diff: tools/testing/dart/test_runner.dart

Issue 8889016: Enable Dartium tests in tools/test.dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments. Created 9 years 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
Index: tools/testing/dart/test_runner.dart
diff --git a/tools/testing/dart/test_runner.dart b/tools/testing/dart/test_runner.dart
index 0237dbb6ae584a747f65a1ba6ff9fc01a6712894..4c09d4d9c15a352ce3648fe1370c2962ffc0ce94 100644
--- a/tools/testing/dart/test_runner.dart
+++ b/tools/testing/dart/test_runner.dart
@@ -80,6 +80,32 @@ class TestCase {
}
+/** RunningProcess.start() handles CompilingTestCase specially, executing
Mads Ager (google) 2011/12/09 13:19:37 BrowserTestCase I would reformulate to say someth
+ * the compilation command line first.
+ */
+class BrowserTestCase extends TestCase {
+ String compilerPath;
+ List<String> compilerArguments;
+
+ BrowserTestCase(displayName,
+ this.compilerPath,
+ this.compilerArguments,
+ executablePath,
+ arguments,
+ configuration,
+ completedHandler,
+ expectedOutcomes,
+ [isNegative = false]) : super(displayName,
+ executablePath,
+ arguments,
+ configuration,
+ completedHandler,
+ expectedOutcomes,
+ isNegative);
+}
+
+
+
class TestOutput {
// The TestCase this is the output from.
TestCase testCase;
@@ -100,7 +126,7 @@ class TestOutput {
bool get unexpectedOutput() => !testCase.expectedOutcomes.contains(result);
- // The Java dartc runner exits with code 253 in case of unhandles
+ // The Java dartc runner exits with code 253 in case of unhandled
// exceptions.
// The VM uses std::abort to terminate on asserts.
// std::abort terminates with exit code 3 on Windows.
@@ -121,7 +147,21 @@ class TestOutput {
bool get hasTimedOut() => timedOut;
- bool get didFail() => exitCode != 0 && !hasCrashed;
+ bool get didFail() {
+ if (exitCode != 0 && !hasCrashed) return true;
+
+ // Browser tests fail unless stdout contains
+ // 'Content-Type: text/plain\nPASS'.
+ if (testCase is !BrowserTestCase) return false;
+ String previous_line = '';
+ for (String line in stdout) {
+ if (line == 'PASS' && previous_line == 'Content-Type: text/plain') {
+ return false;
+ }
+ previous_line = line;
+ }
+ return true;
+ }
// Reverse result of a negative test.
bool get hasFailed() => (testCase.isNegative ? !didFail : didFail);
@@ -148,6 +188,14 @@ class RunningProcess {
testCase.completed();
}
+ void compilerExitHandler(int exitCode) {
+ if (exitCode != 0) {
+ exitHandler(exitCode);
+ } else {
+ runCommand(testCase.executablePath, testCase.arguments, exitHandler);
+ }
+ }
+
void makeReadHandler(StringInputStream source, List<String> destination) {
return () {
if (source.closed) return; // TODO(whesse): Remove when bug is fixed.
@@ -161,15 +209,26 @@ class RunningProcess {
void start() {
Expect.isFalse(testCase.expectedOutcomes.contains(SKIP));
- process = new Process(testCase.executablePath, testCase.arguments);
+ stdout = new List<String>();
+ stderr = new List<String>();
+ if (testCase is BrowserTestCase) {
+ runCommand(testCase.compilerPath,
+ testCase.compilerArguments,
+ compilerExitHandler);
+ } else {
+ runCommand(testCase.executablePath, testCase.arguments, exitHandler);
+ }
+ }
+
+ void runCommand(String executable,
+ List<String> arguments,
+ void exitHandler(int exitCode)) {
+ process = new Process(executable, arguments);
process.exitHandler = exitHandler;
startTime = new Date.now();
process.start();
-
InputStream stdoutStream = process.stdout;
InputStream stderrStream = process.stderr;
- stdout = new List<String>();
- stderr = new List<String>();
StringInputStream stdoutStringStream = new StringInputStream(stdoutStream);
StringInputStream stderrStringStream = new StringInputStream(stderrStream);
stdoutStringStream.dataHandler =
@@ -179,6 +238,8 @@ class RunningProcess {
timeoutTimer = new Timer(timeoutHandler, 1000 * testCase.timeout, false);
}
Mads Ager (google) 2011/12/09 13:19:37 Remove the extra new lines.
+
+
void timeoutHandler(Timer unusedTimer) {
timedOut = true;
process.kill();

Powered by Google App Engine
This is Rietveld 408576698