aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMike McQuaid2015-07-23 21:32:13 +0100
committerMike McQuaid2015-07-28 10:57:56 +0100
commit0c47c8f86400faf3b3b67c84396d216683b093ea (patch)
tree5d86ed86bc36d5ac0aef969f8c07d075036c96c8 /Library
parent09acae83a685bfdcf228cf0177851eeec2799372 (diff)
downloadbrew-0c47c8f86400faf3b3b67c84396d216683b093ea.tar.bz2
test_integration_cmds: basic integration tests.
Closes Homebrew/homebrew#41945. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/test/test_integration_cmds.rb81
1 files changed, 81 insertions, 0 deletions
diff --git a/Library/Homebrew/test/test_integration_cmds.rb b/Library/Homebrew/test/test_integration_cmds.rb
new file mode 100644
index 000000000..82686b8cb
--- /dev/null
+++ b/Library/Homebrew/test/test_integration_cmds.rb
@@ -0,0 +1,81 @@
+require "testing_env"
+
+class IntegrationCommandTests < Homebrew::TestCase
+ def cmd_output *args
+ cmd_args = %W[
+ -W0
+ -I#{HOMEBREW_LIBRARY_PATH}/test/lib
+ -rconfig
+ ]
+ cmd_args << "-rsimplecov" if ENV["HOMEBREW_TESTS_COVERAGE"]
+ cmd_args << (HOMEBREW_LIBRARY_PATH/"../brew.rb").resolved_path.to_s
+ cmd_args += args
+ Bundler.with_original_env do
+ ENV["HOMEBREW_BREW_FILE"] = HOMEBREW_PREFIX/"bin/brew"
+ ENV["HOMEBREW_INTEGRATION_TEST"] = args.join " "
+ ENV["HOMEBREW_TEST_TMPDIR"] = TEST_TMPDIR
+ Utils.popen_read(RUBY_PATH, *cmd_args).chomp
+ end
+ end
+
+ def cmd *args
+ output = cmd_output(*args)
+ assert_equal 0, $?.exitstatus
+ output
+ end
+
+ def cmd_fail *args
+ output = cmd_output(*args)
+ assert_equal 1, $?.exitstatus
+ output
+ end
+
+ def testball
+ "#{File.expand_path("..", __FILE__)}/testball.rb"
+ end
+
+ def test_prefix
+ assert_equal HOMEBREW_PREFIX.to_s,
+ cmd("--prefix")
+ end
+
+ def test_version
+ assert_equal HOMEBREW_VERSION.to_s,
+ cmd("--version")
+ end
+
+ def test_cache
+ assert_equal HOMEBREW_CACHE.to_s,
+ cmd("--cache")
+ end
+
+ def test_cache_formula
+ assert_match %r{#{HOMEBREW_CACHE}/testball-},
+ cmd("--cache", testball)
+ end
+
+ def test_cellar
+ assert_equal HOMEBREW_CELLAR.to_s,
+ cmd("--cellar")
+ end
+
+ def test_cellar_formula
+ assert_match "#{HOMEBREW_CELLAR}/testball",
+ cmd("--cellar", testball)
+ end
+
+ def test_env
+ assert_match "CMAKE_PREFIX_PATH=\"#{HOMEBREW_PREFIX}\"",
+ cmd("--env")
+ end
+
+ def test_prefix_formula
+ assert_match "#{HOMEBREW_CELLAR}/testball",
+ cmd("--prefix", testball)
+ end
+
+ def test_repository
+ assert_match HOMEBREW_REPOSITORY.to_s,
+ cmd("--repository")
+ end
+end