Repository navigation
SwiftIdempotency 0.4.3
Bug fix in the opt-in SwiftIdempotencyPropertyBased product. No API changes. One behaviour change: a property whose operation throws now fails.
Fixed
assertIdempotentProperty and assertIdempotentEffectsProperty passed when the operation threw
swift-property-based 1.0.0 through 2.0.1, on Swift 6.2 and later, runs a propertyCheck body under try?. An error that escapes the body is dropped, and the property passes (x-sheep/swift-property-based#29, open). Both wrappers called the operation, or apply, with a bare try. So a throwing operation passed silently. That included a store that refuses a duplicate on the retry, which is the bug a retry check exists to catch.
Both wrappers now catch inside the property and record the error as a failure. The message names the step that threw: the first call, the second call, the first pass, or the retry pass. Because the error is recorded inside the property, swift-property-based still counts it, shrinks it, and reports the input that failed. This holds on every swift-property-based release and on Swift before and after 6.2. It will not record twice once upstream fixes #29.
Two kinds of error are skipped, as Swift Testing itself skips them:
ExpectationFailedError:try #requirehas already recorded its own issue, so the failure is reported once.- Anything thrown after the task is cancelled (
Test.cancel(), a.timeLimitexpiry, an outer cancel): a cancelled test is not reported as a failure.
Migration
If a property that used to pass now fails with "the operation threw during …", the operation really is throwing on a generated input. Two cases:
- The throw is a bug. The wrapper is now doing its job.
- The handler throws on a duplicate by design (check-then-throw dedup). Catch that error inside the closure, and test the throwing return contract separately. This is the same recipe as the non-property helpers; see USER_GUIDE, "Throw-on-retry handlers".
Validation
ThrownErrorTests(8 cases) covers both wrappers. Each case fails when the part it guards is removed: the catch, theExpectationFailedErrorguard, the cancellation guard.- Full suite green on Swift 6.4.1 (swift.org toolchain);
swiftlint --strictclean. - The two wrapper mutants are regenerated for the new code, and
mutants/run-mutants.shstill kills both.
Full change: #25