Commit 7f1d8df3 authored by Mislav Marohnić's avatar Mislav Marohnić
Browse files

Read Java version number even if it's not on the 1st line

Handles output like:

    Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar
    java version "1.8.0_31"

Fixes #710
parent f674efd6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -687,7 +687,7 @@ fix_rbx_irb() {
}

require_java7() {
  local version="$(java -version 2>&1 | head -1)"
  local version="$(java -version 2>&1 | grep 'java version' | head -1)"
  if [[ $version != *1.[789]* ]]; then
    colorize 1 "ERROR" >&3
    echo ": Java 7 required. Please install a 1.7-compatible JRE." >&3
+12 −0
Original line number Diff line number Diff line
@@ -589,6 +589,18 @@ DEF
  assert_success
}

@test "Java version string not on first line" {
  cached_tarball "jruby-9000.dev" bin/jruby

  stub java "-version : echo 'Picked up JAVA_TOOL_OPTIONS' >&2; echo 'java version \"1.8.0_31\"' >&2"

  run_inline_definition <<DEF
require_java7
install_package "jruby-9000.dev" "http://ci.jruby.org/jruby-dist-9000.dev-bin.tar.gz" jruby
DEF
  assert_success
}

@test "non-writable TMPDIR aborts build" {
  export TMPDIR="${TMP}/build"
  mkdir -p "$TMPDIR"