Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions _common/docker.inc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,19 @@ function docker_build_and_start_composer_container() {
#
function docker_stop_and_cleanup_composer_container() {
local COMPOSER_ID=composer-temp

# Windows needs extra leading slash for path to avoid prepending the host's
# base path
local CONTAINER_ROOT_PATH
if [[ $OSTYPE =~ msys|cygwin ]]; then
CONTAINER_ROOT_PATH=//var/www/html
else
CONTAINER_ROOT_PATH=/var/www/html
fi

# copy modified files to mounted volume:
docker exec $COMPOSER_ID cp composer.lock //var/www/html/
docker exec $COMPOSER_ID cp composer.json //var/www/html/
docker exec $COMPOSER_ID cp composer.lock $CONTAINER_ROOT_PATH/
docker exec $COMPOSER_ID cp composer.json $CONTAINER_ROOT_PATH/
# cleanup
docker stop $COMPOSER_ID
docker rmi $COMPOSER_ID
Expand Down
18 changes: 13 additions & 5 deletions _common/tests.inc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
# Shared test functions for PHP lint, unit test, and general broken link checks
#

# Windows needs extra leading slash for path to avoid prepending the host's base
# path
if [[ $OSTYPE =~ msys|cygwin ]]; then
TEST_CONTAINER_ROOT_PATH=//var/www/html
else
TEST_CONTAINER_ROOT_PATH=/var/www/html
fi

# Record the start time for unit tests for later log review
function do_test_record_start_time() {
TEST_START_TIME=$(date -Is -u)
Expand All @@ -17,7 +25,7 @@ function do_test_record_start_time() {
#
function do_test_unit_tests() {
local CONTAINER="$1"
docker exec "${CONTAINER}" sh -c "vendor/bin/phpunit --testdox ${builder_extra_params[*]}"
docker exec "${CONTAINER}" sh -c "vendor/bin/phpunit --testdox ${builder_extra_params[*]:-}"
}

# Lint .php files for obvious errors
Expand Down Expand Up @@ -48,7 +56,7 @@ function do_test_links() {
skipParams+=(--skip "^${baseURL}${skip}")
done

builder_echo "Testing links; --skip ^(?!${baseURL}) ${skipParams[*]}"
echo "Testing links; --skip ^(?!${baseURL}) ${skipParams[*]}"

npx https://github.com/keymanapp/linkinator \
"${baseURL}${testPath}" \
Expand Down Expand Up @@ -85,18 +93,18 @@ function do_test_print_link_report() {
#
function do_test_print_container_error_logs() {
local CONTAINER="$1"
docker exec "${CONTAINER}" //var/www/html/_common/tests.container.sh report
docker exec "${CONTAINER}" $TEST_CONTAINER_ROOT_PATH/_common/tests.container.sh report
}


function do_test_links_setup() {
local CONTAINER="$1"
docker exec "${CONTAINER}" //var/www/html/_common/tests.container.sh setup
docker exec "${CONTAINER}" $TEST_CONTAINER_ROOT_PATH/_common/tests.container.sh setup
docker kill "${CONTAINER}" --signal="USR1"
}

function do_test_links_cleanup() {
local CONTAINER="$1"
docker exec "${CONTAINER}" //var/www/html/_common/tests.container.sh cleanup
docker exec "${CONTAINER}" $TEST_CONTAINER_ROOT_PATH/_common/tests.container.sh cleanup
docker kill "${CONTAINER}" --signal="USR1"
}