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

Side by Side Diff: tools/testing/dart/test_runner.dart

Issue 10351011: Change Platform members to getters instead of methods. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Adding new test binaries Created 8 years, 7 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
« no previous file with comments | « tools/testing/dart/test_options.dart ('k') | tools/testing/dart/test_suite.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) 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.
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 return new TestOutputImpl(testCase, exitCode, timedOut, 252 return new TestOutputImpl(testCase, exitCode, timedOut,
253 stdout, stderr, time); 253 stdout, stderr, time);
254 } 254 }
255 255
256 String get result() => 256 String get result() =>
257 hasCrashed ? CRASH : (hasTimedOut ? TIMEOUT : (hasFailed ? FAIL : PASS)); 257 hasCrashed ? CRASH : (hasTimedOut ? TIMEOUT : (hasFailed ? FAIL : PASS));
258 258
259 bool get unexpectedOutput() => !testCase.expectedOutcomes.contains(result); 259 bool get unexpectedOutput() => !testCase.expectedOutcomes.contains(result);
260 260
261 bool get hasCrashed() { 261 bool get hasCrashed() {
262 if (Platform.operatingSystem() == 'windows') { 262 if (Platform.operatingSystem == 'windows') {
263 // The VM uses std::abort to terminate on asserts. 263 // The VM uses std::abort to terminate on asserts.
264 // std::abort terminates with exit code 3 on Windows. 264 // std::abort terminates with exit code 3 on Windows.
265 if (exitCode == 3) { 265 if (exitCode == 3) {
266 return !timedOut; 266 return !timedOut;
267 } 267 }
268 return (!timedOut && (exitCode < 0) && ((0x3FFFFF00 & exitCode) == 0)); 268 return (!timedOut && (exitCode < 0) && ((0x3FFFFF00 & exitCode) == 0));
269 } 269 }
270 // The Java dartc runner exits with code 253 in case of unhandled 270 // The Java dartc runner exits with code 253 in case of unhandled
271 // exceptions. 271 // exceptions.
272 return (!timedOut && ((exitCode < 0) || (exitCode == 253))); 272 return (!timedOut && ((exitCode < 0) || (exitCode == 253)));
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 void start() { 591 void start() {
592 Expect.isFalse(testCase.expectedOutcomes.contains(SKIP)); 592 Expect.isFalse(testCase.expectedOutcomes.contains(SKIP));
593 stdout = new List<String>(); 593 stdout = new List<String>();
594 stderr = new List<String>(); 594 stderr = new List<String>();
595 currentStep = 0; 595 currentStep = 0;
596 runCommand(testCase.commands[currentStep++], stepExitHandler); 596 runCommand(testCase.commands[currentStep++], stepExitHandler);
597 } 597 }
598 598
599 void runCommand(Command command, 599 void runCommand(Command command,
600 void exitHandler(int exitCode)) { 600 void exitHandler(int exitCode)) {
601 if (Platform.operatingSystem() == 'windows') { 601 if (Platform.operatingSystem == 'windows') {
602 // Windows can't handle the first command if it is a .bat file or the like 602 // Windows can't handle the first command if it is a .bat file or the like
603 // with the slashes going the other direction. 603 // with the slashes going the other direction.
604 // TODO(efortuna): Remove this when fixed (Issue 1306). 604 // TODO(efortuna): Remove this when fixed (Issue 1306).
605 command.executable = command.executable.replaceAll('/', '\\'); 605 command.executable = command.executable.replaceAll('/', '\\');
606 } 606 }
607 process = new Process.start(command.executable, command.arguments); 607 process = new Process.start(command.executable, command.arguments);
608 process.onExit = exitHandler; 608 process.onExit = exitHandler;
609 process.onError = (e) { 609 process.onError = (e) {
610 print("Error starting process:"); 610 print("Error starting process:");
611 print(" Command: $command"); 611 print(" Command: $command");
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 } 912 }
913 913
914 void _testListerDone() { 914 void _testListerDone() {
915 _activeTestListers--; 915 _activeTestListers--;
916 _checkDone(); 916 _checkDone();
917 } 917 }
918 918
919 String globalTemporaryDirectory() { 919 String globalTemporaryDirectory() {
920 if (_temporaryDirectory != null) return _temporaryDirectory; 920 if (_temporaryDirectory != null) return _temporaryDirectory;
921 921
922 if (Platform.operatingSystem() == 'windows') { 922 if (Platform.operatingSystem == 'windows') {
923 throw new Exception( 923 throw new Exception(
924 'Test suite requires temporary directory. Not supported on Windows.'); 924 'Test suite requires temporary directory. Not supported on Windows.');
925 } 925 }
926 var tempDir = new Directory(''); 926 var tempDir = new Directory('');
927 tempDir.createTempSync(); 927 tempDir.createTempSync();
928 _temporaryDirectory = tempDir.path; 928 _temporaryDirectory = tempDir.path;
929 return _temporaryDirectory; 929 return _temporaryDirectory;
930 } 930 }
931 931
932 /** 932 /**
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 }; 965 };
966 } 966 }
967 } 967 }
968 } 968 }
969 } 969 }
970 970
971 /** 971 /**
972 * True if we are using a browser + platform combination that needs the 972 * True if we are using a browser + platform combination that needs the
973 * Selenium server jar. 973 * Selenium server jar.
974 */ 974 */
975 bool get _needsSelenium() => Platform.operatingSystem() == 'macos' && 975 bool get _needsSelenium() => Platform.operatingSystem == 'macos' &&
976 browserUsed == 'safari'; 976 browserUsed == 'safari';
977 977
978 /** True if the Selenium Server is ready to be used. */ 978 /** True if the Selenium Server is ready to be used. */
979 bool get _isSeleniumAvailable() => _seleniumServer != null || 979 bool get _isSeleniumAvailable() => _seleniumServer != null ||
980 _seleniumAlreadyRunning; 980 _seleniumAlreadyRunning;
981 981
982 /** 982 /**
983 * Restart all the processes that have been waiting/stopped for the server to 983 * Restart all the processes that have been waiting/stopped for the server to
984 * start up. If we just call this once we end up with a single-"threaded" run. 984 * start up. If we just call this once we end up with a single-"threaded" run.
985 */ 985 */
986 void resumeTesting() { 986 void resumeTesting() {
987 for (int i = 0; i < _maxProcesses; i++) _tryRunTest(); 987 for (int i = 0; i < _maxProcesses; i++) _tryRunTest();
988 } 988 }
989 989
990 /** Start the Selenium Server jar, if appropriate for this platform. */ 990 /** Start the Selenium Server jar, if appropriate for this platform. */
991 void _ensureSeleniumServerRunning() { 991 void _ensureSeleniumServerRunning() {
992 if (!_isSeleniumAvailable && !_startingServer) { 992 if (!_isSeleniumAvailable && !_startingServer) {
993 _startingServer = true; 993 _startingServer = true;
994 994
995 // Check to see if the jar was already running before the program started. 995 // Check to see if the jar was already running before the program started.
996 String cmd = 'ps'; 996 String cmd = 'ps';
997 var arg = ['aux']; 997 var arg = ['aux'];
998 if (Platform.operatingSystem() == 'windows') { 998 if (Platform.operatingSystem == 'windows') {
999 cmd = 'tasklist'; 999 cmd = 'tasklist';
1000 arg.add('/v'); 1000 arg.add('/v');
1001 } 1001 }
1002 Process p = new Process.start(cmd, arg); 1002 Process p = new Process.start(cmd, arg);
1003 final StringInputStream stdoutStringStream = 1003 final StringInputStream stdoutStringStream =
1004 new StringInputStream(p.stdout); 1004 new StringInputStream(p.stdout);
1005 p.onError = (e) { 1005 p.onError = (e) {
1006 print("Error starting process:"); 1006 print("Error starting process:");
1007 print(" Command: $cmd ${Strings.join(arg, ' ')}"); 1007 print(" Command: $cmd ${Strings.join(arg, ' ')}");
1008 print(" Error: $e"); 1008 print(" Error: $e");
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 }; 1053 };
1054 } 1054 }
1055 1055
1056 /** 1056 /**
1057 * For browser tests using Safari or Opera, we need to use the Selenium 1.0 1057 * For browser tests using Safari or Opera, we need to use the Selenium 1.0
1058 * Java server. 1058 * Java server.
1059 */ 1059 */
1060 void _startSeleniumServer() { 1060 void _startSeleniumServer() {
1061 // Get the absolute path to the Selenium jar. 1061 // Get the absolute path to the Selenium jar.
1062 String filePath = new Options().script; 1062 String filePath = new Options().script;
1063 String pathSep = Platform.pathSeparator(); 1063 String pathSep = Platform.pathSeparator;
1064 int index = filePath.lastIndexOf(pathSep); 1064 int index = filePath.lastIndexOf(pathSep);
1065 filePath = filePath.substring(0, index) + '${pathSep}testing${pathSep}'; 1065 filePath = filePath.substring(0, index) + '${pathSep}testing${pathSep}';
1066 var dir = new Directory(filePath); 1066 var dir = new Directory(filePath);
1067 dir.onFile = (String file) { 1067 dir.onFile = (String file) {
1068 if (const RegExp(@"selenium-server-standalone-.*\.jar").hasMatch(file) 1068 if (const RegExp(@"selenium-server-standalone-.*\.jar").hasMatch(file)
1069 && _seleniumServer == null) { 1069 && _seleniumServer == null) {
1070 _seleniumServer = new Process.start('java', ['-jar', file]); 1070 _seleniumServer = new Process.start('java', ['-jar', file]);
1071 _seleniumServer.onError = (e) { 1071 _seleniumServer.onError = (e) {
1072 print("Error starting process:"); 1072 print("Error starting process:");
1073 print(" Command: java -jar $file"); 1073 print(" Command: java -jar $file");
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 // the developer doesn't waste his or her time trying to fix a bunch of 1162 // the developer doesn't waste his or her time trying to fix a bunch of
1163 // tests that appear to be broken but were actually just flakes that 1163 // tests that appear to be broken but were actually just flakes that
1164 // didn't get retried because there had already been one failure. 1164 // didn't get retried because there had already been one failure.
1165 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests; 1165 bool allowRetry = _MAX_FAILED_NO_RETRY > _progress.numFailedTests;
1166 new RunningProcess(test, allowRetry, this).start(); 1166 new RunningProcess(test, allowRetry, this).start();
1167 } 1167 }
1168 _numProcesses++; 1168 _numProcesses++;
1169 } 1169 }
1170 } 1170 }
1171 } 1171 }
OLDNEW
« no previous file with comments | « tools/testing/dart/test_options.dart ('k') | tools/testing/dart/test_suite.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698