11//! End-to-end tests forcing `StorageMode::Disk` via the `FORCE_DISK_SPILL` env var.
2+ //!
3+ //! Run with `FORCE_DISK_SPILL=1` set in the environment, e.g.
4+ //! `FORCE_DISK_SPILL=1 cargo test --features disk-spill disk_spill`. Tests
5+ //! fail fast if the var is unset to avoid silent loss of coverage.
26
37use crate :: VmProof ;
48use crate :: tables:: MaxRowsConfig ;
59use crate :: test_utils:: asm_elf_bytes;
610use stark:: proof:: options:: GoldilocksCubicProofOptions ;
711
8- /// RAII guard that sets `FORCE_DISK_SPILL` for the test's scope and clears it
9- /// on drop. Tests must run with `--test-threads=1`.
10- struct ForceDiskGuard ;
11-
12- impl ForceDiskGuard {
13- fn new ( ) -> Self {
14- // SAFETY: tests run with --test-threads=1, no concurrent env access.
15- unsafe { std:: env:: set_var ( "FORCE_DISK_SPILL" , "1" ) } ;
16- Self
17- }
18- }
19-
20- impl Drop for ForceDiskGuard {
21- fn drop ( & mut self ) {
22- // SAFETY: same as new().
23- unsafe { std:: env:: remove_var ( "FORCE_DISK_SPILL" ) } ;
24- }
12+ fn require_force_disk_spill ( ) {
13+ assert_eq ! (
14+ std:: env:: var( "FORCE_DISK_SPILL" ) . as_deref( ) ,
15+ Ok ( "1" ) ,
16+ "set FORCE_DISK_SPILL=1 before running disk-spill tests" ,
17+ ) ;
2518}
2619
2720#[ test]
2821fn test_disk_spill_prove_verify_and_roundtrip_small ( ) {
29- let _guard = ForceDiskGuard :: new ( ) ;
22+ require_force_disk_spill ( ) ;
3023 let elf_bytes = asm_elf_bytes ( "sub" ) ;
3124 let opts = GoldilocksCubicProofOptions :: with_blowup ( 2 ) . expect ( "blowup=2 is always valid" ) ;
3225 let proof = crate :: prove_with_options ( & elf_bytes, & opts, & MaxRowsConfig :: default ( ) )
@@ -46,7 +39,7 @@ fn test_disk_spill_prove_verify_and_roundtrip_small() {
4639
4740#[ test]
4841fn test_disk_spill_prove_verify_and_roundtrip_chunked ( ) {
49- let _guard = ForceDiskGuard :: new ( ) ;
42+ require_force_disk_spill ( ) ;
5043 let elf_bytes = asm_elf_bytes ( "all_instructions_64" ) ;
5144 let opts = GoldilocksCubicProofOptions :: with_blowup ( 2 ) . expect ( "blowup=2 is always valid" ) ;
5245 let proof = crate :: prove_with_options ( & elf_bytes, & opts, & MaxRowsConfig :: small ( ) )
0 commit comments