pointfreeco / swift-issue-reporting

Report issues in your application and library code as Xcode runtime warnings, breakpoints, assertions, and do so in a testable manner.
https://www.pointfree.co
MIT License
368 stars 60 forks source link

Make Test compatible with Swift 5.10 and below #104

Closed sk409 closed 1 month ago

sk409 commented 1 month ago

My project uses Xcode 15.1 (Swift 5.9), but in preparation for the future introduction of Swift Testing, I am implementing tests using Swift Testing. After updating the TCA version to 1.12.1, my tests started crashing. The cause was that IssueReporting.Test and Testing.Swift of Swift 5.10 or lower (swift-testing 0.7.0 or lower) were not compatible and unsafeBitCase was failing. Since it is still difficult to update the version of Xcode in my project, I am thinking of implementing IssueReporting.Test to be compatible with Swift 5.10 or lower. I will create a PR soon.

Below is the environment when a test crashes in my project.

stephencelis commented 1 month ago

@sk409 Thanks for taking the time to look into this, but is there a reason you are attempting to use Testing in <Swift 6? Apple has already dropped support for it and the first stable release will only support Swift 6: https://forums.swift.org/t/dropping-swift-syntax-510-support/71473

Given this I don't think we want to bake in support for unsupported and any unstable version of Testing other than the most current.

If you are using Testing, can you use a stable version via the Xcode 16 beta, instead? Or is it possible for you to maintain your fork till you can upgrade your build setup?

sk409 commented 1 month ago

@stephencelis

but is there a reason you are attempting to use Testing in <Swift 6?

My project has been using Swift Testing since Swift 5.9 to reduce the cost of migrating from XCTest to Swift Testing in the future.

If you are using Testing, can you use a stable version via the Xcode 16 beta, instead?

It is difficult to use Xcode16 at the moment because the stable version has not been released yet. Even if a stable version is released, we plan to perform regression testing when upgrading to Xcode 16, but it is difficult to perform regression testing due to human resources, and it seems that it will be a while before we can introduce Xcode 16.

Or is it possible for you to maintain your fork till you can upgrade your build setup?

If you do not want to include support for unsupported and unstable versions of Testing, I can maintain my fork.

stephencelis commented 1 month ago

I think maintaining the fork is the best course for now, as I don't think folks are commonly maintaining a Swift 5.9 Testing suite, but thanks for sharing your solution! If there are any folks out there that need support for Swift 5.9 we can point them to this branch.

sk409 commented 1 month ago

@stephencelis I tried looking into other solutions. Since IssueReportingTestSupport._currentTestIsNotNil references Testing.Test, I was able to prevent the crash by adding IssueReportingTestSupport to dependencies. Although this is not the original usage of IssueReportingTestSupport, I will add IssueReportingTestSupport as a dependency to avoid crashes until I introduce Xcode16.

mbrandonw commented 1 month ago

Since IssueReportingTestSupport._currentTestIsNotNil references Testing.Test, I was able to prevent the crash by adding IssueReportingTestSupport to dependencies. Although this is not the original usage of IssueReportingTestSupport, I will add IssueReportingTestSupport as a dependency to avoid crashes until I introduce Xcode16.

Hi @sk409, typically if you include IssueReportingTestSupport in a library/target that is included in an App Target, the app will fail to load in the simulator. We have that documented at the bottom of this page. Are you not running into that?

sk409 commented 1 month ago

@mbrandonw

typically if you include IssueReportingTestSupport in a library/target that is included in an App Target, the app will fail to load in the simulator. We have that documented at the bottom of this page. Are you not running into that?

The above error does not occur because I only add IssueReportingTestSupport to the test target dependencies. thank you!