-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest
executable file
·64 lines (55 loc) · 1.84 KB
/
Test
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
#!/usr/bin/env bash
set -e -o pipefail
trap 'e=$?; echo 1>&2 "FAILED!"; exit $e' 0
clean=false
unittest_only=false
while true; do case "$1" in
-C) shift; clean=true;;
-U) shift; unittest_only=true;;
*) break;;
esac; done
basedir="$(cd "$(dirname "$BASH_SOURCE")" && pwd -P)"
cd "$basedir"
$clean && rm -rf .build
# We default to python2 for testing since this should run anywhere.
# You may add your own .python link to the interpreter of your choice.
[[ -L .python ]] || {
echo "No .python link found: setting test interpreter to python2."
py=$(type -P python2) || {
echo 1>&2 "ERROR: Failed to find python2"; exit 1; }
echo ".python → $py"
ln -s "$py" .python
}
source pactivate -q
echo ===== Unit Tests
PYTHONPATH="$basedir/bin" \
HOME="${basedir}/t/home" \
pytest -q "$@" t/t[0-9]*.py
$unittest_only && { trap '' 0; exit 0; }
echo ===== Functional Tests
export HOME="${basedir}/t/home"
export PATH="${basedir}/bin:$PATH"
. ${basedir}/dot/bashrc.inb4
echo '----- without subpath'
diff -u <<. - <(cpd -l a _cpd_p 2>&1)
$HOME/_cpd_p1/abc
$HOME/_cpd_p2/abc
.
echo '----- with subpath'
diff -u <<. - <(cpd -l _cpd a /[dg])
$HOME/_cpd_p1/abc/def
$HOME/_cpd_p1/abc/ghi
$HOME/_cpd_q1/abc/ghi
.
echo '----- graceful pipeline fail'
# Test that we gracefully handle a pipeline process reading our output
# terminating before reading it all (IOError: [Errno 32] Broken pipe).
# We rely on /usr/share/* being present and having a lot of files under
# it to make cpd generate more than 4K of output so we can trigger
# the problem.
cpd -l --project-paths-file t/long-project-paths \? | head -1 > /dev/null
echo '----- lint for 2- vs. 3-isms'
[[ $(python --version 2>&1) = 'Python 2'* ]] \
&& python -3 -Qwarnall -W error -W ignore::DeprecationWarning \
${basedir}/bin/cpd.py >/dev/null
trap '' 0