File tree Expand file tree Collapse file tree 5 files changed +31
-17
lines changed
Sources/_TestingInternals Expand file tree Collapse file tree 5 files changed +31
-17
lines changed Original file line number Diff line number Diff line change @@ -470,20 +470,13 @@ extension Array where Element == PackageDescription.CXXSetting {
470
470
471
471
// Capture the testing library's commit info as C++ constants.
472
472
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
-
479
473
result. append ( . define( " SWT_TESTING_LIBRARY_COMMIT_HASH " , to: #"" \#( git. currentCommit) ""# ) )
480
474
if git. hasUncommittedChanges {
481
475
result. append ( . define( " SWT_TESTING_LIBRARY_COMMIT_MODIFIED " , to: " 1 " ) )
482
476
}
483
477
} else if let gitHubSHA = Context . environment [ " GITHUB_SHA " ] {
484
478
// When building in GitHub Actions, the git command may fail to get us the
485
479
// commit hash, so check if GitHub shared it with us instead.
486
- result. append ( . define( " SWT_TESTING_LIBRARY_VERSION " , to: " 0 " ) )
487
480
result. append ( . define( " SWT_TESTING_LIBRARY_COMMIT_HASH " , to: #"" \#( gitHubSHA) ""# ) )
488
481
}
489
482
Original file line number Diff line number Diff line change 9
9
set (CMAKE_CXX_SCAN_FOR_MODULES 0)
10
10
11
11
include (GitCommit)
12
- include (LibraryVersion)
13
12
include (TargetTriple)
14
13
add_library (_TestingInternals STATIC
15
14
Discovery.cpp
Original file line number Diff line number Diff line change 10
10
11
11
#include " Versions.h"
12
12
13
+ #include < array>
14
+ #include < algorithm>
15
+ #include < iterator>
16
+
13
17
const char *swt_getTestingLibraryVersion (void ) {
14
18
#if defined(SWT_TESTING_LIBRARY_VERSION)
19
+ // The current environment explicitly specifies a version string to return.
15
20
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[] = {
25
+ #pragma clang diagnostic push
26
+ #pragma clang diagnostic ignored "-Wc23-extensions"
27
+ #embed " ../../VERSION.txt"
28
+ #pragma clang diagnostic pop
29
+ };
30
+
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 {};
34
+ auto i = std::find_if (std::begin (version), std::end (version), [] (char c) {
35
+ return c == ' \r ' || c == ' \n ' ;
36
+ });
37
+ std::copy (std::begin (version), i, result.begin ());
38
+ return result;
39
+ }();
40
+
41
+ return version.data ();
16
42
#else
17
- #warning SWT_TESTING_LIBRARY_VERSION not defined: testing library version is unavailable
43
+ #warning SWT_TESTING_LIBRARY_VERSION not defined and VERSION.txt not found : testing library version is unavailable
18
44
return nullptr ;
19
45
#endif
20
46
}
Original file line number Diff line number Diff line change
1
+ 6.3-dev
Original file line number Diff line number Diff line change 1
1
##
2
2
## This source file is part of the Swift.org open source project
3
3
##
4
- ## Copyright (c) 2024 Apple Inc. and the Swift project authors
4
+ ## Copyright (c) 2024–2025 Apple Inc. and the Swift project authors
5
5
## Licensed under Apache License v2.0 with Runtime Library Exception
6
6
##
7
7
## See https://swift.org/LICENSE.txt for license information
8
8
## See https://swift.org/CONTRIBUTORS.txt for Swift project authors
9
9
##
10
10
11
- # The current version of the Swift Testing release. For release branches,
12
- # remember to remove -dev.
13
- set (SWT_TESTING_LIBRARY_VERSION "6.3-dev" )
14
-
15
- message (STATUS "Swift Testing version: ${SWT_TESTING_LIBRARY_VERSION} " )
16
- add_compile_definitions (
17
- "$<$<COMPILE_LANGUAGE:CXX>:SWT_TESTING_LIBRARY_VERSION=\" ${SWT_TESTING_LIBRARY_VERSION} \" >" )
11
+ # The library version is now tracked in VERSION.txt at the root directory of the
12
+ # repository. This file will be removed in a future commit.
You can’t perform that action at this time.
0 commit comments