The previous commit only landed the research-folder rename — a multi-path git add silently failed and left CONTEXT.md, ADR-0012, and the actual skill files unstaged. This lands them: the agentsmd-audit skill itself (three deterministic validators for secrets, structure, and drift against a target repo's AGENTS.md), its bats test suite, provenance record, and the CONTEXT.md/ADR entries documenting why this lives in core rather than kyberforge. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
106 lines
2.2 KiB
Bash
106 lines
2.2 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
setup() {
|
|
REPO_ROOT="$(cd "$BATS_TEST_DIRNAME/../../../../../" && pwd)"
|
|
load "$REPO_ROOT/tests/test_helper/bats-support/load"
|
|
load "$REPO_ROOT/tests/test_helper/bats-assert/load"
|
|
|
|
SCRIPT="$(cd "$BATS_TEST_DIRNAME/../scripts" && pwd)/validate-drift.sh"
|
|
TMPDIR="$(mktemp -d)"
|
|
}
|
|
|
|
teardown() {
|
|
rm -rf "$TMPDIR"
|
|
}
|
|
|
|
@test "fails when AGENTS.md references a stale npm script" {
|
|
cat > "$TMPDIR/package.json" <<'EOF'
|
|
{
|
|
"scripts": {
|
|
"test": "jest"
|
|
}
|
|
}
|
|
EOF
|
|
cat > "$TMPDIR/AGENTS.md" <<'EOF'
|
|
# AGENTS.md
|
|
|
|
## Testing
|
|
- Run `pnpm run e2e` before committing.
|
|
EOF
|
|
run bash "$SCRIPT" "$TMPDIR"
|
|
assert_failure
|
|
assert_output --partial "e2e"
|
|
}
|
|
|
|
@test "passes when the referenced npm script exists" {
|
|
cat > "$TMPDIR/package.json" <<'EOF'
|
|
{
|
|
"scripts": {
|
|
"test": "jest"
|
|
}
|
|
}
|
|
EOF
|
|
cat > "$TMPDIR/AGENTS.md" <<'EOF'
|
|
# AGENTS.md
|
|
|
|
## Testing
|
|
- Run `npm run test` before committing.
|
|
EOF
|
|
run bash "$SCRIPT" "$TMPDIR"
|
|
assert_success
|
|
}
|
|
|
|
@test "fails when AGENTS.md references a stale make target" {
|
|
cat > "$TMPDIR/Makefile" <<'EOF'
|
|
build:
|
|
echo building
|
|
EOF
|
|
cat > "$TMPDIR/AGENTS.md" <<'EOF'
|
|
# AGENTS.md
|
|
|
|
## Setup
|
|
Run `make deploy` to ship.
|
|
EOF
|
|
run bash "$SCRIPT" "$TMPDIR"
|
|
assert_failure
|
|
assert_output --partial "deploy"
|
|
}
|
|
|
|
@test "emits INFO instead of FAIL when there is no package.json to verify an npm script against" {
|
|
cat > "$TMPDIR/AGENTS.md" <<'EOF'
|
|
# AGENTS.md
|
|
|
|
## Testing
|
|
Run `pnpm run e2e` before committing.
|
|
EOF
|
|
run bash "$SCRIPT" "$TMPDIR"
|
|
assert_success
|
|
assert_output --partial "INFO"
|
|
assert_output --partial "e2e"
|
|
}
|
|
|
|
@test "fails when a referenced file path does not exist" {
|
|
cat > "$TMPDIR/AGENTS.md" <<'EOF'
|
|
# AGENTS.md
|
|
|
|
## Setup
|
|
See `scripts/bootstrap.sh` for environment setup.
|
|
EOF
|
|
run bash "$SCRIPT" "$TMPDIR"
|
|
assert_failure
|
|
assert_output --partial "scripts/bootstrap.sh"
|
|
}
|
|
|
|
@test "passes when the referenced file path exists" {
|
|
mkdir -p "$TMPDIR/scripts"
|
|
: > "$TMPDIR/scripts/bootstrap.sh"
|
|
cat > "$TMPDIR/AGENTS.md" <<'EOF'
|
|
# AGENTS.md
|
|
|
|
## Setup
|
|
See `scripts/bootstrap.sh` for environment setup.
|
|
EOF
|
|
run bash "$SCRIPT" "$TMPDIR"
|
|
assert_success
|
|
}
|