Skip to content

Commit

Permalink
Merge branch 'wip-mdl-48761' of https://github.com/rajeshtaneja/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Jan 21, 2015
2 parents 59da38e + d58b0ad commit 81a9b9c
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions lib/tests/behat/behat_general.php
Expand Up @@ -1374,4 +1374,32 @@ public function a_new_page_should_not_have_loaded_since_i_started_watching() {
protected function get_page_load_xpath() {
return "//span[@data-rel = '" . self::PAGE_LOAD_DETECTION_STRING . "']";
}

/**
* Wait unit user press Enter/Return key. Useful when debugging a scenario.
*
* @Then /^(?:|I )pause(?:| scenario execution)$/
*/
public function i_pause_scenario_executon() {
global $CFG;

$posixexists = function_exists('posix_isatty');

// Make sure this step is only used with interactive terminal (if detected).
if ($posixexists && !@posix_isatty(STDOUT)) {
$session = $this->getSession();
throw new ExpectationException('Break point should only be used with interative terminal.', $session);
}

// Windows don't support ANSI code by default, but with ANSICON.
$isansicon = getenv('ANSICON');
if (($CFG->ostype === 'WINDOWS') && empty($isansicon)) {
fwrite(STDOUT, "Paused. Press Enter/Return to continue.");
fread(STDIN, 1024);
} else {
fwrite(STDOUT, "\033[s\n\033[0;93mPaused. Press \033[1;31mEnter/Return\033[0;93m to continue.\033[0m");
fread(STDIN, 1024);
fwrite(STDOUT, "\033[2A\033[u\033[2B");
}
}
}

0 comments on commit 81a9b9c

Please sign in to comment.