probatio 1.6.2 → 1.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4228249f8fc1a787a594dc604462fef627c33ea693cd8fc1567b8bbd859d7ed3
4
- data.tar.gz: 2eec405d2f2e77cd548e62343c92ab07c530b3aaabea4ce91044a8fbcf0effed
3
+ metadata.gz: ff152c52ba246bd8e7705b7c130f3c95cd1b16cd053ad30f99887ff062d7f301
4
+ data.tar.gz: ab0ac7edb97f75c1f86b91923c3ede69ed2de5bb39e0f08ab486ce0e945b1083
5
5
  SHA512:
6
- metadata.gz: a3034d250e0189025c003f95b1f213c34ffc6ea5bdfc6da080c298029e8b419c56ce195566a3943f36a5c4db27e74bc7268473dade3e48ea4658e4ed79a1fd32
7
- data.tar.gz: 9d5f1a38728c5a18162ec83782e818c9c9275368f4bdae18bbe4ad17bbb6a39bd4fed50556ddc03b5cb7819a689b8495b72a2c279728ef9d0fc995d04f6ca58e
6
+ metadata.gz: a4c44eb4831d0839fd8a2fd449cf485405fc9efb92d2d70282effc6eb685c0a47b8c31297476a9b21b745aecf6559784fe6986a4f4fdd821ef380177fb1020ef
7
+ data.tar.gz: 72345c500f5e6380d9291d15c3036ed5fdc51c2763c638003cca1f207be573f8a0cab658a1fb49f38092f1f2922bc25bbd22abf3d4b6d5db8b5e9a6540380dbf
data/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
  # CHANGELOG.md
3
3
 
4
4
 
5
+ ## probatio 1.7.1 released 2026-10-14
6
+
7
+ * Fix Error vs #loc
8
+
9
+
10
+ ## probatio 1.7.0 released 2026-10-14
11
+
12
+ * Introduce `park(*args, &block)` to "park" groups and tests
13
+ * Log seed: and aseed: in .probatio-output.rb
14
+ * Introduce Probatio::Tracer
15
+
16
+
5
17
  ## probatio 1.6.2 released 2026-07-29
6
18
 
7
19
  * Introduce `refute` as counterpart to `assert` jack of some trades
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
 
@@ -209,6 +209,17 @@ group 'core' do
209
209
 
210
210
  group 'bravo' do
211
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
212
223
  end
213
224
 
214
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
@@ -283,14 +283,18 @@ class Probatio::Context
283
283
 
284
284
  def do_assert_(as, &block)
285
285
 
286
- 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)
287
291
 
288
292
  case r =
289
293
  begin; block.call; rescue => err; err; end
290
294
 
291
295
  when StandardError, Hash, String
292
296
 
293
- aerr = make_assertion_error(as, r)
297
+ aerr = Probatio::AssertionError.new(ameloc, as, r, @__child)
294
298
 
295
299
  Probatio.despatch(:test_fail, self, @__child, aerr)
296
300
 
@@ -298,7 +302,7 @@ class Probatio::Context
298
302
 
299
303
  when Exception
300
304
 
301
- Probatio.despatch(:test_exception, self, @__child, r)
305
+ Probatio.despatch(:test_exception, self, @__child, r, ameloc)
302
306
 
303
307
  raise r
304
308
 
@@ -313,19 +317,7 @@ class Probatio::Context
313
317
 
314
318
  ensure
315
319
 
316
- #Probatio.despatch(:test_succeed, self, @__child)
317
- Probatio.despatch(:assertion_leave, self, @__child)
318
- end
319
-
320
- def make_assertion_error(arguments, result)
321
-
322
- Probatio::AssertionError
323
- .new(
324
- extract_assert_method(caller),
325
- arguments,
326
- result,
327
- @__child,
328
- *extract_file_and_line(caller))
320
+ Probatio.despatch(:assertion_leave, self, @__child, ameloc)
329
321
  end
330
322
 
331
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.2'
21
+ VERSION = '1.7.1'
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
@@ -797,12 +808,13 @@ module Probatio
797
808
 
798
809
  class Event
799
810
 
800
- attr_reader :tstamp, :delta
801
- attr_reader :name, :opts, :context, :group, :leaf, :error
811
+ attr_reader :wstamp, :tstamp, :delta
812
+ attr_reader :name, :opts, :context, :group, :leaf, :ameloc, :error
802
813
  attr_accessor :leave_delta
803
814
 
804
815
  def initialize(name, details)
805
816
 
817
+ @wstamp = Time.now
806
818
  @tstamp, @delta = Probatio.monow_and_delta
807
819
 
808
820
  @name = name.to_s
@@ -810,6 +822,7 @@ module Probatio
810
822
  details.each do |d|
811
823
  case d
812
824
  when Hash then @opts = d
825
+ when Array then @ameloc = d
813
826
  when Exception then @error = d
814
827
  when Probatio::Leaf then @leaf = d
815
828
  when Probatio::Group then @group = d
@@ -827,6 +840,20 @@ module Probatio
827
840
  #
828
841
  # which, in the case of assertion != self.node.type ...
829
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
+
830
857
  def node_full_name; node && node.full_name; end
831
858
 
832
859
  def enter?; direction == :enter; end
@@ -847,13 +874,28 @@ module Probatio
847
874
 
848
875
  def location
849
876
 
850
- (error && error.respond_to?(:location) && error.location) ||
851
- (node && node.location)
877
+ (error && error.loc) ||
878
+ (ameloc && ameloc[1]) ||
879
+ (node && node.loca) ||
880
+ [ '', -1 ]
852
881
  end
882
+ alias loca location
853
883
 
854
884
  def path
855
885
 
856
- 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 ]
857
899
  end
858
900
 
859
901
  def to_s
@@ -866,7 +908,8 @@ module Probatio
866
908
  o << "\n node=#{node.full_name.inspect}" if node
867
909
  o << "\n node_type=#{node.type.inspect}" if node
868
910
  o << "\n error=#{error.to_s.inspect}" if error
869
- 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)}\""
870
913
  o << "\n delta=\"#{Probatio.to_time_s(delta)}\"" if delta
871
914
  o << "\n leave_delta=\"#{Probatio.to_time_s(led)}\"" if led
872
915
  o << " />"
@@ -876,7 +919,28 @@ module Probatio
876
919
 
877
920
  def to_h
878
921
 
879
- { 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
880
944
  end
881
945
  end
882
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.2
4
+ version: 1.7.1
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-07-29 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