Replies: 1 comment 1 reply
-
@gohanlon Something we've wanted to support in inline snapshots in general is more complex config. So you could do something like the following to skip recording a particular snapshot inline: func testAccessLeakAndCustomLabelConflictsWithAnotherLabel() {
assertMacro(testFixIts: false) {
"""
@MemberwiseInit(.public)
struct S {
@Init(label: "foo") let x: T
@Init(label: "foo") let y: T
}
"""
} diagnostics: {
"""
@MemberwiseInit(.public)
struct S {
@Init(label: "foo") let x: T
┬───────────────────────────
╰─ 🛑 @MemberwiseInit(.public) would leak access to 'internal' property
✏️ Add '@Init(.public)'
✏️ Add 'public' access level
✏️ Add '@Init(.ignore)' and an initializer
@Init(label: "foo") let y: T
┬───────────────────────────
╰─ 🛑 @MemberwiseInit(.public) would leak access to 'internal' property
✏️ Add '@Init(.public)'
✏️ Add 'public' access level
✏️ Add '@Init(.ignore)' and an initializer
}
"""
}
} fixIts: {
.skip
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Testing of fix-its is a great part of swift-macro-testing. Compared to swift-syntax's testing tools, testing of diagnostics and fix-its is perhaps my most valued feature.
But, for many of my tests the “fixes” are repetitive and don’t strengthen the test. For example, the following test (with hypothetical
testFixIts
option) shows that when code contains both “access leak” and “duplicate label” mistakes, only the “access leak” diagnostics are emitted. The application of the fix-its is redundant with several other tests, and not interesting for this test.Thoughts?
Beta Was this translation helpful? Give feedback.
All reactions