Skip to content

Commit a315461

Browse files
committed
[test] add test features static_stdlib
Add a test feature flag static_stdlib, which is enabled if the user builds the static libraries. We also add the substitution %target-static-stdlib-path which gives the path of the static stdlib. These features allow testing specifically for the static standard library.
1 parent b3cde46 commit a315461

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

docs/Testing.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ code for the target that is not the build machine:
259259
* ``%target-sdk-name``: only for Apple platforms: ``xcrun``-style SDK name
260260
(``macosx``, ``iphoneos``, ``iphonesimulator``).
261261

262+
* ``%target-static-stdlib-path``: the path to the static standard library.
263+
264+
Add ``REQUIRES: static_stdlib`` to the test.
265+
262266
Always use ``%target-*`` substitutions unless you have a good reason. For
263267
example, an exception would be a test that checks how the compiler handles
264268
mixing module files for incompatible platforms (that test would need to compile

test/lit.cfg

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,3 +871,11 @@ config.substitutions.append(('%target-resilience-test', config.target_resilience
871871

872872
config.substitutions.append(('%llvm-profdata', config.llvm_profdata))
873873
config.substitutions.append(('%llvm-cov', config.llvm_cov))
874+
875+
# If static stdlib is present, enable static stdlib tests
876+
static_stdlib_path = os.path.join(os.path.join(config.swift_lib_dir,"swift_static"), config.target_sdk_name)
877+
libswiftCore_path = os.path.join(static_stdlib_path,"libswiftCore.a")
878+
if os.path.exists(libswiftCore_path):
879+
config.available_features.add("static_stdlib")
880+
config.substitutions.append(('%target-static-stdlib-path', static_stdlib_path))
881+
lit_config.note('using static stdlib path: %s' % static_stdlib_path)

0 commit comments

Comments
 (0)