From 846e3930dfcac3f46803637438c3a90352b1b8dc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20B=C3=BCrk?= <stefan@buerk.tech>
Date: Sun, 10 Apr 2022 19:58:37 +0200
Subject: [PATCH] [TASK] Add runTest.sh -s clean to remove build related files
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Add script to 'Build/Scripts/runTests.sh' to clean build and
test related files and folders to get fast a clean state.
Local instance related files are untouched and kept intact.

Added commands:

> Build/Scripts/runTests.sh -s clean
> Build/Scripts/runTests.sh -s cleanBuild
> Build/Scripts/runTests.sh -s cleanCache
> Build/Scripts/runTests.sh -s cleanTests

Resolves: #97355
Releases: main, 11.5, 10.4
Change-Id: I05c9dd966f4703315474e369dad52b1a40881c60
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74400
Tested-by: core-ci <typo3@b13.com>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
---
 Build/Scripts/runTests.sh | 45 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/Build/Scripts/runTests.sh b/Build/Scripts/runTests.sh
index 3e834b2fbd92..02c84c2fb418 100755
--- a/Build/Scripts/runTests.sh
+++ b/Build/Scripts/runTests.sh
@@ -72,6 +72,33 @@ handleDbmsAndDriverOptions() {
     esac
 }
 
+cleanBuildFiles() {
+    # > builds
+    echo -n "Clean builds ... " ; rm -rf \
+        ../../../Build/JavaScript \
+        ../../../Build/node_modules ; \
+        echo "done"
+}
+
+cleanCacheFiles() {
+    # > caches
+    echo -n "Clean caches ... " ; rm -rf \
+        ../../../.cache \
+        ../../../Build/.cache \
+        ../../../Build/.phpunit.result.cache ; \
+        echo "done"
+}
+
+cleanTestFiles() {
+    # > test related
+    echo -n "Clean test related files ... " ; rm -rf \
+        ../../../Build/FunctionalTests-Job-*.xml \
+        ../../../typo3/sysext/core/Tests/Acceptance/AcceptanceTests-Job-* \
+        ../../../typo3/sysext/core/Tests/Acceptance/Support/_generated \
+        ../../../typo3temp/var/tests/ ; \
+        echo "done"
+}
+
 # Load help text into $HELP
 read -r -d '' HELP <<EOF
 TYPO3 core test runner. Execute acceptance, unit, functional and other test suites in
@@ -103,6 +130,10 @@ Options:
             - checkGruntClean: Verify "grunt build" is clean. Warning: Executes git commands! Usually used in CI only.
             - checkPermissions: test some core files for correct executable bits
             - checkRst: test .rst files for integrity
+            - clean: clean up build, cache and testing related files and folders
+            - cleanBuild: clean up build related files and folders
+            - cleanCache: clean up cache related files and folders
+            - cleanTests: clean up test related files and folders
             - composerInstall: "composer install"
             - composerInstallMax: "composer update", with no platform.php config.
             - composerInstallMin: "composer update --prefer-lowest", with platform.php set to PHP version x.x.0.
@@ -533,6 +564,20 @@ case ${TEST_SUITE} in
         SUITE_EXIT_CODE=$?
         docker-compose down
         ;;
+    clean)
+        cleanBuildFiles
+        cleanCacheFiles
+        cleanTestFiles
+        ;;
+    cleanBuild)
+        cleanBuildFiles
+        ;;
+    cleanCache)
+        cleanCacheFiles
+        ;;
+    cleanTests)
+        cleanTestFiles
+        ;;
     composerInstall)
         setUpDockerComposeDotEnv
         docker-compose run composer_install
-- 
GitLab