dohtest 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/dohtest +11 -9
- data/lib/doh/test/assertions.rb +2 -1
- data/lib/doh/test/backtrace_parser.rb +7 -7
- data/lib/doh/test/configure.rb +20 -3
- data/lib/doh/test/master_runner.rb +3 -14
- data/lib/doh/test/stream_output.rb +8 -1
- data/test/test_backtrace_parser.rb +19 -11
- metadata +8 -7
data/bin/dohtest
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'doh/options'
|
3
|
+
require 'doh/test/configure'
|
3
4
|
require 'doh/test/master_runner'
|
4
5
|
require 'doh/test/stream_output'
|
5
6
|
|
6
7
|
opts = Doh::Options.new(
|
7
|
-
{'grep' => [nil, "-g", "--grep <name>", "only execute tests with name that include the given value"] \
|
8
|
-
,'glob' => [
|
9
|
-
,'seed' => [nil, "-v", "--seed <number>", "
|
8
|
+
{'grep' => [nil, "-g", "--grep <name>", "only execute tests with name that include the given value."] \
|
9
|
+
,'glob' => [nil, "-b", "--glob <string>", "glob string to find test files. defaults to *.dt.rb"] \
|
10
|
+
,'seed' => [nil, "-v", "--seed <number>", "use this as the seed to srand"] \
|
10
11
|
}, true, 'Files or directories may be specified to run tests on. Directories will be treated recursively. Defaults to the current directory.')
|
11
12
|
|
12
|
-
|
13
|
-
config[:grep] = opts.grep if opts.grep
|
14
|
-
config[:glob] = opts.glob
|
15
|
-
config[:seed] = opts.seed.to_i if opts.seed
|
16
|
-
config[:paths] = (if opts.varargs.empty? then ['.'] else opts.varargs end)
|
13
|
+
paths = (if opts.varargs.empty? then ['.'] else opts.varargs end)
|
17
14
|
|
18
|
-
|
15
|
+
DohTest::configure(paths[0])
|
16
|
+
DohTest::config[:grep] = opts.grep if opts.grep
|
17
|
+
DohTest::config[:glob] = opts.glob if opts.glob
|
18
|
+
DohTest::config[:seed] = opts.seed.to_i if opts.seed
|
19
|
+
|
20
|
+
exit DohTest::MasterRunner.new(DohTest::StreamOutput.new, DohTest::config, paths).run
|
data/lib/doh/test/assertions.rb
CHANGED
@@ -30,7 +30,8 @@ class TestGroup
|
|
30
30
|
yield
|
31
31
|
no_exception = true
|
32
32
|
rescue Exception => excpt
|
33
|
-
|
33
|
+
expected_str = if (args.size == 1) then args.first else "one of #{args.join(',')}" end
|
34
|
+
assert(args.include?(excpt.class), msg || "expected: #{expected_str}; actual: #{excpt.class}: #{excpt.message}")
|
34
35
|
return
|
35
36
|
end
|
36
37
|
|
@@ -26,7 +26,9 @@ private
|
|
26
26
|
else
|
27
27
|
found_start = true
|
28
28
|
info = location.rpartition(':in').first
|
29
|
-
|
29
|
+
parts = info.partition(':')
|
30
|
+
raise "unexpected backtrace element: #{location}" if parts.first.nil? || parts.last.nil?
|
31
|
+
retval << [parts.first, parts.last]
|
30
32
|
end
|
31
33
|
end
|
32
34
|
retval
|
@@ -36,15 +38,13 @@ private
|
|
36
38
|
retval = ''
|
37
39
|
prev_filename = ''
|
38
40
|
prev_simplified = ''
|
39
|
-
relevant_stack.each do |
|
40
|
-
|
41
|
-
|
42
|
-
simplified = "#{filename}:#{parts.last}"
|
43
|
-
raise "unexpected location format: #{location}" unless filename
|
41
|
+
relevant_stack.each do |path, line_number|
|
42
|
+
filename = File.basename(path)
|
43
|
+
simplified = "#{filename}:#{line_number}"
|
44
44
|
if simplified == prev_simplified
|
45
45
|
# ignore it
|
46
46
|
elsif filename == prev_filename
|
47
|
-
retval += ",#{
|
47
|
+
retval += ",#{line_number}"
|
48
48
|
elsif retval.empty?
|
49
49
|
retval = simplified
|
50
50
|
else
|
data/lib/doh/test/configure.rb
CHANGED
@@ -2,17 +2,34 @@ require 'doh/root'
|
|
2
2
|
|
3
3
|
module DohTest
|
4
4
|
|
5
|
-
def self.
|
5
|
+
def self.config
|
6
|
+
@config ||= {}
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.load_configuration_files(start_path)
|
6
10
|
start_directory = File.dirname(start_path)
|
7
11
|
|
12
|
+
local_filename = Doh::findup(start_directory, 'configure_dohtest.rb')
|
13
|
+
if local_filename && File.exist?(local_filename)
|
14
|
+
require(local_filename)
|
15
|
+
return
|
16
|
+
end
|
17
|
+
|
8
18
|
root_directory = Doh::find_root(start_directory)
|
9
19
|
if root_directory
|
10
20
|
root_filename = File.join(root_directory, 'config', 'dohtest.rb')
|
11
21
|
require(root_filename) if File.exist?(root_filename)
|
12
22
|
end
|
23
|
+
end
|
13
24
|
|
14
|
-
|
15
|
-
|
25
|
+
def self.add_default_config_values
|
26
|
+
DohTest::config[:glob] ||= '*.dt.rb'
|
27
|
+
DohTest::config[:seed] ||= (Time.new.to_f * 1000).to_i
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.configure(start_path)
|
31
|
+
load_configuration_files(start_path)
|
32
|
+
add_default_config_values
|
16
33
|
end
|
17
34
|
|
18
35
|
end
|
@@ -1,31 +1,20 @@
|
|
1
|
-
require 'doh/test/configure'
|
2
1
|
require 'doh/test/group_runner'
|
3
2
|
require 'doh/test/require_paths'
|
4
3
|
|
5
4
|
module DohTest
|
6
5
|
|
7
6
|
class MasterRunner
|
8
|
-
def initialize(output, config)
|
9
|
-
@output, @config = output, config
|
10
|
-
add_missing_config
|
7
|
+
def initialize(output, config, paths)
|
8
|
+
@output, @config, @paths = output, config, paths
|
11
9
|
end
|
12
10
|
|
13
11
|
def run
|
14
|
-
|
15
|
-
DohTest::configure(paths[0])
|
16
|
-
DohTest::require_paths(@config[:glob], paths)
|
12
|
+
DohTest::require_paths(@config[:glob], @paths)
|
17
13
|
srand(@config[:seed])
|
18
14
|
@output.run_begin(@config)
|
19
15
|
TestGroup.descendants.each { |group_class| GroupRunner.new(group_class, @output, @config).run }
|
20
16
|
@output.run_end
|
21
17
|
end
|
22
|
-
|
23
|
-
private
|
24
|
-
def add_missing_config
|
25
|
-
@config[:glob] ||= '*.dt.rb'
|
26
|
-
@config[:seed] ||= (Time.new.to_f * 1000).to_i
|
27
|
-
@config[:paths] ||= ['.']
|
28
|
-
end
|
29
18
|
end
|
30
19
|
|
31
20
|
end
|
@@ -58,9 +58,16 @@ class StreamOutput
|
|
58
58
|
|
59
59
|
private
|
60
60
|
def display_badness(title, group_name, test_name, excpt, display_name)
|
61
|
-
|
61
|
+
parser = DohTest::BacktraceParser.new(excpt.backtrace)
|
62
|
+
warn "#{title} in #{group_name}.#{test_name}"
|
62
63
|
badname = if display_name then "#{excpt.class}: " else '' end
|
63
64
|
warn "=> #{badname}#{excpt}"
|
65
|
+
# main_call = parser.relevant_stack.last
|
66
|
+
# warn "=> #{main_call.first}:#{main_call.last}"
|
67
|
+
# warn "=> #{parser.summary}"
|
68
|
+
parser.relevant_stack.each do |path, line|
|
69
|
+
warn "=> #{path}:#{line}"
|
70
|
+
end
|
64
71
|
end
|
65
72
|
end
|
66
73
|
|
@@ -17,11 +17,11 @@ class TestBacktraceParser < MiniTest::Unit::TestCase
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def test_single_stack
|
20
|
-
|
21
|
-
assert_equal("frog.rb:12",
|
20
|
+
parser = DohTest::BacktraceParser.new(create_single_stack)
|
21
|
+
assert_equal("frog.rb:12", parser.summary)
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
24
|
+
def create_raw_double_stack
|
25
25
|
retval = []
|
26
26
|
retval << "/Users/somebody/dohtest/lib/doh/test/assertions.rb:10:in `assert'"
|
27
27
|
retval << "/Users/somebody/tinker/test/frog.rb:5:in `verify_sum'"
|
@@ -30,9 +30,17 @@ class TestBacktraceParser < MiniTest::Unit::TestCase
|
|
30
30
|
retval
|
31
31
|
end
|
32
32
|
|
33
|
+
def create_relevant_double_stack
|
34
|
+
retval = []
|
35
|
+
retval << ['/Users/somebody/tinker/test/frog.rb', '5']
|
36
|
+
retval << ['/Users/somebody/tinker/test/frog.rb', '12']
|
37
|
+
retval
|
38
|
+
end
|
39
|
+
|
33
40
|
def test_double_stack
|
34
|
-
|
35
|
-
assert_equal(
|
41
|
+
parser = DohTest::BacktraceParser.new(create_raw_double_stack)
|
42
|
+
assert_equal(create_relevant_double_stack, parser.relevant_stack)
|
43
|
+
assert_equal("frog.rb:5,12", parser.summary)
|
36
44
|
end
|
37
45
|
|
38
46
|
def create_multifile_stack
|
@@ -45,8 +53,8 @@ class TestBacktraceParser < MiniTest::Unit::TestCase
|
|
45
53
|
end
|
46
54
|
|
47
55
|
def test_multifile_stack
|
48
|
-
|
49
|
-
assert_equal("toad.rb:8;frog.rb:11",
|
56
|
+
parser = DohTest::BacktraceParser.new(create_multifile_stack)
|
57
|
+
assert_equal("toad.rb:8;frog.rb:11", parser.summary)
|
50
58
|
end
|
51
59
|
|
52
60
|
def create_duplicate_stack
|
@@ -58,8 +66,8 @@ class TestBacktraceParser < MiniTest::Unit::TestCase
|
|
58
66
|
end
|
59
67
|
|
60
68
|
def test_duplicate_stack
|
61
|
-
|
62
|
-
assert_equal("blee.rb:30",
|
69
|
+
parser = DohTest::BacktraceParser.new(create_duplicate_stack)
|
70
|
+
assert_equal("blee.rb:30", parser.summary)
|
63
71
|
end
|
64
72
|
|
65
73
|
def create_block_stack
|
@@ -69,8 +77,8 @@ class TestBacktraceParser < MiniTest::Unit::TestCase
|
|
69
77
|
end
|
70
78
|
|
71
79
|
def test_block_stack
|
72
|
-
|
73
|
-
assert_equal("kblah.rb:3",
|
80
|
+
parser = DohTest::BacktraceParser.new(create_block_stack)
|
81
|
+
assert_equal("kblah.rb:3", parser.summary)
|
74
82
|
end
|
75
83
|
end
|
76
84
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dohtest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,20 +10,20 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-02-23 00:00:00.000000000Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: dohutil
|
17
|
-
requirement: &
|
17
|
+
requirement: &70165913339980 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.1.
|
22
|
+
version: 0.1.5
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
26
|
-
description: Minimalist unit test framework,
|
25
|
+
version_requirements: *70165913339980
|
26
|
+
description: Minimalist unit test framework, easy to understand and extend.
|
27
27
|
email:
|
28
28
|
- devinfo@atpsoft.com
|
29
29
|
executables:
|
@@ -64,9 +64,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
64
|
version: '0'
|
65
65
|
requirements: []
|
66
66
|
rubyforge_project:
|
67
|
-
rubygems_version: 1.8.
|
67
|
+
rubygems_version: 1.8.15
|
68
68
|
signing_key:
|
69
69
|
specification_version: 3
|
70
70
|
summary: minimalist unit test framework
|
71
71
|
test_files:
|
72
72
|
- test/test_backtrace_parser.rb
|
73
|
+
has_rdoc:
|