spl

systems programming language
git clone http://frotz.net/git/spl.git
Log | Files | Refs | README | LICENSE

runtest0 (1289B)


      1 #!/bin/bash
      2 
      3 ## Copyright 2020, Brian Swetland <swetland@frotz.net>
      4 ## Licensed under the Apache License, Version 2.0.
      5 
      6 src="$1"
      7 txt="$2"
      8 base="${txt%.txt}"
      9 bin="${txt%.txt}.bin"
     10 lst="${txt%.txt}.lst"
     11 log="${txt%.txt}.log"
     12 msg="${txt%.txt}.msg"
     13 gold="${src%.spl}.log"
     14 
     15 echo "RUNTEST: $src: compiling..."
     16 if build/compile0 "$src" 2> "$msg"; then
     17 	# success!
     18 	if [[ "$txt" == *"-err"* ]]; then
     19 		# but this was an error test, so...
     20 		echo "RUNTEST: $src: FAIL: compiler did not detect error"
     21 		echo "FAIL: $src" > "$txt"
     22 	else
     23 		#echo "RUNTEST: $src: running..."
     24 		if "$bin" > "$log"; then
     25 			if diff "$log" "$gold" >/dev/null ; then
     26 				echo "RUNTEST: $src: PASS"
     27 				echo "PASS: $src" > "$txt"
     28 			else
     29 				echo "RUNTEST: $src: FAIL: output differs from expected"
     30 				diff "$log" "$gold" | head
     31 				echo "FAIL: %src" > "$txt"
     32 			fi
     33 		else
     34 			echo "RUNTEST: $src: FAIL: emulator crashed"
     35 			echo "FAIL: %src" > "$txt"
     36 		fi
     37 	fi
     38 else
     39 	if [[ $? > 127 ]]; then
     40 		echo "RUNTEST: $src: FAIL: compiler crashed"
     41 		echo "FAIL: $src" > "$txt"
     42 		cat "$msg"
     43 	# failure
     44 	elif [[ "$txt" == *"-err"* ]]; then
     45 		# but this was an error test, so...
     46 		echo "RUNTEST: $src: PASS"
     47 		echo "PASS: $src" > "$txt"
     48 	else
     49 		echo "RUNTEST: $src: FAIL: compiler error"
     50 		echo "FAIL: $src" > "$txt"
     51 		cat "$msg"
     52 	fi
     53 fi
     54