Enable unit tests on OS X (#4697)

* Add OS X test

* Fix apache tests

* Use absolute path first so that certbot works with non-standard $PATH

Some tests use a fake $PATH, which prevents invoking `sw_vers`

* Also test Python 3 on Mac

* Set ulimit to fix "Too many open files"
This commit is contained in:
Yen Chi Hsuan
2017-06-01 09:03:54 -07:00
committed by Brad Warren
parent 6f98987c12
commit c9e9879ad9
3 changed files with 37 additions and 9 deletions
+10 -1
View File
@@ -5,7 +5,10 @@ cache:
- $HOME/.cache/pip
before_install:
- 'dpkg -s libaugeas0'
- '[ $TRAVIS_OS_NAME == linux ] && dpkg -s libaugeas0 || brew install augeas python3'
before_script:
- 'if [ $TRAVIS_OS_NAME = osx ] ; then ulimit -n 1024 ; fi'
# using separate envs with different TOXENVs creates 4x1 Travis build
# matrix, which allows us to clearly distinguish which component under
@@ -112,6 +115,12 @@ matrix:
services: docker
- python: "2.7"
env: TOXENV=nginxroundtrip
- language: generic
env: TOXENV=py27
os: osx
- language: generic
env: TOXENV=py36
os: osx
# Only build pushes to the master branch, PRs, and branches beginning with
+14 -3
View File
@@ -275,9 +275,20 @@ def setup_ssl_options(config_dir, src, dest): # pragma: no cover
def dir_setup(test_dir, pkg): # pragma: no cover
"""Setup the directories necessary for the configurator."""
temp_dir = tempfile.mkdtemp("temp")
config_dir = tempfile.mkdtemp("config")
work_dir = tempfile.mkdtemp("work")
def expanded_tempdir(prefix):
"""Return the real path of a temp directory with the specified prefix
Some plugins rely on real paths of symlinks for working correctly. For
example, certbot-apache uses real paths of configuration files to tell
a virtual host from another. On systems where TMP itself is a symbolic
link, (ex: OS X) such plugins will be confused. This function prevents
such a case.
"""
return os.path.realpath(tempfile.mkdtemp(prefix))
temp_dir = expanded_tempdir("temp")
config_dir = expanded_tempdir("config")
work_dir = expanded_tempdir("work")
os.chmod(temp_dir, constants.CONFIG_DIRS_MODE)
os.chmod(config_dir, constants.CONFIG_DIRS_MODE)
+13 -5
View File
@@ -427,11 +427,19 @@ def get_python_os_info():
if info[1]:
os_ver = info[1]
elif os_type.startswith('darwin'):
os_ver = subprocess.Popen(
["sw_vers", "-productVersion"],
stdout=subprocess.PIPE,
universal_newlines=True,
).communicate()[0].rstrip('\n')
try:
proc = subprocess.Popen(
["/usr/bin/sw_vers", "-productVersion"],
stdout=subprocess.PIPE,
universal_newlines=True,
)
except OSError:
proc = subprocess.Popen(
["sw_vers", "-productVersion"],
stdout=subprocess.PIPE,
universal_newlines=True,
)
os_ver = proc.communicate()[0].rstrip('\n')
elif os_type.startswith('freebsd'):
# eg "9.3-RC3-p1"
os_ver = os_ver.partition("-")[0]