diff --git a/scripts/export_native.py b/scripts/export_native.py index 5e0029ef..2e309e64 100644 --- a/scripts/export_native.py +++ b/scripts/export_native.py @@ -668,7 +668,10 @@ def write_report(path: Path, report: dict) -> None: The run prints five examples per kind of change. The page lists them all, so the maintainer reading it finds each line of the diff named. + A platform with nothing to write made no directory of its own: the + output directory itself may not exist yet. """ + path.parent.mkdir(parents=True, exist_ok=True) write_if_changed(str(path), json.dumps(report, indent=2) + "\n") diff --git a/tests/test_export_report.py b/tests/test_export_report.py index 8277756c..6b36be5a 100644 --- a/tests/test_export_report.py +++ b/tests/test_export_report.py @@ -43,6 +43,14 @@ class ExportReportIsWrittenAndRead(unittest.TestCase): (Path(scratch) / "recalbox").mkdir() self.assertEqual(load_export_reports(scratch), [report]) + def test_a_report_goes_into_a_directory_not_yet_made(self): + """RetroPie with nothing left to correct writes no file, so its + output directory was never made and the report crashed --all.""" + with tempfile.TemporaryDirectory(dir=ROOT / "tmp") as scratch: + target = Path(scratch) / "fresh" / "retropie.json" + export_native.write_report(target, _report("retropie", [])) + self.assertTrue(target.exists()) + def test_export_keeps_every_change_not_the_printed_five(self): source = (ROOT / "scripts" / "export_native.py").read_text(encoding="utf-8") body = source[source.index("def export_platform("):source.index("def write_report(")]