probatio 1.6.1 → 1.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 392bd12c1d87f8e30b750cf32f99fd2d6264af68b9fcfe00f5d6a0e25343381b
4
- data.tar.gz: 4d4d31f7a4a87725fc1e4f1bcde2670fd9a70382754aa7e4dda3bfc920693402
3
+ metadata.gz: ca8587e9a4b21f857e2a8a50603deff772d78e68ce320ad581a16dd1ba11dc89
4
+ data.tar.gz: 86b7da1f6f31f7cf16a7b2b2cb4c0fbb4f845496095168fbbc94c6b88a8ae40d
5
5
  SHA512:
6
- metadata.gz: b11ce6b831b9c0dedb78d552329e8aec1366768e24e2b19a7d2e7e852833fe1aeb57119c3701d6ac89760eead1b9472c797a328098c85f9e92c7fad816106eed
7
- data.tar.gz: 8879952a689f3718038407a1788a1cabd34ac0ddc9d385a8dad47f8159c5fe7275ab24495342b40bbef7f5568f0c629c22018408167aa7f4e5a2fd8c58eda32e
6
+ metadata.gz: a21ac68e3447c28f534127dfd34631f71c9e29cdb612ac62b73b136978e52d997eb62d5c1fd0084fdf941eb18b0bfed5ee0ba59471b35e64c238651785cc68c9
7
+ data.tar.gz: b98452d3e87e06790cdd3a79d1c60704a43b208d87330a01943d8d5f50126856cf989315eec9ba6608a6a044a52270c4d7c48fcf4cffd26bfef7453878a81c1b
data/CHANGELOG.md CHANGED
@@ -2,6 +2,21 @@
2
2
  # CHANGELOG.md
3
3
 
4
4
 
5
+ ## probatio 1.7.0 released 2026-10-14
6
+
7
+ * Introduce `park(*args, &block)` to "park" groups and tests
8
+ * Log seed: and aseed: in .probatio-output.rb
9
+ * Introduce Probatio::Tracer
10
+
11
+
12
+ ## probatio 1.6.2 released 2026-07-29
13
+
14
+ * Introduce `refute` as counterpart to `assert` jack of some trades
15
+ * Introduce `assert_not`
16
+ * Indicate choke point on `before :each do`
17
+ * Introduce bxp.fish, fish bxp completion
18
+
19
+
5
20
  ## probatio 1.6.1 released 2026-03-15
6
21
 
7
22
  * Fix issue with `assert_no_error`
data/README.md CHANGED
@@ -106,7 +106,7 @@ group 'core' do
106
106
  setup do
107
107
  # occurs once before tests and sub-groups in group 'core'
108
108
  end
109
- teadowm do
109
+ teardowm do
110
110
  # occurs once after tests and sub-groups in group 'core'
111
111
  end
112
112
 
@@ -126,6 +126,8 @@ group 'core' do
126
126
  assert_nil nil
127
127
  assert_not_nil [], 1
128
128
 
129
+ assert_not answers.include?('no')
130
+
129
131
  assert_true true
130
132
  assert_false 1 > 2
131
133
 
@@ -199,11 +201,25 @@ group 'core' do
199
201
  # assert equality between key and value
200
202
  assert 'one' => 'on' + 'e', 'two' => :two.to_s
201
203
  # assert equality between keys and values
204
+
205
+ refute 'one', /two/
206
+ # refute is the counter-part to assert...
202
207
  end
203
208
  end
204
209
 
205
210
  group 'bravo' do
206
211
  end
212
+
213
+ park 'not now' do
214
+ #
215
+ # everything within a `park` will be silently discarded
216
+
217
+ group 'coco' do
218
+ test 'this or that' do
219
+ assert false
220
+ end
221
+ end
222
+ end
207
223
  end
208
224
 
209
225
  group 'core' do
data/exe/proba CHANGED
@@ -208,8 +208,12 @@ test_dir =
208
208
  is_directory_with_tests?('spec') ? 'spec' :
209
209
  'test'
210
210
 
211
- prev = Kernel.eval(File.read(Probatio.opath)) rescue { failures: [] }
212
- fails = prev[:failures].collect { |f| "#{f[:p]}:#{f[:l]}" }
211
+ prev =
212
+ begin; Kernel.eval(File.read(Probatio.opath))
213
+ rescue Exception; { failures: [] }; end
214
+ fails =
215
+ prev[:failures].collect { |f| "#{f[:p]}:#{f[:l]}" }
216
+
213
217
  #print 'fails:'; pp fails
214
218
  #
215
219
  tpoint = File.exist?(Probatio.tpath) ? File.read(Probatio.tpath).strip : nil
@@ -39,6 +39,11 @@ class Probatio::Context
39
39
  do_assert(as, 'false') { |a| a == false }
40
40
  end
41
41
 
42
+ def assert_not(*as)
43
+
44
+ do_assert(as, 'not') { |a| ! a }
45
+ end
46
+
42
47
  def assert_any(*as)
43
48
 
44
49
  do_assert(as, 'any') { |a| a.respond_to?(:size) && a.size > 0 }
@@ -62,6 +67,14 @@ class Probatio::Context
62
67
  do_assert(strings, 'matched') { |s| s.match?(rex) }
63
68
  end
64
69
 
70
+ def refute_match(*as)
71
+
72
+ strings, others = as.partition { |a| a.is_a?(String) }
73
+ rex = others.find { |o| o.is_a?(Regexp) } || strings.pop
74
+
75
+ do_assert(strings, 'not matched') { |s| ! s.match?(rex) }
76
+ end
77
+
65
78
  def assert_start_with(*as)
66
79
 
67
80
  fail ArgumentError.new(
@@ -124,6 +137,11 @@ class Probatio::Context
124
137
  do_assert(as[0].to_a, 'hashy equal') { |k, v| k == v }
125
138
  end
126
139
 
140
+ def refute_hashy(*as)
141
+
142
+ do_assert(as[0].to_a, 'hashy not equal') { |k, v| k != v }
143
+ end
144
+
127
145
  def assert_instance_of(*as)
128
146
 
129
147
  moc = as.find { |a| a.is_a?(Module) }
@@ -206,7 +224,15 @@ class Probatio::Context
206
224
 
207
225
  # Jack of all trade assert
208
226
  #
209
- def assert(*as)
227
+ def assert(*as); jack(:assert, as); end
228
+
229
+ # Jack of all trade refute
230
+ #
231
+ def refute(*as); jack(:refute, as); end
232
+
233
+ protected
234
+
235
+ def jack(dir, as)
210
236
 
211
237
  count = {
212
238
  rexes: 0, hashes: 0, arrays: 0, strings: 0, scalars: 0, others: 0 }
@@ -224,27 +250,25 @@ class Probatio::Context
224
250
 
225
251
  if as.length == 1 && count[:hashes] == 1
226
252
 
227
- assert_hashy(*as)
253
+ dir == :assert ? assert_hashy(*as) : refute_hashy(*as)
228
254
 
229
255
  elsif as.length == 1
230
256
 
231
- assert_truthy(*as)
257
+ dir == :assert ? assert_truthy(*as) : assert_falsey(*as)
232
258
 
233
259
  elsif count[:rexes] == 1 && count[:strings] == as.length - 1
234
260
 
235
- assert_match(*as)
261
+ dir == :assert ? assert_match(*as) : refute_match(*as)
236
262
 
237
263
  #elsif count[:arrays] > 0
238
- # assert_include(*as)
264
+ # dir == :assert ? assert_include(*as) : refute_include(*as)
239
265
 
240
266
  else
241
267
 
242
- assert_equal(*as)
268
+ dir == :assert ? assert_equal(*as) : assert_not(*as)
243
269
  end
244
270
  end
245
271
 
246
- protected
247
-
248
272
  def do_assert(as, msg, &block)
249
273
 
250
274
  do_assert_(as) do
@@ -259,14 +283,18 @@ class Probatio::Context
259
283
 
260
284
  def do_assert_(as, &block)
261
285
 
262
- Probatio.despatch(:assertion_enter, self, @__child)
286
+ ameloc = [
287
+ extract_assert_method(caller),
288
+ extract_file_and_line(caller) ]
289
+
290
+ Probatio.despatch(:assertion_enter, self, @__child, ameloc)
263
291
 
264
292
  case r =
265
293
  begin; block.call; rescue => err; err; end
266
294
 
267
295
  when StandardError, Hash, String
268
296
 
269
- aerr = make_assertion_error(as, r)
297
+ aerr = Probatio::AssertionError.new(ameloc, as, r, @__child)
270
298
 
271
299
  Probatio.despatch(:test_fail, self, @__child, aerr)
272
300
 
@@ -274,7 +302,7 @@ class Probatio::Context
274
302
 
275
303
  when Exception
276
304
 
277
- Probatio.despatch(:test_exception, self, @__child, r)
305
+ Probatio.despatch(:test_exception, self, @__child, r, ameloc)
278
306
 
279
307
  raise r
280
308
 
@@ -289,19 +317,7 @@ class Probatio::Context
289
317
 
290
318
  ensure
291
319
 
292
- #Probatio.despatch(:test_succeed, self, @__child)
293
- Probatio.despatch(:assertion_leave, self, @__child)
294
- end
295
-
296
- def make_assertion_error(arguments, result)
297
-
298
- Probatio::AssertionError
299
- .new(
300
- extract_assert_method(caller),
301
- arguments,
302
- result,
303
- @__child,
304
- *extract_file_and_line(caller))
320
+ Probatio.despatch(:assertion_leave, self, @__child, ameloc)
305
321
  end
306
322
 
307
323
  def extract_file_and_line(backtrace)
@@ -11,15 +11,15 @@ module Probatio
11
11
 
12
12
  alias path file
13
13
 
14
- def initialize(assertion, arguments, error_or_message, test, file, line)
14
+ def initialize(ameloc, arguments, error_or_message, test)
15
+
16
+ @assertion = ameloc[0]
17
+ @file, @line = ameloc[1]
15
18
 
16
- @assertion = assertion
17
19
  @arguments = arguments
18
20
 
19
21
  @test = test
20
22
 
21
- @file = file
22
- @line = line
23
23
 
24
24
  if error_or_message.is_a?(String)
25
25
  @msg = error_or_message
@@ -35,6 +35,7 @@ module Probatio
35
35
 
36
36
  [ @file, @line ]
37
37
  end
38
+ alias loca location
38
39
 
39
40
  def loc
40
41
 
@@ -218,9 +218,12 @@ class Probatio::ProbaOutputter
218
218
  ' ')
219
219
 
220
220
  File.open(Probatio.opath, 'wb') do |o|
221
+
221
222
  o << '# ' << Probatio.opath << "\n"
222
223
  o << "{\n"
223
- o << "argv: " << Cerata.horizontal_a_to_s(ARGV) << ",\n"
224
+ o << 'argv: ' << Cerata.horizontal_a_to_s(ARGV) << ",\n"
225
+ o << 'seed: ' << Probatio.seed.to_s << ",\n"
226
+ o << 'aseed: " --seed ' << Probatio.seed.to_s << " \",\n"
224
227
  o << "failures:\n"
225
228
  #o << " [\n"
226
229
  #fls.each { |fl| o << ' ' << fl << ",\n" }
@@ -267,6 +270,28 @@ class Probatio::Exitter
267
270
  end
268
271
  end
269
272
 
273
+ class Probatio::Tracer
274
+
275
+ def initialize
276
+
277
+ File.open(Probatio.cpath, 'wb') do |f|
278
+ f.puts("aa Probatio #{Probatio::VERSION} Tracer")
279
+ f.puts("aa ARGV #{ARGV.inspect}")
280
+ end
281
+ end
282
+
283
+ def on_pre(ev)
284
+
285
+ File.open(Probatio.cpath, 'ab') { |f| f.puts "PP --seed #{Probatio.seed}" }
286
+ end
287
+
288
+ def record(ev)
289
+
290
+ File.open(Probatio.cpath, 'ab') { |f| ev.trace(f) }
291
+ #puts; puts File.read(Probatio.cpath)
292
+ end
293
+ end
294
+
270
295
  Probatio.plug(Probatio::Recorder.new)
271
296
  Probatio.plug(Probatio::Chronometer.new)
272
297
  Probatio.plug(Probatio::DotReporter.new)
@@ -274,4 +299,5 @@ Probatio.plug(Probatio::VanillaSummarizer.new)
274
299
  Probatio.plug(Probatio::ProbaOutputter.new)
275
300
  Probatio.plug(Probatio::Beeper.new)
276
301
  Probatio.plug(Probatio::Exitter.new)
302
+ Probatio.plug(Probatio::Tracer.new)
277
303
 
data/lib/probatio.rb CHANGED
@@ -18,7 +18,7 @@ require 'probatio/more'
18
18
 
19
19
  module Probatio
20
20
 
21
- VERSION = '1.6.1'
21
+ VERSION = '1.7.0'
22
22
 
23
23
  class << self
24
24
 
@@ -173,6 +173,7 @@ module Probatio
173
173
 
174
174
  def epath; '.probatio-environments.rb'; end
175
175
  def opath; '.probatio-output.rb'; end
176
+ def cpath; '.probatio-trace.log'; end
176
177
  def tpath; '.test-point'; end
177
178
 
178
179
  protected
@@ -323,6 +324,11 @@ module Probatio
323
324
  "#{@path}:#{line}"
324
325
  end
325
326
 
327
+ def loca
328
+
329
+ [ @path, line ]
330
+ end
331
+
326
332
  def to_s(opts={})
327
333
 
328
334
  col = Probatio.c
@@ -617,6 +623,11 @@ module Probatio
617
623
 
618
624
  @children << Probatio::Test.new(self, @path, name.to_s, opts, block)
619
625
  end
626
+
627
+ def park(*args)
628
+
629
+ # simply ignore...
630
+ end
620
631
  end
621
632
 
622
633
  class Leaf < Node
@@ -741,8 +752,11 @@ module Probatio
741
752
 
742
753
  def do_run(child, run_opts, &block)
743
754
 
744
- fail ArgumentError.new("invalid child opts #{child.opts.inspect}") \
745
- unless child.opts.is_a?(Hash)
755
+ fail ArgumentError.new(
756
+ "invalid opts #{child.opts.inspect} " +
757
+ "for child #{child.class} " +
758
+ "at #{child.path_and_line}"
759
+ ) unless child.opts.is_a?(Hash)
746
760
 
747
761
  return Probatio.despatch("#{child.type}_pending", self, child, run_opts) \
748
762
  if child.opts[:pending] || child.block.nil?
@@ -794,12 +808,13 @@ module Probatio
794
808
 
795
809
  class Event
796
810
 
797
- attr_reader :tstamp, :delta
798
- attr_reader :name, :opts, :context, :group, :leaf, :error
811
+ attr_reader :wstamp, :tstamp, :delta
812
+ attr_reader :name, :opts, :context, :group, :leaf, :ameloc, :error
799
813
  attr_accessor :leave_delta
800
814
 
801
815
  def initialize(name, details)
802
816
 
817
+ @wstamp = Time.now
803
818
  @tstamp, @delta = Probatio.monow_and_delta
804
819
 
805
820
  @name = name.to_s
@@ -807,6 +822,7 @@ module Probatio
807
822
  details.each do |d|
808
823
  case d
809
824
  when Hash then @opts = d
825
+ when Array then @ameloc = d
810
826
  when Exception then @error = d
811
827
  when Probatio::Leaf then @leaf = d
812
828
  when Probatio::Group then @group = d
@@ -824,6 +840,20 @@ module Probatio
824
840
  #
825
841
  # which, in the case of assertion != self.node.type ...
826
842
 
843
+ def typ
844
+
845
+ case type
846
+ when 'test' then 'tst'
847
+ when 'group' then 'grp'
848
+ when 'setup' then 'sup'
849
+ when 'before' then 'bfr'
850
+ when 'teardown' then 'tdo'
851
+ when 'assertion' then 'ast'
852
+ when 'start' then 'STA'
853
+ when 'over' then 'OVR'
854
+ else @name[0, 3]; end
855
+ end
856
+
827
857
  def node_full_name; node && node.full_name; end
828
858
 
829
859
  def enter?; direction == :enter; end
@@ -844,13 +874,28 @@ module Probatio
844
874
 
845
875
  def location
846
876
 
847
- (error && error.respond_to?(:location) && error.location) ||
848
- (node && node.location)
877
+ (error && error.loca) ||
878
+ (ameloc && ameloc[1]) ||
879
+ (node && node.loca) ||
880
+ [ '', -1 ]
849
881
  end
882
+ alias loca location
850
883
 
851
884
  def path
852
885
 
853
- node && node.path
886
+ #node && node.path
887
+ loca[0]
888
+ end
889
+
890
+ def na
891
+
892
+ n = @name.split('_').map { |e| e[0, 1] }.join('').upcase
893
+ n.length > 1 ? n : n * 2
894
+ end
895
+
896
+ def wstamp_s
897
+
898
+ '%s.%03d' % [ @wstamp.strftime('%Y%m%d %H:%M:%S'), @wstamp.usec / 1000 ]
854
899
  end
855
900
 
856
901
  def to_s
@@ -863,7 +908,8 @@ module Probatio
863
908
  o << "\n node=#{node.full_name.inspect}" if node
864
909
  o << "\n node_type=#{node.type.inspect}" if node
865
910
  o << "\n error=#{error.to_s.inspect}" if error
866
- o << "\n location=#{location.map(&:to_s).join(':').inspect}" if node
911
+ o << "\n location=#{loca.map(&:to_s).join(':').inspect}" if node
912
+ o << "\n wstamp=\"#{wstamp.iso8601(3)}\""
867
913
  o << "\n delta=\"#{Probatio.to_time_s(delta)}\"" if delta
868
914
  o << "\n leave_delta=\"#{Probatio.to_time_s(led)}\"" if led
869
915
  o << " />"
@@ -873,7 +919,28 @@ module Probatio
873
919
 
874
920
  def to_h
875
921
 
876
- { n: name, p: location[0], l: location[1], t: delta_s }
922
+ { n: name, p: loca[0], l: loca[1], t: delta_s, w: wstamp_s }
923
+ end
924
+
925
+ def trace(out)
926
+
927
+ out << na << ' ' << wstamp_s << ' '
928
+ out << typ << ' ' if node
929
+ out << loca[0] << ':' << loca[1] << ' '
930
+
931
+ out << ameloc[0] << ' ' if ameloc
932
+ out << node.full_name.inspect << ' ' if node && ! ameloc
933
+
934
+ out << 'ERROR:' << error.to_s.inspect << ' ' if error
935
+
936
+ out << 'd:' << Probatio.to_time_s(delta) << ' ' if delta
937
+
938
+ led = determine_leave_delta
939
+ out << 'ld:' << Probatio.to_time_s(led) << ' ' if led
940
+
941
+ out << "\n"
942
+
943
+ out
877
944
  end
878
945
  end
879
946
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: probatio
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-03-15 00:00:00.000000000 Z
11
+ date: 2026-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: stringio