Skip to content

Commit d72d72a

Browse files
authored
Merge branch 'main' into jgrynspan/remove-wasm-workaround
2 parents 64659ac + 05b4639 commit d72d72a

File tree

5 files changed

+35
-21
lines changed

5 files changed

+35
-21
lines changed

.github/workflows/pull_request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ jobs:
2323
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
2424
with:
2525
license_header_check_project_name: "Swift"
26-
docs_check_enabled: false
26+
docs_check_container_image: "swift:6.2-noble"
2727
format_check_enabled: false
2828
api_breakage_check_enabled: false

Sources/Testing/Testing.docc/Documentation.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@ their problems.
3535

3636
#### Related videos
3737

38-
@Links(visualStyle: compactGrid) {
39-
- <doc://com.apple.documentation/videos/play/wwdc2024/10179>
40-
- <doc://com.apple.documentation/videos/play/wwdc2024/10195>
41-
}
38+
- [Meet Swift Testing](https://developer.apple.com/videos/play/wwdc2024/10179)
39+
- [Go further with Swift Testing](https://developer.apple.com/videos/play/wwdc2024/10195)
4240

4341
## Topics
4442

Sources/Testing/Testing.docc/MigratingFromXCTest.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -556,9 +556,11 @@ test function with an instance of this trait type to control whether it runs:
556556
}
557557
}
558558

559-
<!-- TODO: document Test.cancel() and Test.Case.cancel() here
559+
<!-- TODO: document Test.cancel() and Test.Case.cancel() here, and update
560+
relevant links to use proper DocC symbol references.
561+
560562
If a test has already started running and you determine it cannot complete and
561-
should end early without failing, use ``Test/cancel(_:sourceLocation:)`` instead
563+
should end early without failing, use `Test/cancel(_:sourceLocation:)` instead
562564
of [`XCTSkip`](https://developer.apple.com/documentation/xctest/xctskip) to
563565
cancel the task associated with the current test:
564566
@@ -592,7 +594,7 @@ cancel the task associated with the current test:
592594
}
593595
594596
If the test is parameterized and you only want to cancel the current test case
595-
rather than the entire test, use ``Test/Case/cancel(_:sourceLocation:)``.
597+
rather than the entire test, use `Test/Case/cancel(_:sourceLocation:)`.
596598
-->
597599

598600
### Annotate known issues

Sources/_TestingInternals/Versions.cpp

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,44 @@
1313
#include <array>
1414
#include <algorithm>
1515
#include <iterator>
16+
#include <mutex>
1617

1718
const char *swt_getTestingLibraryVersion(void) {
1819
#if defined(SWT_TESTING_LIBRARY_VERSION)
1920
// The current environment explicitly specifies a version string to return.
21+
// All CMake builds should take this path (see CompilerSettings.cmake.)
2022
return SWT_TESTING_LIBRARY_VERSION;
21-
#elif __has_embed("../../VERSION.txt")
22-
static constinit auto version = [] () constexpr {
23-
// Read the version from version.txt at the root of the package's repo.
24-
char version[] = {
23+
#elif __clang_major__ >= 17 && defined(__has_embed)
24+
#if __has_embed("../../VERSION.txt")
25+
// Read the version from version.txt at the root of the package's repo.
26+
static char version[] = {
2527
#pragma clang diagnostic push
2628
#pragma clang diagnostic ignored "-Wc23-extensions"
27-
#embed "../../VERSION.txt"
29+
#embed "../../VERSION.txt" suffix(, '\0')
2830
#pragma clang diagnostic pop
29-
};
31+
};
3032

31-
// Copy the first line from the C string into a C array so that we can
32-
// return it from this closure.
33-
std::array<char, std::size(version) + 1> result {};
33+
// Zero out the newline character and anything after it.
34+
static std::once_flag once;
35+
std::call_once(once, [] {
3436
auto i = std::find_if(std::begin(version), std::end(version), [] (char c) {
3537
return c == '\r' || c == '\n';
3638
});
37-
std::copy(std::begin(version), i, result.begin());
38-
return result;
39-
}();
39+
std::fill(i, std::end(version), '\0');
40+
});
4041

41-
return version.data();
42+
return version;
4243
#else
4344
#warning SWT_TESTING_LIBRARY_VERSION not defined and VERSION.txt not found: testing library version is unavailable
4445
return nullptr;
4546
#endif
47+
#elif defined(__OpenBSD__)
48+
// OpenBSD's version of clang doesn't support __has_embed or #embed.
49+
return nullptr;
50+
#else
51+
#warning SWT_TESTING_LIBRARY_VERSION not defined and could not read from VERSION.txt at compile time: testing library version is unavailable
52+
return nullptr;
53+
#endif
4654
}
4755

4856
void swt_getTestingLibraryCommit(const char *_Nullable *_Nonnull outHash, bool *outModified) {

cmake/modules/shared/CompilerSettings.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,9 @@ if(CMAKE_SYSTEM_NAME STREQUAL "WASI")
4242
add_compile_definitions("SWT_NO_DYNAMIC_LINKING")
4343
add_compile_definitions("SWT_NO_PIPES")
4444
endif()
45+
46+
file(STRINGS "../VERSION.txt" SWT_TESTING_LIBRARY_VERSION LIMIT_COUNT 1)
47+
if(SWT_TESTING_LIBRARY_VERSION)
48+
message(STATUS "Swift Testing version: ${SWT_TESTING_LIBRARY_VERSION}")
49+
add_compile_definitions("$<$<COMPILE_LANGUAGE:CXX>:SWT_TESTING_LIBRARY_VERSION=\"${SWT_TESTING_LIBRARY_VERSION}\">")
50+
endif()

0 commit comments

Comments
 (0)