mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
fix(tools): exit 2 when import_audit cannot read an input or write --json
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -312,6 +312,9 @@ def main(argv=None):
|
||||
except AuditError as error:
|
||||
print(f"FAIL: {error}", file=sys.stderr)
|
||||
return 2
|
||||
except OSError as error:
|
||||
print(f"FAIL: {error.strerror}: {error.filename}" if error.filename else f"FAIL: {error}", file=sys.stderr)
|
||||
return 2
|
||||
print(render(summary, records, missing))
|
||||
return 1 if summary["unique_by_class"]["absent"] or missing else 0
|
||||
|
||||
|
||||
@@ -273,6 +273,22 @@ class ImportAuditTests(unittest.TestCase):
|
||||
self.assertEqual((code, out), (2, ""))
|
||||
self.assertIn("game.json: entry 0 has an invalid NID 'short'", err)
|
||||
|
||||
def test_unreadable_library_and_unwritable_json_exit_two(self):
|
||||
work = self.work
|
||||
library = work.libs / "libSceA.prx"
|
||||
library.write_bytes(exporting("AAAAAAAAAAA"))
|
||||
registry = work.root / "game.json"
|
||||
write_registry(registry, [("AAAAAAAAAAA", "libSceA.prx")])
|
||||
code, out, err = work.run(registry, "--json", str(work.modules))
|
||||
self.assertEqual((code, out), (2, ""))
|
||||
self.assertIn("FAIL: ", err)
|
||||
self.assertIn(str(work.modules), err)
|
||||
denied = PermissionError(13, "Permission denied", str(library))
|
||||
with patch.object(Path, "read_bytes", side_effect=denied):
|
||||
code, out, err = work.run(registry)
|
||||
self.assertEqual((code, out), (2, ""))
|
||||
self.assertIn(f"FAIL: Permission denied: {library}", err)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user