From 9eafd945b263eb737d546220a8fe5a0d827f21ac Mon Sep 17 00:00:00 2001 From: Brandon Williams Date: Mon, 3 Mar 2025 10:12:12 -0800 Subject: [PATCH] Add test target without test support linking. --- Package.swift | 6 +++ Package@swift-6.0.swift | 6 +++ Tests/IssueReporting.xctestplan | 18 ++++++- .../WithExpectedIssueTests.swift | 49 +++++++++++++++++++ 4 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 Tests/IssueReportingTestsNoSupport/WithExpectedIssueTests.swift diff --git a/Package.swift b/Package.swift index f3a8668..7019db1 100644 --- a/Package.swift +++ b/Package.swift @@ -31,6 +31,12 @@ let package = Package( "IssueReportingTestSupport", ] ), + .testTarget( + name: "IssueReportingTestsNoSupport", + dependencies: [ + "IssueReporting", + ] + ), .target( name: "IssueReportingTestSupport" ), diff --git a/Package@swift-6.0.swift b/Package@swift-6.0.swift index 22f30ee..1d7c84f 100644 --- a/Package@swift-6.0.swift +++ b/Package@swift-6.0.swift @@ -30,6 +30,12 @@ let package = Package( "IssueReportingTestSupport", ] ), + .testTarget( + name: "IssueReportingTestsNoSupport", + dependencies: [ + "IssueReporting", + ] + ), .target( name: "IssueReportingTestSupport" ), diff --git a/Tests/IssueReporting.xctestplan b/Tests/IssueReporting.xctestplan index b07d2dc..cd3ed07 100644 --- a/Tests/IssueReporting.xctestplan +++ b/Tests/IssueReporting.xctestplan @@ -12,6 +12,20 @@ }, "testTargets" : [ + { + "target" : { + "containerPath" : "container:Examples\/Examples.xcodeproj", + "identifier" : "CADE79BA2C4A9D2D005A85F7", + "name" : "ExamplesTests" + } + }, + { + "target" : { + "containerPath" : "container:", + "identifier" : "XCTestDynamicOverlayTests", + "name" : "XCTestDynamicOverlayTests" + } + }, { "target" : { "containerPath" : "container:", @@ -22,8 +36,8 @@ { "target" : { "containerPath" : "container:", - "identifier" : "XCTestDynamicOverlayTests", - "name" : "XCTestDynamicOverlayTests" + "identifier" : "IssueReportingTestsNoSupport", + "name" : "IssueReportingTestsNoSupport" } } ], diff --git a/Tests/IssueReportingTestsNoSupport/WithExpectedIssueTests.swift b/Tests/IssueReportingTestsNoSupport/WithExpectedIssueTests.swift new file mode 100644 index 0000000..2da366b --- /dev/null +++ b/Tests/IssueReportingTestsNoSupport/WithExpectedIssueTests.swift @@ -0,0 +1,49 @@ +import IssueReporting +import Testing + +@Suite struct WithExpectedIssueTests { + @Test func sync() { + withExpectedIssue { + reportIssue() + } + } + + @Test func syncThrows() throws { + withExpectedIssue { + reportIssue() + throw SomeError() + } + } + + @Test func asyncAwaitBefore() async { + await withExpectedIssue { + await Task.yield() + reportIssue() + } + } + + @Test func asyncAwaitAfter() async { + await withExpectedIssue { + reportIssue() + await Task.yield() + } + } + + @Test func asyncAwaitBeforeThrows() async throws { + await withExpectedIssue { + await Task.yield() + reportIssue() + throw SomeError() + } + } + + @Test func asyncAwaitAfterThrows() async throws { + await withExpectedIssue { + reportIssue() + await Task.yield() + throw SomeError() + } + } +} + +private struct SomeError: Error {}