migueldeicaza / SwiftGodot

New Godot bindings for Swift
https://migueldeicaza.github.io/SwiftGodotDocs/tutorials/swiftgodot-tutorials/
MIT License
1.14k stars 76 forks source link

Swift macro testing #519

Closed mayoff closed 2 months ago

mayoff commented 2 months ago

This pull request converts all macro expansion tests to use the MacroTesting library from the swift-macro-testing package.

I want to do some cleanup and enhancement of SwiftGodot's macros. In particular I want to make @Export automatically infer hints for subclasses of Node and Resource (both built-in and user-defined) and provide better, type-safe syntax for other hints (like @Export(.range(0 ... 10, step: 2, .orGreater)) instead of @Export(.range, "0,10,2,or_greater")).

To facilitate that work, I propose this patch to migrate the macro tests to a much friendlier testing library. The swift-macro-testing library has several advantages over SwiftSyntaxMacrosTestSupport:

For a full explanation of the design of swift-macro-testing, check out these videos:

https://www.pointfree.co/collections/macros/testing-and-debugging-macros

The video pages include full hand-written transcripts in case you'd rather read than watch.

mayoff commented 2 months ago

To be clear, this patch does not add or remove any test cases, or change the inputs or outputs of any test cases other than fixing indentation.

migueldeicaza commented 2 months ago

Thanks for this patch, this one will take me more time to review, but I am also a little hesitant on bringing another external dependency.

mayoff commented 2 months ago

Perhaps it would be better to ignore this PR until I have some other improvements to offer that build on this change.