| OLD | NEW |
| (Empty) | |
| 1 |
| 2 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 3 // for details. All rights reserved. Use of this source code is governed by a |
| 4 // BSD-style license that can be found in the LICENSE file. |
| 5 |
| 6 #library("TestRunnerTest"); |
| 7 |
| 8 |
| 9 #import("../../../tools/testing/dart/test_runner.dart"); |
| 10 |
| 11 // TODO(whesse) source("ProcessTestUtil.dart"); when it is committed. |
| 12 |
| 13 class TestController { |
| 14 static final int numTests = 4; |
| 15 static int numCompletedTests = 0; |
| 16 |
| 17 // Used as TestCase.completedCallback. |
| 18 static processCompletedTest(TestCase testCase) { |
| 19 TestOutput output = testCase.output; |
| 20 print("Test: ${testCase.commandLine}"); |
| 21 if (output.unexpectedOutput) { |
| 22 print("Unexpected output: ${output.result}"); |
| 23 } |
| 24 print("stdout: "); |
| 25 for (var line in output.stdout) print(line); |
| 26 print("stderr: "); |
| 27 for (var line in output.stderr) print(line); |
| 28 |
| 29 print("Time: ${output.time}"); |
| 30 print("Exit code: ${output.exitCode}"); |
| 31 |
| 32 ++numCompletedTests; |
| 33 print("$numCompletedTests/$numTests"); |
| 34 if (numCompletedTests == numTests) { |
| 35 print("TestRunnerTest.dart PASSED"); |
| 36 } |
| 37 } |
| 38 } |
| 39 |
| 40 TestCase MakeTestCase(String testName, List<String> expectations) { |
| 41 return new TestCase(getDartShellFileName(), <String>[ |
| 42 "--ignore-unrecognized-flags", |
| 43 "--enable_type_checks", |
| 44 "tests/standalone/src/${testName}.dart"], |
| 45 TestController.processCompletedTest, |
| 46 new Set<String>.from(expectations)); |
| 47 } |
| 48 |
| 49 void main() { |
| 50 new RunningProcess(MakeTestCase("PassTest", [PASS]), 30).start(); |
| 51 new RunningProcess(MakeTestCase("FailTest", [FAIL]), 30).start(); |
| 52 new RunningProcess(MakeTestCase("TimeoutTest", [TIMEOUT]), 30).start(); |
| 53 |
| 54 // TODO(whesse): Replace process_test with getProcessTestFileName(). |
| 55 new RunningProcess(new TestCase("out/Debug_ia32/process_test", |
| 56 const ["0", "0", "1", "1"], |
| 57 TestController.processCompletedTest, |
| 58 new Set<String>.from([CRASH])), |
| 59 30).start(); |
| 60 Expect.equals(4, TestController.numTests); |
| 61 // Throw must be from body of start() function for this test to work. |
| 62 Expect.throws( |
| 63 new RunningProcess(MakeTestCase("PassTest", [SKIP]), 30).start); |
| 64 } |
| 65 |
| OLD | NEW |