Skip to content

Commit

Permalink
MDL-55379 phpunit: Preserve config option if passed
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajesh Taneja committed Sep 22, 2016
1 parent 64573a3 commit 544de35
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
4 changes: 2 additions & 2 deletions admin/tool/behat/cli/run.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@
exit(1);
}

// Execute all commands.
$processes = cli_execute_parallel($cmds, __DIR__);
// Execute all commands, relative to moodle root directory.
$processes = cli_execute_parallel($cmds, __DIR__ . "/../../../../");
$stoponfail = empty($options['stop-on-failure']) ? false : true;

// Print header.
Expand Down
5 changes: 4 additions & 1 deletion lib/behat/classes/behat_command.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ public final static function get_behat_command($custombyterm = false, $paralleru

// If relative path then prefix relative path.
if ($absolutepath) {
$pathprefix = testing_cli_argument_path('/') . $separator;
$pathprefix = testing_cli_argument_path('/');
if (!empty($pathprefix)) {
$pathprefix .= $separator;
}
} else {
$pathprefix = '';
}
Expand Down
4 changes: 4 additions & 0 deletions lib/phpunit/classes/hint_resultprinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ protected function printDefectTrace(PHPUnit_Framework_TestFailure $defect) {
}
if (in_array($_SERVER['argv'][$i], array('--colors', '--verbose', '-v', '--debug'))) {
$executable .= ' '.$_SERVER['argv'][$i];
} else if (in_array($_SERVER['argv'][$i], array('-c', '--config'))) {
$executable .= ' '.$_SERVER['argv'][$i] . ' ' . $_SERVER['argv'][++$i];
} else if (strpos($_SERVER['argv'][$i], '--config') === 0) {
$executable .= ' '.$_SERVER['argv'][$i];
}
}
}
Expand Down
15 changes: 8 additions & 7 deletions lib/testing/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,21 @@ function testing_cli_argument_path($moodlepath) {
$cwd = getcwd();
}

// In sub path, we want to remove leading Directory separator.
$removeseparator = 0;
if (substr($cwd, -1) !== DIRECTORY_SEPARATOR) {
$removeseparator = 1;
// Remove last directory separator as $path will not contain one.
if ((substr($cwd, -1) === '/') || (substr($cwd, -1) === '\\')) {
$cwd = substr($cwd, -1);
}

$path = realpath($CFG->dirroot.$moodlepath);

// We need standrad directory seperator for path and cwd, so it can be compared.
$cwd = testing_cli_fix_directory_separator($cwd);
$path = testing_cli_fix_directory_separator($path);

if (strpos($path, $cwd) === 0) {
$path = substr($path, strlen($cwd) + $removeseparator);
$path = substr($path, strlen($cwd));
}

$path = testing_cli_fix_directory_separator($path);

return $path;
}

Expand Down
2 changes: 1 addition & 1 deletion user/tests/search_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,4 @@ public function test_users_access() {
$this->assertEquals(\core_search\manager::ACCESS_GRANTED, $searcharea->check_access($user2->id));
$this->assertEquals(\core_search\manager::ACCESS_GRANTED, $searcharea->check_access($user3->id));
}
}
}

0 comments on commit 544de35

Please sign in to comment.