Expand description
§============================================================================= Antithesis Assertion Macros
These macros define correctness properties for Antithesis autonomous testing. They wrap the Antithesis SDK assertion macros and double as standard Rust assertions, giving us a single assertion layer that works both in normal builds and under Antithesis fuzzing.
§The antithesis feature flag
All macros compile to different code depending on whether --features antithesis
is enabled:
- Without the feature: macros behave like their
stdcounterparts (assert!,debug_assert!,unreachable!, etc.), or are no-ops for observational macros. - With the feature: macros additionally report to the Antithesis SDK. On failure,
“always” assertions print an error to stderr and call
std::process::exit(0)instead of panicking. This clean exit lets Antithesis properly process the property violation.
§Five categories of assertions
-
Condition assertions (
turso_assert!,turso_debug_assert!) Drop-in replacements forassert!/debug_assert!that also report to Antithesis. -
Sometimes assertions (
turso_assert_sometimes!,turso_assert_sometimes_greater_than!,turso_assert_sometimes_less_than!,turso_assert_sometimes_greater_than_or_equal!,turso_assert_sometimes_less_than_or_equal!) Observational only — never panic. Tell Antithesis “this condition should be true at least once across all test runs.” Useful for verifying the fuzzer explores both sides of a branch. -
Boolean guidance (
turso_assert_some!,turso_assert_all!) Multi-condition assertions that provide better guidance to the Antithesis fuzzer.some= at least one condition must be true (OR),all= every condition must be true (AND). Panics on failure (or exit(0) with antithesis feature). -
Reachability assertions (
turso_assert_reachable!,turso_assert_unreachable!,turso_soft_unreachable!) Verify whether code paths are or aren’t hit during testing. -
Comparison assertions (
turso_assert_eq!,turso_assert_ne!,turso_assert_greater_than!,turso_assert_greater_than_or_equal!,turso_assert_less_than!,turso_assert_less_than_or_equal!) Typed comparison assertions that provide richer information to Antithesis than a plainturso_assert!(a > b).
§Note: fuzzer guidance temporarily disabled
The Antithesis SDK provides specialized numeric_guidance_helper! and
boolean_guidance_helper! macros that give the fuzzer detailed numeric/boolean
values to guide exploration. These were previously used by comparison and boolean
macros but are currently disabled (replaced with plain assert_always_or_unreachable!
/ assert_sometimes!) while Antithesis investigates an issue.
The macros still work correctly as assertions — they just don’t give the fuzzer as much detail to work with. Guidance will be restored when the issue is resolved.
§Quick reference
| Macro | Antithesis SDK | Panics? | Notes |
|---|---|---|---|
turso_assert! | assert_always_or_unreachable! | Yes (exit(0) w/ feature) | Drop-in for assert! |
turso_debug_assert! | assert_always_or_unreachable! | Debug only (exit(0) w/ feature) | Drop-in for debug_assert! |
turso_assert_sometimes! | assert_sometimes! | Never | Observational only |
turso_assert_some! | assert_always_or_unreachable! | Yes (exit(0) w/ feature) | OR of named conditions |
turso_assert_all! | assert_always_or_unreachable! | Yes (exit(0) w/ feature) | AND of named conditions |
turso_assert_reachable! | (no-op) | Never | Pending better SQL generation |
turso_assert_unreachable! | assert_unreachable! | Yes (exit(0) w/ feature) | Hard unreachable |
turso_soft_unreachable! | assert_unreachable! | Never | Soft signal, no-op w/o feature |
turso_assert_eq! | assert_always_or_unreachable! | Yes (exit(0) w/ feature) | Drop-in for assert_eq! |
turso_assert_ne! | assert_always_or_unreachable! | Yes (exit(0) w/ feature) | Drop-in for assert_ne! |
turso_assert_greater_than! | assert_always_or_unreachable! | Yes (exit(0) w/ feature) | left > right |
turso_assert_greater_than_or_equal! | assert_always_or_unreachable! | Yes (exit(0) w/ feature) | left >= right |
turso_assert_less_than! | assert_always_or_unreachable! | Yes (exit(0) w/ feature) | left < right |
turso_assert_less_than_or_equal! | assert_always_or_unreachable! | Yes (exit(0) w/ feature) | left <= right |
turso_assert_sometimes_greater_than! | assert_sometimes! | Never | Observational left > right |
turso_assert_sometimes_less_than! | assert_sometimes! | Never | Observational left < right |
turso_assert_sometimes_greater_than_or_equal! | assert_sometimes! | Never | Observational left >= right |
turso_assert_sometimes_less_than_or_equal! | assert_sometimes! | Never | Observational left <= right |
Macros§
- match_
ignore_ ascii_ case - match_ignore_ascii_case will generate trie-like tree matching from normal match expression. example:
- register_
extension - Register your extension with ‘core’ by providing the relevant functions
- turso_
assert - Drop-in replacement for
assert!that additionally reports to the Antithesis SDK when compiled with--features antithesis. - turso_
assert_ all - Asserts that all named conditions are true whenever this line is reached (logical AND).
- turso_
assert_ eq - Drop-in replacement for
assert_eq!that additionally reports to the Antithesis SDK in Antithesis builds (--cfg=antithesis). - turso_
assert_ greater_ than - Asserts that
left > right, providing richer comparison information to Antithesis than a plainturso_assert!(a > b). - turso_
assert_ greater_ than_ or_ equal - Asserts that
left >= right, providing richer comparison information to Antithesis than a plainturso_assert!(a >= b). - turso_
assert_ less_ than - Asserts that
left < right, providing richer comparison information to Antithesis than a plainturso_assert!(a < b). - turso_
assert_ less_ than_ or_ equal - Asserts that
left <= right, providing richer comparison information to Antithesis than a plainturso_assert!(a <= b). - turso_
assert_ ne - Drop-in replacement for
assert_ne!that additionally reports to the Antithesis SDK in Antithesis builds (--cfg=antithesis). - turso_
assert_ reachable - Asserts that a code path is reached at least once during Antithesis testing. No-op in non-antithesis builds.
- turso_
assert_ some - Asserts that at least one of multiple named conditions is true whenever this line is reached (logical OR). All conditions are evaluated.
- turso_
assert_ sometimes - Observational assertion: tells Antithesis that a condition should be true at least once across all test runs. Never panics.
- turso_
assert_ sometimes_ greater_ than - Observational assertion: tells Antithesis that
left > rightshould be true at least once across all test runs. Never panics. - turso_
assert_ sometimes_ greater_ than_ or_ equal - Observational assertion: tells Antithesis that
left >= rightshould be true at least once across all test runs. Never panics. - turso_
assert_ sometimes_ less_ than - Observational assertion: tells Antithesis that
left < rightshould be true at least once across all test runs. Never panics. - turso_
assert_ sometimes_ less_ than_ or_ equal - Observational assertion: tells Antithesis that
left <= rightshould be true at least once across all test runs. Never panics. - turso_
assert_ unreachable - Asserts that a code path is never reached. This is a hard assertion — it will terminate the program if the path is executed.
- turso_
debug_ assert - Drop-in replacement for
debug_assert!that additionally reports to the Antithesis SDK when compiled with--features antithesis. - turso_
soft_ unreachable - Soft unreachable: signals to Antithesis that this code path should never be reached,
but does not panic or exit. Without the
antithesisfeature, this is a no-op.
Attribute Macros§
- allocation_
site - Wrap a function body in an allocation-site scope.
- codspeed_
criterion_ benchmark - divan_
bench - scalar
- Declare a scalar function for your extension. This requires the name: #[scalar(name = “example”)] of what you wish to call your function with.
- test
- Test macro for
core_testercrate - trace_
stack - Wrap a function body in a stack trace guard and a
turso_stacktracing span.
Derive Macros§
- Aggregate
Derive - Define an aggregate function for your extension by deriving AggregateDerive on a struct that implements the AggFunc trait.
- Atomic
Enum - Derive macro for creating atomic wrappers for enums
- Description
- A procedural macro that derives a
Descriptiontrait for enums. This macro extracts documentation comments (specified with/// Description...) for enum variants and generates an implementation forget_description, which returns the associated description. - Scalar
Derive - Derive a context-aware scalar function for your extension by deriving
ScalarDeriveon a struct that implements theScalarFunctrait. - VTab
Module Derive - Macro to derive a VTabModule for your extension. This macro will generate the necessary functions to register your module with core. You must implement the VTabModule, VTable, and VTabCursor traits.
- VfsDerive