| Index: tools/testing/dart/test_runner.dart
|
| diff --git a/tools/testing/dart/test_runner.dart b/tools/testing/dart/test_runner.dart
|
| index 8998e9510e9c0bfdaaa6eab36a1e975621292f40..b4c2c2f8c5d262f8df0a53419fb25bfb15cb4e39 100644
|
| --- a/tools/testing/dart/test_runner.dart
|
| +++ b/tools/testing/dart/test_runner.dart
|
| @@ -80,6 +80,33 @@ class TestCase {
|
| }
|
|
|
|
|
| +/**
|
| + * BrowserTestCase has an extra compilation command that is run by
|
| + * RunningProcess.start(), and it checks conditions on the test output
|
| + * in TestOutput.didFail().
|
| + */
|
| +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 +127,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 +148,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 +189,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 +210,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 =
|
|
|