diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 93a31481df883e8b25f1cb881f7a7aa10ea4ddb2..6f3fd6e488c14cf01ecc66e39ba01fb25135937a 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -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| diff --git a/Library/Homebrew/test/formula_test.rb b/Library/Homebrew/test/formula_test.rb index 50c487a6d6530276c7c33173e3e4f4e941ca823f..71f4ea732c62dfe2dd28a25e15b7eaed7826db5a 100755 --- a/Library/Homebrew/test/formula_test.rb +++ b/Library/Homebrew/test/formula_test.rb @@ -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