Skip to content

Commit 2f7ff37

Browse files
committed
[Build System] Add support to execute non-executable tests
1 parent 79716ef commit 2f7ff37

File tree

4 files changed

+32
-9
lines changed

4 files changed

+32
-9
lines changed

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: 17 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_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()

0 commit comments

Comments
 (0)