Skip to content

Commit

Permalink
[BUGFIX] runTests.sh: Fix macos user detection
Browse files Browse the repository at this point in the history
Check for user in /etc/passwd, if it does not exist create
a temporary passwd to get values from.

Resolves: #93372
Releases: master, 10.4, 9.5
Change-Id: I60c9d2a10a0da155354546d57c823961bc39f014
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/67539
Tested-by: Jochen <rothjochen@gmail.com>
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Oliver Bartsch <bo@cedev.de>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Jochen <rothjochen@gmail.com>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/67922
  • Loading branch information
ochorocho authored and lolli42 committed Feb 15, 2021
1 parent 1bda5f4 commit 264fd7e
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 48 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ nbproject
/Build/JavaScript
!/Build/typings/no-def*
/Build/testing-docker/local/.env
/Build/testing-docker/local/macos_passwd
/typo3/sysext/*/Resources/Private/TypeScript/*.js
/typo3/sysext/*/Resources/Public/JavaScript/*.js.map
typo3/sysext/core/Tests/Acceptance/AcceptanceTests-Job-*
Expand Down
26 changes: 19 additions & 7 deletions Build/Scripts/runTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,14 @@ setUpDockerComposeDotEnv() {
echo "PHP_VERSION=${PHP_VERSION}" >> .env
echo "CHUNKS=${CHUNKS}" >> .env
echo "THISCHUNK=${THISCHUNK}" >> .env
echo "PASSWD_PATH=${PASSWD_PATH}" >> .env
}

# Options -a and -d depend on each other. The function
# validates input combinations and sets defaults.
handleDbmsAndDriverOptions() {
case ${DBMS} in
mariadb)
;&
mysql)
mysql|mariadb)
[ -z ${DATABASE_DRIVER} ] && DATABASE_DRIVER="mysqli"
if [ "${DATABASE_DRIVER}" != "mysqli" ] && [ "${DATABASE_DRIVER}" != "pdo_mysql" ]; then
echo "Invalid option -a ${DATABASE_DRIVER} with -d ${DBMS}" >&2
Expand All @@ -63,16 +62,13 @@ handleDbmsAndDriverOptions() {
exit 1
fi
;;
postgres)
;&
sqlite)
postgres|sqlite)
if ! [ -z ${DATABASE_DRIVER} ]; then
echo "Invalid option -a ${DATABASE_DRIVER} with -d ${DBMS}" >&2
echo >&2
echo "call \".Build/Scripts/runTests.sh -h\" to display help and valid options" >&2
exit 1
fi
DATABASE_DRIVER=""
;;
esac
}
Expand Down Expand Up @@ -290,11 +286,13 @@ EXTRA_TEST_OPTIONS=""
SCRIPT_VERBOSE=0
PHPUNIT_RANDOM=""
CGLCHECK_DRY_RUN=""
DATABASE_DRIVER=""
MARIADB_VERSION="10.3"
MYSQL_VERSION="5.5"
POSTGRES_VERSION="10"
CHUNKS=0
THISCHUNK=0
PASSWD_PATH=/etc/passwd

# Option parsing
# Reset in case getopts has been used previously in the shell
Expand Down Expand Up @@ -394,6 +392,20 @@ fi
# Move "7.2" to "php72", the latter is the docker container name
DOCKER_PHP_IMAGE=`echo "php${PHP_VERSION}" | sed -e 's/\.//'`

# Some scripts rely on a proper /etc/passwd that includes the user that runs the
# containers, for instance to determine users $HOME. yarn v1 is espcecially picky
# here since it fails if it can't write a .yarnrc file to users home ...
# MacOS in it's endless wisdom however decided that /etc/passwd is a stupid thing
# and does not write an entry for the standard user in it. In turn, stuff like yarn fails.
# As a solution, we detect if the user executing the script is within /etc/passwd
# and volume mount that file within containers. If not, we create a fake passwd file
# and mount that one.
[ -z ${USER} ] && USER=`id -u -n`
if [ `grep -c "^${USER}:" /etc/passwd` -ne 1 ]; then
echo "${USER}:x:$(id -u $USER):$(id -g $USER):$(id -gn $USER):${HOME}:/bin/bash" > macos_passwd
PASSWD_PATH="./macos_passwd"
fi

# Set $1 to first mass argument, this is the optional test file or test directory to execute
shift $((OPTIND - 1))
TEST_FILE=${1}
Expand Down
Loading

0 comments on commit 264fd7e

Please sign in to comment.