Skip to content

Commit

Permalink
Merge pull request #2230 from rbenv/output-redesign
Browse files Browse the repository at this point in the history
Restructure console output
  • Loading branch information
mislav committed Nov 7, 2023
2 parents 3c50596 + e320bdf commit 8e2662f
Show file tree
Hide file tree
Showing 8 changed files with 287 additions and 274 deletions.
473 changes: 252 additions & 221 deletions bin/ruby-build

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions test/build.bats
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,7 @@ OUT
stub bundle \
'--version : echo 1' \
' : echo bundle "$@" >> build.log' \
'--version : echo 1' \
" exec rake install : { cat build.log; echo bundle \"\$@\"; } >> '$INSTALL_ROOT/build.log'"
"exec rake install : { cat build.log; echo bundle \"\$@\"; } >> '$INSTALL_ROOT/build.log'"

run_inline_definition <<DEF
install_package "rubinius-2.0.0" "http://releases.rubini.us/rubinius-2.0.0.tar.gz" rbx
Expand Down
6 changes: 3 additions & 3 deletions test/cache.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export RUBY_BUILD_SKIP_MIRROR=1
export RUBY_BUILD_CACHE_PATH="$TMP/cache"

@test "packages are saved to download cache" {
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
stub curl "-q -fL -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"

mkdir -p "$RUBY_BUILD_CACHE_PATH"
install_fixture definitions/without-checksum
Expand Down Expand Up @@ -56,7 +56,7 @@ export RUBY_BUILD_CACHE_PATH="$TMP/cache"

stub shasum true "echo invalid" "echo $checksum"
stub curl "-*I* : true" \
"-q -o * -*S* https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3"
"-q -fL -o * https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$4"

mkdir -p "$RUBY_BUILD_CACHE_PATH"
touch "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz"
Expand All @@ -74,7 +74,7 @@ export RUBY_BUILD_CACHE_PATH="$TMP/cache"


@test "nonexistent cache directory is ignored" {
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
stub curl "-q -fL -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"

export RUBY_BUILD_CACHE_PATH="${TMP}/nonexistent"

Expand Down
18 changes: 9 additions & 9 deletions test/checksum.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export RUBY_BUILD_CACHE_PATH=


@test "package URL without checksum" {
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
stub curl "-q -fL -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"

install_fixture definitions/without-checksum

Expand All @@ -19,7 +19,7 @@ export RUBY_BUILD_CACHE_PATH=

@test "package URL with valid checksum" {
stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
stub curl "-q -fL -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"

install_fixture definitions/with-checksum

Expand All @@ -33,7 +33,7 @@ export RUBY_BUILD_CACHE_PATH=

@test "package URL with invalid checksum" {
stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
stub curl "-q -fL -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"

install_fixture definitions/with-invalid-checksum

Expand All @@ -47,7 +47,7 @@ export RUBY_BUILD_CACHE_PATH=

@test "package URL with checksum but no shasum support" {
stub shasum false
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
stub curl "-q -fL -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"

install_fixture definitions/with-checksum

Expand All @@ -61,7 +61,7 @@ export RUBY_BUILD_CACHE_PATH=

@test "package URL with valid md5 checksum" {
stub md5 true "echo 83e6d7725e20166024a1eb74cde80677"
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
stub curl "-q -fL -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"

install_fixture definitions/with-md5-checksum

Expand All @@ -75,7 +75,7 @@ export RUBY_BUILD_CACHE_PATH=

@test "package URL with md5 checksum but no md5 support" {
stub md5 false
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
stub curl "-q -fL -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"

install_fixture definitions/with-md5-checksum

Expand All @@ -89,7 +89,7 @@ export RUBY_BUILD_CACHE_PATH=

@test "package with invalid checksum" {
stub shasum true "echo invalid"
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
stub curl "-q -fL -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"

install_fixture definitions/with-checksum

Expand Down Expand Up @@ -125,7 +125,7 @@ DEF
stub shasum true \
"echo invalid" \
"echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
stub curl "-q -fL -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"

export -n RUBY_BUILD_CACHE_PATH
export RUBY_BUILD_BUILD_PATH="${TMP}/build"
Expand All @@ -144,7 +144,7 @@ DEF
}

@test "package URL with checksum of unexpected length" {
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
stub curl "-q -fL -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"

run_inline_definition <<DEF
install_package "package-1.0.0" "http://example.com/packages/package-1.0.0.tar.gz#checksum_of_unexpected_length" copy
Expand Down
11 changes: 6 additions & 5 deletions test/compiler.bats
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,22 @@ export -n RUBY_CONFIGURE_OPTS
stub_repeated uname '-s : echo Darwin'
stub sw_vers '-productVersion : echo 10.10'
stub_repeated brew 'false'
stub_repeated make 'echo "make $(inspect_args "$@")"'
# shellcheck disable=SC2016
stub_repeated make 'echo "make $(inspect_args "$@")" >> build.log'

cat > ./configure <<CON
#!${BASH}
echo ./configure "\$@"
echo CC=\$CC
echo CFLAGS=\${CFLAGS-no}
echo ./configure "\$@" > build.log
echo CC=\$CC >> build.log
echo CFLAGS=\${CFLAGS-no} >> build.log
CON
chmod +x ./configure

run_inline_definition <<DEF
exec 4<&1
build_package_standard ruby
DEF
assert_success
run cat build.log
assert_output <<OUT
./configure --prefix=$INSTALL_ROOT
CC=clang
Expand Down
22 changes: 4 additions & 18 deletions test/fetch.bats
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ setup() {

install_fixture definitions/without-checksum
assert_failure
assert_output_contains "> http://example.com/packages/package-1.0.0.tar.gz"
assert_output_contains "error: failed to download package-1.0.0.tar.gz"
}

Expand All @@ -30,16 +29,11 @@ setup() {
@test "using aria2c if available" {
export RUBY_BUILD_ARIA2_OPTS=
export -n RUBY_BUILD_HTTP_CLIENT
stub aria2c "--allow-overwrite=true --no-conf=true -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"
stub aria2c "--allow-overwrite=true --no-conf=true --console-log-level=warn --stderr -o * http://example.com/* : cp $FIXTURE_ROOT/\${7##*/} \$6"

install_fixture definitions/without-checksum
assert_success
assert_output <<OUT
Downloading package-1.0.0.tar.gz...
-> http://example.com/packages/package-1.0.0.tar.gz
Installing package-1.0.0...
Installed package-1.0.0 to ${TMP}/install
OUT
assert_output_contains "Downloading package-1.0.0.tar.gz..."
unstub aria2c
}

Expand All @@ -50,11 +44,7 @@ OUT
install_git "package-dev" "http://example.com/packages/package.git" master copy
DEF
assert_success
assert_output <<OUT
Cloning http://example.com/packages/package.git...
Installing package-dev...
Installed package-dev to ${TMP}/install
OUT
assert_output_contains "Cloning http://example.com/packages/package.git..."
unstub git
}

Expand All @@ -68,10 +58,6 @@ OUT
install_git "package-dev" "http://example.com/packages/package.git" master copy
DEF
assert_success
assert_output <<OUT
Cloning http://example.com/packages/package.git...
Installing package-dev...
Installed package-dev to ${TMP}/install
OUT
assert_output_contains "Cloning http://example.com/packages/package.git..."
unstub git
}
27 changes: 12 additions & 15 deletions test/mirror.bats
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com

@test "package URL without checksum bypasses mirror" {
stub shasum true
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
stub curl "-q -fL -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"

install_fixture definitions/without-checksum
echo "$output" >&2

assert_success
assert [ -x "${INSTALL_ROOT}/bin/package" ]
Expand All @@ -23,7 +22,7 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com

@test "package URL with checksum but no shasum support bypasses mirror" {
stub shasum false
stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
stub curl "-q -fL -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"

install_fixture definitions/with-checksum

Expand All @@ -41,7 +40,7 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com

stub shasum true "echo $checksum"
stub curl "-*I* $mirror_url : true" \
"-q -o * -*S* $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3"
"-q -fL -o * $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$4"

install_fixture definitions/with-checksum

Expand All @@ -59,7 +58,7 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com

stub shasum true "echo $checksum"
stub curl "-*I* $mirror_url : false" \
"-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
"-q -fL -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"

install_fixture definitions/with-checksum

Expand All @@ -77,11 +76,10 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com

stub shasum true "echo invalid" "echo $checksum"
stub curl "-*I* $mirror_url : true" \
"-q -o * -*S* $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" \
"-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
"-q -fL -o * $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$4" \
"-q -fL -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"

install_fixture definitions/with-checksum
echo "$output" >&2

assert_success
assert [ -x "${INSTALL_ROOT}/bin/package" ]
Expand All @@ -97,7 +95,7 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com

stub shasum true "echo $checksum"
stub curl "-*I* : true" \
"-q -o * -*S* https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" \
"-q -fL -o * https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$4" \

install_fixture definitions/with-checksum

Expand All @@ -114,7 +112,7 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"

stub shasum true "echo $checksum"
stub curl "-q -o * -*S* https://cache.ruby-lang.org/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
stub curl "-q -fL -o * https://cache.ruby-lang.org/* : cp $FIXTURE_ROOT/\${5##*/} \$4"

run_inline_definition <<DEF
install_package "package-1.0.0" "https://cache.ruby-lang.org/packages/package-1.0.0.tar.gz#ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" copy
Expand All @@ -135,7 +133,7 @@ DEF

stub shasum true "echo $checksum"
stub curl "-*I* $RUBY_BUILD_MIRROR_PACKAGE_URL : true" \
"-q -o * -*S* $RUBY_BUILD_MIRROR_PACKAGE_URL : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3"
"-q -fL -o * $RUBY_BUILD_MIRROR_PACKAGE_URL : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$4"

install_fixture definitions/with-checksum

Expand All @@ -154,7 +152,7 @@ DEF

stub shasum true "echo $checksum"
stub curl "-*I* $RUBY_BUILD_MIRROR_PACKAGE_URL : false" \
"-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
"-q -fL -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"

install_fixture definitions/with-checksum

Expand All @@ -173,11 +171,10 @@ DEF

stub shasum true "echo invalid" "echo $checksum"
stub curl "-*I* $RUBY_BUILD_MIRROR_PACKAGE_URL : true" \
"-q -o * -*S* $RUBY_BUILD_MIRROR_PACKAGE_URL : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3" \
"-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3"
"-q -fL -o * $RUBY_BUILD_MIRROR_PACKAGE_URL : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$4" \
"-q -fL -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"

install_fixture definitions/with-checksum
echo "$output" >&2

assert_success
assert [ -x "${INSTALL_ROOT}/bin/package" ]
Expand Down
1 change: 0 additions & 1 deletion test/test_helper.bash
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export TMP="$BATS_TMPDIR"/ruby-build-test
export RUBY_BUILD_CURL_OPTS=
export RUBY_BUILD_HTTP_CLIENT="curl"
export RUBY_BUILD_TESTING=true

if [ "$FIXTURE_ROOT" != "$BATS_TEST_DIRNAME/fixtures" ]; then
export FIXTURE_ROOT="$BATS_TEST_DIRNAME/fixtures"
Expand Down

0 comments on commit 8e2662f

Please sign in to comment.