@@ -14,12 +14,13 @@ you a better understanding of testing within TYPO3's Core. A full Core git check
1414to run tests in TYPO3.
1515
1616Core development is most likely bound to the Core `main ` branch - backporting patches to older
17- branches are usually handled by Core maintainers and often don 't affect other Core contributors.
17+ branches is usually handled by Core maintainers ("Mergers") and often doesn 't affect other Core contributors.
1818
19- Note, the main script
20- `Build/Scripts/runTests.sh <https://github.com/typo3/typo3/blob/main/Build/Scripts/runTests.sh >`_
21- is relatively new. It works best when executed on a Linux based host but can be run under macOS and
22- Windows with some performance drawbacks on macOS.
19+ The main entry point to perform testing and build-related actions is the helper
20+ `Build/Scripts/runTests.sh <https://github.com/typo3/typo3/blob/main/Build/Scripts/runTests.sh >`_.
21+ It works best when executed on a Linux based host but can be run under macOS and
22+ Windows with some filesystem performance drawbacks on macOS. It utilizes Docker containers,
23+ and more details can be found in :ref: `Using runTests.sh <t3contribute:runTests_sh >`.
2324
2425Additionally, it *is * possible to execute tests on a local system without using Docker. Depending on
2526which test suite is executed, developers may need to configure their environments to run the
@@ -37,7 +38,7 @@ Many developers are familiar with `Docker <https://www.docker.com/>`_. As outlin
3738reliable environment to run tests and also remove the need to manage niche dependencies on your local
3839environment for tests such as "execute functional test 'X' using PostgreSQL with xdebug".
3940
40- Git, docker and docker-compose are all required. For standalone test execution, a local installation of
41+ Git and docker (or podman) are required. For standalone test execution, a local installation of
4142PHP is not required. You can even `composer install ` a Core by calling `Build/Scripts/runTests.sh -s
4243composerInstall ` in a container.
4344
@@ -57,7 +58,7 @@ Windows can rely on WSL to have a decent docker version, too.
5758Quick start
5859===========
5960
60- From now on, it is assumed that git, docker and docker-compose are available with the most up-to-date release
61+ From now on, it is assumed that git and docker (or podman) are available with the most up-to-date release
6162running on the host system. Executing the basic Core unit test suite boils down to:
6263
6364.. code-block :: shell
@@ -80,27 +81,25 @@ Overview
8081So what just happened? We cloned a Core, Composer installed dependencies and executed Core
8182unit tests. Let's have a look at some more details: :file: `runTests.sh ` is a shell script that figures out
8283which test suite with which options a user wants to execute, does some error handling for broken
83- combinations, writes the file `Build/testing-docker/local/.env ` according to its findings and then executes a
84- couple of `docker-compose ` commands to prepare containers, runs tests and stops containers after execution
85- again.
86-
87- A Core developer doing this for the first time may notice `docker-compose ` pulling several container images
88- before continuing. These are the dependent images needed to execute certain jobs. For instance the
89- container `typo3gmbh/php74 <https://hub.docker.com/r/typo3gmbh/php72/ >`_ may be fetched. Its definition
90- can be found at `TYPO3 GmbH GitHub <https://github.com/TYPO3GmbH/infra-bamboo-remote-agent >`_.
91- These are the exact same containers Bamboo based testing is executed in. In Bamboo, the combination of
92- :file: `Build/bamboo/src/main/java/core/PreMergeSpec.java ` and :file: `Build/testing-docker/bamboo/docker-compose.yml `
93- specifies what Bamboo executes for patches pushed to the review system. On local testing, this is the
94- combination of :file: `Build/Scripts/runTests.sh `, :file: `Build/testing-docker/local/.env ` (created by
95- runTests.sh) and
96- `Build/testing-docker/local/docker-compose.yml <https://github.com/typo3/typo3/blob/main/Build/testing-docker/local/docker-compose.yml >`_.
97-
98- Whats impressive is that :file: `runTests.sh ` can do everything locally that Bamboo executes as `pre-merge
99- <https://bamboo.typo3.com/browse/CORE-GTC> `_ tests at the same time. It's just that the combinations of tests
100- and splitting to different jobs is slightly different, for instance Bamboo does multiple tests in
101- the "integration" test at once that are single "check" suites in :file: `runTests.sh `. But if a patch is
102- pushed to Bamboo and it complains about something being broken, it is possible to replay and fix the
103- failing suite locally, then push an updated patch and hopefully enable the Bamboo test to pass.
84+ combinations and then uses local docker commands to run specific containers with specific options. Using
85+ these containers, the actions are performed, and the containers are stopped after execution.
86+
87+ A Core developer doing this for the first time may notice that several container images
88+ will be pulled before continuing. These are the dependent images needed to execute certain jobs. For instance,
89+ a container providing the specific PHP-version may be fetched. The same containers are used for the
90+ TYPO3 CI GitLab Pipeline, even utilizing the same `runTests.sh ` script. What's impressive is that
91+ you can locally run the same tests like a fully-fledged CI server..
92+
93+ The GitLab CI Pipeline is maintained through the Ansible infrastructure found on
94+ `https://git.typo3.org/typo3/CI/testing-infrastructure/-/tree/main/ansible?ref_type=heads `__, and the Pipeline
95+ itself is set up through `https://github.com/TYPO3/typo3/tree/main/Build/gitlab-ci/ `__.
96+
97+ Compared to your local execution it's just that the combinations of tests
98+ and splitting to different jobs which is slightly different, for instance GitLab CI paralelly performs multiple
99+ tests with more complex version matrixes (PHP and Databases).
100+
101+ If a patch is pushed to GitLab and it complains about something being broken, it is possible to replay and fix the
102+ failing suite locally, then push an updated patch and hopefully enable the tests to pass.
104103
105104
106105A runTests.sh run
@@ -111,37 +110,23 @@ Let's pick a :file:`runTests.sh` example and have a closer look:
111110.. code-block :: shell
112111
113112 lolli@apoc /var/www/local/cms/Web $ Build/Scripts/runTests.sh -s functional typo3/sysext/core/Tests/Functional/Authentication/
114- Using driver: mysqli
115- Creating network " local_default" with the default driver
116- Creating local_mariadb_1 ... done
117- Creating local_memcached1-5_1 ... done
118- Creating local_redis4_1 ... done
119- Creating local_prepare_functional_mariadb_run ... done
120- Waiting for database start...
121- Database is up
122- Creating local_functional_mariadb_run ... done
123- PHP 8.0.14 (cli) (built: Dec 18 2021 02:58:33) ( NTS )
124- PHPUnit 9.5.10 by Sebastian Bergmann and contributors.
125-
126- ........................................................ 56 / 56 (100%)
127-
128- Time: 00:24.864, Memory: 101.00 MB
129-
130- OK (56 tests, 162 assertions)
131- Stopping local_redis4_1 ... done
132- Stopping local_mariadb_1 ... done
133- Stopping local_memcached1-5_1 ... done
134- Removing local_functional_mariadb_run_d03a24bcf25c ... done
135- Removing local_prepare_functional_mariadb_run_4648d92e8e32 ... done
136- Removing local_redis4_1 ... done
137- Removing local_mariadb_1 ... done
138- Removing local_memcached1-5_1 ... done
139- Removing network local_default
113+ PHPUnit 11.2.5 by Sebastian Bergmann and contributors.
114+
115+ Runtime: PHP 8.2.19
116+ Configuration: /Users/garvin/TYPO3/typo3-core-bugreproduce-base/typo3-core/Build/phpunit/FunctionalTests.xml
117+
118+ ................................................................. 65 / 67 ( 97%)
119+ .. 67 / 67 (100%)
120+
121+ Time: 00:12.077, Memory: 103.00 MB
122+
123+ OK (67 tests, 176 assertions)
140124
141125 # ##########################################################################
142126 Result of functional
143- PHP: 8.0
144- DBMS: mariadb version 10.3 driver mysqli
127+ Container runtime: docker
128+ PHP: 8.2
129+ DBMS: sqlite
145130 SUCCESS
146131 # ##########################################################################
147132
@@ -152,11 +137,12 @@ Let's pick a :file:`runTests.sh` example and have a closer look:
152137
153138 The command asks :file: `runTests.sh ` to execute the "functional" test suite `-s functional ` and to not execute all
154139available tests but only those within `typo3/sysext/core/Tests/Functional/Authentication/ `. The script first
155- starts the containers it needs: Redis, memcached and a MariaDB. All in one network. It then waits until
156- the MariaDB container opens its database port, then starts a PHP 8.0 container and calls phpunit to execute
157- the tests. phpunit executes only one test in this case, that one is green. The containers and networks are then
158- removed again. Note the exit code of :file: `runTests.sh ` (`echo $? `) is identical to the exit code of the phpunit
159- call: If phpunit reports green, :file: `runTests.sh ` returns 0, and if phpunit is red, the exit code would be non zero.
140+ starts the containers it needs: Redis, memcached (previously also MariaDB by default, which is now using
141+ SQLite instead, due to less dependencies). All in one network. It then starts a PHP 8.2 container and calls
142+ phpunit from there to execute the tests. phpunit executes only one test in this case, that one is green. The containers
143+ and networks are then removed again. Note the exit code of :file: `runTests.sh ` (`echo $? `) is identical to the exit
144+ code of the phpunit call: If phpunit reports green, :file: `runTests.sh ` returns 0, and if phpunit is red, the exit code
145+ would be non zero.
160146
161147
162148.. _testing-core-examples :
@@ -172,7 +158,7 @@ are not valid:
172158
173159 lolli@apoc /var/www/local/cms/Web $ Build/Scripts/runTests.sh -h
174160 TYPO3 Core test runner. Execute acceptance, unit, functional and other test suites in
175- a docker based test environment. Handles execution of single test files, sending
161+ a container based test environment. Handles execution of single test files, sending
176162 xdebug information to a local IDE and more.
177163 ...
178164
@@ -181,14 +167,14 @@ tests, but there is more:
181167
182168.. code-block :: shell
183169
184- # Execute the unit test suite with PHP 7.4
185- Build/Scripts/runTests.sh -s unit -p 7.4
170+ # Execute the unit test suite with PHP 8.3
171+ Build/Scripts/runTests.sh -s unit -p 8.3
186172
187173 # Execute some backend acceptance tests
188174 Build/Scripts/runTests.sh -s acceptance typo3/sysext/core/Tests/Acceptance/Backend/Topbar/
189175
190- # Execute some functional tests with PHP 8.0 and postgres DBMS
191- Build/Scripts/runTests.sh -s functional -p 8.0 -d postgres typo3/sysext/core/Tests/Functional/Package/
176+ # Execute some functional tests with PHP 8.2 and postgres DBMS
177+ Build/Scripts/runTests.sh -s functional -p 8.2 -d postgres typo3/sysext/core/Tests/Functional/Package/
192178
193179 # Execute the cgl fixer
194180 Build/Scripts/runTests.sh -s cglGit
@@ -199,8 +185,11 @@ tests, but there is more:
199185 As shown there are various combinations available. Just go ahead, read the help output and play around.
200186There are tons of further test suites to try.
201187
202- One interesting detail should be mentioned: :file: `runTests.sh ` uses `typo3gmbh/phpXY <https://hub.docker.com/r/typo3gmbh/ >`_
203- as main PHP containers. Those are loosely maintained and may be updated. Use the command
188+ Also note that you can use the `-b ` option to switch between `docker ` and `podman ` container execution,
189+ with `podman ` being the default (when available).
190+
191+ One interesting detail should be mentioned: :file: `runTests.sh ` uses several containers from
192+ `https://github.com/orgs/TYPO3/packages `_ for PHP and JavaScript environments. Use the command
204193`Build/Scripts/runTests.sh -u ` to fetch the latest versions of these containers.
205194
206195.. index ::
@@ -216,9 +205,9 @@ To speed up test execution, the PHP extension `xdebug` is not usually loaded.
216205However, to allow debugging tests and system under tests, it is possible to
217206activate xdebug and send debug output to a local IDE. We'll use PhpStorm for this example.
218207
219- Let's verify our PhpStorm debug settings first. Go to File > Settings > Languages & Frameworks > PHP
220- > Debug. Make sure "Can accept external connections" is enabled, remember the port if it is not the
221- default port(9000) and also raise "Max. simultaneous connections" to two or three. Note remote debugging
208+ Let's verify our PhpStorm debug settings first. Go to :guilabel: ` File > Settings > Languages & Frameworks > PHP
209+ > Debug ` . Make sure "Can accept external connections" is enabled, remember the port if it is not the
210+ default port (9000) and also raise "Max. simultaneous connections" to two or three. Note remote debugging
222211may impose a security risk since everyone on the network can send debug streams to your host.
223212
224213.. figure :: PhpstormXdebugSettings.png
@@ -243,7 +232,7 @@ stops at this line and opens the debug window.
243232
244233.. code-block :: shell
245234
246- Build/Scripts/runTests.sh -x -s functional -p 7.4 -d postgres typo3/sysext/core/Tests/Functional/Package/RuntimeActivatedPackagesTest.php
235+ Build/Scripts/runTests.sh -x -s functional -p 8.1 -d postgres typo3/sysext/core/Tests/Functional/Package/RuntimeActivatedPackagesTest.php
247236
248237 The important flag here is `-x `! This is available for unit and functional testing. It enables xdebug
249238in the PHP container and sends all debug information to port 9000 of the host system. If a local PhpStorm
@@ -256,3 +245,23 @@ Additionally, it may be useful to activate "Break at first line in PHP scripts"
256245mounts the local path to the same location within the container, so path mapping is not needed. PhpStorm
257246also comes with a `guide <https://www.jetbrains.com/help/phpstorm/configuring-xdebug.html >`_ how to set up
258247debugging.
248+
249+ Building
250+ ========
251+
252+ Luckily, `runTests.sh ` also helps us to build JavaScript and CSS assets:
253+
254+ .. code-block :: shell
255+
256+ Build/Scripts/runTests.sh -s buildJavaScript
257+ Build/Scripts/runTests.sh -s buildCss
258+
259+ Again, this utilizes all the needed containers for the proper NodeJS environment, so you have
260+ zero local dependencies on properly building.
261+
262+ You can also run a watch task thanks to the full integration of npm command execution:
263+
264+ .. code-block :: shell
265+
266+ Build/Scripts/runTests.sh -s npm -- run watch
267+
0 commit comments