appmap 0.98.1 → 0.99.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: 8e852506550e061f5525d6dc83fd12facb5a77f17d1e3bcc78573c0a9d71294a
4
- data.tar.gz: 0dea32a345dee9a20a91d2b1e034cbad8fcaae03dbc75d6f64c88639219241c0
3
+ metadata.gz: 463cf482f8d6b1a33721886b5d049ae0ce11c469759562a4ea0b8c6c149abb23
4
+ data.tar.gz: 727ecbc15e19e486f69ed668d9e077a3045c10b24c0892b66801346d11a02a4d
5
5
  SHA512:
6
- metadata.gz: bb509b820a5b0c29bb906c9bf37b75bcad27f5abf6d36df19b2a1d4cbba7969e8b548a8e9fc5f77c6f5d9db1e5a7d607bdf52b41859ef5b0b9e77400c60a8324
7
- data.tar.gz: 9d35cb3828fa3088825f933242c60e61d4fc71ec06bda382874424f6b3401cb55c9b14545e72976b1ea1d80df8fd642cea147d39c315507250a525dd48a35cff
6
+ metadata.gz: cec680149e2742d4ed403a73d7283c454e0e561a95207ab426b9996c4056fa93626d0544de0923f575252038869a7e7e6b6f351eaaab4f1b7576ef20467bb527
7
+ data.tar.gz: 573b7ba81cae478ea658c27937563410bd83143bb0c13b9aeea3402422460ac55debff2adeffc83cb77c4be1372f6e49f1c640d8ff193c18199597a0bff25f58
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ # [0.99.0](https://github.com/getappmap/appmap-ruby/compare/v0.98.1...v0.99.0) (2023-04-13)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Don't report vendored paths as local ([e09cb4f](https://github.com/getappmap/appmap-ruby/commit/e09cb4f9764d275c7ba0858f16b545c2d287b473))
7
+ * Report the first relative path in the backtrace ([f81b346](https://github.com/getappmap/appmap-ruby/commit/f81b346ebc66a4f60ca26ad384d72672893d1333))
8
+
9
+
10
+ ### Features
11
+
12
+ * Report metadata.test_failure ([82c87d2](https://github.com/getappmap/appmap-ruby/commit/82c87d2453ce7c040bce138bf55d94d47aca58fc))
13
+
1
14
  ## [0.98.1](https://github.com/getappmap/appmap-ruby/compare/v0.98.0...v0.98.1) (2023-03-09)
2
15
 
3
16
 
@@ -26,13 +26,28 @@ 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
+
42
+ first_location = failure_exception.backtrace_locations.find { |location| !Pathname.new(Util.normalize_path(location.absolute_path)).absolute? }
43
+ failure_location = [ Util.normalize_path(first_location.path), first_location.lineno ].join(':') if first_location
44
+
45
+ test_failure = {
46
+ message: failure_exception.message,
47
+ location: failure_location,
48
+ }
49
+ end
50
+
36
51
  events = []
37
52
  AppMap.tracing.delete @trace
38
53
 
@@ -49,7 +64,8 @@ module AppMap
49
64
  AppMap::Minitest.save name: scenario_name,
50
65
  class_map: class_map,
51
66
  source_location: source_location,
52
- test_status: failed || exception ? 'failed' : 'succeeded',
67
+ test_status: failed ? 'failed' : 'succeeded',
68
+ test_failure: test_failure,
53
69
  exception: exception,
54
70
  events: events
55
71
  end
@@ -79,7 +95,7 @@ module AppMap
79
95
  recording = @recordings_by_test.delete(test.object_id)
80
96
  return warn "No recording found for #{test}" unless recording
81
97
 
82
- recording.finish (test.failures || []).any?, exception
98
+ recording.finish test.failures || [], exception
83
99
  end
84
100
 
85
101
  def config
@@ -90,7 +106,7 @@ module AppMap
90
106
  @event_methods += event_methods
91
107
  end
92
108
 
93
- def save(name:, class_map:, source_location:, test_status:, exception:, events:)
109
+ def save(name:, class_map:, source_location:, test_status:, test_failure:, exception:, events:)
94
110
  metadata = AppMap::Minitest.metadata.tap do |m|
95
111
  m[:name] = name
96
112
  m[:source_location] = source_location
@@ -105,11 +121,9 @@ module AppMap
105
121
  type: 'tests',
106
122
  }
107
123
  m[:test_status] = test_status
124
+ m[:test_failure] = test_failure if test_failure
108
125
  if exception
109
- m[:exception] = {
110
- class: exception.class.name,
111
- message: AppMap::Event::MethodEvent.display_string(exception.to_s),
112
- }
126
+ m[:exception] = Util.format_exception(exception)
113
127
  end
114
128
  end
115
129
 
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,24 @@ 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
+
108
+ first_location = failure_exception.backtrace_locations.find { |location| !Pathname.new(Util.normalize_path(location.absolute_path)).absolute? }
109
+ failure_location = [ Util.normalize_path(first_location.path), first_location.lineno ].join(':') if first_location
110
+
111
+ test_failure = {
112
+ message: failure_exception.message.strip,
113
+ location: failure_location,
114
+ }
115
+ end
116
+
103
117
  events = []
104
118
  AppMap.tracing.delete @trace
105
119
 
@@ -134,6 +148,7 @@ module AppMap
134
148
  class_map: class_map,
135
149
  source_location: source_location,
136
150
  test_status: exception ? 'failed' : 'succeeded',
151
+ test_failure: test_failure,
137
152
  exception: exception,
138
153
  events: events
139
154
  end
@@ -169,7 +184,7 @@ module AppMap
169
184
  recording = @recordings_by_example.delete(example.object_id)
170
185
  return warn "No recording found for #{example}" unless recording
171
186
 
172
- recording.finish exception unless recording == :false
187
+ recording.finish example.execution_result.exception || exception, exception unless recording == :false
173
188
  end
174
189
 
175
190
  def config
@@ -180,7 +195,7 @@ module AppMap
180
195
  @event_methods += event_methods
181
196
  end
182
197
 
183
- def save(name:, class_map:, source_location:, test_status:, exception:, events:)
198
+ def save(name:, class_map:, source_location:, test_status:, test_failure:, exception:, events:)
184
199
  metadata = AppMap::RSpec.metadata.tap do |m|
185
200
  m[:name] = name
186
201
  m[:source_location] = source_location
@@ -195,8 +210,10 @@ module AppMap
195
210
  type: 'tests'
196
211
  }
197
212
  m[:test_status] = test_status
213
+ m[:test_failure] = test_failure if test_failure
198
214
  if exception
199
- m[:exception] = {
215
+ m[:exception] = Util.format_exception(exception)
216
+ {
200
217
  class: exception.class.name,
201
218
  message: AppMap::Event::MethodEvent.display_string(exception.to_s)
202
219
  }
data/lib/appmap/util.rb CHANGED
@@ -139,13 +139,24 @@ 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
+
149
160
  # Convert a Rails-style path from /org/:org_id(.:format)
150
161
  # to Swagger-style paths like /org/{org_id}
151
162
  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.0'
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.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: 2023-03-09 00:00:00.000000000 Z
11
+ date: 2023-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: method_source