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

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

Issue 123213003: Extended ProcessCommand/RunningProcess with Command specific working directory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 11 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 | « no previous file | no next file » | 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 class ProcessCommand extends Command { 98 class ProcessCommand extends Command {
99 /** Path to the executable of this command. */ 99 /** Path to the executable of this command. */
100 String executable; 100 String executable;
101 101
102 /** Command line arguments to the executable. */ 102 /** Command line arguments to the executable. */
103 List<String> arguments; 103 List<String> arguments;
104 104
105 /** Environment for the command */ 105 /** Environment for the command */
106 Map<String, String> environmentOverrides; 106 Map<String, String> environmentOverrides;
107 107
108 /** Working directory for the command */
109 final String workingDirectory;
110
108 ProcessCommand._(String displayName, this.executable, 111 ProcessCommand._(String displayName, this.executable,
109 this.arguments, 112 this.arguments,
110 [this.environmentOverrides = null]) 113 [this.environmentOverrides = null,
114 this.workingDirectory = null])
111 : super._(displayName) { 115 : super._(displayName) {
112 if (io.Platform.operatingSystem == 'windows') { 116 if (io.Platform.operatingSystem == 'windows') {
113 // Windows can't handle the first command if it is a .bat file or the like 117 // Windows can't handle the first command if it is a .bat file or the like
114 // with the slashes going the other direction. 118 // with the slashes going the other direction.
115 // NOTE: Issue 1306 119 // NOTE: Issue 1306
116 executable = executable.replaceAll('/', '\\'); 120 executable = executable.replaceAll('/', '\\');
117 } 121 }
118 } 122 }
119 123
120 void _buildHashCode(HashCodeBuilder builder) { 124 void _buildHashCode(HashCodeBuilder builder) {
121 super._buildHashCode(builder); 125 super._buildHashCode(builder);
122 builder.add(executable); 126 builder.add(executable);
127 builder.add(workingDirectory);
123 for (var object in arguments) builder.add(object); 128 for (var object in arguments) builder.add(object);
124 if (environmentOverrides != null) { 129 if (environmentOverrides != null) {
125 for (var key in environmentOverrides.keys) { 130 for (var key in environmentOverrides.keys) {
126 builder.add(key); 131 builder.add(key);
127 builder.add(environmentOverrides[key]); 132 builder.add(environmentOverrides[key]);
128 } 133 }
129 } 134 }
130 } 135 }
131 136
132 bool _equal(Command other) { 137 bool _equal(Command other) {
133 if (!super._equal(other)) return false; 138 if (other is ProcessCommand) {
134 if (other is ProcessCommand) { 139 if (!super._equal(other)) return false;
135 140
136 if (hashCode != other.hashCode || 141 if (hashCode != other.hashCode ||
137 executable != other.executable || 142 executable != other.executable ||
138 arguments.length != other.arguments.length) { 143 arguments.length != other.arguments.length) {
139 return false; 144 return false;
140 } 145 }
141 146
142 if (!deepJsonCompare(arguments, other.arguments)) return false; 147 if (!deepJsonCompare(arguments, other.arguments)) return false;
148 if (workingDirectory != other.workingDirectory) return false;
143 if (!deepJsonCompare(environmentOverrides, other.environmentOverrides)) { 149 if (!deepJsonCompare(environmentOverrides, other.environmentOverrides)) {
144 return false; 150 return false;
145 } 151 }
146 152
147 return true; 153 return true;
148 } 154 }
149 return false; 155 return false;
150 } 156 }
151 157
152 String get reproductionCommand { 158 String get reproductionCommand {
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 } 417 }
412 418
413 Command getJSCommandlineCommand(String displayName, executable, arguments, 419 Command getJSCommandlineCommand(String displayName, executable, arguments,
414 [environment = null]) { 420 [environment = null]) {
415 var command = new JSCommandlineCommand._(displayName, executable, arguments, 421 var command = new JSCommandlineCommand._(displayName, executable, arguments,
416 environment); 422 environment);
417 return _getUniqueCommand(command); 423 return _getUniqueCommand(command);
418 } 424 }
419 425
420 Command getProcessCommand(String displayName, executable, arguments, 426 Command getProcessCommand(String displayName, executable, arguments,
421 [environment = null]) { 427 [environment = null, workingDirectory = null]) {
422 var command = new ProcessCommand._(displayName, executable, arguments, 428 var command = new ProcessCommand._(displayName, executable, arguments,
423 environment); 429 environment, workingDirectory);
424 return _getUniqueCommand(command); 430 return _getUniqueCommand(command);
425 } 431 }
426 432
427 Command _getUniqueCommand(Command command) { 433 Command _getUniqueCommand(Command command) {
428 // All Command classes have hashCode/operator==, so we check if this command 434 // All Command classes have hashCode/operator==, so we check if this command
429 // has already been build, if so we return the cached one, otherwise we 435 // has already been build, if so we return the cached one, otherwise we
430 // store the one given as [command] argument. 436 // store the one given as [command] argument.
431 var cachedCommand = _cachedCommands[command]; 437 var cachedCommand = _cachedCommands[command];
432 if (cachedCommand != null) { 438 if (cachedCommand != null) {
433 return cachedCommand; 439 return cachedCommand;
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after
1392 void _runCommand() { 1398 void _runCommand() {
1393 command.outputIsUpToDate.then((bool isUpToDate) { 1399 command.outputIsUpToDate.then((bool isUpToDate) {
1394 if (isUpToDate) { 1400 if (isUpToDate) {
1395 compilationSkipped = true; 1401 compilationSkipped = true;
1396 _commandComplete(0); 1402 _commandComplete(0);
1397 } else { 1403 } else {
1398 var processEnvironment = _createProcessEnvironment(); 1404 var processEnvironment = _createProcessEnvironment();
1399 Future processFuture = 1405 Future processFuture =
1400 io.Process.start(command.executable, 1406 io.Process.start(command.executable,
1401 command.arguments, 1407 command.arguments,
1402 environment: processEnvironment); 1408 environment: processEnvironment,
1409 workingDirectory: command.workingDirectory);
1403 processFuture.then((io.Process process) { 1410 processFuture.then((io.Process process) {
1404 // Close stdin so that tests that try to block on input will fail. 1411 // Close stdin so that tests that try to block on input will fail.
1405 process.stdin.close(); 1412 process.stdin.close();
1406 void timeoutHandler() { 1413 void timeoutHandler() {
1407 timedOut = true; 1414 timedOut = true;
1408 if (process != null) { 1415 if (process != null) {
1409 process.kill(); 1416 process.kill();
1410 } 1417 }
1411 } 1418 }
1412 Future.wait([process.exitCode, 1419 Future.wait([process.exitCode,
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after
2469 } 2476 }
2470 } 2477 }
2471 2478
2472 void eventAllTestsDone() { 2479 void eventAllTestsDone() {
2473 for (var listener in _eventListener) { 2480 for (var listener in _eventListener) {
2474 listener.allDone(); 2481 listener.allDone();
2475 } 2482 }
2476 _allDone(); 2483 _allDone();
2477 } 2484 }
2478 } 2485 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698