mirror of
https://github.com/tw93/Mole.git
synced 2026-02-04 18:34:46 +00:00
30 lines
740 B
Bash
30 lines
740 B
Bash
#!/usr/bin/env bats
|
|
|
|
setup_file() {
|
|
PROJECT_ROOT="$(cd "${BATS_TEST_DIRNAME}/.." && pwd)"
|
|
export PROJECT_ROOT
|
|
}
|
|
|
|
@test "shellcheck passes for test scripts" {
|
|
if ! command -v shellcheck > /dev/null 2>&1; then
|
|
skip "shellcheck not installed"
|
|
fi
|
|
|
|
run env PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc << 'EOF'
|
|
set -euo pipefail
|
|
cd "$PROJECT_ROOT"
|
|
targets=()
|
|
while IFS= read -r file; do
|
|
targets+=("$file")
|
|
done < <(find "$PROJECT_ROOT/tests" -type f \( -name '*.bats' -o -name '*.sh' \) | sort)
|
|
if [[ ${#targets[@]} -eq 0 ]]; then
|
|
echo "No test shell files found"
|
|
exit 0
|
|
fi
|
|
shellcheck --rcfile "$PROJECT_ROOT/.shellcheckrc" "${targets[@]}"
|
|
EOF
|
|
|
|
printf '%s\n' "$output" >&3
|
|
[ "$status" -eq 0 ]
|
|
}
|