swiftlang/swift-package-manager

Update macro template to support Swift Testing tests

Open

#8.890 aberto em 2 de jul. de 2025

Ver no GitHub
 (1 comment) (0 reactions) (0 assignees)Swift (1.462 forks)batch import
enhancementgood first issueswift package init

Métricas do repositório

Stars
 (10.145 stars)
Métricas de merge de PR
 (Mesclagem média 9d 13h) (90 fundiu PRs em 30d)

Description

According to the SwiftPM code base, we are unable to use Swift Testing to verify macros. However, the referenced GitHub issue (https://github.com/swiftlang/swift-syntax/issues/2400) is closed.

The Swift Syntax 600 release notes mentions SwiftSyntaxMacrosGenericTestSupport.

Here is a snippet of the relevant Swift Syntax release notes

SwiftSyntaxMacrosGenericTestSupport

  • Description: A version of the SwiftSyntaxMacrosTestSupport module that doesn't depend on Foundation or XCTest and can thus be used to write macro tests using swift-testing. Since swift-syntax can't depend on swift-testing (which would incur a circular dependency since swift-testing depends on swift-syntax), users need to manually specify a failure handler like the following, that fails the swift-testing test: Issue.record("\($0.message)", fileID: $0.location.fileID, filePath: $0.location.filePath, line: $0.location.line, column: $0.location.column)
  • Pull request: https://github.com/swiftlang/swift-syntax/pull/2647

The SwiftPM template for swift package init --type macro should be update to provide an idiomatic way to write a Swift Testing test to verify and validate a macro.

Guia do colaborador