diff --git a/tests/test_bvh_tri_probe.py b/tests/test_bvh_tri_probe.py index b8a57165f0..11a259a7fd 100644 --- a/tests/test_bvh_tri_probe.py +++ b/tests/test_bvh_tri_probe.py @@ -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) diff --git a/tools/bvh_tri_probe.py b/tools/bvh_tri_probe.py index 9101ce0c3e..a14549c081 100644 --- a/tools/bvh_tri_probe.py +++ b/tools/bvh_tri_probe.py @@ -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: