test_bench-output 2.1.1.3 → 3.0.0.0.pre.1
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/output/comment_style.rb +61 -0
- data/lib/test_bench/output/controls/comment_style.rb +21 -0
- data/lib/test_bench/output/controls/event.rb +2 -2
- data/lib/test_bench/output/controls/events/aborted.rb +9 -0
- data/lib/test_bench/output/controls/events/commented.rb +21 -0
- data/lib/test_bench/output/controls/events/context_finished.rb +9 -0
- data/lib/test_bench/output/controls/events/context_started.rb +9 -0
- data/lib/test_bench/output/controls/events/detailed.rb +21 -0
- data/lib/test_bench/output/controls/events/failed.rb +9 -0
- data/lib/test_bench/output/controls/events/file_executed.rb +9 -0
- data/lib/test_bench/output/controls/events/file_not_found.rb +9 -0
- data/lib/test_bench/output/controls/events/file_queued.rb +9 -0
- data/lib/test_bench/output/controls/events/skipped.rb +9 -0
- data/lib/test_bench/output/controls/events/test_finished.rb +9 -0
- data/lib/test_bench/output/controls/events/test_started.rb +9 -0
- data/lib/test_bench/output/controls/random.rb +2 -2
- data/lib/test_bench/output/controls/session.rb +17 -0
- data/lib/test_bench/output/controls/status.rb +7 -0
- data/lib/test_bench/output/controls/style.rb +14 -6
- data/lib/test_bench/output/controls/text.rb +16 -4
- data/lib/test_bench/output/controls.rb +21 -5
- data/lib/test_bench/output/detail_policy.rb +44 -0
- data/lib/test_bench/output/device/null.rb +3 -3
- data/lib/test_bench/output/device/substitute.rb +19 -33
- data/lib/test_bench/output/device.rb +73 -0
- data/lib/test_bench/output/get.rb +30 -0
- data/lib/test_bench/output/level.rb +51 -0
- data/lib/test_bench/output/output.rb +540 -36
- data/lib/test_bench/output/writer/style.rb +3 -3
- data/lib/test_bench/output/writer/substitute.rb +10 -23
- data/lib/test_bench/output/writer.rb +54 -147
- data/lib/test_bench/output.rb +10 -4
- metadata +49 -21
- data/lib/test_bench/output/controls/data.rb +0 -49
- data/lib/test_bench/output/controls/device.rb +0 -27
- data/lib/test_bench/output/controls/output.rb +0 -34
- data/lib/test_bench/output/controls/styling.rb +0 -27
- data/lib/test_bench/output/digest.rb +0 -113
- data/lib/test_bench/output/writer/buffer.rb +0 -57
- data/lib/test_bench/output/writer/defaults.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e0f38c7295b1224d2d8e379baedbc63eca93df6072eb3c3aa57262fc199428a
|
4
|
+
data.tar.gz: f3b40e1d2d46219fbf937284bc24a48cc9f1572c65baf888db1f7ecbdeae9b77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 554435db7dfcfcd909037034b7781f9caecd142ccd655354be24ceb3d96b775303d0c149841a3b77f297bd0c56ffc39c554cb0012964174627a1cd3f113d97e2
|
7
|
+
data.tar.gz: 61e48708d47b1f7f32b27ecf3f1818ef3811e4b427f2766e1707b11618d751cf930a281639350f5143f0f460cc6fbbe18c99756cfd0469e0d47a64f872f3f4b8
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module TestBench
|
2
|
+
class Output
|
3
|
+
module CommentStyle
|
4
|
+
Error = Class.new(RuntimeError)
|
5
|
+
|
6
|
+
def self.fetch(comment_disposition)
|
7
|
+
comment_style = get(comment_disposition)
|
8
|
+
|
9
|
+
comment_style ||= normal
|
10
|
+
|
11
|
+
comment_style
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.get(comment_disposition)
|
15
|
+
comment_style, _ = comment_styles.rassoc(comment_disposition)
|
16
|
+
comment_style
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.get_disposition(comment_style)
|
20
|
+
comment_styles.fetch(comment_style) do
|
21
|
+
raise Error, "Incorrect comment style: #{comment_style.inspect}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.comment_styles
|
26
|
+
{
|
27
|
+
:detect => 'detect',
|
28
|
+
:normal => 'normal',
|
29
|
+
:heading => 'heading',
|
30
|
+
:block => 'block',
|
31
|
+
:line_number => 'line_number',
|
32
|
+
:raw => 'raw'
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.detect
|
37
|
+
:detect
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.normal
|
41
|
+
:normal
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.heading
|
45
|
+
:heading
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.block
|
49
|
+
:block
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.line_number
|
53
|
+
:line_number
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.raw
|
57
|
+
:raw
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module TestBench
|
2
|
+
class Output
|
3
|
+
module Controls
|
4
|
+
module CommentStyle
|
5
|
+
def self.example
|
6
|
+
:normal
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.disposition
|
10
|
+
'normal'
|
11
|
+
end
|
12
|
+
|
13
|
+
module Disposition
|
14
|
+
def self.example
|
15
|
+
Session::CommentDisposition.example
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module TestBench
|
2
|
+
class Output
|
3
|
+
module Controls
|
4
|
+
module Events
|
5
|
+
module Commented
|
6
|
+
def self.example(text: nil, style: nil)
|
7
|
+
style ||= self.style
|
8
|
+
|
9
|
+
disposition = Output::CommentStyle.get_disposition(style)
|
10
|
+
|
11
|
+
Session::Events::Commented.example(text:, disposition:)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.style
|
15
|
+
CommentStyle.example
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module TestBench
|
2
|
+
class Output
|
3
|
+
module Controls
|
4
|
+
module Events
|
5
|
+
module Detailed
|
6
|
+
def self.example(text: nil, style: nil)
|
7
|
+
style ||= self.style
|
8
|
+
|
9
|
+
disposition = Output::CommentStyle.get_disposition(style)
|
10
|
+
|
11
|
+
Session::Events::Detailed.example(text:, disposition:)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.style
|
15
|
+
CommentStyle.example
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module TestBench
|
2
|
+
class Output
|
3
|
+
module Controls
|
4
|
+
module Session
|
5
|
+
Events = TestBench::Session::Controls::Events
|
6
|
+
|
7
|
+
Event = TestBench::Session::Controls::Event
|
8
|
+
|
9
|
+
Status = TestBench::Session::Controls::Status
|
10
|
+
|
11
|
+
Random = TestBench::Session::Controls::Random
|
12
|
+
|
13
|
+
CommentDisposition = TestBench::Session::Controls::CommentDisposition
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,28 +1,36 @@
|
|
1
1
|
module TestBench
|
2
|
-
|
2
|
+
class Output
|
3
3
|
module Controls
|
4
4
|
module Style
|
5
5
|
def self.example
|
6
6
|
:bold
|
7
7
|
end
|
8
8
|
|
9
|
+
def self.code
|
10
|
+
'1'
|
11
|
+
end
|
12
|
+
|
9
13
|
def self.other_example
|
10
|
-
|
14
|
+
Other.example
|
11
15
|
end
|
12
16
|
|
13
|
-
module
|
17
|
+
module Other
|
14
18
|
def self.example
|
15
|
-
:
|
19
|
+
:italic
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.code
|
23
|
+
'3'
|
16
24
|
end
|
17
25
|
end
|
18
26
|
|
19
27
|
module Code
|
20
28
|
def self.example
|
21
|
-
|
29
|
+
Style.code
|
22
30
|
end
|
23
31
|
|
24
32
|
def self.other_example
|
25
|
-
|
33
|
+
Other.code
|
26
34
|
end
|
27
35
|
end
|
28
36
|
end
|
@@ -1,15 +1,27 @@
|
|
1
1
|
module TestBench
|
2
|
-
|
2
|
+
class Output
|
3
3
|
module Controls
|
4
4
|
module Text
|
5
5
|
def self.example
|
6
6
|
"Some text"
|
7
7
|
end
|
8
8
|
|
9
|
-
def self.
|
10
|
-
|
9
|
+
def self.other_example
|
10
|
+
"Some other text"
|
11
|
+
end
|
12
|
+
|
13
|
+
module NewlineTerminated
|
14
|
+
def self.example(lines: nil)
|
15
|
+
lines ||= 1
|
16
|
+
|
17
|
+
line_count = lines
|
18
|
+
|
19
|
+
lines = (1..line_count).map do |line_number|
|
20
|
+
"Line #{line_number}\n"
|
21
|
+
end
|
11
22
|
|
12
|
-
|
23
|
+
lines.join
|
24
|
+
end
|
13
25
|
end
|
14
26
|
end
|
15
27
|
end
|
@@ -1,10 +1,26 @@
|
|
1
|
-
require 'test_bench/
|
1
|
+
require 'test_bench/session/controls'
|
2
|
+
|
3
|
+
require 'test_bench/output/controls/session'
|
2
4
|
|
3
5
|
require 'test_bench/output/controls/random'
|
4
|
-
require 'test_bench/output/controls/
|
5
|
-
require 'test_bench/output/controls/device'
|
6
|
+
require 'test_bench/output/controls/status'
|
6
7
|
require 'test_bench/output/controls/text'
|
7
|
-
|
8
|
+
|
8
9
|
require 'test_bench/output/controls/style'
|
9
|
-
|
10
|
+
|
11
|
+
require 'test_bench/output/controls/comment_style'
|
12
|
+
|
13
|
+
require 'test_bench/output/controls/events/failed'
|
14
|
+
require 'test_bench/output/controls/events/aborted'
|
15
|
+
require 'test_bench/output/controls/events/skipped'
|
16
|
+
require 'test_bench/output/controls/events/commented'
|
17
|
+
require 'test_bench/output/controls/events/detailed'
|
18
|
+
require 'test_bench/output/controls/events/test_started'
|
19
|
+
require 'test_bench/output/controls/events/test_finished'
|
20
|
+
require 'test_bench/output/controls/events/context_started'
|
21
|
+
require 'test_bench/output/controls/events/context_finished'
|
22
|
+
require 'test_bench/output/controls/events/file_queued'
|
23
|
+
require 'test_bench/output/controls/events/file_executed'
|
24
|
+
require 'test_bench/output/controls/events/file_not_found'
|
25
|
+
|
10
26
|
require 'test_bench/output/controls/event'
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module TestBench
|
2
|
+
class Output
|
3
|
+
module DetailPolicy
|
4
|
+
Error = Class.new(RuntimeError)
|
5
|
+
|
6
|
+
def self.failure
|
7
|
+
:failure
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.on
|
11
|
+
:on
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.off
|
15
|
+
:off
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.detail?(detail_policy, result=nil)
|
19
|
+
result ||= Session::Result.none
|
20
|
+
|
21
|
+
case detail_policy
|
22
|
+
when failure
|
23
|
+
[
|
24
|
+
Session::Result.failed,
|
25
|
+
Session::Result.aborted
|
26
|
+
].include?(result)
|
27
|
+
|
28
|
+
when on
|
29
|
+
true
|
30
|
+
|
31
|
+
when off
|
32
|
+
false
|
33
|
+
|
34
|
+
else
|
35
|
+
raise Error, "Incorrect detail policy: #{detail_policy.inspect}"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.assure_policy(detail_policy)
|
40
|
+
detail?(detail_policy)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -1,56 +1,42 @@
|
|
1
1
|
module TestBench
|
2
|
-
|
3
|
-
|
2
|
+
class Output
|
3
|
+
class Device
|
4
4
|
module Substitute
|
5
5
|
def self.build
|
6
6
|
Device.new
|
7
7
|
end
|
8
8
|
|
9
9
|
class Device
|
10
|
-
def
|
11
|
-
@
|
10
|
+
def written_text
|
11
|
+
@written_text ||= String.new
|
12
12
|
end
|
13
|
-
attr_writer :
|
14
|
-
|
15
|
-
def flushed_data
|
16
|
-
@flushed_data ||= String.new
|
17
|
-
end
|
18
|
-
attr_writer :flushed_data
|
13
|
+
attr_writer :written_text
|
19
14
|
|
20
15
|
attr_accessor :tty
|
21
|
-
def tty? = !!tty
|
22
|
-
|
23
|
-
def write(data)
|
24
|
-
bytes_written = data.bytesize
|
25
|
-
|
26
|
-
written_data << data
|
27
16
|
|
28
|
-
|
17
|
+
def tty?
|
18
|
+
tty ? true : false
|
29
19
|
end
|
30
20
|
|
31
|
-
def
|
32
|
-
|
21
|
+
def set_tty
|
22
|
+
self.tty = true
|
33
23
|
end
|
34
24
|
|
35
|
-
def
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
25
|
+
def write(text)
|
26
|
+
bytes_written = text.bytesize
|
27
|
+
|
28
|
+
written_text << text
|
29
|
+
|
30
|
+
bytes_written
|
41
31
|
end
|
42
32
|
|
43
|
-
def
|
44
|
-
if
|
45
|
-
!
|
33
|
+
def written?(text=nil)
|
34
|
+
if text.nil?
|
35
|
+
!written_text.empty?
|
46
36
|
else
|
47
|
-
|
37
|
+
written_text == text
|
48
38
|
end
|
49
39
|
end
|
50
|
-
|
51
|
-
def tty!
|
52
|
-
self.tty = true
|
53
|
-
end
|
54
40
|
end
|
55
41
|
end
|
56
42
|
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module TestBench
|
2
|
+
class Output
|
3
|
+
class Device
|
4
|
+
Error = Class.new(RuntimeError)
|
5
|
+
|
6
|
+
def raw_device
|
7
|
+
@raw_device ||= Substitute.build
|
8
|
+
end
|
9
|
+
attr_writer :raw_device
|
10
|
+
|
11
|
+
def self.build(target_device=nil)
|
12
|
+
target_device ||= Defaults.target_device
|
13
|
+
|
14
|
+
raw_device = raw_device(target_device)
|
15
|
+
|
16
|
+
instance = new
|
17
|
+
instance.raw_device = raw_device
|
18
|
+
instance
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.configure(receiver, device: nil, attr_name: nil)
|
22
|
+
attr_name ||= :device
|
23
|
+
|
24
|
+
if device.instance_of?(self)
|
25
|
+
instance = device
|
26
|
+
else
|
27
|
+
target_device = device
|
28
|
+
|
29
|
+
instance = build(target_device)
|
30
|
+
end
|
31
|
+
|
32
|
+
receiver.public_send(:"#{attr_name}=", instance)
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.raw_device(target_device)
|
36
|
+
case target_device
|
37
|
+
in :stdout
|
38
|
+
STDOUT
|
39
|
+
in :stderr
|
40
|
+
STDERR
|
41
|
+
in :null
|
42
|
+
Null.instance
|
43
|
+
in Symbol
|
44
|
+
raise Error, "Incorrect output device: #{target_device.inspect}"
|
45
|
+
else
|
46
|
+
target_device
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def write(text)
|
51
|
+
raw_device.write(text)
|
52
|
+
|
53
|
+
text.bytesize
|
54
|
+
end
|
55
|
+
|
56
|
+
def tty?
|
57
|
+
raw_device.tty?
|
58
|
+
end
|
59
|
+
|
60
|
+
module Defaults
|
61
|
+
def self.target_device
|
62
|
+
env_target_device = ENV.fetch('TEST_BENCH_OUTPUT_DEVICE') do
|
63
|
+
STDOUT.sync = true
|
64
|
+
|
65
|
+
'stdout'
|
66
|
+
end
|
67
|
+
|
68
|
+
env_target_device.to_sym
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module TestBench
|
2
|
+
class Output
|
3
|
+
module Get
|
4
|
+
Error = Class.new(RuntimeError)
|
5
|
+
|
6
|
+
def self.call(substitute_session, styling: nil)
|
7
|
+
styling ||= false
|
8
|
+
|
9
|
+
if not substitute_session.instance_of?(Session::Substitute::Session)
|
10
|
+
raise Error, "Not a substitute session: #{substitute_session.inspect}"
|
11
|
+
end
|
12
|
+
|
13
|
+
output = Output.new
|
14
|
+
|
15
|
+
if styling
|
16
|
+
output.writer.set_styling
|
17
|
+
end
|
18
|
+
|
19
|
+
event_records = substitute_session.sink.records
|
20
|
+
event_records.each do |record|
|
21
|
+
event_data = record.event_data
|
22
|
+
|
23
|
+
output.receive(event_data)
|
24
|
+
end
|
25
|
+
|
26
|
+
output.writer.written_text
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|