#!/usr/bin/env bats load test_helper export RUBY_BUILD_CACHE_PATH="$TMP/cache" export MAKE=make export MAKE_OPTS="-j 2" export CC=cc export -n RUBY_CONFIGURE_OPTS setup() { mkdir -p "$INSTALL_ROOT" stub md5 false stub curl false } executable() { local file="$1" mkdir -p "${file%/*}" cat > "$file" chmod +x "$file" } cached_tarball() { mkdir -p "$RUBY_BUILD_CACHE_PATH" pushd "$RUBY_BUILD_CACHE_PATH" >/dev/null tarball "$@" popd >/dev/null } tarball() { local name="$1" local path="$PWD/$name" local configure="$path/configure" shift 1 executable "$configure" <> build.log OUT for file; do mkdir -p "$(dirname "${path}/${file}")" touch "${path}/${file}" done tar czf "${path}.tar.gz" -C "${path%/*}" "$name" } stub_make_install() { stub "$MAKE" \ " : echo \"$MAKE \$@\" >> build.log" \ "install : echo \"$MAKE \$@\" >> build.log && cat build.log >> '$INSTALL_ROOT/build.log'" } assert_build_log() { run cat "$INSTALL_ROOT/build.log" assert_output } @test "yaml is installed for ruby" { cached_tarball "yaml-0.1.6" cached_tarball "ruby-2.0.0" stub brew false stub_make_install stub_make_install install_fixture definitions/needs-yaml assert_success unstub make assert_build_log <> build.log' TMPDIR="$TMP" install_fixture --patch definitions/needs-yaml <<<"" assert_success unstub make unstub patch assert_build_log <> build.log' TMPDIR="$TMP" install_fixture --patch definitions/needs-yaml <<<"diff --git a/script.rb" assert_success unstub make unstub patch assert_build_log <> build.log' stub_make_install export RUBY_CONFIGURE="${TMP}/custom-configure" run_inline_definition <> build.log' \ '--version : echo 1' \ " exec rake install : { cat build.log; echo bundle \"\$@\"; } >> '$INSTALL_ROOT/build.log'" run_inline_definition <>' OUT cached_tarball "rubinius-2.0.0" bin/ruby stub bundle false stub rake \ '--version : echo 1' \ "install : mkdir -p '$INSTALL_ROOT'; cp -fR . '$INSTALL_ROOT'" run_inline_definition <>' OUT } @test "JRuby build" { executable "${RUBY_BUILD_CACHE_PATH}/jruby-1.7.9/bin/jruby" <> ../build.log OUT executable "${RUBY_BUILD_CACHE_PATH}/jruby-1.7.9/bin/gem" <> ../build.log OUT cached_tarball "jruby-9000.dev" run_inline_definition <&2' run_inline_definition <&2' run_inline_definition <