Skip to content

fix: strip wc whitespace in unit tests for macOS compatibility#20

Merged
glauberlima merged 1 commit intomainfrom
fix/unit-test-wc-whitespace-macos
Feb 23, 2026
Merged

fix: strip wc whitespace in unit tests for macOS compatibility#20
glauberlima merged 1 commit intomainfrom
fix/unit-test-wc-whitespace-macos

Conversation

@glauberlima
Copy link
Copy Markdown
Owner

Summary

  • Wrap wc -m and wc -l calls in $(( ... )) to strip macOS leading-space padding before string comparison in unit tests
  • Extract cleanup_temp and validate_json helpers in install.sh to eliminate duplicated inline logic
  • Replace xargs string join with bash array in prompt_component_selection
  • Simplify step counter increments using $((++current_step))

Root Cause

macOS wc pads numeric output with leading spaces (e.g. " 15") while BAR_WIDTH is a bare integer ("15"). The test() function uses string equality (==), so comparisons always failed on macOS despite correct numeric values.

Test plan

  • ./tests/unit.sh — all 68 tests pass (previously 3 failing)
  • ./tests/integration.sh — all 25 tests pass
  • ./tests/shellcheck.sh — zero warnings

🤖 Generated with Claude Code

macOS `wc` pads output with leading spaces (e.g. "      15"), causing
string equality comparisons against bare integers to fail. Wrap each
`wc` call in `$(( ... ))` to strip whitespace via arithmetic expansion.

Also includes install.sh refactors: extract cleanup_temp/validate_json
helpers, use array for component results, and simplify step counter
increments with `$((++current_step))`.
@glauberlima glauberlima merged commit 062356d into main Feb 23, 2026
1 check passed
@glauberlima glauberlima deleted the fix/unit-test-wc-whitespace-macos branch March 6, 2026 11:10
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.

1 participant