compiler

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

runtest2.sh (1353B)


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