From 7d33b87488175af5a2b832fa99e547dbc27ca261 Mon Sep 17 00:00:00 2001 From: Kyle Date: Mon, 10 Mar 2025 17:37:38 +0800 Subject: [PATCH] Add ConditionTraitTests to cover the Swift 6.0 compiler issue for custom trait + closure + macro See https://github.com/swiftlang/swift-testing/issues/1006#issuecomment-2708665563 --- .../Traits/ConditionTraitTests.swift | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Tests/TestingTests/Traits/ConditionTraitTests.swift diff --git a/Tests/TestingTests/Traits/ConditionTraitTests.swift b/Tests/TestingTests/Traits/ConditionTraitTests.swift new file mode 100644 index 000000000..5d70c8e87 --- /dev/null +++ b/Tests/TestingTests/Traits/ConditionTraitTests.swift @@ -0,0 +1,44 @@ +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for Swift project authors +// + +@testable import Testing + +@Suite("Condition Trait Tests", .tags(.traitRelated)) +struct ConditionTraitTests { + #if compiler(>=6.1) + @Test( + ".enabled trait", + .enabled { true }, + .bug("https://github.com/swiftlang/swift/issues/76409", "Verify the custom trait with closure causes @Test macro to fail is fixed") + ) + func enabledTraitClosure() throws {} + #endif + + @Test( + ".enabled if trait", + .enabled(if: true) + ) + func enabledTraitIf() throws {} + + #if compiler(>=6.1) + @Test( + ".disabled trait", + .disabled { false }, + .bug("https://github.com/swiftlang/swift/issues/76409", "Verify the custom trait with closure causes @Test macro to fail is fixed") + ) + func disabledTraitClosure() throws {} + #endif + + @Test( + ".disabled if trait", + .disabled(if: false) + ) + func disabledTraitIf() throws {} +}