Add conditional module: JUnit conditional test execution on 6.1.3 (JDK 25)
Fixtures for the OS, JRE, system property, environment variable and EnabledIf conditions plus a custom ExecutionCondition, run through the JUnit Platform launcher (in-process and in child JVMs) to capture real skip reasons; skipped versus aborted lifecycle; stacking, class-level skips and the deactivate switch; the 2025 article's code compiled as published; and a javap comparison of the condition package in 5.14.4 and 6.1.3. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01G8ikz8xdWuTP5yun8DZ1hk
This commit is contained in:
Executable
+70
@@ -0,0 +1,70 @@
|
||||
#!/usr/bin/env bash
|
||||
# Compiles the 2025 article's code blocks exactly as published (src/old/), and compares the
|
||||
# org.junit.jupiter.api.condition package between the last JUnit 5 release and 6.1.3.
|
||||
# Writes output/08-old-code-vs-junit-6.txt and output/09-api-5-vs-6.txt.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
mkdir -p output target/old target/cmp
|
||||
mvn -q -B dependency:build-classpath -Dmdep.outputFile=target/cp.txt >/dev/null 2>&1
|
||||
CP=$(cat target/cp.txt)
|
||||
|
||||
{
|
||||
echo "# The 2025 article's code blocks, compiled exactly as published, against JUnit Jupiter 6.1.3 on JDK $(java -version 2>&1 | grep -o '"[^"]*"' | head -1 | tr -d '"')"
|
||||
echo
|
||||
for f in src/old/*.java; do
|
||||
name=$(basename "$f" .java)
|
||||
rm -rf target/old/out && mkdir -p target/old/out
|
||||
if err=$(javac --release 25 -proc:none -cp "$CP" -d target/old/out "$f" 2>&1); then
|
||||
echo "$name: compiles"
|
||||
else
|
||||
echo "$name: DOES NOT COMPILE"
|
||||
echo "$err" | grep -E "error|symbol|location" | sed 's/^/ /'
|
||||
fi
|
||||
done
|
||||
} > output/08-old-code-vs-junit-6.txt
|
||||
cat output/08-old-code-vs-junit-6.txt
|
||||
|
||||
V5=5.14.4
|
||||
V6=6.1.3
|
||||
fetch() { # version -> target/cmp/api-<version>.jar, retrying while Maven Central answers 429
|
||||
local v=$1 code
|
||||
if unzip -tq target/cmp/api-$v.jar >/dev/null 2>&1; then return; fi
|
||||
for try in 1 2 3 4 5 6; do
|
||||
code=$(curl -s -o target/cmp/api-$v.jar -w '%{http_code}' \
|
||||
"https://repo1.maven.org/maven2/org/junit/jupiter/junit-jupiter-api/$v/junit-jupiter-api-$v.jar" || echo 000)
|
||||
[ "$code" = "200" ] && return
|
||||
sleep $((try * 8))
|
||||
done
|
||||
echo "could not download junit-jupiter-api $v (HTTP $code)" >&2; exit 1
|
||||
}
|
||||
fetch $V5
|
||||
fetch $V6
|
||||
pkg=org/junit/jupiter/api/condition
|
||||
{
|
||||
echo "# $pkg in junit-jupiter-api $V5 (last JUnit 5 release on Maven Central) and $V6"
|
||||
echo
|
||||
for v in $V5 $V6; do
|
||||
major=$(javap -v -cp target/cmp/api-$v.jar org.junit.jupiter.api.condition.EnabledOnOs 2>/dev/null | grep "major version" | awk '{print $3}')
|
||||
echo "class file major version of EnabledOnOs in $v: $major (52 = Java 8, 61 = Java 17)"
|
||||
done
|
||||
echo
|
||||
for v in $V5 $V6; do unzip -l target/cmp/api-$v.jar | grep "$pkg/" | awk '{print $4}' | sort > target/cmp/cls-$v.txt; done
|
||||
echo "classes in the package: $(wc -l < target/cmp/cls-$V5.txt) in $V5, $(wc -l < target/cmp/cls-$V6.txt) in $V6"
|
||||
echo "classes only in $V6: $(comm -13 target/cmp/cls-$V5.txt target/cmp/cls-$V6.txt | tr '\n' ' ')"
|
||||
echo "classes only in $V5: $(comm -23 target/cmp/cls-$V5.txt target/cmp/cls-$V6.txt | tr '\n' ' ')"
|
||||
echo
|
||||
same=0; changed=""
|
||||
for c in $(comm -12 target/cmp/cls-$V5.txt target/cmp/cls-$V6.txt | sed 's/\.class$//;s#/#.#g'); do
|
||||
a=$({ javap -cp target/cmp/api-$V5.jar "$c" 2>&1 || true; } | grep -v Picked | md5sum || true)
|
||||
b=$({ javap -cp target/cmp/api-$V6.jar "$c" 2>&1 || true; } | grep -v Picked | md5sum || true)
|
||||
if [ "$a" = "$b" ]; then same=$((same+1)); else changed="$changed $c"; fi
|
||||
done
|
||||
echo "classes with an identical public and protected signature (javap): $same"
|
||||
echo "classes whose signature differs:${changed:- none}"
|
||||
for c in $changed; do
|
||||
echo
|
||||
echo "diff of javap $c ($V5 -> $V6):"
|
||||
diff <(javap -cp target/cmp/api-$V5.jar "$c" 2>&1 | { grep -v Picked || true; }) <(javap -cp target/cmp/api-$V6.jar "$c" 2>&1 | { grep -v Picked || true; }) | sed 's/^/ /' || true
|
||||
done
|
||||
} > output/09-api-5-vs-6.txt
|
||||
cat output/09-api-5-vs-6.txt
|
||||
Reference in New Issue
Block a user