Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
ruby-build
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ruby-build
Commits
f666e716
Commit
f666e716
authored
Aug 12, 2016
by
Mislav Marohnić
Committed by
GitHub
Aug 12, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #965 from yyuu/workaround-aria2c-stdout
`aria2c` doesn't support writing remote content to stdout
parents
1a37ab18
6baed1ff
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
112 additions
and
54 deletions
+112
-54
bin/ruby-build
+7
-2
test/build.bats
+2
-1
test/cache.bats
+13
-12
test/checksum.bats
+18
-18
test/fetch.bats
+17
-1
test/hooks.bats
+1
-0
test/mirror.bats
+20
-20
test/rbenv.bats
+1
-0
test/test_helper.bash
+33
-0
No files found.
bin/ruby-build
View file @
f666e716
...
...
@@ -313,11 +313,16 @@ http() {
}
http_head_aria2c
()
{
aria2c
--dry-run
${
ARIA2_OPTS
}
"
$1
"
>
&4 2>&1
aria2c
--dry-run
--no-conf
=
true
${
ARIA2_OPTS
}
"
$1
"
>
&4 2>&1
}
http_get_aria2c
()
{
aria2c
-o
"
${
2
:-
-
}
"
${
ARIA2_OPTS
}
"
$1
"
local
out
=
"
${
2
:-$(
mktemp
"out.XXXXXX"
)}
"
if
aria2c
--allow-overwrite
=
true
--no-conf
=
true
-o
"
${
out
}
"
${
ARIA2_OPTS
}
"
$1
"
>
&4
;
then
[
-n
"
$2
"
]
||
cat
"
${
out
}
"
else
false
fi
}
http_head_curl
()
{
...
...
test/build.bats
View file @
f666e716
...
...
@@ -8,9 +8,10 @@ export CC=cc
export -n RUBY_CONFIGURE_OPTS
setup() {
ensure_not_found_in_path aria2c
mkdir -p "$INSTALL_ROOT"
stub md5 false
stub
aria2c
false
stub
curl
false
}
executable() {
...
...
test/cache.bats
View file @
f666e716
...
...
@@ -3,27 +3,28 @@
load test_helper
export RUBY_BUILD_SKIP_MIRROR=1
export RUBY_BUILD_CACHE_PATH="$TMP/cache"
export RUBY_BUILD_
ARIA2
_OPTS=
export RUBY_BUILD_
CURL
_OPTS=
setup() {
ensure_not_found_in_path aria2c
mkdir "$RUBY_BUILD_CACHE_PATH"
}
@test "packages are saved to download cache" {
stub
aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2
"
stub
curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3
"
install_fixture definitions/without-checksum
assert_success
assert [ -e "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
unstub
aria2c
unstub
curl
}
@test "cached package without checksum" {
stub
aria2c
stub
curl
cp "${FIXTURE_ROOT}/package-1.0.0.tar.gz" "$RUBY_BUILD_CACHE_PATH"
...
...
@@ -32,13 +33,13 @@ setup() {
assert_success
assert [ -e "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
unstub
aria2c
unstub
curl
}
@test "cached package with valid checksum" {
stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
stub
aria2c
stub
curl
cp "${FIXTURE_ROOT}/package-1.0.0.tar.gz" "$RUBY_BUILD_CACHE_PATH"
...
...
@@ -48,7 +49,7 @@ setup() {
assert [ -x "${INSTALL_ROOT}/bin/package" ]
assert [ -e "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
unstub
aria2c
unstub
curl
unstub shasum
}
...
...
@@ -58,8 +59,8 @@ setup() {
local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
stub shasum true "echo invalid" "echo $checksum"
stub
aria2c "--dry-run
* : true" \
"-
o * https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$2
"
stub
curl "-*I
* : true" \
"-
q -o * -*S* https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3
"
touch "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz"
...
...
@@ -70,13 +71,13 @@ setup() {
assert [ -e "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
assert diff -q "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" "${FIXTURE_ROOT}/package-1.0.0.tar.gz"
unstub
aria2c
unstub
curl
unstub shasum
}
@test "nonexistent cache directory is ignored" {
stub
aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2
"
stub
curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3
"
export RUBY_BUILD_CACHE_PATH="${TMP}/nonexistent"
...
...
@@ -86,5 +87,5 @@ setup() {
assert [ -x "${INSTALL_ROOT}/bin/package" ]
refute [ -d "$RUBY_BUILD_CACHE_PATH" ]
unstub
aria2c
unstub
curl
}
test/checksum.bats
View file @
f666e716
...
...
@@ -3,107 +3,107 @@
load test_helper
export RUBY_BUILD_SKIP_MIRROR=1
export RUBY_BUILD_CACHE_PATH=
export RUBY_BUILD_
ARIA2
_OPTS=
export RUBY_BUILD_
CURL
_OPTS=
@test "package URL without checksum" {
stub
aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2
"
stub
curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3
"
install_fixture definitions/without-checksum
assert_success
assert [ -x "${INSTALL_ROOT}/bin/package" ]
unstub
aria2c
unstub
curl
}
@test "package URL with valid checksum" {
stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
stub
aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2
"
stub
curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3
"
install_fixture definitions/with-checksum
assert_success
assert [ -x "${INSTALL_ROOT}/bin/package" ]
unstub
aria2c
unstub
curl
unstub shasum
}
@test "package URL with invalid checksum" {
stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
stub
aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2
"
stub
curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3
"
install_fixture definitions/with-invalid-checksum
assert_failure
refute [ -f "${INSTALL_ROOT}/bin/package" ]
unstub
aria2c
unstub
curl
unstub shasum
}
@test "package URL with checksum but no shasum support" {
stub shasum false
stub
aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2
"
stub
curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3
"
install_fixture definitions/with-checksum
assert_success
assert [ -x "${INSTALL_ROOT}/bin/package" ]
unstub
aria2c
unstub
curl
unstub shasum
}
@test "package URL with valid md5 checksum" {
stub md5 true "echo 83e6d7725e20166024a1eb74cde80677"
stub
aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2
"
stub
curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3
"
install_fixture definitions/with-md5-checksum
assert_success
assert [ -x "${INSTALL_ROOT}/bin/package" ]
unstub
aria2c
unstub
curl
unstub md5
}
@test "package URL with md5 checksum but no md5 support" {
stub md5 false
stub
aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2
"
stub
curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3
"
install_fixture definitions/with-md5-checksum
assert_success
assert [ -x "${INSTALL_ROOT}/bin/package" ]
unstub
aria2c
unstub
curl
unstub md5
}
@test "package with invalid checksum" {
stub shasum true "echo invalid"
stub
aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2
"
stub
curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3
"
install_fixture definitions/with-checksum
assert_failure
refute [ -f "${INSTALL_ROOT}/bin/package" ]
unstub
aria2c
unstub
curl
unstub shasum
}
@test "existing tarball in build location is reused" {
stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
stub
aria2c
false
stub
curl
false
stub wget false
export -n RUBY_BUILD_CACHE_PATH
...
...
@@ -126,7 +126,7 @@ DEF
stub shasum true \
"echo invalid" \
"echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
stub
aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2
"
stub
curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3
"
export -n RUBY_BUILD_CACHE_PATH
export RUBY_BUILD_BUILD_PATH="${TMP}/build"
...
...
@@ -145,7 +145,7 @@ DEF
}
@test "package URL with checksum of unexpected length" {
stub
aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2
"
stub
curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3
"
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
...
...
test/fetch.bats
View file @
f666e716
...
...
@@ -3,14 +3,16 @@
load test_helper
export RUBY_BUILD_SKIP_MIRROR=1
export RUBY_BUILD_CACHE_PATH=
export RUBY_BUILD_ARIA2_OPTS=
setup() {
ensure_not_found_in_path aria2c
export RUBY_BUILD_BUILD_PATH="${TMP}/source"
mkdir -p "${RUBY_BUILD_BUILD_PATH}"
}
@test "failed download displays error message" {
stub
aria2c
false
stub
curl
false
install_fixture definitions/without-checksum
assert_failure
...
...
@@ -18,6 +20,20 @@ setup() {
assert_output_contains "error: failed to download package-1.0.0.tar.gz"
}
@test "using aria2c if available" {
stub aria2c "--allow-overwrite=true --no-conf=true -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"
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
unstub aria2c
}
@test "fetching from git repository" {
stub git "clone --depth 1 --branch master http://example.com/packages/package.git package-dev : mkdir package-dev"
...
...
test/hooks.bats
View file @
f666e716
...
...
@@ -3,6 +3,7 @@
load test_helper
setup() {
ensure_not_found_in_path aria2c
export RBENV_ROOT="${TMP}/rbenv"
export HOOK_PATH="${TMP}/i has hooks"
mkdir -p "$HOOK_PATH"
...
...
test/mirror.bats
View file @
f666e716
...
...
@@ -4,12 +4,12 @@ load test_helper
export RUBY_BUILD_SKIP_MIRROR=
export RUBY_BUILD_CACHE_PATH=
export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
export RUBY_BUILD_
ARIA2
_OPTS=
export RUBY_BUILD_
CURL
_OPTS=
@test "package URL without checksum bypasses mirror" {
stub shasum true
stub
aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2
"
stub
curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3
"
install_fixture definitions/without-checksum
echo "$output" >&2
...
...
@@ -17,21 +17,21 @@ export RUBY_BUILD_ARIA2_OPTS=
assert_success
assert [ -x "${INSTALL_ROOT}/bin/package" ]
unstub
aria2c
unstub
curl
unstub shasum
}
@test "package URL with checksum but no shasum support bypasses mirror" {
stub shasum false
stub
aria2c "-o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2
"
stub
curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3
"
install_fixture definitions/with-checksum
assert_success
assert [ -x "${INSTALL_ROOT}/bin/package" ]
unstub
aria2c
unstub
curl
unstub shasum
}
...
...
@@ -41,15 +41,15 @@ export RUBY_BUILD_ARIA2_OPTS=
local mirror_url="${RUBY_BUILD_MIRROR_URL}/$checksum"
stub shasum true "echo $checksum"
stub
aria2c "--dry-run
$mirror_url : true" \
"-
o * $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$2
"
stub
curl "-*I*
$mirror_url : true" \
"-
q -o * -*S* $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3
"
install_fixture definitions/with-checksum
assert_success
assert [ -x "${INSTALL_ROOT}/bin/package" ]
unstub
aria2c
unstub
curl
unstub shasum
}
...
...
@@ -59,15 +59,15 @@ export RUBY_BUILD_ARIA2_OPTS=
local mirror_url="${RUBY_BUILD_MIRROR_URL}/$checksum"
stub shasum true "echo $checksum"
stub
aria2c "--dry-run
$mirror_url : false" \
"-
o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2
"
stub
curl "-*I*
$mirror_url : false" \
"-
q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3
"
install_fixture definitions/with-checksum
assert_success
assert [ -x "${INSTALL_ROOT}/bin/package" ]
unstub
aria2c
unstub
curl
unstub shasum
}
...
...
@@ -77,9 +77,9 @@ export RUBY_BUILD_ARIA2_OPTS=
local mirror_url="${RUBY_BUILD_MIRROR_URL}/$checksum"
stub shasum true "echo invalid" "echo $checksum"
stub
aria2c "--dry-run
$mirror_url : true" \
"-
o * $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$2
" \
"-
o * http://example.com/* : cp $FIXTURE_ROOT/\${3##*/} \$2
"
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
"
install_fixture definitions/with-checksum
echo "$output" >&2
...
...
@@ -87,7 +87,7 @@ export RUBY_BUILD_ARIA2_OPTS=
assert_success
assert [ -x "${INSTALL_ROOT}/bin/package" ]
unstub
aria2c
unstub
curl
unstub shasum
}
...
...
@@ -97,15 +97,15 @@ export RUBY_BUILD_ARIA2_OPTS=
local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
stub shasum true "echo $checksum"
stub
aria2c "--dry-run
: true" \
"-
o * https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$2
" \
stub
curl "-*I*
: true" \
"-
q -o * -*S* https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3
" \
install_fixture definitions/with-checksum
assert_success
assert [ -x "${INSTALL_ROOT}/bin/package" ]
unstub
aria2c
unstub
curl
unstub shasum
}
...
...
@@ -115,7 +115,7 @@ export RUBY_BUILD_ARIA2_OPTS=
local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
stub shasum true "echo $checksum"
stub
aria2c "-o * https://cache.ruby-lang.org/* : cp $FIXTURE_ROOT/\${3##*/} \$2
"
stub
curl "-q -o * -*S* https://cache.ruby-lang.org/* : cp $FIXTURE_ROOT/\${5##*/} \$3
"
run_inline_definition <<DEF
install_package "package-1.0.0" "https://cache.ruby-lang.org/packages/package-1.0.0.tar.gz#ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" copy
...
...
@@ -124,6 +124,6 @@ DEF
assert_success
assert [ -x "${INSTALL_ROOT}/bin/package" ]
unstub
aria2c
unstub
curl
unstub shasum
}
test/rbenv.bats
View file @
f666e716
...
...
@@ -4,6 +4,7 @@ load test_helper
export RBENV_ROOT="${TMP}/rbenv"
setup() {
ensure_not_found_in_path aria2c
stub rbenv-hooks 'install : true'
stub rbenv-rehash 'true'
}
...
...
test/test_helper.bash
View file @
f666e716
...
...
@@ -9,6 +9,39 @@ if [ "$FIXTURE_ROOT" != "$BATS_TEST_DIRNAME/fixtures" ]; then
export
PATH
fi
remove_command_from_path
()
{
OLDIFS
=
"
${
IFS
}
"
local
cmd
=
"
$1
"
local
path
local
paths
=()
IFS
=
:
for
path
in
${
PATH
}
;
do
if
[
-e
"
${
path
}
/
${
cmd
}
"
]
;
then
local
tmp_path
=
"
$(
mktemp
-d
"
${
TMP
}
/path.XXXXX"
)
"
ln
-fs
"
${
path
}
"
/
*
"
${
tmp_path
}
"
rm
-f
"
${
tmp_path
}
/
${
cmd
}
"
paths[
"
${#
paths
[@]
}
"
]=
"
${
tmp_path
}
"
else
paths[
"
${#
paths
[@]
}
"
]=
"
${
path
}
"
fi
done
export
PATH
=
"
${
paths
[*]
}
"
IFS
=
"
${
OLDIFS
}
"
}
ensure_not_found_in_path
()
{
local
cmd
for
cmd
;
do
if
command
-v
"
${
cmd
}
"
1>/dev/null 2>&1
;
then
remove_command_from_path
"
${
cmd
}
"
fi
done
}
setup
()
{
ensure_not_found_in_path aria2c
}
teardown
()
{
rm
-fr
"
${
TMP
:?
}
"
/
*
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment