You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: AGENTS.md
+26-2Lines changed: 26 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,6 +67,14 @@ Most changes are correctness-sensitive because public behavior is generated by m
67
67
## Testing Expectations
68
68
69
69
- Run `swift test` before finishing any behavioral change.
70
+
- Preserve the macro guardrail suite in `Tests/ObservableDefaultsMacroTests`. It exists to catch generated-code regressions before runtime tests do.
71
+
- When changing macro generation, run `swift test --filter ObservableDefaultsMacroTests` in addition to any affected runtime suites.
72
+
- Keep macro coverage split by responsibility:
73
+
-`MacroExpansionSnapshotTests.swift` for expanded-source and formatted-source snapshots
74
+
-`MacroStructureTests.swift` for syntax/shape assertions that should survive harmless formatting changes
75
+
-`MacroDiagnosticTests.swift` for diagnostics and invalid-argument coverage
76
+
- Add or update fixtures in `Tests/ObservableDefaultsMacroTests/Fixtures` when a macro change introduces a new meaningful expansion scenario.
77
+
- Update files under `Tests/ObservableDefaultsMacroTests/__Snapshots__` only when the expanded output intentionally changes. Treat snapshot diffs as generated-code behavior changes unless proven otherwise.
70
78
- If a change touches external notifications, fallback logic, or equality checks, at minimum run:
71
79
-`swift test --filter ExternalChangeEqualityTests`
72
80
-`swift test --filter ObservableDefaultsTests`
@@ -77,16 +85,31 @@ Most changes are correctness-sensitive because public behavior is generated by m
77
85
-`swift test --filter PrefixTests`
78
86
-`swift test --filter WhitespaceTests`
79
87
-`swift test --filter StringParameterTests`
88
+
- If a change touches macro parameter parsing or diagnostics, also run:
89
+
-`swift test --filter ObservableDefaultsMacroTests`
80
90
- If a change touches storage format or overload resolution, run:
81
91
-`swift test --filter RawRepresentableCodableTests`
82
92
-`swift test --filter Issue26OverloadAmbiguityTests`
93
+
- If a change touches observer lifetime, notification registration, or external notification teardown, also run:
94
+
-`swift test --filter ObservableDefaultsTests`
95
+
-`swift test --filter ObservableCloudTests`
96
+
- verify the runtime regression tests covering model deallocation and post-release notifications still pass
83
97
84
98
### Test Isolation Rules
85
99
86
100
-`UserDefaults` tests should use isolated suite names. Prefer `UserDefaults.getTestInstance(suiteName:)`, and use a unique suite per test when cross-test interference is possible.
87
101
- Cloud `.testMode` tests use per-test mock suite isolation through `NSUbiquitousKeyValueStoreWrapper.testSuiteName`. Preserve that mechanism.
88
102
- If a suite relies on shared notifications or shared storage state, make it `.serialized`.
89
103
- Do not “fix” flaky tests by weakening expectations if the real issue is shared storage or notification interference.
104
+
- Prefer running `swift test` commands serially when changing macro/plugin code. Parallel SwiftPM test runs can contend on `.build` and produce misleading cache or lock failures.
105
+
106
+
### Macro Test Workflow
107
+
108
+
- Use `swift-testing` by default for new repository tests. Keep `XCTest` only where macro-testing APIs still require it.
109
+
- Prefer structure assertions plus snapshots over snapshots alone. Snapshot tests catch whole-output drift; structure tests catch semantic shape changes with less formatting sensitivity.
110
+
- Snapshot files are intentionally not reformatted by the pre-commit hook. Do not manually reformat files under `Tests/ObservableDefaultsMacroTests/__Snapshots__`.
111
+
- Macro string parameters are valid only when they are plain string literals composed entirely of `StringSegmentSyntax` segments. Interpolated strings must be diagnosed, not partially accepted.
112
+
- Macro boolean parameters must diagnose invalid non-literal expressions rather than silently falling back to defaults.
90
113
91
114
## Documentation Rules
92
115
@@ -105,8 +128,9 @@ When reviewing changes, prioritize:
105
128
2. missing tests for external changes and fallback paths
106
129
3.`MainActor` and `defaultIsolationIsMainActor` coverage
107
130
4.`observeFirst` correctness
108
-
5. storage format compatibility for RawRepresentable/Codable hybrids
109
-
6. test isolation and notification scope
131
+
5. observer lifecycle and notification token teardown
132
+
6. storage format compatibility for RawRepresentable/Codable hybrids
0 commit comments