In #269, the Android build script dropped the --build-system native flag, so we will use whatever the default is for the current toolchain (which, as of 6.4, is 'swiftbuild'). That PR rightly handles the fact that the native build created test executables with the .xctest suffix, but the new swiftbuild created the binaries ending with -test-runner (as discussed at swiftlang/swift-package-manager#9673):
|
TEST_CMD="./*-test-runner" |
|
if ! find "${STAGING_DIR}" -name '*-test-runner' -maxdepth 1 | grep -q .; then |
|
TEST_CMD="./*.xctest" |
|
fi |
|
TEST_SHELL="cd ${ANDROID_TMP_FOLDER}" |
|
TEST_SHELL="${TEST_SHELL} && ${TEST_CMD} --testing-library xctest" |
|
|
|
# Run test cases a second time with the Swift Testing library |
|
# We additionally need to handle the special exit code |
|
# EXIT_NO_TESTS_FOUND (69 on Android), which can happen |
|
# when the tests link to Testing, but no tests are executed |
|
# see: https://github.com/swiftlang/swift-package-manager/blob/main/Sources/Commands/SwiftTestCommand.swift#L1571 |
|
TEST_SHELL="${TEST_SHELL} && ${TEST_CMD} --testing-library swift-testing && [ \$? -eq 0 ] || [ \$? -eq 69 ]" |
However, it doesn't take into account the fact that while native created a single monolithic test executable, swiftbuild appears to create a separate executable for each test target (@owenv confirm?)
For example, for the swift-numerics package:
native: .build/aarch64-unknown-linux-android28/debug/swift-numericsPackageTests.xctest
swiftbuild: .build/out/Products/Debug-android/ComplexTests-test-runner, .build/out/Products/Debug-android/RealTests-test-runner, .build/out/Products/Debug-android/IntegerUtilitiesTests-test-runner
This means that even if the test is being executed at all, it is likely only executing one of them. This may explain why swift-algorithms testing is passing with 6.3 Android, but failing with nightly-main Android.
Unless there is some hidden way to run all the tests as a single batch, I suspect that we'll need to have the action create a little script that executes each of the test executables, remembers the process result for each of them, and then passes/fails based on whether all of the individual tests passed. Something like:
# Run each of the test binaries, both in XCTest mode and Swift Testing mode
.build/out/Products/Debug-android/ComplexTests-test-runner; echo $? >> results.txt
.build/out/Products/Debug-android/ComplexTests-test-runner --testing-library xctest; echo $? >> results.txt
.build/out/Products/Debug-android/RealTests-test-runner; echo $? >> results.txt
.build/out/Products/Debug-android/RealTests-test-runner --testing-library xctest; echo $? >> results.txt
.build/out/Products/Debug-android/IntegerUtilitiesTests-test-runner; echo $? >> results.txt
.build/out/Products/Debug-android/IntegerUtilitiesTests-test-runner --testing-library xctest; echo $? >> results.txt
# grep for any non-0 non-69 values in results.txt and fail if any are found…
CC @swiftlang/android-workgroup as discussed at the workgroup meeting today
CC @dschaefer in case this is of interest for packaging and tooling (swiftlang/swift-package-manager#9940 (comment))
In #269, the Android build script dropped the
--build-system nativeflag, so we will use whatever the default is for the current toolchain (which, as of 6.4, is 'swiftbuild'). That PR rightly handles the fact that thenativebuild created test executables with the.xctestsuffix, but the newswiftbuildcreated the binaries ending with-test-runner(as discussed at swiftlang/swift-package-manager#9673):github-workflows/.github/workflows/scripts/android/android-emulator-tests.sh
Lines 163 to 175 in 0366eba
However, it doesn't take into account the fact that while
nativecreated a single monolithic test executable,swiftbuildappears to create a separate executable for each test target (@owenv confirm?)For example, for the
swift-numericspackage:native:
.build/aarch64-unknown-linux-android28/debug/swift-numericsPackageTests.xctestswiftbuild:
.build/out/Products/Debug-android/ComplexTests-test-runner,.build/out/Products/Debug-android/RealTests-test-runner,.build/out/Products/Debug-android/IntegerUtilitiesTests-test-runnerThis means that even if the test is being executed at all, it is likely only executing one of them. This may explain why
swift-algorithmstesting is passing with 6.3 Android, but failing with nightly-main Android.Unless there is some hidden way to run all the tests as a single batch, I suspect that we'll need to have the action create a little script that executes each of the test executables, remembers the process result for each of them, and then passes/fails based on whether all of the individual tests passed. Something like:
CC @swiftlang/android-workgroup as discussed at the workgroup meeting today
CC @dschaefer in case this is of interest for packaging and tooling (swiftlang/swift-package-manager#9940 (comment))