Skip to content

Merge 'main' branch to 'release/6.2' #1088

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Apr 24, 2025

Conversation

stmontgomery
Copy link
Contributor

This merges the main branch into the release/6.2 branch.

Note: The Swift Testing project will be periodically performing "backwards" merges like this for a period which extends beyond the date when the 6.2 branches were cut, since nearly all contributions are intended to be included in the 6.2 release.

Once this PR has been merged, I will adjust the milestones on the PRs included in this merge to be 6.2 wherever appropriate.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

grynspan and others added 24 commits April 4, 2025 16:28
Revert "Ensure `Locked+Platform.swift` is not stripped when statically linking. (swiftlang#1035)"
This PR has a few minor changes:

- The default implementation of
`DiscoverableAsTestContent._testContentTypeNameHint` is not present if
`SWT_NO_LEGACY_TEST_DISCOVERY` is defined;
- Fixed the precondition in `TestContentKind.init(stringLiteral:)` so it
doesn't call `utf8CodeUnitCount` on single-character static strings;
- The implementation of `TestContentKind._fourCCValue` uses `isprint()`
to check if the kind value looks like a FourCC rather than calling
ICU-based functions;
- Fixed a type in a comment on
`SectionBounds.Kind.segmentAndSectionName`; and
- Simplified the implementation of
`TestContentKind.commentRepresentation` (in the macro target).

### Checklist:

- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.
This PR uses the entire 256 bits of the computed SHA-256 hash for an
exit test's ID, not just the first 128. They're there, might as well use
them.

### Checklist:

- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.
The special-case signal handling implemented for Windows doesn't
currently set a handler for `SIGABRT_COMPAT` (which is a synonym of
`SIGABRT` with a different value.) This PR adds it to the list of
signals we install handlers for.

### Checklist:

- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.
…get. (swiftlang#1043)

This PR adds preliminary/experimental support for Embedded Swift _to the
`_TestDiscovery` target only_ when building Swift Testing as a package.
To try it out, you must set the environment variable `SWT_EMBEDDED` to
`true` before building.

Tested with the following incantation using the 2025-03-28 main-branch
toolchain:

```sh
SWT_EMBEDDED=1 swift build --target _TestDiscovery --triple arm64-apple-macosx
```

### Checklist:

- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.
This PR replaces the private `_CurrentContainer` class used to store the
current exit test with a bare pointer. The class is prone to duplicate
definitions, but we really just use it as a glorified box type for the
move-only `ExitTest`, so an immortal pointer will work just as well.

Works around rdar://148837303.

### Checklist:

- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.
…n code for synchronous test functions (swiftlang#1067)

This fixes a compilation error in code expanded from the `@Test` macro
when it's attached to a synchronous (i.e. non-`async`) test function in
a context where there is a concrete type named `Actor`. For example, the
following code reproduces the error:

```swift
// In MyApp
public class Actor {}

// In test code
import Testing
import MyApp

// ❌ 'any' has no effect on concrete type 'Actor'
//  - 'isolated' parameter type 'Actor?' does not conform to 'Actor' or 'DistributedActor'
@test func example() /* No 'async' */ {}
```

The macro code includes an unqualified reference to a type by that name,
but it's intended to refer to the protocol in Swift's `_Concurrency`
module. The fix is to ensure the macro's reference to this protocol is
fully-qualified with a module name.

This was first reported on the Swift Forums in
https://forums.swift.org/t/error-isolated-parameter-type-actor-does-not-conform-to-actor-or-distributedactor/79190.
This bug was introduced in swiftlang#747, which first landed in Swift 6.1 and
Xcode 16.3.

### Checklist:

- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.
This PR promotes attachments to API and makes the appropriate changes to
match what was approved in the review of
[ST-0009](https://github.com/swiftlang/swift-evolution/blob/main/proposals/testing/0009-attachments.md).

### Checklist:

- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.
Introduce a severity level when recording issues

### Motivation:

In order to create issues that don't fail a test this introduces a
parameter to specify the severity of the issue. This is in support of
work added here for an issue severity:
swiftlang#931

This is experimental.

Example usage:
`Issue.record("My comment", severity: .warning)`

### Modifications:

I modified the `Issue.record` method signature to take in a severity
level so that users can create issues that are not failing.

### Checklist:

- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.
- [x] Add tests
This PR adds support for the `--attachments-path` CLI argument on `swift
test` as approved in
[ST-0009](https://github.com/swiftlang/swift-evolution/blob/main/proposals/testing/0009-attachments.md).
We will maintain support for the older `--experimental-attachments-path`
version through Swift 6.2.

Resolves rdar://147753783.

### Checklist:

- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.
… `StatusAtExit`. (swiftlang#1073)

This PR adds `CustomStringConvertible` conformance to these data/value
types so that they are presented reasonably in expectation failure
messages or when printed.

Strictly speaking, API changes should go through a review, but there's
not really anything to review here, so with the consent of the Testing
Workgroup we can amend the exit tests proposal to retroactively include
these conformances.

See also: swiftlang/swift-evolution#2789

### Checklist:

- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.
Add `isFailure` var to `Issue`

### Motivation:

This adds a variable to `Issue` in order to inspect if an issue
isFailing. This will be nice when inspecting an issue after it is
recorded.

### Modifications:

- Add `isFailure` variable
- Update existing code to use `isFailure` 

### Checklist:

- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.
This PR changes the `@Test` and `#expect()` macros so they handle
`unsafe` expressions the same way `try` and `await` expressions are
handled. The propagation rules for `unsafe` aren't the same as for `try`
and `await` (i.e. it doesn't colour the calling function), but the
general way we handle the keyword is the same.

I haven't attempted to avoid inserting `unsafe` if a function is not
marked `@unsafe` as it complicates the necessary logic but has no
effects at runtime.

### Checklist:

- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.
This PR implements an experimental form of state capture in exit tests.
If you specify a capture list on the test's body closure and explicitly
write the type of each captured value, _and_ each value conforms to
`Sendable`, `Codable`, and (implicitly) `Copyable`, we'll encode them
and send them "over the wire" to the child process:

```swift
let a = Int.random(in: 100 ..< 200)
await #expect(exitsWith: .failure) { [a = a as Int] in
  assert(a > 500)
}
```

This PR is incomplete. Among other details:

- [x] Need to properly transmit the data, not stuff it in an environment
variable
- [x] Need to implement diagnostics correctly
- [x] Need to figure out if `ExitTest.CapturedValue` and
`__Expression.Value` have any synergy. _(They do, but it's beyond the
scope of this initial/experimental PR.)_

We are ultimately constrained by the language here as we don't have real
type information for the captured values, nor can we infer captures by
inspecting the syntax of the exit test body (hence the need for an
explicit capture list with types.) If we had something like `decltype()`
we could apply during macro expansion, you wouldn't need to write `x = x
as T` and could just write `x`. The macro would use `decltype()` to
produce a thunk function of the form:

```swift
@sendable func __compiler_generated_name__(aʹ: decltype(a), bʹ: decltype(b), cʹ: decltype(c)) async throws {
  let (a, b, c) = (aʹ, bʹ, cʹ)
  try await { /* ... */ }()
}
```

### Checklist:

- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.
…the compiler when SWT_NO_EXIT_TESTS is defined.
… when building for non-Embedded without a fallback condition (swiftlang#1081)

This fixes an unintended side effect from swiftlang#1043 where the
`SWT_NO_LEGACY_TEST_DISCOVERY` compilation conditional was being applied
when building for non-Embedded.

### Checklist:

- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.
…t`. (swiftlang#1076)

This PR allows `DiscoverableAsTestContent.Context` to be less-aligned
than `UInt` so long as its stride remains the same. It also removes the
sneaky conformance of `ExitTest` to `DiscoverableAsTestContent`, opting
instead to use an internal type. Since the conformance to
`DiscoverableAsTestContent` and the implementation of `__store()` form a
closed system (where all type information is controlled by Swift Testing
at runtime), we can do this without breaking any ABI. I've updated
ABI/TestContent.md to remove some of the relevant implementation
details.

### Checklist:

- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.

---------

Co-authored-by: Stuart Montgomery <[email protected]>
…ry target (swiftlang#1082)

This enables Library Evolution (LE) for the `_TestDiscovery` target in
Swift package-based builds. The CMake-based build is already configured
to enable LE for this target, so this is just matching behavior.

(Note that we already enable LE for several other targets which vend
public API as of swiftlang#951.)

### Checklist:

- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.
…ting 6.1 development snapshot toolchains (swiftlang#1084)

This fixes a build failure when attempting to build the `main` branch
using a 6.1 development snapshot toolchain. This failure was introduced
by swiftlang#1069, which added usage of the new `@unsafe` attribute, and the
failure was revealed when we set up the 6.1 CI jobs in swiftlang#1083.

Here are some relevant related Swift PRs which give context around these
changes:

- swiftlang/swift#75413
- swiftlang/swift#79645

See the code comment for more details.

### Checklist:

- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.
@stmontgomery stmontgomery added the build 🧱 Affects the project's build configuration or process label Apr 21, 2025
@stmontgomery stmontgomery added this to the Swift 6.2 milestone Apr 21, 2025
@stmontgomery stmontgomery self-assigned this Apr 21, 2025
@stmontgomery
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@briancroom briancroom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@stmontgomery
Copy link
Contributor Author

The macOS and Linux CI failures are expected to be resolved by swiftlang/swift#80830, but the release of a new main snapshot toolchain is currently blocked for unrelated reasons. Proceeding to merge.

@stmontgomery stmontgomery added integration ⚙️ Integrating work to release branches and removed build 🧱 Affects the project's build configuration or process labels Apr 24, 2025
@stmontgomery stmontgomery merged commit 63d4ef2 into swiftlang:release/6.2 Apr 24, 2025
1 of 3 checks passed
@stmontgomery stmontgomery deleted the main-6.2-merge branch April 24, 2025 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration ⚙️ Integrating work to release branches
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants