Sha256: e690f2eb76161ba860970702b5818a0696a6b50b249826216f8420c3be7e5484
Contents?: true
Size: 1.45 KB
Versions: 2
Compression:
Stored size: 1.45 KB
Contents
require 'nano/string/pull' module Test module Unit class CommentAutoRunner < AutoRunner def self.run(current_file=nil, default_dir=nil, argv=ARGV, &block) if(!current_file || current_file == $0) r = new(!current_file, &block) if !r.process_args(argv) && default_dir r.to_run << default_dir end r.run end end def load_commented_tests( filepath ) rbfile = File.read( filepath ) rblines = rbfile.split("\n") tests = [] intest = nil comment = nil hcomment = nil rblines.each_with_index do |l,i| if /^(\ *#\ *)?=\ *begin testing/ =~ l intest = true comment = true unless $1 next elsif intest and /^(\ *#\ *)?=\ *end/ =~ l intest = false comment = false next end hcomment = true if /^\ *#/ =~ l if intest and (comment or hcomment) l.pull if hcomment tests << l end end tests = tests.join("\n") tests.gsub!( %r{^([ ]*)testcase[ ]+(\w+)} ) { "#{$1}class TC_#{$2} < Test::Unit::TestCase" } tests.gsub!( %r{^([ ]*)test[ ]+(\w+)} ) { |md| "#{$1}def test_#{$2}" } tests end end end end # Test::Unit::CommentAutoRunner.start( __FILE__ ) # # puts tests, "\n" if $VERBOSE # # require 'test/unit' # # load ARGV[0] # # eval tests
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
reap-6.0.2 | forge/unit_runner/commentrunner.rb |
reap-6.0.1 | forge/unit_runner/commentrunner.rb |