提交 8d9b0a37 authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Fixed script run_tests_in_batch so that it works even when the 'nosetests'…

Fixed script run_tests_in_batch so that it works even when the 'nosetests' command cannot be directly called from subprocess. This happens for instance on Windows when nosetests was installed within MinGW with "python setup.py install".
上级 d10f323f
__authors__ = "Olivier Delalleau"
__contact__ = "delallea@iro"
"""
This script should behave the same as the `nosetests` command.
The reason for its existence is that on some systems, it may not be obvious to
find where nosetests is installed in order to run it in a different process.
This script is called from `run_tests_in_batch.py`.
"""
import sys
import nose
if __name__ == '__main__':
sys.exit(nose.main())
...@@ -37,8 +37,11 @@ import theano ...@@ -37,8 +37,11 @@ import theano
def main(): def main():
theano_dir = os.path.dirname(theano.__file__)
# `nose` is the script that calls nosetests.
nose = os.path.join(theano_dir, 'tests', 'call_nose.py')
if len(sys.argv) == 1: if len(sys.argv) == 1:
tests_dir = os.path.join(os.path.dirname(theano.__file__), '..') tests_dir = theano_dir
else: else:
assert len(sys.argv) == 2 assert len(sys.argv) == 2
tests_dir = sys.argv[1] tests_dir = sys.argv[1]
...@@ -52,7 +55,8 @@ def main(): ...@@ -52,7 +55,8 @@ def main():
#################### ####################
# COLLECTING TESTS # # COLLECTING TESTS #
####################""" ####################"""
assert subprocess.call(['nosetests', '--collect-only', '--with-id']) == 0 rval = subprocess.call(['python', nose, '--collect-only', '--with-id'])
assert rval == 0
noseids_file = '.noseids' noseids_file = '.noseids'
data = cPickle.load(open(noseids_file, 'rb')) data = cPickle.load(open(noseids_file, 'rb'))
ids = data['ids'] ids = data['ids']
...@@ -70,7 +74,7 @@ def main(): ...@@ -70,7 +74,7 @@ def main():
# We suppress all output because we want the user to focus only on the # We suppress all output because we want the user to focus only on the
# failed tests, which are re-run (with output) below. # failed tests, which are re-run (with output) below.
dummy_out = open(os.devnull, 'w') dummy_out = open(os.devnull, 'w')
rval = subprocess.call(['nosetests', '-q', '--with-id'] + rval = subprocess.call(['python', nose, '-q', '--with-id'] +
map(str, test_range), stdout=dummy_out.fileno(), map(str, test_range), stdout=dummy_out.fileno(),
stderr=dummy_out.fileno()) stderr=dummy_out.fileno())
# Recover failed test indices from the 'failed' field of the '.noseids' # Recover failed test indices from the 'failed' field of the '.noseids'
...@@ -88,7 +92,7 @@ def main(): ...@@ -88,7 +92,7 @@ def main():
################################ ################################
# RE-RUNNING FAILED TESTS ONLY # # RE-RUNNING FAILED TESTS ONLY #
################################""" ################################"""
subprocess.call(['nosetests', '-v', '--with-id'] + failed) subprocess.call(['python', nose, '-v', '--with-id'] + failed)
return 0 return 0
else: else:
print """\ print """\
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论