Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions tests/test_bvh_tri_probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,21 @@ def test_bad_arguments_rejected_before_open_oracle(self):
self.assertEqual(probe.main(argv), 2)
self.assertIn("error:", err.getvalue())

def test_json_directory_is_named_as_typed(self):
# every other diagnostic in this tool prints the path the user typed; repr() doubled each backslash
with tempfile.TemporaryDirectory() as tmp:
err = io.StringIO()
with redirect_stderr(err):
self.assertEqual(probe.main(["--json", tmp]), 2)
self.assertEqual(err.getvalue(), f"error: --json {tmp} is not a file path\n")

def test_json_empty_is_a_named_error(self):
# an empty --json value cannot be echoed as a path; the message says (empty) instead of showing ''
err = io.StringIO()
with redirect_stderr(err):
self.assertEqual(probe.main(["--json", " "]), 2)
self.assertEqual(err.getvalue(), "error: --json (empty) is not a file path\n")

def test_write_kernels(self):
with tempfile.TemporaryDirectory() as tmp, redirect_stdout(io.StringIO()):
self.assertEqual(probe.main(["--write-kernels", tmp, "--kernel", "tri_g4b"]), 0)
Expand Down
2 changes: 1 addition & 1 deletion tools/bvh_tri_probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ def main(argv=None):
return 2
kernels = [k for k in kernels if k.label in args.kernel]
if args.json_out is not None and (not args.json_out.strip() or os.path.isdir(args.json_out)):
print(f"error: --json {args.json_out!r} is not a file path", file=sys.stderr)
print(f"error: --json {args.json_out.strip() or '(empty)'} is not a file path", file=sys.stderr)
return 2
if args.list:
for k in kernels:
Expand Down