mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-32400 rework phpunit exit codes, use only php based init
This commit is contained in:
parent
589376d385
commit
0d8e51a65f
9 changed files with 57 additions and 115 deletions
|
@ -1,22 +0,0 @@
|
|||
@ECHO OFF
|
||||
ECHO Initialising Moodle PHPUnit test environment...
|
||||
|
||||
CALL php %~dp0\util.php --diag > NUL 2>&1
|
||||
|
||||
IF ERRORLEVEL 133 GOTO drop
|
||||
IF ERRORLEVEL 132 GOTO install
|
||||
IF ERRORLEVEL 1 GOTO unknown
|
||||
GOTO done
|
||||
|
||||
:drop
|
||||
CALL php %~dp0\util.php --drop
|
||||
IF ERRORLEVEL 1 GOTO done
|
||||
|
||||
:install
|
||||
CALL php %~dp0\util.php --install
|
||||
GOTO done
|
||||
|
||||
:unknown
|
||||
CALL php %~dp0\util.php --diag
|
||||
|
||||
:done
|
|
@ -43,13 +43,13 @@ exec("php util.php --diag", $output, $code);
|
|||
if ($code == 0) {
|
||||
// everything is ready
|
||||
|
||||
} else if ($code == 132) {
|
||||
} else if ($code == PHPUNIT_EXITCODE_INSTALL) {
|
||||
passthru("php util.php --install", $code);
|
||||
if ($code != 0) {
|
||||
exit($code);
|
||||
}
|
||||
|
||||
} else if ($code == 133) {
|
||||
} else if ($code == PHPUNIT_EXITCODE_REINSTALL) {
|
||||
passthru("php util.php --drop", $code);
|
||||
passthru("php util.php --install", $code);
|
||||
if ($code != 0) {
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
|
||||
CLIDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
|
||||
UTIL="$CLIDIR/util.php"
|
||||
|
||||
echo "Initialising Moodle PHPUnit test environment..."
|
||||
|
||||
DIGERROR=`php $UTIL --diag`
|
||||
DIAG=$?
|
||||
if [ $DIAG -eq 132 ] ; then
|
||||
php $UTIL --install
|
||||
else
|
||||
if [ $DIAG -eq 133 ] ; then
|
||||
php $UTIL --drop
|
||||
RESULT=$?
|
||||
if [ $RESULT -gt 0 ] ; then
|
||||
exit $RESULT
|
||||
fi
|
||||
php $UTIL --install
|
||||
else
|
||||
if [ $DIAG -gt 0 ] ; then
|
||||
echo $DIGERROR
|
||||
exit $DIAG
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
php $UTIL --buildconfig
|
|
@ -17,14 +17,7 @@
|
|||
/**
|
||||
* PHPUnit related utilities.
|
||||
*
|
||||
* Exit codes:
|
||||
* 0 - success
|
||||
* 1 - general error
|
||||
* 130 - missing PHPUnit library error
|
||||
* 131 - configuration problem
|
||||
* 132 - install new test database
|
||||
* 133 - drop existing data before installing
|
||||
* 134 - can not create main phpunit.xml
|
||||
* Exit codes: {@see phpunit_bootstrap_error()}
|
||||
*
|
||||
* @package tool_phpunit
|
||||
* @copyright 2012 Petr Skoda {@link http://skodak.org}
|
||||
|
@ -73,11 +66,7 @@ if ($options['phpunitdir']) {
|
|||
|
||||
// verify PHPUnit libs are loaded
|
||||
if (!@include_once('PHPUnit/Autoload.php')) {
|
||||
phpunit_bootstrap_error(130);
|
||||
}
|
||||
|
||||
if (!@include_once('PHPUnit/Extensions/Database/Autoload.php')) {
|
||||
phpunit_bootstrap_error(130);
|
||||
phpunit_bootstrap_error(PHPUNIT_EXITCODE_PHPUNITMISSING);
|
||||
}
|
||||
|
||||
if ($options['run']) {
|
||||
|
@ -147,7 +136,7 @@ if ($diag) {
|
|||
if (phpunit_util::build_config_file()) {
|
||||
exit(0);
|
||||
} else {
|
||||
phpunit_bootstrap_error(134);
|
||||
phpunit_bootstrap_error(PHPUNIT_EXITCODE_CONFIGWARNING, 'Can not create phpunit.xml configuration file, verify dirroot permissions');
|
||||
}
|
||||
|
||||
} else if ($drop) {
|
||||
|
|
|
@ -67,7 +67,7 @@ if ($execute) {
|
|||
if ($code == 0) {
|
||||
// everything is ready
|
||||
|
||||
} else if ($code == 132) {
|
||||
} else if ($code == PHPUNIT_EXITCODE_INSTALL) {
|
||||
tool_phpunit_header();
|
||||
echo $OUTPUT->box_start('generalbox');
|
||||
echo '<pre>';
|
||||
|
@ -87,7 +87,7 @@ if ($execute) {
|
|||
echo $OUTPUT->footer();
|
||||
die();
|
||||
|
||||
} else if ($code == 133) {
|
||||
} else if ($code == PHPUNIT_EXITCODE_REINSTALL) {
|
||||
tool_phpunit_header();
|
||||
echo $OUTPUT->box_start('generalbox');
|
||||
echo '<pre>';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue