Commit dc054d30 by Mislav Marohnić

Simplify fetching tarballs in build tests

- use cache path feature to skip HTTP fetch atogether
- unified build.log
parent d35349e8
#!/usr/bin/env bats #!/usr/bin/env bats
load test_helper load test_helper
export RUBY_BUILD_CACHE_PATH="$TMP/cache"
setup() {
mkdir -p "$INSTALL_ROOT"
stub md5 false
stub curl false
}
cached_tarball() {
mkdir -p "$RUBY_BUILD_CACHE_PATH"
pushd "$RUBY_BUILD_CACHE_PATH" >/dev/null
tarball "$1"
popd >/dev/null
}
tarball() { tarball() {
local name="$1" local name="$1"
local path="$TMP/$name" local path="$PWD/$name"
local configure="$path/configure" local configure="$path/configure"
mkdir -p "$path" mkdir -p "$path"
...@@ -14,67 +28,57 @@ echo "$name: \$@" > build.log ...@@ -14,67 +28,57 @@ echo "$name: \$@" > build.log
OUT OUT
chmod +x "$configure" chmod +x "$configure"
tar czf "${path}.tgz" -C "$TMP" "$name" tar czf "${path}.tar.gz" -C "${path%/*}" "$name"
echo "${path}.tgz"
} }
stub_download() { stub_make_install() {
stub curl "-C - -o * -*S* $1 : cp '$(tarball "$2")' \$4" stub make \
' : echo make "$@" >> build.log' \
"install : cat build.log >> '$INSTALL_ROOT/build.log'"
}
assert_build_log() {
run cat "$INSTALL_ROOT/build.log"
assert_output
} }
@test "yaml is installed for ruby" { @test "yaml is installed for ruby" {
mkdir -p "$INSTALL_ROOT/bin" cached_tarball "yaml-0.1.4"
cached_tarball "ruby-2.0.0"
stub md5 false
stub brew false stub brew false
stub_download "http://pyyaml.org/*" "yaml-0.1.4" stub_make_install
stub_download "http://ruby-lang.org/*" "ruby-2.0.0" stub_make_install
stub make \
' : echo make "$@" >> build.log' \
"install : cp build.log '$INSTALL_ROOT/yaml.log'" \
' : echo make "$@" >> build.log' \
"install : cp build.log '$INSTALL_ROOT/ruby.log'"
install_fixture definitions/needs-yaml install_fixture definitions/needs-yaml
assert_success assert_success
unstub curl
unstub make unstub make
run cat "$INSTALL_ROOT/yaml.log" assert_build_log <<OUT
assert_output <<OUT
yaml-0.1.4: --prefix=$INSTALL_ROOT yaml-0.1.4: --prefix=$INSTALL_ROOT
make -j 2 make -j 2
OUT
run cat "$INSTALL_ROOT/ruby.log"
assert_output <<OUT
ruby-2.0.0: --prefix=$INSTALL_ROOT ruby-2.0.0: --prefix=$INSTALL_ROOT
make -j 2 make -j 2
OUT OUT
} }
@test "yaml is linked from Homebrew" { @test "yaml is linked from Homebrew" {
cached_tarball "ruby-2.0.0"
brew_libdir="$TMP/homebrew-yaml" brew_libdir="$TMP/homebrew-yaml"
mkdir -p "$INSTALL_ROOT/bin"
mkdir -p "$brew_libdir" mkdir -p "$brew_libdir"
stub md5 false
stub brew "--prefix libyaml : echo '$brew_libdir'" stub brew "--prefix libyaml : echo '$brew_libdir'"
stub_download "http://ruby-lang.org/*" "ruby-2.0.0" stub_make_install
stub make \
' : echo make "$@" >> build.log' \
"install : cp build.log '$INSTALL_ROOT/ruby.log'"
install_fixture definitions/needs-yaml install_fixture definitions/needs-yaml
assert_success assert_success
unstub brew unstub brew
unstub curl
unstub make unstub make
run cat "$INSTALL_ROOT/ruby.log" assert_build_log <<OUT
assert_output <<OUT
ruby-2.0.0: --prefix=$INSTALL_ROOT --with-libyaml-dir=$brew_libdir ruby-2.0.0: --prefix=$INSTALL_ROOT --with-libyaml-dir=$brew_libdir
make -j 2 make -j 2
OUT OUT
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment