vm-tests: the typecheck fails a step that rebinds a function of its script
A VM test script and `lib/k3s.py` share one namespace, so a step that assigns `pod = ...` replaces the library's `pod()` for every later call and the test dies mid-run with `TypeError: 'dict' object is not callable`. `ty` and `ruff --select F` accept a module-level rebinding, so this cost a full VM round on #6947. `vm-test-shadow-scan.py` parses the script and fails when a name bound at module level (assignment, `for` or `with` target, `import ... as`, walrus, `except ... as`) is also a module-level `def`. It looks into `with`, `if`, `for`, `while` and `try` bodies, where `with subtest(...)` steps live, and not into function or comprehension bodies. Every `vm-test-typecheck-<name>` runs it on the script alone. `vm-test-typecheck-shadow-control` passes only when it rejects each form of rebinding and accepts the same names where they are local. The one existing case, `sources` in `k8s-services`, is renamed `cred_sources`. Closes #6951
This commit is contained in:
parent
81676ccc78
commit
0d6065cf8f
1 changed files with 175 additions and 4 deletions
|
|
@ -1601,9 +1601,9 @@ pkgs.testers.runNixOSTest {
|
|||
assert env["BAO_AUTH"] == "jwt" and env["BAO_JWT_ROLE"] == CI, env
|
||||
assert "BAO_CLIENT_CERT" not in env and "BAO_CLIENT_KEY" not in env, env
|
||||
creds = next(v for v in spec["volumes"] if v["name"] == "credentials")
|
||||
sources = creds["projected"]["sources"]
|
||||
assert [src["configMap"]["name"] for src in sources] == ["hyperhive-ca-trust"], sources
|
||||
assert [(i["key"], i["path"]) for i in sources[0]["configMap"]["items"]] == [("bao-server-ca.pem", "bao-ca.pem")], sources
|
||||
cred_sources = creds["projected"]["sources"]
|
||||
assert [src["configMap"]["name"] for src in cred_sources] == ["hyperhive-ca-trust"], cred_sources
|
||||
assert [(i["key"], i["path"]) for i in cred_sources[0]["configMap"]["items"]] == [("bao-server-ca.pem", "bao-ca.pem")], cred_sources
|
||||
assert not any("secret" in v or any("secret" in src for src in v.get("projected", {}).get("sources", [])) for v in spec["volumes"]), spec["volumes"]
|
||||
assert other_secrets() == set(), other_secrets()
|
||||
# The control that the lookup finds the variable: the router's pod sets
|
||||
|
|
|
|||
Loading…
Reference in a new issue