#!/usr/bin/env bash set -euo pipefail repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" fixture_root="$(mktemp -d)" trap 'rm -rf "$fixture_root"' EXIT printf '#!/bin/sh\nexit 0\n' > "$fixture_root/ok.sh" printf '#!/bin/sh\r\nexit 0\r\n' > "$fixture_root/bad.sh" printf 'services:\r\n app:\r\n image: example\r\n' > "$fixture_root/compose.yaml" printf 'FROM scratch\r\n' > "$fixture_root/Dockerfile" printf 'Write-Output "ok"\r\n' > "$fixture_root/valid.ps1" set +e output="$("$repo_root/scripts/verify-line-endings.sh" "$fixture_root" 2>&1)" status=$? set -e if [[ $status -eq 0 ]]; then echo "expected CRLF rejection" >&2 exit 1 fi for expected_path in bad.sh compose.yaml Dockerfile; do if ! grep -Fqx "$expected_path" <<< "$output"; then echo "missing CRLF path: $expected_path" >&2 exit 1 fi done if grep -Fq 'ok.sh' <<< "$output"; then echo "reported LF-only path: ok.sh" >&2 exit 1 fi if grep -Fq 'valid.ps1' <<< "$output"; then echo "reported compliant CRLF PowerShell path: valid.ps1" >&2 exit 1 fi printf '#!/bin/sh\nexit 0\n' > "$fixture_root/bad.sh" printf 'services:\n app:\n image: example\n' > "$fixture_root/compose.yaml" printf 'FROM scratch\n' > "$fixture_root/Dockerfile" "$repo_root/scripts/verify-line-endings.sh" "$fixture_root" git_fixture="$fixture_root/git-worktree" mkdir -p "$git_fixture" git -C "$git_fixture" init -q printf 'tracked then deleted\n' >"$git_fixture/deleted.md" git -C "$git_fixture" add deleted.md rm "$git_fixture/deleted.md" git_output="$(cd "$git_fixture" && "$repo_root/scripts/verify-line-endings.sh" 2>&1)" if grep -Fq 'No such file or directory' <<<"$git_output"; then echo "line-ending verifier tried to read a tracked deletion" >&2 exit 1 fi echo "line-ending verifier tests passed"