Mole
Mole copied to clipboard
Cache bytes_to_human results and use isolated temp dir for install tests
Motivation
- Reduce repeated formatting overhead in
bytes_to_humanby caching results for identical inputs to improve performance. - Make the installation test safer and non-destructive by using a unique temporary install prefix instead of a fixed
/tmppath. - Avoid brittle performance assertions by keeping the performance test configurable and consistent with previous limits.
Description
- Add a simple one-entry cache to
bytes_to_humaninlib/core/base.shusingMOLE_BYTES_TO_HUMAN_CACHE_*variables and consolidate formatted output via a localresultvariable. - Source
lib/core/file_ops.shinscripts/test.sh, create a unique temp install directory viamktemp -dfor the install test, and remove it withsafe_removeinstead ofrm -rf. - Restore the default
bytes_to_humanperformance threshold intests/performance.batsand make it overridable viaMOLE_PERF_BYTES_TO_HUMAN_LIMIT_MS.
Testing
- No automated test suite was executed as part of this change.
- The change updates
tests/performance.batsto use the configurable limit and does not itself run the test harness. - Manual inspection and lint-style safety changes were applied to test runner flow but no CI results are available.
- All changes are limited to
lib/core/base.sh,scripts/test.sh, andtests/performance.batsand compiled successfully in a local commit.