updated drupal core to 7.51
This commit is contained in:
@@ -67,6 +67,7 @@ for ($i = 0; $i < 24; $i++) {
|
||||
++$voc_id;
|
||||
$vocabulary['name'] = "vocabulary $voc_id (i=$i)";
|
||||
$vocabulary['description'] = "description of ". $vocabulary['name'];
|
||||
$vocabulary['help'] = "help for ". $vocabulary['name'];
|
||||
$vocabulary['nodes'] = $i > 11 ? array('page' => TRUE) : array();
|
||||
$vocabulary['multiple'] = $multiple[$i % 12];
|
||||
$vocabulary['required'] = $required[$i % 12];
|
||||
|
@@ -8,12 +8,16 @@ define('SIMPLETEST_SCRIPT_COLOR_PASS', 32); // Green.
|
||||
define('SIMPLETEST_SCRIPT_COLOR_FAIL', 31); // Red.
|
||||
define('SIMPLETEST_SCRIPT_COLOR_EXCEPTION', 33); // Brown.
|
||||
|
||||
define('SIMPLETEST_SCRIPT_EXIT_SUCCESS', 0);
|
||||
define('SIMPLETEST_SCRIPT_EXIT_FAILURE', 1);
|
||||
define('SIMPLETEST_SCRIPT_EXIT_EXCEPTION', 2);
|
||||
|
||||
// Set defaults and get overrides.
|
||||
list($args, $count) = simpletest_script_parse_args();
|
||||
|
||||
if ($args['help'] || $count == 0) {
|
||||
simpletest_script_help();
|
||||
exit;
|
||||
exit(($count == 0) ? SIMPLETEST_SCRIPT_EXIT_FAILURE : SIMPLETEST_SCRIPT_EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if ($args['execute-test']) {
|
||||
@@ -30,7 +34,7 @@ else {
|
||||
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
|
||||
if (!module_exists('simpletest')) {
|
||||
simpletest_script_print_error("The simpletest module must be enabled before this script can run.");
|
||||
exit;
|
||||
exit(SIMPLETEST_SCRIPT_EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if ($args['clean']) {
|
||||
@@ -43,7 +47,7 @@ if ($args['clean']) {
|
||||
foreach ($messages as $text) {
|
||||
echo " - " . $text . "\n";
|
||||
}
|
||||
exit;
|
||||
exit(SIMPLETEST_SCRIPT_EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
// Load SimpleTest files.
|
||||
@@ -64,7 +68,7 @@ if ($args['list']) {
|
||||
echo " - " . $info['name'] . ' (' . $class . ')' . "\n";
|
||||
}
|
||||
}
|
||||
exit;
|
||||
exit(SIMPLETEST_SCRIPT_EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
$test_list = simpletest_script_get_test_list();
|
||||
@@ -78,7 +82,7 @@ simpletest_script_reporter_init();
|
||||
$test_id = db_insert('simpletest_test_id')->useDefaults(array('test_id'))->execute();
|
||||
|
||||
// Execute tests.
|
||||
simpletest_script_execute_batch($test_id, simpletest_script_get_test_list());
|
||||
$status = simpletest_script_execute_batch($test_id, simpletest_script_get_test_list());
|
||||
|
||||
// Retrieve the last database prefix used for testing and the last test class
|
||||
// that was run from. Use the information to read the lgo file in case any
|
||||
@@ -100,7 +104,7 @@ if ($args['xml']) {
|
||||
simpletest_clean_results_table($test_id);
|
||||
|
||||
// Test complete, exit.
|
||||
exit;
|
||||
exit($status);
|
||||
|
||||
/**
|
||||
* Print help text.
|
||||
@@ -142,6 +146,8 @@ All arguments are long options.
|
||||
--file Run tests identified by specific file names, instead of group names.
|
||||
Specify the path and the extension (i.e. 'modules/user/user.test').
|
||||
|
||||
--directory Run all tests found within the specified file directory.
|
||||
|
||||
--xml <path>
|
||||
|
||||
If provided, test results will be written as xml files to this path.
|
||||
@@ -190,6 +196,7 @@ function simpletest_script_parse_args() {
|
||||
'all' => FALSE,
|
||||
'class' => FALSE,
|
||||
'file' => FALSE,
|
||||
'directory' => '',
|
||||
'color' => FALSE,
|
||||
'verbose' => FALSE,
|
||||
'test_names' => array(),
|
||||
@@ -222,7 +229,7 @@ function simpletest_script_parse_args() {
|
||||
else {
|
||||
// Argument not found in list.
|
||||
simpletest_script_print_error("Unknown argument '$arg'.");
|
||||
exit;
|
||||
exit(SIMPLETEST_SCRIPT_EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -235,7 +242,7 @@ function simpletest_script_parse_args() {
|
||||
// Validate the concurrency argument
|
||||
if (!is_numeric($args['concurrency']) || $args['concurrency'] <= 0) {
|
||||
simpletest_script_print_error("--concurrency must be a strictly positive integer.");
|
||||
exit;
|
||||
exit(SIMPLETEST_SCRIPT_EXIT_FAILURE);
|
||||
}
|
||||
|
||||
return array($args, $count);
|
||||
@@ -265,7 +272,7 @@ function simpletest_script_init($server_software) {
|
||||
else {
|
||||
simpletest_script_print_error('Unable to automatically determine the path to the PHP interpreter. Supply the --php command line argument.');
|
||||
simpletest_script_help();
|
||||
exit();
|
||||
exit(SIMPLETEST_SCRIPT_EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Get URL from arguments.
|
||||
@@ -310,6 +317,8 @@ function simpletest_script_init($server_software) {
|
||||
function simpletest_script_execute_batch($test_id, $test_classes) {
|
||||
global $args;
|
||||
|
||||
$total_status = SIMPLETEST_SCRIPT_EXIT_SUCCESS;
|
||||
|
||||
// Multi-process execution.
|
||||
$children = array();
|
||||
while (!empty($test_classes) || !empty($children)) {
|
||||
@@ -325,7 +334,7 @@ function simpletest_script_execute_batch($test_id, $test_classes) {
|
||||
|
||||
if (!is_resource($process)) {
|
||||
echo "Unable to fork test process. Aborting.\n";
|
||||
exit;
|
||||
exit(SIMPLETEST_SCRIPT_EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Register our new child.
|
||||
@@ -345,13 +354,22 @@ function simpletest_script_execute_batch($test_id, $test_classes) {
|
||||
if (empty($status['running'])) {
|
||||
// The child exited, unregister it.
|
||||
proc_close($child['process']);
|
||||
if ($status['exitcode']) {
|
||||
if ($status['exitcode'] == SIMPLETEST_SCRIPT_EXIT_FAILURE) {
|
||||
if ($status['exitcode'] > $total_status) {
|
||||
$total_status = $status['exitcode'];
|
||||
}
|
||||
}
|
||||
elseif ($status['exitcode']) {
|
||||
$total_status = $status['exitcode'];
|
||||
echo 'FATAL ' . $test_class . ': test runner returned a non-zero error code (' . $status['exitcode'] . ').' . "\n";
|
||||
}
|
||||
|
||||
// Remove this child.
|
||||
unset($children[$cid]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $total_status;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -374,11 +392,14 @@ function simpletest_script_run_one_test($test_id, $test_class) {
|
||||
simpletest_script_print($info['name'] . ' ' . _simpletest_format_summary_line($test->results) . "\n", simpletest_script_color_code($status));
|
||||
|
||||
// Finished, kill this runner.
|
||||
exit(0);
|
||||
if ($had_fails || $had_exceptions) {
|
||||
exit(SIMPLETEST_SCRIPT_EXIT_FAILURE);
|
||||
}
|
||||
exit(SIMPLETEST_SCRIPT_EXIT_SUCCESS);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
echo (string) $e;
|
||||
exit(1);
|
||||
exit(SIMPLETEST_SCRIPT_EXIT_EXCEPTION);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -432,7 +453,7 @@ function simpletest_script_get_test_list() {
|
||||
}
|
||||
simpletest_script_print_error('Test class not found: ' . $test_class);
|
||||
simpletest_script_print_alternatives($test_class, $all_classes, 6);
|
||||
exit(1);
|
||||
exit(SIMPLETEST_SCRIPT_EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -451,6 +472,51 @@ function simpletest_script_get_test_list() {
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($args['directory']) {
|
||||
// Extract test case class names from specified directory.
|
||||
// Find all tests in the PSR-X structure; Drupal\$extension\Tests\*.php
|
||||
// Since we do not want to hard-code too many structural file/directory
|
||||
// assumptions about PSR-0/4 files and directories, we check for the
|
||||
// minimal conditions only; i.e., a '*.php' file that has '/Tests/' in
|
||||
// its path.
|
||||
// Ignore anything from third party vendors, and ignore template files used in tests.
|
||||
// And any api.php files.
|
||||
$ignore = array('nomask' => '/vendor|\.tpl\.php|\.api\.php/');
|
||||
$files = array();
|
||||
if ($args['directory'][0] === '/') {
|
||||
$directory = $args['directory'];
|
||||
}
|
||||
else {
|
||||
$directory = DRUPAL_ROOT . "/" . $args['directory'];
|
||||
}
|
||||
$file_list = file_scan_directory($directory, '/\.php|\.test$/', $ignore);
|
||||
foreach ($file_list as $file) {
|
||||
// '/Tests/' can be contained anywhere in the file's path (there can be
|
||||
// sub-directories below /Tests), but must be contained literally.
|
||||
// Case-insensitive to match all Simpletest and PHPUnit tests:
|
||||
// ./lib/Drupal/foo/Tests/Bar/Baz.php
|
||||
// ./foo/src/Tests/Bar/Baz.php
|
||||
// ./foo/tests/Drupal/foo/Tests/FooTest.php
|
||||
// ./foo/tests/src/FooTest.php
|
||||
// $file->filename doesn't give us a directory, so we use $file->uri
|
||||
// Strip the drupal root directory and trailing slash off the URI
|
||||
$filename = substr($file->uri, strlen(DRUPAL_ROOT)+1);
|
||||
if (stripos($filename, '/Tests/')) {
|
||||
$files[drupal_realpath($filename)] = 1;
|
||||
} else if (stripos($filename, '.test')){
|
||||
$files[drupal_realpath($filename)] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for valid class names.
|
||||
foreach ($all_tests as $class_name) {
|
||||
$refclass = new ReflectionClass($class_name);
|
||||
$classfile = $refclass->getFileName();
|
||||
if (isset($files[$classfile])) {
|
||||
$test_list[] = $class_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Check for valid group names and get all valid classes in group.
|
||||
foreach ($args['test_names'] as $group_name) {
|
||||
@@ -460,7 +526,7 @@ function simpletest_script_get_test_list() {
|
||||
else {
|
||||
simpletest_script_print_error('Test group not found: ' . $group_name);
|
||||
simpletest_script_print_alternatives($group_name, array_keys($groups));
|
||||
exit(1);
|
||||
exit(SIMPLETEST_SCRIPT_EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -468,7 +534,7 @@ function simpletest_script_get_test_list() {
|
||||
|
||||
if (empty($test_list)) {
|
||||
simpletest_script_print_error('No valid tests were specified.');
|
||||
exit;
|
||||
exit(SIMPLETEST_SCRIPT_EXIT_FAILURE);
|
||||
}
|
||||
return $test_list;
|
||||
}
|
||||
|
Reference in New Issue
Block a user