Skip to content

Commit ad59d90

Browse files
author
Joe Shajrawi
committed
Set up testing with the standard libraries coming from the OS
We default Swift tests to use the just-built libraries See radars rdar://problem/35163663 and rdar://problem/42176864
1 parent e64b037 commit ad59d90

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

docs/Testing.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ out with ``lit.py -h``. We document some of the more useful ones below:
113113
* ``--param swift_test_mode=<MODE>`` drives the various suffix variations
114114
mentioned above. Again, it's best to get the invocation from the existing
115115
build system targets and modify it rather than constructing it yourself.
116+
* ``--param use_os_stdlib`` will run all tests with the standard libraries
117+
coming from the OS.
116118

117119
##### Remote testing options
118120

test/lit.cfg

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
#
1313
# This is a configuration file for the 'lit' test runner.
1414
#
15-
# Refer to docs/Testing.rst for documentation.
15+
# Refer to docs/Testing.md for documentation.
1616
#
17-
# Update docs/Testing.rst when changing this file.
17+
# Update docs/Testing.md when changing this file.
1818
#
1919
# -----------------------------------------------------------------------------
2020

@@ -1093,6 +1093,15 @@ if (not getattr(config, 'target_run', None) and
10931093
remote_run_host = lit_config.params['remote_run_host']
10941094
remote_tmp_dir = lit_config.params['remote_run_tmpdir']
10951095
remote_lib_dir = os.path.join(remote_tmp_dir, 'stdlib')
1096+
remote_run_lib_path = ''
1097+
if 'use_os_stdlib' not in lit_config.params:
1098+
remote_run_lib_path = remote_lib_dir
1099+
else:
1100+
os_stdlib_path = ''
1101+
if run_vendor == 'apple':
1102+
#If we get swift-in-the-OS for non-Apple platforms, add a condition here
1103+
os_stdlib_path = "/usr/lib/swift"
1104+
remote_run_lib_path = os.path.pathsep.join((os_stdlib_path, remote_lib_dir))
10961105

10971106
remote_run_extra_args_param = lit_config.params.get('remote_run_extra_args')
10981107
remote_run_extra_args = shlex.split(remote_run_extra_args_param or '')
@@ -1141,7 +1150,7 @@ if (not getattr(config, 'target_run', None) and
11411150
"REMOTE_RUN_CHILD_DYLD_LIBRARY_PATH='{0}' " # Apple option
11421151
"REMOTE_RUN_CHILD_LD_LIBRARY_PATH='{0}' " # Linux option
11431152
"'{1}'/remote-run --input-prefix '{2}' --output-prefix %t "
1144-
"--remote-dir '{3}'%t {4} {5}".format(remote_lib_dir,
1153+
"--remote-dir '{3}'%t {4} {5}".format(remote_run_lib_path,
11451154
config.swift_utils,
11461155
config.swift_src_root,
11471156
remote_tmp_dir,
@@ -1461,6 +1470,29 @@ if os.path.exists(libswiftCore_path):
14611470
config.substitutions.append(('%target-static-stdlib-path', static_stdlib_path))
14621471
lit_config.note('using static stdlib path: %s' % static_stdlib_path)
14631472

1473+
# Set up testing with the standard libraries coming from the OS / just-built libraries
1474+
# default Swift tests to use the just-built libraries
1475+
target_stdlib_path = platform_module_dir
1476+
if 'use_os_stdlib' not in lit_config.params:
1477+
lit_config.note('Testing with the just-built libraries at ' + target_stdlib_path)
1478+
config.target_run = (
1479+
"/usr/bin/env "
1480+
"DYLD_LIBRARY_PATH='{0}' " # Apple option
1481+
"LD_LIBRARY_PATH='{0}' " # Linux option
1482+
.format(target_stdlib_path))
1483+
else:
1484+
os_stdlib_path = ''
1485+
if run_vendor == 'apple':
1486+
#If we get swift-in-the-OS for non-Apple platforms, add a condition here
1487+
os_stdlib_path = "/usr/lib/swift"
1488+
all_stdlib_path = os.path.pathsep.join((os_stdlib_path, target_stdlib_path))
1489+
lit_config.note('Testing with the standard libraries coming from the OS ' + all_stdlib_path)
1490+
config.target_run = (
1491+
"/usr/bin/env "
1492+
"DYLD_LIBRARY_PATH='{0}' " # Apple option
1493+
"LD_LIBRARY_PATH='{0}' " # Linux option
1494+
.format(all_stdlib_path))
1495+
14641496
if config.lldb_build_root != "":
14651497
config.available_features.add('lldb')
14661498
# Note: using the same approach to locating the lib dir as in

0 commit comments

Comments
 (0)