Skip to content

Commit f74349d

Browse files
ssbarneagaborbernat
authored andcommitted
travis: enable use of test_activate.sh (#1087)
1 parent c185fc6 commit f74349d

File tree

4 files changed

+34
-9
lines changed

4 files changed

+34
-9
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ docs/_build
88
.eggs
99
.tox
1010
.cache
11-
tests/test_activate_actual.output
11+
/tests/test_activate_output.actual
12+
/tests/test_activate_output.expected

.travis.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,18 @@ install:
2525
- ./bin/rebuild-script.py && git diff-files --quiet || { >&2 echo "Code submitted without running ./bin/rebuild-script.py first."; exit 1; }
2626
- pip install tox
2727

28-
script: tox
28+
script:
29+
- ./bin/rebuild-script.py
30+
- tox
31+
- ./tests/test_activate.sh
32+
- |-
33+
function check_status() {
34+
if ! git diff-index --quiet --ignore-submodules=all HEAD --; then
35+
echo 'Uncommitted changes detected:';
36+
git diff-index HEAD --;
37+
return 1;
38+
fi;
39+
}
2940
3041
sudo: false # Use container based builds
3142

tests/test_activate.sh

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,16 @@ rm -rf ${TESTENV}
1010

1111
echo "$0: Creating virtualenv ${TESTENV}..." 1>&2
1212

13-
${VIRTUALENV} ${TESTENV} | tee ${ROOT}/tests/test_activate_output.actual
13+
PY_BLEND=$(python -c "import sys; print('pypy' if '__pypy__' in sys.builtin_module_names else 'python');")
14+
cat >${ROOT}/tests/test_activate_output.expected <<EOL
15+
New ${PY_BLEND} executable in /tmp/test_virtualenv_activate.venv/bin/python
16+
Installing setuptools, pip, wheel...done.
17+
EOL
18+
19+
# "Path not in prefix" warning is not really an error, being expected under pypy
20+
# > Path not in prefix '/home/travis/virtualenv/pypy2.7-5.8.0/include' '/opt/python/pypy2.7-5.8.0'
21+
22+
${VIRTUALENV} ${TESTENV} 2>&1 | sed '/^++\|^Also creating executable in\|^Using real prefix\|^Path not in prefix/d' | tee ${ROOT}/tests/test_activate_output.actual
1423
if ! diff ${ROOT}/tests/test_activate_output.expected ${ROOT}/tests/test_activate_output.actual; then
1524
echo "$0: Failed to get expected output from ${VIRTUALENV}!" 1>&2
1625
exit 1
@@ -61,10 +70,17 @@ echo "$0: Output of \$(which easy_install) is OK." 1>&2
6170
echo "$0: Executing a simple Python program..." 1>&2
6271

6372
TESTENV=${TESTENV} python <<__END__
64-
import os, sys
73+
import os
74+
import platform
75+
import sys
6576
66-
expected_site_packages = os.path.join(os.environ['TESTENV'], 'lib','python%s' % sys.version[:3], 'site-packages')
67-
site_packages = os.path.join(os.environ['VIRTUAL_ENV'], 'lib', 'python%s' % sys.version[:3], 'site-packages')
77+
if 'PyPy' == platform.python_implementation():
78+
expected_site_packages = os.path.join(os.environ['TESTENV'], 'site-packages')
79+
site_packages = os.path.join(os.environ['VIRTUAL_ENV'], 'site-packages')
80+
81+
else:
82+
expected_site_packages = os.path.join(os.environ['TESTENV'], 'lib','python%s' % sys.version[:3], 'site-packages')
83+
site_packages = os.path.join(os.environ['VIRTUAL_ENV'], 'lib', 'python%s' % sys.version[:3], 'site-packages')
6884
6985
assert site_packages == expected_site_packages, 'site_packages did not have expected value; actual value: %r' % site_packages
7086
@@ -93,4 +109,3 @@ echo "$0: Deactivated ${TESTENV}." 1>&2
93109
echo "$0: OK!" 1>&2
94110

95111
rm -rf ${TESTENV}
96-

tests/test_activate_output.expected

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)