From 4c741b12f7dc43b596f27348195ec5ffc3156943 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Fri, 13 Sep 2024 05:53:06 +0900 Subject: [PATCH] [CI] test_download: Test the new version available warning in `git cinnabar --version` --- CI/test_download.py | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/CI/test_download.py b/CI/test_download.py index 772da2e9..00c6c201 100644 --- a/CI/test_download.py +++ b/CI/test_download.py @@ -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 @@ -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 @@ -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