sus 0.20.3 → 0.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/bin/sus-host +9 -5
- data/lib/sus/assertions.rb +16 -45
- data/lib/sus/it.rb +4 -5
- data/lib/sus/output/buffered.rb +20 -0
- data/lib/sus/output/messages.rb +78 -0
- data/lib/sus/output/null.rb +3 -2
- data/lib/sus/output/structured.rb +42 -0
- data/lib/sus/output/text.rb +3 -2
- data/lib/sus/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +4 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8d9e361b911f82db22849e86d61769d01ed115b1137639f1dd323c1a7d9f7e8
|
4
|
+
data.tar.gz: c24ffc6bc111a1860b5bf01c97510a37d79a4efee8ca93c0f5718f40b23c3e25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2341975dbac7bbb46ed3758f2845158da81310cd9f518cf008c5a04f43da7ca397500db3e24316e3c4ae6918993d0580cb8df0c76c80245fc31b9c2e2a0f4b49
|
7
|
+
data.tar.gz: 04f25d46435a3d3eeb303926f8931857b6b4fc19788f393863de1b610d8eadc04ed96b9868502265c4dce74cac5ce4d22677845834d54fd90f6acd0c121e1946
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/bin/sus-host
CHANGED
@@ -15,12 +15,14 @@ count = Etc.nprocessors
|
|
15
15
|
|
16
16
|
$stdout.sync = true
|
17
17
|
|
18
|
+
require_relative '../lib/sus/output/structured'
|
19
|
+
|
18
20
|
input = $stdin.dup
|
19
21
|
$stdin.reopen(File::NULL)
|
20
22
|
output = $stdout.dup
|
21
23
|
$stdout.reopen($stderr)
|
22
24
|
|
23
|
-
def
|
25
|
+
def messages_for(assertions)
|
24
26
|
messages = []
|
25
27
|
|
26
28
|
assertions.each_failure do |failure|
|
@@ -63,17 +65,19 @@ while line = input.gets
|
|
63
65
|
output.puts JSON.generate({started: job.identity})
|
64
66
|
end
|
65
67
|
|
66
|
-
|
68
|
+
structured_output = Sus::Output::Structured.buffered(output, job.identity)
|
69
|
+
|
70
|
+
assertions = Sus::Assertions.new(output: structured_output, measure: true)
|
67
71
|
job.call(assertions)
|
68
72
|
results.push(assertions)
|
69
73
|
|
70
74
|
guard.synchronize do
|
71
75
|
if assertions.passed?
|
72
|
-
output.puts JSON.generate({passed: job.identity, duration: assertions.clock.ms})
|
76
|
+
output.puts JSON.generate({passed: job.identity, messages: messages_for(assertions), duration: assertions.clock.ms})
|
73
77
|
elsif assertions.errored?
|
74
|
-
output.puts JSON.generate({errored: job.identity, messages:
|
78
|
+
output.puts JSON.generate({errored: job.identity, messages: messages_for(assertions), duration: assertions.clock.ms})
|
75
79
|
else
|
76
|
-
output.puts JSON.generate({failed: job.identity, messages:
|
80
|
+
output.puts JSON.generate({failed: job.identity, messages: messages_for(assertions), duration: assertions.clock.ms})
|
77
81
|
end
|
78
82
|
end
|
79
83
|
end
|
data/lib/sus/assertions.rb
CHANGED
@@ -187,13 +187,13 @@ module Sus
|
|
187
187
|
@passed << assert
|
188
188
|
|
189
189
|
if !@orientation || @verbose
|
190
|
-
@output.
|
190
|
+
@output.assert(condition, @orientation, message || "assertion passed", backtrace)
|
191
191
|
end
|
192
192
|
else
|
193
193
|
@failed << assert
|
194
194
|
|
195
195
|
if @orientation || @verbose
|
196
|
-
@output.
|
196
|
+
@output.assert(condition, @orientation, message || "assertion failed", backtrace)
|
197
197
|
end
|
198
198
|
end
|
199
199
|
end
|
@@ -222,12 +222,21 @@ module Sus
|
|
222
222
|
end
|
223
223
|
|
224
224
|
def skip(reason)
|
225
|
-
@output.
|
225
|
+
@output.skip(reason, @identity&.scoped)
|
226
|
+
|
226
227
|
@skipped << self
|
227
228
|
end
|
228
229
|
|
229
|
-
def inform(message)
|
230
|
-
|
230
|
+
def inform(message = nil)
|
231
|
+
if message.nil? and block_given?
|
232
|
+
begin
|
233
|
+
message = yield
|
234
|
+
rescue => error
|
235
|
+
message = error.full_message
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
@output.inform(message, @identity&.scoped)
|
231
240
|
end
|
232
241
|
|
233
242
|
# Add deferred assertions.
|
@@ -275,15 +284,8 @@ module Sus
|
|
275
284
|
|
276
285
|
@errored << Error.new(identity, error)
|
277
286
|
|
278
|
-
|
279
|
-
|
280
|
-
@output.puts(:indent, *error_prefix, error.class, ": ", lines.shift)
|
281
|
-
|
282
|
-
lines.each do |line|
|
283
|
-
@output.puts(:indent, line)
|
284
|
-
end
|
285
|
-
|
286
|
-
@output.write(Output::Backtrace.for(error, @identity))
|
287
|
+
# TODO consider passing `identity`.
|
288
|
+
@output.error(error, @identity)
|
287
289
|
end
|
288
290
|
|
289
291
|
def nested(target, identity: nil, isolated: false, distinct: false, inverted: false, **options)
|
@@ -402,36 +404,5 @@ module Sus
|
|
402
404
|
# @output.puts
|
403
405
|
# end
|
404
406
|
end
|
405
|
-
|
406
|
-
PASSED_PREFIX = [:passed, "✓ "].freeze
|
407
|
-
FAILED_PREFIX = [:failed, "✗ "].freeze
|
408
|
-
|
409
|
-
def pass_prefix
|
410
|
-
if @orientation
|
411
|
-
PASSED_PREFIX
|
412
|
-
else
|
413
|
-
FAILED_PREFIX
|
414
|
-
end
|
415
|
-
end
|
416
|
-
|
417
|
-
def fail_prefix
|
418
|
-
if @orientation
|
419
|
-
FAILED_PREFIX
|
420
|
-
else
|
421
|
-
PASSED_PREFIX
|
422
|
-
end
|
423
|
-
end
|
424
|
-
|
425
|
-
def inform_prefix
|
426
|
-
"ℹ "
|
427
|
-
end
|
428
|
-
|
429
|
-
def skip_prefix
|
430
|
-
"⏸ "
|
431
|
-
end
|
432
|
-
|
433
|
-
def error_prefix
|
434
|
-
[:errored, "⚠ "]
|
435
|
-
end
|
436
407
|
end
|
437
408
|
end
|
data/lib/sus/it.rb
CHANGED
@@ -45,13 +45,9 @@ module Sus
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def handle_skip(instance, assertions)
|
48
|
-
|
48
|
+
catch(:skip) do
|
49
49
|
return instance.call
|
50
50
|
end
|
51
|
-
|
52
|
-
assertions.skip(reason)
|
53
|
-
|
54
|
-
return nil
|
55
51
|
end
|
56
52
|
end
|
57
53
|
|
@@ -62,7 +58,10 @@ module Sus
|
|
62
58
|
end
|
63
59
|
|
64
60
|
class Base
|
61
|
+
# Skip the current test with a reason.
|
62
|
+
# @parameter reason [String] The reason for skipping the test.
|
65
63
|
def skip(reason)
|
64
|
+
@__assertions__.skip(reason)
|
66
65
|
throw :skip, reason
|
67
66
|
end
|
68
67
|
end
|
data/lib/sus/output/buffered.rb
CHANGED
@@ -75,6 +75,26 @@ module Sus
|
|
75
75
|
@chunks << [:puts, *arguments]
|
76
76
|
@tee&.puts(*arguments)
|
77
77
|
end
|
78
|
+
|
79
|
+
def assert(*arguments)
|
80
|
+
@chunks << [:assert, *arguments]
|
81
|
+
@tee&.assert(*arguments)
|
82
|
+
end
|
83
|
+
|
84
|
+
def skip(*arguments)
|
85
|
+
@chunks << [:skip, *arguments]
|
86
|
+
@tee&.skip(*arguments)
|
87
|
+
end
|
88
|
+
|
89
|
+
def error(*arguments)
|
90
|
+
@chunks << [:error, *arguments]
|
91
|
+
@tee&.error(*arguments)
|
92
|
+
end
|
93
|
+
|
94
|
+
def inform(*arguments)
|
95
|
+
@chunks << [:inform, *arguments]
|
96
|
+
@tee&.inform(*arguments)
|
97
|
+
end
|
78
98
|
end
|
79
99
|
end
|
80
100
|
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2023, by Samuel Williams.
|
5
|
+
|
6
|
+
module Sus
|
7
|
+
# Styled output output.
|
8
|
+
module Output
|
9
|
+
module Messages
|
10
|
+
PASSED_PREFIX = [:passed, "✓ "].freeze
|
11
|
+
FAILED_PREFIX = [:failed, "✗ "].freeze
|
12
|
+
|
13
|
+
def pass_prefix(orientation)
|
14
|
+
if orientation
|
15
|
+
PASSED_PREFIX
|
16
|
+
else
|
17
|
+
FAILED_PREFIX
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def fail_prefix(orientation)
|
22
|
+
if orientation
|
23
|
+
FAILED_PREFIX
|
24
|
+
else
|
25
|
+
PASSED_PREFIX
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# If the orientation is true, and the test passed, then it is a successful outcome.
|
30
|
+
# If the orientation is false, and the test failed, then it is a successful outcome.
|
31
|
+
# Otherwise, it is a failed outcome.
|
32
|
+
#
|
33
|
+
# @parameter condition [Boolean] The result of the test.
|
34
|
+
# @parameter orientation [Boolean] The orientation of the assertions.
|
35
|
+
# @parameter message [String] The message to display.
|
36
|
+
# @parameter backtrace [Array] The backtrace to display.
|
37
|
+
def assert(condition, orientation, message, backtrace)
|
38
|
+
if condition
|
39
|
+
self.puts(:indent, *pass_prefix(orientation), message, backtrace)
|
40
|
+
else
|
41
|
+
self.puts(:indent, *fail_prefix(orientation), message, backtrace)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def skip_prefix
|
46
|
+
"⏸ "
|
47
|
+
end
|
48
|
+
|
49
|
+
def skip(reason, identity)
|
50
|
+
self.puts(:indent, :skipped, skip_prefix, reason)
|
51
|
+
end
|
52
|
+
|
53
|
+
def error_prefix
|
54
|
+
[:errored, "⚠ "]
|
55
|
+
end
|
56
|
+
|
57
|
+
def error(error, identity)
|
58
|
+
lines = error.message.split(/\r?\n/)
|
59
|
+
|
60
|
+
self.puts(:indent, *error_prefix, error.class, ": ", lines.shift)
|
61
|
+
|
62
|
+
lines.each do |line|
|
63
|
+
self.puts(:indent, line)
|
64
|
+
end
|
65
|
+
|
66
|
+
self.write(Output::Backtrace.for(error, identity))
|
67
|
+
end
|
68
|
+
|
69
|
+
def inform_prefix
|
70
|
+
"ℹ "
|
71
|
+
end
|
72
|
+
|
73
|
+
def inform(message, identity)
|
74
|
+
self.puts(:indent, :inform, inform_prefix, message)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
data/lib/sus/output/null.rb
CHANGED
@@ -3,13 +3,14 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2021-2022, by Samuel Williams.
|
5
5
|
|
6
|
-
|
7
|
-
require 'stringio'
|
6
|
+
require_relative 'messages'
|
8
7
|
|
9
8
|
module Sus
|
10
9
|
# Styled output output.
|
11
10
|
module Output
|
12
11
|
class Null
|
12
|
+
include Messages
|
13
|
+
|
13
14
|
def initialize
|
14
15
|
end
|
15
16
|
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Released under the MIT License.
|
4
|
+
# Copyright, 2023, by Samuel Williams.
|
5
|
+
|
6
|
+
require_relative 'null'
|
7
|
+
|
8
|
+
module Sus
|
9
|
+
# Styled output output.
|
10
|
+
module Output
|
11
|
+
class Structured < Null
|
12
|
+
def self.buffered(...)
|
13
|
+
Buffered.new(self.new(...))
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(io, identity = nil)
|
17
|
+
@io = io
|
18
|
+
@identity = identity
|
19
|
+
end
|
20
|
+
|
21
|
+
def skip(reason, identity)
|
22
|
+
inform(reason.to_s, identity)
|
23
|
+
end
|
24
|
+
|
25
|
+
def inform(message, identity)
|
26
|
+
unless message.is_a?(String)
|
27
|
+
message = message.inspect
|
28
|
+
end
|
29
|
+
|
30
|
+
@io.puts(JSON.generate({
|
31
|
+
inform: @identity,
|
32
|
+
message: {
|
33
|
+
text: message,
|
34
|
+
location: identity&.to_location,
|
35
|
+
}
|
36
|
+
}))
|
37
|
+
|
38
|
+
@io.flush
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/sus/output/text.rb
CHANGED
@@ -3,13 +3,14 @@
|
|
3
3
|
# Released under the MIT License.
|
4
4
|
# Copyright, 2021-2022, by Samuel Williams.
|
5
5
|
|
6
|
-
|
6
|
+
require_relative 'messages'
|
7
7
|
require_relative 'buffered'
|
8
8
|
|
9
9
|
module Sus
|
10
|
-
# Styled io io.
|
11
10
|
module Output
|
12
11
|
class Text
|
12
|
+
include Messages
|
13
|
+
|
13
14
|
def initialize(io)
|
14
15
|
@io = io
|
15
16
|
|
data/lib/sus/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.21.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -38,7 +38,7 @@ cert_chain:
|
|
38
38
|
Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
|
39
39
|
voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
|
40
40
|
-----END CERTIFICATE-----
|
41
|
-
date: 2023-
|
41
|
+
date: 2023-06-11 00:00:00.000000000 Z
|
42
42
|
dependencies:
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: bake-test
|
@@ -125,9 +125,11 @@ files:
|
|
125
125
|
- lib/sus/output/bar.rb
|
126
126
|
- lib/sus/output/buffered.rb
|
127
127
|
- lib/sus/output/lines.rb
|
128
|
+
- lib/sus/output/messages.rb
|
128
129
|
- lib/sus/output/null.rb
|
129
130
|
- lib/sus/output/progress.rb
|
130
131
|
- lib/sus/output/status.rb
|
132
|
+
- lib/sus/output/structured.rb
|
131
133
|
- lib/sus/output/text.rb
|
132
134
|
- lib/sus/output/xterm.rb
|
133
135
|
- lib/sus/raise_exception.rb
|
metadata.gz.sig
CHANGED
Binary file
|