-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrunUnitTest.sh
More file actions
executable file
·43 lines (37 loc) · 1.84 KB
/
Copy pathrunUnitTest.sh
File metadata and controls
executable file
·43 lines (37 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
# Stelle sicher, dass das Skript im Projekt-Root ausgeführt wird oder passe $(pwd) an
cd ~/projects/php/SL5_preg_contentFinder || exit # Stellt sicher, dass wir im richtigen Verzeichnis sind
echo "Running ALL PHPUnit tests (PHP, recursive). Displaying only summaries of failures and errors."
echo "=================================================================================================="
# -maxdepth 1 ENTFERNT, um rekursiv zu suchen
for testfile_relative in $(find tests/PHPUnit -name '*.php' ! -name 'PHPUnitAllTest_AutoCollected.php' ! -name 'create_1file_withAll_PHPUnit_tests.php')
do
echo "" # Leerzeile für bessere Lesbarkeit zwischen den Tests
echo "--- TESTING: $testfile_relative ---"
# Verwende das PHP 7.4 Image und den vendor/bin/phpunit Pfad
output=$(docker run --rm -v "$(pwd):/app" -w /app sl5-preg-contentfinder-php81-dev php vendor/bin/phpunit "$testfile_relative" 2>&1)
if echo "$output" | grep -E -q "FAILURES!|ERRORS!"; then
echo "!!! Found Failures/Errors in $testfile_relative !!!"
# Filter angepasst für PHPUnit 9.x Header
echo "$output" | \
sed -n -e '/There was .* failure:/,$p' \
-e '/There were .* failures:/,$p' \
-e '/There was .* error:/,$p' \
-e '/There were .* errors:/,$p' \
-e '/^FAILURES!/,$p' \
-e '/^ERRORS!/,$p' | \
sed -e '/^OK/d' \
-e '/Time: /d' \
-e '/Memory: /d' \
-e '/PHPUnit [0-9]\+\.[0-9]\+\.[0-9]\+ by Sebastian Bergmann and contributors\.$/d' \
-e '/^\s*\.*$/d' \
-e '/^$/d' \
-e '/^\s*$/d'
else
echo "OK - $testfile_relative" # Erfolg melden ist gut für die Übersicht
# : # Alternative: Nichts tun bei Erfolg
fi
done
echo ""
echo "=================================================================================================="
echo "All tests finished."