OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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 /** | 5 /** |
6 * Classes and methods for executing tests. | 6 * Classes and methods for executing tests. |
7 * | 7 * |
8 * This module includes: | 8 * This module includes: |
9 * - Managing parallel execution of tests, including timeout checks. | 9 * - Managing parallel execution of tests, including timeout checks. |
10 * - Evaluating the output of each test as pass/fail/crash/timeout. | 10 * - Evaluating the output of each test as pass/fail/crash/timeout. |
11 */ | 11 */ |
12 library test_runner; | 12 library test_runner; |
13 | 13 |
14 import "dart:async"; | 14 import "dart:async"; |
15 // We need to use the 'io' prefix here, otherwise io.exitCode will shadow | 15 // We need to use the 'io' prefix here, otherwise io.exitCode will shadow |
16 // CommandOutput.exitCode in subclasses of CommandOutput. | 16 // CommandOutput.exitCode in subclasses of CommandOutput. |
17 import "dart:io" as io; | 17 import "dart:io" as io; |
18 import "dart:isolate"; | 18 import "dart:isolate"; |
19 import "dart:uri"; | 19 import "dart:uri"; |
20 import "status_file_parser.dart"; | 20 import "status_file_parser.dart"; |
21 import "test_progress.dart"; | 21 import "test_progress.dart"; |
22 import "test_suite.dart"; | 22 import "test_suite.dart"; |
| 23 import "http_server.dart" as http_server; |
23 | 24 |
24 const int NO_TIMEOUT = 0; | 25 const int NO_TIMEOUT = 0; |
25 const int SLOW_TIMEOUT_MULTIPLIER = 4; | 26 const int SLOW_TIMEOUT_MULTIPLIER = 4; |
26 | 27 |
27 typedef void TestCaseEvent(TestCase testCase); | 28 typedef void TestCaseEvent(TestCase testCase); |
28 typedef void ExitCodeEvent(int exitCode); | 29 typedef void ExitCodeEvent(int exitCode); |
29 typedef void EnqueueMoreWork(ProcessQueue queue); | 30 typedef void EnqueueMoreWork(ProcessQueue queue); |
30 | 31 |
31 | 32 |
32 /** | 33 /** |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 * with the content of [expectedOutputPath]. | 173 * with the content of [expectedOutputPath]. |
173 * This is used for example for pixel tests, where [expectedOutputPath] points | 174 * This is used for example for pixel tests, where [expectedOutputPath] points |
174 * to a *png file. | 175 * to a *png file. |
175 */ | 176 */ |
176 io.Path expectedOutputPath; | 177 io.Path expectedOutputPath; |
177 | 178 |
178 DumpRenderTreeCommand(String executable, | 179 DumpRenderTreeCommand(String executable, |
179 String htmlFile, | 180 String htmlFile, |
180 List<String> options, | 181 List<String> options, |
181 List<String> dartFlags, | 182 List<String> dartFlags, |
182 Uri packageRootUri, | |
183 io.Path this.expectedOutputPath) | 183 io.Path this.expectedOutputPath) |
184 : super(executable, | 184 : super(executable, |
185 _getArguments(options, htmlFile), | 185 _getArguments(options, htmlFile), |
186 _getEnvironment(dartFlags, packageRootUri)); | 186 _getEnvironment(dartFlags)); |
187 | 187 |
188 static Map _getEnvironment(List<String> dartFlags, Uri packageRootUri) { | 188 static Map _getEnvironment(List<String> dartFlags) { |
189 var needDartFlags = dartFlags != null && dartFlags.length > 0; | 189 var needDartFlags = dartFlags != null && dartFlags.length > 0; |
190 var needDartPackageRoot = packageRootUri != null; | |
191 | 190 |
192 var env = null; | 191 var env = null; |
193 if (needDartFlags || needDartPackageRoot) { | 192 if (needDartFlags) { |
194 env = new Map.from(io.Platform.environment); | 193 env = new Map.from(io.Platform.environment); |
195 if (needDartFlags) { | 194 if (needDartFlags) { |
196 env['DART_FLAGS'] = Strings.join(dartFlags, " "); | 195 env['DART_FLAGS'] = Strings.join(dartFlags, " "); |
197 } | 196 } |
198 if (needDartPackageRoot) { | |
199 env['DART_PACKAGE_ROOT'] = packageRootUri.toString(); | |
200 } | |
201 } | 197 } |
202 | 198 |
203 return env; | 199 return env; |
204 } | 200 } |
205 | 201 |
206 static List<String> _getArguments(List<String> options, String htmlFile) { | 202 static List<String> _getArguments(List<String> options, String htmlFile) { |
207 var arguments = new List.from(options); | 203 var arguments = new List.from(options); |
208 arguments.add(htmlFile); | 204 arguments.add(htmlFile); |
209 return arguments; | 205 return arguments; |
210 } | 206 } |
(...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1704 if (test.usesWebDriver && _needsSelenium && !_isSeleniumAvailable || (test | 1700 if (test.usesWebDriver && _needsSelenium && !_isSeleniumAvailable || (test |
1705 is BrowserTestCase && test.waitingForOtherTest)) { | 1701 is BrowserTestCase && test.waitingForOtherTest)) { |
1706 // The test is not yet ready to run. Put the test back in | 1702 // The test is not yet ready to run. Put the test back in |
1707 // the queue. Avoid spin-polling by using a timeout. | 1703 // the queue. Avoid spin-polling by using a timeout. |
1708 _tests.add(test); | 1704 _tests.add(test); |
1709 new Timer(100, (timer) {_tryRunTest();}); // Don't lose a process. | 1705 new Timer(100, (timer) {_tryRunTest();}); // Don't lose a process. |
1710 return; | 1706 return; |
1711 } | 1707 } |
1712 if (_verbose) { | 1708 if (_verbose) { |
1713 int i = 1; | 1709 int i = 1; |
| 1710 if (test is BrowserTestCase) { |
| 1711 // Additional command for rerunning the steps locally after the fact. |
| 1712 print('$i. ${TestUtils.dartTestExecutable.toNativePath()} ' |
| 1713 '${TestUtils.dartDir().toNativePath()}/tools/testing/dart/' |
| 1714 'http_server.dart -m ${test.configuration["mode"]} ' |
| 1715 '-a ${test.configuration["arch"]} ' |
| 1716 '-p ${http_server.TestingServerRunner.serverList[0].port} ' |
| 1717 '-c ${http_server.TestingServerRunner.serverList[1].port}'); |
| 1718 i++; |
| 1719 } |
1714 for (Command command in test.commands) { | 1720 for (Command command in test.commands) { |
1715 print('$i. ${command.commandLine}'); | 1721 print('$i. ${command.commandLine}'); |
1716 i++; | 1722 i++; |
1717 } | 1723 } |
1718 } | 1724 } |
1719 _progress.start(test); | 1725 _progress.start(test); |
1720 TestCaseEvent oldCallback = test.completedHandler; | 1726 TestCaseEvent oldCallback = test.completedHandler; |
1721 void wrapper(TestCase test_arg) { | 1727 void wrapper(TestCase test_arg) { |
1722 _numProcesses--; | 1728 _numProcesses--; |
1723 _progress.done(test_arg); | 1729 _progress.done(test_arg); |
(...skipping 18 matching lines...) Expand all Loading... |
1742 // the developer doesn't waste his or her time trying to fix a bunch of | 1748 // the developer doesn't waste his or her time trying to fix a bunch of |
1743 // tests that appear to be broken but were actually just flakes that | 1749 // tests that appear to be broken but were actually just flakes that |
1744 // didn't get retried because there had already been one failure. | 1750 // didn't get retried because there had already been one failure. |
1745 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests; | 1751 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests; |
1746 new RunningProcess(test, allowRetry, this).start(); | 1752 new RunningProcess(test, allowRetry, this).start(); |
1747 } | 1753 } |
1748 _numProcesses++; | 1754 _numProcesses++; |
1749 } | 1755 } |
1750 } | 1756 } |
1751 } | 1757 } |
OLD | NEW |