diff --git a/.github/workflows/lisp.yaml b/.github/workflows/lisp.yaml index 0f4dcb0..49c0fbb 100644 --- a/.github/workflows/lisp.yaml +++ b/.github/workflows/lisp.yaml @@ -11,17 +11,10 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: [ "linux/amd64", "linux/386" ] - - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: '>=1.17' + - name: Set up dependencies + run: sudo apt update && sudo apt install -y qemu-system-x86 nasm - name: Test - run: ./test -DHEADLESS lisp/tester.asm + run: script -q -e -c "./test -DHEADLESS lisp/tester.asm" diff --git a/test b/test index 9d92f87..fb81d64 100755 --- a/test +++ b/test @@ -5,6 +5,10 @@ if [ "$#" -eq 0 ]; then exit 1 fi +if [ -z "$QEMU" ]; then + QEMU="qemu-system-x86_64" +fi + file=${@: -1} name="${file%%.*}" binfile="bin/$name.bin" @@ -14,9 +18,27 @@ if [ "$1" = "-DHEADLESS" ]; then HEADLESS_ARGS="-display none" fi +PID=$$ +compile() { + nasm $file -f bin -o $binfile -DDEBUGCON ${@:2:$(($#-2))} && \ + $QEMU $HEADLESS_ARGS -debugcon stdio -drive file=$binfile,format=raw,if=ide + ERR=$? + if [ $ERR -ne 0 ]; then + echo "Exit code: $ERR" + kill $PID + sleep 1 + fi + return $ERR +} + mkdir -p `dirname $binfile` -OUTPUT=$(nasm $file -f bin -o $binfile -DDEBUGCON ${@:1:$(($#-1))} && \ - qemu-system-x86_64 $HEADLESS_ARGS -debugcon stdio -drive file=$binfile,format=raw,if=ide | tee /dev/tty) +OUTPUT=$(compile ERROR $@ | tee /dev/tty) + +exit $ERROR + +if [ $ERROR -ne 0 ]; then + exit $ERROR +fi if grep -q "FAIL" - <<< "$OUTPUT"; then exit 1