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+
608612if 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:
10641077config .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-
11141080subst_target_jit_run = ""
11151081if '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 = ""
11201087subst_target_repl_run_simple_swift = ""
11211088if '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
11851258config .substitutions .append (('%target-run-simple-opt-Osize-swift' , config .target_run_simple_opt_Osize_swift ))
11861259config .substitutions .append (('%target-run-stdlib-swiftgyb' , config .target_run_stdlib_swiftgyb ))
11871260config .substitutions .append (('%target-run-stdlib-swift' , config .target_run_stdlib_swift ))
1261+ config .substitutions .append (('%target-repl-run-swift' , subst_target_repl_run_swift ))
11881262config .substitutions .append (('%target-repl-run-simple-swift' , subst_target_repl_run_simple_swift ))
11891263config .substitutions .append (('%target-run' , config .target_run ))
11901264config .substitutions .append (('%target-jit-run' , subst_target_jit_run ))
@@ -1245,13 +1319,6 @@ if hasattr(config, 'target_swift_autolink_extract'):
12451319config .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-
12551322config .substitutions .insert (0 , ('%platform-module-dir' , platform_module_dir ))
12561323config .substitutions .insert (0 , ('%platform-sdk-overlay-dir' , platform_sdk_overlay_dir ))
12571324
@@ -1275,14 +1342,6 @@ config.substitutions.append(
12751342 pipes .quote (config .filecheck ))))
12761343config .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-
12861345if config .lldb_build_root != "" :
12871346 config .available_features .add ('lldb' )
12881347 # Note: using the same approach to locating the lib dir as in
0 commit comments