Skip to content

Commit 5f0ccca

Browse files
authored
Merge pull request swiftlang#29991 from apple/add-flag-non-executable-test
[Build System] Add support to execute non-executable tests (30308095)
2 parents 52bf957 + 5a4d290 commit 5f0ccca

File tree

5 files changed

+60
-9
lines changed

5 files changed

+60
-9
lines changed

utils/build-presets.ini

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,14 @@ skip-test-ios-host
175175
skip-test-tvos-host
176176
skip-test-watchos-host
177177

178+
179+
[preset: buildbot,tools=RA,stdlib=DA,test=non_executable]
180+
mixin-preset=
181+
mixin_buildbot_tools_RA_stdlib_DA
182+
183+
only-non-executable-test
184+
185+
178186
[preset: buildbot,tools=RA,stdlib=RD]
179187
mixin-preset=
180188
mixin_buildbot_tools_RA_stdlib_RD
@@ -187,6 +195,14 @@ skip-test-ios-host
187195
skip-test-tvos-host
188196
skip-test-watchos-host
189197

198+
199+
[preset: buildbot,tools=RA,stdlib=RD,test=non_executable]
200+
mixin-preset=
201+
mixin_buildbot_tools_RA_stdlib_RD
202+
203+
only-non-executable-test
204+
205+
190206
[preset: buildbot,tools=RA,stdlib=RD,single-thread]
191207
mixin-preset=
192208
mixin_buildbot_tools_RA_stdlib_RD
@@ -215,6 +231,11 @@ skip-test-tvos-host
215231
skip-test-watchos-host
216232
check-incremental-compilation
217233

234+
[preset: buildbot,tools=R,stdlib=RD,test=non_executable]
235+
mixin-preset=
236+
mixin_buildbot_tools_R_stdlib_RD
237+
238+
only-non-executable-test
218239

219240
[preset: buildbot,tools=RA,stdlib=RDA]
220241
mixin-preset=
@@ -228,6 +249,12 @@ skip-test-ios-host
228249
skip-test-tvos-host
229250
skip-test-watchos-host
230251

252+
[preset: buildbot,tools=RA,stdlib=RDA,test=non_executable]
253+
mixin-preset=
254+
mixin_buildbot_tools_RA_stdlib_RDA
255+
256+
only-non-executable-test
257+
231258

232259
[preset: buildbot,tools=RA,stdlib=RDA,long_test]
233260
mixin-preset=

utils/build_swift/build_swift/driver_arguments.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,8 @@ def create_argument_parser():
825825
option('--only-executable-test', toggle_true,
826826
help='Only run executable tests. Does nothing if host-test is not '
827827
'allowed')
828+
option('--only-non-executable-test', toggle_true,
829+
help='Only run non-executable tests.')
828830

829831
option('--test-paths', append,
830832
type=argparse.ShellSplitType(),

utils/build_swift/tests/expected_options.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@
155155
'host_target': targets.StdlibDeploymentTarget.host_target().name,
156156
'host_test': False,
157157
'only_executable_test': False,
158+
'only_non_executable_test': False,
158159
'install_prefix': targets.install_prefix(),
159160
'install_symroot': None,
160161
'install_destdir': None,
@@ -498,6 +499,7 @@ class BuildScriptImplOption(_BaseOption):
498499
EnableOption('--foundation', dest='build_foundation'),
499500
EnableOption('--host-test'),
500501
EnableOption('--only-executable-test'),
502+
EnableOption('--only-non-executable-test'),
501503
EnableOption('--libdispatch', dest='build_libdispatch'),
502504
EnableOption('--libicu', dest='build_libicu'),
503505
EnableOption('--indexstore-db', dest='build_indexstoredb'),

utils/swift_build_support/swift_build_support/host_specific_configuration.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ def __init__(self, host_target, args):
136136
suffix = "-only_non_executable"
137137
elif args.only_executable_test:
138138
suffix = "-only_executable"
139+
elif args.only_non_executable_test:
140+
suffix = "-only_non_executable"
139141
else:
140142
suffix = ""
141143
subset_suffix = ""
@@ -214,25 +216,25 @@ def __platforms_to_skip_test(self, args):
214216
platforms_to_skip_test.add(StdlibDeploymentTarget.Cygwin)
215217
if not args.test_osx:
216218
platforms_to_skip_test.add(StdlibDeploymentTarget.OSX)
217-
if not args.test_ios_host:
219+
if not args.test_ios_host and not args.only_non_executable_test:
218220
platforms_to_skip_test.add(StdlibDeploymentTarget.iOS)
219-
else:
221+
elif not args.only_non_executable_test:
220222
raise ArgumentError(None,
221223
"error: iOS device tests are not " +
222224
"supported in open-source Swift.")
223225
if not args.test_ios_simulator:
224226
platforms_to_skip_test.add(StdlibDeploymentTarget.iOSSimulator)
225-
if not args.test_tvos_host:
227+
if not args.test_tvos_host and not args.only_non_executable_test:
226228
platforms_to_skip_test.add(StdlibDeploymentTarget.AppleTV)
227-
else:
229+
elif not args.only_non_executable_test:
228230
raise ArgumentError(None,
229231
"error: tvOS device tests are not " +
230232
"supported in open-source Swift.")
231233
if not args.test_tvos_simulator:
232234
platforms_to_skip_test.add(StdlibDeploymentTarget.AppleTVSimulator)
233-
if not args.test_watchos_host:
235+
if not args.test_watchos_host and not args.only_non_executable_test:
234236
platforms_to_skip_test.add(StdlibDeploymentTarget.AppleWatch)
235-
else:
237+
elif not args.only_non_executable_test:
236238
raise ArgumentError(None,
237239
"error: watchOS device tests are not " +
238240
"supported in open-source Swift.")
@@ -255,10 +257,10 @@ def __platforms_to_skip_test_host(self, args):
255257
platforms_to_skip_test_host = set()
256258
if not args.test_android_host:
257259
platforms_to_skip_test_host.add(StdlibDeploymentTarget.Android)
258-
if not args.test_ios_host:
260+
if not args.test_ios_host and not args.only_non_executable_test:
259261
platforms_to_skip_test_host.add(StdlibDeploymentTarget.iOS)
260-
if not args.test_tvos_host:
262+
if not args.test_tvos_host and not args.only_non_executable_test:
261263
platforms_to_skip_test_host.add(StdlibDeploymentTarget.AppleTV)
262-
if not args.test_watchos_host:
264+
if not args.test_watchos_host and not args.only_non_executable_test:
263265
platforms_to_skip_test_host.add(StdlibDeploymentTarget.AppleWatch)
264266
return platforms_to_skip_test_host

utils/swift_build_support/tests/test_host_specific_configuration.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,23 @@ def test_should_allow_testing_only_executable_tests(self):
320320
self.assertIn('check-swift-only_executable-macosx-x86_64',
321321
after.swift_test_run_targets)
322322

323+
def test_should_allow_testing_only_non_executable_tests(self):
324+
args = self.default_args()
325+
args.build_osx = True
326+
args.test_osx = True
327+
args.host_target = 'macosx-x86_64'
328+
args.stdlib_deployment_targets = ['macosx-x86_64']
329+
args.build_stdlib_deployment_targets = 'all'
330+
331+
before = HostSpecificConfiguration('macosx-x86_64', args)
332+
self.assertIn('check-swift-macosx-x86_64',
333+
before.swift_test_run_targets)
334+
335+
args.only_non_executable_test = True
336+
after = HostSpecificConfiguration('macosx-x86_64', args)
337+
self.assertIn('check-swift-only_non_executable-macosx-x86_64',
338+
after.swift_test_run_targets)
339+
323340
def generate_should_build_benchmarks(host_target, build_arg_name):
324341
def test(self):
325342
args = self.default_args()
@@ -620,6 +637,7 @@ def default_args(self):
620637
maccatalyst_ios_tests=False,
621638
long_test=False,
622639
only_executable_test=False,
640+
only_non_executable_test=False,
623641
stress_test=False,
624642
test_android=False,
625643
test_android_host=False,

0 commit comments

Comments
 (0)