summaryrefslogtreecommitdiff
path: root/scripts/run-tests.sh
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2008-07-24 06:46:28 +0000
committerDries Buytaert <dries@buytaert.net>2008-07-24 06:46:28 +0000
commit43a70352e69bf1cf43766bd16c28482d983c8e06 (patch)
tree128ef0ed937a74bd66adad75252be0aaa799e610 /scripts/run-tests.sh
parent8b51a9dfb1f3dae6349216d86375bce9cf5edb74 (diff)
downloadbrdo-43a70352e69bf1cf43766bd16c28482d983c8e06.tar.gz
brdo-43a70352e69bf1cf43766bd16c28482d983c8e06.tar.bz2
- Patch #254166 by Damien Tournoud: improved error handling of concurrency mode.
Diffstat (limited to 'scripts/run-tests.sh')
-rwxr-xr-xscripts/run-tests.sh20
1 files changed, 16 insertions, 4 deletions
diff --git a/scripts/run-tests.sh b/scripts/run-tests.sh
index 22615c1a9..8f2c7238a 100755
--- a/scripts/run-tests.sh
+++ b/scripts/run-tests.sh
@@ -115,7 +115,8 @@ All arguments are long options.
--concurrency [num]
Run tests in parallel, up to [num] tests at a time.
- This is not supported under Windows.
+ This requires the Process Control Extension (PCNTL) to be compiled in PHP,
+ not supported under Windows.
--all Run all available tests.
@@ -198,6 +199,17 @@ function simpletest_script_parse_args() {
$args['test_names'] += explode(',', $arg);
}
}
+
+ // Validate the concurrency argument
+ if (!is_numeric($args['concurrency']) || $args['concurrency'] <= 0) {
+ simpletest_script_print_error("--concurrency must be a strictly positive integer.");
+ exit;
+ }
+ else if ($args['concurrency'] > 1 && !function_exists('pcntl_fork')) {
+ simpletest_script_print_error("Parallel test execution requires the Process Control extension to be compiled in PHP. Please see http://php.net/manual/en/intro.pcntl.php for more information.");
+ exit;
+ }
+
return array($args, $count);
}
@@ -242,7 +254,7 @@ function simpletest_script_execute_batch() {
simpletest_script_print_error("--execute-batch should not be called interactively.");
exit;
}
- if ($args['concurrency'] == 1 || !function_exists('pcntl_fork')) {
+ if ($args['concurrency'] == 1) {
// Fallback to mono-threaded execution.
if (count($args['test_names']) > 1) {
foreach ($args['test_names'] as $test_class) {
@@ -264,7 +276,7 @@ function simpletest_script_execute_batch() {
$children = array();
while (!empty($args['test_names']) || !empty($children)) {
// Fork children safely since Drupal is not bootstrapped yet.
- while (count($children) < $concurrency) {
+ while (count($children) < $args['concurrency']) {
if (empty($args['test_names'])) break;
$child = array();
@@ -273,7 +285,7 @@ function simpletest_script_execute_batch() {
if (!$child['pid']) {
// This is the child process, bootstrap and execute the test.
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
- simpletest_script_run_one_test($test_id, $test_class);
+ simpletest_script_run_one_test($args['test-id'], $test_class);
exit;
}
else {