OLD | NEW |
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 """Classes and methods for executing tasks for the test.py framework. | 5 """Classes and methods for executing tasks for the test.py framework. |
6 | 6 |
7 This module includes: | 7 This module includes: |
8 - Managing parallel execution of tests using threads | 8 - Managing parallel execution of tests using threads |
9 - Windows and Unix specific code for spawning tasks and retrieving results | 9 - Windows and Unix specific code for spawning tasks and retrieving results |
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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 """Implements communication with a set of subprocesses using threads.""" | 218 """Implements communication with a set of subprocesses using threads.""" |
219 | 219 |
220 def __init__(self, work_queue, tasks, progress, batch_cmd): | 220 def __init__(self, work_queue, tasks, progress, batch_cmd): |
221 super(BatchRunner, self).__init__(work_queue, tasks, progress) | 221 super(BatchRunner, self).__init__(work_queue, tasks, progress) |
222 self.runners = {} | 222 self.runners = {} |
223 self.last_activity = {} | 223 self.last_activity = {} |
224 self.context = progress.context | 224 self.context = progress.context |
225 | 225 |
226 # Scale the number of tasks to the nubmer of CPUs on the machine | 226 # Scale the number of tasks to the nubmer of CPUs on the machine |
227 # 1:1 is too much of an overload on many machines in batch mode, | 227 # 1:1 is too much of an overload on many machines in batch mode, |
228 # so scale the ratio of threads to CPUs back. | 228 # so scale the ratio of threads to CPUs back. On Windows running |
| 229 # more than one task is not safe. |
229 if tasks == testing.USE_DEFAULT_CPUS: | 230 if tasks == testing.USE_DEFAULT_CPUS: |
230 tasks = .75 * testing.HOST_CPUS | 231 if utils.IsWindows(): |
| 232 tasks = 1 |
| 233 else: |
| 234 tasks = .75 * testing.HOST_CPUS |
231 | 235 |
232 # Start threads | 236 # Start threads |
233 for i in xrange(tasks): | 237 for i in xrange(tasks): |
234 thread = threading.Thread(target=self.RunThread, args=[batch_cmd, i]) | 238 thread = threading.Thread(target=self.RunThread, args=[batch_cmd, i]) |
235 self.threads.append(thread) | 239 self.threads.append(thread) |
236 thread.daemon = True | 240 thread.daemon = True |
237 thread.start() | 241 thread.start() |
238 | 242 |
239 def RunThread(self, batch_cmd, thread_number): | 243 def RunThread(self, batch_cmd, thread_number): |
240 """A thread started to feed a single TestRunner.""" | 244 """A thread started to feed a single TestRunner.""" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 def Shutdown(self): | 418 def Shutdown(self): |
415 """Kill all active runners.""" | 419 """Kill all active runners.""" |
416 print 'Shutting down remaining runners.' | 420 print 'Shutting down remaining runners.' |
417 self.terminate = True | 421 self.terminate = True |
418 for runner in self.runners.values(): | 422 for runner in self.runners.values(): |
419 runner.kill() | 423 runner.kill() |
420 # Give threads a chance to exit gracefully | 424 # Give threads a chance to exit gracefully |
421 time.sleep(2) | 425 time.sleep(2) |
422 for runner in self.runners.values(): | 426 for runner in self.runners.values(): |
423 self.EndRunner(runner) | 427 self.EndRunner(runner) |
OLD | NEW |