Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modify
assertMacroExpansion()
so that it only conditionally calls `…
…XCTFail()`. This PR changes the signature of `assertMacroExpansion()` such that an alternative failure handler can be passed for use when e.g. swift-testing is being used. Right now, the function calls `XCTAssertEqual()`, `XCTFail()`, etc. on the assumption that the caller is using XCTest. This assumption does not always hold and the dependency on XCTest may prevent a developer from writing effective tests leveraging `assertMacroExpansion()` while also using swift-testing or other testing libraries. It is not possible for swift-syntax to include swift-testing as a dependency at this time, so the function cannot be amended to directly call the equivalent of `XCTFail()` from that library. Nor can the function check if the current process is running an XCTest-based test because XCTest does not expose API to determine if a test is running. Until such time as swift-syntax can directly call into swift-testing, developers can do so when calling `assertMacroExpansion()` like so: ```swift assertMacroExpansion( "@foo bar", "expanded_foo bar", macros: ..., ... ) { message, fileID, filePath, line, column in Issue.record(Comment(rawValue: message), fileID: fileID, filePath: String(describing: filePath), Int(line), Int(column)) } ``` An improved interface is a future direction. Resolves #2400.
- Loading branch information