File tree Expand file tree Collapse file tree 5 files changed +35
-16
lines changed
Sources/_TestingInternals Expand file tree Collapse file tree 5 files changed +35
-16
lines changed Original file line number Diff line number Diff line change @@ -470,12 +470,6 @@ extension Array where Element == PackageDescription.CXXSetting {
470470
471471 // Capture the testing library's commit info as C++ constants.
472472 if let git {
473- if let tag = git. currentTag {
474- result. append ( . define( " SWT_TESTING_LIBRARY_VERSION " , to: #"" \#( tag) ""# ) )
475- } else {
476- result. append ( . define( " SWT_TESTING_LIBRARY_VERSION " , to: " 0 " ) )
477- }
478-
479473 result. append ( . define( " SWT_TESTING_LIBRARY_COMMIT_HASH " , to: #"" \#( git. currentCommit) ""# ) )
480474 if git. hasUncommittedChanges {
481475 result. append ( . define( " SWT_TESTING_LIBRARY_COMMIT_MODIFIED " , to: " 1 " ) )
Original file line number Diff line number Diff line change 99set (CMAKE_CXX_SCAN_FOR_MODULES 0)
1010
1111include (GitCommit)
12- include (LibraryVersion)
1312include (TargetTriple)
1413add_library (_TestingInternals STATIC
1514 Discovery.cpp
Original file line number Diff line number Diff line change 1010
1111#include " Versions.h"
1212
13+ #include < mutex>
14+
1315const char *swt_getTestingLibraryVersion (void ) {
1416#if defined(SWT_TESTING_LIBRARY_VERSION)
17+ // The current environment explicitly specifies a version string to return.
1518 return SWT_TESTING_LIBRARY_VERSION;
19+ #elif __has_embed("../../version.txt")
20+ // Read the version from version.txt at the root of the package's repository.
21+ static char version[] = {
22+ #pragma clang diagnostic push
23+ #pragma clang diagnostic ignored "-Wc23-extensions"
24+ #embed " ../../version.txt" suffix(, '\0')
25+ #pragma clang diagnostic pop
26+ };
27+
28+ // Trim any trailing whitespace.
29+ static std::once_flag once;
30+ std::call_once (once, [] {
31+ auto i = std::find_if (std::begin (version), std::end (version), std::isspace);
32+ if (i != std::end (version)) {
33+ *i = ' \0 ' ;
34+ }
35+ });
36+
37+ return version;
1638#else
17- #warning SWT_TESTING_LIBRARY_VERSION not defined: testing library version is unavailable
39+ #warning SWT_TESTING_LIBRARY_VERSION not defined and version.txt not found : testing library version is unavailable
1840 return nullptr ;
1941#endif
2042}
Original file line number Diff line number Diff line change 11# This source file is part of the Swift.org open source project
22#
3- # Copyright (c) 2024 Apple Inc. and the Swift project authors
3+ # Copyright (c) 2024–2025 Apple Inc. and the Swift project authors
44# Licensed under Apache License v2.0 with Runtime Library Exception
55#
66# See http://swift.org/LICENSE.txt for license information
77# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
88
9- # The current version of the Swift Testing release. For release branches,
10- # remember to remove -dev.
11- set (SWT_TESTING_LIBRARY_VERSION "6.3-dev" )
12-
13- message (STATUS "Swift Testing version: ${SWT_TESTING_LIBRARY_VERSION} " )
14- add_compile_definitions (
15- "$<$<COMPILE_LANGUAGE:CXX>:SWT_TESTING_LIBRARY_VERSION=\" ${SWT_TESTING_LIBRARY_VERSION} \" >" )
9+ # The library version is now tracked in version.txt at the root directory of the
10+ # repository. This file will be removed in a future commit.
Original file line number Diff line number Diff line change 1+ 6.3-dev
2+
3+ # This source file is part of the Swift.org open source project
4+ #
5+ # Copyright (c) 2025 Apple Inc. and the Swift project authors
6+ # Licensed under Apache License v2.0 with Runtime Library Exception
7+ #
8+ # See http://swift.org/LICENSE.txt for license information
9+ # See http://swift.org/CONTRIBUTORS.txt for Swift project authors
You can’t perform that action at this time.
0 commit comments