Answer principles round 3: 0 🔴, 2 🟡; find docker past a launcher's own options, as for a mutation tool
This commit is contained in:
@@ -116,14 +116,15 @@ 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 "run-heavy" in names:
|
||||
if not names or "run-heavy" in names:
|
||||
return False
|
||||
start = next((i for i, name in enumerate(names) if name not in LAUNCHERS), len(names))
|
||||
if names[start:start + 1] == ["docker"]:
|
||||
subcommand = docker_subcommand(words[start + 1:])
|
||||
return subcommand in (["build"], ["buildx", "build"], ["compose", "build"]) or (subcommand[-1:] in (["run"], ["exec"]) and mutation_run(names[start + 1:]))
|
||||
# Past a launcher, the tool may follow the launcher's own options, as in uvx --with pytest mutmut run; without one, the command itself is the tool.
|
||||
return mutation_run(names[start:]) if start else bool(names) and names[0] in MUTATORS and mutation_run(names)
|
||||
# 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
|
||||
docker = next((i for i, name in enumerate(names) if name == "docker"), None) if launched else (0 if names[0] == "docker" else None)
|
||||
if docker is not None:
|
||||
subcommand = docker_subcommand(words[docker + 1:])
|
||||
return subcommand in (["build"], ["buildx", "build"], ["compose", "build"]) or (subcommand[-1:] in (["run"], ["exec"]) and mutation_run(names[docker + 1:]))
|
||||
return (launched or names[0] in MUTATORS) and mutation_run(names)
|
||||
|
||||
|
||||
def mutation_run(names: list[str]) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user