-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·50 lines (40 loc) · 1.08 KB
/
test.sh
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
#!/bin/bash
errors=0
# COLORS
CC='\033[0m'
CR='\033[0;31m'
CG='\033[0;32m'
function log() {
echo "[*] $1"
}
function err() {
echo "[-] $1"
errors="$((errors + 1))"
}
function run_args() {
local name
local arg
name="$1"
arg="$2"
log "running test '$name' ..."
./bash-to-fish.sh --debug test/"$name"/sample.sh || { err "failed to compile"; return; }
./bash-to-fish.sh test/"$name"/sample.sh test/"$name"/out.fish || { err "failed to compile"; return; }
fish test/"$name"/out.fish "$arg" || { err "failed to run"; return; }
}
function run() {
local name
name="$1"
log "running test '$name' ..."
./bash-to-fish.sh --debug test/"$name"/sample.sh || { err "failed to compile"; return; }
./bash-to-fish.sh test/"$name"/sample.sh test/"$name"/out.fish || { err "failed to compile"; return; }
fish test/"$name"/out.fish || { err "failed to run"; return; }
}
run_args args --help
run func
echo ""
if [ "$errors" != "0" ]
then
echo -e "[${CR}-${CC}] failed with $errors errors."
else
echo -e "[${CG}+${CC}] test successful."
fi