Skip to content

fix(test): scripts/test-commands.sh runs to completion and reports totals (#679) - #684

Merged
TinDang97 merged 1 commit into
mainfrom
fix/test-commands-harness-rot-679
Aug 23, 2026
Merged

fix(test): scripts/test-commands.sh runs to completion and reports totals (#679)#684
TinDang97 merged 1 commit into
mainfrom
fix/test-commands-harness-rot-679

Conversation

@TinDang97

Copy link
Copy Markdown
Collaborator

Fixes #679.

What was wrong

scripts/test-commands.sh is the suite CLAUDE.md points at for every new
command, and it had never printed a result. It died partway through, silently,
and the operator saw a truncated log instead of a summary.

What it does now

  Total:  504
  Passed: 478
  Failed: 26

The 26 are pre-existing and are filed separately as #683. They became
visible for the first time because the run now reaches them — I verified each
one against the session-start log rather than assuming. Nothing here weakens
an assertion to manufacture a green; three rows that were failing do pass now
(FT.CREATE basic, FT.INFO returns index name, FT.DROPINDEX), because the
FLAT bug below was the cause.

Why one report became a sweep

Every abort was the same bash shape: a command whose non-zero status
set -euo pipefail converts into a silent exit. grep exits 1 when it matches
nothing, lsof exits 1 when a port is free, pkill exits 1 when nothing
matched, and a shell function whose last statement is a false if returns 1
too. That failure prints nothing at all, so each instance hid the next. Two of
the guards in this PR are for aborts I introduced while fixing earlier ones
in the same class — both found with bash -x, not by reading.

Guarded: 26 command substitutions ending in grep (the reported NUMERIC-07
site was one of a class, so the class is fixed); 6 raw redis-cli pipelines
and all four client wrappers, so a dead server yields failing rows plus a
summary instead of a truncated log; cargo build ... 2>/dev/null, which threw
away the reason a build failed; and the cleanup trap, which returned its last
kill's status rather than the script's — reporting a clean run as a failure.

On the wrappers: nothing in the file branches on their exit status (checked —
no if mcli ... and no mcli ... && anywhere), so || true costs no signal.

Three defects behind wrong results, not aborts

grep -Pzo "(?s)A.*B" at 13 call sites is GNU-only. On a macOS host grep
is ugrep, which rejects -P and exits 2 — and since those rows compare output
rather than status, that 2 was being reported as moon's answer. Replaced with
a portable spans() helper.

No --dir, so moon used the CWD. The suite wrote appendonlydir/ and
moon.lock into the repo root and reloaded the previous run's FT index
definitions, so a second run failed with ERR Index already exists. Each run
now gets a fresh mktemp dir, removed on exit.

No port pre-flight. A leftover server from an unrelated run answers, and
every row silently compares against it. Not hypothetical: it produced a full
run of MOONERR diskfull failures that I initially misattributed to my own
--dir change, until an A/B cleared the flag and lsof named another
session's moon on the port. The suite now refuses to start on an occupied port
and names the holder.

The FLAT row

FT.CREATE ... VECTOR FLAT expected OK, but moon has only ever implemented
HNSW (ERR expected HNSW algorithm, in ft_create.rs since #27) — so that row
had failed from the day it was written, and took four dependent rows down with
it. It now builds an HNSW index, and the FLAT gap is asserted explicitly
instead of hiding inside a row that expected success.

Regression coverage

Added a row for #681 (truncated FT.CREATE aborting the process) asserting the
server is still alive afterwards. Mutation-proven in both directions: it FAILS
against a pre-#682 binary and PASSES after.

Also

CLAUDE.md's "190 tests across 13 categories" was stale by more than half.

Gates

  • bash -n clean; full suite run to completion on a macOS host (the platform
    where grep -P was the blocker).
  • scripts/ci-local.sh + the full dispatch matrix before merge.

…tals (#679)

The suite CLAUDE.md points at for every new command had never printed a
result. It died partway through, silently, and the operator saw a truncated
log instead of a summary. It now finishes: 504 rows, 478 passing.

The 26 remaining failures are pre-existing and are filed as #683 -- they
became visible for the first time because the run now reaches them. Nothing
here weakens an assertion to get a green.

Every abort was the same bash shape: a command whose non-zero status
`set -euo pipefail` converts into a silent exit. grep exits 1 when it matches
nothing, lsof exits 1 when a port is free, pkill exits 1 when nothing matched,
and a shell function whose last statement is a false `if` returns 1 as well.
Because that failure prints nothing at all, each instance hid the next --
which is why this took several rounds, and why two of the guards below are
for aborts introduced by earlier ones in this same commit.

Guarded:
  * 26 command substitutions ending in grep. The reported NUMERIC-07 site was
    one of a class, so the class is fixed rather than the instance.
  * 6 raw redis-cli pipelines and all four client wrappers, so a dead server
    yields failing rows plus a summary instead of a truncated log. Nothing in
    the file branches on those wrappers' exit status (checked: no `if mcli`
    and no `mcli ... &&` anywhere), so `|| true` costs no signal.
  * `cargo build ... 2>/dev/null`, which threw away the reason a build failed
    and left the log reading "Building moon..." and nothing else.
  * the cleanup trap, which returned its last kill's status rather than the
    script's -- reporting a clean run as a failure.

Three defects that produced wrong results rather than aborts:

  * `grep -Pzo "(?s)A.*B"` at 13 call sites is GNU-only. On a macOS host grep
    is ugrep, which rejects -P and exits 2; since those rows compare output
    rather than status, that 2 was being reported as moon's answer. Replaced
    with a portable spans() helper.
  * No --dir, so moon treated the CWD as its data dir: the suite wrote
    appendonlydir/ and moon.lock into the repo root and reloaded the previous
    run's FT index definitions, so a second run failed with "Index already
    exists". Each run now gets a fresh mktemp dir, removed on exit.
  * No port pre-flight. A leftover server from an unrelated run answers and
    every row silently compares against it. Not hypothetical: it produced a
    full run of MOONERR diskfull failures traced to another session's moon on
    the port. The suite now refuses to start on an occupied port and names the
    holder.

The `FT.CREATE ... VECTOR FLAT` row expected OK, but moon has only ever
implemented HNSW (ERR expected HNSW algorithm, in ft_create.rs since #27), so
it had failed from the day it was written and took four dependent rows with
it. It now builds an HNSW index, and the FLAT gap is asserted explicitly
instead of hiding inside a row that expected success.

Added a regression row for #681 asserting the server is still alive after a
truncated FT.CREATE. Proven in both directions: it fails against a pre-#682
binary and passes after.

CLAUDE.md's "190 tests" was stale by more than half.

Fixes #679
Refs #681, #682, #683

author: Tin Dang
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing

@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 20 minutes.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6ec68ed1-db0b-4bb5-8fa3-272f03e83cca

📥 Commits

Reviewing files that changed from the base of the PR and between 9516931 and e2c3c9b.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • CLAUDE.md
  • scripts/test-commands.sh

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@TinDang97
TinDang97 merged commit 45eb83c into main Aug 23, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test-commands.sh aborts before its summary, and several rows have never passed

1 participant