~lbnz/xr0

6c02b36a163a52cbfd379fb4638c2883fc8dbe06 — Claude Betz a month ago 8badd6f
fix: testrunner file-based output comparison

issue: https://github.com/xr0-org/xr0/issues/40
2 files changed, 10 insertions(+), 6 deletions(-)

M src/ast/topological.c
M tests/run
M src/ast/topological.c => src/ast/topological.c +1 -1
@@ 48,7 48,7 @@ topological_order(char *fname, struct externals *ext)
	/* no more nodes with incoming edges */
	if (order->n != indegrees->n) {
		/* TODO: pass up error */
		fprintf(stderr, "cycle detected in graph");		
		fprintf(stderr, "cycle detected in graph\n");
		exit(EXIT_FAILURE);
	}


M tests/run => tests/run +9 -5
@@ 26,16 26,17 @@ do
	folder=$(dirname "$f")

	printf "%-${length}s ..." "$f"
	tempfile="${f}.temp"
	if [ "$folder" == *"$topological_folder"* ]
	then
		if [[ "$f" == *"verification"* ]]
		then
			output=$($XR0 -x main -I $libx -v $f 2>&1 >/dev/null)
			output=$($XR0 -x main -I $libx -v $f > "$tempfile" 2>&1)
		else
			output=$($XR0 -t main -I $libx $f 2>&1 >/dev/null)
			output=$($XR0 -t main -I $libx $f > "$tempfile" 2>&1)
		fi
	else 
		output=$($XR0 -I $libx $f 2>&1 >/dev/null)
		output=$($XR0 -I $libx $f > "$tempfile" 2>&1)
	fi

	# cases where we have an expected output to compare with


@@ 43,8 44,9 @@ do
	then
		expected_file="${f}.${expected_suffix}"
		
		echo "$output" | diff - $expected_file
		if [[ $? -eq 0 ]]
		output_file=$(<$tempfile)
		echo "$output_file" | diff - $expected_file
		if diff -q "$tempfile" "$expected_file" >/dev/null;
		then
			npass=$((npass+1))
			printf "$pass"


@@ 59,6 61,8 @@ do
			printf "$pass"
		fi
	fi

	rm $tempfile
done

nfail=$((ntests-npass))