-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-utils.sh
More file actions
executable file
·80 lines (67 loc) · 1.13 KB
/
test-utils.sh
File metadata and controls
executable file
·80 lines (67 loc) · 1.13 KB
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
72
73
74
75
76
77
78
79
80
#!/bin/sh
export NO_COLOR='\033[0m'
export BOLD='\033[1m'
export RED='\033[31m'
export GREEN='\033[32m'
echo_green()
{
echo "${GREEN}${BOLD}$@${NO_COLOR}"
}
echo_red()
{
echo "${RED}${BOLD}$@${NO_COLOR}"
}
# Remove local path prefix
remove_path_prefix()
{
if test -z "$LOCAL_PATH_PREFIX"
then
export LOCAL_PATH_PREFIX=`cd ../../../..; echo $PWD`
fi
sed "s;$LOCAL_PATH_PREFIX;[ local path prefix ];g"
}
# Remove local author
remove_author()
{
sed 's;^// \\author .*;// \\author [user name];'
}
# Run a test
run()
{
printf '%-74s' $1
$@
status=$?
if test $status -eq 0
then
echo_green PASSED
else
echo_red FAILED
fi
return $status
}
# Run a test suite
run_suite()
{
tests=$@
num_passed=0
num_failed=0
{
for t in $tests
do
if run $t
then
num_passed=`expr $num_passed + 1`
else
num_failed=`expr $num_failed + 1`
fi
done
printf "$num_passed passed"
if test $num_failed -gt 0
then
printf ", $num_failed failed"
fi
echo
echo $num_failed > num_failed.txt
} 2>&1 | tee test-output.txt
exit `cat num_failed.txt`
}