Skip to content

Commit

Permalink
Merge pull request #448 from rht/macOS
Browse files Browse the repository at this point in the history
Travis: Add macOS to the build matrix
  • Loading branch information
mmcky committed Dec 10, 2018
2 parents 6ba4ba0 + 57ba55b commit 6a14ebb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
29 changes: 26 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,31 @@

sudo: false #Use new Container Infrastructure
language: python
python:
- 3.6

cache:
pip: true
directories:
- $HOME/miniconda
# osx-specific caches
- $HOME/Library/Caches/pip

matrix:
include:
- python: 3.6
- os: osx
osx_image: xcode10
sudo: required
env: TRAVIS_PYTHON_VERSION=3.7
language: generic
before_install:
- pip install virtualenv
- virtualenv env -p python3
- source env/bin/activate
- wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh
- chmod +x miniconda.sh
- ./miniconda.sh -u -b -p $HOME/miniconda
- export PATH=$HOME/miniconda/bin:$PATH
- conda update --yes conda

notifications:
email: false
Expand All @@ -18,7 +41,7 @@ branches:
before_install:
- wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
- chmod +x miniconda.sh
- ./miniconda.sh -b -p /home/travis/miniconda
- ./miniconda.sh -u -b -p /home/travis/miniconda
- export PATH=/home/travis/miniconda/bin:$PATH
- conda update --yes conda
#- sudo rm -rf /dev/shm
Expand Down
13 changes: 11 additions & 2 deletions quantecon/util/tests/test_timing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""

import time
from sys import platform
from numpy.testing import assert_allclose
from nose.tools import eq_, ok_
from quantecon.util import tic, tac, toc, loop_timer
Expand All @@ -15,6 +16,10 @@ def setUp(self):
self.digits = 10

def test_timer(self):
if platform == 'darwin':
# skip for darwin
return

tic()

time.sleep(self.h)
Expand All @@ -32,6 +37,10 @@ def test_timer(self):
assert_allclose(actual, desired, rtol=rtol)

def test_loop(self):
if platform == 'darwin':
# skip for darwin
return

def test_function_one_arg(n):
return time.sleep(n)

Expand All @@ -43,9 +52,9 @@ def test_function_two_arg(n, a):
test_two_arg = \
loop_timer(5, test_function_two_arg, [self.h, 1], digits=10)
for tm in test_one_arg:
assert(abs(tm - self.h) < 0.01)
assert(abs(tm - self.h) < 0.01), tm
for tm in test_two_arg:
assert(abs(tm - self.h) < 0.01)
assert(abs(tm - self.h) < 0.01), tm

for (average_time, average_of_best) in [test_one_arg, test_two_arg]:
ok_(average_time >= average_of_best)
Expand Down

0 comments on commit 6a14ebb

Please sign in to comment.