summaryrefslogtreecommitdiff
path: root/run_tests.sh
blob: 578392a507d52b63f3d77fa30a3bc8fe80e42fb9 (plain)
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
#!/usr/bin/env bash

testdir=test/bin

red='\e[0;31m'
yellow='\e[0;33m'
green='\e[0;32m'

reset='\e[0m'

lprintf() {
    local fmt="$1"
    local text="$2"
    [[ -x "$text" ]] && return
    while IFS= read -r line; do
        printf "$fmt" "$line"
    done <<< "$text"
}

echo "  ╓──────────╖"
echo "╔═╣ leo test ╠════════════════════════════════════"
echo "║ ╙──────────╜"

for testbin in $testdir/*; do
    if [[ -x "$testbin" ]]; then
        echo -ne "╟─ running ${yellow}${testbin}${reset}:\t"
        output=$(./$testbin 2>&1) # TODO save output and display at end
        if [[ $? -eq 0 ]]; then
            echo -e "${green}passed${reset}"
        else
            echo -e "${red}failed${reset}"
            lprintf "║    %s\n" "$output"
        fi
    fi
done

echo "║"
echo "╚═════════════════════════════════════════════════"