/** * Return parallel runs * * @return int number of parallel runs. */ public function get_number_of_parallel_run() { // Get number of parallel runs if not passed. if (empty($this->parallelruns) && $this->parallelruns !== false) { $this->parallelruns = behat_config_manager::get_parallel_test_runs(); } return $this->parallelruns; }
require_once __DIR__ . '/../../../../lib/behat/lib.php'; require_once __DIR__ . '/../../../../lib/behat/classes/behat_command.php'; require_once __DIR__ . '/../../../../lib/behat/classes/behat_config_manager.php'; // CLI options. list($options, $unrecognized) = cli_get_params(array('help' => false, 'install' => false, 'drop' => false, 'enable' => false, 'disable' => false, 'diag' => false, 'parallel' => 0, 'maxruns' => false, 'updatesteps' => false, 'fromrun' => 1, 'torun' => 0), array('h' => 'help', 'j' => 'parallel', 'm' => 'maxruns')); // Checking util.php CLI script usage. $help = "\nBehat utilities to manage the test environment\n\nOptions:\n--install Installs the test environment for acceptance tests\n--drop Drops the database tables and the dataroot contents\n--enable Enables test environment and updates tests list\n--disable Disables test environment\n--diag Get behat test environment status code\n-j, --parallel Number of parallel behat run operation\n-m, --maxruns Max parallel processes to be executed at one time.\n--updatesteps Update feature step file.\n\n-h, --help Print out this help\n\nExample from Moodle root directory:\n\$ php admin/tool/behat/cli/util.php --enable --parallel=4\n\nMore info in http://docs.moodle.org/dev/Acceptance_testing#Running_tests\n"; if (!empty($options['help'])) { echo $help; exit(0); } $cwd = getcwd(); // For drop option check if parallel site. if (empty($options['parallel']) && $options['drop']) { // Get parallel run info from first run. $options['parallel'] = behat_config_manager::get_parallel_test_runs($options['fromrun']); } // If not a parallel site then open single run. if (empty($options['parallel'])) { chdir(__DIR__); // Check if behat is initialised, if not exit. passthru("php util_single_run.php --diag", $status); if ($status) { exit($status); } $cmd = commands_to_execute($options); $processes = cli_execute_parallel(array($cmd), __DIR__); $status = print_sequential_output($processes, false); chdir($cwd); exit($status); }
if ($unrecognized) { $unrecognized = implode(PHP_EOL . " ", $unrecognized); cli_error(get_string('cliunknowoption', 'admin', $unrecognized)); } // Behat utilities. require_once $CFG->libdir . '/behat/classes/util.php'; require_once $CFG->libdir . '/behat/classes/behat_command.php'; require_once $CFG->libdir . '/behat/classes/behat_config_manager.php'; // Ensure run option is <= parallel run installed. $run = 0; $parallel = 0; if ($options['run']) { $run = $options['run']; // If parallel option is not passed, then try get it form config. if (!$options['parallel']) { $parallel = behat_config_manager::get_parallel_test_runs(); } else { $parallel = $options['parallel']; } if (empty($parallel) || $run > $parallel) { echo "Parallel runs can't be more then " . $parallel . PHP_EOL; exit(1); } $CFG->behatrunprocess = $run; } // Run command (only one per time). if ($options['install']) { behat_util::install_site(); // This is only displayed once for parallel install. if (empty($run)) { mtrace("Acceptance tests site installed");