Skip to content

Commit 9ddb8db

Browse files
achimfritzclaude
andcommitted
[TASK] Sync runTests.sh improvements from TYPO3 core
- Add printSummary() function replacing inline cleanup+summary block - Add TTY detection to auto-drop -it flags in non-interactive shells - Add CI_JOB_ID to container suffix for unique names in parallel CI jobs - Add TMPFS_MOUNT_OPTIONS variable (with uid/gid for docker, plain for podman) - Add CONTAINER_COMMON_PARAMS_CI support for injecting extra CI params - Update MariaDB versions: remove 10.1-10.3, add 11.2-11.4 - Update MySQL versions: remove unmaintained 5.5, 5.6, 5.7 - Remove stale TYPO3 v11 special case from container binary detection - Fix duplicate "With '-d mariadb'" bug in help text (second entry is mysql) - Update header comment to mention podman Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent d8bf031 commit 9ddb8db

1 file changed

Lines changed: 59 additions & 59 deletions

File tree

Build/Scripts/runTests.sh

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,41 @@
11
#!/usr/bin/env bash
22

33
#
4-
# TYPO3 core test runner based on docker.
4+
# TYPO3 core test runner based on docker or podman.
55
#
66
if [ "${CI}" != "true" ]; then
77
trap 'echo "runTests.sh SIGINT signal emitted";cleanUp;exit 2' SIGINT
88
fi
99

10+
printSummary() {
11+
cleanUp
12+
13+
echo "" >&2
14+
echo "###########################################################################" >&2
15+
echo "Result of ${TEST_SUITE}" >&2
16+
echo "Container runtime: ${CONTAINER_BIN}" >&2
17+
echo "Container suffix: ${SUFFIX}"
18+
echo "PHP: ${PHP_VERSION}" >&2
19+
if [[ ${TEST_SUITE} =~ ^(functional|acceptance)$ ]]; then
20+
case "${DBMS}" in
21+
mariadb|mysql|postgres)
22+
echo "DBMS: ${DBMS} version ${DBMS_VERSION} driver ${DATABASE_DRIVER}" >&2
23+
;;
24+
sqlite)
25+
echo "DBMS: ${DBMS}" >&2
26+
;;
27+
esac
28+
fi
29+
if [[ ${SUITE_EXIT_CODE} -eq 0 ]]; then
30+
echo "SUCCESS" >&2
31+
else
32+
echo "FAILURE" >&2
33+
fi
34+
echo "###########################################################################" >&2
35+
echo "" >&2
36+
exit ${SUITE_EXIT_CODE}
37+
}
38+
1039
waitFor() {
1140
local HOST=${1}
1241
local PORT=${2}
@@ -53,7 +82,7 @@ handleDbmsOptions() {
5382
exit 1
5483
fi
5584
[ -z "${DBMS_VERSION}" ] && DBMS_VERSION="10.4"
56-
if ! [[ ${DBMS_VERSION} =~ ^(10.1|10.2|10.3|10.4|10.5|10.6|10.7|10.8|10.9|10.10|10.11|11.0|11.1)$ ]]; then
85+
if ! [[ ${DBMS_VERSION} =~ ^(10.4|10.5|10.6|10.7|10.8|10.9|10.10|10.11|11.0|11.1|11.2|11.3|11.4)$ ]]; then
5786
echo "Invalid combination -d ${DBMS} -i ${DBMS_VERSION}" >&2
5887
echo >&2
5988
echo "Use \".Build/Scripts/runTests.sh -h\" to display help and valid options" >&2
@@ -69,7 +98,7 @@ handleDbmsOptions() {
6998
exit 1
7099
fi
71100
[ -z "${DBMS_VERSION}" ] && DBMS_VERSION="8.0"
72-
if ! [[ ${DBMS_VERSION} =~ ^(5.5|5.6|5.7|8.0|8.1|8.2|8.3|8.4)$ ]]; then
101+
if ! [[ ${DBMS_VERSION} =~ ^(8.0|8.1|8.2|8.3|8.4)$ ]]; then
73102
echo "Invalid combination -d ${DBMS} -i ${DBMS_VERSION}" >&2
74103
echo >&2
75104
echo "Use \".Build/Scripts/runTests.sh -h\" to display help and valid options" >&2
@@ -175,9 +204,6 @@ Options:
175204
-i version
176205
Specify a specific database version
177206
With "-d mariadb":
178-
- 10.1 short-term, no longer maintained
179-
- 10.2 short-term, no longer maintained
180-
- 10.3 short-term, maintained until 2023-05-25
181207
- 10.4 short-term, maintained until 2024-06-18 (default)
182208
- 10.5 short-term, maintained until 2025-06-24
183209
- 10.6 long-term, maintained until 2026-06
@@ -187,19 +213,19 @@ Options:
187213
- 10.10 short-term, maintained until 2023-11
188214
- 10.11 long-term, maintained until 2028-02
189215
- 11.0 development series
190-
- 11.1 short-term development series
191-
With "-d mariadb":
192-
- 5.5 unmaintained since 2018-12
193-
- 5.6 unmaintained since 2021-02
194-
- 5.7 maintained until 2023-10
195-
- 8.0 maintained until 2026-04 (default)
216+
- 11.1 short-term development series, maintained until 2024-08
217+
- 11.2 short-term development series, maintained until 2024-11
218+
- 11.3 short-term development series, rolling release
219+
- 11.4 long-term, maintained until 2029-05
220+
With "-d mysql":
221+
- 8.0 maintained until 2026-04 (default) LTS
196222
- 8.1 unmaintained since 2023-10
197223
- 8.2 unmaintained since 2024-01
198224
- 8.3 maintained until 2024-04
199225
- 8.4 maintained until 2032-04 LTS
200226
With "-d postgres":
201227
- 10 unmaintained since 2022-11-10 (default)
202-
- 11 maintained until 2023-11-09
228+
- 11 unmaintained since 2023-11-09
203229
- 12 maintained until 2024-11-14
204230
- 13 maintained until 2025-11-13
205231
- 14 maintained until 2026-11-12
@@ -300,7 +326,11 @@ CONTAINER_HOST="host.docker.internal"
300326
HOST_UID=$(id -u)
301327
HOST_PID=$(id -g)
302328
USERSET=""
329+
CI_JOB_ID=${CI_JOB_ID:-}
303330
SUFFIX=$(echo $RANDOM)
331+
if [ ${CI_JOB_ID} ]; then
332+
SUFFIX="${CI_JOB_ID}-${SUFFIX}"
333+
fi
304334
NETWORK="b13-container-${SUFFIX}"
305335
PHPUNIT_EXCLUDE_GROUPS="${PHPUNIT_EXCLUDE_GROUPS:-}"
306336
# @todo Remove USE_APACHE option when TF7 has been dropped (along with TYPO3 v11 support).
@@ -391,28 +421,24 @@ fi
391421

392422
handleDbmsOptions
393423

394-
# ENV var "CI" is set by gitlab-ci. Use it to force some CI details.
395-
IS_CORE_CI=0
396424
if [ "${CI}" == "true" ]; then
397-
IS_CORE_CI=1
425+
# ENV var "CI" is set by gitlab-ci. Use it to force some CI details.
398426
CONTAINER_INTERACTIVE=""
427+
elif [ ! -t 0 ] || [ ! -t 1 ]; then
428+
# If stdin or stdout is not a TTY (e.g. a script runner, pipe, or non-interactive shell),
429+
# drop the interactive "-it" flags automatically to avoid podman warning "The input device
430+
# is not a TTY." and docker failure, and to keep redirected output free of TTY control characters.
431+
# Keep "--init" so the PID 1 init process still forwards signals (e.g. ctrl-c) to the test process.
432+
CONTAINER_INTERACTIVE="--init"
399433
fi
400434

401435
# determine default container binary to use: 1. podman 2. docker
402436
if [[ -z "${CONTAINER_BIN}" ]]; then
403-
if [[ "${TYPO3}" == "11" ]]; then
404-
if type "docker" >/dev/null 2>&1; then
405-
CONTAINER_BIN="docker"
406-
elif type "podman" >/dev/null 2>&1; then
407-
CONTAINER_BIN="podman"
408-
fi
409-
else
410437
if type "podman" >/dev/null 2>&1; then
411438
CONTAINER_BIN="podman"
412439
elif type "docker" >/dev/null 2>&1; then
413440
CONTAINER_BIN="docker"
414441
fi
415-
fi
416442
fi
417443

418444
if [ $(uname) != "Darwin" ] && [ ${CONTAINER_BIN} = "docker" ]; then
@@ -455,10 +481,16 @@ ${CONTAINER_BIN} network create ${NETWORK} >/dev/null
455481
if [ ${CONTAINER_BIN} = "docker" ]; then
456482
# docker needs the add-host for xdebug remote debugging. podman has host.container.internal built in
457483
CONTAINER_COMMON_PARAMS="${CONTAINER_INTERACTIVE} --rm --network ${NETWORK} --add-host "${CONTAINER_HOST}:host-gateway" ${USERSET} -v ${CORE_ROOT}:${CORE_ROOT} -w ${CORE_ROOT}"
484+
TMPFS_MOUNT_OPTIONS="rw,noexec,nosuid,uid=${HOST_UID},gid=${HOST_PID}"
458485
else
459486
# podman
460487
CONTAINER_HOST="host.containers.internal"
461488
CONTAINER_COMMON_PARAMS="${CONTAINER_INTERACTIVE} ${CI_PARAMS} --rm --network ${NETWORK} -v ${CORE_ROOT}:${CORE_ROOT} -w ${CORE_ROOT}"
489+
TMPFS_MOUNT_OPTIONS="rw,noexec,nosuid"
490+
fi
491+
492+
if [[ "${CI}" == "true" ]]; then
493+
CONTAINER_COMMON_PARAMS="${CONTAINER_COMMON_PARAMS} ${CONTAINER_COMMON_PARAMS_CI:-}"
462494
fi
463495

464496
if [ ${PHP_XDEBUG_ON} -eq 0 ]; then
@@ -653,7 +685,7 @@ case ${TEST_SUITE} in
653685
# create sqlite tmpfs mount typo3temp/var/tests/functional-sqlite-dbs/ to avoid permission issues
654686
rm -rf "${CORE_ROOT}/.Build/Web/typo3temp/var/tests/functional-sqlite-dbs"
655687
mkdir -p "${CORE_ROOT}/.Build/Web/typo3temp/var/tests/functional-sqlite-dbs/"
656-
CONTAINERPARAMS="-e typo3DatabaseDriver=pdo_sqlite --tmpfs ${CORE_ROOT}/.Build/Web/typo3temp/var/tests/functional-sqlite-dbs/:rw,noexec,nosuid"
688+
CONTAINERPARAMS="-e typo3DatabaseDriver=pdo_sqlite --tmpfs ${CORE_ROOT}/.Build/Web/typo3temp/var/tests/functional-sqlite-dbs/:${TMPFS_MOUNT_OPTIONS}"
657689
${CONTAINER_BIN} run --rm ${CI_PARAMS} ${CONTAINER_COMMON_PARAMS} --name functional-${SUFFIX} ${XDEBUG_MODE} -e XDEBUG_CONFIG="${XDEBUG_CONFIG}" ${CONTAINERPARAMS} ${IMAGE_PHP} "${COMMAND[@]}"
658690
SUITE_EXIT_CODE=$?
659691
;;
@@ -710,37 +742,5 @@ case ${TEST_SUITE} in
710742
;;
711743
esac
712744

713-
cleanUp
714-
715-
# Print summary
716-
echo "" >&2
717-
echo "###########################################################################" >&2
718-
echo "Result of ${TEST_SUITE}" >&2
719-
if [[ ${IS_CORE_CI} -eq 1 ]]; then
720-
echo "Environment: CI" >&2
721-
else
722-
echo "Environment: local" >&2
723-
fi
724-
echo "Container runtime: ${CONTAINER_BIN}" >&2
725-
echo "Container suffix: ${SUFFIX}"
726-
echo "PHP: ${PHP_VERSION}" >&2
727-
if [[ ${TEST_SUITE} =~ ^(functional|functionalDeprecated|acceptance|acceptanceInstall)$ ]]; then
728-
case "${DBMS}" in
729-
mariadb|mysql|postgres)
730-
echo "DBMS: ${DBMS} version ${DBMS_VERSION} driver ${DATABASE_DRIVER}" >&2
731-
;;
732-
sqlite)
733-
echo "DBMS: ${DBMS}" >&2
734-
;;
735-
esac
736-
fi
737-
if [[ ${SUITE_EXIT_CODE} -eq 0 ]]; then
738-
echo "SUCCESS" >&2
739-
else
740-
echo "FAILURE" >&2
741-
fi
742-
echo "###########################################################################" >&2
743-
echo "" >&2
744-
745-
# Exit with code of test suite - This script return non-zero if the executed test failed.
746-
exit $SUITE_EXIT_CODE
745+
# Cleanup, print summary && exit with exitcode
746+
printSummary

0 commit comments

Comments
 (0)