appmap 0.72.3 → 0.73.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: c7d208fd0b861c7e7c3f75dfe12111441f450d8f65a75fb34cca032ff2272c43
4
- data.tar.gz: 4ab7ee1e0b724a2dab5428836d6ff585bf9d06f90c5e6356d07f7b9d1c86cc4c
3
+ metadata.gz: df9ed913bb9ce4b945312ab2a50d8305b7c85c8f84a2004b9cf785362fcf2ad2
4
+ data.tar.gz: 2f2a844c20263b62a1291b05396d883c205cdebf2ae32062206e7bf42c23e757
5
5
  SHA512:
6
- metadata.gz: e3fa641617f40905dfd821f0d47ea2f2459caf768390b9891a01e9bd3ea94a78c0d304cc2580fbaffda1d42d3518351a5cce9673b01369ccbff3af366bc77f03
7
- data.tar.gz: b417bdef218555f14bf82e3aba7606b33479eeddade41288d2e7694f5990cbe3a99f2de4f7d467d56798ccdaf798254a262bff79efe8ab615b900cae4e713baa
6
+ metadata.gz: 330bcbec5db0a2b92662898432b3cc4eb4e8ca98729f6cfc0577d6490a0f19a1908e19b6c58c512c9b5db7e98a9f90804c5f0fe4362f52b31a69849760cde6db
7
+ data.tar.gz: 29544bb8ae0db136aad8a518511eb6723fe113e54bc4d585d9e06a857f9227f3e0fbf6daa2bcf1067df5092eef88b13034862d09b187e496cb6758eb8ec094eb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,29 @@
1
+ # [0.73.0](https://github.com/applandinc/appmap-ruby/compare/v0.72.5...v0.73.0) (2022-03-07)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Remove GC before test case execution, because it's slow ([d38695e](https://github.com/applandinc/appmap-ruby/commit/d38695ed9425a5363e48f2b7bdd5dc3853a827bf))
7
+
8
+
9
+ ### Features
10
+
11
+ * Use bind_call when its available ([60d4fb5](https://github.com/applandinc/appmap-ruby/commit/60d4fb5919974d977722ee730b141ae398cbe927))
12
+
13
+ ## [0.72.5](https://github.com/applandinc/appmap-ruby/compare/v0.72.4...v0.72.5) (2022-02-17)
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * Override method accessors to provide the correct signature ([#223](https://github.com/applandinc/appmap-ruby/issues/223)) ([936bba4](https://github.com/applandinc/appmap-ruby/commit/936bba470c5360ee313e0b3e45a65d83acd0b53d))
19
+
20
+ ## [0.72.4](https://github.com/applandinc/appmap-ruby/compare/v0.72.3...v0.72.4) (2022-02-17)
21
+
22
+
23
+ ### Bug Fixes
24
+
25
+ * Retain the proper signature on hooked methods ([31e2de2](https://github.com/applandinc/appmap-ruby/commit/31e2de219a37311df9ba0e5caa407dc80745ca09))
26
+
1
27
  ## [0.72.3](https://github.com/applandinc/appmap-ruby/compare/v0.72.2...v0.72.3) (2022-02-14)
2
28
 
3
29
 
data/LICENSE.txt CHANGED
@@ -1,6 +1,18 @@
1
- The MIT License (MIT)
1
+ The Software is provided to you by the Licensor under the License, as defined below, subject to the following condition.
2
2
 
3
- Copyright (c) 2018 Kevin Gilpin
3
+ Without limiting other conditions in the License, the grant of rights under the License will not include,
4
+ and the License does not grant to you, the right to Sell the Software.
5
+
6
+ For purposes of the foregoing, “Sell” means practicing any or all of the rights granted to you under the License to provide to third parties,
7
+ for a fee or other consideration (including without limitation fees for hosting or consulting/ support services related to the Software),
8
+ a product or service whose value derives, entirely or substantially, from the functionality of the Software.
9
+ Any license notice or attribution required by the License must also include this Commons Clause License Condition notice.
10
+
11
+ Software: AppMap agent for Ruby
12
+
13
+ License: MIT License
14
+
15
+ Copyright 2022, AppLand Inc
4
16
 
5
17
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
18
  of this software and associated documentation files (the "Software"), to deal
@@ -7,6 +7,23 @@ module AppMap
7
7
  end
8
8
 
9
9
  class Hook
10
+ SIGNATURES = {}
11
+
12
+ LOOKUP_SIGNATURE = lambda do |id|
13
+ method = super(id)
14
+
15
+ signature = SIGNATURES[[ method.owner, method.name ]]
16
+ if signature
17
+ method.singleton_class.module_eval do
18
+ define_method(:parameters) do
19
+ signature
20
+ end
21
+ end
22
+ end
23
+
24
+ method
25
+ end
26
+
10
27
  class Method
11
28
  attr_reader :hook_package, :hook_class, :hook_method
12
29
 
@@ -53,8 +70,6 @@ module AppMap
53
70
  with_disabled_hook = self.method(:with_disabled_hook)
54
71
 
55
72
  hook_method_def = Proc.new do |*args, &block|
56
- instance_method = hook_method.bind(self).to_proc
57
-
58
73
  is_array_containing_empty_hash = ->(obj) {
59
74
  obj.is_a?(Array) && obj.length == 1 && obj[0].is_a?(Hash) && obj[0].size == 0
60
75
  }
@@ -62,9 +77,17 @@ module AppMap
62
77
  call_instance_method = -> {
63
78
  # https://github.com/applandinc/appmap-ruby/issues/153
64
79
  if NEW_RUBY && is_array_containing_empty_hash.(args) && hook_method.arity == 1
65
- instance_method.call({}, &block)
80
+ if NEW_RUBY
81
+ hook_method.bind_call(self, {}, &block)
82
+ else
83
+ hook_method.bind(self).call({}, &block)
84
+ end
66
85
  else
67
- instance_method.call(*args, &block)
86
+ if NEW_RUBY
87
+ hook_method.bind_call(self, *args, &block)
88
+ else
89
+ hook_method.bind(self).call(*args, &block)
90
+ end
68
91
  end
69
92
  }
70
93
 
@@ -99,7 +122,12 @@ module AppMap
99
122
  end
100
123
  hook_method_def = hook_method_def.ruby2_keywords if hook_method_def.respond_to?(:ruby2_keywords)
101
124
 
102
- hook_class.ancestors.first.define_method_with_arity(hook_method.name, hook_method.arity, hook_method_def)
125
+ hook_method_parameters = hook_method.parameters.dup.freeze
126
+ SIGNATURES[[ hook_class, hook_method.name ]] = hook_method_parameters
127
+
128
+ hook_class.ancestors.first.tap do |cls|
129
+ cls.define_method_with_arity(hook_method.name, hook_method.arity, hook_method_def)
130
+ end
103
131
  end
104
132
 
105
133
  protected
@@ -129,4 +157,27 @@ module AppMap
129
157
  end
130
158
  end
131
159
  end
160
+
161
+ module ObjectMethods
162
+ define_method(:method, AppMap::Hook::LOOKUP_SIGNATURE)
163
+ define_method(:public_method, AppMap::Hook::LOOKUP_SIGNATURE)
164
+ define_method(:singleton_method, AppMap::Hook::LOOKUP_SIGNATURE)
165
+ end
166
+
167
+ module ModuleMethods
168
+ define_method(:instance_method, AppMap::Hook::LOOKUP_SIGNATURE)
169
+ define_method(:public_instance_method, AppMap::Hook::LOOKUP_SIGNATURE)
170
+ end
171
+ end
172
+
173
+ unless ENV['APPMAP_NO_PATCH_OBJECT'] == 'true'
174
+ class Object
175
+ prepend AppMap::ObjectMethods
176
+ end
177
+ end
178
+
179
+ unless ENV['APPMAP_NO_PATCH_MODULE'] == 'true'
180
+ class Module
181
+ prepend AppMap::ModuleMethods
182
+ end
132
183
  end
@@ -142,7 +142,6 @@ if AppMap::Minitest.enabled?
142
142
  alias run_without_hook run
143
143
 
144
144
  def run
145
- GC.start
146
145
  AppMap::Minitest.begin_test self, name
147
146
  begin
148
147
  run_without_hook
data/lib/appmap/rspec.rb CHANGED
@@ -87,7 +87,6 @@ module AppMap
87
87
  end
88
88
 
89
89
  warn "Starting recording of example #{example}@#{source_location}" if AppMap::RSpec::LOG
90
- GC.start
91
90
  @trace = AppMap.tracing.trace
92
91
  @webdriver_port = webdriver_port.()
93
92
  end
@@ -3,7 +3,7 @@
3
3
  module AppMap
4
4
  URL = 'https://github.com/applandinc/appmap-ruby'
5
5
 
6
- VERSION = '0.72.3'
6
+ VERSION = '0.73.0'
7
7
 
8
8
  APPMAP_FORMAT_VERSION = '1.5.1'
9
9
 
@@ -0,0 +1,8 @@
1
+
2
+ class ReportParameters
3
+ def to_s; self.class.name; end
4
+
5
+ def report_parameters(*args, kw1:, kw2: 'kw2', **kws)
6
+ method(:report_parameters).parameters
7
+ end
8
+ end
@@ -47,7 +47,6 @@ RSpec.configure do |config|
47
47
 
48
48
  config.before(:suite) do
49
49
  DatabaseCleaner.strategy = :transaction
50
- DatabaseCleaner.clean_with(:truncation)
51
50
  end
52
51
 
53
52
  config.around :each do |example|
@@ -47,7 +47,6 @@ RSpec.configure do |config|
47
47
 
48
48
  config.before(:suite) do
49
49
  DatabaseCleaner.strategy = :transaction
50
- DatabaseCleaner.clean_with(:truncation)
51
50
  end
52
51
 
53
52
  config.around :each do |example|
data/spec/hook_spec.rb CHANGED
@@ -225,6 +225,12 @@ describe 'AppMap class Hooking', docker: false do
225
225
  :value: default
226
226
  YAML
227
227
  test_hook_behavior 'spec/fixtures/hook/instance_method.rb', events_yaml do
228
+ expect(InstanceMethod.instance_method(:say_default).parameters).to eq([])
229
+ expect(InstanceMethod.public_instance_method(:say_default).parameters).to eq([])
230
+ expect(InstanceMethod.new.method(:say_default).parameters).to eq([])
231
+ expect(InstanceMethod.new.public_method(:say_default).parameters).to eq([])
232
+ expect { InstanceMethod.new.singleton_method(:say_default) }.to raise_error(NameError)
233
+
228
234
  expect(InstanceMethod.new.say_default).to eq('default')
229
235
  end
230
236
  end
@@ -315,7 +321,22 @@ describe 'AppMap class Hooking', docker: false do
315
321
  :class: String
316
322
  :value: protected
317
323
  YAML
324
+ parameters = []
318
325
  test_hook_behavior 'spec/fixtures/hook/protected_method.rb', events_yaml do
326
+ expect(ProtectedMethod.singleton_method(:call_protected).parameters).to eq(parameters)
327
+ expect(ProtectedMethod.instance_method(:call_protected).parameters).to eq(parameters)
328
+ expect(ProtectedMethod.public_instance_method(:call_protected).parameters).to eq(parameters)
329
+ expect(ProtectedMethod.new.method(:call_protected).parameters).to eq(parameters)
330
+ expect(ProtectedMethod.new.public_method(:call_protected).parameters).to eq(parameters)
331
+ expect { ProtectedMethod.new.singleton_method(:call_protected) }.to raise_error(NameError)
332
+
333
+ expect(ProtectedMethod.singleton_method(:protected_method).parameters).to eq(parameters)
334
+ expect(ProtectedMethod.instance_method(:protected_method).parameters).to eq(parameters)
335
+ expect(ProtectedMethod.public_instance_method(:protected_method).parameters).to eq(parameters)
336
+ expect(ProtectedMethod.new.method(:protected_method).parameters).to eq(parameters)
337
+ expect(ProtectedMethod.new.public_method(:protected_method).parameters).to eq(parameters)
338
+ expect { ProtectedMethod.new.singleton_method(:protected_method) }.to raise_error(NameError)
339
+
319
340
  expect(ProtectedMethod.new.call_protected).to eq('protected')
320
341
  end
321
342
  end
@@ -358,6 +379,7 @@ describe 'AppMap class Hooking', docker: false do
358
379
  :class: String
359
380
  :value: self.protected
360
381
  YAML
382
+ parameters = []
361
383
  test_hook_behavior 'spec/fixtures/hook/protected_method.rb', events_yaml do
362
384
  expect(ProtectedMethod.call_protected).to eq('self.protected')
363
385
  end
@@ -1100,6 +1122,51 @@ describe 'AppMap class Hooking', docker: false do
1100
1122
  end
1101
1123
  end
1102
1124
 
1125
+ it 'preserves the sighnature of hooked methods' do
1126
+ parameters = []
1127
+ events = <<~YAML
1128
+ ---
1129
+ - :id: 1
1130
+ :event: :call
1131
+ :defined_class: ReportParameters
1132
+ :method_id: report_parameters
1133
+ :path: spec/fixtures/hook/report_parameters.rb
1134
+ :lineno: 5
1135
+ :static: false
1136
+ :parameters:
1137
+ - :name: :args
1138
+ :class: Array
1139
+ :value: '["foo"]'
1140
+ :kind: :rest
1141
+ - :name: :kw1
1142
+ :class: String
1143
+ :value: kw1
1144
+ :kind: :keyreq
1145
+ - :name: :kw2
1146
+ :class: NilClass
1147
+ :value: null
1148
+ :kind: :key
1149
+ - :name: :kws
1150
+ :class: Hash
1151
+ :value: "{}"
1152
+ :kind: :keyrest
1153
+ :receiver:
1154
+ :class: ReportParameters
1155
+ :value: ReportParameters
1156
+ - :id: 2
1157
+ :event: :return
1158
+ :parent_id: 1
1159
+ :return_value:
1160
+ :class: Array
1161
+ :value: "[[:rest, :args], [:keyreq, :kw1], [:key, :kw2], [:keyrest, :kws]]"
1162
+ YAML
1163
+ parameters = [[:rest, :args], [:keyreq, :kw1], [:key, :kw2], [:keyrest, :kws]]
1164
+ test_hook_behavior 'spec/fixtures/hook/report_parameters.rb', events do
1165
+ expect(ReportParameters.instance_method(:report_parameters).parameters).to eq(parameters)
1166
+ expect(ReportParameters.new.report_parameters('foo', kw1: 'kw1')).to eq(parameters)
1167
+ end
1168
+ end
1169
+
1103
1170
  describe 'kwargs handling' do
1104
1171
  if ruby_2?
1105
1172
  # https://github.com/applandinc/appmap-ruby/issues/153
data/yarn.lock CHANGED
@@ -320,12 +320,7 @@ ansi-escapes@^4.2.1:
320
320
  dependencies:
321
321
  type-fest "^0.21.3"
322
322
 
323
- ansi-regex@^5.0.0:
324
- version "5.0.0"
325
- resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75"
326
- integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==
327
-
328
- ansi-regex@^5.0.1:
323
+ ansi-regex@^5.0.0, ansi-regex@^5.0.1:
329
324
  version "5.0.1"
330
325
  resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304"
331
326
  integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==
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.72.3
4
+ version: 0.73.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Gilpin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-14 00:00:00.000000000 Z
11
+ date: 2022-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -447,6 +447,7 @@ files:
447
447
  - spec/fixtures/hook/pkg_a/a.rb
448
448
  - spec/fixtures/hook/prepended_override.rb
449
449
  - spec/fixtures/hook/protected_method.rb
450
+ - spec/fixtures/hook/report_parameters.rb
450
451
  - spec/fixtures/hook/revoke_api_key.appmap.json
451
452
  - spec/fixtures/hook/singleton_method.rb
452
453
  - spec/fixtures/hook/spec/api_spec.rb