Skip to content

Commit 76da81b

Browse files
authored
fix(nx): exclude abstract test base classes from phpunit.xml.dist at setup time (#381)
PHPUnit 12 emits a runner warning for every abstract class whose filename ends in Test.php, causing exit code 2 which Nx treats as failure even when all real tests pass. At setup time, use find to discover all Abstract*Test.php / *AbstractTest.php files in the testsuite directory and inject <exclude> entries into phpunit.xml.dist for the Magento Integration Tests Real Suite. This mirrors the find-based filter added to the full-suite workflow in #375. The patched phpunit.xml.dist is included in the project cache so all matrix runners pick it up without repeating the work.
1 parent 84d1462 commit 76da81b

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

nx-integration-tests-setup/action.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,35 @@ runs:
111111
nx print-affected --head=HEAD --base=remotes/origin/${{ inputs.pr_base }} > ${AFFECTED_OUTPUT}
112112
echo "Affected Projects: $(jq .projects ${AFFECTED_OUTPUT})"
113113
114+
- name: Exclude abstract test base classes from phpunit.xml.dist
115+
working-directory: ./main
116+
shell: bash
117+
run: |
118+
# PHPUnit 12 emits a runner warning for abstract classes whose filename ends
119+
# in Test.php, producing exit code 2 which Nx treats as failure.
120+
# Mirror the find-based filter from the full-suite workflow (see PR #375).
121+
PHPUNIT_CONFIG=dev/tests/integration/phpunit.xml.dist
122+
TMPFILE=$(mktemp)
123+
124+
find dev/tests/integration/testsuite -type f \
125+
\( -name 'Abstract*Test.php' -o -name '*AbstractTest.php' \) \
126+
-print0 | sort -z | while IFS= read -r -d '' file; do
127+
rel="${file#dev/tests/integration/}"
128+
printf ' <exclude>%s</exclude>\n' "${rel}"
129+
done > "${TMPFILE}"
130+
131+
awk -v excludes="${TMPFILE}" '
132+
/Magento Integration Tests Real Suite/ { in_suite=1 }
133+
in_suite && /<\/testsuite>/ {
134+
while ((getline line < excludes) > 0) print line
135+
in_suite=0
136+
}
137+
{ print }
138+
' "${PHPUNIT_CONFIG}" > "${PHPUNIT_CONFIG}.tmp" \
139+
&& mv "${PHPUNIT_CONFIG}.tmp" "${PHPUNIT_CONFIG}"
140+
141+
rm "${TMPFILE}"
142+
114143
- name: Project Cache
115144
uses: actions/cache/save@v3
116145
with:

0 commit comments

Comments
 (0)