Skip to content

Commit cfb76cc

Browse files
authored
[test] Allow customizing swift-ide-test invocations during tests. (#65684)
In some Linux setups, one might need to provide extra arguments to setup the environment for invocations done during the tests. The Swift frontend and driver already had a mechanism to provide those arguments in the shape of `SWIFT_FRONTEND_TEST_OPTIONS` and `SWIFT_DRIVER_TEST_OPTIONS`. `swift-ide-test` was sadly missing the same feature, which meant that many tests might fail or tests against the incorrect environment. The changes implement the `SWIFT_IDE_TEST_TEST_OPTIONS` mechanism to cover that gap.
1 parent 0366c42 commit cfb76cc

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

test/lit.cfg

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@ if test_options:
511511

512512
config.swift_frontend_test_options += os.environ.get('SWIFT_FRONTEND_TEST_OPTIONS', '')
513513
config.swift_driver_test_options += os.environ.get('SWIFT_DRIVER_TEST_OPTIONS', '')
514+
config.swift_ide_test_test_options += os.environ.get('SWIFT_IDE_TEST_TEST_OPTIONS', '')
514515
config.sil_test_options = os.environ.get('SIL_TEST_OPTIONS', '')
515516

516517
config.clang_module_cache_path = make_path(config.swift_test_results_dir, "clang-module-cache")
@@ -772,6 +773,7 @@ elif swift_test_mode == 'with_cxx_interop':
772773
config.available_features.add("with_cxx_interop")
773774
config.swift_frontend_test_options += ' -cxx-interoperability-mode=default'
774775
config.swift_driver_test_options += ' -cxx-interoperability-mode=default'
776+
config.swift_ide_test_test_options += ' -cxx-interoperability-mode=default'
775777
else:
776778
lit_config.fatal("Unknown test mode %r" % swift_test_mode)
777779

@@ -1357,11 +1359,13 @@ if run_vendor == 'apple':
13571359
"%s %s -sdk %r" %
13581360
(config.swift_api_extract, target_options, config.variant_sdk))
13591361
config.target_swift_ide_test = (
1360-
"%s %s %s %s" %
1361-
(xcrun_prefix, config.swift_ide_test, target_options, ccp_opt))
1362+
"%s %s %s %s %s" %
1363+
(xcrun_prefix, config.swift_ide_test, target_options, ccp_opt,
1364+
config.swift_ide_test_test_options))
13621365
subst_target_swift_ide_test_mock_sdk = (
1363-
"%s %s %s %s" %
1364-
(xcrun_prefix, config.swift_ide_test, target_options_for_mock_sdk, ccp_opt))
1366+
"%s %s %s %s %s" %
1367+
(xcrun_prefix, config.swift_ide_test, target_options_for_mock_sdk, ccp_opt,
1368+
config.swift_ide_test_test_options))
13651369
subst_target_swift_ide_test_mock_sdk_after = \
13661370
target_options_for_mock_sdk_after
13671371
config.target_swiftc_driver = (
@@ -1497,9 +1501,11 @@ elif run_os in ['windows-msvc']:
14971501
config.variant_sdk, \
14981502
config.variant_triple))
14991503
config.target_swift_ide_test = \
1500-
('%r -target %s %s %s %s' % (config.swift_ide_test, \
1501-
config.variant_triple, \
1502-
config.resource_dir_opt, mcp_opt, ccp_opt))
1504+
('%r -target %s %s %s %s %s' % (config.swift_ide_test, \
1505+
config.variant_triple, \
1506+
config.resource_dir_opt, mcp_opt, \
1507+
ccp_opt, \
1508+
config.swift_ide_test_test_options))
15031509

15041510
subst_target_swift_ide_test_mock_sdk = config.target_swift_ide_test
15051511
subst_target_swift_ide_test_mock_sdk_after = ''
@@ -1632,9 +1638,9 @@ elif (run_os in ['linux-gnu', 'linux-gnueabihf', 'freebsd', 'openbsd', 'windows-
16321638
'%s -target %s -sdk %r' %
16331639
(config.swift_api_extract, config.variant_triple, config.variant_sdk))
16341640
config.target_swift_ide_test = (
1635-
'%s -target %s %s %s %s' %
1641+
'%s -target %s %s %s %s %s' %
16361642
(config.swift_ide_test, config.variant_triple, config.resource_dir_opt,
1637-
mcp_opt, ccp_opt))
1643+
mcp_opt, ccp_opt, config.swift_ide_test_test_options))
16381644
subst_target_swift_ide_test_mock_sdk = config.target_swift_ide_test
16391645
subst_target_swift_ide_test_mock_sdk_after = ""
16401646
config.target_swiftc_driver = (
@@ -1747,7 +1753,8 @@ elif run_os == 'linux-androideabi' or run_os == 'linux-android':
17471753
'env', 'SDKROOT={}'.format(shell_quote(config.variant_sdk)),
17481754
config.swift_ide_test,
17491755
'-target', config.variant_triple,
1750-
config.resource_dir_opt, mcp_opt, ccp_opt])
1756+
config.resource_dir_opt, mcp_opt, ccp_opt,
1757+
config.swift_ide_test_test_options])
17511758
subst_target_swift_ide_test_mock_sdk = config.target_swift_ide_test
17521759
subst_target_swift_ide_test_mock_sdk_after = ""
17531760
config.target_swiftc_driver = ' '.join([
@@ -1819,9 +1826,9 @@ elif run_os == 'wasi':
18191826
'-target', config.variant_triple,
18201827
mcp_opt])
18211828
config.target_swift_ide_test = (
1822-
'%s -target %s %s %s %s' %
1829+
'%s -target %s %s %s %s %s' %
18231830
(config.swift_ide_test, config.variant_triple, config.resource_dir_opt,
1824-
mcp_opt, ccp_opt))
1831+
mcp_opt, ccp_opt, config.swift_ide_test_test_options))
18251832
subst_target_swift_ide_test_mock_sdk = config.target_swift_ide_test
18261833
subst_target_swift_ide_test_mock_sdk_after = ""
18271834
config.target_swiftc_driver = (

test/lit.site.cfg.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ config.libdispatch_build_path = "@SWIFT_PATH_TO_LIBDISPATCH_BUILD@"
4040
config.libdispatch_static_build_path = "@SWIFT_PATH_TO_LIBDISPATCH_STATIC_BUILD@"
4141
config.swift_driver_test_options = "@SWIFT_DRIVER_TEST_OPTIONS@"
4242
config.swift_frontend_test_options = "@SWIFT_FRONTEND_TEST_OPTIONS@"
43+
config.swift_ide_test_test_options = "@SWIFT_IDE_TEST_TEST_OPTIONS@"
4344

4445
# --- Darwin ---
4546
config.darwin_xcrun_toolchain = "@SWIFT_DARWIN_XCRUN_TOOLCHAIN@"

validation-test/lit.site.cfg.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ config.host_sdkroot = "@SWIFT_HOST_SDKROOT@"
3434

3535
config.swift_driver_test_options = "@SWIFT_DRIVER_TEST_OPTIONS@"
3636
config.swift_frontend_test_options = "@SWIFT_FRONTEND_TEST_OPTIONS@"
37+
config.swift_ide_test_test_options = "@SWIFT_IDE_TEST_TEST_OPTIONS@"
3738

3839
# --- Darwin Configuration ---
3940
config.darwin_xcrun_toolchain = "@SWIFT_DARWIN_XCRUN_TOOLCHAIN@"

0 commit comments

Comments
 (0)