1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
require "bundler"
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_match 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 %r{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
def test_install
assert_match "#{HOMEBREW_CELLAR}/testball/0.1", cmd("install", testball)
ensure
cmd("uninstall", "--force", testball)
cmd("cleanup", "--force", "--prune=all")
end
def test_bottle
cmd("install", "--build-bottle", testball)
HOMEBREW_CACHE.cd do
assert_match(/testball-0\.1.*\.bottle\.tar\.gz/,
cmd_output("bottle", "--no-revision", testball))
end
ensure
cmd("uninstall", "--force", testball)
cmd("cleanup", "--force", "--prune=all")
end
def test_uninstall
cmd("install", "--build-bottle", testball)
assert_match "Uninstalling testball", cmd("uninstall", "--force", testball)
ensure
cmd("cleanup", "--force", "--prune=all")
end
def test_cleanup
(HOMEBREW_CACHE/"test").write "test"
assert_match "#{HOMEBREW_CACHE}/test", cmd("cleanup", "--prune=all")
end
def test_readall
repo = CoreFormulaRepository.new
formula_file = repo.formula_dir/"foo.rb"
formula_file.write <<-EOS.undent
class Foo < Formula
url "https://example.com/foo-1.0.tar.gz"
end
EOS
alias_file = repo.alias_dir/"bar"
alias_file.parent.mkpath
FileUtils.ln_s formula_file, alias_file
cmd("readall", "--aliases", "--syntax")
cmd("readall", "Homebrew/homebrew")
ensure
formula_file.unlink
repo.alias_dir.rmtree
end
end
|