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