feat: add domain model foundation
This commit is contained in:
@@ -88,7 +88,27 @@ def discover_commands(root: Path) -> list[str]:
|
||||
return load_cmake_commands(root)
|
||||
|
||||
|
||||
def resolve_validation_command(command: str) -> str:
|
||||
parts = command.split(maxsplit=1)
|
||||
if not parts:
|
||||
return command
|
||||
|
||||
tool = parts[0].lower()
|
||||
if tool not in {"cmake", "ctest"}:
|
||||
return command
|
||||
if shutil.which(tool) is not None:
|
||||
return command
|
||||
|
||||
exe = COMMON_CMAKE_BIN / f"{tool}.exe"
|
||||
if not exe.exists():
|
||||
return command
|
||||
|
||||
suffix = f" {parts[1]}" if len(parts) > 1 else ""
|
||||
return f'"{exe}"{suffix}'
|
||||
|
||||
|
||||
def run_command(command: str, root: Path) -> subprocess.CompletedProcess:
|
||||
command = resolve_validation_command(command)
|
||||
return subprocess.run(
|
||||
command,
|
||||
cwd=root,
|
||||
@@ -103,17 +123,25 @@ def run_command(command: str, root: Path) -> subprocess.CompletedProcess:
|
||||
|
||||
def validation_environment(base_env: os._Environ | dict[str, str]) -> dict[str, str]:
|
||||
env = dict(base_env)
|
||||
if shutil.which("cmake") is not None:
|
||||
path_key = "Path" if os.name == "nt" else "PATH"
|
||||
path_values = []
|
||||
for key in list(env):
|
||||
if key.lower() == "path":
|
||||
path_values.append(env.pop(key))
|
||||
|
||||
current_path = os.pathsep.join(part for part in path_values if part)
|
||||
env[path_key] = current_path
|
||||
|
||||
if shutil.which("cmake", path=current_path) is not None:
|
||||
return env
|
||||
cmake_exe = COMMON_CMAKE_BIN / "cmake.exe"
|
||||
if not cmake_exe.exists():
|
||||
return env
|
||||
|
||||
current_path = env.get("PATH", "")
|
||||
paths = [part for part in current_path.split(os.pathsep) if part]
|
||||
common_bin_text = str(COMMON_CMAKE_BIN)
|
||||
if not any(part.lower() == common_bin_text.lower() for part in paths):
|
||||
env["PATH"] = common_bin_text + (os.pathsep + current_path if current_path else "")
|
||||
env[path_key] = common_bin_text + (os.pathsep + current_path if current_path else "")
|
||||
return env
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user