a few more integration tests

Closes Homebrew/homebrew#47714.

Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
This commit is contained in:
Baptiste Fontaine 2016-01-05 15:45:45 +01:00
parent d6c6f00393
commit c8401b8243
2 changed files with 26 additions and 16 deletions

View File

@ -0,0 +1,9 @@
module Homebrew
module Diagnostic
class Checks
def check_integration_test
"This is an integration test" if ENV["HOMEBREW_INTEGRATION_TEST"]
end
end
end
end

View File

@ -11,6 +11,7 @@ class IntegrationCommandTests < Homebrew::TestCase
-W0 -W0
-I#{HOMEBREW_LIBRARY_PATH}/test/lib -I#{HOMEBREW_LIBRARY_PATH}/test/lib
-rconfig -rconfig
-rintegration_mocks
] ]
cmd_args << "-rsimplecov" if ENV["HOMEBREW_TESTS_COVERAGE"] cmd_args << "-rsimplecov" if ENV["HOMEBREW_TESTS_COVERAGE"]
cmd_args << (HOMEBREW_LIBRARY_PATH/"../brew.rb").resolved_path.to_s cmd_args << (HOMEBREW_LIBRARY_PATH/"../brew.rb").resolved_path.to_s
@ -100,6 +101,11 @@ class IntegrationCommandTests < Homebrew::TestCase
cmd("--repository") cmd("--repository")
end end
def test_help
assert_match "Example usage:",
cmd("help")
end
def test_install def test_install
assert_match "#{HOMEBREW_CELLAR}/testball/0.1", cmd("install", testball) assert_match "#{HOMEBREW_CELLAR}/testball/0.1", cmd("install", testball)
ensure ensure
@ -214,26 +220,21 @@ class IntegrationCommandTests < Homebrew::TestCase
bar_file.unlink unless bar_file.nil? bar_file.unlink unless bar_file.nil?
end end
def test_doctor_check_path_for_trailing_slashes def test_doctor
assert_match "Some directories in your path end in a slash", assert_match "This is an integration test",
cmd_fail("doctor", "check_path_for_trailing_slashes", cmd_fail("doctor", "check_integration_test")
{"PATH" => ENV["PATH"] + File::PATH_SEPARATOR + "/foo/bar/"})
end end
def test_doctor_check_for_anaconda def test_custom_command
mktmpdir do |path| mktmpdir do |path|
anaconda = "#{path}/anaconda" cmd = "int-test-#{rand}"
python = "#{path}/python" file = "#{path}/brew-#{cmd}"
FileUtils.touch anaconda
File.open(python, "w") do |file|
file.write("#! #{`which bash`}\necho -n '#{python}'\n")
end
FileUtils.chmod 0777, anaconda
FileUtils.chmod 0777, python
assert_match "Anaconda", File.open(file, "w") { |f| f.write "#!/bin/sh\necho 'I am #{cmd}'\n" }
cmd_fail("doctor", "check_for_anaconda", FileUtils.chmod 0777, file
{"PATH" => path + File::PATH_SEPARATOR + ENV["PATH"]})
assert_match "I am #{cmd}",
cmd(cmd, {"PATH" => "#{path}#{File::PATH_SEPARATOR}#{ENV["PATH"]}"})
end end
end end
end end