Skip to content

Commit be162e5

Browse files
committed
Merge branch 'main' into jgrynspan/162-redesign-value-capture
2 parents 301f3f9 + e4e0b88 commit be162e5

File tree

77 files changed

+1903
-479
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1903
-479
lines changed

.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
##
2+
## This source file is part of the Swift.org open source project
3+
##
4+
## Copyright (c) 2024-2025 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+
111
# EditorConfig documentation: https://editorconfig.org
212

313
root = true

.github/workflows/pull_request.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Pull request
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
tests:
13+
name: Test
14+
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
15+
with:
16+
linux_swift_versions: '["nightly-main", "nightly-6.2"]'
17+
linux_os_versions: '["amazonlinux2", "jammy"]'
18+
windows_swift_versions: '["nightly-main", "nightly-6.2"]'
19+
enable_macos_checks: true
20+
macos_exclude_xcode_versions: "[{\"xcode_version\": \"16.2\"}, {\"xcode_version\": \"16.3\"}]"
21+
enable_wasm_sdk_build: true
22+
soundness:
23+
name: Soundness
24+
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
25+
with:
26+
license_header_check_project_name: "Swift"
27+
docs_check_container_image: "swift:6.2-noble"
28+
format_check_enabled: false
29+
api_breakage_check_enabled: false

.license_header_template

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@@
2+
@@ This source file is part of the Swift.org open source project
3+
@@
4+
@@ Copyright (c) YEARS 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+
@@

.licenseignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Package.swift
2+
**/*.xctestplan
3+
**/*.xcscheme
4+
**/*.swiftoverlay

CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# Copyright (c) 2024 Apple Inc. and the Swift project authors
44
# Licensed under Apache License v2.0 with Runtime Library Exception
55
#
6-
# See http://swift.org/LICENSE.txt for license information
7-
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
6+
# See https://swift.org/LICENSE.txt for license information
7+
# See https://swift.org/CONTRIBUTORS.txt for Swift project authors
88

99
cmake_minimum_required(VERSION 3.19.6...3.29)
1010

@@ -19,6 +19,8 @@ if(POLICY CMP0157)
1919
endif()
2020
endif()
2121

22+
set(SWT_SOURCE_ROOT_DIR ${CMAKE_SOURCE_DIR})
23+
2224
project(SwiftTesting
2325
LANGUAGES CXX Swift)
2426

Dockerfile

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
# This source file is part of the Swift.org open source project
2-
#
3-
# Copyright (c) 2023 Apple Inc. and the Swift project authors
4-
# Licensed under Apache License v2.0 with Runtime Library Exception
5-
#
6-
# See https://swift.org/LICENSE.txt for license information
7-
# See https://swift.org/CONTRIBUTORS.txt for Swift project authors
1+
##
2+
## This source file is part of the Swift.org open source project
3+
##
4+
## Copyright (c) 2023 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+
##
810

911
FROM swiftlang/swift:nightly-main-jammy
1012

1113
# Set up the current build user in the same way done in the Swift.org CI system:
12-
# https://github.com/swiftlang/swift-docker/blob/main/swift-ci/master/ubuntu/22.04/Dockerfile
14+
# https://github.com/swiftlang/swift-docker/blob/main/swift-ci/main/ubuntu/22.04/Dockerfile
1315

1416
RUN groupadd -g 998 build-user && \
1517
useradd -m -r -u 998 -g build-user build-user
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<!--
2+
This source file is part of the Swift.org open source project
3+
4+
Copyright (c) 2023–2025 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+
# Environment variables in Swift Testing
12+
13+
This document lists the environment variables that Swift Testing currently uses.
14+
This list is meant for use by developers working on Swift Testing.
15+
16+
Those environment variables marked with `*` are defined by components outside
17+
Swift Testing. In general, environment variables that Swift Testing defines have
18+
names prefixed with `SWT_`.
19+
20+
> [!WARNING]
21+
> This document is not an API contract. The set of environment variables Swift
22+
> Testing uses may change at any time.
23+
24+
## Console output
25+
26+
| Variable Name | Value Type | Notes |
27+
|-|:-:|-|
28+
| `COLORTERM`\* | `String` | Used to determine if the current terminal supports 24-bit color. Common across UNIX-like platforms. |
29+
| `NO_COLOR`[\*](https://no-color.org) | `Any?` | If set to any value, disables color output regardless of terminal capabilities. |
30+
| `SWT_ENABLE_EXPERIMENTAL_CONSOLE_OUTPUT` | `Bool` | Used to enable or disable experimental console output. |
31+
| `SWT_SF_SYMBOLS_ENABLED` | `Bool` | Used to explicitly enable or disable SF&nbsp;Symbols support on macOS. |
32+
| `TERM`[\*](https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap08.html) | `String` | Used to determine if the current terminal supports 4- or 8-bit color. Common across UNIX-like platforms. |
33+
34+
## Error handling
35+
36+
| Variable Name | Value Type | Notes |
37+
|-|:-:|-|
38+
| `SWT_FOUNDATION_ERROR_BACKTRACING_ENABLED` | `Bool` | Used to explicitly enable or disable error backtrace capturing when an instance of `NSError` or `CFError` is created on Apple platforms. |
39+
| `SWT_SWIFT_ERROR_BACKTRACING_ENABLED` | `Bool` | Used to explicitly enable or disable error backtrace capturing when a Swift error is thrown. |
40+
41+
## Event streams
42+
43+
| Variable Name | Value Type | Notes |
44+
|-|:-:|-|
45+
| `SWT_EXPERIMENTAL_EVENT_STREAM_FIELDS_ENABLED` | `Bool` | Used to explicitly enable or disable experimental fields in the JSON event stream. |
46+
| `SWT_PRETTY_PRINT_JSON` | `Bool` | Used to enable pretty-printed JSON output to the event stream (for debugging purposes). |
47+
48+
## Exit tests
49+
50+
| Variable Name | Value Type | Notes |
51+
|-|:-:|-|
52+
| `SWT_BACKCHANNEL` | `CInt`/`HANDLE` | A file descriptor (handle on Windows) to which the exit test's events are written. |
53+
| `SWT_CAPTURED_VALUES` | `CInt`/`HANDLE` | A file descriptor (handle on Windows) containing captured values passed to the exit test. |
54+
| `SWT_CLOSEFROM` | `CInt` | Used on OpenBSD to emulate `posix_spawn_file_actions_addclosefrom_np()`. |
55+
| `SWT_EXIT_TEST_ID` | `String` (JSON) | Specifies which exit test to run. |
56+
| `XCTestBundlePath`\* | `String` | Used on Apple platforms to determine if Xcode is hosting the test run. |
57+
58+
## Miscellaneous
59+
60+
| Variable Name | Value Type | Notes |
61+
|-|:-:|-|
62+
| `CFFIXED_USER_HOME`\* | `String` | Used on Apple platforms to determine the user's home directory. |
63+
| `HOME`[\*](https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap08.html) | `String` | Used to determine the user's home directory. |
64+
| `SIMULATOR_RUNTIME_BUILD_VERSION`\* | `String` | Used when running in the iOS (etc.) Simulator to determine the simulator's version. |
65+
| `SIMULATOR_RUNTIME_VERSION`\* | `String` | Used when running in the iOS (etc.) Simulator to determine the simulator's version. |
66+
| `SWT_USE_LEGACY_TEST_DISCOVERY` | `Bool` | Used to explicitly enable or disable legacy test discovery. |

Package.swift

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version: 6.1
1+
// swift-tools-version: 6.2
22

33
//
44
// This source file is part of the Swift.org open source project
@@ -164,7 +164,7 @@ let package = Package(
164164
"Testing",
165165
],
166166
path: "Tests/_MemorySafeTestingTests",
167-
swiftSettings: .packageSettings + .strictMemorySafety
167+
swiftSettings: .packageSettings + [.strictMemorySafety()]
168168
),
169169
.testTarget(
170170
name: "SubexpressionShowcase",
@@ -276,6 +276,7 @@ let package = Package(
276276
"Testing",
277277
],
278278
path: "Sources/Overlays/_Testing_WinSDK",
279+
exclude: ["CMakeLists.txt"],
279280
swiftSettings: .packageSettings + .enableLibraryEvolution()
280281
),
281282

@@ -376,17 +377,6 @@ extension Array where Element == PackageDescription.SwiftSetting {
376377
// proposal via Swift Evolution.
377378
.enableExperimentalFeature("SymbolLinkageMarkers"),
378379

379-
// This setting is no longer needed when building with a 6.2 or later
380-
// toolchain now that SE-0458 has been accepted and implemented, but it is
381-
// needed in order to preserve support for building with 6.1 development
382-
// snapshot toolchains. (Production 6.1 toolchains can build the testing
383-
// library even without this setting since this experimental feature is
384-
// _suppressible_.) This setting can be removed once the minimum supported
385-
// toolchain for building the testing library is ≥ 6.2. It is not needed
386-
// in the CMake settings since that is expected to build using a
387-
// new-enough toolchain.
388-
.enableExperimentalFeature("AllowUnsafeAttribute"),
389-
390380
.enableUpcomingFeature("InferIsolatedConformances"),
391381

392382
// When building as a package, the macro plugin always builds as an
@@ -443,18 +433,6 @@ extension Array where Element == PackageDescription.SwiftSetting {
443433

444434
return result
445435
}
446-
447-
/// Settings necessary to enable Strict Memory Safety, introduced in
448-
/// [SE-0458: Opt-in Strict Memory Safety Checking](https://github.com/swiftlang/swift-evolution/blob/main/proposals/0458-strict-memory-safety.md#swiftpm-integration).
449-
static var strictMemorySafety: Self {
450-
#if compiler(>=6.2)
451-
// FIXME: Adopt official `.strictMemorySafety()` condition once the minimum
452-
// supported toolchain is 6.2.
453-
[.unsafeFlags(["-strict-memory-safety"])]
454-
#else
455-
[]
456-
#endif
457-
}
458436
}
459437

460438
extension Array where Element == PackageDescription.CXXSetting {
@@ -475,16 +453,16 @@ extension Array where Element == PackageDescription.CXXSetting {
475453
.define("SWT_NO_LIBDISPATCH", .whenEmbedded()),
476454
]
477455

478-
// Capture the testing library's version as a C++ string constant.
456+
// Capture the testing library's commit info as C++ constants.
479457
if let git {
480-
let testingLibraryVersion = if let tag = git.currentTag {
481-
tag
482-
} else if git.hasUncommittedChanges {
483-
"\(git.currentCommit) (modified)"
484-
} else {
485-
git.currentCommit
458+
result.append(.define("SWT_TESTING_LIBRARY_COMMIT_HASH", to: #""\#(git.currentCommit)""#))
459+
if git.hasUncommittedChanges {
460+
result.append(.define("SWT_TESTING_LIBRARY_COMMIT_MODIFIED", to: "1"))
486461
}
487-
result.append(.define("SWT_TESTING_LIBRARY_VERSION", to: #""\#(testingLibraryVersion)""#))
462+
} else if let gitHubSHA = Context.environment["GITHUB_SHA"] {
463+
// When building in GitHub Actions, the git command may fail to get us the
464+
// commit hash, so check if GitHub shared it with us instead.
465+
result.append(.define("SWT_TESTING_LIBRARY_COMMIT_HASH", to: #""\#(gitHubSHA)""#))
488466
}
489467

490468
return result

Sources/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# Copyright (c) 2024 Apple Inc. and the Swift project authors
44
# Licensed under Apache License v2.0 with Runtime Library Exception
55
#
6-
# See http://swift.org/LICENSE.txt for license information
7-
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
6+
# See https://swift.org/LICENSE.txt for license information
7+
# See https://swift.org/CONTRIBUTORS.txt for Swift project authors
88

99
set(SwiftTesting_MACRO "<auto>" CACHE STRING
1010
"Path to SwiftTesting macro plugin, or '<auto>' for automatically building it")

Sources/Overlays/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
# Copyright (c) 2024–2025 Apple Inc. and the Swift project authors
44
# Licensed under Apache License v2.0 with Runtime Library Exception
55
#
6-
# See http://swift.org/LICENSE.txt for license information
7-
# See http://swift.org/CONTRIBUTORS.txt for Swift project authors
6+
# See https://swift.org/LICENSE.txt for license information
7+
# See https://swift.org/CONTRIBUTORS.txt for Swift project authors
88

99
add_subdirectory(_Testing_AppKit)
1010
add_subdirectory(_Testing_CoreGraphics)
1111
add_subdirectory(_Testing_CoreImage)
1212
add_subdirectory(_Testing_Foundation)
1313
add_subdirectory(_Testing_UIKit)
14+
add_subdirectory(_Testing_WinSDK)

0 commit comments

Comments
 (0)