diff --git a/scripts/verify.py b/scripts/verify.py index f47c7f011..efbfda178 100644 --- a/scripts/verify.py +++ b/scripts/verify.py @@ -2988,13 +2988,13 @@ def _main(held: contextlib.ExitStack) -> None: print(_overall_summary(group_results)) if args.destinations: - held = {} + destinations = {} for (result, names), (group, _rep) in zip(group_results, groups): for name, key in zip(names, group): - held[name] = { + destinations[name] = { "platform": key, "pack_destinations": result["pack_destinations"], } - Path(args.destinations).write_text(json.dumps(held, indent=1, sort_keys=True)) + Path(args.destinations).write_text(json.dumps(destinations, indent=1, sort_keys=True)) if args.json: for r in all_results.values(): diff --git a/tests/test_verify_listing.py b/tests/test_verify_listing.py index c825b52a5..11d05d6ce 100644 --- a/tests/test_verify_listing.py +++ b/tests/test_verify_listing.py @@ -173,6 +173,23 @@ class TheDestinationsFlagNeedsAPack(unittest.TestCase): self.assertEqual(result.returncode, 2, result.stdout[-300:]) self.assertIn("--destinations", result.stderr) + def test_the_lock_stack_is_not_rebound(self): + """The --destinations branch reused `held`, the ExitStack that holds + the data directory locks, for its dict: a later enter_context in + that mode raised AttributeError.""" + import ast + + tree = ast.parse((REPO_ROOT / "scripts" / "verify.py").read_text(encoding="utf-8")) + body = next(n for n in tree.body if isinstance(n, ast.FunctionDef) and n.name == "_main") + stack = body.args.args[0].arg + rebound = [ + node.lineno for node in ast.walk(body) + if isinstance(node, (ast.Assign, ast.AnnAssign, ast.AugAssign)) + for target in (node.targets if isinstance(node, ast.Assign) else [node.target]) + if isinstance(target, ast.Name) and target.id == stack + ] + self.assertEqual(rebound, []) + class EveryGapCountedIsNamed(unittest.TestCase): """verify --platform batocera --verbose counted 3 optional core files and