MDL-37046 behat: CLI option to add/remove javascript tests

This commit is contained in:
David Monllao
2013-01-29 08:40:36 +08:00
parent cca2c80630
commit 25833ef86e
2 changed files with 17 additions and 6 deletions
+5 -2
View File
@@ -37,6 +37,7 @@ list($options, $unrecognized) = cli_get_params(
'filter' => false,
'tags' => false,
'extra' => false,
'with-javascript' => false,
'testenvironment' => false
),
array(
@@ -51,13 +52,15 @@ Ensure the user who executes the action has permissions over behat installation
Options:
--stepsdefinitions Displays the available steps definitions (accepts --filter=\"\" option to restrict the list to the matching definitions)
--runtests Runs the tests (accepts --tags=\"\" option to execute only the matching tests and --extra=\"\" to specify extra behat options)
--runtests Runs the tests (accepts --with-javascript option, --tags=\"\" option to execute only the matching tests and --extra=\"\" to specify extra behat options)
--testenvironment Allows the test environment to be accesses through the built-in server (accepts value 'enable' or 'disable')
-h, --help Print out this help
Example from Moodle root directory:
\$ php admin/tool/behat/cli/util.php --runtests --tags=\"tool_behat\"
More info in http://docs.moodle.org/dev/Acceptance_testing#Usage
";
if (!empty($options['help'])) {
@@ -90,7 +93,7 @@ switch ($action) {
break;
case 'runtests':
tool_behat::runtests($options['tags'], $options['extra']);
tool_behat::runtests($options['with-javascript'], $options['tags'], $options['extra']);
break;
case 'testenvironment':
+12 -4
View File
@@ -146,7 +146,7 @@ class tool_behat {
* @param string $tags Restricts the executed tests to the ones that matches the tags
* @param string $extra Extra CLI behat options
*/
public static function runtests($tags = false, $extra = false) {
public static function runtests($withjavascript = false, $tags = false, $extra = false) {
global $CFG;
// Checks that the behat reference is properly set up
@@ -159,14 +159,22 @@ class tool_behat {
@set_time_limit(0);
// Priority to the one specified as argument.
if (!$tags) {
$tags = optional_param('tags', false, PARAM_ALPHANUMEXT);
// No javascript by default
if (!$withjavascript && strstr($tags, 'javascript') == false) {
$jsstr = '~javascript';
}
// Adding javascript option to --tags.
$tagsoption = '';
if ($tags) {
if (!empty($jsstr)) {
$tags .= ',' . $jsstr;
}
$tagsoption = ' --tags ' . $tags;
// No javascript by default.
} else if (!empty($jsstr)) {
$tagsoption = ' --tags ' . $jsstr;
}
if (!$extra) {