upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 03:14:25 -0500
committerItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 03:14:25 -0500
commitae1daa66d7d54a78fb8a78c2caee79da0df64cb1 (patch)
tree64c5743b763fb69528de5669d9828fe4118c601c
parent2cd416311ffb0378e66880e872f5ddb0d9d514ac (diff)
parentbe562fc277db1314afe8a3c77cd8c4244a04e8ff (diff)
Merge pull request #1190 from Tayar
-rw-r--r--tests/test_pe_inspect.py11
-rw-r--r--tools/pe_inspect.py6
2 files changed, 16 insertions, 1 deletions
diff --git a/tests/test_pe_inspect.py b/tests/test_pe_inspect.py
index af6a02f3a..b776e4f3f 100644
--- a/tests/test_pe_inspect.py
+++ b/tests/test_pe_inspect.py
@@ -323,6 +323,17 @@ class PeInspectTest(unittest.TestCase):
323 self.assertEqual(r["pdata_functions"], 0) 323 self.assertEqual(r["pdata_functions"], 0)
324 self.assertFalse(r["has_relocs"]) 324 self.assertFalse(r["has_relocs"])
325 325
326 def test_cli_reports_an_unusable_output_directory(self):
327 out = os.path.join(self.dir, "report-file")
328 with open(out, "w", encoding="utf-8") as f:
329 f.write("keep me")
330 stderr = io.StringIO()
331 with contextlib.redirect_stderr(stderr):
332 self.assertEqual(pe_inspect.main([self.image, "--out", out]), 1)
333 self.assertIn(f"cannot create output directory {out}", stderr.getvalue())
334 with open(out, encoding="utf-8") as f:
335 self.assertEqual(f.read(), "keep me")
336
326 def test_cli_writes_json_and_markdown(self): 337 def test_cli_writes_json_and_markdown(self):
327 out = os.path.join(self.dir, "reports") 338 out = os.path.join(self.dir, "reports")
328 with contextlib.redirect_stdout(io.StringIO()), contextlib.redirect_stderr(io.StringIO()): 339 with contextlib.redirect_stdout(io.StringIO()), contextlib.redirect_stderr(io.StringIO()):
diff --git a/tools/pe_inspect.py b/tools/pe_inspect.py
index 076b96a4c..07695dbfd 100644
--- a/tools/pe_inspect.py
+++ b/tools/pe_inspect.py
@@ -385,7 +385,11 @@ def main(argv: list[str] | None = None) -> int:
385 ap.add_argument("--game-dir") 385 ap.add_argument("--game-dir")
386 ap.add_argument("--out", default=os.path.join(os.path.dirname(__file__), "..", "reports", "pe")) 386 ap.add_argument("--out", default=os.path.join(os.path.dirname(__file__), "..", "reports", "pe"))
387 a = ap.parse_args(argv) 387 a = ap.parse_args(argv)
388 os.makedirs(a.out, exist_ok=True) 388 try:
389 os.makedirs(a.out, exist_ok=True)
390 except OSError as e:
391 print(f"cannot create output directory {a.out}: {e.strerror or e}", file=sys.stderr)
392 return 1
389 rc = 0 393 rc = 0
390 seen_paths: set[tuple[str, str]] = set() 394 seen_paths: set[tuple[str, str]] = set()
391 used_names: set[str] = set() 395 used_names: set[str] = set()