Skip to content

Commit 389800e

Browse files
committed
Only run with --testing-library swift-testing if the command links to the Testing library
1 parent 1757c12 commit 389800e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

action.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,18 @@ runs:
363363
echo "adb push ${TEST_BASE_FOLDER} ${REMOTE_FOLDER}" >> ${SCRIPT_FILE}
364364
for XCTEST in ${TEST_BASE_FOLDER}/*.xctest; do
365365
XCTEST_BASE=$(basename "${XCTEST}")
366-
echo "adb shell 'cd ${REMOTE_FOLDER}/${TEST_BASE_FOLDER} && ${{ inputs.test-env }} ./${XCTEST_BASE} ${{ inputs.swift-test-flags }} && ${{ inputs.test-env }} ./${XCTEST_BASE} ${{ inputs.swift-test-flags }} --testing-library swift-testing'" >> ${SCRIPT_FILE}
366+
TEST_CMD="${{ inputs.test-env }} ./${XCTEST_BASE} ${{ inputs.swift-test-flags }}"
367+
368+
TEST_SHELL="cd ${REMOTE_FOLDER}/${TEST_BASE_FOLDER}"
369+
TEST_SHELL="${TEST_SHELL} && ${TEST_CMD}"
370+
if [[ "${{ steps.setup.outputs.swift-version }}" != 6.0* ]]; then
371+
# for SDKs that support it (i.e., 6.1+), add another invocation using the swift-testing library
372+
# see https://github.com/swiftlang/swift-package-manager/issues/8362#issuecomment-2719116854
373+
# but only do it when the command links to the Testing library, otherwise it will fail with the error:
374+
# Error: Invalid option "--testing-library"
375+
patchelf --print-needed ${XCTEST} | grep libTesting.so && TEST_SHELL="${TEST_SHELL} && ${TEST_CMD} --testing-library swift-testing" || true
376+
fi
377+
echo "adb shell '${TEST_SHELL}'" >> ${SCRIPT_FILE}
367378
done
368379
369380
# ensure the emulator stops when we are done

0 commit comments

Comments
 (0)