This server is intended for use for Academic Classwork related Git repositories only. Projects/repositories will generally be removed after 6 months following close of the semester. Inactive repositories from previous semester are now being archived when no activity for 365 days. They are renamed and marked as 'archived'. After 90 days in that state they will be removed from the system completely.

compare_output.sh 1.25 KB
Newer Older
Jonathan Evans's avatar
Jonathan Evans committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#!/bin/bash

# If you make any changes to this script in Windows, you must
# run dos2unix on it before running. 

# Place this script in the same directory as your source
# files. In this directory there should be a `sample_input`
# directory and an `expected_output` directory, both of
# which can be found on Canvas.
# Create an empty directory called `my_output`. This can be
# done by running the command `mkdir my_output`.
# Run this script my typing `bash compare_output.sh`

# If you would like the script to compile your program, 
# uncomment the following 3 lines and change the file names
# to the correct format specified in Canvas.
# Otherwise, make sure your executable is named `a.out`
# or update the first line in the for loop.
19 20

make
Jonathan Evans's avatar
Jonathan Evans committed
21 22 23 24 25

test_files=`ls ./sample_input`
diff_files=0

for file in $test_files; do
jdev52's avatar
jdev52 committed
26
	./evanshogan_parser < ./sample_input/$file > ./my_output/$file.out
Jonathan Evans's avatar
Jonathan Evans committed
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
	
    diff_lines=`diff ./my_output/$file.out \
					./expected_output/$file.out \
					--ignore-space-change --ignore-case  | egrep -c "^<|^>"`
					
	if [ $diff_lines == 0 ]
	then
		echo $file matches.
	else
		diff_files=$((diff_files+1))
		echo $file does not match. There are $diff_lines differences.
	fi
done

echo
echo "Number of different input files: $diff_files"
echo
jdev52's avatar
jdev52 committed
44
make clean