Skip to content

Commit a0aaf39

Browse files
Joe Shajrawimikeash
authored andcommitted
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 e6047a2 commit a0aaf39

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

@@ -925,6 +925,15 @@ if (not getattr(config, 'target_run', None) and
925925
remote_run_host = lit_config.params['remote_run_host']
926926
remote_tmp_dir = lit_config.params['remote_run_tmpdir']
927927
remote_lib_dir = os.path.join(remote_tmp_dir, 'stdlib')
928+
remote_run_lib_path = ''
929+
if 'use_os_stdlib' not in lit_config.params:
930+
remote_run_lib_path = remote_lib_dir
931+
else:
932+
os_stdlib_path = ''
933+
if run_vendor == 'apple':
934+
#If we get swift-in-the-OS for non-Apple platforms, add a condition here
935+
os_stdlib_path = "/usr/lib/swift"
936+
remote_run_lib_path = os.path.pathsep.join((os_stdlib_path, remote_lib_dir))
928937

929938
remote_run_extra_args_param = lit_config.params.get('remote_run_extra_args')
930939
remote_run_extra_args = shlex.split(remote_run_extra_args_param or '')
@@ -973,7 +982,7 @@ if (not getattr(config, 'target_run', None) and
973982
"REMOTE_RUN_CHILD_DYLD_LIBRARY_PATH='{0}' " # Apple option
974983
"REMOTE_RUN_CHILD_LD_LIBRARY_PATH='{0}' " # Linux option
975984
"'{1}'/remote-run --input-prefix '{2}' --output-prefix %t "
976-
"--remote-dir '{3}'%t {4} {5}".format(remote_lib_dir,
985+
"--remote-dir '{3}'%t {4} {5}".format(remote_run_lib_path,
977986
config.swift_utils,
978987
config.swift_src_root,
979988
remote_tmp_dir,
@@ -1283,6 +1292,29 @@ if os.path.exists(libswiftCore_path):
12831292
config.substitutions.append(('%target-static-stdlib-path', static_stdlib_path))
12841293
lit_config.note('using static stdlib path: %s' % static_stdlib_path)
12851294

1295+
# Set up testing with the standard libraries coming from the OS / just-built libraries
1296+
# default Swift tests to use the just-built libraries
1297+
target_stdlib_path = platform_module_dir
1298+
if 'use_os_stdlib' not in lit_config.params:
1299+
lit_config.note('Testing with the just-built libraries at ' + target_stdlib_path)
1300+
config.target_run = (
1301+
"/usr/bin/env "
1302+
"DYLD_LIBRARY_PATH='{0}' " # Apple option
1303+
"LD_LIBRARY_PATH='{0}' " # Linux option
1304+
.format(target_stdlib_path))
1305+
else:
1306+
os_stdlib_path = ''
1307+
if run_vendor == 'apple':
1308+
#If we get swift-in-the-OS for non-Apple platforms, add a condition here
1309+
os_stdlib_path = "/usr/lib/swift"
1310+
all_stdlib_path = os.path.pathsep.join((os_stdlib_path, target_stdlib_path))
1311+
lit_config.note('Testing with the standard libraries coming from the OS ' + all_stdlib_path)
1312+
config.target_run = (
1313+
"/usr/bin/env "
1314+
"DYLD_LIBRARY_PATH='{0}' " # Apple option
1315+
"LD_LIBRARY_PATH='{0}' " # Linux option
1316+
.format(all_stdlib_path))
1317+
12861318
if config.lldb_build_root != "":
12871319
config.available_features.add('lldb')
12881320
# Note: using the same approach to locating the lib dir as in

0 commit comments

Comments
 (0)