Skip to content
Snippets Groups Projects
Commit 0d71baba authored by Nat Goodspeed's avatar Nat Goodspeed
Browse files

Produce error message, not traceback, when test program doesn't build.

A traceback from a Python script always makes people think there's a bug in
your script. Even when a test program fails to build, CMake often (always?)
tries to run it anyway, via our run_build_test.py script. For that case,
produce a straightforward error message -- rather than an OSError traceback
that doesn't even mention the program name!
parent 3b7d3cb1
No related branches found
No related tags found
No related merge requests found
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
import os import os
import sys import sys
import errno
import signal import signal
import subprocess import subprocess
...@@ -112,7 +113,23 @@ def main(command, libpath=[], vars={}): ...@@ -112,7 +113,23 @@ def main(command, libpath=[], vars={}):
print "Running: %s" % " ".join(command) print "Running: %s" % " ".join(command)
# Make sure we see all relevant output *before* child-process output. # Make sure we see all relevant output *before* child-process output.
sys.stdout.flush() sys.stdout.flush()
return subprocess.call(command) try:
return subprocess.call(command)
except OSError as err:
# If the caller is trying to execute a test program that doesn't
# exist, we want to produce a reasonable error message rather than a
# traceback. This happens when the build is halted by errors, but
# CMake tries to proceed with testing anyway <eyeroll/>. However, do
# NOT attempt to handle any error but "doesn't exist."
if err.errno != errno.ENOENT:
raise
# In practice, the pathnames into CMake's build tree are so long as to
# obscure the name of the test program. Just print its basename.
print "No such program %s; check for preceding build errors" % \
os.path.basename(command[0])
# What rc should we simulate for missing executable? Windows produces
# 9009.
return 9009
# swiped from vita, sigh, seems like a Bad Idea to introduce dependency # swiped from vita, sigh, seems like a Bad Idea to introduce dependency
def translate_rc(rc): def translate_rc(rc):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment