Skip to content

Commit 03d0363

Browse files
authored
Merge pull request #25784 from kevints/testing-os-cherrypick-5.0
[5.0] Cherry-pick changes to allow testing the OS or just-built Swift dylibs
2 parents e6047a2 + e9e2d8a commit 03d0363

File tree

10 files changed

+137
-67
lines changed

10 files changed

+137
-67
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/Interpreter/protocol_lookup_jit.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Test protocol_lookup.swift in JIT mode.
2-
// RUN: %swift -interpret %S/protocol_lookup.swift | %FileCheck %S/protocol_lookup.swift --check-prefix=CHECK --check-prefix=CHECK-%target-runtime
2+
// RUN: %target-jit-run %S/protocol_lookup.swift | %FileCheck %S/protocol_lookup.swift --check-prefix=CHECK --check-prefix=CHECK-%target-runtime
33
// REQUIRES: executable_test
44

55
// REQUIRES: swift_interpreter

test/Interpreter/repl_autolinking.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// RUN: sed -n -e '/REPL_START$/,/REPL_END$/ p' %s > %t/repl.swift
55
// RUN: %target-swiftc_driver -emit-library %t/a.swift -I %t -L %t -emit-module-path %t/ModuleA.swiftmodule -autolink-force-load -module-link-name ModuleA -module-name ModuleA -o %t/libModuleA.dylib
66
// RUN: %target-swiftc_driver -emit-library %t/b.swift -I %t -L %t -emit-module-path %t/ModuleB.swiftmodule -autolink-force-load -module-link-name ModuleB -module-name ModuleB -o %t/libModuleB.dylib
7-
// RUN: %swift -repl -I %t -L %t < %t/repl.swift 2>&1 | %FileCheck %s
7+
// RUN: %target-repl-run-swift -I %t -L %t < %t/repl.swift 2>&1 | %FileCheck %s
88

99
// REQUIRES: swift_repl
1010
// UNSUPPORTED: OS=linux-gnu

test/SIL/Serialization/deserialize_coregraphics.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// RUN: %target-sil-opt -assume-parsing-unqualified-ownership-sil %platform-sdk-overlay-dir/CoreGraphics.swiftmodule > /dev/null
33
// RUN: llvm-bcanalyzer %platform-sdk-overlay-dir/CoreGraphics.swiftmodule | %FileCheck %s
44

5+
// REQUIRES: rdar51868140
56
// REQUIRES: objc_interop
67

78
// CHECK-NOT: Unknown

test/SIL/Serialization/deserialize_darwin.sil

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// RUN: %target-sil-opt -assume-parsing-unqualified-ownership-sil %platform-sdk-overlay-dir/Darwin.swiftmodule > /dev/null
33
// RUN: llvm-bcanalyzer %platform-sdk-overlay-dir/Darwin.swiftmodule | %FileCheck %s
44

5+
// REQUIRES: rdar51868140
56
// REQUIRES: objc_interop
67

78
// CHECK-NOT: Unknown

test/SIL/Serialization/deserialize_objectivec.sil

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// RUN: %target-sil-opt -assume-parsing-unqualified-ownership-sil %platform-sdk-overlay-dir/ObjectiveC.swiftmodule > /dev/null
33
// RUN: llvm-bcanalyzer %platform-sdk-overlay-dir/ObjectiveC.swiftmodule | %FileCheck %s
44

5+
// REQUIRES: rdar51868140
56
// REQUIRES: objc_interop
67

78
// CHECK-NOT: Unknown

test/SIL/Serialization/deserialize_stdlib.sil

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
// RUN: %target-sil-opt -assume-parsing-unqualified-ownership-sil %platform-module-dir/Swift.swiftmodule > /dev/null
33
// RUN: llvm-bcanalyzer %platform-module-dir/Swift.swiftmodule | %FileCheck %s
44

5+
// REQUIRES: rdar51868140
6+
57
// CHECK-NOT: Unknown

test/lit.cfg

Lines changed: 124 additions & 65 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

@@ -605,6 +605,10 @@ def use_interpreter_for_simple_runs():
605605
config.target_run_simple_swift = make_simple_target_run()
606606
config.available_features.add('interpret')
607607

608+
target_specific_module_triple = config.variant_triple
609+
610+
config.target_run = ""
611+
608612
if run_vendor == 'apple':
609613
config.available_features.add('objc_interop')
610614
config.target_object_format = "macho"
@@ -925,6 +929,15 @@ if (not getattr(config, 'target_run', None) and
925929
remote_run_host = lit_config.params['remote_run_host']
926930
remote_tmp_dir = lit_config.params['remote_run_tmpdir']
927931
remote_lib_dir = os.path.join(remote_tmp_dir, 'stdlib')
932+
remote_run_lib_path = ''
933+
if 'use_os_stdlib' not in lit_config.params:
934+
remote_run_lib_path = remote_lib_dir
935+
else:
936+
os_stdlib_path = ''
937+
if run_vendor == 'apple':
938+
#If we get swift-in-the-OS for non-Apple platforms, add a condition here
939+
os_stdlib_path = "/usr/lib/swift"
940+
remote_run_lib_path = os.path.pathsep.join((os_stdlib_path, remote_lib_dir))
928941

929942
remote_run_extra_args_param = lit_config.params.get('remote_run_extra_args')
930943
remote_run_extra_args = shlex.split(remote_run_extra_args_param or '')
@@ -973,7 +986,7 @@ if (not getattr(config, 'target_run', None) and
973986
"REMOTE_RUN_CHILD_DYLD_LIBRARY_PATH='{0}' " # Apple option
974987
"REMOTE_RUN_CHILD_LD_LIBRARY_PATH='{0}' " # Linux option
975988
"'{1}'/remote-run --input-prefix '{2}' --output-prefix %t "
976-
"--remote-dir '{3}'%t {4} {5}".format(remote_lib_dir,
989+
"--remote-dir '{3}'%t {4} {5}".format(remote_run_lib_path,
977990
config.swift_utils,
978991
config.swift_src_root,
979992
remote_tmp_dir,
@@ -1064,61 +1077,16 @@ if sftp_server_path:
10641077
config.substitutions.append(('%sftp-server',
10651078
sftp_server_path or 'no-sftp-server'))
10661079

1067-
1068-
if not getattr(config, 'target_run_simple_swift', None):
1069-
config.target_run_simple_swift = (
1070-
'%%empty-directory(%%t) && '
1071-
'%s %s %%s -o %%t/a.out -module-name main && '
1072-
'%s %%t/a.out &&'
1073-
'%s %%t/a.out'
1074-
% (config.target_build_swift, mcp_opt, config.target_codesign, config.target_run))
1075-
config.target_run_simple_opt_O_swift = (
1076-
'%%empty-directory(%%t) && '
1077-
'%s %s -O %%s -o %%t/a.out -module-name main && '
1078-
'%s %%t/a.out &&'
1079-
'%s %%t/a.out'
1080-
% (config.target_build_swift, mcp_opt, config.target_codesign, config.target_run))
1081-
config.target_run_simple_opt_Osize_swift = (
1082-
'%%empty-directory(%%t) && '
1083-
'%s %s -Osize %%s -o %%t/a.out -module-name main && '
1084-
'%s %%t/a.out &&'
1085-
'%s %%t/a.out'
1086-
% (config.target_build_swift, mcp_opt, config.target_codesign, config.target_run))
1087-
config.target_run_stdlib_swift = (
1088-
'%%empty-directory(%%t) && '
1089-
'%s %s %%s -o %%t/a.out -module-name main '
1090-
'-Xfrontend -disable-access-control && '
1091-
'%s %%t/a.out &&'
1092-
'%s %%t/a.out'
1093-
% (config.target_build_swift, mcp_opt, config.target_codesign, config.target_run))
1094-
config.target_run_simple_swiftgyb = (
1095-
'%%empty-directory(%%t) && '
1096-
'%%gyb %%s -o %%t/main.swift && '
1097-
'%%line-directive %%t/main.swift -- '
1098-
'%s %s %%t/main.swift -o %%t/a.out -module-name main && '
1099-
'%s %%t/a.out &&'
1100-
'%%line-directive %%t/main.swift -- '
1101-
'%s %%t/a.out'
1102-
% (config.target_build_swift, mcp_opt, config.target_codesign, config.target_run))
1103-
config.target_run_stdlib_swiftgyb = (
1104-
'%%empty-directory(%%t) && '
1105-
'%%gyb %%s -o %%t/main.swift && '
1106-
'%%line-directive %%t/main.swift -- '
1107-
'%s %s %%t/main.swift -o %%t/a.out -module-name main '
1108-
'-Xfrontend -disable-access-control && '
1109-
'%s %%t/a.out &&'
1110-
'%%line-directive %%t/main.swift -- '
1111-
'%s %%t/a.out'
1112-
% (config.target_build_swift, mcp_opt, config.target_codesign, config.target_run))
1113-
11141080
subst_target_jit_run = ""
11151081
if 'swift_interpreter' in config.available_features:
11161082
subst_target_jit_run = (
11171083
"%s -interpret %s" %
11181084
(config.target_swift_frontend, sdk_overlay_link_path))
11191085

1086+
subst_target_repl_run_swift = ""
11201087
subst_target_repl_run_simple_swift = ""
11211088
if 'swift_repl' in config.available_features:
1089+
subst_target_repl_run_swift = "%s -repl" % (config.target_swift_frontend)
11221090
subst_target_repl_run_simple_swift = (
11231091
"%s -repl %s < %%s 2>&1" %
11241092
(config.target_swift_frontend, sdk_overlay_link_path))
@@ -1157,6 +1125,111 @@ if platform.system() != 'Darwin':
11571125
config.target_resilience_test = ('%s --no-symbol-diff' %
11581126
config.target_resilience_test)
11591127

1128+
platform_module_dir = make_path(test_resource_dir, config.target_sdk_name)
1129+
if run_vendor != 'apple':
1130+
platform_module_dir = make_path(platform_module_dir, run_cpu)
1131+
lit_config.note('Using platform module dir: ' + platform_module_dir)
1132+
if test_sdk_overlay_dir:
1133+
platform_sdk_overlay_dir = test_sdk_overlay_dir
1134+
else:
1135+
platform_sdk_overlay_dir = platform_module_dir
1136+
1137+
# If static stdlib is present, enable static stdlib tests
1138+
static_stdlib_path = make_path(config.swift_lib_dir, "swift_static", config.target_sdk_name)
1139+
static_libswiftCore_path = make_path(static_stdlib_path, "libswiftCore.a")
1140+
if os.path.exists(static_libswiftCore_path):
1141+
config.available_features.add("static_stdlib")
1142+
config.substitutions.append(('%target-static-stdlib-path', static_stdlib_path))
1143+
lit_config.note('using static stdlib path: %s' % static_stdlib_path)
1144+
1145+
# Set up testing with the standard libraries coming from the OS / just-built libraries
1146+
# default Swift tests to use the just-built libraries
1147+
target_stdlib_path = platform_module_dir
1148+
if 'use_os_stdlib' not in lit_config.params:
1149+
lit_config.note('Testing with the just-built libraries at ' + target_stdlib_path)
1150+
library_path_env = (
1151+
"/usr/bin/env "
1152+
"DYLD_LIBRARY_PATH='{0}' " # Apple option
1153+
"LD_LIBRARY_PATH='{0}' " # Linux option
1154+
"SIMCTL_CHILD_DYLD_LIBRARY_PATH='{0}' " # Simulator option
1155+
.format(target_stdlib_path))
1156+
config.target_run = library_path_env + config.target_run
1157+
subst_target_jit_run = library_path_env + subst_target_jit_run
1158+
config.swift_remoteast_test = library_path_env + config.swift_remoteast_test
1159+
subst_target_repl_run_simple_swift = library_path_env + subst_target_repl_run_simple_swift
1160+
subst_target_repl_run_swift = library_path_env + subst_target_repl_run_swift
1161+
else:
1162+
os_stdlib_path = ''
1163+
if run_vendor == 'apple':
1164+
#If we get swift-in-the-OS for non-Apple platforms, add a condition here
1165+
os_stdlib_path = "/usr/lib/swift"
1166+
all_stdlib_path = os.path.pathsep.join((os_stdlib_path, target_stdlib_path))
1167+
lit_config.note('Testing with the standard libraries coming from the OS ' + all_stdlib_path)
1168+
library_path_env = (
1169+
"/usr/bin/env "
1170+
"DYLD_LIBRARY_PATH='{0}' " # Apple option
1171+
"LD_LIBRARY_PATH='{0}' " # Linux option
1172+
"SIMCTL_CHILD_DYLD_LIBRARY_PATH='{0}' " # Simulator option
1173+
.format(all_stdlib_path))
1174+
config.target_run = library_path_env + config.target_run
1175+
subst_target_jit_run = library_path_env + subst_target_jit_run
1176+
config.swift_remoteast_test = library_path_env + config.swift_remoteast_test
1177+
subst_target_repl_run_simple_swift = library_path_env + subst_target_repl_run_simple_swift
1178+
subst_target_repl_run_swift = library_path_env + subst_target_repl_run_swift
1179+
1180+
if not getattr(config, 'target_run_simple_swift', None):
1181+
config.target_run_simple_swift_parameterized = \
1182+
(SubstituteCaptures('%%empty-directory(%%t) && '
1183+
'%s %s %%s \\1 -o %%t/a.out -module-name main && '
1184+
'%s %%t/a.out &&'
1185+
'%s %%t/a.out' % (config.target_build_swift,
1186+
mcp_opt, config.target_codesign,
1187+
config.target_run)))
1188+
config.target_run_simple_swift = (
1189+
'%%empty-directory(%%t) && '
1190+
'%s %s %%s -o %%t/a.out -module-name main && '
1191+
'%s %%t/a.out &&'
1192+
'%s %%t/a.out'
1193+
% (config.target_build_swift, mcp_opt, config.target_codesign, config.target_run))
1194+
config.target_run_simple_opt_O_swift = (
1195+
'%%empty-directory(%%t) && '
1196+
'%s %s -O %%s -o %%t/a.out -module-name main && '
1197+
'%s %%t/a.out &&'
1198+
'%s %%t/a.out'
1199+
% (config.target_build_swift, mcp_opt, config.target_codesign, config.target_run))
1200+
config.target_run_simple_opt_Osize_swift = (
1201+
'%%empty-directory(%%t) && '
1202+
'%s %s -Osize %%s -o %%t/a.out -module-name main && '
1203+
'%s %%t/a.out &&'
1204+
'%s %%t/a.out'
1205+
% (config.target_build_swift, mcp_opt, config.target_codesign, config.target_run))
1206+
config.target_run_stdlib_swift = (
1207+
'%%empty-directory(%%t) && '
1208+
'%s %s %%s -o %%t/a.out -module-name main '
1209+
'-Xfrontend -disable-access-control && '
1210+
'%s %%t/a.out &&'
1211+
'%s %%t/a.out'
1212+
% (config.target_build_swift, mcp_opt, config.target_codesign, config.target_run))
1213+
config.target_run_simple_swiftgyb = (
1214+
'%%empty-directory(%%t) && '
1215+
'%%gyb %%s -o %%t/main.swift && '
1216+
'%%line-directive %%t/main.swift -- '
1217+
'%s %s %%t/main.swift -o %%t/a.out -module-name main && '
1218+
'%s %%t/a.out &&'
1219+
'%%line-directive %%t/main.swift -- '
1220+
'%s %%t/a.out'
1221+
% (config.target_build_swift, mcp_opt, config.target_codesign, config.target_run))
1222+
config.target_run_stdlib_swiftgyb = (
1223+
'%%empty-directory(%%t) && '
1224+
'%%gyb %%s -o %%t/main.swift && '
1225+
'%%line-directive %%t/main.swift -- '
1226+
'%s %s %%t/main.swift -o %%t/a.out -module-name main '
1227+
'-Xfrontend -disable-access-control && '
1228+
'%s %%t/a.out &&'
1229+
'%%line-directive %%t/main.swift -- '
1230+
'%s %%t/a.out'
1231+
% (config.target_build_swift, mcp_opt, config.target_codesign, config.target_run))
1232+
11601233
#
11611234
# When changing substitutions, update docs/Testing.rst.
11621235
#
@@ -1185,6 +1258,7 @@ config.substitutions.append(('%target-run-simple-opt-O-swift', config.target_run
11851258
config.substitutions.append(('%target-run-simple-opt-Osize-swift', config.target_run_simple_opt_Osize_swift))
11861259
config.substitutions.append(('%target-run-stdlib-swiftgyb', config.target_run_stdlib_swiftgyb))
11871260
config.substitutions.append(('%target-run-stdlib-swift', config.target_run_stdlib_swift))
1261+
config.substitutions.append(('%target-repl-run-swift', subst_target_repl_run_swift))
11881262
config.substitutions.append(('%target-repl-run-simple-swift', subst_target_repl_run_simple_swift))
11891263
config.substitutions.append(('%target-run', config.target_run))
11901264
config.substitutions.append(('%target-jit-run', subst_target_jit_run))
@@ -1245,13 +1319,6 @@ if hasattr(config, 'target_swift_autolink_extract'):
12451319
config.substitutions.append(('%target-swift-modulewrap',
12461320
config.target_swift_modulewrap))
12471321

1248-
platform_module_dir = make_path(test_resource_dir, '%target-sdk-name', run_cpu)
1249-
lit_config.note('Using platform module dir: ' + platform_module_dir)
1250-
if test_sdk_overlay_dir is not None:
1251-
platform_sdk_overlay_dir = make_path(test_sdk_overlay_dir, run_cpu)
1252-
else:
1253-
platform_sdk_overlay_dir = platform_module_dir
1254-
12551322
config.substitutions.insert(0, ('%platform-module-dir', platform_module_dir))
12561323
config.substitutions.insert(0, ('%platform-sdk-overlay-dir', platform_sdk_overlay_dir))
12571324

@@ -1275,14 +1342,6 @@ config.substitutions.append(
12751342
pipes.quote(config.filecheck))))
12761343
config.substitutions.append(('%raw-FileCheck', pipes.quote(config.filecheck)))
12771344

1278-
# If static stdlib is present, enable static stdlib tests
1279-
static_stdlib_path = make_path(config.swift_lib_dir, "swift_static", config.target_sdk_name)
1280-
libswiftCore_path = make_path(static_stdlib_path, "libswiftCore.a")
1281-
if os.path.exists(libswiftCore_path):
1282-
config.available_features.add("static_stdlib")
1283-
config.substitutions.append(('%target-static-stdlib-path', static_stdlib_path))
1284-
lit_config.note('using static stdlib path: %s' % static_stdlib_path)
1285-
12861345
if config.lldb_build_root != "":
12871346
config.available_features.add('lldb')
12881347
# Note: using the same approach to locating the lib dir as in

utils/build-script-impl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3342,6 +3342,9 @@ for host in "${ALL_HOSTS[@]}"; do
33423342
echo "Skipping PlaygroundLogger tests on non-macOS platform"
33433343
continue
33443344
fi
3345+
3346+
echo "Skipping PlaygroundLogger tests due to rdar://47528005"
3347+
continue
33453348

33463349
PLAYGROUNDSUPPORT_BUILD_DIR=$(build_directory ${host} ${product})
33473350
SWIFTC_BIN="$(build_directory_bin ${host} swift)/swiftc"

validation-test/execution/interpret-with-dependencies.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// REQUIRES: rdar51868140
12
// REQUIRES: OS=macosx
23
// RUN: %empty-directory(%t)
34

0 commit comments

Comments
 (0)