appmap 0.98.1 → 0.99.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: 8e852506550e061f5525d6dc83fd12facb5a77f17d1e3bcc78573c0a9d71294a
4
- data.tar.gz: 0dea32a345dee9a20a91d2b1e034cbad8fcaae03dbc75d6f64c88639219241c0
3
+ metadata.gz: ff070f04eeeb2d79a08d4f93462a84e277dfad345bffd1d6b87bd063a63b8f00
4
+ data.tar.gz: 27e47f4e5a85fce938cbd259bf76cce952490851cfee98315fddf6d6b1c798d3
5
5
  SHA512:
6
- metadata.gz: bb509b820a5b0c29bb906c9bf37b75bcad27f5abf6d36df19b2a1d4cbba7969e8b548a8e9fc5f77c6f5d9db1e5a7d607bdf52b41859ef5b0b9e77400c60a8324
7
- data.tar.gz: 9d35cb3828fa3088825f933242c60e61d4fc71ec06bda382874424f6b3401cb55c9b14545e72976b1ea1d80df8fd642cea147d39c315507250a525dd48a35cff
6
+ metadata.gz: 97db1ff69373241c3e2ca4633fcca4c800d72b60734bde3b32aae2d3765e86f484e490a4148b98c9e90c40b3fa68cc9b734e56ce9175d1e26ec9bfc767b9707e
7
+ data.tar.gz: 074b036daecfc348fbe13510ab7c6cca46fe8d2d630bd81e28808ef4f05e15b47dedda31e9d3a2e423f426ba0980ea04e50439b3533b8b7690c9047be199a1a9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ ## [0.99.1](https://github.com/getappmap/appmap-ruby/compare/v0.99.0...v0.99.1) (2023-04-24)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * backtrace_locations may be nil ([7f3890a](https://github.com/getappmap/appmap-ruby/commit/7f3890a00d5f4425fac273c72e5576cf7752eeaf)), closes [#324](https://github.com/getappmap/appmap-ruby/issues/324)
7
+
8
+ # [0.99.0](https://github.com/getappmap/appmap-ruby/compare/v0.98.1...v0.99.0) (2023-04-13)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * Don't report vendored paths as local ([e09cb4f](https://github.com/getappmap/appmap-ruby/commit/e09cb4f9764d275c7ba0858f16b545c2d287b473))
14
+ * Report the first relative path in the backtrace ([f81b346](https://github.com/getappmap/appmap-ruby/commit/f81b346ebc66a4f60ca26ad384d72672893d1333))
15
+
16
+
17
+ ### Features
18
+
19
+ * Report metadata.test_failure ([82c87d2](https://github.com/getappmap/appmap-ruby/commit/82c87d2453ce7c040bce138bf55d94d47aca58fc))
20
+
1
21
  ## [0.98.1](https://github.com/getappmap/appmap-ruby/compare/v0.98.0...v0.98.1) (2023-03-09)
2
22
 
3
23
 
@@ -26,13 +26,21 @@ module AppMap
26
26
  end
27
27
 
28
28
  def source_location
29
- test.method(test_name).source_location.join(':')
29
+ location = test.method(test_name).source_location
30
+ [ Util.normalize_path(location.first), location.last ].join(':')
30
31
  end
31
32
 
32
- def finish(failed, exception)
33
- warn "Finishing recording of #{failed || exception ? 'failed ' : ''} test #{test.class}.#{test.name}" if AppMap::Minitest::LOG
33
+ def finish(failures, exception)
34
+ failed = failures.any? || exception
35
+ warn "Finishing recording of #{failed ? 'failed ' : ''} test #{test.class}.#{test.name}" if AppMap::Minitest::LOG
34
36
  warn "Exception: #{exception}" if exception && AppMap::Minitest::LOG
35
37
 
38
+ if failed
39
+ failure_exception = failures.first || exception
40
+ warn "Failure exception: #{failure_exception}" if AppMap::Minitest::LOG
41
+ test_failure = Util.extract_test_failure(failure_exception)
42
+ end
43
+
36
44
  events = []
37
45
  AppMap.tracing.delete @trace
38
46
 
@@ -49,7 +57,8 @@ module AppMap
49
57
  AppMap::Minitest.save name: scenario_name,
50
58
  class_map: class_map,
51
59
  source_location: source_location,
52
- test_status: failed || exception ? 'failed' : 'succeeded',
60
+ test_status: failed ? 'failed' : 'succeeded',
61
+ test_failure: test_failure,
53
62
  exception: exception,
54
63
  events: events
55
64
  end
@@ -79,7 +88,7 @@ module AppMap
79
88
  recording = @recordings_by_test.delete(test.object_id)
80
89
  return warn "No recording found for #{test}" unless recording
81
90
 
82
- recording.finish (test.failures || []).any?, exception
91
+ recording.finish test.failures || [], exception
83
92
  end
84
93
 
85
94
  def config
@@ -90,7 +99,7 @@ module AppMap
90
99
  @event_methods += event_methods
91
100
  end
92
101
 
93
- def save(name:, class_map:, source_location:, test_status:, exception:, events:)
102
+ def save(name:, class_map:, source_location:, test_status:, test_failure:, exception:, events:)
94
103
  metadata = AppMap::Minitest.metadata.tap do |m|
95
104
  m[:name] = name
96
105
  m[:source_location] = source_location
@@ -105,11 +114,9 @@ module AppMap
105
114
  type: 'tests',
106
115
  }
107
116
  m[:test_status] = test_status
117
+ m[:test_failure] = test_failure if test_failure
108
118
  if exception
109
- m[:exception] = {
110
- class: exception.class.name,
111
- message: AppMap::Event::MethodEvent.display_string(exception.to_s),
112
- }
119
+ m[:exception] = Util.format_exception(exception)
113
120
  end
114
121
  end
115
122
 
data/lib/appmap/rspec.rb CHANGED
@@ -8,7 +8,7 @@ require 'fileutils'
8
8
  module AppMap
9
9
  module RSpec
10
10
  APPMAP_OUTPUT_DIR = 'tmp/appmap/rspec'
11
- LOG = false
11
+ LOG = (ENV['APPMAP_DEBUG'] == 'true' || ENV['DEBUG'] == 'true')
12
12
 
13
13
  def self.metadata
14
14
  AppMap.detect_metadata
@@ -96,10 +96,17 @@ module AppMap
96
96
  result
97
97
  end
98
98
 
99
- def finish(exception)
100
- warn "Finishing recording of example #{example}" if AppMap::RSpec::LOG
99
+ def finish(failure, exception)
100
+ failed = true if failure || exception
101
+ warn "Finishing recording of #{failed ? 'failed ' : ''} example #{example}" if AppMap::RSpec::LOG
101
102
  warn "Exception: #{exception}" if exception && AppMap::RSpec::LOG
102
103
 
104
+ if failed
105
+ failure_exception = failure || exception
106
+ warn "Failure exception: #{failure_exception}" if AppMap::RSpec::LOG
107
+ test_failure = Util.extract_test_failure(failure_exception)
108
+ end
109
+
103
110
  events = []
104
111
  AppMap.tracing.delete @trace
105
112
 
@@ -134,6 +141,7 @@ module AppMap
134
141
  class_map: class_map,
135
142
  source_location: source_location,
136
143
  test_status: exception ? 'failed' : 'succeeded',
144
+ test_failure: test_failure,
137
145
  exception: exception,
138
146
  events: events
139
147
  end
@@ -169,7 +177,7 @@ module AppMap
169
177
  recording = @recordings_by_example.delete(example.object_id)
170
178
  return warn "No recording found for #{example}" unless recording
171
179
 
172
- recording.finish exception unless recording == :false
180
+ recording.finish example.execution_result.exception || exception, exception unless recording == :false
173
181
  end
174
182
 
175
183
  def config
@@ -180,7 +188,7 @@ module AppMap
180
188
  @event_methods += event_methods
181
189
  end
182
190
 
183
- def save(name:, class_map:, source_location:, test_status:, exception:, events:)
191
+ def save(name:, class_map:, source_location:, test_status:, test_failure:, exception:, events:)
184
192
  metadata = AppMap::RSpec.metadata.tap do |m|
185
193
  m[:name] = name
186
194
  m[:source_location] = source_location
@@ -195,8 +203,10 @@ module AppMap
195
203
  type: 'tests'
196
204
  }
197
205
  m[:test_status] = test_status
206
+ m[:test_failure] = test_failure if test_failure
198
207
  if exception
199
- m[:exception] = {
208
+ m[:exception] = Util.format_exception(exception)
209
+ {
200
210
  class: exception.class.name,
201
211
  message: AppMap::Event::MethodEvent.display_string(exception.to_s)
202
212
  }
data/lib/appmap/util.rb CHANGED
@@ -139,13 +139,33 @@ module AppMap
139
139
  end
140
140
 
141
141
  def normalize_path(path)
142
- if path.index(Dir.pwd) == 0 && !path.index(Bundler.bundle_path.to_s)
142
+ is_local_path = -> { path.index(Dir.pwd) == 0 }
143
+ is_bundled_path = -> { path.index(Bundler.bundle_path.to_s) == 0 }
144
+ is_vendored_path = -> { path.index(File.join(Dir.pwd, 'vendor/bundle')) == 0 }
145
+
146
+ if is_local_path.() && !is_bundled_path.() && !is_vendored_path.()
143
147
  path[Dir.pwd.length + 1..-1]
144
148
  else
145
149
  path
146
150
  end
147
151
  end
148
152
 
153
+ def format_exception(exception)
154
+ {
155
+ class: exception.class.name,
156
+ message: AppMap::Event::MethodEvent.display_string(exception.to_s),
157
+ }
158
+ end
159
+
160
+ def extract_test_failure(exception)
161
+ return unless exception
162
+
163
+ { message: exception.message }.tap do |test_failure|
164
+ first_location = exception.backtrace_locations&.find { |location| !Pathname.new(normalize_path(location.absolute_path)).absolute? }
165
+ test_failure[:location] = [ normalize_path(first_location.path), first_location.lineno ].join(':') if first_location
166
+ end
167
+ end
168
+
149
169
  # Convert a Rails-style path from /org/:org_id(.:format)
150
170
  # to Swagger-style paths like /org/{org_id}
151
171
  def swaggerize_path(path)
@@ -3,9 +3,9 @@
3
3
  module AppMap
4
4
  URL = 'https://github.com/applandinc/appmap-ruby'
5
5
 
6
- VERSION = '0.98.1'
6
+ VERSION = '0.99.1'
7
7
 
8
- APPMAP_FORMAT_VERSION = '1.10.0'
8
+ APPMAP_FORMAT_VERSION = '1.12.0'
9
9
 
10
10
  SUPPORTED_RUBY_VERSIONS = %w[2.5 2.6 2.7 3.0 3.1 3.2].freeze
11
11
 
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.98.1
4
+ version: 0.99.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Gilpin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-09 00:00:00.000000000 Z
11
+ date: 2023-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: method_source