mirror of
https://github.com/Nexoniarz/Finch.git
synced 2026-11-03 16:54:25 +00:00
- on stderr (finch ir stays the IR), as yellow warnings in editors (@W in the index), once per place - str, arrays and maps inside a struct don't count: passing it copies only their handles - none in the compiler, the examples or the tests other than the new one - docs: the warning instead of "not planned"; what was and wasn't checked for Android Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GzNP6r8dg6WDxUVZy8wjL
60 lines
2.4 KiB
Shell
Executable file
60 lines
2.4 KiB
Shell
Executable file
#!/usr/bin/env bash
|
|
# Builds every test for another system and runs it there through an emulator:
|
|
# tests/cross.sh windows x86_64-w64-mingw32, run with Wine
|
|
# tests/cross.sh arm64 aarch64 Linux, run with qemu-aarch64
|
|
# e.g. nix-shell -p pkgsCross.mingwW64.buildPackages.gcc wine64 --run 'tests/cross.sh windows'
|
|
# nix-shell -p pkgsCross.aarch64-multiplatform.buildPackages.gcc qemu \
|
|
# --run 'FINCH_CC=aarch64-unknown-linux-gnu-gcc QEMU_LD_PREFIX=<the aarch64 glibc> tests/cross.sh arm64'
|
|
# (On a real Windows/ARM64/macOS machine, use tests/run.sh with that system's finch.)
|
|
set -u
|
|
cd "$(dirname "$0")"
|
|
target=${1:?usage: tests/cross.sh windows|arm64}
|
|
FINCH=${FINCH:-../build/finch}
|
|
export WINEDEBUG=-all
|
|
case $target in
|
|
windows) runner=wine; ext=.exe
|
|
wine cmd /c exit > /dev/null 2>&1 || true ;; # the first run sets Wine up and says so: not in a test's output
|
|
arm64) runner=qemu-aarch64; ext= ;;
|
|
*) echo "unknown target $target"; exit 2 ;;
|
|
esac
|
|
pass=0; failed=0
|
|
tmp=$(mktemp -d)
|
|
trap 'rm -rf "$tmp"' EXIT
|
|
|
|
run_exe() { # program, stdin -> output without Windows' \r
|
|
$runner "$1" < "$2" 2>&1 | tr -d '\r'
|
|
}
|
|
|
|
for f in run/*.fch new/*.fch; do
|
|
grep -q "^fn main" "$f" || continue
|
|
input="${f%.fch}.in"
|
|
[ -f "$input" ] || input=/dev/null
|
|
exe="$tmp/$(basename "${f%.fch}")$ext"
|
|
if ! "$FINCH" build "$f" --target "$target" -o "$exe" > "$tmp/err" 2>&1; then
|
|
failed=$((failed + 1)); echo "FAIL (build) $f"; head -5 "$tmp/err"; continue
|
|
fi
|
|
got=$(run_exe "$exe" "$input")
|
|
# (warnings come from the build, which is not part of what the program prints)
|
|
if [ "$got" == "$(tr -d '\r' < "${f%.fch}.out" | grep -v ': warning: ')" ]; then
|
|
pass=$((pass + 1))
|
|
else
|
|
failed=$((failed + 1)); echo "FAIL $f"; diff <(echo "$got") "${f%.fch}.out" | head -10
|
|
fi
|
|
done
|
|
|
|
for f in fail/*.fch new/fail/*.fch; do
|
|
expect=$(head -1 "$f" | sed -n 's|^// expect: ||p')
|
|
exe="$tmp/$(basename "${f%.fch}")$ext"
|
|
if "$FINCH" build "$f" --target "$target" -o "$exe" > "$tmp/out" 2>&1; then
|
|
got=$(run_exe "$exe" /dev/null)
|
|
else
|
|
got=$(cat "$tmp/out")
|
|
fi
|
|
if [[ "$got" == *"$expect"* ]]; then
|
|
pass=$((pass + 1))
|
|
else
|
|
failed=$((failed + 1)); echo "FAIL $f (wanted: $expect)"; echo "$got" | head -5
|
|
fi
|
|
done
|
|
echo "$target ($runner): $pass passed, $failed failed"
|
|
[ $failed -eq 0 ]
|