Files
orca/scripts/tests

Bash Testing Policy (grill C-15)

Every bash script under scripts/ MUST have at least one bats test covering the happy path and one covering the failure path. This is the compensating control for bash being exempt from the Go coverage gate (D-186).

Framework

  • batsbats scripts/tests/*.bash runs all bash tests.
  • shellcheckshellcheck scripts/*.sh scripts/lib/*.sh scripts/tests/*.bash static analysis.
  • shfmtshfmt -d scripts/ formatting check (optional; skip if not installed).

Install (if missing)

# bats
npm install -g bats    # or: git clone https://github.com/bats-core/bats-core.git && ./bats-core/install.sh /usr/local
# shellcheck
apt-get install -y shellcheck
# shfmt (optional)
mvdan.cc/sh (go install mvdan.cc/sh/v3/cmd/shfmt@latest)

Running

make test-bash   # runs bats (skips gracefully if bats missing)
make lint-bash   # runs shellcheck + shfmt (skips gracefully if missing)
make test        # runs both Go + bash tests
make lint        # runs both Go + bash lint

Test file convention

  • Test files live in scripts/tests/<script-name>_test.bash.
  • Source load test_helper at the top of every test file.
  • Happy path: @test "<script> happy path" { ... }
  • Failure path: @test "<script> failure path" { ... }
  • Use run <command> + assert_status/assert_contains/assert_not_contains from test_helper.