Skip to content

26_deconstruct: count snarl IDs with grep -c, not a quoted wc -l - #5108

Open
glennhickey wants to merge 1 commit into
masterfrom
vg-deconstruct-wc-fix
Open

glennhickey wants to merge 1 commit into
masterfrom
vg-deconstruct-wc-fix

Conversation

@glennhickey

Copy link
Copy Markdown
Contributor

BSD wc -l right-aligns its count in an eight-wide field, so "$(... | wc -l)" is " 1", and bash-tap's is() compares strings without trimming. One assertion in 26_deconstruct.t is written with the command substitution quoted, so it fails wherever /usr/bin/wc is the wc on the PATH.

make test and the macos CI job never see it: the Makefile prepends Homebrew's coreutils gnubin, so both get GNU wc. It fails when prove is run on a single test file from a shell without that PATH, which is how CLAUDE.md says to run one test file. The other twenty wc -l assertions in this file are unquoted, so word splitting strips the padding.

grep -c . counts the same lines here and is the form this file already uses thirty-one times, including once inside a quoted command substitution. It is also stricter: were a record's ID column ever empty, wc -l would count the blank line and let the assertion pass with no IDs in it at all.

Other test files still hold quoted wc -l assertions with the same problem. They are left alone.

Tested with prove t/26_deconstruct.t on macOS 15.5, with and without gnubin on the PATH.

🤖 Generated with Claude Code

BSD wc -l right-aligns its count in an eight-wide field, so "$(... | wc -l)"
is "       1", and bash-tap's is() compares strings without trimming. The
assertion fails wherever /usr/bin/wc is the wc on the PATH.

make test and the macos CI job never see it: the Makefile puts Homebrew's
coreutils gnubin ahead of /usr/bin, so both get GNU wc, which does not pad.
It fails when prove is run on a single test file from a shell without that
PATH, which is how CLAUDE.md says to run one test file. The other twenty
wc -l assertions in this file are unquoted, so word splitting strips the
padding and they pass either way; this was the only quoted one.

grep -c . counts the same lines here, and is the form this file already uses
thirty-one times, including once inside a quoted command substitution. It is
also stricter: were a record's ID column ever empty, wc -l would count the
blank line and let the assertion pass with no IDs in it at all, where
grep -c . returns 0 and fails.

Other test files still hold quoted wc -l assertions with the same problem.
They are left alone.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

2 participants