Refactor formula_test.
This commit is contained in:
parent
411874e0b6
commit
224beabdd5
@ -43,6 +43,10 @@ class Formulary
|
||||
end
|
||||
everything.sort
|
||||
end
|
||||
|
||||
def self.paths
|
||||
Dir["#{HOMEBREW_REPOSITORY}/Library/Formula/*.rb"]
|
||||
end
|
||||
|
||||
def self.read name
|
||||
Formulary.names.each do |f|
|
||||
|
||||
@ -10,25 +10,9 @@ require 'formula'
|
||||
require 'utils'
|
||||
|
||||
|
||||
# NOTE duplicated in unittest.rb (we need to refactor the tests anyway)
|
||||
def nostdout
|
||||
if ARGV.include? '-V'
|
||||
yield
|
||||
end
|
||||
begin
|
||||
require 'stringio'
|
||||
tmpo=$stdout
|
||||
tmpe=$stderr
|
||||
$stdout=StringIO.new
|
||||
yield
|
||||
ensure
|
||||
$stdout=tmpo
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
class FormulaNames <Test::Unit::TestCase
|
||||
class WellKnownCodeIssues <Test::Unit::TestCase
|
||||
def test_formula_names
|
||||
# Formula names should be valid
|
||||
nostdout do
|
||||
Dir["#{HOMEBREW_PREFIX}/Library/Formula/*.rb"].each do |f|
|
||||
assert_nothing_raised do
|
||||
@ -37,16 +21,10 @@ class FormulaNames <Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class WellKnownCodeIssues <Test::Unit::TestCase
|
||||
def all_formulas
|
||||
Dir["#{HOMEBREW_PREFIX}/Library/Formula/*.rb"].each {|f| yield f }
|
||||
end
|
||||
|
||||
def test_for_commented_out_cmake
|
||||
# Formulas shouldn't contain commented-out cmake code from the default template
|
||||
all_formulas do |f|
|
||||
Formulary.paths.each do |f|
|
||||
result = `grep "# depends_on 'cmake'" "#{f}"`.strip
|
||||
assert_equal('', result, "Commented template code still in #{f}")
|
||||
end
|
||||
@ -56,10 +34,9 @@ class WellKnownCodeIssues <Test::Unit::TestCase
|
||||
# Prefix should not have single quotes if the system args are already separated
|
||||
target_string = "[\\\"]--prefix=[\\']"
|
||||
|
||||
all_formulas do |f|
|
||||
Formulary.paths.each do |f|
|
||||
result = `grep -e "#{target_string}" "#{f}"`.strip
|
||||
assert_equal('', result, "--prefix is incorrectly single-quoted in #{f}")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user