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

Side by Side Diff: tests/standalone/src/TestRunnerTest.dart

Issue 8662004: Update test scripts to deal with current VM behavior on optional constructor arguments. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/standalone/src/ProcessTestUtil.dart ('k') | tools/testing/dart/test_options.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #library("TestRunnerTest"); 5 #library("TestRunnerTest");
6 6
7 #import("../../../tools/testing/dart/test_runner.dart"); 7 #import("../../../tools/testing/dart/test_runner.dart");
8 #import("../../../tools/testing/dart/status_file_parser.dart"); 8 #import("../../../tools/testing/dart/status_file_parser.dart");
9 9 #source("ProcessTestUtil.dart");
10 // TODO(whesse) source("ProcessTestUtil.dart"); when it is committed.
11 10
12 class TestController { 11 class TestController {
13 static final int numTests = 4; 12 static final int numTests = 4;
14 static int numCompletedTests = 0; 13 static int numCompletedTests = 0;
15 14
16 // Used as TestCase.completedCallback. 15 // Used as TestCase.completedCallback.
17 static processCompletedTest(TestCase testCase) { 16 static processCompletedTest(TestCase testCase) {
18 TestOutput output = testCase.output; 17 TestOutput output = testCase.output;
19 print("Test: ${testCase.commandLine}"); 18 print("Test: ${testCase.commandLine}");
20 if (output.unexpectedOutput) { 19 if (output.unexpectedOutput) {
21 throw "Unexpected output: ${output.result}"; 20 throw "Unexpected output: ${output.result}";
22 } 21 }
23 print("stdout: "); 22 print("stdout: ");
24 for (var line in output.stdout) print(line); 23 for (var line in output.stdout) print(line);
25 print("stderr: "); 24 print("stderr: ");
26 for (var line in output.stderr) print(line); 25 for (var line in output.stderr) print(line);
27 26
28 print("Time: ${output.time}"); 27 print("Time: ${output.time}");
29 print("Exit code: ${output.exitCode}"); 28 print("Exit code: ${output.exitCode}");
30 29
31 ++numCompletedTests; 30 ++numCompletedTests;
32 print("$numCompletedTests/$numTests"); 31 print("$numCompletedTests/$numTests");
33 if (numCompletedTests == numTests) { 32 if (numCompletedTests == numTests) {
34 print("TestRunnerTest.dart PASSED"); 33 print("TestRunnerTest.dart PASSED");
35 } 34 }
36 } 35 }
37 } 36 }
38 37
38
39 TestCase MakeTestCase(String testName, List<String> expectations) { 39 TestCase MakeTestCase(String testName, List<String> expectations) {
40 String test_path = "tests/standalone/src/${testName}.dart"; 40 String test_path = "tests/standalone/src/${testName}.dart";
41 // Working directory may be dart/runtime rather than dart. 41 // Working directory may be dart/runtime rather than dart.
42 if (!new File(test_path).existsSync()) { 42 if (!new File(test_path).existsSync()) {
43 test_path = "../tests/standalone/src/${testName}.dart"; 43 test_path = "../tests/standalone/src/${testName}.dart";
44 } 44 }
45 45
46 var timeout = 2; 46 var timeout = 2;
47 return new TestCase(testName, 47 return new TestCase(testName,
48 getDartBinName(), 48 getDartBinName(),
49 <String>["--ignore-unrecognized-flags", 49 <String>["--ignore-unrecognized-flags",
50 "--enable_type_checks", 50 "--enable_type_checks",
51 test_path], 51 test_path],
52 timeout, 52 timeout,
53 TestController.processCompletedTest, 53 TestController.processCompletedTest,
54 new Set<String>.from(expectations)); 54 new Set<String>.from(expectations));
55 } 55 }
56 56
57 57
58 String getDartBinName() { 58 String getDartBinName() {
59 var names = ["out/Debug_ia32/dart", 59 var os = new Platform().operatingSystem();
60 "out/Release_ia32/dart", 60
61 "xcodebuild/Debug_ia32/dart", 61 var outDir = '';
62 "xcodebuild/Release_ia32/dart", 62 if (os == 'linux') {
63 "Debug_ia32/dart.exe", 63 outDir = 'out';
64 "Release_ia32/dart.exe"]; 64 } else if (os == 'macos') {
65 outDir = 'xcodebuild';
66 }
67
68 var names = ['$outDir/Debug_ia32/dart',
69 '$outDir/Release_ia32/dart'];
70
65 for (var name in names) { 71 for (var name in names) {
66 if (new File(name).existsSync()) { 72 if (new File(name).existsSync()) {
67 return name; 73 return name;
68 } 74 }
69 } 75 }
70 } 76 }
71 77
72 78
73 String getProcessTestFileName() {
74 var names = ['out/Release_ia32/process_test',
75 'out/Debug_ia32/process_test',
76 'xcodebuild/Release_ia32/process_test',
77 'xcodebuild/Debug_ia32/process_test',
78 'Release_ia32/process_test.exe',
79 'Debug_ia32/process_test.exe'];
80 for (var name in names) {
81 if (new File(name).existsSync()) {
82 return name;
83 }
84 }
85 Expect.fail('Could not find the process_test program.');
86 }
87
88 void main() { 79 void main() {
89 int timeout = 2; 80 int timeout = 2;
90 new RunningProcess(MakeTestCase("PassTest", [PASS]), timeout).start(); 81 new RunningProcess(MakeTestCase("PassTest", [PASS]), timeout).start();
91 new RunningProcess(MakeTestCase("FailTest", [FAIL]), timeout).start(); 82 new RunningProcess(MakeTestCase("FailTest", [FAIL]), timeout).start();
92 new RunningProcess(MakeTestCase("TimeoutTest", [TIMEOUT]), timeout).start(); 83 new RunningProcess(MakeTestCase("TimeoutTest", [TIMEOUT]), timeout).start();
93 84
94 new RunningProcess(new TestCase("CrashTest", 85 new RunningProcess(new TestCase("CrashTest",
95 getProcessTestFileName(), 86 getProcessTestFileName(),
96 const ["0", "0", "1", "1"], 87 const ["0", "0", "1", "1"],
97 timeout, 88 timeout,
98 TestController.processCompletedTest, 89 TestController.processCompletedTest,
99 new Set<String>.from([CRASH])), 90 new Set<String>.from([CRASH])),
100 timeout).start(); 91 timeout).start();
101 Expect.equals(4, TestController.numTests); 92 Expect.equals(4, TestController.numTests);
102 // Throw must be from body of start() function for this test to work. 93 // Throw must be from body of start() function for this test to work.
103 Expect.throws( 94 Expect.throws(
104 new RunningProcess(MakeTestCase("PassTest", [SKIP]), timeout).start); 95 new RunningProcess(MakeTestCase("PassTest", [SKIP]), timeout).start);
105 } 96 }
106 97
OLDNEW
« no previous file with comments | « tests/standalone/src/ProcessTestUtil.dart ('k') | tools/testing/dart/test_options.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698