File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
Sources/SwiftSyntaxMacrosTestSupport Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import _SwiftSyntaxTestSupport
14
14
import SwiftBasicFormat
15
15
import SwiftDiagnostics
16
16
import SwiftParser
17
+ import SwiftParserDiagnostics
17
18
import SwiftSyntax
18
19
import SwiftSyntaxMacros
19
20
import XCTest
@@ -272,10 +273,26 @@ public func assertMacroExpansion(
272
273
let context = BasicMacroExpansionContext (
273
274
sourceFiles: [ origSourceFile: . init( moduleName: testModuleName, fullFilePath: testFileName) ]
274
275
)
275
- let expandedSourceFile = origSourceFile. expand ( macros: macros, in: context) . formatted ( using: BasicFormat ( indentationWidth: indentationWidth) )
276
276
277
+ let expandedSourceFile = origSourceFile. expand ( macros: macros, in: context)
278
+ let diags = ParseDiagnosticsGenerator . diagnostics ( for: expandedSourceFile)
279
+ if !diags. isEmpty {
280
+ XCTFail (
281
+ """
282
+ Expanded source should not contain any syntax errors, but contains:
283
+ \( DiagnosticsFormatter . annotatedSource ( tree: expandedSourceFile, diags: diags) )
284
+
285
+ Expanded syntax tree was:
286
+ \( expandedSourceFile. debugDescription)
287
+ """ ,
288
+ file: file,
289
+ line: line
290
+ )
291
+ }
292
+
293
+ let formattedSourceFile = expandedSourceFile. formatted ( using: BasicFormat ( indentationWidth: indentationWidth) )
277
294
assertStringsEqualWithDiff (
278
- expandedSourceFile . description. trimmingCharacters ( in: . newlines) ,
295
+ formattedSourceFile . description. trimmingCharacters ( in: . newlines) ,
279
296
expandedSource. trimmingCharacters ( in: . newlines) ,
280
297
additionalInfo: """
281
298
Actual expanded source:
You can’t perform that action at this time.
0 commit comments