sus 0.15.0 → 0.15.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68595280910704ed5eb41683985ffaff34df40eb30e72408da93667de742fb0c
4
- data.tar.gz: fc0ac561eae164316247c381c0a20cb244c61c0af6b68891ea120fad2f7916c4
3
+ metadata.gz: 83bf82adb70fa074a1f303a612403523b64317dc0bc780432a46c1babe5e853b
4
+ data.tar.gz: bc6e9c2f98c527fb09ca5b2a0b6cb3c977f42d1cf4a287bd956fa33576b2d443
5
5
  SHA512:
6
- metadata.gz: 1fa0de727817b73859de636f2414dcd08b6001cdd5d837cc9ca72caa3014bdfe08052a0d5c785c91127ee8632e21e64d1eb43817e00baeee2461e698975ab937
7
- data.tar.gz: 2ce965a251d21411e22f8d5feb8ae5573805c18da2e8061ef47768e60600721ebd0d72cb2d8c9a6e1d6be6989dbddb32f12a8fd5a26d65e64c9cb3b47bc7d4ac
6
+ metadata.gz: 9865aac49407ff145daf5bc98ec83b3d3f63fb4ea06b483ff0713cfb25966443191f40c47990ea3bfd928248f9dcce70ebdbb522ad57ed46029e7b7304d9de59
7
+ data.tar.gz: fea67b00c8999565b4a6d3e08dad67a3e4132172d6ee40d2b3c93fd37b7135cb410d95fe5ba79a779cbc5d00ec99ec4aae44024bfba1e0de08860f408859e93d
checksums.yaml.gz.sig CHANGED
Binary file
data/bin/sus CHANGED
@@ -28,6 +28,6 @@ config.after_tests(assertions)
28
28
  #
29
29
  # $ stackprof sus.stackprof --text --limit 10
30
30
 
31
- if assertions.failed.any?
31
+ unless assertions.passed?
32
32
  exit(1)
33
33
  end
data/bin/sus-parallel CHANGED
@@ -65,6 +65,6 @@ results.close
65
65
  assertions = aggregation.value
66
66
  config.after_tests(assertions)
67
67
 
68
- if assertions.failed.any?
68
+ unless assertions.passed?
69
69
  exit(1)
70
70
  end
@@ -35,6 +35,8 @@ module Sus
35
35
  @passed = Array.new
36
36
  @failed = Array.new
37
37
  @deferred = Array.new
38
+ @skipped = Array.new
39
+ @errored = Array.new
38
40
 
39
41
  @count = 0
40
42
  end
@@ -63,15 +65,18 @@ module Sus
63
65
  # Nested assertions have been deferred.
64
66
  attr :deferred
65
67
 
68
+ attr :skipped
69
+ attr :errored
70
+
66
71
  # The total number of assertions performed:
67
72
  attr :count
68
73
 
69
74
  def inspect
70
- "\#<#{self.class} #{@passed.size} passed #{@failed.size} failed #{@deferred.size} deferred>"
75
+ "\#<#{self.class} #{@passed.size} passed #{@failed.size} failed #{@deferred.size} deferred #{@skipped.size} skipped #{@errored.size} errored>"
71
76
  end
72
77
 
73
78
  def total
74
- @passed.size + @failed.size
79
+ @passed.size + @failed.size + @deferred.size + @skipped.size + @errored.size
75
80
  end
76
81
 
77
82
  def print(output, verbose: @verbose)
@@ -95,6 +100,14 @@ module Sus
95
100
  output.write(:deferred, @deferred.size, " deferred", :reset, " ")
96
101
  end
97
102
 
103
+ if @skipped.any?
104
+ output.write(:skipped, @skipped.size, " skipped", :reset, " ")
105
+ end
106
+
107
+ if @errored.any?
108
+ output.write(:errored, @errored.size, " errored", :reset, " ")
109
+ end
110
+
98
111
  output.write("out of ", self.total, " total (", @count, " assertions)")
99
112
  end
100
113
  end
@@ -104,16 +117,16 @@ module Sus
104
117
  end
105
118
 
106
119
  def empty?
107
- @passed.empty? and @failed.empty?
120
+ @passed.empty? and @failed.empty? and @deferred.empty? and @skipped.empty? and @errored.empty?
108
121
  end
109
122
 
110
123
  def passed?
111
124
  if @inverted
112
125
  # Inverted assertions:
113
- self.failed.any?
126
+ @failed.any? and @errored.empty?
114
127
  else
115
128
  # Normal assertions:
116
- self.failed.empty?
129
+ @failed.empty? and @errored.empty?
117
130
  end
118
131
  end
119
132
 
@@ -121,6 +134,10 @@ module Sus
121
134
  !self.passed?
122
135
  end
123
136
 
137
+ def errored?
138
+ @errored.any?
139
+ end
140
+
124
141
  def assert(condition, message = nil)
125
142
  @count += 1
126
143
 
@@ -140,7 +157,8 @@ module Sus
140
157
  end
141
158
 
142
159
  def skip(reason)
143
- @output.puts(:indent, :skip, skip_prefix, reason)
160
+ @output.puts(:indent, :skipped, skip_prefix, reason)
161
+ @skipped << self
144
162
  end
145
163
 
146
164
  def inform(message)
@@ -166,15 +184,15 @@ module Sus
166
184
  end
167
185
  end
168
186
 
169
- def fail(error)
170
- @failed << self
187
+ def error!(error)
188
+ @errored << self
171
189
 
172
190
  lines = error.message.split(/\r?\n/)
173
191
 
174
- @output.puts(:indent, *fail_prefix, "Unhandled exception ", :value, error.class, ":", :reset, " ", lines.shift)
192
+ @output.puts(:indent, *error_prefix, error.class, ": ", lines.shift)
175
193
 
176
194
  lines.each do |line|
177
- @output.puts(:indent, "| ", line)
195
+ @output.puts(:indent, line)
178
196
  end
179
197
 
180
198
  @output.write(Output::Backtrace.for(error, @identity))
@@ -205,7 +223,7 @@ module Sus
205
223
  begin
206
224
  result = yield(assertions)
207
225
  rescue StandardError => error
208
- assertions.fail(error)
226
+ assertions.error!(error)
209
227
  end
210
228
  end
211
229
 
@@ -255,7 +273,9 @@ module Sus
255
273
  def merge!(assertions)
256
274
  @count += assertions.count
257
275
 
258
- if assertions.passed?
276
+ if assertions.errored?
277
+ @errored << assertions
278
+ elsif assertions.passed?
259
279
  @passed << assertions
260
280
 
261
281
  # if @verbose
@@ -277,6 +297,8 @@ module Sus
277
297
  @passed.concat(assertions.passed)
278
298
  @failed.concat(assertions.failed)
279
299
  @deferred.concat(assertions.deferred)
300
+ @skipped.concat(assertions.skipped)
301
+ @errored.concat(assertions.errored)
280
302
 
281
303
  # if @verbose
282
304
  # @output.write(:indent)
@@ -309,7 +331,11 @@ module Sus
309
331
  end
310
332
 
311
333
  def skip_prefix
312
- " "
334
+ " "
335
+ end
336
+
337
+ def error_prefix
338
+ [:errored, "⚠ "]
313
339
  end
314
340
  end
315
341
  end
data/lib/sus/be.rb CHANGED
@@ -16,7 +16,9 @@ module Sus
16
16
  end
17
17
 
18
18
  def call(assertions, subject)
19
- assertions.assert(subject.public_send(*@arguments), self)
19
+ assertions.nested(self) do |assertions|
20
+ assertions.assert(subject.public_send(*@arguments))
21
+ end
20
22
  end
21
23
 
22
24
  class << self
data/lib/sus/config.rb CHANGED
@@ -116,13 +116,13 @@ module Sus
116
116
 
117
117
  assertions.print(output)
118
118
  output.puts
119
-
119
+
120
120
  print_finished_statistics(assertions)
121
-
121
+
122
122
  if !partial? and assertions.passed?
123
123
  print_test_feedback(assertions)
124
124
  end
125
-
125
+
126
126
  print_slow_tests(assertions)
127
127
  print_failed_assertions(assertions)
128
128
  end
@@ -193,14 +193,22 @@ module Sus
193
193
  end
194
194
  end
195
195
 
196
- def print_failed_assertions(assertions)
197
- if assertions.failed.any?
196
+ def print_assertions(title, assertions)
197
+ if assertions.any?
198
198
  output.puts
199
+ output.puts title
199
200
 
200
- assertions.failed.each do |failure|
201
- output.append(failure.output)
201
+ assertions.each do |assertion|
202
+ assertions.each do |failure|
203
+ output.append(failure.output)
204
+ end
202
205
  end
203
206
  end
204
207
  end
208
+
209
+ def print_failed_assertions(assertions)
210
+ print_assertions("🤔 Failed assertions:", assertions.failed)
211
+ print_assertions("🔥 Errored assertions:", assertions.errored)
212
+ end
205
213
  end
206
214
  end
data/lib/sus/output.rb CHANGED
@@ -39,8 +39,9 @@ module Sus
39
39
 
40
40
  output[:passed] = output.style(:green)
41
41
  output[:failed] = output.style(:red)
42
- output[:error] = output.style(:red)
43
- output[:skip] = output.style(:blue)
42
+ output[:deferred] = output.style(:yellow)
43
+ output[:skipped] = output.style(:blue)
44
+ output[:errored] = output.style(:red)
44
45
  # output[:inform] = output.style(nil, nil, :bold)
45
46
 
46
47
  return output
data/lib/sus/version.rb CHANGED
@@ -4,5 +4,5 @@
4
4
  # Copyright, 2021-2022, by Samuel Williams.
5
5
 
6
6
  module Sus
7
- VERSION = "0.15.0"
7
+ VERSION = "0.15.1"
8
8
  end
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.15.0
4
+ version: 0.15.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -37,7 +37,7 @@ cert_chain:
37
37
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
38
38
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
39
39
  -----END CERTIFICATE-----
40
- date: 2022-10-30 00:00:00.000000000 Z
40
+ date: 2022-12-04 00:00:00.000000000 Z
41
41
  dependencies:
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: bake-test
metadata.gz.sig CHANGED
Binary file