From 6fe3986deca218afc375e814badc6bf4f7c48529 Mon Sep 17 00:00:00 2001 From: David Monllao Date: Tue, 5 Mar 2013 16:11:15 +0800 Subject: [PATCH] MDL-38007 behat: Refining error texts Also removing a couple of silly notices --- admin/tool/behat/lang/en/tool_behat.php | 5 ++++- lib/behat/classes/behat_command.php | 18 ++++++++++++++---- lib/behat/classes/util.php | 4 ++-- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/admin/tool/behat/lang/en/tool_behat.php b/admin/tool/behat/lang/en/tool_behat.php index 8bb1f1d9174c7..6c4f29650d0b1 100644 --- a/admin/tool/behat/lang/en/tool_behat.php +++ b/admin/tool/behat/lang/en/tool_behat.php @@ -38,4 +38,7 @@ $string['theninfo'] = 'Then. Checkings to ensure the outcomes are the expected ones'; $string['viewsteps'] = 'Filter'; $string['wheninfo'] = 'When. Actions that provokes an event'; -$string['wrongbehatsetup'] = 'Something is wrong with the setup, ensure you ran the composer installer and vendor/bin/behat file has execution permissions'; +$string['wrongbehatsetup'] = 'Something is wrong with behat setup, ensure:'; diff --git a/lib/behat/classes/behat_command.php b/lib/behat/classes/behat_command.php index d2b390b2380ec..e39999633d21b 100644 --- a/lib/behat/classes/behat_command.php +++ b/lib/behat/classes/behat_command.php @@ -140,17 +140,22 @@ public static function behat_setup_problem($checkphp = false) { behat_error(BEHAT_EXITCODE_REQUIREMENT, 'PHP 5.4 is required. See config-dist.php for possible alternatives'); } + $clibehaterrorstr = "Behat dependencies not installed. Ensure you ran the composer installer. " . self::DOCS_URL . "#Installation\n"; + // Moodle setting. if (!self::are_behat_dependencies_installed()) { - $msg = get_string('wrongbehatsetup', 'tool_behat'); // With HTML. - $docslink = self::DOCS_URL . '#Installation'; if (!CLI_SCRIPT) { + + $msg = get_string('wrongbehatsetup', 'tool_behat'); + $docslink = self::DOCS_URL . '#Installation'; $docslink = html_writer::tag('a', $docslink, array('href' => $docslink, 'target' => '_blank')); + $msg .= get_string('moreinfoin', 'tool_behat', $docslink); + } else { + $msg = $clibehaterrorstr; } - $msg .= '. ' . get_string('moreinfoin', 'tool_behat', $docslink); self::output_msg($msg); return BEHAT_EXITCODE_COMPOSER; @@ -161,7 +166,12 @@ public static function behat_setup_problem($checkphp = false) { if ($code != 0) { // Returning composer error code to avoid conflicts with behat and moodle error codes. - self::output_msg(get_string('wrongbehatsetup', 'tool_behat')); + if (!CLI_SCRIPT) { + $msg = get_string('wrongbehatsetup', 'tool_behat'); + } else { + $msg = $clibehaterrorstr; + } + self::output_msg($msg); return BEHAT_EXITCODE_COMPOSER; } diff --git a/lib/behat/classes/util.php b/lib/behat/classes/util.php index 33495c2bb4426..47886852e65cb 100644 --- a/lib/behat/classes/util.php +++ b/lib/behat/classes/util.php @@ -177,7 +177,7 @@ public static function start_test_mode() { // Checks the behat set up and the PHP version. if ($errorcode = behat_command::behat_setup_problem(true)) { - exit($code); + exit($errorcode); } // Check that test environment is correctly set up. @@ -211,7 +211,7 @@ public static function get_behat_status() { // Checks the behat set up and the PHP version, returning an error code if something went wrong. if ($errorcode = behat_command::behat_setup_problem(true)) { - return $code; + return $errorcode; } // Check that test environment is correctly set up, stops execution.