Skip to content

Commit 9c6426e

Browse files
author
Guillaume LODI
committed
Changed colors
1 parent 01d2d95 commit 9c6426e

File tree

1 file changed

+29
-14
lines changed

1 file changed

+29
-14
lines changed

lemin/lemin.sh

+29-14
Original file line numberDiff line numberDiff line change
@@ -27,40 +27,51 @@ testmap () {
2727
if [ "$got" -eq "$estimated" ]; then
2828
printf "${C_GRN}Perfect${C_RES}\n"
2929
elif [ "$got" -lt "$estimated" ]; then
30-
printf "${C_MAG}Awesome 😎${C_RES} (diff %d)\n" `echo "$got" - "$estimated" | bc`
30+
printf "${C_MAG}Awesome 😎 ${C_RES} (%+d)\n" `echo "$got" - "$estimated" | bc`
3131
elif [ "$got" -lt "`echo \"$estimated + 4\" | bc`" ]; then
32-
printf "${C_GRN}Great${C_RES} (diff %d)\n" `echo "$got" - "$estimated" | bc`
32+
printf "${C_GRN}Great ${C_RES} (%+d)\n" `echo "$got" - "$estimated" | bc`
33+
elif [ "$got" -lt "`echo \"$estimated + 11\" | bc`" ]; then
34+
printf "${C_YEL}Ok ${C_RES} (%+d)\n" `echo "$got" - "$estimated" | bc`
35+
elif [ "$got" -lt "`echo \"$estimated + 16\" | bc`" ]; then
36+
printf "${C_YEL}Warning ${C_RES} (%+d)\n" `echo "$got" - "$estimated" | bc`
3337
else
34-
printf "${C_YEL}Warning${C_RES} (diff %d)\n" `echo "$got" - "$estimated" | bc`
38+
printf "${C_RED}Error ${C_RES} (%+d)\n" `echo "$got" - "$estimated" | bc`
3539
fi
3640
done
3741
}
3842

43+
# $1 must be name prefix, $2 must be generator arg
44+
generateallmaps () {
45+
rm -r "$BASE/maps"
46+
mkdir -p "$BASE/maps"
47+
printinfo "Creating all maps with generator. Please wait, this can take a while..."
48+
generatemap "flowone" "--flow-one" &
49+
generatemap "flowten" "--flow-ten" &
50+
generatemap "flowthousand" "--flow-thousand" &
51+
generatemap "big" "--big" &
52+
generatemap "bigsup" "--big-superposition" &
53+
wait
54+
echo
55+
}
56+
3957
# $1 must be name prefix, $2 must be generator arg
4058
generatemap () {
41-
mkdir -p $BASE/maps
42-
for f in {1..15}
59+
for f in {1..30}
4360
do
4461
printf "${C_GRY}.${C_RES}"
45-
./$BASE/generator $2 > "$BASE/maps/$1$(printf '%02d' $f)"
62+
./$BASE/generator "$2" > "$BASE/maps/$1$(printf '%02d' $f)"
4663
sleep 1
4764
done
48-
echo
4965
}
5066

5167
# $1 must be name prefix, $2 must be generator arg
5268
runtest () {
5369
printtest "$2"
5470
printinfo "This test will:
55-
- generate 15 maps with $2 argument,
56-
- run lem-in for each map and count lines of output
71+
- run lem-in for each '$2' map and count lines of output
5772
- show difference between output and what generator expect."
58-
if [ "$3" -eq 1 ]; then
59-
printinfo "Creating 15 maps $2 with generator"
60-
generatemap "$1" "$2"
61-
fi
6273
waitkeypress
63-
printinfo "Running lem-in 15 times in $2 map"
74+
printinfo "Running lem-in for maps '$2'"
6475
testmap "$1"
6576
}
6677

@@ -75,6 +86,10 @@ if [ -d "$BASE/maps" ]; then
7586
fi
7687
fi
7788

89+
if [ "$generate" -eq 1 ]; then
90+
generateallmaps
91+
fi
92+
7893
runtest "flowone" "--flow-one" "$generate"
7994
runtest "flowten" "--flow-ten" "$generate"
8095
runtest "flowthousand" "--flow-thousand" "$generate"

0 commit comments

Comments
 (0)