Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #124 from kiryx/travis_python_test
Browse files Browse the repository at this point in the history
Added Python tests to travis CI
  • Loading branch information
Krzysztof Nowak committed Mar 12, 2015
2 parents d8dbcd6 + 0cd3d0a commit dd8ed7b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
23 changes: 12 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: cpp
compiler:
compiler:
# - gcc
- clang

Expand All @@ -18,7 +18,7 @@ before_install:
- if [ "$CXX" == "clang++" ]; then sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test; fi
- if [ "$CXX" == "clang++" ]; then sudo add-apt-repository --yes ppa:h-rayflood/llvm; fi
- if [ "$CXX" == "clang++" ]; then sudo apt-get -qq update; fi
- if [ "$CXX" == "clang++" ]; then sudo apt-get -qq install libstdc++-4.8-dev clang-3.4; fi
- if [ "$CXX" == "clang++" ]; then sudo apt-get -qq install libstdc++-4.8-dev clang-3.4; fi
- if [ "$CXX" == "clang++" ]; then export CXX="clang++-3.4"; fi
- if [ "$CXX" == "clang++" ]; then export CC= "clang++-3.4"; fi

Expand All @@ -36,14 +36,15 @@ install:
- export BOOST_ROOT=$(pwd)/boost

script:
- mkdir build
- cd build
- cmake .. -DBUILD_PYGMO="ON" -DENABLE_TESTS="ON" -DPYTHON_MODULES_DIR="~/local/python" -DCMAKE_INSTALL_PREFIX="~/local"
- make -j4
- make test
- make install
- mkdir build
- cd build
- cmake .. -DBUILD_PYGMO="ON" -DENABLE_TESTS="ON" -DPYTHON_MODULES_DIR="~/local/python" -DCMAKE_INSTALL_PREFIX="~/local"
- make -j4
- make test
- make install
- export PYTHONPATH=~/local/python
- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/local/lib:${PWD%/build}/boost/lib
- python -c "from PyGMO import test; test.run_full_test_suite()"

after_success:
- export PYTHONPATH=~/local/python
- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/local/lib:~/build/esa/pagmo/boost/lib
- python -c "import PyGMO; print(PyGMO.__version__)"
- python -c "import PyGMO; print(PyGMO.__version__)"
13 changes: 11 additions & 2 deletions PyGMO/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,20 @@
class _serialization_test(_ut.TestCase):

def test_pickle(self):
from PyGMO import archipelago, island_list, problem_list, algorithm_list, problem, algorithm
from PyGMO import archipelago, island_list, problem_list, algorithm_list, problem
import pickle
from copy import deepcopy
# We remove some problems that cannot be constructed without external
# txt data files
prob_list = deepcopy(problem_list)
prob_list.remove(problem.cec2013)

# Remove trajectory problems if PyKEP is not installed
try:
import PyKEP
except ImportError:
prob_list.remove(problem.py_pl2pl)

print('')
for isl in island_list:
for prob in prob_list:
Expand Down Expand Up @@ -114,6 +121,7 @@ def run_island_torture_test_suite():

def run_full_test_suite():
"""Run the complete test suite for PyGMO."""
import sys
from PyGMO import test
from PyGMO.test._hypervolume_tests import get_hv_suite
from PyGMO.test._topology_tests import get_topology_test_suite
Expand All @@ -125,7 +133,8 @@ def run_full_test_suite():
suite.addTests(get_topology_test_suite())
suite.addTests(get_archipelago_test_suite())

_ut.TextTestRunner(verbosity=2).run(suite)
successful = _ut.TextTestRunner(verbosity=2).run(suite).wasSuccessful()
sys.exit(0 if successful else 1)


def run_hv_test_suite():
Expand Down
3 changes: 2 additions & 1 deletion PyGMO/test/_archipelago_tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from PyGMO import topology, algorithm, problem, archipelago, distribution_type, migration_direction, island, population, migration
import unittest


class ArchipelagoTests(unittest.TestCase):
"""Test archipelago properties"""

Expand Down Expand Up @@ -89,7 +90,6 @@ def test_one_way_ring_null_alg(self):
top.set_weight(0.0)
self.do_test_migr_setup(pop_xs, pop_xs, top, 1)


def test_distribution_type(self):
"""Testing whether the distribution_type property works"""

Expand All @@ -103,6 +103,7 @@ def test_distribution_type(self):

self.assertEqual(a.distribution_type, dist_type)


def get_archipelago_test_suite():
suite = unittest.TestSuite()
suite.addTests(unittest.makeSuite(ArchipelagoTests))
Expand Down

0 comments on commit dd8ed7b

Please sign in to comment.