mirror of
https://github.com/DeusData/codebase-memory-mcp.git
synced 2026-11-03 08:03:38 +08:00
- Add scripts/env.sh: detects true hardware arch (even under Rosetta), verifies compiler supports target arch, adds arch prefix on macOS - macOS uses cc/c++ everywhere (tests + builds) — ASan works natively - Linux uses gcc/g++ everywhere — full sanitizer support - Remove broken CC ?= gcc-14 from Makefile (GNU Make built-in overrides it) - Scripts accept --arch flag and CC=/CXX= overrides
62 lines
1.5 KiB
Bash
Executable File
62 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# test.sh — Clean build + run all C tests with ASan + UBSan.
|
|
#
|
|
# Usage:
|
|
# scripts/test.sh # Auto-detect everything
|
|
# scripts/test.sh --arch x86_64 # Force x86_64 build
|
|
# scripts/test.sh CC=gcc-14 CXX=g++-14 # Override compiler
|
|
#
|
|
# This script is the SINGLE source of truth for running tests.
|
|
# Used identically in local development and CI workflows.
|
|
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
cd "$ROOT"
|
|
|
|
# Parse --arch flag before sourcing env.sh
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
--arch) :;; # next arg is the value, handled below
|
|
arm64|x86_64)
|
|
# Check if previous arg was --arch
|
|
if [[ "${prev_arg:-}" == "--arch" ]]; then
|
|
export CBM_ARCH="$arg"
|
|
fi
|
|
;;
|
|
esac
|
|
prev_arg="$arg"
|
|
done
|
|
|
|
# Also support --arch=value
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
--arch=*) export CBM_ARCH="${arg#--arch=}" ;;
|
|
esac
|
|
done
|
|
|
|
# shellcheck source=env.sh
|
|
source "$ROOT/scripts/env.sh"
|
|
|
|
# Forward CC/CXX from args
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
CC=*|CXX=*) export "${arg}" ;;
|
|
--arch|--arch=*) ;; # already handled
|
|
arm64|x86_64) ;; # already handled
|
|
esac
|
|
done
|
|
|
|
print_env "test.sh"
|
|
|
|
# Verify compiler supports target arch
|
|
verify_compiler "${CC:-gcc-14}"
|
|
|
|
# Step 1: Clean
|
|
scripts/clean.sh
|
|
|
|
# Step 2 + 3: Build and run tests (with arch prefix on macOS)
|
|
$ARCH_PREFIX make -j"$NPROC" -f Makefile.cbm test
|
|
|
|
echo "=== All tests passed ==="
|