aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/test/formula_test.rb
blob: c79c62571a058eccad164f9507f9666a2eb70c7d (plain)
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
#!/usr/bin/ruby
# This software is in the public domain, furnished "as is", without technical
# support, and with no warranty, express or implied, as to its usefulness for
# any purpose.

$:.push(File.expand_path(__FILE__+'/../..'))
require 'test/unit'
require 'global'
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
  def test_formula_names
    nostdout do
      Dir["#{HOMEBREW_PREFIX}/Library/Formula/*.rb"].each do |f|
        assert_nothing_raised do
          Formula.factory f
        end
      end
    end
  end
end

class CommentedTemplateCode <Test::Unit::TestCase
  def test_for_commented_out_cmake
    Dir["#{HOMEBREW_PREFIX}/Library/Formula/*.rb"].each do |f|
      result = `grep "# depends_on 'cmake'" "#{f}"`.strip
      assert_equal('', result, "Commented template code still in #{f}")
    end
  end
end