mirror of
https://github.com/Nexoniarz/Finch.git
synced 2026-11-03 00:44:27 +00:00
Windows support (wip): target layer, Microsoft x64 ABI, portable runtime, CI
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
8497251dc5
commit
84cbbb3e16
18 changed files with 481 additions and 94 deletions
|
|
@ -17,7 +17,7 @@ for f in run/*.fch; do
|
|||
want="${f%.fch}.out"
|
||||
input="${f%.fch}.in"
|
||||
[ -f "$input" ] || input=/dev/null
|
||||
got=$("$FINCH" run "$f" < "$input" 2>&1)
|
||||
got=$("$FINCH" run "$f" < "$input" 2>&1 | tr -d '\r') # Windows ends lines with \r\n
|
||||
if [ "$got" != "$(cat "$want")" ]; then
|
||||
failed=$((failed + 1))
|
||||
echo "FAIL $f"
|
||||
|
|
@ -41,6 +41,7 @@ for f in fail/*.fch; do
|
|||
expect=$(head -1 "$f" | sed -n 's|^// expect: ||p')
|
||||
got=$("$FINCH" run "$f" < /dev/null 2>&1)
|
||||
status=$?
|
||||
got=$(echo "$got" | tr -d '\r')
|
||||
if [ $status -ne 0 ] && [[ "$got" == *"$expect"* ]]; then
|
||||
pass=$((pass + 1))
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
fn main() {
|
||||
path := "/tmp/finch_test_file.txt"
|
||||
path := "finch_test_file.txt"
|
||||
ok := write_file(path, "line one\nline two\n")
|
||||
print(ok, file_exists(path))
|
||||
text := read_file(path)
|
||||
lines := text.trim().split("\n")
|
||||
print(lines, lines.len)
|
||||
print(file_exists("/definitely/not/here"))
|
||||
print(delete_file(path), file_exists(path))
|
||||
print(file_exists("definitely/not/here"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
true true
|
||||
["line one", "line two"] 2
|
||||
true false
|
||||
false
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
42
|
||||
2 1
|
||||
99
|
||||
true true (nil)
|
||||
true true null
|
||||
|
|
|
|||
50
tests/windows.sh
Executable file
50
tests/windows.sh
Executable file
|
|
@ -0,0 +1,50 @@
|
|||
#!/usr/bin/env bash
|
||||
# Cross-compiles every test for Windows (x86_64-w64-mingw32) and runs it under Wine.
|
||||
# Needs x86_64-w64-mingw32-gcc and wine, e.g.:
|
||||
# nix-shell -p pkgsCross.mingwW64.buildPackages.gcc wine64 --run tests/windows.sh
|
||||
# (On a real Windows machine, use tests/run.sh with finch.exe instead.)
|
||||
set -u
|
||||
cd "$(dirname "$0")"
|
||||
FINCH=${FINCH:-../build/finch}
|
||||
export WINEDEBUG=-all
|
||||
pass=0; failed=0
|
||||
tmp=$(mktemp -d)
|
||||
trap 'rm -rf "$tmp"' EXIT
|
||||
|
||||
run_exe() { # exe, stdin -> output without Windows' \r
|
||||
wine "$1" < "$2" 2>&1 | tr -d '\r'
|
||||
}
|
||||
|
||||
for f in run/*.fch; do
|
||||
grep -q "^fn main" "$f" || continue
|
||||
input="${f%.fch}.in"
|
||||
[ -f "$input" ] || input=/dev/null
|
||||
exe="$tmp/$(basename "${f%.fch}").exe"
|
||||
if ! "$FINCH" build "$f" --target windows -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")
|
||||
if [ "$got" == "$(cat "${f%.fch}.out")" ]; 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; do
|
||||
expect=$(head -1 "$f" | sed -n 's|^// expect: ||p')
|
||||
exe="$tmp/$(basename "${f%.fch}").exe"
|
||||
if got=$("$FINCH" build "$f" --target windows -o "$exe" 2>&1); then
|
||||
got=$(run_exe "$exe" /dev/null); status=$?
|
||||
status=$( [ -n "$got" ] && echo 1 || echo 0 )
|
||||
else
|
||||
status=1
|
||||
fi
|
||||
if [[ "$got" == *"$expect"* ]]; then
|
||||
pass=$((pass + 1))
|
||||
else
|
||||
failed=$((failed + 1)); echo "FAIL $f (wanted: $expect)"; echo "$got" | head -5
|
||||
fi
|
||||
done
|
||||
echo "windows (wine): $pass passed, $failed failed"
|
||||
[ $failed -eq 0 ]
|
||||
Loading…
Reference in a new issue