diff options
Diffstat (limited to 'tests/test_batch_glb.py')
| -rw-r--r-- | tests/test_batch_glb.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/test_batch_glb.py b/tests/test_batch_glb.py index 6cc3bd416..58753cbcf 100644 --- a/tests/test_batch_glb.py +++ b/tests/test_batch_glb.py | |||
| @@ -57,11 +57,34 @@ class TestBatchGlb(unittest.TestCase): | |||
| 57 | [sys.executable, "-I", os.path.join(TOOLS, "batch_glb.py"), source, output], | 57 | [sys.executable, "-I", os.path.join(TOOLS, "batch_glb.py"), source, output], |
| 58 | capture_output=True, text=True, errors="replace", check=False, | 58 | capture_output=True, text=True, errors="replace", check=False, |
| 59 | ) | 59 | ) |
| 60 | self.assertEqual(result.returncode, 1) | 60 | self.assertEqual(result.returncode, 2) |
| 61 | self.assertTrue(result.stderr.startswith("ERROR: "), result.stderr) | 61 | self.assertTrue(result.stderr.startswith("ERROR: "), result.stderr) |
| 62 | self.assertIn(error, result.stderr) | 62 | self.assertIn(error, result.stderr) |
| 63 | self.assertEqual(len(result.stderr.splitlines()), 1) | 63 | self.assertEqual(len(result.stderr.splitlines()), 1) |
| 64 | 64 | ||
| 65 | def test_cli_exit_status_follows_the_docstring(self) -> None: | ||
| 66 | script = os.path.join(TOOLS, "batch_glb.py") | ||
| 67 | with tempfile.TemporaryDirectory() as root: | ||
| 68 | empty = os.path.join(root, "empty") | ||
| 69 | broken = os.path.join(root, "broken") | ||
| 70 | os.mkdir(empty) | ||
| 71 | os.mkdir(broken) | ||
| 72 | with open(os.path.join(broken, "broken.obj"), "w", encoding="utf-8", newline="\n") as f: | ||
| 73 | f.write("o broken\nf 1 2 3\n") | ||
| 74 | |||
| 75 | cases = [ | ||
| 76 | ("empty input folder: no model failed", [empty, os.path.join(root, "out_empty")], 0), | ||
| 77 | ("one model failed", [broken, os.path.join(root, "out_broken")], 1), | ||
| 78 | ("usage error", ["--bogus"], 2), | ||
| 79 | ] | ||
| 80 | for label, args, expected in cases: | ||
| 81 | with self.subTest(case=label): | ||
| 82 | result = subprocess.run( | ||
| 83 | [sys.executable, "-I", script, *args], | ||
| 84 | capture_output=True, text=True, errors="replace", check=False, | ||
| 85 | ) | ||
| 86 | self.assertEqual(result.returncode, expected, result.stdout + result.stderr) | ||
| 87 | |||
| 65 | def test_cli_rejects_invalid_jobs_and_max_tex_size(self) -> None: | 88 | def test_cli_rejects_invalid_jobs_and_max_tex_size(self) -> None: |
| 66 | with tempfile.TemporaryDirectory() as root: | 89 | with tempfile.TemporaryDirectory() as root: |
| 67 | for flag, value, error in [ | 90 | for flag, value, error in [ |