aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorAdam Vandenberg2009-11-19 14:10:47 -0800
committerAdam Vandenberg2009-11-19 14:13:31 -0800
commit075727251d121e20a5682beeb059b6443c435bf4 (patch)
treeba5cbfd18c23d308e9c671da412b61d00a166f6f /Library
parentc1d91ef4436e3ad792a77701eba7fecd4f62c6fd (diff)
downloadhomebrew-075727251d121e20a5682beeb059b6443c435bf4.tar.bz2
Refactor formula_test.
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/formula.rb4
-rwxr-xr-xLibrary/Homebrew/test/formula_test.rb31
2 files changed, 8 insertions, 27 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index 93a31481d..6f3fd6e48 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 50c487a6d..71f4ea732 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