Skip to content

Commit cc568d2

Browse files
authored
Merge pull request swiftlang#22532 from drodriguez/enable-non-executable-android-tests
[android] Allow executing only Android compiler tests.
2 parents 31f3d51 + 9cec482 commit cc568d2

File tree

9 files changed

+70
-18
lines changed

9 files changed

+70
-18
lines changed

test/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,15 @@ foreach(SDK ${SWIFT_SDKS})
305305
set(test_mode_target_suffix "-${test_mode}")
306306
endif()
307307

308+
set(maybe_command_upload_stdlib)
309+
if(NOT test_mode STREQUAL "only_non_executable")
310+
set(maybe_command_upload_stdlib ${command_upload_stdlib})
311+
endif()
312+
308313
set(test_target_name
309314
"check-swift${test_subset_target_suffix}${test_mode_target_suffix}${VARIANT_SUFFIX}")
310315
add_custom_target("${test_target_name}"
311-
${command_upload_stdlib}
316+
${maybe_command_upload_stdlib}
312317
${command_upload_swift_reflection_test}
313318
${command_clean_test_results_dir}
314319
COMMAND

test/lit.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,8 @@ elif run_os == 'linux-androideabi' or run_os == 'linux-android':
10611061
tools_directory,
10621062
'-L%s' % make_path(test_resource_dir, config.target_sdk_name)])
10631063
# The Swift interpreter is not available when targeting Android.
1064-
config.available_features.remove('swift_interpreter')
1064+
if 'swift_interpreter' in config.available_features:
1065+
config.available_features.remove('swift_interpreter')
10651066

10661067
else:
10671068
lit_config.fatal("Don't know how to define target_run and "

utils/build-presets.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,8 @@ mixin-preset=
804804
[preset: buildbot_linux_crosscompile_android,tools=RA,stdlib=RD,build]
805805
mixin-preset=buildbot_linux
806806

807+
host-test
808+
807809
release
808810
assertions
809811
extra-cmake-options=-DSWIFT_ENABLE_LLD_LINKER:BOOL=OFF
@@ -819,6 +821,8 @@ android-icu-i18n=%(arm_dir)s/libicui18nswift.so
819821
android-icu-i18n-include=%(arm_dir)s/icu/source/i18n
820822
android-icu-data=%(arm_dir)s/libicudataswift.so
821823

824+
skip-test-linux
825+
822826
[preset: buildbot_linux_crosscompile_android,tools=RA,stdlib=RD,build,aarch64]
823827
mixin-preset=buildbot_linux_crosscompile_android,tools=RA,stdlib=RD,build
824828

utils/build-script

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,10 @@ class HostSpecificConfiguration(object):
137137
# For platforms which normally require a connected device to
138138
# test, the default behavior is to run tests that only require
139139
# the host (i.e., they do not attempt to execute).
140-
if deployment_platform.is_darwin and \
141-
deployment_platform.is_embedded and \
142-
not deployment_platform.is_simulator:
143-
if deployment_platform not in \
144-
invocation.platforms_to_skip_test_host:
145-
test_host_only = True
146-
test = True
147-
else:
148-
test = False
140+
if deployment_platform.uses_host_tests and \
141+
deployment_platform not in \
142+
invocation.platforms_to_skip_test_host:
143+
test_host_only = True
149144

150145
name = deployment_target.name
151146

@@ -181,7 +176,7 @@ class HostSpecificConfiguration(object):
181176
"check-swift-benchmark-{}-external".format(name))
182177
if test:
183178
if test_host_only:
184-
suffix = "-non-executable"
179+
suffix = "-only_non_executable"
185180
else:
186181
suffix = ""
187182
subset_suffix = ""
@@ -407,11 +402,13 @@ class BuildScriptInvocation(object):
407402
if not args.test_watchos_simulator:
408403
self.platforms_to_skip_test.add(
409404
StdlibDeploymentTarget.AppleWatchSimulator)
410-
411-
if not args.test_android_host:
405+
if not args.test_android:
412406
self.platforms_to_skip_test.add(StdlibDeploymentTarget.Android)
413407

414408
self.platforms_to_skip_test_host = set()
409+
if not args.test_android_host:
410+
self.platforms_to_skip_test_host.add(
411+
StdlibDeploymentTarget.Android)
415412
if not args.test_ios_host:
416413
self.platforms_to_skip_test_host.add(StdlibDeploymentTarget.iOS)
417414
if not args.test_tvos_host:
@@ -709,6 +706,8 @@ class BuildScriptInvocation(object):
709706
impl_args += ["--skip-test-watchos-host"]
710707
if not args.test_watchos_simulator:
711708
impl_args += ["--skip-test-watchos-simulator"]
709+
if not args.test_android:
710+
impl_args += ["--skip-test-android"]
712711
if not args.test_android_host:
713712
impl_args += ["--skip-test-android-host"]
714713
if args.build_runtime_with_host_compiler:

utils/build-script-impl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ KNOWN_SETTINGS=(
166166
skip-test-tvos-host "" "set to skip testing the host parts of the tvOS toolchain"
167167
skip-test-watchos-simulator "" "set to skip testing Swift stdlibs for Apple watchOS simulators (i.e. test devices only)"
168168
skip-test-watchos-host "" "set to skip testing the host parts of the watchOS toolchain"
169+
skip-test-android "" "set to skip testing Swift stdlibs for Android"
169170
skip-test-android-host "" "set to skip testing the host parts of the Android toolchain"
170171
validation-test "0" "set to run the validation test suite"
171172
long-test "0" "set to run the long test suite"
@@ -1435,7 +1436,11 @@ function calculate_targets_for_host() {
14351436
android-*)
14361437
swift_sdk="ANDROID"
14371438
build_for_this_target=$(not ${SKIP_BUILD_ANDROID})
1438-
test_this_target=$(not ${SKIP_TEST_ANDROID_HOST})
1439+
if [[ ! "${SKIP_TEST_ANDROID_HOST}" ]] ; then
1440+
test_host_only=1
1441+
else
1442+
test_this_target=$(not ${SKIP_TEST_ANDROID})
1443+
fi
14391444
;;
14401445
*)
14411446
echo "Unknown compiler deployment target: ${stdlib_deployment_target}"
@@ -1476,7 +1481,7 @@ function calculate_targets_for_host() {
14761481
if [[ "${test_this_target}" ]] && [[ "${is_in_build_list}" ]]; then
14771482
test_target_suffix=""
14781483
if [[ -n "${test_host_only}" ]] ; then
1479-
test_target_suffix="-non-executable"
1484+
test_target_suffix="-only_non_executable"
14801485
fi
14811486

14821487
test_subset_target_suffix=""

utils/build_swift/driver_arguments.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ def _apply_default_arguments(args):
202202
args.test_ios = False
203203
args.test_tvos = False
204204
args.test_watchos = False
205+
args.test_android = False
205206
args.test_indexstoredb = False
206207
args.test_sourcekitlsp = False
207208

@@ -237,6 +238,10 @@ def _apply_default_arguments(args):
237238
args.test_watchos_simulator = False
238239

239240
if not args.build_android:
241+
args.test_android = False
242+
args.test_android_host = False
243+
244+
if not args.test_android:
240245
args.test_android_host = False
241246

242247
if not args.host_test:
@@ -899,6 +904,9 @@ def create_argument_parser():
899904
help='skip testing watchOS device targets on the host machine (the '
900905
'watch itself)')
901906

907+
option('--skip-test-android',
908+
toggle_false('test_android'),
909+
help='skip testing all Android targets.')
902910
option('--skip-test-android-host',
903911
toggle_false('test_android_host'),
904912
help='skip testing Android device targets on the host machine (the '

utils/build_swift/tests/expected_options.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@
174174
'swift_user_visible_version': defaults.SWIFT_USER_VISIBLE_VERSION,
175175
'symbols_package': None,
176176
'test': None,
177+
'test_android': False,
177178
'test_android_host': False,
178179
'test_cygwin': False,
179180
'test_freebsd': False,
@@ -479,6 +480,7 @@ class IgnoreOption(_BaseOption):
479480
dest='build_watchos_device'),
480481
DisableOption('--skip-build-watchos-simulator',
481482
dest='build_watchos_simulator'),
483+
DisableOption('--skip-test-android', dest='test_android'),
482484
DisableOption('--skip-test-android-host', dest='test_android_host'),
483485
DisableOption('--skip-test-cygwin', dest='test_cygwin'),
484486
DisableOption('--skip-test-freebsd', dest='test_freebsd'),

utils/run-test

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ def main():
202202
upload_stdlib_targets = []
203203
need_validation = any('/validation-test-' in path for path in paths)
204204
for target in targets:
205-
upload_stdlib_targets += ["upload-stdlib-%s" % target]
205+
if args.mode != 'only_non_executable':
206+
upload_stdlib_targets += ["upload-stdlib-%s" % target]
206207
if need_validation:
207208
dependency_targets += ["swift-stdlib-%s" % target]
208209
else:

utils/swift_build_support/swift_build_support/targets.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ def supports_benchmark(self):
4242
# By default, we don't support benchmarks on most platforms.
4343
return False
4444

45+
@property
46+
def uses_host_tests(self):
47+
"""
48+
Check if this is a Darwin platform that needs a connected device
49+
for tests.
50+
"""
51+
# By default, we don't use connected devices on most platforms.
52+
return False
53+
4554
def contains(self, target_name):
4655
"""
4756
Returns True if the given target name belongs to a one of this
@@ -69,6 +78,24 @@ def supports_benchmark(self):
6978
# platforms.
7079
return not self.is_simulator
7180

81+
@property
82+
def uses_host_tests(self):
83+
"""
84+
Check if this is a Darwin platform that needs a connected device
85+
for tests.
86+
"""
87+
return self.is_embedded and not self.is_simulator
88+
89+
90+
class AndroidPlatform(Platform):
91+
@property
92+
def uses_host_tests(self):
93+
"""
94+
Check if this is a Darwin platform that needs a connected device
95+
for tests.
96+
"""
97+
return True
98+
7299

73100
class Target(object):
74101
"""
@@ -125,7 +152,7 @@ class StdlibDeploymentTarget(object):
125152

126153
Cygwin = Platform("cygwin", archs=["x86_64"])
127154

128-
Android = Platform("android", archs=["armv7", "aarch64"])
155+
Android = AndroidPlatform("android", archs=["armv7", "aarch64"])
129156

130157
Windows = Platform("windows", archs=["x86_64"])
131158

0 commit comments

Comments
 (0)