Skip to content

Commit 74bdd7d

Browse files
committed
Provide a good err msg for invalid test executables
1 parent 2c579ba commit 74bdd7d

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

bin/jp-compliance

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,13 @@ class ComplianceTestRunner(object):
125125
def _run_test(self, test_case):
126126
command = shlex.split(self.jp_executable)
127127
command.append(test_case['expression'])
128-
process = subprocess.Popen(command, stdout=subprocess.PIPE,
129-
stderr=subprocess.PIPE,
130-
stdin=subprocess.PIPE)
128+
try:
129+
process = subprocess.Popen(command, stdout=subprocess.PIPE,
130+
stderr=subprocess.PIPE,
131+
stdin=subprocess.PIPE)
132+
except Exception, e:
133+
raise RuntimeError('Could not execute test executable "%s": '
134+
'%s' % (' '.join(command), e))
131135
process.stdin.write(json.dumps(test_case['given']))
132136
process.stdin.flush()
133137
stdout, stderr = process.communicate()
@@ -219,9 +223,15 @@ def main():
219223
if args.list:
220224
display_available_tests(runner.get_compliance_test_files())
221225
else:
222-
runner.run_tests()
226+
try:
227+
runner.run_tests()
228+
except Exception, e:
229+
sys.stderr.write(str(e))
230+
sys.stderr.write("\n")
231+
return 1
223232
sys.stdout.write('\n')
233+
return 0
224234

225235

226236
if __name__ == '__main__':
227-
main()
237+
sys.exit(main())

0 commit comments

Comments
 (0)