IQ.Pilot Release Commit @ 92b3bb6
This commit is contained in:
@@ -154,7 +154,11 @@ iq_pkg() {
|
||||
# the venv python has the component packages (iqdbc etc.); bare python3 does not
|
||||
local py=python3
|
||||
[[ -x "$IQ_ROOT/.venv/bin/python3" ]] && py="$IQ_ROOT/.venv/bin/python3"
|
||||
(cd "$IQ_ROOT" && iq_run "$py" iqpilot/tools/scripts/setup_private_packages.py "$@")
|
||||
if [[ -f "$IQ_ROOT/iqpilot/tools/scripts/setup_private_packages.py" ]]; then
|
||||
(cd "$IQ_ROOT" && iq_run "$py" iqpilot/tools/scripts/setup_private_packages.py "$@")
|
||||
else
|
||||
iq_note 'private package sources are not present in this checkout'
|
||||
fi
|
||||
if [[ -f "$IQ_ROOT/artifacts/runtime/ensure_private_installed.sh" ]]; then
|
||||
(cd "$IQ_ROOT" && iq_run bash artifacts/runtime/ensure_private_installed.sh)
|
||||
fi
|
||||
|
||||
66
iqpilot/tools/tests/test_iq_command.py
Normal file
66
iqpilot/tools/tests/test_iq_command.py
Normal file
@@ -0,0 +1,66 @@
|
||||
# Copyright © IQ.Lvbs, apart of Project Teal Lvbs, All Rights Reserved, licensed under https://konn3kt.com/tos
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
|
||||
|
||||
IQ_COMMAND = Path(__file__).parents[1] / "iq.sh"
|
||||
|
||||
|
||||
def make_checkout(tmp_path: Path) -> Path:
|
||||
checkout = tmp_path / "checkout"
|
||||
(checkout / "iqpilot").mkdir(parents=True)
|
||||
(checkout / "launch_iqpilot.sh").touch()
|
||||
return checkout
|
||||
|
||||
|
||||
def run_pkg(checkout: Path, path: Path) -> subprocess.CompletedProcess[str]:
|
||||
env = os.environ.copy()
|
||||
env["PATH"] = f"{path}:{env['PATH']}"
|
||||
return subprocess.run(
|
||||
["bash", str(IQ_COMMAND), "--dir", str(checkout), "pkg"],
|
||||
check=False,
|
||||
capture_output=True,
|
||||
env=env,
|
||||
text=True,
|
||||
)
|
||||
|
||||
|
||||
def test_public_checkout_skips_private_package_source_setup(tmp_path: Path):
|
||||
checkout = make_checkout(tmp_path)
|
||||
|
||||
result = run_pkg(checkout, tmp_path)
|
||||
|
||||
assert result.returncode == 0
|
||||
assert "private package sources are not present" in result.stdout
|
||||
assert "setup_private_packages.py" not in result.stderr
|
||||
|
||||
|
||||
def test_internal_checkout_runs_private_package_source_setup(tmp_path: Path):
|
||||
checkout = make_checkout(tmp_path)
|
||||
setup_script = checkout / "iqpilot/tools/scripts/setup_private_packages.py"
|
||||
setup_script.parent.mkdir(parents=True)
|
||||
setup_script.touch()
|
||||
python_log = tmp_path / "python.log"
|
||||
python = tmp_path / "python3"
|
||||
python.write_text(f"#!/usr/bin/env bash\nprintf '%s\\n' \"$*\" > {python_log!s}\n")
|
||||
python.chmod(0o755)
|
||||
|
||||
result = run_pkg(checkout, tmp_path)
|
||||
|
||||
assert result.returncode == 0
|
||||
assert python_log.read_text().strip() == "iqpilot/tools/scripts/setup_private_packages.py"
|
||||
|
||||
|
||||
def test_public_checkout_runs_bundled_package_installer(tmp_path: Path):
|
||||
checkout = make_checkout(tmp_path)
|
||||
installer_log = tmp_path / "installer.log"
|
||||
installer = checkout / "artifacts/runtime/ensure_private_installed.sh"
|
||||
installer.parent.mkdir(parents=True)
|
||||
installer.write_text(f"printf installed > {installer_log!s}\n")
|
||||
|
||||
result = run_pkg(checkout, tmp_path)
|
||||
|
||||
assert result.returncode == 0
|
||||
assert installer_log.read_text() == "installed"
|
||||
Reference in New Issue
Block a user