Skip to content

Commit e4e7da2

Browse files
committed
test: provide an opaque-values testing mode
Introduces a new build-script flag `--test-optimize-none-with-opaque-values` and build targets like `check-swift-optimize_none_with_opaque_values` that runs the execution_test's while compiling them with -enable-sil-opaque-values. This mode is quite useful while working to bring-up opaque values.
1 parent d8b28cf commit e4e7da2

File tree

6 files changed

+29
-0
lines changed

6 files changed

+29
-0
lines changed

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ set(profdata_merge_worker
348348

349349
set(TEST_MODES
350350
optimize_none optimize optimize_unchecked optimize_size
351+
optimize_none_with_opaque_values
351352
optimize_none_with_implicit_dynamic
352353
optimize_with_implicit_dynamic
353354
only_executable only_non_executable

test/lit.cfg

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,11 @@ if swift_test_mode == 'optimize_none':
925925
# optimize mode for a cpu.
926926
config.available_features.add("swift_test_mode_optimize_none_" + run_cpu)
927927
swift_execution_tests_extra_flags = ''
928+
elif swift_test_mode == 'optimize_none_with_opaque_values':
929+
config.available_features.add("executable_test")
930+
config.limit_to_features.add("executable_test")
931+
config.available_features.add("swift_test_mode_optimize_none_with_opaque_values")
932+
swift_execution_tests_extra_flags = '-Xfrontend -enable-sil-opaque-values'
928933
elif swift_test_mode == 'optimize_none_with_implicit_dynamic':
929934
config.available_features.add("executable_test")
930935
config.limit_to_features.add("executable_test")

utils/build_swift/build_swift/driver_arguments.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ def _apply_default_arguments(args):
203203
if args.test_optimize_none_with_implicit_dynamic:
204204
args.test = True
205205

206+
if args.test_optimize_none_with_opaque_values:
207+
args.test = True
208+
206209
# If none of tests specified skip swift stdlib test on all platforms
207210
if not args.test and not args.validation_test and not args.long_test:
208211
args.test_linux = False
@@ -1143,6 +1146,12 @@ def create_argument_parser():
11431146
help='run the test suite in optimize none with implicit dynamic'
11441147
'mode too (implies --test)')
11451148

1149+
# NOTE: this mode is meant to aid the bring-up of opaque values
1150+
# and once its enabled by default, we can remove this.
1151+
option('--test-optimize-none-with-opaque-values', toggle_true,
1152+
help='run the executable tests again, compiling them with '
1153+
'-enable-sil-opaque-values (implies --test)')
1154+
11461155
option('--long-test', toggle_true,
11471156
help='run the long test suite')
11481157

utils/build_swift/tests/build_swift/test_driver_arguments.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,11 @@ def test_implied_defaults_test_optimize_none_with_implicit_dynamic(self):
605605
['--test-optimize-none-with-implicit-dynamic'])
606606
self.assertTrue(namespace.test)
607607

608+
def test_implied_defaults_test_optimize_none_with_opaque_values(self):
609+
namespace = self.parse_default_args(
610+
['--test-optimize-none-with-opaque-values'])
611+
self.assertTrue(namespace.test)
612+
608613
def test_implied_defaults_skip_all_tests(self):
609614
namespace = self.parse_default_args([
610615
'--test', '0',

utils/build_swift/tests/expected_options.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@
313313
'test_linux_static': False,
314314
'test_optimize_for_size': None,
315315
'test_optimize_none_with_implicit_dynamic': None,
316+
'test_optimize_none_with_opaque_values': None,
316317
'test_optimized': None,
317318
'test_osx': False,
318319
'test_paths': [],
@@ -544,6 +545,8 @@ class BuildScriptImplOption(_BaseOption):
544545
SetOption('-s', dest='test_optimize_for_size', value=True),
545546
SetOption('-y',
546547
dest='test_optimize_none_with_implicit_dynamic', value=True),
548+
SetOption('--test-optimize-none-with-opaque-values',
549+
dest='test_optimize_none_with_opaque_values', value=True),
547550
SetOption('-t', dest='test', value=True),
548551
SetOption('-a', dest='assertions', value=True),
549552

@@ -707,6 +710,7 @@ class BuildScriptImplOption(_BaseOption):
707710
EnableOption('--test'),
708711
EnableOption('--test-optimize-for-size'),
709712
EnableOption('--test-optimize-none-with-implicit-dynamic'),
713+
EnableOption('--test-optimize-none-with-opaque-values'),
710714
EnableOption('--test-optimized'),
711715
EnableOption('--tvos'),
712716
EnableOption('--validation-test'),

utils/swift_build_support/swift_build_support/host_specific_configuration.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,11 @@ def __init__(self, host_target, args, stage_dependent_args=None):
215215
self.swift_test_run_targets.append(
216216
"check-swift{}-optimize_none_with_implicit_dynamic-{}"
217217
.format(subset_suffix, name))
218+
if args.test_optimize_none_with_opaque_values and \
219+
not test_host_only:
220+
self.swift_test_run_targets.append(
221+
"check-swift{}-optimize_none_with_opaque_values-{}"
222+
.format(subset_suffix, name))
218223

219224
# Only pull in these flags when cross-compiling with
220225
# --cross-compile-hosts.

0 commit comments

Comments
 (0)