B1: DatabasePath() now always resolves to .beads/dolt/ for dolt backend, ignoring stale Database field values like town, wyvern, beads_rig that caused bd to look in the wrong directory. B2: bootstrapEmbeddedDolt() now blocks JSONL auto-import in dolt-native sync mode. If the dolt DB does not exist, it returns an error instead of silently creating a new database from stale JSONL backup. B-build: Makefile and scripts/test.sh now detect Homebrew keg-only icu4c and export CGO_CFLAGS/CGO_CPPFLAGS/CGO_LDFLAGS so dolt go-icu-regex dependency can compile and link. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
115 lines
2.8 KiB
Bash
Executable file
115 lines
2.8 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Test runner that automatically skips known broken tests
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
SKIP_FILE="$REPO_ROOT/.test-skip"
|
|
|
|
# ICU4C is keg-only on macOS (Homebrew doesn't symlink it into /opt/homebrew).
|
|
# Dolt's go-icu-regex dependency needs these paths to compile and link.
|
|
if [[ "$(uname)" == "Darwin" ]]; then
|
|
ICU_PREFIX="$(brew --prefix icu4c 2>/dev/null || true)"
|
|
if [[ -n "$ICU_PREFIX" ]]; then
|
|
export CGO_CFLAGS="${CGO_CFLAGS:+$CGO_CFLAGS }-I${ICU_PREFIX}/include"
|
|
export CGO_CPPFLAGS="${CGO_CPPFLAGS:+$CGO_CPPFLAGS }-I${ICU_PREFIX}/include"
|
|
export CGO_LDFLAGS="${CGO_LDFLAGS:+$CGO_LDFLAGS }-L${ICU_PREFIX}/lib"
|
|
fi
|
|
fi
|
|
|
|
# Build skip pattern from .test-skip file
|
|
build_skip_pattern() {
|
|
if [[ ! -f "$SKIP_FILE" ]]; then
|
|
echo ""
|
|
return
|
|
fi
|
|
|
|
# Read non-comment, non-empty lines and join with |
|
|
local pattern=$(grep -v '^#' "$SKIP_FILE" | grep -v '^[[:space:]]*$' | paste -sd '|' -)
|
|
echo "$pattern"
|
|
}
|
|
|
|
# Default values
|
|
TIMEOUT="${TEST_TIMEOUT:-3m}"
|
|
SKIP_PATTERN=$(build_skip_pattern)
|
|
VERBOSE="${TEST_VERBOSE:-}"
|
|
RUN_PATTERN="${TEST_RUN:-}"
|
|
COVERAGE="${TEST_COVER:-}"
|
|
COVERPROFILE="${TEST_COVERPROFILE:-/tmp/beads.coverage.out}"
|
|
COVERPKG="${TEST_COVERPKG:-}"
|
|
|
|
# Parse arguments
|
|
PACKAGES=()
|
|
while [[ $# -gt 0 ]]; do
|
|
case $1 in
|
|
-v|--verbose)
|
|
VERBOSE="-v"
|
|
shift
|
|
;;
|
|
-timeout)
|
|
TIMEOUT="$2"
|
|
shift 2
|
|
;;
|
|
-run)
|
|
RUN_PATTERN="$2"
|
|
shift 2
|
|
;;
|
|
-skip)
|
|
# Allow additional skip patterns
|
|
if [[ -n "$SKIP_PATTERN" ]]; then
|
|
SKIP_PATTERN="$SKIP_PATTERN|$2"
|
|
else
|
|
SKIP_PATTERN="$2"
|
|
fi
|
|
shift 2
|
|
;;
|
|
*)
|
|
PACKAGES+=("$1")
|
|
shift
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# Default to all packages if none specified
|
|
if [[ ${#PACKAGES[@]} -eq 0 ]]; then
|
|
PACKAGES=("./...")
|
|
fi
|
|
|
|
# Build go test command
|
|
CMD=(go test -timeout "$TIMEOUT")
|
|
|
|
if [[ -n "$VERBOSE" ]]; then
|
|
CMD+=(-v)
|
|
fi
|
|
|
|
if [[ -n "$SKIP_PATTERN" ]]; then
|
|
CMD+=(-skip "$SKIP_PATTERN")
|
|
fi
|
|
|
|
if [[ -n "$RUN_PATTERN" ]]; then
|
|
CMD+=(-run "$RUN_PATTERN")
|
|
fi
|
|
|
|
if [[ -n "$COVERAGE" ]]; then
|
|
CMD+=(-covermode=atomic -coverprofile "$COVERPROFILE")
|
|
if [[ -n "$COVERPKG" ]]; then
|
|
CMD+=(-coverpkg "$COVERPKG")
|
|
fi
|
|
fi
|
|
|
|
CMD+=("${PACKAGES[@]}")
|
|
|
|
echo "Running: ${CMD[*]}" >&2
|
|
echo "Skipping: $SKIP_PATTERN" >&2
|
|
echo "" >&2
|
|
|
|
"${CMD[@]}"
|
|
status=$?
|
|
|
|
if [[ -n "$COVERAGE" ]]; then
|
|
total=$(go tool cover -func="$COVERPROFILE" | awk '/^total:/ {print $NF}')
|
|
echo "Total coverage: ${total} (profile: ${COVERPROFILE})" >&2
|
|
fi
|
|
|
|
exit $status
|