diff options
author | Marius Kintel <marius@kintel.net> | 2010-08-28 13:16:03 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2010-10-31 00:42:38 (GMT) |
commit | f2323c78b381c24d2924c6cea7c9230416542a17 (patch) | |
tree | 1cc22a189603e2a6d3db5ecca0fd7204b504866e /tests/test_cmdline_tool.py | |
parent | 22b74585d85d50c774c59cd7fb501d4ef05e6ac9 (diff) |
Better error output when cmd is not found
Diffstat (limited to 'tests/test_cmdline_tool.py')
-rwxr-xr-x | tests/test_cmdline_tool.py | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/tests/test_cmdline_tool.py b/tests/test_cmdline_tool.py index e365214..e841905 100755 --- a/tests/test_cmdline_tool.py +++ b/tests/test_cmdline_tool.py @@ -64,19 +64,23 @@ def run_test(testname, cmd, args): if not os.path.exists(outputdir): os.makedirs(outputdir) outputname = actualfilename outfile = open(outputname, "wb") - proc = subprocess.Popen([cmd] + args, stdout=outfile, stderr=subprocess.PIPE) - errtext = proc.communicate()[1] - if errtext != None and len(errtext) > 0: - print >> sys.stderr, "Error output: " + errtext - outfile.close() - if proc.returncode != 0: - print >> sys.stderr, "Error: %s failed with return code %d" % (cmdname, proc.returncode) - return False - - if not options.generate: - if not compare_text(expectedfilename, actualfilename): - execute_and_redirect("diff", [expectedfilename, actualfilename], sys.stderr) + try: + proc = subprocess.Popen([cmd] + args, stdout=outfile, stderr=subprocess.PIPE) + errtext = proc.communicate()[1] + if errtext != None and len(errtext) > 0: + print >> sys.stderr, "Error output: " + errtext + outfile.close() + if proc.returncode != 0: + print >> sys.stderr, "Error: %s failed with return code %d" % (cmdname, proc.returncode) return False + + if not options.generate: + if not compare_text(expectedfilename, actualfilename): + execute_and_redirect("diff", [expectedfilename, actualfilename], sys.stderr) + return False + except OSError, err: + print >> sys.stderr, "Error: %s \"%s\"" % (err.strerror, cmd) + return True class Options: |