compiler

Unnamed Compiled Systems Language Project
git clone http://frotz.net/git/compiler.git
Log | Files | Refs

runtest.sh (1264B)


      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 bin="${txt%.txt}.bin"
      9 lst="${txt%.txt}.lst"
     10 log="${txt%.txt}.log"
     11 msg="${txt%.txt}.msg"
     12 gold="${src%.src}.log"
     13 
     14 #echo "RUNTEST: $src: compiling..."
     15 if bin/cold -o "$bin" -l "$lst" "$src" 2> "$msg"; then
     16 	# success!
     17 	if [[ "$txt" == *"-err"* ]]; then
     18 		# but this was an error test, so...
     19 		echo "RUNTEST: $src: FAIL: compiler did not detect error"
     20 		echo "FAIL: $src" > "$txt"
     21 	else
     22 		#echo "RUNTEST: $src: running..."
     23 		if bin/r5e "$bin" > "$log"; then
     24 			if diff "$log" "$gold" >/dev/null ; then
     25 				echo "RUNTEST: $src: PASS"
     26 				echo "PASS: $src" > "$txt"
     27 			else
     28 				echo "RUNTEST: $src: FAIL: output differs from expected"
     29 				diff "$log" "$gold" | head
     30 				echo "FAIL: %src" > "$txt"
     31 			fi
     32 		else
     33 			echo "RUNTEST: $src: FAIL: emulator crashed"
     34 			echo "FAIL: %src" > "$txt"
     35 		fi
     36 	fi
     37 else
     38 	if [[ $? > 127 ]]; then
     39 		echo "RUNTEST: $src: FAIL: compiler crashed"
     40 		cat "$msg"
     41 	# failure
     42 	elif [[ "$txt" == *"-err"* ]]; then
     43 		# but this was an error test, so...
     44 		echo "RUNTEST: $src: PASS"
     45 		echo "PASS: $src" > "$txt"
     46 	else
     47 		echo "RUNTEST: $src: FAIL: compiler error"
     48 		echo "FAIL: $src" > "$txt"
     49 		cat "$msg"
     50 	fi
     51 fi
     52