-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow indentation width to be set explicitly #8
Allow indentation width to be set explicitly #8
Conversation
This allows the user to circumvent the default indentation behavior. In particular, it can be used to avoid getting the default four-space indentation when expanding source that doesn’t contain any indentation to infer the indentation width from. Changes: * The `assertMacro` function, along with related functions, now accepts `indentationWidth` as a parameter (`Trivia`). * Introduces `IndentationWidthTests` to validate both the existing indentation behavior and the new explicit indentation width functionality.
@@ -90,8 +91,11 @@ import XCTest | |||
/// | |||
/// - Parameters: | |||
/// - macros: The macros to expand in the original source string. Required, either implicitly via | |||
/// ``withMacroTesting(isRecording:macros:operation:)-2vypn``, or explicitly via this parameter. | |||
/// no fix-its to apply, or if any diagnostics are unfixable, the assertion will fail. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this stray line:
/// no fix-its to apply, or if any diagnostics are unfixable, the assertion will fail.
which was left behind when applyFixIts
was removed:
///
/// - applyFixIts: Applies fix-its to the original source and snapshots the result. If there are
/// no fix-its to apply, or if any diagnostics are unfixable, the assertion will fail.
///
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for diving into this! Brandon and I will chat about it early next week.
Hi @stephencelis, any updates on this? A way to clean up the awkward indentation in a dozen or so of my tests would be a nice-to-have! 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gohanlon Sorry, we just lost track of this. Thanks!
This allows the user to circumvent the default indentation behavior. In particular, it can be used to avoid getting the default four-space indentation when expanding source that doesn’t contain any indentation to infer the indentation width from, e.g.:
Unindented original source seems uncommon, but it occurs pretty frequently in my macro tests. For example, I have a collection of tests that exercise each possible combination of access modifier for structs, classes, and actors.
Changes:
assertMacro
andwithMacroTesting
functions now acceptindentationWidth
as a parameter (Trivia
).IndentationWidthTests
to validate both the existing indentation behavior and the new explicit indentation width functionality.Some alternatives to consider:
defaultIndentationWidth
to let the user only control the fallback indentation value. This would work in my use case.assertMacro
and not inwithMacroTesting
.