Skip to content

Conversation

@417-72KI
Copy link
Owner

No description provided.

@417-72KI 417-72KI force-pushed the built-in-swift-testing-for-mac branch from 2994e5d to 557ce91 Compare November 18, 2024 06:05
@417-72KI 417-72KI requested a review from Copilot October 27, 2025 00:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the project to use the built-in swift-testing framework available in Swift 6.0 (Xcode 16) while maintaining backward compatibility with earlier compiler versions. The changes add thread safety to shared state and enable test serialization for the new testing framework.

  • Conditionally uses built-in swift-testing for Swift 6.0+ and falls back to the external package for earlier versions
  • Adds thread-safe access to the stub registry using NSLock
  • Enables serialized test execution for Swift 6.0+ to prevent race conditions

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
Package.swift Conditionally includes swift-testing package dependency only for compiler versions < 6.0
StubNetworkKitTests_SwiftTesting.swift Adds .serialized trait to test suite for Swift 6.0+ to ensure sequential test execution
StubURLProtocol.swift Introduces NSLock to synchronize access to shared stubs array
TestPlan.xctestplan Removes repeatInNewRunnerProcess option from test configuration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +64 to +71
#if compiler(<6.0)
package.dependencies.append(contentsOf: [
.package(url: "https://github.com/apple/swift-testing", exact: "0.3.0"),
])
testTarget.dependencies.append(contentsOf: [
.product(name: "Testing", package: "swift-testing"),
])
#endif
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

Build-time conditional compilation directives like #if compiler(<6.0) are evaluated during package manifest compilation, not during target compilation. This means the condition will be checked against the Swift compiler version used to build the Package.swift file itself, not the version used to build the targets. This will not achieve the intended backward compatibility. Consider using target-level conditions or separate package manifests for different Swift versions instead.

Suggested change
#if compiler(<6.0)
package.dependencies.append(contentsOf: [
.package(url: "https://github.com/apple/swift-testing", exact: "0.3.0"),
])
testTarget.dependencies.append(contentsOf: [
.product(name: "Testing", package: "swift-testing"),
])
#endif
// NOTE: Conditional compilation directives like `#if compiler(<6.0)` are evaluated during manifest compilation,
// not during target compilation. To support Swift < 6.0, consider using separate manifests or document this requirement.
// If you need to add the swift-testing dependency only for Swift < 6.0, update the manifest manually as needed.

Copilot uses AI. Check for mistakes.
@417-72KI 417-72KI force-pushed the built-in-swift-testing-for-mac branch from 557ce91 to e9cacf4 Compare October 27, 2025 10:27
Copilot AI review requested due to automatic review settings October 31, 2025 02:32
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

import os

// based on https://github.com/417-72KI/MultipartFormDataParser/blob/main/Tests/MultipartFormDataParserTests/StubURLProtocol.swift
final class StubURLProtocol: URLProtocol {
Copy link

Copilot AI Oct 31, 2025

Choose a reason for hiding this comment

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

OSAllocatedUnfairLock is only available on macOS 13.0+, iOS 16.0+, watchOS 9.0+, and tvOS 16.0+. While this aligns with the package's minimum platform versions in Package.swift, the lack of an explicit @available annotation makes the platform requirements less clear and could cause issues if the minimum platform versions are lowered in the future. Consider adding an @available annotation to make the dependency explicit.

Suggested change
final class StubURLProtocol: URLProtocol {
final class StubURLProtocol: URLProtocol {
@available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)

Copilot uses AI. Check for mistakes.

Choose a reason for hiding this comment

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

The minimum platform version won't be lowered

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants