Skip to content

Fatal crash in parameterised tests that repeat a testing parameter #1027

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
alexhunsley opened this issue Mar 14, 2025 · 3 comments
Closed
Labels
bug 🪲 Something isn't working

Comments

@alexhunsley
Copy link

alexhunsley commented Mar 14, 2025

Description

If you write a parameterised @Test, and in the arguments param pass the same list value twice, we get a fatal crash.

This problem occurs for parameter lists where the entries are computed, as well as for tests param lists giving literal values (see repro below).

If non-repeating values is an expected input condition I'd expect the Testing API documentation to call this out explicitly. The semantics of passing a Collection of Sendable (and not e.g. a set or map) imply equal params shouldn't cause an issue?

(I'm aware of the discussion at https://github.com/swiftlang/swift-evolution/blob/main/visions/swift-testing.md#test-identity on related matters, but still not sure what this implies about this issue report)

Clarity might be needed around to what extent any code being tested can go in parameter lists, or not? And what constitutes "testing code" (e.g. the example below. In effect it's testing ! (not) operator. Would ! itself be considered 'testing code'?)

Reproduction

@Test("bool negation operator", arguments: [
        (true, true),     // control case (no negation used)
        (!true, false),   // negate once
        (!(!true), true), // negate twice
    ])
    func testBoolNegation(lhs: Bool, rhs: Bool) {
        #expect(lhs == rhs)
    }

@Test("bool negation operator (using literals)", arguments: [
        (true, true),     // control case (no negation used)
        (false, false),   // negate once
        (true, true),     // negate twice
    ])
    func testBoolNegationWithLiterals(lhs: Bool, rhs: Bool) {
        #expect(lhs == rhs)
    }

Running this simple example with Testing causes a fatal crash:

libswiftCore.dylib`_swift_runtime_on_report:
 Thread 5: Fatal error: Internal inconsistency: No test reporter for test case argumentiDs:
 Optional ([Testing.Test.Case.Argument.ID(bytes: [102, 97, 108, 115, 101]),
   Testing.Test.Case.Argument.ID(bytes: [102, 97, 108, 115, 101])])
   in test ScratchTests/testBoolNegation(Ihs:rhs:)/ScratchTests.swift:15:6

If you comment out the first or third line of the test params, the duplicated value is removed and the test passes.

Expected behavior

The given @Test sample code should pass.

OR documentation should detail this limitation, and cause a more informative test failure message (not a crash): e.g malformed test arguments -- do not use the same value twice.

Environment

swift-driver version: 1.115 Apple Swift version 6.0.2 (swiftlang-6.0.2.1.2 clang-1600.0.26.4)

Darwin MacBook-Pro-2021.local 24.3.0 Darwin Kernel Version 24.3.0: Thu Jan 2 20:24:16 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6000 arm64

@alexhunsley alexhunsley added bug 🪲 Something isn't working triage-needed labels Mar 14, 2025
@grynspan
Copy link
Contributor

This is a known issue in Xcode. @stmontgomery do you have an original handy to dup against?

@stmontgomery
Copy link
Contributor

There are two issues: one is in Swift Testing, and was recently fixed in #1000; the other is in Xcode, and is tracked by rdar://121455205. Since I can only dupe to GitHub issues I'll dupe this to the former.

@stmontgomery
Copy link
Contributor

Duplicate of #1000

@stmontgomery stmontgomery marked this as a duplicate of #1000 Mar 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants