Skip to content

Commit

Permalink
[CI] test_download: Test the new version available warning in `git ci…
Browse files Browse the repository at this point in the history
…nnabar --version`
  • Loading branch information
glandium committed Sep 12, 2024
1 parent 703d847 commit 4c741b1
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions CI/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,13 @@ def __repr__(self):
)

def check_output(x, **kwargs):
extra_env = kwargs.pop("extra_env", {})
e = env
if extra_env:
e = e.copy()
e.update(extra_env)
result = checked_call(
subprocess.check_output, x, env=env, cwd=cwd, text=True, **kwargs
subprocess.check_output, x, env=e, cwd=cwd, text=True, **kwargs
)
if isinstance(result, subprocess.CalledProcessError):
result.__class__ = CalledProcessError
Expand Down Expand Up @@ -225,11 +230,32 @@ def get_pkg():
Result(get_version, [git_cinnabar_v, "-V"]),
v,
)
version = Result(get_version, [git_cinnabar_v, "--version"])
version = Result(
get_version,
[git_cinnabar_v, "--version"],
extra_env={"GIT_CINNABAR_CHECK": ""},
stderr=subprocess.STDOUT,
)
new_version_warning = ""
# Starting with version 0.7.0beta1, a warning is shown when there is a
# new version available. Unfortunately, 0.7.0beta1 has a bug that makes
# it believe there's always an update even if it's the last version.
if (
"." in t
and tuple(int(x) for x in t.split(".")[:2]) >= (0, 7)
and (t != last_tag or t == "0.7.0beta1")
):
new_version = t.replace("b", "-b").replace("rc", "-rc")
new_version_warning = (
f"\n\nWARNING New git-cinnabar version available: {new_version} (current version: {v})"
"\n\nWARNING You may run `git cinnabar self-update` to update."
)

loop_status += assert_eq(
version,
full_versions[t],
full_versions[t] + new_version_warning,
)

status += loop_status
if not loop_status:
continue
Expand All @@ -244,7 +270,6 @@ def get_pkg():
extra_args = []
if branch:
extra_args += ["--branch", branch]
# 0.7.0beta1 has a bug that makes it believe there's always an update even if it's the last version.
if (
branch in (None, "release")
and t == last_tag
Expand Down

0 comments on commit 4c741b1

Please sign in to comment.