Skip to content
Snippets Groups Projects
Commit ce461fa1 authored by Manuel Günther's avatar Manuel Günther
Browse files

Made more nose tests quiet

parent 2fd1aa06
Branches
Tags
No related merge requests found
......@@ -542,7 +542,7 @@ class Library (Extension):
self.c_define_macros.extend(self.pkg_macros)
def compile(self, build_directory, compiler = None):
def compile(self, build_directory, compiler = None, stdout=None):
"""This function will automatically create a CMakeLists.txt file in the ``package_directory`` including the required information.
Afterwards, the library is built using CMake in the given ``build_directory``.
The build type is automatically taken from the debug option in the buildout.cfg.
......@@ -578,12 +578,12 @@ class Library (Extension):
env['CXX'] = compiler
# configure cmake
command = [self.c_cmake, final_build_dir]
if subprocess.call(command, cwd=final_build_dir, env=env) != 0:
if subprocess.call(command, cwd=final_build_dir, env=env, stdout=stdout) != 0:
raise OSError("Could not generate makefiles with CMake")
# run make
make_call = ['make']
if "BOB_BUILD_PARALLEL" in os.environ: make_call += ['-j%s' % os.environ["BOB_BUILD_PARALLEL"]]
if subprocess.call(make_call, cwd=final_build_dir, env=env) != 0:
if subprocess.call(make_call, cwd=final_build_dir, env=env, stdout=stdout) != 0:
raise OSError("CMake compilation stopped with an error; stopping ...")
......
......@@ -79,11 +79,13 @@ def test_library():
version = '3.2.1'
)
# redirect output of functions to /dev/null to avoid spamming the console
devnull = open(os.devnull, 'w')
# compile
compile_dir = os.path.join(temp_dir, 'build', 'lib')
os.makedirs(compile_dir)
os.makedirs(target_dir)
library.compile(compile_dir)
library.compile(compile_dir,stdout=devnull)
# check that the library was generated sucessfully
if platform.system() == 'Darwin':
......@@ -99,4 +101,3 @@ def test_library():
# finally, clean up the mess
shutil.rmtree(temp_dir)
......@@ -15,25 +15,34 @@ def test_new_version():
from bob.extension.scripts import new_version
# keep the nose tests quiet
_stdout, _stderr = sys.stdout, sys.stderr
# test the script using the dry-run option (to avoid to actually tag and push code)
try:
devnull = open(os.devnull, 'w')
sys.stdout = sys.stderr = devnull
# assert that it does not raise an exception, when both latest and stable version are specified
if os.path.exists("version.txt"):
new_version(['--dry-run', '--stable-version', '20.7.0', '--latest-version', '20.8.0'])
# assert that it does not raise an exception, when both latest and stable version are specified
if os.path.exists("version.txt"):
new_version(['--dry-run', '--stable-version', '20.7.0', '--latest-version', '20.8.0'])
# assert that it does not raise an exception, when only the latest version is specified
if os.path.exists("version.txt"):
new_version(['--dry-run', '--latest-version', '20.8.0'])
# assert that it does not raise an exception, when only the latest version is specified
if os.path.exists("version.txt"):
new_version(['--dry-run', '--latest-version', '20.8.0'])
# assert that no exception is raised even if no version is specified
if os.path.exists("version.txt"):
new_version(['--dry-run'])
# assert that no exception is raised even if no version is specified
if os.path.exists("version.txt"):
new_version(['--dry-run'])
# assert that it does raise an exception, when the latest version is too low
nose.tools.assert_raises(ValueError, new_version, ['--dry-run', '--latest-version', '0.8.0'])
# assert that it does raise an exception, when the latest version is too low
nose.tools.assert_raises(ValueError, new_version, ['--dry-run', '--latest-version', '0.8.0'])
# assert that it does raise an exception, when the stable version is too low
nose.tools.assert_raises(ValueError, new_version, ['--dry-run', '--stable-version', '0.8.0', '--latest-version', '0.9.0'])
# assert that it does raise an exception, when the stable version is too low
nose.tools.assert_raises(ValueError, new_version, ['--dry-run', '--stable-version', '0.8.0', '--latest-version', '0.9.0'])
# assert that it does raise an exception, when the stable version is higher than latest version
nose.tools.assert_raises(ValueError, new_version, ['--dry-run', '--stable-version', '20.8.0', '--latest-version', '20.8.0a1'])
# assert that it does raise an exception, when the stable version is higher than latest version
nose.tools.assert_raises(ValueError, new_version, ['--dry-run', '--stable-version', '20.8.0', '--latest-version', '20.8.0a1'])
finally:
sys.stdout, sys.stderr = _stdout, _stderr
......@@ -144,39 +144,49 @@ package-z
-e http://example.com/mypackage-1.0.4.zip
"""
# test NumPy and SciPy docs
try:
import numpy
result = link_documentation(['numpy'], None)
assert len(result) == 1
key = list(result.keys())[0]
assert '/numpy' in key
except ImportError:
pass
# keep the nose tests quiet
_stdout = sys.stdout
try:
import scipy
result = link_documentation(['scipy'], None)
assert len(result) == 1
key = list(result.keys())[0]
assert '/scipy' in key
assert '/reference' in key
except ImportError:
pass
# test pypi packages
additional_packages = ['python', 'bob.extension', 'gridtk', 'other.bob.package']
if "BOB_DOCUMENTATION_SERVER" not in os.environ:
devnull = open(os.devnull, 'w')
sys.stdout = devnull
# test NumPy and SciPy docs
try:
import numpy
result = link_documentation(['numpy'], None)
assert len(result) == 1
key = list(result.keys())[0]
assert '/numpy' in key
except ImportError:
pass
try:
import scipy
result = link_documentation(['scipy'], None)
assert len(result) == 1
key = list(result.keys())[0]
assert '/scipy' in key
assert '/reference' in key
except ImportError:
pass
# test pypi packages
additional_packages = ['python', 'bob.extension', 'gridtk', 'other.bob.package']
if "BOB_DOCUMENTATION_SERVER" not in os.environ:
result = link_documentation(additional_packages, stringio(f))
expected = {'http://docs.python.org/%d.%d' % sys.version_info[:2] : None, 'https://pythonhosted.org/setuptools' : None, 'https://pythonhosted.org/bob.extension' : None, 'https://pythonhosted.org/gridtk' : None}
nose.tools.eq_(result, expected)
# test idiap server
os.environ["BOB_DOCUMENTATION_SERVER"] = "https://www.idiap.ch/software/bob/docs/latest/bioidiap/%s/master"
result = link_documentation(additional_packages, stringio(f))
expected = {'http://docs.python.org/%d.%d' % sys.version_info[:2] : None, 'https://pythonhosted.org/setuptools' : None, 'https://pythonhosted.org/bob.extension' : None, 'https://pythonhosted.org/gridtk' : None}
expected = {'http://docs.python.org/%d.%d' % sys.version_info[:2] : None, 'https://www.idiap.ch/software/bob/docs/latest/bioidiap/bob.extension/master' : None, 'https://www.idiap.ch/software/bob/docs/latest/idiap/gridtk/master' : None}
nose.tools.eq_(result, expected)
# test idiap server
os.environ["BOB_DOCUMENTATION_SERVER"] = "https://www.idiap.ch/software/bob/docs/latest/bioidiap/%s/master"
result = link_documentation(additional_packages, stringio(f))
expected = {'http://docs.python.org/%d.%d' % sys.version_info[:2] : None, 'https://www.idiap.ch/software/bob/docs/latest/bioidiap/bob.extension/master' : None, 'https://www.idiap.ch/software/bob/docs/latest/idiap/gridtk/master' : None}
nose.tools.eq_(result, expected)
finally:
sys.stdout = _stdout
def test_get_config():
# Test the generic get_config() function
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment