frozenlib / test-strategy

Procedural macro to easily write higher-order strategies in proptest.
Apache License 2.0
44 stars 10 forks source link

Test `filter_with_strategy_and_map` fails seemingly on 32-bit platforms #13

Closed nc7s closed 3 months ago

nc7s commented 3 months ago

Hi, I packaged this in Debian, and noticed that it failed the same titular test on the armel, armhf, and i386 platforms (check links for detailed test log). This pattern occurred to me as 32-bit only, because these are 32-bit, while all passing platforms are 64-bit.

(...)
150s test strategy_tuple_struct ... ok
150s test strategy_struct ... ok
150s test strategy_rank3 ... ok
150s test filter_with_strategy_and_map ... FAILED
150s 
150s failures:
150s 
150s ---- filter_with_strategy_and_map stdout ----
150s thread 'filter_with_strategy_and_map' panicked at tests/test_helpers.rs:36:48:
150s called `Result::unwrap()` on an `Err` value: Reason("Too many local rejects")
150s stack backtrace:
150s    0: rust_begin_unwind
150s              at /usr/src/rustc-1.75.0/library/std/src/panicking.rs:645:5
150s    1: core::panicking::panic_fmt
150s              at /usr/src/rustc-1.75.0/library/core/src/panicking.rs:72:14
150s    2: core::result::unwrap_failed
150s              at /usr/src/rustc-1.75.0/library/core/src/result.rs:1653:5
150s    3: core::result::Result<T,E>::unwrap
150s              at /usr/src/rustc-1.75.0/library/core/src/result.rs:1077:23
150s    4: arbitrary::test_helpers::assert_eq_strategy_ops
150s              at ./tests/test_helpers.rs:36:22
150s    5: arbitrary::test_helpers::assert_eq_strategy
150s              at ./tests/test_helpers.rs:25:5
150s    6: arbitrary::test_helpers::assert_arbitrary
150s              at ./tests/test_helpers.rs:13:5
150s    7: arbitrary::filter_with_strategy_and_map
150s              at ./tests/arbitrary.rs:1627:5
150s    8: arbitrary::filter_with_strategy_and_map::{{closure}}
150s              at ./tests/arbitrary.rs:1596:34
150s    9: core::ops::function::FnOnce::call_once
150s              at /usr/src/rustc-1.75.0/library/core/src/ops/function.rs:250:5
150s   10: core::ops::function::FnOnce::call_once
150s              at /usr/src/rustc-1.75.0/library/core/src/ops/function.rs:250:5
150s note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
150s 
150s 
150s failures:
150s     filter_with_strategy_and_map
150s 
150s test result: FAILED. 102 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.35s
150s 
150s error: test failed, to rerun pass `--test arbitrary`
150s autopkgtest [09:30:40]: test rust-test-strategy:@: -----------------------]

With a few eprintln!s, I managed to get these:

Unfortunately I'm unfamiliar with arbitrary and proptest, thus can't dig much deeper.

frozenlib commented 3 months ago

Thank you for your report.

I was able to confirm that changing the failed test from y % 2 == 0 to y % 2 == 1 results in test failures on 64-bit OS as well. It appears that when using #[map] and #[filter] together, code like Just(..).prop_filter(..) is generated, and an error occurs when the Just value doesn't match the filter.

To fix this issue, I'd like to change the target of prop_filter application from Just to the following strategies:

nc7s commented 3 months ago

Thanks! I'll be cherry-picking it since it's not released yet.

nc7s commented 3 months ago

... OK, I'll admit it's harder than I thought. Would you mind cutting a new release? So I can leverage our packaging tooling and save some handwork on patches ;)

frozenlib commented 3 months ago

I have now published version 0.4.0, which includes this fix.

nc7s commented 3 months ago

Great, thanks!