Merge commit 'refs/pr-all/1346' into carry/1346

This commit is contained in:
MoonEyes
2026-12-02 10:59:56 +01:00
2 changed files with 40 additions and 0 deletions

View File

@ -337,6 +337,27 @@ class ArgumentTest(unittest.TestCase):
with open(path, "rb") as f:
self.assertEqual(f.read(), original)
def test_new_report_with_a_case_variant_of_the_carve_manifest(self):
carve = os.path.join(self.root, "carve")
os.mkdir(carve)
manifest = os.path.join(carve, "index.json")
report = os.path.join(carve, "INDEX.JSON")
with open(manifest, "xb"):
pass
folds_case = os.path.exists(report)
os.remove(manifest) # The guard must work before either path exists.
result = self.run_tool(carve, report)
if folds_case:
self.assertEqual(result.returncode, 2, result.stderr)
self.assertIn("would overwrite a carve input", result.stderr)
self.assertFalse(os.path.exists(report))
else:
self.assertEqual(result.returncode, 0, result.stderr)
with open(report, encoding="utf-8") as f:
self.assertEqual(json.load(f)["files"], [])
self.assertFalse(os.path.exists(manifest))
def test_directory_report_cannot_replace_a_stream_via_a_hard_link(self):
stream = os.path.join(self.root, "00000001.bin")
out = os.path.join(self.root, "report.csv")

View File

@ -553,6 +553,25 @@ class OutputTest(unittest.TestCase):
self.assertIn("must be different files", result.stderr)
self.assertFalse(os.path.exists(out))
def test_new_json_and_csv_paths_that_differ_only_in_case(self):
source = os.path.join(self.root, "sample.bin")
with open(source, "wb") as f:
f.write(wide_blob())
out = os.path.join(self.root, "tree.json")
table = os.path.join(self.root, "TREE.JSON")
result = self._run_cli(source, out, "--csv", table)
if os.path.exists(os.path.join(self.root, "SAMPLE.BIN")):
self.assertEqual(result.returncode, 2, result.stderr)
self.assertIn("must be different files", result.stderr)
self.assertFalse(os.path.exists(out))
else:
self.assertEqual(result.returncode, 0, result.stderr)
with open(out, encoding="utf-8") as f:
self.assertEqual(json.load(f)["summary"]["resources"], 1)
with open(table, encoding="utf-8", newline="") as f:
self.assertEqual(next(csv.DictReader(f))["root"], "TestRoot")
def test_root_filter_and_limit(self):
with open(os.path.join(self.root, "00000000.bin"), "wb") as f:
f.write(wide_blob())