forked from Chaoyun8888/dotfiles-2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.sh
executable file
·103 lines (89 loc) · 2.45 KB
/
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/sh
# author: deadc0de6 (https://github.com/deadc0de6)
# Copyright (c) 2017, deadc0de6
# stop on first error
#set -ev
set -e
# PEP8 tests
which pycodestyle >/dev/null 2>&1
[ "$?" != "0" ] && echo "Install pycodestyle" && exit 1
echo "testing with pycodestyle"
pycodestyle --ignore=W503,W504,W605 dotdrop/
pycodestyle tests/
pycodestyle scripts/
# pyflakes tests
echo "testing with pyflakes"
pyflakes dotdrop/
pyflakes tests/
# retrieve the nosetests binary
nosebin="nosetests"
which ${nosebin} >/dev/null 2>&1
[ "$?" != "0" ] && nosebin="nosetests3"
which ${nosebin} >/dev/null 2>&1
[ "$?" != "0" ] && echo "Install nosetests" && exit 1
# do not print debugs when running tests (faster)
export DOTDROP_FORCE_NODEBUG=yes
# coverage file location
cur=`dirname $(readlink -f "${0}")`
workers=${DOTDROP_WORKERS}
if [ ! -z ${workers} ]; then
unset DOTDROP_WORKERS
echo "DISABLE workers"
fi
# execute tests with coverage
if [ -z ${GITHUB_WORKFLOW} ]; then
## local
export COVERAGE_FILE=
PYTHONPATH="dotdrop" ${nosebin} -s --processes=-1 --with-coverage --cover-package=dotdrop
else
## CI/CD
export COVERAGE_FILE="${cur}/.coverage"
PYTHONPATH="dotdrop" ${nosebin} --processes=0 --with-coverage --cover-package=dotdrop
fi
#PYTHONPATH="dotdrop" python3 -m pytest tests
# enable debug logs
export DOTDROP_DEBUG=yes
unset DOTDROP_FORCE_NODEBUG
# do not print debugs when running tests (faster)
#export DOTDROP_FORCE_NODEBUG=yes
export DOTDROP_WORKDIR=/tmp/dotdrop-tests-workdir
if [ ! -z ${workers} ]; then
DOTDROP_WORKERS=${workers}
echo "ENABLE workers: ${workers}"
fi
# run bash tests
if [ -z ${GITHUB_WORKFLOW} ]; then
## local
export COVERAGE_FILE=
tests-ng/tests-launcher.py
else
## CI/CD
export COVERAGE_FILE="${cur}/.coverage"
tests-ng/tests-launcher.py 1
fi
## test the doc with remark
## https://github.com/remarkjs/remark-validate-links
set +e
which remark >/dev/null 2>&1
r="$?"
set -e
if [ "$r" != "0" ]; then
echo "[WARNING] install \"remark\" to test the doc"
else
remark -f -u validate-links docs/
remark -f -u validate-links *.md
fi
### test the doc with markdown-link-check
### https://github.com/tcort/markdown-link-check
#set +e
#which markdown-link-check >/dev/null 2>&1
#r="$?"
#set -e
#if [ "$r" != "0" ]; then
# echo "[WARNING] install \"markdown-link-check\" to test the doc"
#else
# for i in `find docs -iname '*.md'`; do markdown-link-check $i; done
# markdown-link-check README.md
#fi
## done
echo "All test finished successfully"