This repository has been archived by the owner on Sep 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
exec-tests.sh
executable file
·72 lines (58 loc) · 1.96 KB
/
exec-tests.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env bash
# Source the common helpers script.
source scripts/common.bash
printf "${yellow}"
print_banner "Python 3"
printf "${normal}\n"
# add -s for verbose output
opt_venv='--user'
if [ ! -z ${VIRTUAL_ENV} ]; then
message_std "Virtual environment ${green}detected${normal}."
opt_venv=''
else
message_std "Virtual environment ${red}not detected${normal}."
fi
printf "\n"
execute_command_checked "./exec-reqs-install.sh > /dev/null 2>&1"
# clean up any precompiled code before the tests are executd
find . -name "__pycache__" -exec rm -rf {} \; >& /dev/null
find . -name "*.py?" -exec rm {} \; >& /dev/null
options=(
--cov-report=term
--cov-report=term-missing
--cov-report=html
--cov-report=xml
--cov=configparserenhanced
)
python3 -m pytest ${options[@]}
err=$?
printf "\n"
if [ $err != 0 ]; then
printf "${red}"
print_banner "TESTING FAILED"
printf "${normal}"
printf "\n"
exit $err
fi
# Check installation
pwd
execute_command_checked "python3 -m pip install ${opt_venv} . >& _test-install.log"
# Run the Example(s)
execute_command_checked "pushd examples"
execute_command_checked "python3 ConfigParserEnhanced-example-01.py >& _test-example-01.log"
execute_command_checked "popd"
# Check uninstaller
execute_command_checked "python3 -m pip uninstall -y configparserenhanced >& _test-uninstall.log"
# Clean up generated bytecode
if [ $err -eq 0 ]; then
execute_command "find . -name '__pycache__' -exec rm -rf {} \; > /dev/null 2>&1"
execute_command "find . -name '*.py?' -exec rm {} \; > /dev/null 2>&1"
execute_command "find . -depth 2 -name '_example-*.ini' -exec rm {} \; > /dev/null 2>&1"
execute_command "find . -maxdepth 2 -name '_test-*.log' -exec rm {} \; > /dev/null 2>&1"
execute_command "find . -maxdepth 1 -name '___*.ini' -exec rm {} \; > /dev/null 2>&1"
fi
printf "\n"
printf "${green}"
print_banner "TESTING PASSED"
printf "${normal}"
printf "\n"