fix+test: improve test suite, fix 2 bugs found by tests
Bugs fixed in production code: - compare.sh: Python truthiness on 0.0 — `if b_val` was False for 0.0 t/s, displaying it as a dash instead of "0.0". Fixed with `is not None` checks. - compare.sh: ZeroDivisionError when computing delta % with 0.0 baseline. Test improvements (review findings): - detect.bats: kernel param tests now use real detect_kernel_param logic pattern (not a separate reimplementation). Added non-GiB-aligned RAM test, device ID without 0x prefix, empty firmware version, llama-bench detection, detect_total_physical_ram_kb tests. - benchmark_compare.bats: assert delta percentages (+20.0%, -25.0%, 0.0%), test 0.0 t/s edge case, test per-directory error messages, test config change detection with specific field assertions. - log_metrics.bats: add assert_success, --help test, timestamp format validation. Remove unused mock sysfs setup. - common.bats: fix data_dir test, remove redundant assertion, add cleanup. - test_helper.sh: remove unused FIXTURES_DIR. - Remove empty tests/fixtures/ directory. 94 tests, all passing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -120,11 +120,11 @@ for key in all_keys:
|
||||
b_val = b_idx.get(key)
|
||||
a_val = a_idx.get(key)
|
||||
|
||||
b_str = f"{b_val:.1f}" if b_val else "—"
|
||||
a_str = f"{a_val:.1f}" if a_val else "—"
|
||||
b_str = f"{b_val:.1f}" if b_val is not None else "—"
|
||||
a_str = f"{a_val:.1f}" if a_val is not None else "—"
|
||||
|
||||
if b_val and a_val:
|
||||
delta_pct = (a_val - b_val) / b_val * 100
|
||||
if b_val is not None and a_val is not None:
|
||||
delta_pct = (a_val - b_val) / b_val * 100 if b_val != 0 else (float('inf') if a_val > 0 else 0)
|
||||
if delta_pct > 0:
|
||||
d_str = f"\033[32m+{delta_pct:.1f}%\033[0m"
|
||||
elif delta_pct < 0:
|
||||
|
||||
Reference in New Issue
Block a user