From ed7f3eb949b84213936f97029c0a1e4efe96dbb6 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 8 Nov 2026 11:14:13 +0100 Subject: [PATCH] =?UTF-8?q?Answer=20stability=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=203=20=F0=9F=9F=A1=20(0=20misread);=20drop=20the?= =?UTF-8?q?=20duplicate=20predicate=20test,=20say=20that=20finds=5Fthis=5F?= =?UTF-8?q?docker=20assumes=20run-heavy's=20PATH,=20say=20why=20resets=5Fp?= =?UTF-8?q?ath=20matches=20broadly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/run_heavy/capped_docker.py | 4 ++-- bin/run_heavy/test_run_heavy.py | 9 --------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/bin/run_heavy/capped_docker.py b/bin/run_heavy/capped_docker.py index 77b99d11..b253d9df 100644 --- a/bin/run_heavy/capped_docker.py +++ b/bin/run_heavy/capped_docker.py @@ -37,10 +37,10 @@ def without_path_entry(path: str) -> str: def finds_this_docker(word: str, before: list[str]) -> bool: - """Whether a command that runs under run-heavy reaches this docker, given the word that names docker and the words before it: docker named bare, since a path names another, and no word before it resets the PATH that run-heavy set. Only where run-heavy knows the memory, as on Linux.""" + """Whether a command's docker is this one, given the word that names docker and the words before it, assuming run-heavy put this docker first on PATH, as it does on Linux. It is where docker is named bare, since a path names a different docker, and no word before it may reset PATH.""" return word == "docker" and not any(resets_path(earlier) for earlier in before) def resets_path(word: str) -> bool: - """Whether a word before docker drops the PATH run-heavy set: a PATH= of its own, env's -i or -u, or sudo or doas, which reset it.""" + """Whether a word before docker may drop the PATH run-heavy set. It errs towards yes, so that a command it matches must set its own memory limits: it matches a PATH= assignment, -i, --ignore-environment, -u or --unset whichever variable and launcher they belong to, and sudo or doas, which reset PATH.""" return word.startswith(("PATH=", "--unset")) or word in ("-i", "--ignore-environment", "-u") or tool_name(word) in ("doas", "sudo") diff --git a/bin/run_heavy/test_run_heavy.py b/bin/run_heavy/test_run_heavy.py index 3a9a158a..f028d6b7 100644 --- a/bin/run_heavy/test_run_heavy.py +++ b/bin/run_heavy/test_run_heavy.py @@ -9,7 +9,6 @@ import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) -from run_heavy.capped_docker import finds_this_docker from run_heavy import main from machine_load.memory import read_memory from machine_load.slots import slot_count, usable_cpus @@ -142,14 +141,6 @@ class RunHeavy(unittest.TestCase): self.assertEqual(helped.returncode, 0) self.assertIn("usage: run-heavy ", helped.stdout) - def test_the_capped_docker_is_found_only_by_docker_named_bare_with_no_word_before_it_resetting_path(self): - for word, before in [("docker", []), ("docker", ["run-heavy"]), ("docker", ["run-heavy", "env", "X=1"]), ("docker", ["run-heavy", "nice", "-n", "19"])]: - with self.subTest(word=word, before=before): - self.assertTrue(finds_this_docker(word, before)) - for word, before in [("/usr/bin/docker", []), ("docker", ["env", "PATH=/usr/bin"]), ("docker", ["env", "-i"]), ("docker", ["env", "-u", "PATH"]), ("docker", ["env", "--unset=PATH"]), ("docker", ["sudo"]), ("docker", ["/usr/bin/doas"])]: - with self.subTest(word=word, before=before): - self.assertFalse(finds_this_docker(word, before)) - if __name__ == "__main__": unittest.main()