Mole icon indicating copy to clipboard operation
Mole copied to clipboard

Cache bytes_to_human results and use isolated temp dir for install tests

Open tw93 opened this issue 2 days ago • 0 comments

Motivation

  • Reduce repeated formatting overhead in bytes_to_human by 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 /tmp path.
  • 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_human in lib/core/base.sh using MOLE_BYTES_TO_HUMAN_CACHE_* variables and consolidate formatted output via a local result variable.
  • Source lib/core/file_ops.sh in scripts/test.sh, create a unique temp install directory via mktemp -d for the install test, and remove it with safe_remove instead of rm -rf.
  • Restore the default bytes_to_human performance threshold in tests/performance.bats and make it overridable via MOLE_PERF_BYTES_TO_HUMAN_LIMIT_MS.

Testing

  • No automated test suite was executed as part of this change.
  • The change updates tests/performance.bats to 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, and tests/performance.bats and compiled successfully in a local commit.

Codex Task

tw93 avatar Dec 31 '25 12:12 tw93