Skip to content

Commit

Permalink
Publicize Swift Testing's underlying Test.ID (#131)
Browse files Browse the repository at this point in the history
* Publicize Swift Testing's underlying Test.ID

This allows Issue Reporting's provided ID to be compared to the
underlying Test.ID value from Swift Testing.

* Add Xcode 16 to CI

* Update ci.yml

* fix

* fix
  • Loading branch information
stephencelis authored Sep 11, 2024
1 parent b185073 commit bc2a151
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ jobs:
- debug
- release
xcode:
- 15.4
- 15.2
- 15.4
- 16_beta_6
name: macOS
runs-on: macos-14
steps:
Expand All @@ -47,12 +48,15 @@ jobs:
config:
- Debug
- Release
xcode:
- 15.4
- 16_beta_6
name: Examples
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- name: Select Xcode
run: sudo xcode-select -s /Applications/Xcode_15.4.app
run: sudo xcode-select -s /Applications/Xcode_${{ matrix.xcode }}.app
- name: Run tests
run: make CONFIG=${{ matrix.config }} test-examples

Expand Down Expand Up @@ -81,7 +85,7 @@ jobs:
matrix:
toolchain:
- wasm-5.9.2-RELEASE
- wasm-5.10.0-RELEASE
- wasm-5.10.0-RELEASE
steps:
- name: Cache toolchains
uses: actions/cache@v3
Expand Down
2 changes: 1 addition & 1 deletion Examples/ExamplesTests/SwiftTestingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
struct SwiftTestingTests_Debug {
@Test func context() {
switch TestContext.current {
case .xcTest:
case .swiftTesting:
#expect(Bool(true))
default:
Issue.record()
Expand Down
6 changes: 5 additions & 1 deletion Sources/IssueReporting/IsTesting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@
if environment.keys.contains("XCTestBundlePath") { return true }
if environment.keys.contains("XCTestConfigurationFilePath") { return true }
if environment.keys.contains("XCTestSessionIdentifier") { return true }

return arguments.contains { argument in
let path = URL(fileURLWithPath: argument)
return path.lastPathComponent == "xctest" || path.pathExtension == "xctest"
return path.lastPathComponent == "swiftpm-testing-helper"
|| argument == "--testing-library"
|| path.lastPathComponent == "xctest"
|| path.pathExtension == "xctest"
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/IssueReporting/TestContext.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// A type representing the context in which a test is being run, _i.e._ either in Swift's native
/// Testing framework, or Xcode's XCTest framework.
public enum TestContext: Equatable {
public enum TestContext: Equatable, Sendable {
/// The Swift Testing framework.
case swiftTesting(Testing?)

Expand Down Expand Up @@ -37,14 +37,14 @@ public enum TestContext: Equatable {
return true
}

public struct Testing: Equatable {
public struct Testing: Equatable, Sendable {
public let test: Test

public struct Test: Equatable, Hashable, Identifiable, Sendable {
public let id: ID

public struct ID: Equatable, Hashable, @unchecked Sendable {
fileprivate let rawValue: AnyHashable
public let rawValue: AnyHashable
}
}
}
Expand Down

0 comments on commit bc2a151

Please sign in to comment.