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: AGENT.md
+11-8Lines changed: 11 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,23 +15,26 @@
15
15
16
16
## Test Guidance
17
17
18
-
- Command-line full test runs should use serial execution:
19
-
-`swift test --no-parallel`
18
+
- Command-line full test runs should use parallel execution:
19
+
-`swift test --parallel`
20
20
- or `./test.sh`
21
21
-`./test.sh` is the preferred full-suite command because it enables Core Data concurrency assertions via `com.apple.CoreData.ConcurrencyDebug=1`.
22
-
- In Xcode, disable parallel testing for this package before running the full suite.
23
22
- When debugging failures, prefer running a single test file or a filtered suite first.
24
-
- This repository's tests are currently treated as serial-only at the full-suite level.
23
+
- Swift Testing parallel runs should be treated as same-process concurrency, not process isolation per test case.
24
+
- Do not assume `static` state is isolated per test. Static helpers in the test target are shared across concurrently running suites.
25
25
- For new Core Data tests, do not write directly through `viewContext` or a raw background context from the test body.
26
26
- Prefer `Tests/PersistentHistoryTrackingKitTests/TestAppDataHandler.swift` and actor-isolated helper methods for creating, updating, deleting, and reading test data.
27
27
- If a test needs direct inspection of a handler-owned context, use the handler's `withContext` API rather than `context.perform` from the test body.
28
+
- Prefer real test data and the actual transaction-processing path over synthetic Core Data artifacts. Do not hand-build `HookContext`, `NSManagedObjectID`, or similar fake inputs when a test can create data through `TestAppDataHandler` and trigger processing through the library.
28
29
29
30
## Known Test Constraints
30
31
31
-
- Full-suite parallel execution in Xcode can hang before any individual test completes.
32
-
-Serial full-suite execution has been verified to pass repeatedly.
32
+
- Full-suite parallel execution has been revalidated after test-infrastructure fixes.
33
+
-Repeated parallel runs have been observed to pass after serializing test container creation.
33
34
- Repeated Xcode runs of `cleanTransactionsByTimestampAndAuthors` have been observed to pass.
34
-
- Repeated Xcode serial full-suite runs have also been observed to pass.
35
+
-`TestModelBuilder.createContainer` is intentionally serialized with a global lock.
36
+
- Reason: concurrent `NSPersistentContainer` creation and `loadPersistentStores` can crash inside Core Data with `EXC_BAD_ACCESS`, even when each test uses a unique SQLite store URL.
37
+
- The container creation lock is required for test stability; do not remove it unless the Core Data initialization path is reworked and revalidated under repeated parallel runs.
35
38
36
39
## Failure Triage
37
40
@@ -46,7 +49,7 @@ If a crash or hang appears again, collect the following before changing code:
46
49
## Build and Cache Notes
47
50
48
51
- If SwiftPM reports compiler/module version mismatches, clear `.build` and rerun.
49
-
- If Xcode behaves inconsistently while command-line serial runs are stable, suspect DerivedData or Xcode test execution settings before changing repository code.
52
+
- If Xcode behaves inconsistently while command-line parallel runs are stable, suspect DerivedData or Xcode test execution settings before changing repository code.
@@ -503,33 +503,31 @@ let hookB = await kit.registerMergeHook(before: hookA) { _ in
503
503
504
504
## Testing
505
505
506
-
**⚠️ Important: Tests Must Run Serially**
507
-
508
-
Due to Core Data's singleton nature and shared persistent stores, **tests must run serially**, not in parallel. Running tests in parallel will cause race conditions and failures.
506
+
Tests are validated under parallel execution. The test infrastructure serializes `NSPersistentContainer` creation internally to avoid Core Data store-loading crashes while preserving parallel suite execution.
0 commit comments