test_bench 1.0.0.0 → 1.2.0.0
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 +9 -9
- data/lib/test_bench/cli.rb +2 -2
- data/lib/test_bench/cli/parse_arguments.rb +33 -20
- data/lib/test_bench/controls.rb +5 -1
- 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/summary/error.rb +0 -16
- 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 +18 -0
- data/lib/test_bench/deactivation_variants.rb +0 -10
- 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 +112 -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/writer.rb +2 -2
- data/lib/test_bench/run.rb +9 -9
- data/lib/test_bench/test_bench.rb +31 -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 -274
- 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
@@ -0,0 +1,94 @@
|
|
1
|
+
module TestBench
|
2
|
+
module Output
|
3
|
+
class Summary
|
4
|
+
module Session
|
5
|
+
def self.call(file_count: nil, test_count: nil, pass_count: nil, skip_count: nil, failure_count: nil, error_count: nil, elapsed_time: nil, writer: nil)
|
6
|
+
file_count ||= 0
|
7
|
+
test_count ||= 0
|
8
|
+
pass_count ||= 0
|
9
|
+
skip_count ||= 0
|
10
|
+
failure_count ||= 0
|
11
|
+
error_count ||= 0
|
12
|
+
elapsed_time ||= 0
|
13
|
+
writer ||= Writer.build
|
14
|
+
|
15
|
+
failed = error_count > 0
|
16
|
+
|
17
|
+
if elapsed_time.nonzero?
|
18
|
+
tests_per_second = test_count / elapsed_time
|
19
|
+
end
|
20
|
+
|
21
|
+
if failed
|
22
|
+
writer.escape_code(:red)
|
23
|
+
end
|
24
|
+
|
25
|
+
writer
|
26
|
+
.text("Finished running #{numeric_label(file_count, 'file')}")
|
27
|
+
.newline
|
28
|
+
.text("Ran %s in %.3fs (%.1f tests/second)" % [
|
29
|
+
numeric_label(test_count, 'test'),
|
30
|
+
elapsed_time,
|
31
|
+
tests_per_second || 0])
|
32
|
+
.newline
|
33
|
+
|
34
|
+
if pass_count.nonzero? && !failed
|
35
|
+
writer
|
36
|
+
.escape_code(:green)
|
37
|
+
.text("#{pass_count} passed")
|
38
|
+
.escape_code(:reset_fg)
|
39
|
+
else
|
40
|
+
writer.text("#{pass_count} passed")
|
41
|
+
end
|
42
|
+
|
43
|
+
writer.text(", ")
|
44
|
+
|
45
|
+
if skip_count.nonzero? && !failed
|
46
|
+
writer
|
47
|
+
.escape_code(:yellow)
|
48
|
+
.text("#{skip_count} skipped")
|
49
|
+
.escape_code(:reset_fg)
|
50
|
+
else
|
51
|
+
writer.text("#{skip_count} skipped")
|
52
|
+
end
|
53
|
+
|
54
|
+
writer.text(", ")
|
55
|
+
|
56
|
+
if failure_count.nonzero?
|
57
|
+
writer
|
58
|
+
.escape_code(:bold)
|
59
|
+
.text("#{failure_count} failed")
|
60
|
+
.escape_code(:reset_intensity)
|
61
|
+
else
|
62
|
+
writer.text("0 failed")
|
63
|
+
end
|
64
|
+
|
65
|
+
writer.text(", ")
|
66
|
+
|
67
|
+
if failed
|
68
|
+
writer
|
69
|
+
.escape_code(:bold)
|
70
|
+
.text(numeric_label(error_count, 'total error'))
|
71
|
+
.escape_code(:reset_intensity)
|
72
|
+
.escape_code(:reset_fg)
|
73
|
+
else
|
74
|
+
writer.text("0 total errors")
|
75
|
+
end
|
76
|
+
|
77
|
+
2.times do
|
78
|
+
writer.newline
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.numeric_label(number, label, plural_text=nil)
|
83
|
+
plural_text ||= 's'
|
84
|
+
|
85
|
+
if number == 1
|
86
|
+
"#{number} #{label}"
|
87
|
+
else
|
88
|
+
"#{number} #{label}#{plural_text}"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -130,7 +130,7 @@ module TestBench
|
|
130
130
|
end
|
131
131
|
|
132
132
|
def self.styling?(device, styling_setting=nil)
|
133
|
-
styling_setting ||= Defaults.
|
133
|
+
styling_setting ||= Defaults.styling
|
134
134
|
|
135
135
|
assure_styling_setting(styling_setting)
|
136
136
|
|
@@ -177,7 +177,7 @@ module TestBench
|
|
177
177
|
$stdout
|
178
178
|
end
|
179
179
|
|
180
|
-
def self.
|
180
|
+
def self.styling
|
181
181
|
styling = ::ENV['TEST_BENCH_OUTPUT_STYLING']
|
182
182
|
|
183
183
|
if styling.nil?
|
data/lib/test_bench/run.rb
CHANGED
@@ -3,14 +3,14 @@ module TestBench
|
|
3
3
|
Error = Class.new(RuntimeError)
|
4
4
|
|
5
5
|
def session
|
6
|
-
@session ||= Session::Substitute.build
|
6
|
+
@session ||= Fixture::Session::Substitute.build
|
7
7
|
end
|
8
8
|
attr_writer :session
|
9
9
|
|
10
|
-
def
|
11
|
-
@
|
10
|
+
def exclude_pattern
|
11
|
+
@exclude_pattern ||= Defaults.exclude_pattern
|
12
12
|
end
|
13
|
-
attr_writer :
|
13
|
+
attr_writer :exclude_pattern
|
14
14
|
|
15
15
|
attr_reader :paths
|
16
16
|
|
@@ -18,14 +18,14 @@ module TestBench
|
|
18
18
|
@paths = Array(paths)
|
19
19
|
end
|
20
20
|
|
21
|
-
def self.build(*paths,
|
21
|
+
def self.build(*paths, exclude: nil, session: nil, output: nil)
|
22
22
|
session ||= TestBench.session
|
23
23
|
|
24
24
|
instance = new(*paths)
|
25
25
|
|
26
|
-
instance.
|
26
|
+
instance.exclude_pattern = exclude unless exclude.nil?
|
27
27
|
|
28
|
-
Session.configure(instance, session: session)
|
28
|
+
Fixture::Session.configure(instance, session: session)
|
29
29
|
instance.session.output = output unless output.nil?
|
30
30
|
|
31
31
|
instance
|
@@ -80,7 +80,7 @@ module TestBench
|
|
80
80
|
glob_pattern = File.join(path, '**/*.rb')
|
81
81
|
|
82
82
|
Dir[glob_pattern].sort.each do |path|
|
83
|
-
next if
|
83
|
+
next if exclude_pattern.match?(path)
|
84
84
|
|
85
85
|
file(path)
|
86
86
|
end
|
@@ -91,7 +91,7 @@ module TestBench
|
|
91
91
|
end
|
92
92
|
|
93
93
|
module Defaults
|
94
|
-
def self.
|
94
|
+
def self.exclude_pattern
|
95
95
|
pattern = ENV.fetch('TEST_BENCH_EXCLUDE_FILE_PATTERN') do
|
96
96
|
'_init.rb$'
|
97
97
|
end
|
@@ -2,7 +2,9 @@ module TestBench
|
|
2
2
|
def self.session
|
3
3
|
@session ||= build_session.tap do |session|
|
4
4
|
at_exit do
|
5
|
-
|
5
|
+
exit_code = exit_code(session)
|
6
|
+
|
7
|
+
exit(exit_code) unless exit_code.zero?
|
6
8
|
end
|
7
9
|
end
|
8
10
|
end
|
@@ -37,6 +39,14 @@ module TestBench
|
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
42
|
+
def self.context(title=nil, session: nil, &block)
|
43
|
+
evaluate(session: session) do
|
44
|
+
context(title) do
|
45
|
+
instance_exec(&block)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
40
50
|
def self.fixture(session=nil, receiver: nil)
|
41
51
|
session ||= self.session
|
42
52
|
receiver ||= Object.new
|
@@ -57,7 +67,7 @@ module TestBench
|
|
57
67
|
end
|
58
68
|
|
59
69
|
def self.session_error_policy(abort_on_error=nil)
|
60
|
-
abort_on_error =
|
70
|
+
abort_on_error = Defaults.abort_on_error if abort_on_error.nil?
|
61
71
|
|
62
72
|
if abort_on_error
|
63
73
|
:abort
|
@@ -66,11 +76,29 @@ module TestBench
|
|
66
76
|
end
|
67
77
|
end
|
68
78
|
|
79
|
+
def self.exit_code(session, fail_deactivated_tests: nil)
|
80
|
+
if fail_deactivated_tests.nil?
|
81
|
+
fail_deactivated_tests = Defaults.fail_deactivated_tests
|
82
|
+
end
|
83
|
+
|
84
|
+
if session.failed?
|
85
|
+
1
|
86
|
+
elsif session.skip?
|
87
|
+
fail_deactivated_tests ? 2 : 0
|
88
|
+
else
|
89
|
+
0
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
69
93
|
Session = Fixture::Session
|
70
94
|
|
71
|
-
module
|
95
|
+
module Defaults
|
72
96
|
def self.abort_on_error
|
73
97
|
Environment::Boolean.fetch('TEST_BENCH_ABORT_ON_ERROR', false)
|
74
98
|
end
|
99
|
+
|
100
|
+
def self.fail_deactivated_tests
|
101
|
+
Environment::Boolean.fetch('TEST_BENCH_FAIL_DEACTIVATED_TESTS', true)
|
102
|
+
end
|
75
103
|
end
|
76
104
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test_bench
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Ladd
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: script
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test_bench-fixture
|
@@ -38,7 +38,7 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
description:
|
41
|
+
description:
|
42
42
|
email: nathanladd+github@gmail.com
|
43
43
|
executables:
|
44
44
|
- bench
|
@@ -55,12 +55,16 @@ files:
|
|
55
55
|
- lib/test_bench/controls/directory.rb
|
56
56
|
- lib/test_bench/controls/error.rb
|
57
57
|
- lib/test_bench/controls/fixture.rb
|
58
|
+
- lib/test_bench/controls/output/batch_data.rb
|
59
|
+
- lib/test_bench/controls/output/detail_setting.rb
|
58
60
|
- lib/test_bench/controls/output/escape_code.rb
|
61
|
+
- lib/test_bench/controls/output/exercise.rb
|
62
|
+
- lib/test_bench/controls/output/log_level.rb
|
59
63
|
- lib/test_bench/controls/output/newline_character.rb
|
60
64
|
- lib/test_bench/controls/output/print_error.rb
|
61
65
|
- lib/test_bench/controls/output/styling.rb
|
62
66
|
- lib/test_bench/controls/output/summary/error.rb
|
63
|
-
- lib/test_bench/controls/output/summary/
|
67
|
+
- lib/test_bench/controls/output/summary/session.rb
|
64
68
|
- lib/test_bench/controls/path.rb
|
65
69
|
- lib/test_bench/controls/pattern.rb
|
66
70
|
- lib/test_bench/controls/result.rb
|
@@ -71,16 +75,13 @@ files:
|
|
71
75
|
- lib/test_bench/fixtures.rb
|
72
76
|
- lib/test_bench/fixtures/configure_receiver.rb
|
73
77
|
- lib/test_bench/output.rb
|
74
|
-
- lib/test_bench/output/
|
75
|
-
- lib/test_bench/output/
|
76
|
-
- lib/test_bench/output/
|
77
|
-
- lib/test_bench/output/levels/none.rb
|
78
|
-
- lib/test_bench/output/levels/pass.rb
|
79
|
-
- lib/test_bench/output/levels/summary.rb
|
78
|
+
- lib/test_bench/output/batch_data.rb
|
79
|
+
- lib/test_bench/output/buffer.rb
|
80
|
+
- lib/test_bench/output/log.rb
|
80
81
|
- lib/test_bench/output/print_error.rb
|
81
|
-
- lib/test_bench/output/
|
82
|
-
- lib/test_bench/output/summary
|
83
|
-
- lib/test_bench/output/summary/
|
82
|
+
- lib/test_bench/output/raw.rb
|
83
|
+
- lib/test_bench/output/summary.rb
|
84
|
+
- lib/test_bench/output/summary/session.rb
|
84
85
|
- lib/test_bench/output/timer.rb
|
85
86
|
- lib/test_bench/output/timer/substitute.rb
|
86
87
|
- lib/test_bench/output/writer.rb
|
@@ -95,7 +96,7 @@ homepage: https://github.com/test-bench/test-bench
|
|
95
96
|
licenses:
|
96
97
|
- MIT
|
97
98
|
metadata: {}
|
98
|
-
post_install_message:
|
99
|
+
post_install_message:
|
99
100
|
rdoc_options: []
|
100
101
|
require_paths:
|
101
102
|
- lib
|
@@ -110,8 +111,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
111
|
- !ruby/object:Gem::Version
|
111
112
|
version: '0'
|
112
113
|
requirements: []
|
113
|
-
rubygems_version: 3.1.
|
114
|
-
signing_key:
|
114
|
+
rubygems_version: 3.1.3
|
115
|
+
signing_key:
|
115
116
|
specification_version: 4
|
116
117
|
summary: Principled Test Framework for Ruby
|
117
118
|
test_files: []
|
@@ -1,59 +0,0 @@
|
|
1
|
-
module TestBench
|
2
|
-
module Controls
|
3
|
-
module Output
|
4
|
-
module Summary
|
5
|
-
module Run
|
6
|
-
def self.example(writer: nil, timer: nil)
|
7
|
-
run_summary = Example.new
|
8
|
-
run_summary.writer = writer unless writer.nil?
|
9
|
-
run_summary.timer = timer unless timer.nil?
|
10
|
-
run_summary
|
11
|
-
end
|
12
|
-
|
13
|
-
class Example
|
14
|
-
include TestBench::Fixture::Output
|
15
|
-
include TestBench::Output::Summary::Run
|
16
|
-
|
17
|
-
TestBench::Fixture::Output.instance_methods.each do |method|
|
18
|
-
define_method(method) do |*|
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
module Text
|
24
|
-
def self.example
|
25
|
-
<<~TEXT
|
26
|
-
Finished running 0 files
|
27
|
-
Ran 0 tests in 0.000s (0.0 tests/second)
|
28
|
-
0 passed, 0 skipped, 0 failed, 0 total errors
|
29
|
-
|
30
|
-
TEXT
|
31
|
-
end
|
32
|
-
|
33
|
-
module Pass
|
34
|
-
def self.example
|
35
|
-
<<~TEXT
|
36
|
-
Finished running 1 file
|
37
|
-
Ran 1 test in 0.000s (0.0 tests/second)
|
38
|
-
1 passed, 0 skipped, 0 failed, 0 total errors
|
39
|
-
|
40
|
-
TEXT
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
module Failure
|
45
|
-
def self.example
|
46
|
-
<<~TEXT
|
47
|
-
Finished running 1 file
|
48
|
-
Ran 1 test in 0.000s (0.0 tests/second)
|
49
|
-
0 passed, 0 skipped, 1 failed, 1 total error
|
50
|
-
|
51
|
-
TEXT
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
module TestBench
|
2
|
-
module Output
|
3
|
-
module Build
|
4
|
-
Error = Class.new(RuntimeError)
|
5
|
-
|
6
|
-
def self.call(level: nil, **args)
|
7
|
-
level ||= Defaults.level
|
8
|
-
|
9
|
-
level_setting = level
|
10
|
-
|
11
|
-
cls = level_class(level_setting)
|
12
|
-
|
13
|
-
cls.build(**args)
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.level_class(level_setting)
|
17
|
-
assure_level(level_setting)
|
18
|
-
|
19
|
-
levels.fetch(level_setting)
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.levels
|
23
|
-
{
|
24
|
-
:none => Levels::None,
|
25
|
-
:summary => Levels::Summary,
|
26
|
-
:failure => Levels::Failure,
|
27
|
-
:pass => Levels::Pass,
|
28
|
-
:debug => Levels::Debug
|
29
|
-
}
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.level_settings
|
33
|
-
levels.keys
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.assure_level(level_setting)
|
37
|
-
unless level_settings.include?(level_setting)
|
38
|
-
raise Error, "Unknown output level #{level_setting.inspect} (Valid levels: #{level_settings.map(&:inspect) * ', '})"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
module Defaults
|
43
|
-
def self.level
|
44
|
-
verbose = Environment::Boolean.fetch('VERBOSE')
|
45
|
-
|
46
|
-
if verbose.nil?
|
47
|
-
level_text = ENV.fetch('TEST_BENCH_OUTPUT_LEVEL', 'pass')
|
48
|
-
|
49
|
-
level_text.to_sym
|
50
|
-
else
|
51
|
-
:debug
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,229 +0,0 @@
|
|
1
|
-
module TestBench
|
2
|
-
module Output
|
3
|
-
module Levels
|
4
|
-
class Debug
|
5
|
-
include TestBench::Fixture::Output
|
6
|
-
|
7
|
-
include Writer::Dependency
|
8
|
-
|
9
|
-
include PrintError
|
10
|
-
|
11
|
-
include Output::Summary::Error
|
12
|
-
include Output::Summary::Run
|
13
|
-
|
14
|
-
def previous_byte_offset
|
15
|
-
@previous_byte_offset ||= 0
|
16
|
-
end
|
17
|
-
attr_writer :previous_byte_offset
|
18
|
-
|
19
|
-
def self.build(omit_backtrace_pattern: nil, reverse_backtraces: nil, writer: nil, styling: nil, device: nil)
|
20
|
-
instance = new
|
21
|
-
|
22
|
-
instance.omit_backtrace_pattern = omit_backtrace_pattern unless omit_backtrace_pattern.nil?
|
23
|
-
instance.reverse_backtraces = reverse_backtraces unless reverse_backtraces.nil?
|
24
|
-
|
25
|
-
Writer.configure(instance, writer: writer, styling: styling, device: device)
|
26
|
-
Timer.configure(instance)
|
27
|
-
|
28
|
-
instance
|
29
|
-
end
|
30
|
-
|
31
|
-
def comment(text)
|
32
|
-
writer
|
33
|
-
.indent
|
34
|
-
.text(text)
|
35
|
-
.newline
|
36
|
-
end
|
37
|
-
|
38
|
-
def error(error)
|
39
|
-
print_error(error)
|
40
|
-
end
|
41
|
-
|
42
|
-
def finish_test(title, result)
|
43
|
-
writer.decrease_indentation
|
44
|
-
|
45
|
-
fg_color = result ? :green : :red
|
46
|
-
|
47
|
-
writer.indent
|
48
|
-
|
49
|
-
writer
|
50
|
-
.escape_code(fg_color)
|
51
|
-
.text("Finished test")
|
52
|
-
|
53
|
-
unless title.nil?
|
54
|
-
writer
|
55
|
-
.text(' ')
|
56
|
-
.escape_code(:bold)
|
57
|
-
.text(title.inspect)
|
58
|
-
.escape_code(:reset_intensity)
|
59
|
-
end
|
60
|
-
|
61
|
-
writer
|
62
|
-
.text(" (Result: #{result ? 'pass' : 'failure'})")
|
63
|
-
.escape_code(:reset_fg)
|
64
|
-
.newline
|
65
|
-
end
|
66
|
-
|
67
|
-
def skip_test(title)
|
68
|
-
writer.indent
|
69
|
-
|
70
|
-
writer
|
71
|
-
.escape_code(:yellow)
|
72
|
-
.text("Skipped test")
|
73
|
-
|
74
|
-
unless title.nil?
|
75
|
-
writer
|
76
|
-
.text(' ')
|
77
|
-
.escape_code(:bold)
|
78
|
-
.text(title.inspect)
|
79
|
-
.escape_code(:reset_intensity)
|
80
|
-
end
|
81
|
-
|
82
|
-
writer
|
83
|
-
.escape_code(:reset_fg)
|
84
|
-
.newline
|
85
|
-
end
|
86
|
-
|
87
|
-
def start_test(title)
|
88
|
-
if title.nil?
|
89
|
-
text = "Starting test"
|
90
|
-
else
|
91
|
-
text = "Starting test #{title.inspect}"
|
92
|
-
end
|
93
|
-
|
94
|
-
writer
|
95
|
-
.indent
|
96
|
-
.escape_code(:cyan)
|
97
|
-
.text(text)
|
98
|
-
.escape_code(:reset_fg)
|
99
|
-
.newline
|
100
|
-
|
101
|
-
writer.increase_indentation
|
102
|
-
end
|
103
|
-
|
104
|
-
def enter_context(title)
|
105
|
-
return if title.nil?
|
106
|
-
|
107
|
-
writer
|
108
|
-
.indent
|
109
|
-
.escape_code(:green)
|
110
|
-
.text(title)
|
111
|
-
.escape_code(:reset_fg)
|
112
|
-
.newline
|
113
|
-
|
114
|
-
writer.increase_indentation
|
115
|
-
end
|
116
|
-
|
117
|
-
def exit_context(title, result)
|
118
|
-
return if title.nil?
|
119
|
-
|
120
|
-
writer.decrease_indentation
|
121
|
-
|
122
|
-
fg_color = result ? :green : :red
|
123
|
-
|
124
|
-
text = "Finished context #{title.inspect} (Result: #{result ? 'pass' : 'failure'})"
|
125
|
-
|
126
|
-
writer
|
127
|
-
.indent
|
128
|
-
.escape_code(:faint)
|
129
|
-
.escape_code(:italic)
|
130
|
-
.escape_code(fg_color)
|
131
|
-
.text(text)
|
132
|
-
.escape_code(:reset_fg)
|
133
|
-
.escape_code(:reset_italic)
|
134
|
-
.escape_code(:reset_intensity)
|
135
|
-
.newline
|
136
|
-
|
137
|
-
writer.newline if writer.indentation_depth.zero?
|
138
|
-
end
|
139
|
-
|
140
|
-
def skip_context(title)
|
141
|
-
return if title.nil?
|
142
|
-
|
143
|
-
writer
|
144
|
-
.indent
|
145
|
-
.escape_code(:yellow)
|
146
|
-
.text(title)
|
147
|
-
.escape_code(:reset_fg)
|
148
|
-
.newline
|
149
|
-
|
150
|
-
writer.newline if writer.indentation_depth.zero?
|
151
|
-
end
|
152
|
-
|
153
|
-
def start_fixture(fixture)
|
154
|
-
fixture_class = fixture.class.inspect
|
155
|
-
|
156
|
-
writer
|
157
|
-
.indent
|
158
|
-
.escape_code(:blue)
|
159
|
-
.text("Starting fixture (Fixture: #{fixture_class})")
|
160
|
-
.escape_code(:reset_fg)
|
161
|
-
.newline
|
162
|
-
|
163
|
-
writer.increase_indentation
|
164
|
-
end
|
165
|
-
|
166
|
-
def finish_fixture(fixture, result)
|
167
|
-
fixture_class = fixture.class.inspect
|
168
|
-
|
169
|
-
writer.decrease_indentation
|
170
|
-
|
171
|
-
writer
|
172
|
-
.indent
|
173
|
-
.escape_code(:magenta)
|
174
|
-
.text("Finished fixture (Fixture: #{fixture_class}, Result: #{result ? 'pass' : 'failure'})")
|
175
|
-
.escape_code(:reset_fg)
|
176
|
-
.newline
|
177
|
-
|
178
|
-
writer.newline if writer.indentation_depth.zero?
|
179
|
-
end
|
180
|
-
|
181
|
-
def enter_file(file)
|
182
|
-
text = "Running #{file}"
|
183
|
-
|
184
|
-
writer.text(text).newline
|
185
|
-
|
186
|
-
self.previous_byte_offset = writer.byte_offset
|
187
|
-
end
|
188
|
-
|
189
|
-
def exit_file(file, _)
|
190
|
-
unless writer.byte_offset > previous_byte_offset
|
191
|
-
writer
|
192
|
-
.escape_code(:faint)
|
193
|
-
.text("(Nothing written)")
|
194
|
-
.escape_code(:reset_intensity)
|
195
|
-
.newline
|
196
|
-
|
197
|
-
writer.newline
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
def enter_assert_block(caller_location)
|
202
|
-
text = "Entered assert block (Caller Location: #{caller_location})"
|
203
|
-
|
204
|
-
writer
|
205
|
-
.indent
|
206
|
-
.escape_code(:blue)
|
207
|
-
.text(text)
|
208
|
-
.escape_code(:reset_fg)
|
209
|
-
.newline
|
210
|
-
|
211
|
-
writer.increase_indentation
|
212
|
-
end
|
213
|
-
|
214
|
-
def exit_assert_block(caller_location, result)
|
215
|
-
writer.decrease_indentation
|
216
|
-
|
217
|
-
text = "Exited assert block (Caller Location: #{caller_location}, Result: #{result ? 'pass' : 'failure'})"
|
218
|
-
|
219
|
-
writer
|
220
|
-
.indent
|
221
|
-
.escape_code(:cyan)
|
222
|
-
.text(text)
|
223
|
-
.escape_code(:reset_fg)
|
224
|
-
.newline
|
225
|
-
end
|
226
|
-
end
|
227
|
-
end
|
228
|
-
end
|
229
|
-
end
|