[BUGFIX] Apply enableFields in JOIN's ON condition
[Packages/TYPO3.CMS.git] / Build / Scripts / runTests.sh
1 #!/usr/bin/env bash
2
3 #
4 # TYPO3 core test runner based on docker and docker-compose.
5 #
6
7 # Function to write a .env file in Build/testing-docker/local
8 # This is read by docker-compose and vars defined here are
9 # used in Build/testing-docker/local/docker-compose.yml
10 setUpDockerComposeDotEnv() {
11 # Delete possibly existing local .env file if exists
12 [ -e .env ] && rm .env
13 # Set up a new .env file for docker-compose
14 echo "COMPOSE_PROJECT_NAME=local" >> .env
15 # To prevent access rights of files created by the testing, the docker image later
16 # runs with the same user that is currently executing the script. docker-compose can't
17 # use $UID directly itself since it is a shell variable and not an env variable, so
18 # we have to set it explicitly here.
19 echo "HOST_UID=`id -u`" >> .env
20 # Your local home directory for composer and npm caching
21 echo "HOST_HOME=${HOME}" >> .env
22 # Your local user
23 echo "CORE_ROOT"=${CORE_ROOT} >> .env
24 echo "HOST_USER=${USER}" >> .env
25 echo "TEST_FILE=${TEST_FILE}" >> .env
26 echo "PHP_XDEBUG_ON=${PHP_XDEBUG_ON}" >> .env
27 echo "PHP_XDEBUG_PORT=${PHP_XDEBUG_PORT}" >> .env
28 echo "DOCKER_PHP_IMAGE=${DOCKER_PHP_IMAGE}" >> .env
29 echo "EXTRA_TEST_OPTIONS=${EXTRA_TEST_OPTIONS}" >> .env
30 echo "SCRIPT_VERBOSE=${SCRIPT_VERBOSE}" >> .env
31 echo "PHPUNIT_RANDOM=${PHPUNIT_RANDOM}" >> .env
32 echo "CGLCHECK_DRY_RUN=${CGLCHECK_DRY_RUN}" >> .env
33 echo "DATABASE_DRIVER=${DATABASE_DRIVER}" >> .env
34 echo "MARIADB_VERSION=${MARIADB_VERSION}" >> .env
35 echo "MYSQL_VERSION=${MYSQL_VERSION}" >> .env
36 echo "POSTGRES_VERSION=${POSTGRES_VERSION}" >> .env
37 echo "PHP_VERSION=${PHP_VERSION}" >> .env
38 echo "CHUNKS=${CHUNKS}" >> .env
39 echo "THISCHUNK=${THISCHUNK}" >> .env
40 echo "PASSWD_PATH=${PASSWD_PATH}" >> .env
41 }
42
43 # Options -a and -d depend on each other. The function
44 # validates input combinations and sets defaults.
45 handleDbmsAndDriverOptions() {
46 case ${DBMS} in
47 mysql|mariadb)
48 [ -z ${DATABASE_DRIVER} ] && DATABASE_DRIVER="mysqli"
49 if [ "${DATABASE_DRIVER}" != "mysqli" ] && [ "${DATABASE_DRIVER}" != "pdo_mysql" ]; then
50 echo "Invalid option -a ${DATABASE_DRIVER} with -d ${DBMS}" >&2
51 echo >&2
52 echo "call \".Build/Scripts/runTests.sh -h\" to display help and valid options" >&2
53 exit 1
54 fi
55 ;;
56 mssql)
57 [ -z ${DATABASE_DRIVER} ] && DATABASE_DRIVER="sqlsrv"
58 if [ "${DATABASE_DRIVER}" != "sqlsrv" ] && [ "${DATABASE_DRIVER}" != "pdo_sqlsrv" ]; then
59 echo "Invalid option -a ${DATABASE_DRIVER} with -d ${DBMS}" >&2
60 echo >&2
61 echo "call \".Build/Scripts/runTests.sh -h\" to display help and valid options" >&2
62 exit 1
63 fi
64 ;;
65 postgres|sqlite)
66 if ! [ -z ${DATABASE_DRIVER} ]; then
67 echo "Invalid option -a ${DATABASE_DRIVER} with -d ${DBMS}" >&2
68 echo >&2
69 echo "call \".Build/Scripts/runTests.sh -h\" to display help and valid options" >&2
70 exit 1
71 fi
72 ;;
73 esac
74 }
75
76 # Load help text into $HELP
77 read -r -d '' HELP <<EOF
78 TYPO3 core test runner. Execute acceptance, unit, functional and other test suites in
79 a docker based test environment. Handles execution of single test files, sending
80 xdebug information to a local IDE and more.
81
82 Successfully tested with docker version 18.06.1-ce and docker-compose 1.21.2.
83
84 Usage: $0 [options] [file]
85
86 No arguments: Run all unit tests with PHP 7.4
87
88 Options:
89 -s <...>
90 Specifies which test suite to run
91 - acceptance: main backend acceptance tests
92 - buildCss: execute scss to css builder
93 - buildJavascript: execute typescript to javascript builder
94 - cglGit: test and fix latest committed patch for CGL compliance
95 - cglAll: test and fix all core php files
96 - checkAnnotations: check php code for allowed annotations
97 - checkBom: check UTF-8 files do not contain BOM
98 - checkComposer: check composer.json files for version integrity
99 - checkCsvFixtures: test integrity of functional test csv fixtures
100 - checkExceptionCodes: test core for duplicate exception codes
101 - checkExtensionScannerRst: test all .rst files referenced by extension scanner exist
102 - checkFilePathLength: test core file paths do not exceed maximum length
103 - checkGitSubmodule: test core git has no sub modules defined
104 - checkGruntClean: Verify "grunt build" is clean. Warning: Executes git commands! Usually used in CI only.
105 - checkPermissions: test some core files for correct executable bits
106 - checkRst: test .rst files for integrity
107 - composerInstall: "composer install"
108 - composerInstallMax: "composer update", with no platform.php config.
109 - composerInstallMin: "composer update --prefer-lowest", with platform.php set to PHP version x.x.0.
110 - composerValidate: "composer validate"
111 - docBlockCheck: Scan php doc blocks for validity
112 - fixCsvFixtures: fix broken functional test csv fixtures
113 - functional: functional tests
114 - install: installation acceptance tests, only with -d mariadb|postgres|sqlite
115 - lint: PHP linting
116 - lintScss: SCSS linting
117 - lintTypescript: TS linting
118 - lintHtml: HTML linting
119 - listExceptionCodes: list core exception codes in JSON format
120 - phpstan: phpstan tests
121 - unit (default): PHP unit tests
122 - unitDeprecated: deprecated PHP unit tests
123 - unitJavascript: JavaScript unit tests
124 - unitRandom: PHP unit tests in random order, add -o <number> to use specific seed
125
126 -a <mysqli|pdo_mysql|sqlsrv|pdo_sqlsrv>
127 Only with -s functional
128 Specifies to use another driver, following combinations are available:
129 - mysql
130 - mysqli (default)
131 - pdo_mysql
132 - mariadb
133 - mysqli (default)
134 - pdo_mysql
135 - mssql
136 - sqlsrv (default)
137 - pdo_sqlsrv
138
139 -d <mariadb|mysql|mssql|postgres|sqlite>
140 Only with -s install|functional|acceptance
141 Specifies on which DBMS tests are performed
142 - mariadb (default): use mariadb
143 - mysql: use MySQL server
144 - mssql: use mssql microsoft sql server
145 - postgres: use postgres
146 - sqlite: use sqlite
147
148 -i <10.1|10.2|10.3|10.4|10.5>
149 Only with -d mariadb
150 Specifies on which version of mariadb tests are performed
151 - 10.1
152 - 10.2
153 - 10.3 (default)
154 - 10.4
155 - 10.5
156
157 -j <5.5|5.6|5.7|8.0>
158 Only with -d mysql
159 Specifies on which version of mysql tests are performed
160 - 5.5 (default)
161 - 5.6
162 - 5.7
163 - 8.0
164
165 -k <9.6|10|11|12|13>
166 Only with -d postgres
167 Specifies on which version of postgres tests are performed
168 - 9.6
169 - 10 (default)
170 - 11
171 - 12
172 -13
173
174 -c <chunk/numberOfChunks>
175 Only with -s functional|acceptance
176 Hack functional or acceptance tests into #numberOfChunks pieces and run tests of #chunk.
177 Example -c 3/13
178
179 -p <7.4|8.0>
180 Specifies the PHP minor version to be used
181 - 7.4 (default): use PHP 7.4
182 - 8.0: use PHP 8.0
183
184 -e "<phpunit options>"
185 Only with -s functional|unit|unitDeprecated|unitRandom
186 Additional options to send to phpunit (unit & functional tests) or codeception (acceptance
187 tests). For phpunit, options starting with "--" must be added after options starting with "-".
188 Example -e "-v --filter canRetrieveValueWithGP" to enable verbose output AND filter tests
189 named "canRetrieveValueWithGP"
190
191 -x
192 Only with -s functional|unit|unitDeprecated|unitRandom|acceptance|install
193 Send information to host instance for test or system under test break points. This is especially
194 useful if a local PhpStorm instance is listening on default xdebug port 9003. A different port
195 can be selected with -y
196
197 -y <port>
198 Send xdebug information to a different port than default 9003 if an IDE like PhpStorm
199 is not listening on default port.
200
201 -o <number>
202 Only with -s unitRandom
203 Set specific random seed to replay a random run in this order again. The phpunit randomizer
204 outputs the used seed at the end (in bamboo core testing logs, too). Use that number to
205 replay the unit tests in that order.
206
207 -n
208 Only with -s cglGit|cglAll
209 Activate dry-run in CGL check that does not actively change files and only prints broken ones.
210
211 -u
212 Update existing typo3/core-testing-*:latest docker images. Maintenance call to docker pull latest
213 versions of the main php images. The images are updated once in a while and only the youngest
214 ones are supported by core testing. Use this if weird test errors occur. Also removes obsolete
215 image versions of typo3/core-testing-*.
216
217 -v
218 Enable verbose script output. Shows variables and docker commands.
219
220 -h
221 Show this help.
222
223 Examples:
224 # Run all core unit tests using PHP 7.4
225 ./Build/Scripts/runTests.sh
226 ./Build/Scripts/runTests.sh -s unit
227
228 # Run all core units tests and enable xdebug (have a PhpStorm listening on port 9003!)
229 ./Build/Scripts/runTests.sh -x
230
231 # Run unit tests in phpunit verbose mode with xdebug on PHP 8.0 and filter for test canRetrieveValueWithGP
232 ./Build/Scripts/runTests.sh -x -p 8.0 -e "-v --filter canRetrieveValueWithGP"
233
234 # Run functional tests in phpunit with a filtered test method name in a specified file
235 # example will currently execute two tests, both of which start with the search term
236 ./Build/Scripts/runTests.sh -s functional -e "--filter deleteContent" typo3/sysext/core/Tests/Functional/DataHandling/Regular/Modify/ActionTest.php
237
238 # Run unit tests with PHP 8.0 and have xdebug enabled
239 ./Build/Scripts/runTests.sh -x -p 8.0
240
241 # Run functional tests on postgres with xdebug, php 8.0 and execute a restricted set of tests
242 ./Build/Scripts/runTests.sh -x -p 8.0 -s functional -d postgres typo3/sysext/core/Tests/Functional/Authentication
243
244 # Run functional tests on mariadb 10.5
245 ./Build/Scripts/runTests.sh -d mariadb -i 10.5
246
247 # Run install tests on mysql 8.0
248 .Build/Scripts/runTests.sh -d mysql -j 8.0
249
250 # Run functional tests on postgres 11
251 ./Build/Scripts/runTests.sh -d postgres -k 11
252
253 # Run restricted set of backend acceptance tests
254 ./Build/Scripts/runTests.sh -s acceptance typo3/sysext/core/Tests/Acceptance/Backend/Login/BackendLoginCest.php
255
256 # Run installer tests of a new instance on sqlite
257 ./Build/Scripts/runTests.sh -s install -d sqlite
258 EOF
259
260 # Test if docker-compose exists, else exit out with error
261 if ! type "docker-compose" > /dev/null; then
262 echo "This script relies on docker and docker-compose. Please install" >&2
263 exit 1
264 fi
265
266 # Go to the directory this script is located, so everything else is relative
267 # to this dir, no matter from where this script is called.
268 THIS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
269 cd "$THIS_SCRIPT_DIR" || exit 1
270
271 # Go to directory that contains the local docker-compose.yml file
272 cd ../testing-docker/local || exit 1
273
274 # Option defaults
275 CORE_ROOT="${PWD}/../../../"
276 TEST_SUITE="unit"
277 DBMS="mariadb"
278 PHP_VERSION="7.4"
279 PHP_XDEBUG_ON=0
280 PHP_XDEBUG_PORT=9003
281 EXTRA_TEST_OPTIONS=""
282 SCRIPT_VERBOSE=0
283 PHPUNIT_RANDOM=""
284 CGLCHECK_DRY_RUN=""
285 DATABASE_DRIVER=""
286 MARIADB_VERSION="10.3"
287 MYSQL_VERSION="5.5"
288 POSTGRES_VERSION="10"
289 CHUNKS=0
290 THISCHUNK=0
291 PASSWD_PATH=/etc/passwd
292
293 # Option parsing
294 # Reset in case getopts has been used previously in the shell
295 OPTIND=1
296 # Array for invalid options
297 INVALID_OPTIONS=();
298 # Simple option parsing based on getopts (! not getopt)
299 while getopts ":a:s:c:d:i:j:k:p:e:xy:o:nhuv" OPT; do
300 case ${OPT} in
301 s)
302 TEST_SUITE=${OPTARG}
303 ;;
304 a)
305 DATABASE_DRIVER=${OPTARG}
306 ;;
307 c)
308 if ! [[ ${OPTARG} =~ ^([0-9]+\/[0-9]+)$ ]]; then
309 INVALID_OPTIONS+=(${OPTARG})
310 else
311 # Split "2/13" - run chunk 2 of 13 chunks
312 THISCHUNK=`echo ${OPTARG} | cut -d '/' -f1`
313 CHUNKS=`echo ${OPTARG} | cut -d '/' -f2`
314 fi
315 ;;
316 d)
317 DBMS=${OPTARG}
318 ;;
319 i)
320 MARIADB_VERSION=${OPTARG}
321 if ! [[ ${MARIADB_VERSION} =~ ^(10.1|10.2|10.3|10.4|10.5)$ ]]; then
322 INVALID_OPTIONS+=(${OPTARG})
323 fi
324 ;;
325 j)
326 MYSQL_VERSION=${OPTARG}
327 if ! [[ ${MYSQL_VERSION} =~ ^(5.5|5.6|5.7|8.0)$ ]]; then
328 INVALID_OPTIONS+=(${OPTARG})
329 fi
330 ;;
331 k)
332 POSTGRES_VERSION=${OPTARG}
333 if ! [[ ${POSTGRES_VERSION} =~ ^(9.6|10|11|12|13)$ ]]; then
334 INVALID_OPTIONS+=(${OPTARG})
335 fi
336 ;;
337 p)
338 PHP_VERSION=${OPTARG}
339 if ! [[ ${PHP_VERSION} =~ ^(7.4|8.0)$ ]]; then
340 INVALID_OPTIONS+=(${OPTARG})
341 fi
342 ;;
343 e)
344 EXTRA_TEST_OPTIONS=${OPTARG}
345 ;;
346 x)
347 PHP_XDEBUG_ON=1
348 ;;
349 y)
350 PHP_XDEBUG_PORT=${OPTARG}
351 ;;
352 o)
353 PHPUNIT_RANDOM="--random-order-seed=${OPTARG}"
354 ;;
355 n)
356 CGLCHECK_DRY_RUN="-n"
357 ;;
358 h)
359 echo "${HELP}"
360 exit 0
361 ;;
362 u)
363 TEST_SUITE=update
364 ;;
365 v)
366 SCRIPT_VERBOSE=1
367 ;;
368 \?)
369 INVALID_OPTIONS+=(${OPTARG})
370 ;;
371 :)
372 INVALID_OPTIONS+=(${OPTARG})
373 ;;
374 esac
375 done
376
377 # Exit on invalid options
378 if [ ${#INVALID_OPTIONS[@]} -ne 0 ]; then
379 echo "Invalid option(s):" >&2
380 for I in "${INVALID_OPTIONS[@]}"; do
381 echo "-"${I} >&2
382 done
383 echo >&2
384 echo "call \".Build/Scripts/runTests.sh -h\" to display help and valid options"
385 exit 1
386 fi
387
388 # Move "7.4" to "php74", the latter is the docker container name
389 DOCKER_PHP_IMAGE=`echo "php${PHP_VERSION}" | sed -e 's/\.//'`
390
391 # Some scripts rely on a proper /etc/passwd that includes the user that runs the
392 # containers, for instance to determine users $HOME. yarn v1 is espcecially picky
393 # here since it fails if it can't write a .yarnrc file to users home ...
394 # MacOS in it's endless wisdom however decided that /etc/passwd is a stupid thing
395 # and does not write an entry for the standard user in it. In turn, stuff like yarn fails.
396 # As a solution, we detect if the user executing the script is within /etc/passwd
397 # and volume mount that file within containers. If not, we create a fake passwd file
398 # and mount that one.
399 [ -z ${USER} ] && USER=`id -u -n`
400 if [ `grep -c "^${USER}:" /etc/passwd` -ne 1 ]; then
401 echo "${USER}:x:$(id -u $USER):$(id -g $USER):$(id -gn $USER):${HOME}:/bin/bash" > macos_passwd
402 PASSWD_PATH="./macos_passwd"
403 fi
404
405 # Set $1 to first mass argument, this is the optional test file or test directory to execute
406 shift $((OPTIND - 1))
407 TEST_FILE=${1}
408
409 if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
410 set -x
411 fi
412
413 # Suite execution
414 case ${TEST_SUITE} in
415 acceptance)
416 handleDbmsAndDriverOptions
417 setUpDockerComposeDotEnv
418 if [ ${CHUNKS} -gt 1 ]; then
419 docker-compose run acceptance_split
420 fi
421 case ${DBMS} in
422 mysql)
423 echo "Using driver: ${DATABASE_DRIVER}"
424 docker-compose run prepare_acceptance_backend_mysql
425 docker-compose run acceptance_backend_mysql
426 SUITE_EXIT_CODE=$?
427 ;;
428 mariadb)
429 echo "Using driver: ${DATABASE_DRIVER}"
430 docker-compose run prepare_acceptance_backend_mariadb
431 docker-compose run acceptance_backend_mariadb
432 SUITE_EXIT_CODE=$?
433 ;;
434 postgres)
435 docker-compose run prepare_acceptance_backend_postgres
436 docker-compose run acceptance_backend_postgres
437 SUITE_EXIT_CODE=$?
438 ;;
439 *)
440 echo "Acceptance tests don't run with DBMS ${DBMS}" >&2
441 echo >&2
442 echo "call \".Build/Scripts/runTests.sh -h\" to display help and valid options" >&2
443 exit 1
444 esac
445 docker-compose down
446 ;;
447 buildCss)
448 setUpDockerComposeDotEnv
449 docker-compose run build_css
450 SUITE_EXIT_CODE=$?
451 docker-compose down
452 ;;
453 buildJavascript)
454 setUpDockerComposeDotEnv
455 docker-compose run build_javascript
456 SUITE_EXIT_CODE=$?
457 docker-compose down
458 ;;
459 cglGit)
460 setUpDockerComposeDotEnv
461 docker-compose run cgl_git
462 SUITE_EXIT_CODE=$?
463 docker-compose down
464 ;;
465 cglAll)
466 # Active dry-run for cglAll needs not "-n" but specific options
467 if [[ ! -z ${CGLCHECK_DRY_RUN} ]]; then
468 CGLCHECK_DRY_RUN="--dry-run --diff --diff-format udiff"
469 fi
470 setUpDockerComposeDotEnv
471 docker-compose run cgl_all
472 SUITE_EXIT_CODE=$?
473 docker-compose down
474 ;;
475 checkAnnotations)
476 setUpDockerComposeDotEnv
477 docker-compose run check_annotations
478 SUITE_EXIT_CODE=$?
479 docker-compose down
480 ;;
481 checkBom)
482 setUpDockerComposeDotEnv
483 docker-compose run check_bom
484 SUITE_EXIT_CODE=$?
485 docker-compose down
486 ;;
487 checkComposer)
488 setUpDockerComposeDotEnv
489 docker-compose run check_composer
490 SUITE_EXIT_CODE=$?
491 docker-compose down
492 ;;
493 checkCsvFixtures)
494 setUpDockerComposeDotEnv
495 docker-compose run check_csv_fixtures
496 SUITE_EXIT_CODE=$?
497 docker-compose down
498 ;;
499 checkExceptionCodes)
500 setUpDockerComposeDotEnv
501 docker-compose run check_exception_codes
502 SUITE_EXIT_CODE=$?
503 docker-compose down
504 ;;
505 checkExtensionScannerRst)
506 setUpDockerComposeDotEnv
507 docker-compose run check_extension_scanner_rst
508 SUITE_EXIT_CODE=$?
509 docker-compose down
510 ;;
511 checkFilePathLength)
512 setUpDockerComposeDotEnv
513 docker-compose run check_file_path_length
514 SUITE_EXIT_CODE=$?
515 docker-compose down
516 ;;
517 checkGitSubmodule)
518 setUpDockerComposeDotEnv
519 docker-compose run check_git_submodule
520 SUITE_EXIT_CODE=$?
521 docker-compose down
522 ;;
523 checkGruntClean)
524 setUpDockerComposeDotEnv
525 docker-compose run check_grunt_clean
526 SUITE_EXIT_CODE=$?
527 docker-compose down
528 ;;
529 checkPermissions)
530 setUpDockerComposeDotEnv
531 docker-compose run check_permissions
532 SUITE_EXIT_CODE=$?
533 docker-compose down
534 ;;
535 checkRst)
536 setUpDockerComposeDotEnv
537 docker-compose run check_rst
538 SUITE_EXIT_CODE=$?
539 docker-compose down
540 ;;
541 composerInstall)
542 setUpDockerComposeDotEnv
543 docker-compose run composer_install
544 SUITE_EXIT_CODE=$?
545 docker-compose down
546 ;;
547 composerInstallMax)
548 setUpDockerComposeDotEnv
549 docker-compose run composer_install_max
550 SUITE_EXIT_CODE=$?
551 docker-compose down
552 ;;
553 composerInstallMin)
554 setUpDockerComposeDotEnv
555 docker-compose run composer_install_min
556 SUITE_EXIT_CODE=$?
557 docker-compose down
558 ;;
559 composerValidate)
560 setUpDockerComposeDotEnv
561 docker-compose run composer_validate
562 SUITE_EXIT_CODE=$?
563 docker-compose down
564 ;;
565 docBlockCheck)
566 setUpDockerComposeDotEnv
567 docker-compose run doc_block_check
568 SUITE_EXIT_CODE=$?
569 docker-compose down
570 ;;
571 fixCsvFixtures)
572 setUpDockerComposeDotEnv
573 docker-compose run fix_csv_fixtures
574 SUITE_EXIT_CODE=$?
575 docker-compose down
576 ;;
577 functional)
578 handleDbmsAndDriverOptions
579 setUpDockerComposeDotEnv
580 if [ ${CHUNKS} -gt 1 ]; then
581 docker-compose run functional_split
582 fi
583 case ${DBMS} in
584 mariadb)
585 echo "Using driver: ${DATABASE_DRIVER}"
586 docker-compose run prepare_functional_mariadb
587 docker-compose run functional_mariadb
588 SUITE_EXIT_CODE=$?
589 ;;
590 mysql)
591 echo "Using driver: ${DATABASE_DRIVER}"
592 docker-compose run prepare_functional_mysql
593 docker-compose run functional_mysql
594 SUITE_EXIT_CODE=$?
595 ;;
596 mssql)
597 echo "Using driver: ${DATABASE_DRIVER}"
598 docker-compose run prepare_functional_mssql2019latest
599 docker-compose run functional_mssql2019latest
600 SUITE_EXIT_CODE=$?
601 ;;
602 postgres)
603 docker-compose run prepare_functional_postgres
604 docker-compose run functional_postgres
605 SUITE_EXIT_CODE=$?
606 ;;
607 sqlite)
608 docker-compose run prepare_functional_sqlite
609 docker-compose run functional_sqlite
610 SUITE_EXIT_CODE=$?
611 ;;
612 *)
613 echo "Functional tests don't run with DBMS ${DBMS}" >&2
614 echo >&2
615 echo "call \".Build/Scripts/runTests.sh -h\" to display help and valid options" >&2
616 exit 1
617 esac
618 docker-compose down
619 ;;
620 install)
621 handleDbmsAndDriverOptions
622 setUpDockerComposeDotEnv
623 case ${DBMS} in
624 mysql)
625 echo "Using driver: ${DATABASE_DRIVER}"
626 docker-compose run prepare_acceptance_install_mysql
627 docker-compose run acceptance_install_mysql
628 SUITE_EXIT_CODE=$?
629 ;;
630 mariadb)
631 echo "Using driver: ${DATABASE_DRIVER}"
632 docker-compose run prepare_acceptance_install_mariadb
633 docker-compose run acceptance_install_mariadb
634 SUITE_EXIT_CODE=$?
635 ;;
636 postgres)
637 docker-compose run prepare_acceptance_install_postgres
638 docker-compose run acceptance_install_postgres
639 SUITE_EXIT_CODE=$?
640 ;;
641 sqlite)
642 docker-compose run prepare_acceptance_install_sqlite
643 docker-compose run acceptance_install_sqlite
644 SUITE_EXIT_CODE=$?
645 ;;
646 *)
647 echo "Install tests don't run with DBMS ${DBMS}" >&2
648 echo >&2
649 echo "call \".Build/Scripts/runTests.sh -h\" to display help and valid options" >&2
650 exit 1
651 esac
652 docker-compose down
653 ;;
654 lint)
655 setUpDockerComposeDotEnv
656 docker-compose run lint_php
657 SUITE_EXIT_CODE=$?
658 docker-compose down
659 ;;
660 lintScss)
661 setUpDockerComposeDotEnv
662 docker-compose run lint_scss
663 SUITE_EXIT_CODE=$?
664 docker-compose down
665 ;;
666 lintTypescript)
667 setUpDockerComposeDotEnv
668 docker-compose run lint_typescript
669 SUITE_EXIT_CODE=$?
670 docker-compose down
671 ;;
672 lintHtml)
673 setUpDockerComposeDotEnv
674 docker-compose run lint_html
675 SUITE_EXIT_CODE=$?
676 docker-compose down
677 ;;
678 listExceptionCodes)
679 setUpDockerComposeDotEnv
680 docker-compose run list_exception_codes
681 SUITE_EXIT_CODE=$?
682 docker-compose down
683 ;;
684 phpstan)
685 setUpDockerComposeDotEnv
686 docker-compose run phpstan
687 SUITE_EXIT_CODE=$?
688 docker-compose down
689 ;;
690 unit)
691 setUpDockerComposeDotEnv
692 docker-compose run unit
693 SUITE_EXIT_CODE=$?
694 docker-compose down
695 ;;
696 unitDeprecated)
697 setUpDockerComposeDotEnv
698 docker-compose run unitDeprecated
699 SUITE_EXIT_CODE=$?
700 docker-compose down
701 ;;
702 unitJavascript)
703 setUpDockerComposeDotEnv
704 docker-compose run unitJavascript
705 SUITE_EXIT_CODE=$?
706 docker-compose down
707 ;;
708 unitRandom)
709 setUpDockerComposeDotEnv
710 docker-compose run unitRandom
711 SUITE_EXIT_CODE=$?
712 docker-compose down
713 ;;
714 update)
715 # pull typo3/core-testing-*:latest versions of those ones that exist locally
716 docker images typo3/core-testing-*:latest --format "{{.Repository}}:latest" | xargs -I {} docker pull {}
717 # remove "dangling" typo3/core-testing-* images (those tagged as <none>)
718 docker images typo3/core-testing-* --filter "dangling=true" --format "{{.ID}}" | xargs -I {} docker rmi {}
719 ;;
720 *)
721 echo "Invalid -s option argument ${TEST_SUITE}" >&2
722 echo >&2
723 echo "${HELP}" >&2
724 exit 1
725 esac
726
727 case ${DBMS} in
728 mariadb)
729 DBMS_OUTPUT="DBMS: ${DBMS} version ${MARIADB_VERSION} driver ${DATABASE_DRIVER}"
730 ;;
731 mysql)
732 DBMS_OUTPUT="DBMS: ${DBMS} version ${MYSQL_VERSION} driver ${DATABASE_DRIVER}"
733 ;;
734 mssql)
735 DBMS_OUTPUT="DBMS: ${DBMS} driver ${DATABASE_DRIVER}"
736 ;;
737 postgres)
738 DBMS_OUTPUT="DBMS: ${DBMS} version ${POSTGRES_VERSION}"
739 ;;
740 sqlite)
741 DBMS_OUTPUT="DBMS: ${DBMS}"
742 ;;
743 *)
744 DBMS_OUTPUT="DBMS not recognized: $DBMS"
745 exit 1
746 esac
747
748 # Print summary
749 if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
750 # Turn off verbose mode for the script summary
751 set +x
752 fi
753 echo "" >&2
754 echo "###########################################################################" >&2
755 if [[ ${TEST_SUITE} =~ ^(functional|install|acceptance)$ ]]; then
756 echo "Result of ${TEST_SUITE}" >&2
757 echo "PHP: ${PHP_VERSION}" >&2
758 echo "${DBMS_OUTPUT}" >&2
759 else
760 echo "Result of ${TEST_SUITE}" >&2
761 echo "PHP: ${PHP_VERSION}" >&2
762 fi
763
764 if [[ ${SUITE_EXIT_CODE} -eq 0 ]]; then
765 echo "SUCCESS" >&2
766 else
767 echo "FAILURE" >&2
768 fi
769 echo "###########################################################################" >&2
770 echo "" >&2
771
772 # Exit with code of test suite - This script return non-zero if the executed test failed.
773 exit $SUITE_EXIT_CODE