Tests can skip by exiting with 99; fix eigen test failure

This allows (and changes the current examples) to exit with status 99 to
skip a test instead of outputting a special string ("NumPy missing").

This also fixes the eigen test, which currently fails when eigen
headers are available but NumPy is not, to skip instead of failing when
NumPy isn't available.
This commit is contained in:
Jason Rhinelander
2016-07-08 17:44:12 -04:00
parent 5ba89c340c
commit 7de9f6c72d
4 changed files with 19 additions and 11 deletions

View File

@@ -52,16 +52,20 @@ if len(sys.argv) == 3 and sys.argv[1] == '--relaxed':
relaxed = True
name = sys.argv[1]
output_bytes = subprocess.check_output([sys.executable, name + ".py"],
stderr=subprocess.STDOUT)
try:
output_bytes = subprocess.check_output([sys.executable, name + ".py"],
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
if e.returncode == 99:
print('Test "%s" could not be run.' % name)
exit(0)
else:
raise
output = sanitize(output_bytes.decode('utf-8'))
reference = sanitize(open(name + '.ref', 'r').read())
if 'NumPy missing' in output:
print('Test "%s" could not be run.' % name)
exit(0)
elif output == reference:
if output == reference:
print('Test "%s" succeeded.' % name)
exit(0)
else: