-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_examples.sh
executable file
·50 lines (40 loc) · 1.25 KB
/
run_examples.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
#!/usr/bin/env bash
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color
interpreter=lagger
all_good=$(find examples/good -type f -name "*.lagger" | wc -l)
all_bad=$(find examples/bad -type f -name "*.lagger" | wc -l)
all=$((all_good + all_bad))
make
echo -e " \n${YELLOW}== Running examples. ==${NC}"
echo -e " \n${YELLOW}== Running good examples. All should pass. ==${NC}\n"
passed_good=0
for example in examples/good/*.lagger; do
echo -e "${YELLOW}$example:${NC}\n"
./$interpreter "$example"
if [[ $? -eq 0 ]]; then
((passed_good++))
echo -e "${GREEN}\n-- OK --${NC}\n\n"
else
echo -e "${RED}\n-- WA --${NC}\n\n"
fi
done
echo -e "\n${YELLOW}== Running bad examples. All should fail. ==${NC}\n"
passed_bad=0
for example in examples/bad/*.lagger; do
echo -e "${YELLOW}$example:${NC}\n"
./$interpreter "$example"
if [[ $? -eq 1 ]]; then
((passed_bad++))
echo -e "${GREEN}\n-- OK --${NC}\n\n"
else
echo -e "${RED}\n-- WA --${NC}\n\n"
fi
done
passed_all=$((passed_good + passed_bad))
echo -e "${YELLOW}== Summary: ==${NC}\n"
echo -e "Good passed: ${GREEN}$passed_good / $all_good${NC}"
echo -e "Bad passed: ${GREEN}$passed_bad / $all_bad${NC}"
echo -e "All passed: ${GREEN}$passed_all / $all${NC}"