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
d924fcee
Commit
d924fcee
authored
Nov 19, 2012
by
Sam Stephenson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test package cache
parent
d999db78
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
95 additions
and
5 deletions
+95
-5
bin/ruby-build
+5
-5
test/cache.bats
+89
-0
test/test_helper.bash
+1
-0
No files found.
bin/ruby-build
View file @
d924fcee
...
@@ -147,9 +147,9 @@ verify_checksum() {
...
@@ -147,9 +147,9 @@ verify_checksum() {
# If there's no MD5 support, return success
# If there's no MD5 support, return success
[
-n
"
$HAS_MD5_SUPPORT
"
]
||
return
0
[
-n
"
$HAS_MD5_SUPPORT
"
]
||
return
0
# If the specified filename doesn't exist, return
failure
# If the specified filename doesn't exist, return
success
local
filename
=
"
$1
"
local
filename
=
"
$1
"
[
-e
"
$filename
"
]
||
return
1
[
-e
"
$filename
"
]
||
return
0
# If there's no expected checksum, return success
# If there's no expected checksum, return success
local
expected_checksum
=
"
$2
"
local
expected_checksum
=
"
$2
"
...
@@ -236,9 +236,9 @@ symlink_tarball_from_cache() {
...
@@ -236,9 +236,9 @@ symlink_tarball_from_cache() {
local
cached_package_filename
=
"
${
RUBY_BUILD_CACHE_PATH
}
/
$package_filename
"
local
cached_package_filename
=
"
${
RUBY_BUILD_CACHE_PATH
}
/
$package_filename
"
local
checksum
=
"
$2
"
local
checksum
=
"
$2
"
{
verify_checksum
"
$cached_package_filename
"
"
$checksum
"
[
-e
"
$cached_package_filename
"
]
||
return
1
ln
-s
"
$cached_package_filename
"
"
$package_filename
"
verify_checksum
"
$cached_package_filename
"
"
$checksum
"
>
&4 2>&1
||
return
1
}
>
&4 2>&1
||
return
1
ln
-s
"
$cached_package_filename
"
"
$package_filename
"
>
&4 2>&1
||
return
1
}
}
download_tarball
()
{
download_tarball
()
{
...
...
test/cache.bats
0 → 100644
View file @
d924fcee
#!/usr/bin/env bats
load test_helper
export RUBY_BUILD_SKIP_MIRROR=1
export RUBY_BUILD_CACHE_PATH="$TMP/cache"
setup() {
mkdir "$RUBY_BUILD_CACHE_PATH"
}
@test "packages are saved to download cache" {
stub md5 true
stub curl "-*S* : cat package-1.0.0.tar.gz"
install_fixture definitions/without-checksum
[ "$status" -eq 0 ]
[ -e "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
unstub curl
unstub md5
}
@test "cached package without checksum" {
stub md5 true
stub curl
cp "${FIXTURE_ROOT}/package-1.0.0.tar.gz" "$RUBY_BUILD_CACHE_PATH"
install_fixture definitions/without-checksum
[ "$status" -eq 0 ]
[ -e "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
unstub curl
unstub md5
}
@test "cached package with valid checksum" {
stub md5 true "echo 83e6d7725e20166024a1eb74cde80677"
stub curl
cp "${FIXTURE_ROOT}/package-1.0.0.tar.gz" "$RUBY_BUILD_CACHE_PATH"
install_fixture definitions/with-checksum
[ "$status" -eq 0 ]
[ -x "${INSTALL_ROOT}/bin/package" ]
[ -e "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
unstub curl
unstub md5
}
@test "cached package with invalid checksum falls back to mirror and updates cache" {
export RUBY_BUILD_SKIP_MIRROR=
local checksum="83e6d7725e20166024a1eb74cde80677"
stub md5 true "echo invalid" "echo $checksum"
stub curl "-*I* : true" "-*S* http://?*/$checksum : cat package-1.0.0.tar.gz"
touch "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz"
install_fixture definitions/with-checksum
[ "$status" -eq 0 ]
[ -x "${INSTALL_ROOT}/bin/package" ]
[ -e "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
diff -q "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" "${FIXTURE_ROOT}/package-1.0.0.tar.gz"
unstub curl
unstub md5
}
@test "nonexistent cache directory is ignored" {
stub md5 true
stub curl "-*S* : cat package-1.0.0.tar.gz"
export RUBY_BUILD_CACHE_PATH="${TMP}/nonexistent"
install_fixture definitions/without-checksum
[ "$status" -eq 0 ]
[ -x "${INSTALL_ROOT}/bin/package" ]
[ ! -d "$RUBY_BUILD_CACHE_PATH" ]
unstub curl
unstub md5
}
test/test_helper.bash
View file @
d924fcee
...
@@ -20,6 +20,7 @@ stub() {
...
@@ -20,6 +20,7 @@ stub() {
export
PATH
=
"
${
BATS_TEST_DIRNAME
}
/stubs/
${
program
}
:
$PATH
"
export
PATH
=
"
${
BATS_TEST_DIRNAME
}
/stubs/
${
program
}
:
$PATH
"
rm
-f
"
${
TMP
}
/
${
program
}
-stub-plan"
"
${
TMP
}
/
${
program
}
-stub-run"
rm
-f
"
${
TMP
}
/
${
program
}
-stub-plan"
"
${
TMP
}
/
${
program
}
-stub-run"
touch
"
${
TMP
}
/
${
program
}
-stub-plan"
for
arg
in
"
$@
"
;
do
printf
"%s
\n
"
"
$arg
"
>>
"
${
TMP
}
/
${
program
}
-stub-plan"
;
done
for
arg
in
"
$@
"
;
do
printf
"%s
\n
"
"
$arg
"
>>
"
${
TMP
}
/
${
program
}
-stub-plan"
;
done
}
}
...
...
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