#!/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 export -n PKG_CONFIG_PATH 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() { local save_to_fixtures case "$*" in "ruby-3.2.0 configure" | "yaml-0.1.6 configure" | "jruby-9000.dev bin/jruby" ) save_to_fixtures=1 ;; esac local tarball="${1}.tar.gz" local fixture_tarball="${FIXTURE_ROOT}/${tarball}" local cached_tarball="${RUBY_BUILD_CACHE_PATH}/${tarball}" shift 1 if [ -n "$save_to_fixtures" ] && [ -e "$fixture_tarball" ]; then mkdir -p "$(dirname "$cached_tarball")" cp "$fixture_tarball" "$cached_tarball" return 0 fi generate_tarball "$cached_tarball" "$@" [ -z "$save_to_fixtures" ] || cp "$cached_tarball" "$fixture_tarball" } generate_tarball() { local tarfile="$1" shift 1 local name path name="$(basename "${tarfile%.tar.gz}")" path="$(mktemp -d "$TMP/tarball.XXXXX")/${name}" local file target for file; do case "$file" in config | configure ) mkdir -p "$(dirname "${path}/${file}")" cat > "${path}/${file}" <> build.log OUT chmod +x "${path}/${file}" ;; *:* ) target="${file#*:}" file="${file%:*}" mkdir -p "$(dirname "${path}/${file}")" cp "$target" "${path}/${file}" ;; * ) mkdir -p "$(dirname "${path}/${file}")" touch "${path}/${file}" ;; esac done mkdir -p "$(dirname "$tarfile")" tar czf "$tarfile" -C "${path%/*}" "$name" rm -rf "$path" } stub_make_install() { local target="${1:-install}" stub "$MAKE" \ " : echo \"\${PKG_CONFIG_PATH:+PKG_CONFIG_PATH=\$PKG_CONFIG_PATH }$MAKE \$(inspect_args \"\$@\")\" >> build.log" \ "$target : echo \"$MAKE \$(inspect_args \"\$@\")\" >> 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" configure cached_tarball "ruby-3.2.0" configure stub_repeated uname '-s : echo Linux' stub_repeated brew false stub_make_install stub_make_install install_fixture definitions/needs-yaml assert_success unstub uname unstub brew unstub make assert_build_log <> build.log' TMPDIR="$TMP" install_fixture --patch definitions/needs-yaml <> build.log' TMPDIR="$TMP" install_fixture --patch definitions/needs-yaml <> build.log' TMPDIR="$TMP" install_fixture --patch definitions/needs-yaml < 4.0.2\n\"OpenSSL 1.0.3a 1 Aug 202\"\n0 errors.\n"' stub_make_install mkdir -p "$INSTALL_ROOT"/openssl/ssl # OPENSSLDIR run_inline_definition < "$TMP/build-definition" < "$TMP"/definitions/3.2.0 < ruby-123-internal <> build.log' stub_make_install RUBY_CONFIGURE="${TMP}/custom-configure" run_inline_definition <> build.log' stub_make_install "update-gems" run_inline_definition <> '$INSTALL_ROOT'/build.log mkdir -p build/host/bin touch build/host/bin/{mruby,mirb} chmod +x build/host/bin/{mruby,mirb} OUT cached_tarball "mruby-1.0" "minirake:$TMP/minirake" include/mruby.h stub gem false stub rake false mkdir -p "$INSTALL_ROOT/bin" touch "$INSTALL_ROOT/bin/mruby" chmod -w "$INSTALL_ROOT/bin/mruby" run_inline_definition <> build.log' \ "exec rake install : { cat build.log; echo bundle \"\$@\"; } >> '$INSTALL_ROOT/build.log'" run_inline_definition <>' OUT cached_tarball "rubinius-2.0.0" configure bin/ruby \ gems/bin/rake:"$TMP"/rbx-rake \ gems/bin/irb:"$TMP"/rbx-irb 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 "${TMP}/jruby-bin" <> ../build.log OUT executable "${TMP}/jruby-gem" <= 7 required, but your Java version was:" } @test "JRuby Java is outdated" { cached_tarball "jruby-9000.dev" bin/jruby stub java "-version : echo 'java version \"1.6.0_21\"' >&2" run_inline_definition <= 7 required, but your Java version was:" assert_output_contains 'java version "1.6.0_21"' } @test "JRuby Java 7 up-to-date" { cached_tarball "jruby-9000.dev" bin/jruby stub java '-version : echo java version "1.7.0_21" >&2' run_inline_definition <&2; echo 'java version \"1.8.0_31\"' >&2" run_inline_definition <&2" run_inline_definition <&2" run_inline_definition <&2" run_inline_definition <&2" run_inline_definition <&2" run_inline_definition <> build.log OUT cached_tarball "truffleruby-test" bin/truffleruby lib/truffle/post_install_hook.sh:"$TMP"/hook.sh run_inline_definition <