File tree Expand file tree Collapse file tree 5 files changed +50
-12
lines changed Expand file tree Collapse file tree 5 files changed +50
-12
lines changed Original file line number Diff line number Diff line change @@ -125,7 +125,7 @@ let simulatorVersion: String = {
125125///
126126/// This value is not part of the public interface of the testing library.
127127var testingLibraryVersion: String {
128- SWT_TESTING_LIBRARY_VERSION
128+ swt_getTestingLibraryVersion ( ) . flatMap ( String . init ( validatingCString : ) ) ?? " unknown "
129129}
130130
131131/// A human-readable string describing the Swift Standard Library's version.
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ set(CMAKE_CXX_SCAN_FOR_MODULES 0)
1111include (LibraryVersion)
1212add_library (_TestingInternals STATIC
1313 Discovery.cpp
14+ Versions.cpp
1415 WillThrow.cpp)
1516target_include_directories (_TestingInternals PUBLIC
1617 ${CMAKE_CURRENT_SOURCE_DIR} /include )
Original file line number Diff line number Diff line change 1+ //
2+ // This source file is part of the Swift.org open source project
3+ //
4+ // Copyright (c) 2024 Apple Inc. and the Swift project authors
5+ // Licensed under Apache License v2.0 with Runtime Library Exception
6+ //
7+ // See https://swift.org/LICENSE.txt for license information
8+ // See https://swift.org/CONTRIBUTORS.txt for Swift project authors
9+ //
10+
11+ #include " Versions.h"
12+
13+ const char *swt_getTestingLibraryVersion (void ) {
14+ #if defined(_SWT_TESTING_LIBRARY_VERSION)
15+ return _SWT_TESTING_LIBRARY_VERSION;
16+ #else
17+ #warning _SWT_TESTING_LIBRARY_VERSION not defined: testing library version is unavailable
18+ return nullptr ;
19+ #endif
20+ }
Original file line number Diff line number Diff line change 3232/// An attribute that renames a C symbol in Swift.
3333#define SWT_SWIFT_NAME (name ) __attribute__((swift_name(#name)))
3434
35- /// The testing library version from the package manifest.
36- ///
37- /// - Bug: The value provided to the compiler (`_SWT_TESTING_LIBRARY_VERSION`)
38- /// is not visible in Swift, so this second macro is needed.
39- /// ((#43521)[https://github.com/swiftlang/swift/issues/43521])
40- #if defined(_SWT_TESTING_LIBRARY_VERSION )
41- #define SWT_TESTING_LIBRARY_VERSION _SWT_TESTING_LIBRARY_VERSION
42- #else
43- #define SWT_TESTING_LIBRARY_VERSION "unknown"
44- #endif
45-
4635#endif // SWT_DEFINES_H
Original file line number Diff line number Diff line change 1+ //
2+ // This source file is part of the Swift.org open source project
3+ //
4+ // Copyright (c) 2024 Apple Inc. and the Swift project authors
5+ // Licensed under Apache License v2.0 with Runtime Library Exception
6+ //
7+ // See https://swift.org/LICENSE.txt for license information
8+ // See https://swift.org/CONTRIBUTORS.txt for Swift project authors
9+ //
10+
11+ #if !defined(SWT_VERSIONS_H )
12+ #define SWT_VERSIONS_H
13+
14+ #include "Defines.h"
15+
16+ SWT_ASSUME_NONNULL_BEGIN
17+
18+ /// Get the human-readable version of the testing library.
19+ ///
20+ /// - Returns: A human-readable string describing the version of the testing
21+ /// library, or `nullptr` if no version information is available. This
22+ /// string's value and format may vary between platforms, releases, or any
23+ /// other conditions. Do not attempt to parse it.
24+ SWT_EXTERN const char * _Nullable swt_getTestingLibraryVersion (void );
25+
26+ SWT_ASSUME_NONNULL_END
27+
28+ #endif
You can’t perform that action at this time.
0 commit comments