Skip to content

Commit

Permalink
Attempt to support restructured directories
Browse files Browse the repository at this point in the history
TODO: Bats tests
  • Loading branch information
andrewnicols committed Oct 11, 2024
1 parent 3114715 commit e68e59b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
17 changes: 14 additions & 3 deletions runner/main/jobtypes/behat/behat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ function behat_to_env_file() {
SELENIUMURL_10

WEBSERVER
APACHE_DOCUMENT_ROOT
PUBLICROOT

IONICURL

Expand All @@ -67,6 +69,8 @@ function behat_to_env_file() {
function behat_to_summary() {
echo "== Moodle branch (version.php): ${MOODLE_BRANCH}"
echo "== PHP version: ${PHP_VERSION}"
echo "== APACHE_DOCUMENT_ROOT: ${APACHE_DOCUMENT_ROOT}"
echo "== PUBLICROOT: ${PUBLICROOT}"
echo "== DBTYPE: ${DBTYPE}"
echo "== DBTAG: ${DBTAG}"
echo "== DBREPLICAS: ${DBREPLICAS}"
Expand Down Expand Up @@ -144,6 +148,8 @@ function behat_check() {
# Behat job type init.
function behat_config() {
# Apply some defaults.
APACHE_DOCUMENT_ROOT="${APACHE_DOCUMENT_ROOT:-/var/www/html}"
PUBLICROOT="${PUBLICROOT:-}"
RUNCOUNT="${RUNCOUNT:-1}"
BEHAT_SUITE="${BEHAT_SUITE:-}"
BEHAT_TAGS="${BEHAT_TAGS:-}"
Expand Down Expand Up @@ -177,6 +183,11 @@ function behat_config() {
BEHAT_RERUNS=0
BEHAT_TIMING_FILENAME=
fi

if [[ -d "${CODEDIR}/public" ]]; then
APACHE_DOCUMENT_ROOT="${APACHE_DOCUMENT_ROOT:-/var/www/html/public}"
PUBLICROOT="${PUBLICROOT:-/public}"
fi
}

# Behat job type setup.
Expand Down Expand Up @@ -229,7 +240,7 @@ function behat_initcmd() {

# Build the complete init command.
cmd=(
php admin/tool/behat/cli/init.php
php ${PUBLICROOT}admin/tool/behat/cli/init.php
"${initsuite}"
-j="${BEHAT_PARALLEL}"
--axe
Expand Down Expand Up @@ -451,7 +462,7 @@ function behat_main_command() {

# Let's build the complete behat command for the 1st (parallel) run.
_cmd=(
php admin/tool/behat/cli/run.php
php ${PUBLICROOT}admin/tool/behat/cli/run.php
)

# Add the options and profile.
Expand Down Expand Up @@ -527,7 +538,7 @@ function behat_rerun_command() {
# and, also, it automatically handles the file system links for the web server.
# (output is a little bit uglier, but consistent with the main run).
_reruncmd=(
php admin/tool/behat/cli/run.php --rerun
php ${PUBLICROOT}admin/tool/behat/cli/run.php --rerun
)

# Add the config, options and profile.
Expand Down
9 changes: 8 additions & 1 deletion runner/main/jobtypes/phpunit/phpunit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
# PHPUnit needed variables to go to the env file.
function phpunit_to_env_file() {
local env=(
PUBLICROOT

DBTYPE
DBTAG
DBHOST
Expand Down Expand Up @@ -53,6 +55,7 @@ function phpunit_to_env_file() {
function phpunit_to_summary() {
echo "== Moodle branch (version.php): ${MOODLE_BRANCH}"
echo "== PHP version: ${PHP_VERSION}"
echo "== PUBLICROOT: ${PUBLICROOT}"
echo "== DBTYPE: ${DBTYPE}"
echo "== DBTAG: ${DBTAG}"
echo "== DBCOLLATION: ${DBCOLLATION}"
Expand Down Expand Up @@ -128,6 +131,10 @@ function phpunit_config() {
# Also, we don't want to allow repetitions in the bisect session.
RUNCOUNT=1
fi

if [[ -d "${CODEDIR}/public" ]]; then
PUBLICROOT="${PUBLICROOT:-/public}"
fi
}

# PHPUnit job type setup.
Expand Down Expand Up @@ -157,7 +164,7 @@ function phpunit_initcmd() {
local -n cmd=$1
cmd=(
php
admin/tool/phpunit/cli/init.php
${PUBLICROOT}admin/tool/phpunit/cli/init.php
)
}

Expand Down
6 changes: 5 additions & 1 deletion runner/main/modules/moodle-core-copy/moodle-core-copy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ function moodle-core-copy_check() {
# Moodle core copy module config.
function moodle-core-copy_config() {
# Get the Moodle branch from code, so we can make decisions based on it.
MOODLE_BRANCH=$(grep "\$branch" "${CODEDIR}"/version.php | sed "s/';.*//" | sed "s/^\$.*'//")
if [[ -d "${CODEDIR}/public" ]]; then
MOODLE_BRANCH=$(grep "\$branch" "${CODEDIR}"/public/version.php | sed "s/';.*//" | sed "s/^\$.*'//")
else
MOODLE_BRANCH=$(grep "\$branch" "${CODEDIR}"/version.php | sed "s/';.*//" | sed "s/^\$.*'//")
fi
}

# Moodle core copy module setup.
Expand Down

0 comments on commit e68e59b

Please sign in to comment.