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

Side by Side Diff: tests/standalone/io/test_runner_test.dart

Issue 21001003: test.py: First step towards support of caching dart2js compilations across runtimes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 months 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 import "dart:io"; 5 import "dart:io";
6 import "dart:isolate"; 6 import "dart:isolate";
7 import "dart:async"; 7 import "dart:async";
8 import "dart:utf"; 8 import "dart:utf";
9 import "../../../tools/testing/dart/test_runner.dart"; 9 import "../../../tools/testing/dart/test_runner.dart";
10 import "../../../tools/testing/dart/test_suite.dart"; 10 import "../../../tools/testing/dart/test_suite.dart";
11 import "../../../tools/testing/dart/test_progress.dart" as progress;
11 import "../../../tools/testing/dart/status_file_parser.dart"; 12 import "../../../tools/testing/dart/status_file_parser.dart";
12 import "../../../tools/testing/dart/test_options.dart"; 13 import "../../../tools/testing/dart/test_options.dart";
13 import "process_test_util.dart"; 14 import "process_test_util.dart";
14 15
15 final DEFAULT_TIMEOUT = 2; 16 final DEFAULT_TIMEOUT = 2;
16 final LONG_TIMEOUT = 30; 17 final LONG_TIMEOUT = 30;
17 18
18 class TestController { 19 class TestController {
19 static int numTests = 0; 20 static int numTests = 0;
20 static int numCompletedTests = 0; 21 static int numCompletedTests = 0;
21 22
22 // Used as TestCase.completedCallback. 23 // Used as TestCase.completedCallback.
23 static processCompletedTest(TestCase testCase) { 24 static processCompletedTest(TestCase testCase) {
24 numCompletedTests++; 25 numCompletedTests++;
25 CommandOutput output = testCase.lastCommandOutput;
26 if (testCase.displayName == "fail-unexpected") { 26 if (testCase.displayName == "fail-unexpected") {
27 if (!output.unexpectedOutput) { 27 if (!testCase.unexpectedOutput) {
28 throw "Expected fail-unexpected"; 28 throw "Expected fail-unexpected";
29 } 29 }
30 } else { 30 } else {
31 if (output.unexpectedOutput) { 31 if (testCase.unexpectedOutput) {
32 throw "Unexpected fail"; 32 throw "Unexpected fail";
33 } 33 }
34 } 34 }
35 } 35 }
36 36
37 static void finished() { 37 static void finished() {
38 if (numTests != numCompletedTests) { 38 if (numTests != numCompletedTests) {
39 throw "bad completion count. " 39 throw "bad completion count. "
40 "expected: $numTests, actual: $numCompletedTests"; 40 "expected: $numTests, actual: $numCompletedTests";
41 } 41 }
(...skipping 22 matching lines...) Expand all
64 enqueueTestCase(testCaseFail); 64 enqueueTestCase(testCaseFail);
65 enqueueTestCase(testCaseTimeout); 65 enqueueTestCase(testCaseTimeout);
66 enqueueTestCase(testCaseFailUnexpected); 66 enqueueTestCase(testCaseFailUnexpected);
67 67
68 if (onDone != null) { 68 if (onDone != null) {
69 onDone(); 69 onDone();
70 } 70 }
71 } 71 }
72 72
73 TestCase _makeNormalTestCase(name, expectations) { 73 TestCase _makeNormalTestCase(name, expectations) {
74 var command = new Command('custom', 74 var command = CommandBuilder.instance.getCommand(
75 Platform.executable, 75 'custom', Platform.executable, [Platform.script, name],
76 [Platform.script, name]); 76 'ReleaseIA32');
77 return _makeTestCase(name, DEFAULT_TIMEOUT, command, expectations); 77 return _makeTestCase(name, DEFAULT_TIMEOUT, command, expectations);
78 } 78 }
79 79
80 _makeCrashTestCase(name, expectations) { 80 _makeCrashTestCase(name, expectations) {
ricow1 2013/08/01 18:23:52 where do call this from?
kustermann 2013/08/05 07:29:17 25 lines above.
81 var crashCommand = new Command('custom_crash', 81 var crashCommand = CommandBuilder.instance.getCommand(
82 getProcessTestFileName(), 82 'custom_crash', getProcessTestFileName(), ["0", "0", "1", "1"],
83 ["0", "0", "1", "1"]); 83 'ReleaseIA32');
84 // The crash test sometimes times out. Run it with a large timeout 84 // The crash test sometimes times out. Run it with a large timeout
85 // to help diagnose the delay. 85 // to help diagnose the delay.
86 // The test loads a new executable, which may sometimes take a long time. 86 // The test loads a new executable, which may sometimes take a long time.
87 // It involves a wait on the VM event loop, and possible system 87 // It involves a wait on the VM event loop, and possible system
88 // delays. 88 // delays.
89 return _makeTestCase(name, LONG_TIMEOUT, crashCommand, expectations); 89 return _makeTestCase(name, LONG_TIMEOUT, crashCommand, expectations);
90 } 90 }
91 91
92 _makeTestCase(name, timeout, command, expectations) { 92 _makeTestCase(name, timeout, command, expectations) {
93 var configuration = new TestOptionsParser() 93 var configuration = new TestOptionsParser()
94 .parse(['--timeout', '$timeout'])[0]; 94 .parse(['--timeout', '$timeout'])[0];
95 return new TestCase(name, 95 return new TestCase(name,
96 [command], 96 [command],
97 configuration, 97 configuration,
98 TestController.processCompletedTest,
99 new Set<String>.from(expectations)); 98 new Set<String>.from(expectations));
100 } 99 }
101 } 100 }
102 101
103 void testProcessQueue() { 102 void testProcessQueue() {
104 var maxProcesses = 2; 103 var maxProcesses = 2;
105 var maxBrowserProcesses = maxProcesses; 104 var maxBrowserProcesses = maxProcesses;
106 new ProcessQueue(maxProcesses, maxBrowserProcesses, 105 new ProcessQueue({}, maxProcesses, maxBrowserProcesses,
107 new DateTime.now(), [new CustomTestSuite()], [], TestController.finished); 106 new DateTime.now(), [new CustomTestSuite()],
107 [new EventListener()], TestController.finished);
108 }
109
110 class EventListener extends progress.EventListener{
111 void done(TestCase test) {
112 TestController.processCompletedTest(test);
113 }
108 } 114 }
109 115
110 void main() { 116 void main() {
111 // Run the test_runner_test if there are no command-line options. 117 // Run the test_runner_test if there are no command-line options.
112 // Otherwise, run one of the component tests that always pass, 118 // Otherwise, run one of the component tests that always pass,
113 // fail, or timeout. 119 // fail, or timeout.
114 var arguments = new Options().arguments; 120 var arguments = new Options().arguments;
115 if (arguments.isEmpty) { 121 if (arguments.isEmpty) {
116 testProcessQueue(); 122 testProcessQueue();
117 } else { 123 } else {
118 switch (arguments[0]) { 124 switch (arguments[0]) {
119 case 'pass': 125 case 'pass':
120 return; 126 return;
121 case 'fail-unexpected': 127 case 'fail-unexpected':
122 case 'fail': 128 case 'fail':
123 throw "This test always fails, to test the test scripts."; 129 throw "This test always fails, to test the test scripts.";
124 break; 130 break;
125 case 'timeout': 131 case 'timeout':
126 // Run for 10 seconds, then exit. This tests a 2 second timeout. 132 // Run for 10 seconds, then exit. This tests a 2 second timeout.
127 new Timer(new Duration(seconds: 10), (){ }); 133 new Timer(new Duration(seconds: 10), (){ });
128 break; 134 break;
129 default: 135 default:
130 throw "Unknown option ${arguments[0]} passed to test_runner_test"; 136 throw "Unknown option ${arguments[0]} passed to test_runner_test";
131 } 137 }
132 } 138 }
133 } 139 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698