Skip to content

feat(assert): assert_true and assert_false accept a command with arguments - #999

Merged
Chemaclass merged 1 commit into
mainfrom
feat/994-assert-true-variadic
Aug 8, 2026
Merged

feat(assert): assert_true and assert_false accept a command with arguments#999
Chemaclass merged 1 commit into
mainfrom
feat/994-assert-true-variadic

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #994

assert_true test -d /tmp
assert_true grep -q foo ./file
assert_false test -d /nope

The argument used to be run as a single command word. Anything with arguments was looked up as a command whose name contained spaces — so the natural spelling was the broken one, and the workaround was an eval prefix nobody had documented until #993.

💡 Changes

Arguments are now passed through as arguments. Nothing is re-parsed, so a path containing a space survives — which the eval form cannot promise.

Additive by construction. With exactly one argument the old path runs unchanged, including the literal true/false/0/1 fast path and the eval prefix. Every existing call means what it meant. The literal check is guarded on argument count, because assert_true true --version is the command named true, not the boolean.

The exit code is captured with || exit_code=$? rather than a bare call — under --strict a failing command as a statement would abort the whole test.

🚫 Why not split the string instead

Splitting the single-argument form on whitespace would silently change what an existing string means, break arguments that legitimately contain spaces, and make the assertion sometimes-word-splitting. Passing real arguments needs no re-parsing at all.

✅ Verification

All eight shapes checked: literal true, literal 0, bare function, eval prefix, variadic, variadic with a space in a path, variadic assert_false, and true --version where the literal and the command collide.

5 new tests, RED first. make sa · make lint · bash build.sh bin -v✅ Build verified ✅ · 1713 sequential / 1672 parallel-simple-strict.

…ments

Closes #994.

    assert_true test -d /tmp
    assert_true grep -q foo ./file
    assert_false test -d /nope

The argument used to be run as a single command word. Anything with arguments
was looked up as a command whose name contained spaces, so the natural spelling
was the broken one and the workaround was an `eval ` prefix nobody had
documented until #993.

Arguments are now passed through as arguments. Nothing is re-parsed, so a path
containing a space survives -- which the eval form cannot promise.

Additive by construction: with exactly one argument the old path runs unchanged,
including the literal `true`/`false`/`0`/`1` fast path and the `eval ` prefix. So
every existing call means what it meant. The literal check is guarded on the
argument count, because `assert_true true --version` is the command named true,
not the boolean.

The exit code is captured with `|| exit_code=$?` rather than a bare call: under
--strict a failing command as a statement would abort the whole test.

The alternative of splitting the single-argument string on whitespace was
rejected. It would silently change what an existing string means, break
arguments that legitimately contain spaces, and make the assertion
sometimes-word-splitting. Passing real arguments needs no re-parsing at all.

Verified across all eight shapes: literal true, literal 0, bare function, eval
prefix, variadic, variadic with a space in a path, variadic assert_false, and
`true --version` where the literal and the command collide.

1713 sequential / 1672 parallel; baseline + 5, RED first.
@Chemaclass Chemaclass added the enhancement New feature or request label Aug 8, 2026
@Chemaclass Chemaclass self-assigned this Aug 8, 2026
@Chemaclass
Chemaclass merged commit 2061310 into main Aug 8, 2026
37 checks passed
@Chemaclass
Chemaclass deleted the feat/994-assert-true-variadic branch August 8, 2026 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant