4 require File.dirname(__FILE__) + '/../../../ruby/ohcount.rb' # .rb is to specify the .rb instead of .bundle
5 require File.dirname(__FILE__) + '/../../../ruby/gestalt' # .rb is to specify the .rb instead of .bundle
7 unless defined?(TEST_DIR)
8 TEST_DIR = File.dirname(__FILE__)
14 # Ohcount::Test is a base class which includes several helper methods for parser testing.
15 # All unit tests in Ohcount should derive from this class.
19 # To manually test a parser, rebuild ohcount and run it against your test file:
22 # bin/ohcount --annotate test/src_dir/my_file.ext
24 # The +annotate+ option will emit your test file to the console, and each line will be
25 # labeled as code, comment, or blank.
27 class Ohcount::Test < Test::Unit::TestCase
29 # For reasons unknown, the base class defines a default_test method to throw a failure.
30 # We override it with a no-op to prevent this 'helpful' feature.
35 def assert_tool(path, *tools)
36 gestalts = tools.map do |t|
37 Base.new(:tool, t.to_s)
39 assert_gestalts path, gestalts
42 def assert_platform(path, *platforms)
43 gestalts = platforms.map do |p|
44 Base.new(:platform, p.to_s)
46 assert_gestalts path, gestalts
49 def assert_gestalts(path, expected_gestalts)
50 assert_equal expected_gestalts.sort, get_gestalts(path)
53 def get_gestalts(path)
54 sfl = SourceFileList.new(:paths => [test_dir(path)])
61 File.expand_path(File.dirname(__FILE__) + "/../../gestalt_files/#{ d }")