You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enhance assertMacroExpansion to Validate Post-Fix-It Macro Expansions
This commit introduces an enhancement to the `assertMacroExpansion` function in SwiftSyntax's testing suite. The key addition is the capability to validate macro expansions on source code after the application of Fix-Its. This change ensures a more robust and comprehensive testing process, particularly for macros that propose fix-its for diagnostics.
Modifications include:
- Addition of a new parameter `expandedFixedSource` in test assertions. This parameter allows users to assert against the expanded source code after applying Fix-Its.
- Update of `assertMacroExpansion` to handle the new testing workflow. It now performs macro expansion tests on both the original and the fixed source code, ensuring that both the pre-fix and post-fix states are correctly validated.
- Refinement of the internal logic for applying Fix-Its and conducting macro expansion tests, ensuring accuracy and efficiency in the testing process.
- Update of test cases in `AddBlockerTests.swift` and `AddCompletionHandlerMacroTests.swift` to demonstrate and validate the new functionality.
Resolves: #2333
Copy file name to clipboardExpand all lines: Sources/SwiftSyntaxMacrosTestSupport/Assertions.swift
+92-39
Original file line number
Diff line number
Diff line change
@@ -256,6 +256,7 @@ func assertDiagnostic(
256
256
/// (e.g., `StringifyMacro.self`).
257
257
/// - applyFixIts: If specified, filters the Fix-Its that are applied to generate `fixedSource` to only those whose message occurs in this array. If `nil`, all Fix-Its from the diagnostics are applied.
258
258
/// - fixedSource: If specified, asserts that the source code after applying Fix-Its matches this string.
259
+
/// - expectedExpandedFixedSource: If specified, asserts against the expanded fixed source.
259
260
/// - testModuleName: The name of the test module to use.
260
261
/// - testFileName: The name of the test file name to use.
261
262
/// - indentationWidth: The indentation width used in the expansion.
@@ -266,48 +267,26 @@ public func assertMacroExpansion(
0 commit comments