Answer product-owner round 1: 0 🔴, 0 🟡; name the slot folder and fuser in the wait message, keep help calls light, and give the reviewer's suite the long timeout
This commit is contained in:
@@ -103,6 +103,8 @@ class Outcome:
|
||||
LAUNCHERS = frozenset({"bunx", "env", "nice", "npx", "pipx", "pnpm", "time", "uvx", "yarn"})
|
||||
# Each mutation tool, and the word of which one must follow it within two words for its call to be a mutation run; an empty set makes every call one.
|
||||
MUTATORS = {"cargo": {"mutants"}, "infection": set(), "mutmut": {"run"}, "stryker": {"run"}}
|
||||
# Flags that only print, so the call that carries one is light whatever tool it names.
|
||||
LIGHT_FLAGS = frozenset({"--help", "--list", "--version", "-h"})
|
||||
# The options of docker and docker compose that take a value, so the value is not read as a subcommand.
|
||||
DOCKER_VALUED = frozenset({"--ansi", "--config", "--context", "--env-file", "--file", "--host", "--log-level", "--parallel", "--profile", "--progress", "--project-directory", "--project-name", "-c", "-f", "-H", "-l", "-p"})
|
||||
|
||||
@@ -116,7 +118,7 @@ def tool_name(word: str) -> str:
|
||||
def heavy(words: list[str]) -> bool:
|
||||
"""Whether the simple command runs a docker build, or a mutation run directly, through a launcher or in a container, outside run-heavy."""
|
||||
names = [tool_name(word) for word in words]
|
||||
if not names or "run-heavy" in names:
|
||||
if not names or "run-heavy" in names or LIGHT_FLAGS & set(words):
|
||||
return False
|
||||
# Past a launcher, the tool may follow the launcher's own options and assignments, as in nice -n 19 docker build or uvx --with pytest mutmut run; without one, the command itself is the tool.
|
||||
launched = names[0] in LAUNCHERS
|
||||
|
||||
@@ -111,7 +111,7 @@ class CommandBreaches(unittest.TestCase):
|
||||
self.assertEqual(checked(command), ["run-heavy"])
|
||||
|
||||
def test_a_heavy_command_under_run_heavy_or_a_light_docker_or_mutmut_call_passes(self):
|
||||
for command in ["~/.claude/bin/run-heavy docker build -t x .", "/home/me/.claude/bin/run-heavy uvx mutmut run", "nice -n 19 ~/.claude/bin/run-heavy docker build .", "env X=1 run-heavy docker compose run app mutmut run", "docker images", "docker compose run --rm app go vet", "docker compose run app make build", "uvx 'mutmut>=3,<4' results", "echo docker build", "npx prettier --check infection.json5", "echo mutmut run", "env"]:
|
||||
for command in ["~/.claude/bin/run-heavy docker build -t x .", "/home/me/.claude/bin/run-heavy uvx mutmut run", "nice -n 19 ~/.claude/bin/run-heavy docker build .", "env X=1 run-heavy docker compose run app mutmut run", "docker images", "docker compose run --rm app go vet", "docker compose run app make build", "uvx 'mutmut>=3,<4' results", "echo docker build", "npx prettier --check infection.json5", "echo mutmut run", "env", "docker build --help", "cargo mutants --list", "infection --version"]:
|
||||
with self.subTest(command):
|
||||
self.assertEqual(checked(command), [])
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ def held_slot(folder: pathlib.Path, slots: int) -> int | Failure:
|
||||
"""The number of the slot this call holds, its lock left for the command to inherit, or why no slot could be taken."""
|
||||
try:
|
||||
folder.mkdir(parents=True, exist_ok=True)
|
||||
slot, fd = waited_slot(folder, slots, lambda: print(f"run-heavy: waiting for one of the machine's {slots} heavy slots", file=sys.stderr, flush=True))
|
||||
slot, fd = waited_slot(folder, slots, lambda: print(f"run-heavy: waiting for one of the machine's {slots} heavy slots in {folder}; `fuser {folder}/slot-*` names the processes that hold them", file=sys.stderr, flush=True))
|
||||
except OSError as failure:
|
||||
return Failure(f"cannot take a heavy slot in {folder}: {failure.strerror}")
|
||||
# The command inherits the locked file, so the slot stays held until it exits.
|
||||
|
||||
Reference in New Issue
Block a user