appmap 0.35.1 → 0.35.2

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: baf04e5395f8456142064fd8413363f6e29aa1bf2b68150e79b904d3879b8b7f
4
- data.tar.gz: ca27e18b4778b9341801ac81e25e9025ab26a047824b58ab4bcf113ab91fd5b9
3
+ metadata.gz: 9e7d5c58bd3addf395c32591fe468c4a0b0e886d715cb711ffb6c898049455e5
4
+ data.tar.gz: 271ac50ee1ebe139ed8e52262a98a13e6b3d471ddcab49316669e66d0b7be57a
5
5
  SHA512:
6
- metadata.gz: f7a97d2d7a4e8bd5ae7db133e6287775dcff0373af82f187bc7d82411f868731e30fdb1a1267b173578a38d44017b20127cb20dcd7ddf3924d813e9ba6b32eb5
7
- data.tar.gz: 784ea7d032b9186d50352c0222b168887249b0a9bde5d850f4b2b98e12555ed728f1dc95c1604e2e45d7d6a15c6765eda467ddbd55530af859c82842a1aca4ca
6
+ metadata.gz: b84b1d76d8890a72fb376e95c7ab3811814b75e99304d2f1c15bb091cba1aef1e81f7688fd69c35b8c7735fd72167f89c67eeb25f76e54253503be610fff52cc
7
+ data.tar.gz: 12b27887ae25d8f91fa6321ea59c222c7ec7d1e2d6a198f6672fa166fcd3c32456fe0d3969dda729d4c4817129a3eb874f8bae0afb5dca6b74253ccf457bd51b
@@ -1,3 +1,7 @@
1
+ # v0.35.2
2
+ * Make sure `MethodEvent#display_string` works when the value's `#to_s` and/or `#inspect`
3
+ methods have problems.
4
+
1
5
  # v0.35.1
2
6
  * Take out hooking of `IO` and `Logger` methods.
3
7
  * Enable logging if either `APPMAP_DEBUG` or `DEBUG` is `true`.
@@ -31,11 +31,6 @@ module AppMap
31
31
  def display_string(value)
32
32
  return nil unless value
33
33
 
34
- last_resort_string = lambda do
35
- warn "AppMap encountered an error inspecting a #{value.class.name}: #{$!.message}"
36
- '*Error inspecting variable*'
37
- end
38
-
39
34
  value_string = custom_display_string(value) || default_display_string(value)
40
35
 
41
36
  (value_string||'')[0...LIMIT].encode('utf-8', invalid: :replace, undef: :replace, replace: '_')
@@ -57,6 +52,11 @@ module AppMap
57
52
  end
58
53
 
59
54
  def default_display_string(value)
55
+ last_resort_string = lambda do
56
+ warn "AppMap encountered an error inspecting a #{value.class.name}: #{$!.message}"
57
+ '*Error inspecting variable*'
58
+ end
59
+
60
60
  begin
61
61
  value.to_s
62
62
  rescue NoMethodError
@@ -3,7 +3,7 @@
3
3
  module AppMap
4
4
  URL = 'https://github.com/applandinc/appmap-ruby'
5
5
 
6
- VERSION = '0.35.1'
6
+ VERSION = '0.35.2'
7
7
 
8
8
  APPMAP_FORMAT_VERSION = '1.2'
9
9
  end
@@ -9,3 +9,47 @@ class ExceptionMethod
9
9
  raise 'Exception occurred in raise_exception'
10
10
  end
11
11
  end
12
+
13
+ # subclass from BasicObject so we don't get #to_s. Requires some
14
+ # hackery to implement the other methods normally provided by Object.
15
+ class NoToSMethod < BasicObject
16
+ def is_a?(*args)
17
+ return false
18
+ end
19
+
20
+ def class
21
+ return ::Class
22
+ end
23
+
24
+ def respond_to?(*args)
25
+ return false
26
+ end
27
+
28
+ def inspect
29
+ "NoToSMethod"
30
+ end
31
+
32
+ def say_hello
33
+ "hello"
34
+ end
35
+ end
36
+
37
+ class InspectRaises < NoToSMethod
38
+ def inspect
39
+ ::Kernel.raise "#to_s missing, #inspect raises"
40
+ end
41
+
42
+ def say_hello
43
+ "hello"
44
+ end
45
+ end
46
+
47
+ class ToSRaises
48
+ def to_s
49
+ raise "#to_s raises"
50
+ end
51
+
52
+ def say_hello
53
+ "hello"
54
+ end
55
+ end
@@ -465,6 +465,132 @@ describe 'AppMap class Hooking', docker: false do
465
465
  end
466
466
  end
467
467
 
468
+ context 'string conversions works for the receiver when' do
469
+
470
+ it 'is missing #to_s' do
471
+ events_yaml = <<~YAML
472
+ ---
473
+ - :id: 1
474
+ :event: :call
475
+ :defined_class: NoToSMethod
476
+ :method_id: respond_to?
477
+ :path: spec/fixtures/hook/exception_method.rb
478
+ :lineno: 24
479
+ :static: false
480
+ :parameters:
481
+ - :name: :args
482
+ :class: Symbol
483
+ :value: to_s
484
+ :kind: :rest
485
+ :receiver:
486
+ :class: Class
487
+ :value: NoToSMethod
488
+ - :id: 2
489
+ :event: :return
490
+ :parent_id: 1
491
+ - :id: 3
492
+ :event: :call
493
+ :defined_class: NoToSMethod
494
+ :method_id: say_hello
495
+ :path: spec/fixtures/hook/exception_method.rb
496
+ :lineno: 32
497
+ :static: false
498
+ :parameters: []
499
+ :receiver:
500
+ :class: Class
501
+ :value: NoToSMethod
502
+ - :id: 4
503
+ :event: :return
504
+ :parent_id: 3
505
+ :return_value:
506
+ :class: String
507
+ :value: hello
508
+ YAML
509
+
510
+ test_hook_behavior 'spec/fixtures/hook/exception_method.rb', events_yaml do
511
+ inst = NoToSMethod.new
512
+ # sanity check
513
+ expect(inst).not_to respond_to(:to_s)
514
+ inst.say_hello
515
+ end
516
+ end
517
+
518
+ it 'it is missing #to_s and it raises an exception in #inspect' do
519
+ events_yaml = <<~YAML
520
+ ---
521
+ - :id: 1
522
+ :event: :call
523
+ :defined_class: NoToSMethod
524
+ :method_id: respond_to?
525
+ :path: spec/fixtures/hook/exception_method.rb
526
+ :lineno: 24
527
+ :static: false
528
+ :parameters:
529
+ - :name: :args
530
+ :class: Symbol
531
+ :value: to_s
532
+ :kind: :rest
533
+ :receiver:
534
+ :class: Class
535
+ :value: "*Error inspecting variable*"
536
+ - :id: 2
537
+ :event: :return
538
+ :parent_id: 1
539
+ - :id: 3
540
+ :event: :call
541
+ :defined_class: InspectRaises
542
+ :method_id: say_hello
543
+ :path: spec/fixtures/hook/exception_method.rb
544
+ :lineno: 42
545
+ :static: false
546
+ :parameters: []
547
+ :receiver:
548
+ :class: Class
549
+ :value: "*Error inspecting variable*"
550
+ - :id: 4
551
+ :event: :return
552
+ :parent_id: 3
553
+ :return_value:
554
+ :class: String
555
+ :value: hello
556
+ YAML
557
+
558
+ test_hook_behavior 'spec/fixtures/hook/exception_method.rb', events_yaml do
559
+ inst = InspectRaises.new
560
+ # sanity check
561
+ expect(inst).not_to respond_to(:to_s)
562
+ inst.say_hello
563
+ end
564
+ end
565
+
566
+ it 'it raises an exception in #to_s' do
567
+ events_yaml = <<~YAML
568
+ ---
569
+ - :id: 1
570
+ :event: :call
571
+ :defined_class: ToSRaises
572
+ :method_id: say_hello
573
+ :path: spec/fixtures/hook/exception_method.rb
574
+ :lineno: 52
575
+ :static: false
576
+ :parameters: []
577
+ :receiver:
578
+ :class: ToSRaises
579
+ :value: "*Error inspecting variable*"
580
+ - :id: 2
581
+ :event: :return
582
+ :parent_id: 1
583
+ :return_value:
584
+ :class: String
585
+ :value: hello
586
+ YAML
587
+
588
+ test_hook_behavior 'spec/fixtures/hook/exception_method.rb', events_yaml do
589
+ ToSRaises.new.say_hello
590
+ end
591
+ end
592
+ end
593
+
468
594
  it 're-raises exceptions' do
469
595
  RSpec::Expectations.configuration.on_potential_false_positives = :nothing
470
596
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appmap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.35.1
4
+ version: 0.35.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Gilpin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-25 00:00:00.000000000 Z
11
+ date: 2020-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport