brew/Library/Homebrew/test/os/mac/java_requirement_test.rb
Bob W. Hogg 5a214de68d java_requirement: port to Linux and refactor
Split the core requirement class into generic, Linux-specific,
and macOS-specific parts.

Additionally, the Linux version is now able to detect Java versions
(the previous Linuxbrew implementation was only able to detect
if Java was present at all.)
2017-02-15 21:35:26 -08:00

32 lines
900 B
Ruby

require "testing_env"
require "requirements/java_requirement"
require "fileutils"
class OSMacJavaRequirementTests < Homebrew::TestCase
def setup
super
@java_req = JavaRequirement.new(%w[1.8])
@tmp_java_home = mktmpdir
@tmp_pathname = Pathname.new(@tmp_java_home)
FileUtils.mkdir @tmp_pathname/"bin"
FileUtils.touch @tmp_pathname/"bin/java"
@java_req.stubs(:preferred_java).returns(@tmp_pathname/"bin/java")
@java_req.satisfied?
end
def test_java_env_apple
ENV.expects(:prepend_path)
ENV.expects(:append_to_cflags)
@java_req.modify_build_environment
assert_equal ENV["JAVA_HOME"], @tmp_java_home
end
def test_java_env_oracle
FileUtils.mkdir @tmp_pathname/"include"
ENV.expects(:prepend_path)
ENV.expects(:append_to_cflags).twice
@java_req.modify_build_environment
assert_equal ENV["JAVA_HOME"], @tmp_java_home
end
end