From 2761276ea6f7f77a039fbf7ded17895acf66e4c3 Mon Sep 17 00:00:00 2001 From: bea-claude Date: Fri, 2 Oct 2026 00:16:52 +0200 Subject: [PATCH] Update the bats suite for beplus CLI 2.x The suite had rotted against the current CLI: 9 of 27 tests failed. - 0.22.0, the "well-known old version", is no longer published (404); use 2.0.0, a past prod release with linux-x64 and macos-arm64 builds - beplus --version now prints a banner ("beplus CLI vX.Y.Z" + project details) instead of the bare version; cli_version extracts it - the reference resolver read the GitHub Releases API, which lists builds the mirror does not host and rate-limits unauthenticated CI runners; it now reads the same index be does (BE_RELEASE_INDEX_URL, default S3) Co-Authored-By: Claude Opus 5.5 --- test/tests.md | 2 +- test/tests/install-contents.bats | 6 +-- test/tests/install-options.bats | 20 ++++----- test/tests/install-reference-versions.bash | 6 +-- test/tests/install-versions.bats | 10 ++--- test/tests/run-which.bats | 52 +++++++++++----------- test/tests/shared-functions.bash | 14 +++++- test/tests/uninstall.bats | 6 +-- 8 files changed, 64 insertions(+), 52 deletions(-) diff --git a/test/tests.md b/test/tests.md index 56fd095..3d52ab7 100644 --- a/test/tests.md +++ b/test/tests.md @@ -40,7 +40,7 @@ to allow an insecure connection through the mitm proxy. `beplus` versions added to proxy cache (and used in tests): -* v0.22.0 +* v2.0.0 * latest ## Docker Tips diff --git a/test/tests/install-contents.bats b/test/tests/install-contents.bats index e7c0b30..ee2d731 100644 --- a/test/tests/install-contents.bats +++ b/test/tests/install-contents.bats @@ -11,7 +11,7 @@ function setup() { @test "install: contents" { - readonly TARGET_VERSION="0.22.0" + readonly TARGET_VERSION="2.0.0" setup_tmp_prefix [ ! -d "${BE_PREFIX}/be/versions" ] @@ -23,7 +23,7 @@ function setup() { # beplus [ -f "${BE_PREFIX}/bin/beplus" ] - output="$(beplus --version)" + output="$(beplus --version | cli_version)" assert_equal "${output}" "${TARGET_VERSION}" rm -rf "${TMP_PREFIX_DIR}" @@ -32,7 +32,7 @@ function setup() { @test "install: cache prefix" { readonly BE_CACHE_PREFIX="$(mktemp -d)" - readonly TARGET_VERSION="0.22.0" + readonly TARGET_VERSION="2.0.0" setup_tmp_prefix export BE_CACHE_PREFIX diff --git a/test/tests/install-options.bats b/test/tests/install-options.bats index e8c4bb2..209d98b 100644 --- a/test/tests/install-options.bats +++ b/test/tests/install-options.bats @@ -16,31 +16,31 @@ function teardown() { } -@test "be --download 0.22.0" { - be --download 0.22.0 - [ -d "${BE_PREFIX}/be/versions/beplus/0.22.0" ] +@test "be --download 2.0.0" { + be --download 2.0.0 + [ -d "${BE_PREFIX}/be/versions/beplus/2.0.0" ] [ ! -f "${BE_PREFIX}/bin/beplus" ] } -@test "be --quiet 0.22.0" { +@test "be --quiet 2.0.0" { # just checking option is allowed, not testing functionality - be --quiet 0.22.0 - output="$(beplus --version)" - assert_equal "${output}" "0.22.0" + be --quiet 2.0.0 + output="$(beplus --version | cli_version)" + assert_equal "${output}" "2.0.0" } # variations with i/install and latest/numeric @test "version variations # (2 installs)" { - local VERSION="0.22.0" + local VERSION="2.0.0" local LATEST_VERSION="$(display_remote_version latest)" be v${VERSION} - output="$("${BE_PREFIX}/bin/beplus" --version)" + output="$("${BE_PREFIX}/bin/beplus" --version | cli_version)" assert_equal "${output}" "${VERSION}" be "${LATEST_VERSION}" - output="$("${BE_PREFIX}/bin/beplus" --version)" + output="$("${BE_PREFIX}/bin/beplus" --version | cli_version)" assert_equal "${output}" "${LATEST_VERSION}" } diff --git a/test/tests/install-reference-versions.bash b/test/tests/install-reference-versions.bash index ddede01..d0b475f 100755 --- a/test/tests/install-reference-versions.bash +++ b/test/tests/install-reference-versions.bash @@ -5,8 +5,8 @@ # Run commands we want to cache downloads for. # Get index into cache for lookups of expected versions. Uncompressed. -curl --location --fail https://api.github.com/repos/beplus/cli/releases &> /dev/null +curl --location --fail https://beplus.s3.amazonaws.com/cli/releases.json &> /dev/null -# Using 0.22.0 as a well known old version (which is no longer getting updated so does not change) -sudo be --download 0.22.0 +# Using 2.0.0 as a well known old version (a past release, so it does not change) +sudo be --download 2.0.0 sudo be --download latest diff --git a/test/tests/install-versions.bats b/test/tests/install-versions.bats index 2016d47..936a449 100644 --- a/test/tests/install-versions.bats +++ b/test/tests/install-versions.bats @@ -18,15 +18,15 @@ function teardown() { # Testing version permutations in lsr tests -@test "be 0.22.0" { - be 0.22.0 - output="$(beplus --version)" - assert_equal "${output}" "0.22.0" +@test "be 2.0.0" { + be 2.0.0 + output="$(beplus --version | cli_version)" + assert_equal "${output}" "2.0.0" } @test "be latest" { be latest - output="$(beplus --version)" + output="$(beplus --version | cli_version)" assert_equal "${output}" "$(display_remote_version latest)" } diff --git a/test/tests/run-which.bats b/test/tests/run-which.bats index c10c577..4127ff5 100644 --- a/test/tests/run-which.bats +++ b/test/tests/run-which.bats @@ -9,7 +9,7 @@ function setup_file() { # fixed directory so can reuse the two installs tmpdir="${TMPDIR:-/tmp}" export BE_PREFIX="${tmpdir}/be/test/run-which" - be --download 0.22.0 + be --download 2.0.0 be --download latest # using "latest" for download tests with run and exec } @@ -20,26 +20,26 @@ function teardown_file() { @test "setupAll for run/which/exec # (2 installs)" { # Dummy test so setupAll displayed while running first setup - [ -d "${BE_PREFIX}/be/versions/beplus/0.22.0" ] + [ -d "${BE_PREFIX}/be/versions/beplus/2.0.0" ] } # be which -@test "be which 0.22.0" { - output="$(be which 0.22.0)" - assert_equal "$output" "${BE_PREFIX}/be/versions/beplus/0.22.0/beplus" +@test "be which 2.0.0" { + output="$(be which 2.0.0)" + assert_equal "$output" "${BE_PREFIX}/be/versions/beplus/2.0.0/beplus" } -@test "be which v0.22.0" { - output="$(be which v0.22.0)" - assert_equal "$output" "${BE_PREFIX}/be/versions/beplus/0.22.0/beplus" +@test "be which v2.0.0" { + output="$(be which v2.0.0)" + assert_equal "$output" "${BE_PREFIX}/be/versions/beplus/2.0.0/beplus" } -@test "be bin v0.22.0" { - output="$(be bin v0.22.0)" - assert_equal "$output" "${BE_PREFIX}/be/versions/beplus/0.22.0/beplus" +@test "be bin v2.0.0" { + output="$(be bin v2.0.0)" + assert_equal "$output" "${BE_PREFIX}/be/versions/beplus/2.0.0/beplus" } @test "be which latest" { @@ -51,31 +51,31 @@ function teardown_file() { # be run -@test "be run 0.22.0" { - output="$(be run 0.22.0 --version)" - assert_equal "$output" "0.22.0" +@test "be run 2.0.0" { + output="$(be run 2.0.0 --version | cli_version)" + assert_equal "$output" "2.0.0" } @test "be run latest" { - output="$(be run latest --version)" + output="$(be run latest --version | cli_version)" local LATEST_VERSION="$(display_remote_version latest)" assert_equal "$output" "${LATEST_VERSION}" } -@test "be use 0.22.0" { - output="$(be use 0.22.0 --version)" - assert_equal "$output" "0.22.0" +@test "be use 2.0.0" { + output="$(be use 2.0.0 --version | cli_version)" + assert_equal "$output" "2.0.0" } -@test "be as v0.22.0" { - output="$(be as 0.22.0 --version)" - assert_equal "$output" "0.22.0" +@test "be as v2.0.0" { + output="$(be as 2.0.0 --version | cli_version)" + assert_equal "$output" "2.0.0" } @test "be run --download latest" { be rm latest || true be run --download latest --version - output="$(be run latest --version)" + output="$(be run latest --version | cli_version)" local LATEST_VERSION="$(display_remote_version latest)" assert_equal "$output" "${LATEST_VERSION}" } @@ -83,13 +83,13 @@ function teardown_file() { # be exec -@test "be exec v0.22.0 beplus" { - output="$(be exec v0.22.0 beplus --version)" - assert_equal "$output" "0.22.0" +@test "be exec v2.0.0 beplus" { + output="$(be exec v2.0.0 beplus --version | cli_version)" + assert_equal "$output" "2.0.0" } @test "be exec latest" { - output="$(be exec latest beplus --version)" + output="$(be exec latest beplus --version | cli_version)" local LATEST_VERSION="$(display_remote_version latest)" assert_equal "$output" "${LATEST_VERSION}" } diff --git a/test/tests/shared-functions.bash b/test/tests/shared-functions.bash index 5046940..2f44a89 100644 --- a/test/tests/shared-functions.bash +++ b/test/tests/shared-functions.bash @@ -33,6 +33,16 @@ function setup_tmp_prefix() { export PATH="${BE_PREFIX}/bin:${PATH}" } +# +# Synopsis: beplus --version | cli_version +# The version a beplus binary reports, without the leading v. 2.x prints a banner whose first +# line is "beplus CLI vX.Y.Z", where older builds printed just the version. +# + +function cli_version() { + sed -n -E 's/^[[:space:]]*(beplus CLI )?v?([0-9]+\.[0-9]+\.[0-9]+[^[:space:]]*)[[:space:]]*$/\2/p' | head -n 1 +} + # # @todo Duplicate # Synopsis: is_numeric_version version @@ -106,7 +116,9 @@ function display_remote_version() { abort "invalid version '$1'" fi - local index_url="https://api.github.com/repos/beplus/cli/releases" + # The same index be reads: the GitHub Releases API lists builds the mirror does not host, and + # rate-limits unauthenticated callers such as CI runners. + local index_url="${BE_RELEASE_INDEX_URL:-https://beplus.s3.amazonaws.com/cli/releases.json}" local jq_release_filter='.[]' if [[ -n "${official_only}" ]]; then diff --git a/test/tests/uninstall.bats b/test/tests/uninstall.bats index 2c799ce..96266d0 100644 --- a/test/tests/uninstall.bats +++ b/test/tests/uninstall.bats @@ -14,13 +14,13 @@ function teardown() { } -@test "be uninstall (of 0.22.0)" { - be 0.22.0 +@test "be uninstall (of 2.0.0)" { + be 2.0.0 [ -f "${BE_PREFIX}/bin/beplus" ] # Check we get all the files if we uninstall and rm cache. echo y | be uninstall - be rm 0.22.0 + be rm 2.0.0 output="$(find "${BE_PREFIX}" -not -type d)" assert_equal "$output" "" }