ding-young commented on code in PR #16145: URL: https://github.com/apache/datafusion/pull/16145#discussion_r2102322164
########## datafusion/execution/src/memory_pool/pool.rs: ########## @@ -452,64 +453,64 @@ mod tests { let mut r1 = MemoryConsumer::new("unspillable").register(&pool); // Can grow beyond capacity of pool r1.grow(2000); - assert_eq!(pool.reserved(), 2000); + assert_snapshot!(pool.reserved(), @"2000"); let mut r2 = MemoryConsumer::new("r2") .with_can_spill(true) .register(&pool); // Can grow beyond capacity of pool r2.grow(2000); - assert_eq!(pool.reserved(), 4000); + assert_snapshot!(pool.reserved(), @"4000"); let err = r2.try_grow(1).unwrap_err().strip_backtrace(); - assert_eq!(err, "Resources exhausted: Failed to allocate additional 1.0 B for r2 with 2000.0 B already allocated for this reservation - 0.0 B remain available for the total pool"); + assert_snapshot!(err, @"Resources exhausted: Failed to allocate additional 1 bytes for r2 with 2000 bytes already allocated for this reservation - 0 bytes remain available for the total pool"); let err = r2.try_grow(1).unwrap_err().strip_backtrace(); - assert_eq!(err, "Resources exhausted: Failed to allocate additional 1.0 B for r2 with 2000.0 B already allocated for this reservation - 0.0 B remain available for the total pool"); + assert_snapshot!(err, @"Resources exhausted: Failed to allocate additional 1 bytes for r2 with 2000 bytes already allocated for this reservation - 0 bytes remain available for the total pool"); r1.shrink(1990); r2.shrink(2000); - assert_eq!(pool.reserved(), 10); + assert_snapshot!(pool.reserved(), @"10"); r1.try_grow(10).unwrap(); - assert_eq!(pool.reserved(), 20); + assert_snapshot!(pool.reserved(), @"20"); // Can grow r2 to 80 as only spilling consumer r2.try_grow(80).unwrap(); - assert_eq!(pool.reserved(), 100); + assert_snapshot!(pool.reserved(), @"100"); r2.shrink(70); - assert_eq!(r1.size(), 20); - assert_eq!(r2.size(), 10); - assert_eq!(pool.reserved(), 30); + assert_snapshot!(r1.size(), @"20"); + assert_snapshot!(r2.size(), @"10"); + assert_snapshot!(pool.reserved(), @"30"); let mut r3 = MemoryConsumer::new("r3") .with_can_spill(true) .register(&pool); let err = r3.try_grow(70).unwrap_err().strip_backtrace(); - assert_eq!(err, "Resources exhausted: Failed to allocate additional 70.0 B for r3 with 0.0 B already allocated for this reservation - 40.0 B remain available for the total pool"); + assert_snapshot!(err, @"Resources exhausted: Failed to allocate additional 70 bytes for r3 with 0 bytes already allocated for this reservation - 40 bytes remain available for the total pool"); //Shrinking r2 to zero doesn't allow a3 to allocate more than 45 r2.free(); let err = r3.try_grow(70).unwrap_err().strip_backtrace(); - assert_eq!(err, "Resources exhausted: Failed to allocate additional 70.0 B for r3 with 0.0 B already allocated for this reservation - 40.0 B remain available for the total pool"); + assert_snapshot!(err, @"Resources exhausted: Failed to allocate additional 70 bytes for r3 with 0 bytes already allocated for this reservation - 40 bytes remain available for the total pool"); // But dropping r2 does drop(r2); - assert_eq!(pool.reserved(), 20); + assert_snapshot!(pool.reserved(), @"20"); r3.try_grow(80).unwrap(); - assert_eq!(pool.reserved(), 100); + assert_snapshot!(pool.reserved(), @"100"); r1.free(); - assert_eq!(pool.reserved(), 80); + assert_snapshot!(pool.reserved(), @"80"); let mut r4 = MemoryConsumer::new("s4").register(&pool); let err = r4.try_grow(30).unwrap_err().strip_backtrace(); - assert_eq!(err, "Resources exhausted: Failed to allocate additional 30.0 B for s4 with 0.0 B already allocated for this reservation - 20.0 B remain available for the total pool"); + assert_snapshot!(err, @"Resources exhausted: Failed to allocate additional 30 bytes for s4 with 0 bytes already allocated for this reservation - 20 bytes remain available for the total pool"); Review Comment: By the way, is there a reason for replacing `B` with `bytes`? I think the error message still seems to print B, so I was wondering if the change was intentional or if there's a plan to update the formatting consistently. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org