Skip to content

Commit

Permalink
Do not resolve tracked releases
Browse files Browse the repository at this point in the history
  • Loading branch information
larsevj committed Oct 25, 2024
1 parent 2b2d093 commit cfac1e7
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
5 changes: 3 additions & 2 deletions komodoenv/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ def main() -> None:
release = root / args.release

if not (release / "enable").is_file():
sys.exit(f"'{release !s}' is not a valid komodo release!")
msg = f"'{release !s}' is not a valid komodo release!"
raise ValueError(msg)

if not args.track:
release, track = resolve_release(
Expand All @@ -211,7 +212,7 @@ def main() -> None:
no_update=args.no_update,
)
else:
track = (root / args.track).resolve()
track = root / args.track
if not (release / "enable").is_file():
sys.exit(f"'{track !s}' is not a valid komodo release!")
destination = Path(args.destination).absolute()
Expand Down
8 changes: 5 additions & 3 deletions komodoenv/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ class KomodoenvUpdateNamespace(Namespace):
"""


def read_config() -> Dict[str, str]:
with open(Path(__file__).parents[2] / "komodoenv.conf", encoding="utf-8") as f:
def read_config(config_path: Path) -> Dict[str, str]:
with open(config_path, encoding="utf-8") as f:
lines = f.readlines()
config = {}
for line in lines:
Expand Down Expand Up @@ -463,7 +463,9 @@ def parse_args(args: List[str]) -> KomodoenvUpdateNamespace:
def main() -> None:
args = parse_args(sys.argv[1:])

config = read_config()
# kmd_env/root/bin/komodoenv-update
# kmd_env/komodoenv.conf
config = read_config(Path(__file__).parents[2] / "komodoenv.conf")
if not check_same_distro(config):
return

Expand Down
16 changes: 16 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from subprocess import PIPE, STDOUT, Popen, check_output

from komodoenv.__main__ import main as _main
from komodoenv.update import read_config


def bash(script):
Expand Down Expand Up @@ -124,6 +125,21 @@ def test_autodetect(komodo_root, tmp_path):
assert bash(script) == 0


def test_manual_tracking(komodo_root, tmp_path):
script = f"""\
source {komodo_root}/2030.01-py38/enable
{sys.executable} -m komodoenv --root={komodo_root} {tmp_path}/kenv --track stable
source {tmp_path}/kenv/enable
[[ $(which python) == "{tmp_path}/kenv/root/bin/python" ]]
komodoenv-update
"""
assert bash(script) == 0
assert (
read_config(tmp_path / "kenv" / "komodoenv.conf")["tracked-release"] == "stable"
)


def main(*args):
"""Convenience function because it looks nicer"""
sys.argv = ["komodoenv", *args]
Expand Down
18 changes: 18 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
from pathlib import Path

import komodoenv.__main__ as main
Expand Down Expand Up @@ -84,3 +85,20 @@ def test_resolve_no_update(komodo_root, expect, name):
)
assert release == tracked
assert release == komodo_root / expect


def test_no_enable_file(tmp_path):
(tmp_path / "some_release").mkdir()
sys.argv = [
"komodoenv",
"--root",
str(tmp_path),
"--release",
"some_release",
"--no-update",
"my_kenv",
]
with pytest.raises(
ValueError, match="'*/some_release' is not a valid komodo release!"
):
main.main()

0 comments on commit cfac1e7

Please sign in to comment.