Skip to content

Commit 0c9726c

Browse files
committed
Revert macro tests to use XCTest
swift-testing is not supported for macro expansion tests yet. See swiftlang/swift-syntax#2720
1 parent eeaf1af commit 0c9726c

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

Tests/DefaultsMacrosDeclarationsTests/ObservableDefaultMacroTests.swift

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import SwiftSyntaxMacros
22
import SwiftSyntaxMacrosTestSupport
3-
import Testing
3+
import XCTest
44

55
// Macro implementations build for the host, so the corresponding module is not available when cross-compiling.
66
// 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] = [
1515
let testMacros: [String: Macro.Type] = [:]
1616
#endif
1717

18-
@Suite(.serialized)
19-
final class ObservableDefaultMacroTests {
20-
@Test(.disabled(if: testMacros.isEmpty))
18+
final class ObservableDefaultMacroTests: XCTestCase {
2119
func testExpansionWithMemberSyntax() throws {
20+
#if canImport(DefaultsMacrosDeclarations)
2221
assertMacroExpansion(
2322
#"""
2423
@Observable
@@ -49,10 +48,13 @@ final class ObservableDefaultMacroTests {
4948
macros: testMacros,
5049
indentationWidth: .tabs(1)
5150
)
51+
#else
52+
throw XCTSkip("Macros are only supported when running tests for the host platform")
53+
#endif
5254
}
5355

54-
@Test(.disabled(if: testMacros.isEmpty))
5556
func testExpansionWithDotSyntax() throws {
57+
#if canImport(DefaultsMacrosDeclarations)
5658
assertMacroExpansion(
5759
#"""
5860
@Observable
@@ -83,10 +85,13 @@ final class ObservableDefaultMacroTests {
8385
macros: testMacros,
8486
indentationWidth: .tabs(1)
8587
)
88+
#else
89+
throw XCTSkip("Macros are only supported when running tests for the host platform")
90+
#endif
8691
}
8792

88-
@Test(.disabled(if: testMacros.isEmpty))
8993
func testExpansionWithFunctionCall() throws {
94+
#if canImport(DefaultsMacrosDeclarations)
9095
assertMacroExpansion(
9196
#"""
9297
@Observable
@@ -117,10 +122,13 @@ final class ObservableDefaultMacroTests {
117122
macros: testMacros,
118123
indentationWidth: .tabs(1)
119124
)
125+
#else
126+
throw XCTSkip("Macros are only supported when running tests for the host platform")
127+
#endif
120128
}
121129

122-
@Test(.disabled(if: testMacros.isEmpty))
123130
func testExpansionWithProperty() throws {
131+
#if canImport(DefaultsMacrosDeclarations)
124132
assertMacroExpansion(
125133
#"""
126134
@Observable
@@ -151,5 +159,8 @@ final class ObservableDefaultMacroTests {
151159
macros: testMacros,
152160
indentationWidth: .tabs(1)
153161
)
162+
#else
163+
throw XCTSkip("Macros are only supported when running tests for the host platform")
164+
#endif
154165
}
155166
}

0 commit comments

Comments
 (0)