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