-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·52 lines (41 loc) · 1.01 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# Runs input(s) from input/, saves result to results/ and compares to file from output/
if [ ! "$#" -gt 0 ]
then
echo "Expecting list of test case names or 'all'"
exit 1
fi
arr=(input/*.in)
IFS=$'\n'
mkdir -p "./results/"
run_individual_test () {
test_case="input/$1.in"
echo "Running test $test_case"
result_file="results/$1.out"
# run and output to res_file
xargs ./target/release/findw < input/$1.in > $result_file
correct_output_file="output/$1.out"
diff -q <(sort $result_file) <(sort $correct_output_file)
if [ $? -ne 0 ];
then
echo "FAILED: $1.in"
diff $result_file $correct_output_file
fi
}
# build for release
cargo b --release
printf "Built for release; running tests\n"
if [[ "$1" == "all" ]]; then
test_case_name=$(basename $file_name .in)
for file_name in ${arr[*]}; do
test_case_name=$(basename $file_name .in)
run_individual_test $test_case_name
printf ""
done
else
for case in "$@"
do
run_individual_test "$case"
done
fi
unset IFS