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