mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-10 13:33:24 -05:00
fix: fail a truth diff that compared nothing
This commit is contained in:
1 parent
e4cc978614
commit
ae0bbb9d3c
2 files changed
+27
-7
No files matched your search
@@ -179,26 +179,23 @@ def main() -> None:
|
||||
|
||||
reports: list[dict] = []
|
||||
formatter = _format_markdown if args.format == "markdown" else _format_terminal
|
||||
compared = 0
|
||||
|
||||
for platform in platforms:
|
||||
truth = _load_truth(args.truth_dir, platform)
|
||||
if truth is None:
|
||||
if not args.json_output:
|
||||
print(
|
||||
f"skip {platform}: no truth YAML in {args.truth_dir}/",
|
||||
file=sys.stderr,
|
||||
)
|
||||
print(f"skip {platform}: no truth YAML in {args.truth_dir}/", file=sys.stderr)
|
||||
continue
|
||||
|
||||
try:
|
||||
scraped = load_platform_config(platform, args.platforms_dir)
|
||||
except FileNotFoundError:
|
||||
if not args.json_output:
|
||||
print(f"skip {platform}: no scraped config", file=sys.stderr)
|
||||
print(f"skip {platform}: no scraped config", file=sys.stderr)
|
||||
continue
|
||||
|
||||
report = diff_platform_truth(truth, scraped)
|
||||
report["platform"] = platform
|
||||
compared += 1
|
||||
|
||||
if args.json_output:
|
||||
reports.append(report)
|
||||
@@ -210,6 +207,10 @@ def main() -> None:
|
||||
json.dump(reports, sys.stdout, indent=2)
|
||||
print()
|
||||
|
||||
if compared < len(platforms) and (args.platform or not compared):
|
||||
print(f"compared {compared} of {len(platforms)} platform(s)", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -56,6 +56,25 @@ class ATargetedModelIsItsOwnArtifact(unittest.TestCase):
|
||||
)
|
||||
|
||||
|
||||
class ADiffThatComparedNothingFails(unittest.TestCase):
|
||||
"""diff_truth --all skipped every platform without a model and exited 0."""
|
||||
|
||||
def test_an_empty_truth_directory_is_an_error(self):
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
repo = pathlib.Path(__file__).resolve().parent.parent
|
||||
with tempfile.TemporaryDirectory(dir=str(repo / "tmp")) as directory:
|
||||
for selection in (["--all"], ["--platform", "retroarch"]):
|
||||
proc = subprocess.run(
|
||||
[sys.executable, "scripts/diff_truth.py", *selection,
|
||||
"--truth-dir", directory, "--json"],
|
||||
capture_output=True, text=True, cwd=str(repo), timeout=120,
|
||||
)
|
||||
self.assertEqual(proc.returncode, 1, selection)
|
||||
self.assertIn("skip", proc.stderr)
|
||||
|
||||
|
||||
class RenameMatching(unittest.TestCase):
|
||||
def test_a_shared_sha1_pairs_the_two_names(self):
|
||||
truth = [_entry("bios_CD_U.bin", sha1="a" * 40)]
|
||||
|
||||
Reference in new issue
Block a user