-
Notifications
You must be signed in to change notification settings - Fork 1
/
run-scenarios
executable file
·71 lines (63 loc) · 1.3 KB
/
run-scenarios
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#! /bin/bash
# USAGE:
#
# ./run-scenarios [-b] [TEST_CASES]
#
# -b: rewrite baselines
#
# TEST_CASES defaults to tests/scenarios/*
TEST=1
root_dir=$(dirname $0)
regress_dir=$root_dir/tests/scenarios
run=$root_dir/target/release/run-scenario
if [[ $1 == '-b' ]]; then
write_bl=1
shift
fi
if [[ $# -eq 0 ]]; then
files=$regress_dir/*.txt
else
files=$(find $@ | grep -E '.txt$')
fi
cargo build --release
exit_code=0
echo
for file in $files; do
if ! [ -f $file ] ; then
echo "Can't find file '$file'"
exit 1
fi
bl=${file}.baseline
base=$(basename $file)
printf "%-40s " "${base}:"
# Diffing baselines
if [ -z $write_bl ] ; then
# Has a baseline
if [ -f $bl ] ; then
diff $bl <($run $file 2>${file}.err) > ${file}.diff
if [[ $? -eq 0 ]] ; then
printf "\e[1;32m%-6s\e[0m\n" PASSED
else
printf "\e[1;31m%-6s\e[0m\n" FAILED
exit_code=1
cat ${file}.diff
if [ -s ${file}.err ]; then
echo "-- STDERR --"
cat ${file}.err
fi
fi
rm ${file}.diff
rm ${file}.err
else
printf "\e[1;33m%-6s\e[0m\n" 'BASELINE MISSING'
fi
# Writing baselines
else
$run $file > $bl
if [[ $? -eq 0 ]] ; then
printf "\e[1;34m%-9s\e[0m\n" BASELINED
fi
fi
done
echo
exit $exit_code