Skip to content

Conversation

@Viditgupta-official
Copy link

@Viditgupta-official Viditgupta-official commented Dec 28, 2025

Add functional test covering swift test --sanitize --filter failure

Motivation:

When running swift test on macOS with both --sanitize address and --filter enabled, test execution fails with the error:

Sanitizer load violates platform policy.

Running either flag independently works as expected, but the combination consistently fails. This behavior is currently undocumented and untested. Adding coverage ensures the issue is reproducible and prevents accidental regressions while the underlying cause is investigated.

Modifications:

Added a new functional test in TestDiscoveryTests

Used SwiftPM’s functional test harness to invoke swift test

Passed --sanitize address and --filter together

Asserted on the observed platform policy violation message

Guarded the test to macOS

Result:

The sanitizer + filter failure is now captured by SwiftPM’s test suite, making the behavior explicit and providing a stable foundation for future fixes or refactors.
Fixes #9546

@Viditgupta-official
Copy link
Author

This PR intentionally only adds coverage for the sanitizer + filter behavior.
I plan to investigate the root cause of the sanitizer runtime loading failure in a follow-up change once this test is in place.

@Viditgupta-official
Copy link
Author

Note: This test documents a known failure that appears to originate in the swiftpm-xctest-helper (an Xcode tool), not SwiftPM itself.

The test is intentionally added as coverage to prevent regressions and to make the behavior explicit while the underlying issue is tracked separately (via Apple Feedback).

Co-authored-by: Stuart Montgomery <smontgomery@apple.com>
}
}
#else
throw SkipTest("Sanitizer + filter behavior is macOS-specific")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd generally recommend an .enabled(if:) for expressing that a particular test is only relevant on certain platforms

_ buildSystem: BuildSystemProvider.Kind
) async throws {
#if os(macOS)
try await withKnownIssue(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: indentation looks off; I'd expect the body of this whole function to be indented one level

) async throws {
#if os(macOS)
try await withKnownIssue(
"Fails due to swiftpm-xctest-helper (Xcode tool) violating platform sanitizer policy (#9546, rdar://168234231)"
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the part I commented on/suggested, and that part LGTM! Thanks

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.

swift test --filter with --sanitize fails: "Sanitizer load violates platform policy"

2 participants