Skip to content

Conversation

@DPrakashhh
Copy link

Description:
This PR addresses #3190 by adding a runtime safety guard to SwiftSyntaxMacrosTestSupport. This is a stop-gap measure until full Swift Testing support (#2720) is implemented.

The Problem
SwiftSyntaxMacrosTestSupport is XCTest-based. When used with the new Swift Testing framework, assertions may fail silently or produce false positives, leading to developer confusion.

The Solution
I have added a thread-safe, once-per-process runtime check in _SwiftTestingDetection.swift.

Key Features:

  • Smart Detection: Identifies Swift Testing via environment variables (SWIFT_TESTING_) and command-line arguments.
  • XCTest Safety: Automatically detects standard XCTest environments to prevent false warnings for existing tests.
  • Swift 6 Ready: Uses NSLock and nonisolated(unsafe) to satisfy strict concurrency requirements.
  • High Visibility: Prints a distinct ASCII banner to stderr that is "hard to miss."
  • Configuration: - SWIFTSYNTAX_TESTSUPPORT_SILENCE=1: Suppresses the warning.
    • SWIFTSYNTAX_TESTSUPPORT_STRICT=1: Triggers a preconditionFailure for strict enforcement.

Verification

  • Regression Testing: Verified with the full test suite (3,470 tests passed).

@DPrakashhh DPrakashhh force-pushed the task/3190-swift-testing-warning branch from 12ccd4a to ae4a379 Compare December 25, 2025 14:38
@DPrakashhh
Copy link
Author

@ahoppen
Sir, kindly check this PR, I have opened this few time ago :)

@ahoppen
Copy link
Member

ahoppen commented Jan 7, 2026

I’ll leave this PR to @rintaro and @hamishknight to review who have more context here at the moment.

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.

2 participants