@@ -26,9 +26,6 @@ EMULATOR_NAME="swiftemu"
2626ANDROID_PROFILE=" Nexus 10"
2727ANDROID_EMULATOR_LAUNCH_TIMEOUT=300
2828
29- # FIXME: pass this in with an argument
30- PACKAGE=" TestPackage"
31-
3229install_package () {
3330 # Detect package manager
3431 if command -v apt > /dev/null 2>&1 ; then
@@ -135,30 +132,37 @@ nohup emulator -no-accel -no-metrics -partition-size 1024 -memory 4096 -avd "${E
135132log " Waiting for Android emulator startup"
136133timeout ${ANDROID_EMULATOR_LAUNCH_TIMEOUT} adb wait-for-any-device
137134
135+ log " Find libc++_shared.so"
136+ find / -name ' libc++_shared.so'
137+
138+ log " Prepare Swift test package"
139+
138140# create a staging folder where we copy the test executable
139141# and all the dependent libraries to copy over to the emulator
140- STAGING=" android-test- ${PACKAGE} "
142+ STAGING=" swift- android-test"
141143rm -rf .build/" ${STAGING} "
142144mkdir .build/" ${STAGING} "
143145
144- # for the common case of tests referencing their own files as hardwired resource paths
146+ # for the common case of tests referencing
147+ # their own files as hardwired resource paths
145148if [[ -d Tests ]]; then
146149 cp -a Tests .build/" ${STAGING} "
147150fi
148151
149- find ~ / -name libc++_shared.so
150-
151152cd .build/
152- cp -a debug/* .xctest " ${STAGING} "
153- cp -a debug/* .resources " ${STAGING} " || true
154- cp -a " ${ANDROID_NDK_HOME} " /toolchains/llvm/prebuilt/ * /sysroot/usr/lib/ " ${ANDROID_EMULATOR_ARCH_TRIPLE} " -linux-android/libc++_shared.so " ${STAGING} "
153+ TEST_PACKAGE= $( ls -1 debug/* .xctest | tail -n 1 | xargs basename )
154+ cp -a debug/" ${TEST_PACKAGE} " " ${STAGING} "
155+ find debug/ -name ' *.resources ' -exec cp -a {} " ${STAGING} " \;
155156cp -a " ${SWIFT_ANDROID_SDK_HOME} " /swift-android/swift-resources/usr/lib/swift-" ${ANDROID_EMULATOR_ARCH_TRIPLE} " /android/* .so " ${STAGING} "
157+ cp -a " ${ANDROID_NDK_HOME} " /toolchains/llvm/prebuilt/* /sysroot/usr/lib/" ${ANDROID_EMULATOR_ARCH_TRIPLE} " -linux-android/libc++_shared.so " ${STAGING} "
158+
159+ log " Copy Swift test package to emulator"
156160
157161adb push " ${STAGING} " /data/local/tmp/
158162
159163cd -
160164
161- TEST_CMD=" ./${PACKAGE} PackageTests.xctest "
165+ TEST_CMD=" ./${TEST_PACKAGE} "
162166TEST_SHELL=" cd /data/local/tmp/${STAGING} "
163167TEST_SHELL=" ${TEST_SHELL} && ${TEST_CMD} "
164168
@@ -168,6 +172,7 @@ TEST_SHELL="${TEST_SHELL} && ${TEST_CMD}"
168172# see: https://github.com/swiftlang/swift-package-manager/blob/1b593469e8ad3daf2cc10e798340bd2de68c402d/Sources/Commands/SwiftTestCommand.swift#L1542
169173TEST_SHELL=" ${TEST_SHELL} && ${TEST_CMD} --testing-library swift-testing && [ \$ ? -eq 0 ] || [ \$ ? -eq 69 ]"
170174
175+ log " Run Swift package tests"
176+
171177# run the test executable
172178adb shell " ${TEST_SHELL} "
173-
0 commit comments