Skip to content

Commit 5e0d14f

Browse files
committed
fix(tests): generate storage-only scalar fixtures via run(), not run_sampled()
The catalog-driven fixture dispatch emitted `eql_v2_<T>::spec().run_sampled().await` for EVERY token. run_sampled() requires `T: RandomPlaintext`, which is implemented only for the seven comparison scalar plaintext types — `bool` (storage-only, no `_eq`/`_ord`, no comparison corpus to randomize) deliberately has no impl. So adding the `bool` row to the dispatch list (eql_v3_bool, #295) and switching the dispatch to the randomized corpus (property-tests work) were each green in isolation but broke when combined: error[E0277]: the trait bound `bool: RandomPlaintext` is not satisfied --> tests/sqlx/tests/generate_all_fixtures.rs:23 (scalar_types!(fixture_dispatch)) failing test:sqlx:prep -> fixture:generate:all in build-archive and the new e2e job. Route storage-only tokens to run() (fixed curated values, only needs FixtureValue) and keep run_sampled() for comparison-capable scalars. The macro already classifies storage-only via is_storage_only_token; this reuses it. Adds dispatch-routing assertions to the bool unit test. Verified: cargo test -p eql-tests-macros (20/20) and a --no-run compile of the generate_all_fixtures target (E0277 gone).
1 parent 11d4357 commit 5e0d14f

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

  • crates/eql-tests-macros/src

crates/eql-tests-macros/src/lib.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,18 @@ fn fixture_dispatch_tokens(list: &ScalarList) -> TokenStream2 {
274274
let arms = list.entries.iter().map(|e| {
275275
let token_str = e.token.to_string();
276276
let mod_ident = format_ident!("eql_v2_{}", e.token);
277+
// Storage-only scalars (`bool`) carry no comparison corpus to randomize
278+
// and deliberately have no `RandomPlaintext` impl (the trait is for the
279+
// comparison scalars only), so generate their fixed curated values via
280+
// `run()`. Comparison-capable scalars get the randomized
281+
// `mandatory ∪ random ∪ duplicates` corpus via `run_sampled()`.
282+
let gen_method = if is_storage_only_token(&token_str) {
283+
format_ident!("run")
284+
} else {
285+
format_ident!("run_sampled")
286+
};
277287
quote! {
278-
#token_str => ::eql_tests::fixtures::#mod_ident::spec().run_sampled().await,
288+
#token_str => ::eql_tests::fixtures::#mod_ident::spec().#gen_method().await,
279289
}
280290
});
281291
quote! {
@@ -646,6 +656,20 @@ mod tests {
646656
assert!(suites.contains("caps = [storage]"));
647657
let dispatch = norm(&fixture_dispatch_tokens(&list));
648658
assert!(dispatch.contains(r#""bool" =>"#));
659+
// A storage-only scalar has no comparison corpus to randomize and no
660+
// `RandomPlaintext` impl, so its fixture is generated from the fixed
661+
// curated values via `run()`. Comparison-capable scalars use the
662+
// randomized `run_sampled()` corpus.
663+
assert!(
664+
dispatch.contains(
665+
r#""bool" => :: eql_tests :: fixtures :: eql_v2_bool :: spec () . run () . await"#
666+
),
667+
"storage-only bool must dispatch to run(), got: {dispatch}"
668+
);
669+
assert!(
670+
dispatch.contains(r#""int4" => :: eql_tests :: fixtures :: eql_v2_int4 :: spec () . run_sampled () . await"#),
671+
"comparison-capable int4 must dispatch to run_sampled(), got: {dispatch}"
672+
);
649673
}
650674

651675
#[test]

0 commit comments

Comments
 (0)