test_bench 1.0.1.0 → 1.2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/test_bench.rb +12 -10
- data/lib/test_bench/cli.rb +2 -2
- data/lib/test_bench/cli/parse_arguments.rb +50 -37
- data/lib/test_bench/controls.rb +8 -2
- data/lib/test_bench/controls/error.rb +8 -8
- data/lib/test_bench/controls/output/batch_data.rb +52 -0
- data/lib/test_bench/controls/output/detail_setting.rb +29 -0
- data/lib/test_bench/controls/output/exercise.rb +7 -0
- data/lib/test_bench/controls/output/log_level.rb +7 -0
- data/lib/test_bench/controls/output/newline_character.rb +6 -1
- data/lib/test_bench/controls/output/summary/error.rb +5 -21
- data/lib/test_bench/controls/output/summary/session.rb +20 -0
- data/lib/test_bench/controls/pattern.rb +6 -2
- data/lib/test_bench/controls/time.rb +30 -2
- data/lib/test_bench/deactivation_variants.rb +0 -10
- data/lib/test_bench/fixtures.rb +3 -1
- data/lib/test_bench/output.rb +14 -2
- data/lib/test_bench/output/batch_data.rb +17 -0
- data/lib/test_bench/output/buffer.rb +114 -0
- data/lib/test_bench/output/log.rb +27 -0
- data/lib/test_bench/output/raw.rb +353 -0
- data/lib/test_bench/output/summary.rb +146 -0
- data/lib/test_bench/output/summary/session.rb +94 -0
- data/lib/test_bench/output/timer/substitute.rb +1 -1
- data/lib/test_bench/output/writer.rb +3 -3
- data/lib/test_bench/run.rb +9 -9
- data/lib/test_bench/test_bench.rb +23 -3
- metadata +18 -17
- data/lib/test_bench/controls/output/summary/run.rb +0 -59
- data/lib/test_bench/output/build.rb +0 -57
- data/lib/test_bench/output/levels/debug.rb +0 -229
- data/lib/test_bench/output/levels/failure.rb +0 -31
- data/lib/test_bench/output/levels/none.rb +0 -13
- data/lib/test_bench/output/levels/pass.rb +0 -286
- data/lib/test_bench/output/levels/summary.rb +0 -21
- data/lib/test_bench/output/summary/error.rb +0 -77
- data/lib/test_bench/output/summary/run.rb +0 -102
- data/lib/test_bench/output/summary/run/print.rb +0 -98
@@ -1,21 +0,0 @@
|
|
1
|
-
module TestBench
|
2
|
-
module Output
|
3
|
-
module Levels
|
4
|
-
class Summary
|
5
|
-
include TestBench::Fixture::Output
|
6
|
-
|
7
|
-
include Output::Summary::Error
|
8
|
-
include Output::Summary::Run
|
9
|
-
|
10
|
-
def self.build(writer: nil, styling: nil, device: nil)
|
11
|
-
warn "Warning: #{self} is deprecated. It will remain in the TestBench v2 series, but will be removed from TestBench v3"
|
12
|
-
|
13
|
-
instance = new
|
14
|
-
Writer.configure(instance, writer: writer, styling: styling, device: device)
|
15
|
-
Timer.configure(instance)
|
16
|
-
instance
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
module TestBench
|
2
|
-
module Output
|
3
|
-
module Summary
|
4
|
-
module Error
|
5
|
-
include Writer::Dependency
|
6
|
-
|
7
|
-
def self.included(cls)
|
8
|
-
cls.prepend(OutputMethods)
|
9
|
-
end
|
10
|
-
|
11
|
-
def error_summary_errors
|
12
|
-
@error_summary_errors ||= Hash.new do |hash, key|
|
13
|
-
hash[key] = []
|
14
|
-
end
|
15
|
-
end
|
16
|
-
attr_writer :error_summary_errors
|
17
|
-
|
18
|
-
attr_accessor :error_summary_current_file
|
19
|
-
|
20
|
-
def error_summary
|
21
|
-
return if error_summary_errors.empty?
|
22
|
-
|
23
|
-
writer
|
24
|
-
.escape_code(:bold)
|
25
|
-
.escape_code(:red)
|
26
|
-
.text('Error Summary:')
|
27
|
-
.escape_code(:reset_intensity)
|
28
|
-
.escape_code(:reset_fg)
|
29
|
-
.newline
|
30
|
-
|
31
|
-
error_summary_errors.each do |file, errors|
|
32
|
-
error_count = errors.count
|
33
|
-
|
34
|
-
writer
|
35
|
-
.text(error_count.to_s.rjust(4, ' '))
|
36
|
-
.text(": #{file}")
|
37
|
-
.newline
|
38
|
-
|
39
|
-
errors.each do |error|
|
40
|
-
writer
|
41
|
-
.text(' ')
|
42
|
-
.escape_code(:red)
|
43
|
-
|
44
|
-
PrintError.error_message(error, writer: writer)
|
45
|
-
|
46
|
-
writer.escape_code(:reset_fg)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
writer.newline
|
51
|
-
end
|
52
|
-
|
53
|
-
module OutputMethods
|
54
|
-
def enter_file(file)
|
55
|
-
super
|
56
|
-
|
57
|
-
self.error_summary_current_file = file
|
58
|
-
end
|
59
|
-
|
60
|
-
def error(error)
|
61
|
-
super
|
62
|
-
|
63
|
-
current_file = error_summary_current_file
|
64
|
-
|
65
|
-
self.error_summary_errors[current_file] << error
|
66
|
-
end
|
67
|
-
|
68
|
-
def finish(_)
|
69
|
-
super
|
70
|
-
|
71
|
-
error_summary
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
@@ -1,102 +0,0 @@
|
|
1
|
-
module TestBench
|
2
|
-
module Output
|
3
|
-
module Summary
|
4
|
-
module Run
|
5
|
-
include Writer::Dependency
|
6
|
-
extend Print
|
7
|
-
|
8
|
-
def self.included(cls)
|
9
|
-
cls.prepend(OutputMethods)
|
10
|
-
end
|
11
|
-
|
12
|
-
def file_count
|
13
|
-
@file_count ||= 0
|
14
|
-
end
|
15
|
-
attr_writer :file_count
|
16
|
-
|
17
|
-
def test_count
|
18
|
-
@test_count ||= 0
|
19
|
-
end
|
20
|
-
attr_writer :test_count
|
21
|
-
|
22
|
-
def pass_count
|
23
|
-
@pass_count ||= 0
|
24
|
-
end
|
25
|
-
attr_writer :pass_count
|
26
|
-
|
27
|
-
def skip_count
|
28
|
-
@skip_count ||= 0
|
29
|
-
end
|
30
|
-
attr_writer :skip_count
|
31
|
-
|
32
|
-
def failure_count
|
33
|
-
@failure_count ||= 0
|
34
|
-
end
|
35
|
-
attr_writer :failure_count
|
36
|
-
|
37
|
-
def error_count
|
38
|
-
@error_count ||= 0
|
39
|
-
end
|
40
|
-
attr_writer :error_count
|
41
|
-
|
42
|
-
def elapsed_time
|
43
|
-
@elapsed_time ||= 0
|
44
|
-
end
|
45
|
-
attr_writer :elapsed_time
|
46
|
-
|
47
|
-
def timer
|
48
|
-
@timer ||= Timer::Substitute.build
|
49
|
-
end
|
50
|
-
attr_writer :timer
|
51
|
-
|
52
|
-
module OutputMethods
|
53
|
-
def enter_file(_)
|
54
|
-
super
|
55
|
-
|
56
|
-
timer.start
|
57
|
-
end
|
58
|
-
|
59
|
-
def exit_file(_, _)
|
60
|
-
super
|
61
|
-
|
62
|
-
elapsed_time = timer.stop
|
63
|
-
|
64
|
-
self.elapsed_time += elapsed_time
|
65
|
-
|
66
|
-
self.file_count += 1
|
67
|
-
end
|
68
|
-
|
69
|
-
def finish_test(_, result)
|
70
|
-
super
|
71
|
-
|
72
|
-
self.test_count += 1
|
73
|
-
|
74
|
-
if result
|
75
|
-
self.pass_count += 1
|
76
|
-
else
|
77
|
-
self.failure_count += 1
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def skip_test(_)
|
82
|
-
super
|
83
|
-
|
84
|
-
self.skip_count += 1
|
85
|
-
end
|
86
|
-
|
87
|
-
def error(_)
|
88
|
-
super
|
89
|
-
|
90
|
-
self.error_count += 1
|
91
|
-
end
|
92
|
-
|
93
|
-
def finish(_)
|
94
|
-
super
|
95
|
-
|
96
|
-
Print.(file_count: file_count, test_count: test_count, pass_count: pass_count, skip_count: skip_count, failure_count: failure_count, error_count: error_count, elapsed_time: elapsed_time, writer: writer)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
@@ -1,98 +0,0 @@
|
|
1
|
-
module TestBench
|
2
|
-
module Output
|
3
|
-
module Summary
|
4
|
-
module Run
|
5
|
-
module Print
|
6
|
-
extend self
|
7
|
-
|
8
|
-
def call(file_count: nil, test_count: nil, pass_count: nil, skip_count: nil, failure_count: nil, error_count: nil, elapsed_time: nil, writer: nil)
|
9
|
-
file_count ||= 0
|
10
|
-
test_count ||= 0
|
11
|
-
pass_count ||= 0
|
12
|
-
skip_count ||= 0
|
13
|
-
failure_count ||= 0
|
14
|
-
error_count ||= 0
|
15
|
-
elapsed_time ||= 0
|
16
|
-
writer ||= Writer.build
|
17
|
-
|
18
|
-
failed = error_count > 0
|
19
|
-
|
20
|
-
if elapsed_time.nonzero?
|
21
|
-
tests_per_second = test_count / elapsed_time
|
22
|
-
end
|
23
|
-
|
24
|
-
if failed
|
25
|
-
writer.escape_code(:red)
|
26
|
-
end
|
27
|
-
|
28
|
-
writer
|
29
|
-
.text("Finished running #{numeric_label(file_count, 'file')}")
|
30
|
-
.newline
|
31
|
-
.text("Ran %s in %.3fs (%.1f tests/second)" % [
|
32
|
-
numeric_label(test_count, 'test'),
|
33
|
-
elapsed_time,
|
34
|
-
tests_per_second || 0])
|
35
|
-
.newline
|
36
|
-
|
37
|
-
if pass_count.nonzero? && !failed
|
38
|
-
writer
|
39
|
-
.escape_code(:green)
|
40
|
-
.text("#{pass_count} passed")
|
41
|
-
.escape_code(:reset_fg)
|
42
|
-
else
|
43
|
-
writer.text("#{pass_count} passed")
|
44
|
-
end
|
45
|
-
|
46
|
-
writer.text(", ")
|
47
|
-
|
48
|
-
if skip_count.nonzero? && !failed
|
49
|
-
writer
|
50
|
-
.escape_code(:yellow)
|
51
|
-
.text("#{skip_count} skipped")
|
52
|
-
.escape_code(:reset_fg)
|
53
|
-
else
|
54
|
-
writer.text("#{skip_count} skipped")
|
55
|
-
end
|
56
|
-
|
57
|
-
writer.text(", ")
|
58
|
-
|
59
|
-
if failure_count.nonzero?
|
60
|
-
writer
|
61
|
-
.escape_code(:bold)
|
62
|
-
.text("#{failure_count} failed")
|
63
|
-
.escape_code(:reset_intensity)
|
64
|
-
else
|
65
|
-
writer.text("0 failed")
|
66
|
-
end
|
67
|
-
|
68
|
-
writer.text(", ")
|
69
|
-
|
70
|
-
if failed
|
71
|
-
writer
|
72
|
-
.escape_code(:bold)
|
73
|
-
.text(numeric_label(error_count, 'total error'))
|
74
|
-
.escape_code(:reset_intensity)
|
75
|
-
.escape_code(:reset_fg)
|
76
|
-
else
|
77
|
-
writer.text("0 total errors")
|
78
|
-
end
|
79
|
-
|
80
|
-
2.times do
|
81
|
-
writer.newline
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
def numeric_label(number, label, plural_text=nil)
|
86
|
-
plural_text ||= 's'
|
87
|
-
|
88
|
-
if number == 1
|
89
|
-
"#{number} #{label}"
|
90
|
-
else
|
91
|
-
"#{number} #{label}#{plural_text}"
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|