1 | #!/usr/bin/env bash |
2 |
|
3 | success() { |
4 | echo -e "\033[92m\033[1m\033[7m${@}\033[0m" |
5 | } |
6 |
|
7 | success_lite() { |
8 | echo -e "\033[92m${@}\033[0m" |
9 | } |
10 |
|
11 | error() { |
12 | echo -e "\033[91m\033[7m\033[1m${@}\033[0m" |
13 | } |
14 |
|
15 | warn() { |
16 | echo -e "\033[93m\033[1m\033[7m${@}\033[0m" |
17 | } |
18 |
|
19 | warn_lite() { |
20 | echo -e "\033[93m${@}\033[0m" |
21 | } |
22 |
|
23 | exit_on_error() { |
24 | if [ $1 -ne 0 ] |
25 | then |
26 | error "Error in test. Exiting..." |
27 | exit $1 |
28 | else |
29 | success_lite "Success in test." |
30 | fi |
31 | } |
32 |
|
33 | handle() { |
34 | $1 |
35 | exit_on_error $? |
36 | } |
37 |
|
38 | help() { |
39 | echo "Usage: ./test [help] [c_unit]" |
40 | } |
41 |
|
42 | c_unit() { |
43 | warn "Running C unit test chain" |
44 | echo |
45 |
|
46 | # Compile C unit tests |
47 | warn_lite "Making C header unit test" |
48 | handle make c_unit |
49 | echo |
50 |
|
51 | warn_lite "Running C header unit test" |
52 | handle bin/c |
53 | echo |
54 | |
55 | success "Finished" |
56 | } |
57 |
|
58 | for test in "$@" |
59 | do |
60 | $test |
61 | done |
62 |
|
63 | echo -e "finished: ${SECONDS} seconds" |
64 |
|