Skip to content

Commit

Permalink
Revert macro tests to use XCTest
Browse files Browse the repository at this point in the history
swift-testing is not supported for macro expansion tests yet.
See swiftlang/swift-syntax#2720
  • Loading branch information
kevinrpb committed Nov 19, 2024
1 parent eeaf1af commit 0c9726c
Showing 1 changed file with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}

0 comments on commit 0c9726c

Please sign in to comment.