-
Notifications
You must be signed in to change notification settings - Fork 0
/
shelltest.sh
executable file
·39 lines (36 loc) · 1.39 KB
/
shelltest.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
# !/bin/bash
shelltests_path="$(dirname $(realpath $0))/shelltests"
src_paths="$shelltests_path/src/*"
tests_path="$shelltests_path/tests/"
if [[ $1 ]]; then
src_paths="$shelltests_path/src/$1/*"
tests_path="$shelltests_path/tests/$1/*"
fi
for src_path in $src_paths
do
[ -e "$src_path" ] || continue
if [[ -d $src_path ]]; then
echo "${src_path##*/}"
nested_shelltest="${src_path}/*"
for nested_src_path in $nested_shelltest
do
nested_src_path_without_extension=${nested_src_path%%.*}
test_path=${nested_src_path_without_extension##*src/}
compile_program="stack run necklace-exe ${nested_src_path} scriptname >/dev/null 2>/dev/null"
eval "$compile_program"
run_test="shelltest ${tests_path}${test_path}.test -c | head -n -5 | sed --unbuffered -e 's/\(.*OK.*\)/\o033[32m\1\o033[39m/' -e 's/\(.*Failed.*\)/\o033[31m\1\o033[39m/'"
eval "$run_test"
done
echo " "
elif [[ -f $src_path ]]; then
src_path_without_extension=${src_path%%.*}
src_name=${src_path_without_extension##*/}
compile_program="stack run necklace-exe ${src_path} scriptname >/dev/null 2>/dev/null"
eval "$compile_program"
run_test="shelltest ${tests_path}${src_name}.test -c | head -n -5 | sed --unbuffered -e 's/\(.*OK.*\)/\o033[32m\1\o033[39m/' -e 's/\(.*Failed.*\)/\o033[31m\1\o033[39m/'"
eval "$run_test"
else
echo "Invalid path"
exit 1
fi
done