diff --git a/.travis.yml b/.travis.yml index 83d6b6da65b2da5ecf80447ad7bb37e5e3086d89..3945a5c39fe230cb41ab332e269c93d12e697ef4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,3 @@ -## Add to .hg/hgrc to enable bitbucket pushes to push to github as well. -# [hooks] -# outgoing = hg push git+ssh://git@github.com/jmchilton/lwr.git || true language: python python: - 2.6 @@ -22,7 +19,7 @@ install: - sudo python scripts/configure_test_slurm.py - echo "export DRMAA_LIBRARY_PATH=/usr/lib/libdrmaa.so" >> local_env.sh - pip install drmaa - - sudo apt-get install condor +# - sudo apt-get install condor script: . local_env.sh; nosetests matrix: include: diff --git a/test/integration_test.py b/test/integration_test.py index 6e90b8779e15dc457be4a5664066e0ba616ee54b..b2f26187bdfc4f695711d3da63d6e24b9eb0d17b 100644 --- a/test/integration_test.py +++ b/test/integration_test.py @@ -1,5 +1,5 @@ from os.path import join -from .test_utils import TempDirectoryTestCase +from .test_utils import TempDirectoryTestCase, skipUnlessExecutable, skipUnlessEnvironVariable from lwr.util import Bunch from .check import run @@ -11,6 +11,7 @@ except ImportError: class IntegrationTest(TempDirectoryTestCase): + @skipUnlessEnvironVariable("DRMAA_LIBRARY_PATH") def test_integration_as_user(self): self.__run(job_conf_props={'type': 'queued_external_drmaa', "production": "false"}, private_token=None, default_file_action="copy", user='u1') @@ -35,9 +36,11 @@ class IntegrationTest(TempDirectoryTestCase): def test_integration_errors(self): self.__run(app_conf={"private_key": "testtoken"}, private_token="testtoken", transport="curl", test_errors=True) + @skipUnlessEnvironVariable("DRMAA_LIBRARY_PATH") def test_integration_drmaa(self): self.__run(app_conf={}, job_conf_props={'type': 'queued_drmaa'}, private_token=None) + @skipUnlessExecutable("condor_submit") def test_integration_condor(self): self.__run(app_conf={}, job_conf_props={'type': 'queued_condor'}, private_token=None) diff --git a/test/test_utils.py b/test/test_utils.py index d7509da20887448349c5e2a3256b944552dc2c4e..9130d6ba69d2a662b85ae813e7b74ca8398289f7 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -1,15 +1,15 @@ from contextlib import contextmanager from stat import S_IXOTH -from os import pardir, stat, chmod -from os.path import join, dirname +from os import pardir, stat, chmod, access, X_OK, pathsep, environ +from os.path import join, dirname, isfile, split from tempfile import mkdtemp from shutil import rmtree from sys import version_info if version_info < (2, 7): - from unittest2 import TestCase + from unittest2 import TestCase, skip else: - from unittest import TestCase + from unittest import TestCase, skip from webtest import TestApp from webtest.http import StopableWSGIServer @@ -131,6 +131,37 @@ def test_app(global_conf={}, app_conf={}, test_conf={}): pass +def skipUnlessExecutable(executable): + if __which(executable): + return lambda func: func + return skip("PATH doesn't contain executable {!r}".format(executable)) + + +def skipUnlessEnvironVariable(variable): + if variable in environ: + return lambda func: func + return skip("Environment variable %s is not defined." % variable) + + +def __which(program): + + def is_exe(fpath): + return isfile(fpath) and access(fpath, X_OK) + + fpath, fname = split(program) + if fpath: + if is_exe(program): + return program + else: + for path in environ["PATH"].split(pathsep): + path = path.strip('"') + exe_file = join(path, program) + if is_exe(exe_file): + return exe_file + + return None + + class TestAuthorizer(object): def __init__(self):