#!/usr/bin/env bats # # Tests for scripts/install-lang.sh — install a language ruleset into a project. # # Strategy: scaffold a fresh git project in a temp dir, run install-lang.sh # against it. Canonical source stays the real one (install-lang.sh resolves # languages/ and claude-rules/ relative to its own location). REAL_REPO="$(cd "$(dirname "$BATS_TEST_FILENAME")/../.." && pwd)" INSTALL_LANG="$REAL_REPO/scripts/install-lang.sh" setup() { PROJECT="$(mktemp -d -t install-lang-bats.XXXXXX)" (cd "$PROJECT" && git init -q) } teardown() { rm -rf "$PROJECT" } @test "install-lang elisp: lands the tooling footprint" { run bash "$INSTALL_LANG" elisp "$PROJECT" [ "$status" -eq 0 ] [ -d "$PROJECT/.claude/rules" ] [ -d "$PROJECT/githooks" ] [ -f "$PROJECT/CLAUDE.md" ] # The coverage-summary script ships inside the gitignored .claude footprint. [ -f "$PROJECT/.claude/scripts/coverage-summary.el" ] } @test "install-lang elisp: seeds the project-owned coverage Makefile fragment" { run bash "$INSTALL_LANG" elisp "$PROJECT" [ "$status" -eq 0 ] [ -f "$PROJECT/coverage-makefile.txt" ] } @test "install-lang elisp: does not overwrite an existing fragment without FORCE" { echo "MY OWN VERSION" > "$PROJECT/coverage-makefile.txt" run bash "$INSTALL_LANG" elisp "$PROJECT" [ "$status" -eq 0 ] grep -qxF "MY OWN VERSION" "$PROJECT/coverage-makefile.txt" } @test "install-lang elisp: gitignores the full Claude tooling footprint" { run bash "$INSTALL_LANG" elisp "$PROJECT" [ "$status" -eq 0 ] # The whole .claude/, CLAUDE.md, and githooks/ stay out of the project's # git history — Claude tooling is delivered by install/sync, never committed. grep -qxF ".claude/" "$PROJECT/.gitignore" grep -qxF "CLAUDE.md" "$PROJECT/.gitignore" grep -qxF "githooks/" "$PROJECT/.gitignore" # Elisp byte-compile artifacts. grep -qxF "*.elc" "$PROJECT/.gitignore" grep -qxF "*.eln" "$PROJECT/.gitignore" } @test "install-lang python: lands the coverage script in the gitignored footprint" { run bash "$INSTALL_LANG" python "$PROJECT" [ "$status" -eq 0 ] [ -f "$PROJECT/.claude/scripts/coverage-summary.py" ] [ -f "$PROJECT/coverage-makefile.txt" ] # The .claude footprint must be gitignored so the script isn't committed. grep -qxF ".claude/" "$PROJECT/.gitignore" grep -qxF "coverage.json" "$PROJECT/.gitignore" } @test "install-lang typescript: lands the coverage script in the gitignored footprint" { run bash "$INSTALL_LANG" typescript "$PROJECT" [ "$status" -eq 0 ] [ -f "$PROJECT/.claude/scripts/coverage-summary.js" ] [ -f "$PROJECT/coverage-makefile.txt" ] grep -qxF ".claude/" "$PROJECT/.gitignore" grep -qxF "coverage/" "$PROJECT/.gitignore" } @test "install-lang go: full bundle lands (rules, hook, settings, githook, CLAUDE.md, coverage)" { run bash "$INSTALL_LANG" go "$PROJECT" [ "$status" -eq 0 ] # Coverage slice [ -f "$PROJECT/.claude/scripts/coverage-summary.go" ] [ -f "$PROJECT/coverage-makefile.txt" ] # Language + testing rules — these are the bundle's sync fingerprint [ -f "$PROJECT/.claude/rules/go.md" ] [ -f "$PROJECT/.claude/rules/go-testing.md" ] # PostToolUse validate hook, executable and wired into settings [ -x "$PROJECT/.claude/hooks/validate-go.sh" ] grep -qF "validate-go.sh" "$PROJECT/.claude/settings.json" # Pre-commit githook [ -x "$PROJECT/githooks/pre-commit" ] # CLAUDE.md seeded [ -f "$PROJECT/CLAUDE.md" ] # Gitignore footprint grep -qxF ".claude/" "$PROJECT/.gitignore" grep -qxF "cover.out" "$PROJECT/.gitignore" }