From 0c9726cf19bd0ee75b1cf0c8533f44d665073a8a Mon Sep 17 00:00:00 2001 From: Kevin Romero Peces-Barba Date: Tue, 19 Nov 2024 11:20:53 -0500 Subject: [PATCH] Revert macro tests to use XCTest swift-testing is not supported for macro expansion tests yet. See https://github.com/swiftlang/swift-syntax/issues/2720 --- .../ObservableDefaultMacroTests.swift | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/Tests/DefaultsMacrosDeclarationsTests/ObservableDefaultMacroTests.swift b/Tests/DefaultsMacrosDeclarationsTests/ObservableDefaultMacroTests.swift index d3b0526..149d931 100644 --- a/Tests/DefaultsMacrosDeclarationsTests/ObservableDefaultMacroTests.swift +++ b/Tests/DefaultsMacrosDeclarationsTests/ObservableDefaultMacroTests.swift @@ -1,6 +1,6 @@ import SwiftSyntaxMacros import SwiftSyntaxMacrosTestSupport -import Testing +import XCTest // Macro implementations build for the host, so the corresponding module is not available when cross-compiling. // Cross-compiled tests may still make use of the macro itself in end-to-end tests. @@ -15,10 +15,9 @@ let testMacros: [String: Macro.Type] = [ let testMacros: [String: Macro.Type] = [:] #endif -@Suite(.serialized) -final class ObservableDefaultMacroTests { - @Test(.disabled(if: testMacros.isEmpty)) +final class ObservableDefaultMacroTests: XCTestCase { func testExpansionWithMemberSyntax() throws { + #if canImport(DefaultsMacrosDeclarations) assertMacroExpansion( #""" @Observable @@ -49,10 +48,13 @@ final class ObservableDefaultMacroTests { macros: testMacros, indentationWidth: .tabs(1) ) + #else + throw XCTSkip("Macros are only supported when running tests for the host platform") + #endif } - @Test(.disabled(if: testMacros.isEmpty)) func testExpansionWithDotSyntax() throws { + #if canImport(DefaultsMacrosDeclarations) assertMacroExpansion( #""" @Observable @@ -83,10 +85,13 @@ final class ObservableDefaultMacroTests { macros: testMacros, indentationWidth: .tabs(1) ) + #else + throw XCTSkip("Macros are only supported when running tests for the host platform") + #endif } - @Test(.disabled(if: testMacros.isEmpty)) func testExpansionWithFunctionCall() throws { + #if canImport(DefaultsMacrosDeclarations) assertMacroExpansion( #""" @Observable @@ -117,10 +122,13 @@ final class ObservableDefaultMacroTests { macros: testMacros, indentationWidth: .tabs(1) ) + #else + throw XCTSkip("Macros are only supported when running tests for the host platform") + #endif } - @Test(.disabled(if: testMacros.isEmpty)) func testExpansionWithProperty() throws { + #if canImport(DefaultsMacrosDeclarations) assertMacroExpansion( #""" @Observable @@ -151,5 +159,8 @@ final class ObservableDefaultMacroTests { macros: testMacros, indentationWidth: .tabs(1) ) + #else + throw XCTSkip("Macros are only supported when running tests for the host platform") + #endif } }