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
1414import SwiftBasicFormat
1515import SwiftDiagnostics
1616import SwiftParser
17+ import SwiftParserDiagnostics
1718import SwiftSyntax
1819import SwiftSyntaxMacros
1920import XCTest
@@ -272,10 +273,26 @@ public func assertMacroExpansion(
272273 let context = BasicMacroExpansionContext (
273274 sourceFiles: [ origSourceFile: . init( moduleName: testModuleName, fullFilePath: testFileName) ]
274275 )
275- let expandedSourceFile = origSourceFile. expand ( macros: macros, in: context) . formatted ( using: BasicFormat ( indentationWidth: indentationWidth) )
276276
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+ \( diags. map ( \. debugDescription) . joined ( separator: " \n " ) )
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) )
277294 assertStringsEqualWithDiff (
278- expandedSourceFile . description,
295+ formattedSourceFile . description,
279296 expandedSource,
280297 file: file,
281298 line: line
You can’t perform that action at this time.
0 commit comments