From 9ae3e85cba603e79005cc889d49dcc53a74f0794 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Thu, 3 Dec 2026 22:00:44 +0100 Subject: [PATCH] =?UTF-8?q?Answer=20stability=20round=202:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=202=20=F0=9F=9F=A1=20(0=20misread);=20a=20window?= =?UTF-8?q?=20is=20handed=20an=20XDG=20variable=20its=20starter=20lacks=20?= =?UTF-8?q?as=20empty,=20and=20a=20test=20pins=20the=20plan=20check=20unde?= =?UTF-8?q?r=20XDG=5FCONFIG=5FHOME?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/build_release/loop/test_chunk_windows.py | 4 ++-- bin/build_release/test_black_box.py | 2 +- bin/chunk_driver/claims.py | 7 ++++--- bin/chunk_driver/test_claims.py | 4 ++-- bin/do_epic/test_main.py | 2 +- bin/rule_hook/test_rule_hook.py | 4 ++++ 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/bin/build_release/loop/test_chunk_windows.py b/bin/build_release/loop/test_chunk_windows.py index 288a5744..3118ae8b 100644 --- a/bin/build_release/loop/test_chunk_windows.py +++ b/bin/build_release/loop/test_chunk_windows.py @@ -167,8 +167,8 @@ class StartChunks(unittest.TestCase): self.assertEqual(self.starts(fake), [("new-session", "item-1", [str(self.LAUNCHER), "--chunk", "item-1", "ship it"]), ("new-window", "item-3", [str(self.LAUNCHER), "--chunk", "item-3", "ship it"])]) first = next(call for call in fake.tmux_calls if call[0] == "new-session") self.assertEqual((first[first.index("-s") + 1], first[first.index("-c") + 1]), (self.session, str(self.root))) - # Only build-release's own variables are handed on, since a window gets the tmux server's environment. - self.assertEqual([word for word in first if "=" in word], ["BUILD_RELEASE_WORKER_MODEL=m"]) + # Only build-release's own variables and the two XDG ones are handed on, since a window gets the tmux server's environment. + self.assertEqual([word for word in first if "=" in word], ["BUILD_RELEASE_WORKER_MODEL=m", "XDG_CONFIG_HOME=", "XDG_STATE_HOME="]) self.assertEqual(fake.tmux_calls[0], ["list-windows", "-t", f"={self.session}", "-F", "#{window_name}\t#{pane_dead}\t#{window_id}"]) # The session names the checkout whose chunks it runs. self.assertIn(["set-option", "-t", f"={self.session}:", "@loop-root", str(self.root)], fake.tmux_calls) diff --git a/bin/build_release/test_black_box.py b/bin/build_release/test_black_box.py index c24f3655..c8b7b165 100644 --- a/bin/build_release/test_black_box.py +++ b/bin/build_release/test_black_box.py @@ -836,7 +836,7 @@ class Windows(unittest.TestCase): ["-V"], ["list-windows", "-t", "=loop-proj", "-F", "#{window_name}\t#{pane_dead}\t#{window_id}"], ["list-windows", "-a", "-F", "#{session_name}\t#{window_name}\t#{pane_dead}\t#{window_id}\t#{@chunk-root}"], - ["new-session", "-d", "-s", "loop-proj", "-n", "item-4", "-c", str(checkout.root), "-e", "BUILD_RELEASE_JUDGE_MODEL=judge-model", "-e", "BUILD_RELEASE_WORKER_MODEL=worker-model", "-P", "-F", "#{window_id}", "--", str(checkout.script), "--chunk", "item-4", "ship it"], + ["new-session", "-d", "-s", "loop-proj", "-n", "item-4", "-c", str(checkout.root), "-e", "BUILD_RELEASE_JUDGE_MODEL=judge-model", "-e", "BUILD_RELEASE_WORKER_MODEL=worker-model", "-e", "XDG_CONFIG_HOME=", "-e", "XDG_STATE_HOME=", "-P", "-F", "#{window_id}", "--", str(checkout.script), "--chunk", "item-4", "ship it"], ["set-option", "-t", "=loop-proj:", "@loop-root", str(checkout.root)], ["set-option", "-w", "-t", "@7", "@chunk-root", str(checkout.root)], ["set-option", "-w", "-t", "@7", "remain-on-exit", "failed"], diff --git a/bin/chunk_driver/claims.py b/bin/chunk_driver/claims.py index aad014c5..b6bdd518 100644 --- a/bin/chunk_driver/claims.py +++ b/bin/chunk_driver/claims.py @@ -20,10 +20,11 @@ CHUNK_FLAG = "--chunk" OWN = "BUILD_RELEASE_" -# A window gets the tmux server's environment, not the starting terminal's. Without the two XDG variables, a window would lock and write in other folders than the entry point that started it. +# A window gets the tmux server's environment, not the starting terminal's. With another XDG value than its starter's, a window would lock and write in other folders. So each is handed even where the starter lacks it, as empty: an empty value moves no folder. def handed(env: typing.Mapping[str, str]) -> dict[str, str]: - """The variables of env that an entry point hands each window it starts: those both entry points read, and the two that move the config folder and the state folder.""" - return {name: value for name, value in env.items() if name.startswith(OWN) or name in (XDG_CONFIG_HOME, XDG_STATE_HOME)} + """The variables an entry point hands each window it starts: those of env that both entry points read, and the two that move the config folder and the state folder.""" + own = {name: value for name, value in env.items() if name.startswith(OWN)} + return {**own, XDG_CONFIG_HOME: env.get(XDG_CONFIG_HOME, ""), XDG_STATE_HOME: env.get(XDG_STATE_HOME, "")} @contextlib.contextmanager diff --git a/bin/chunk_driver/test_claims.py b/bin/chunk_driver/test_claims.py index b7346b04..0c5f4076 100644 --- a/bin/chunk_driver/test_claims.py +++ b/bin/chunk_driver/test_claims.py @@ -14,8 +14,8 @@ class Handed(unittest.TestCase): env = {"BUILD_RELEASE_JUDGE_MODEL": "judge", "XDG_CONFIG_HOME": "/configs", "XDG_STATE_HOME": "/state", "XDG_DATA_HOME": "/data", "PATH": "/bin"} self.assertEqual(handed(env), {"BUILD_RELEASE_JUDGE_MODEL": "judge", "XDG_CONFIG_HOME": "/configs", "XDG_STATE_HOME": "/state"}) - def test_hands_no_variable_the_starter_lacks(self) -> None: - self.assertEqual(handed({"PATH": "/bin"}), {}) + def test_hands_an_xdg_variable_the_starter_lacks_as_empty_so_the_tmux_servers_value_moves_no_folder(self) -> None: + self.assertEqual(handed({"PATH": "/bin", "XDG_STATE_HOME": "/state"}), {"XDG_CONFIG_HOME": "", "XDG_STATE_HOME": "/state"}) class Starting(unittest.TestCase): diff --git a/bin/do_epic/test_main.py b/bin/do_epic/test_main.py index 59968dd1..ab4b4c77 100644 --- a/bin/do_epic/test_main.py +++ b/bin/do_epic/test_main.py @@ -146,7 +146,7 @@ class TheCommand(DoEpicTest): self.assertIn("started ABC-21 in the tmux session epic-ABC-12\n", out) self.assertIn("ABC-20 waits: it is a human's task\n", out) started = [args for args in fake.tmux_calls if args[0] == "new-session"] - self.assertEqual(started, [["new-session", "-d", "-s", "epic-ABC-12", "-n", "ABC-21", "-c", str(self.home / ".local/state/build-release/do-epic/ABC-12"), "-e", "BUILD_RELEASE_WORKER_MODEL=m", "-e", "CHUNK_PR_PARKS=1", "-P", "-F", "#{window_id}", "--", "/b/do-epic", "--chunk", "ABC-21", "ABC-12"]]) + self.assertEqual(started, [["new-session", "-d", "-s", "epic-ABC-12", "-n", "ABC-21", "-c", str(self.home / ".local/state/build-release/do-epic/ABC-12"), "-e", "BUILD_RELEASE_WORKER_MODEL=m", "-e", "XDG_CONFIG_HOME=", "-e", "XDG_STATE_HOME=", "-e", "CHUNK_PR_PARKS=1", "-P", "-F", "#{window_id}", "--", "/b/do-epic", "--chunk", "ABC-21", "ABC-12"]]) # The session is no checkout's, so nothing marks it as one's. self.assertNotIn(tmux.OWNER, [args[3] for args in fake.tmux_calls if args[0] == "set-option"]) diff --git a/bin/rule_hook/test_rule_hook.py b/bin/rule_hook/test_rule_hook.py index 805de0b8..261d9ba3 100644 --- a/bin/rule_hook/test_rule_hook.py +++ b/bin/rule_hook/test_rule_hook.py @@ -1268,6 +1268,10 @@ class Hook(unittest.TestCase): self.assertIn("Blocked by rule commit-title: title the commit as the project's config asks, `PAY-{id} - {summary}`", self.round_commit("Tidy").stderr) self.assertIn("Blocked by rule round-title-counts", self.round_commit("PAY-7 - Answer stability round 1: 0 🔴, 0 🟡 (0 misread); x").stderr) self.assertEqual(self.round_commit("PAY-7 - Answer stability round 1: 0 🔴, 1 🟡 (0 misread); x").returncode, 0) + pathlib.Path(self.repo, "todo.md").write_text("# todo\n") + plan = self.round_commit("PAY-7 - Tidy").stderr + self.assertIn("Blocked by rule todo-rank-check", plan) + self.assertNotIn("no config names the checkout", plan) def test_a_commit_on_a_branch_that_doesnt_fit_the_configs_branch_template_takes_a_bare_title(self): config = self.configured() / "config.toml"