Skip to content

Commit cf3e2d5

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 e896244 commit cf3e2d5

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
@@ -275,8 +275,18 @@ fn fixture_dispatch_tokens(list: &ScalarList) -> TokenStream2 {
275275
let arms = list.entries.iter().map(|e| {
276276
let token_str = e.token.to_string();
277277
let mod_ident = format_ident!("eql_v2_{}", e.token);
278+
// Storage-only scalars (`bool`) carry no comparison corpus to randomize
279+
// and deliberately have no `RandomPlaintext` impl (the trait is for the
280+
// comparison scalars only), so generate their fixed curated values via
281+
// `run()`. Comparison-capable scalars get the randomized
282+
// `mandatory ∪ random ∪ duplicates` corpus via `run_sampled()`.
283+
let gen_method = if is_storage_only_token(&token_str) {
284+
format_ident!("run")
285+
} else {
286+
format_ident!("run_sampled")
287+
};
278288
quote! {
279-
#token_str => ::eql_tests::fixtures::#mod_ident::spec().run_sampled().await,
289+
#token_str => ::eql_tests::fixtures::#mod_ident::spec().#gen_method().await,
280290
}
281291
});
282292
quote! {
@@ -648,6 +658,20 @@ mod tests {
648658
assert!(suites.contains("caps = [storage]"));
649659
let dispatch = norm(&fixture_dispatch_tokens(&list));
650660
assert!(dispatch.contains(r#""bool" =>"#));
661+
// A storage-only scalar has no comparison corpus to randomize and no
662+
// `RandomPlaintext` impl, so its fixture is generated from the fixed
663+
// curated values via `run()`. Comparison-capable scalars use the
664+
// randomized `run_sampled()` corpus.
665+
assert!(
666+
dispatch.contains(
667+
r#""bool" => :: eql_tests :: fixtures :: eql_v2_bool :: spec () . run () . await"#
668+
),
669+
"storage-only bool must dispatch to run(), got: {dispatch}"
670+
);
671+
assert!(
672+
dispatch.contains(r#""int4" => :: eql_tests :: fixtures :: eql_v2_int4 :: spec () . run_sampled () . await"#),
673+
"comparison-capable int4 must dispatch to run_sampled(), got: {dispatch}"
674+
);
651675
}
652676

653677
#[test]

0 commit comments

Comments
 (0)