OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012, 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 #import("dart:io"); | |
6 #import("../../../../tools/testing/dart/test_runner.dart"); | |
7 #import("../../../../tools/testing/dart/status_file_parser.dart"); | |
8 #import("../../../../tools/testing/dart/test_options.dart"); | |
9 #source("ProcessTestUtil.dart"); | |
10 | |
11 class TestController { | |
12 static final int numTests = 4; | |
13 static int numCompletedTests = 0; | |
14 | |
15 // Used as TestCase.completedCallback. | |
16 static processCompletedTest(TestCase testCase) { | |
17 TestOutput output = testCase.output; | |
18 print("Test: ${testCase.commands.last().commandLine}"); | |
19 if (output.unexpectedOutput) { | |
20 throw "Unexpected output: ${output.result}"; | |
21 } | |
22 print("stdout: "); | |
23 for (var line in output.stdout) print(line); | |
24 print("stderr: "); | |
25 for (var line in output.stderr) print(line); | |
26 | |
27 print("Time: ${output.time}"); | |
28 print("Exit code: ${output.exitCode}"); | |
29 | |
30 ++numCompletedTests; | |
31 print("$numCompletedTests/$numTests"); | |
32 if (numCompletedTests == numTests) { | |
33 print("TestRunnerTest.dart PASSED"); | |
34 } | |
35 } | |
36 } | |
37 | |
38 | |
39 TestCase MakeTestCase(String testName, List<String> expectations) { | |
40 String test_path = "tests/standalone/src/${testName}.dart"; | |
41 // Working directory may be dart/runtime rather than dart. | |
42 if (!new File(test_path).existsSync()) { | |
43 test_path = "../tests/standalone/src/${testName}.dart"; | |
44 } | |
45 | |
46 var configuration = new TestOptionsParser().parse(['--timeout', '2'])[0]; | |
47 return new TestCase(testName, | |
48 [new Command(getDartFileName(), | |
49 <String>["--ignore-unrecognized-flags", | |
50 "--enable_type_checks", | |
51 test_path])], | |
52 configuration, | |
53 TestController.processCompletedTest, | |
54 new Set<String>.from(expectations)); | |
55 } | |
56 | |
57 | |
58 void main() { | |
59 new RunningProcess(MakeTestCase("PassTest", [PASS])).start(); | |
60 new RunningProcess(MakeTestCase("FailTest", [FAIL])).start(); | |
61 new RunningProcess(MakeTestCase("TimeoutTest", [TIMEOUT])).start(); | |
62 | |
63 // The crash test sometimes times out. Run it with a large timeout to help | |
64 // diagnose the delay. | |
65 // The test loads a new executable, which may sometimes take a long time. | |
66 // It involves a wait on the VM event loop, and possible system delays. | |
67 var configuration = new TestOptionsParser().parse(['--timeout', '60'])[0]; | |
68 new RunningProcess(new TestCase("CrashTest", | |
69 [new Command(getProcessTestFileName(), | |
70 const ["0", "0", "1", "1"])], | |
71 configuration, | |
72 TestController.processCompletedTest, | |
73 new Set<String>.from([CRASH]))).start(); | |
74 Expect.equals(4, TestController.numTests); | |
75 // Throw must be from body of start() function for this test to work. | |
76 Expect.throws(new RunningProcess(MakeTestCase("PassTest", [SKIP])).start); | |
77 } | |
OLD | NEW |