appmap 0.25.0 → 0.28.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 +4 -4
- data/.gitignore +1 -2
- data/CHANGELOG.md +33 -0
- data/README.md +123 -39
- data/exe/appmap +3 -57
- data/lib/appmap.rb +51 -32
- data/lib/appmap/command/record.rb +2 -61
- data/lib/appmap/cucumber.rb +89 -0
- data/lib/appmap/event.rb +1 -1
- data/lib/appmap/hook.rb +7 -1
- data/lib/appmap/metadata.rb +62 -0
- data/lib/appmap/middleware/remote_recording.rb +2 -7
- data/lib/appmap/rails/sql_handler.rb +0 -5
- data/lib/appmap/railtie.rb +2 -2
- data/lib/appmap/rspec.rb +20 -38
- data/lib/appmap/trace.rb +9 -9
- data/lib/appmap/util.rb +40 -0
- data/lib/appmap/version.rb +1 -1
- data/spec/fixtures/rails_users_app/Gemfile +1 -0
- data/spec/fixtures/rails_users_app/features/api_users.feature +13 -0
- data/spec/fixtures/rails_users_app/features/support/env.rb +4 -0
- data/spec/fixtures/rails_users_app/features/support/hooks.rb +11 -0
- data/spec/fixtures/rails_users_app/features/support/steps.rb +18 -0
- data/spec/hook_spec.rb +21 -3
- data/spec/rails_spec_helper.rb +2 -0
- data/spec/rspec_feature_metadata_spec.rb +2 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/util_spec.rb +21 -0
- data/test/cli_test.rb +0 -13
- data/test/cucumber_test.rb +72 -0
- data/test/fixtures/cucumber4_recorder/Gemfile +5 -0
- data/test/fixtures/cucumber4_recorder/appmap.yml +3 -0
- data/test/fixtures/cucumber4_recorder/features/say_hello.feature +5 -0
- data/test/fixtures/cucumber4_recorder/features/support/env.rb +5 -0
- data/test/fixtures/cucumber4_recorder/features/support/hooks.rb +11 -0
- data/test/fixtures/cucumber4_recorder/features/support/steps.rb +9 -0
- data/test/fixtures/cucumber4_recorder/lib/hello.rb +7 -0
- data/test/fixtures/cucumber_recorder/Gemfile +5 -0
- data/test/fixtures/cucumber_recorder/appmap.yml +3 -0
- data/test/fixtures/cucumber_recorder/features/say_hello.feature +5 -0
- data/test/fixtures/cucumber_recorder/features/support/env.rb +5 -0
- data/test/fixtures/cucumber_recorder/features/support/hooks.rb +11 -0
- data/test/fixtures/cucumber_recorder/features/support/steps.rb +9 -0
- data/test/fixtures/cucumber_recorder/lib/hello.rb +7 -0
- data/test/fixtures/rspec_recorder/Gemfile +1 -1
- data/test/fixtures/rspec_recorder/spec/decorated_hello_spec.rb +12 -0
- data/test/rspec_test.rb +5 -0
- metadata +26 -3
- data/lib/appmap/command/upload.rb +0 -101
data/test/rspec_test.rb
CHANGED
@@ -9,6 +9,7 @@ class RSpecTest < Minitest::Test
|
|
9
9
|
Bundler.with_clean_env do
|
10
10
|
Dir.chdir 'test/fixtures/rspec_recorder' do
|
11
11
|
FileUtils.rm_rf 'tmp'
|
12
|
+
system 'bundle config --local local.appmap ../../..'
|
12
13
|
system 'bundle'
|
13
14
|
system({ 'APPMAP' => 'true' }, %(bundle exec rspec spec/#{test_name}.rb))
|
14
15
|
|
@@ -48,6 +49,10 @@ class RSpecTest < Minitest::Test
|
|
48
49
|
assert_equal({ name: 'appmap', url: AppMap::URL, version: AppMap::VERSION }.stringify_keys, metadata['client'])
|
49
50
|
assert_includes metadata.keys, 'recorder'
|
50
51
|
assert_equal({ name: 'rspec' }.stringify_keys, metadata['recorder'])
|
52
|
+
|
53
|
+
assert_includes metadata.keys, 'frameworks'
|
54
|
+
rspec = metadata['frameworks'].select {|f| f['name'] == 'rspec'}
|
55
|
+
assert_equal 1, rspec.count
|
51
56
|
end
|
52
57
|
end
|
53
58
|
|
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.
|
4
|
+
version: 0.28.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: 2020-
|
11
|
+
date: 2020-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -269,15 +269,17 @@ files:
|
|
269
269
|
- lib/appmap/class_map.rb
|
270
270
|
- lib/appmap/command/record.rb
|
271
271
|
- lib/appmap/command/stats.rb
|
272
|
-
- lib/appmap/
|
272
|
+
- lib/appmap/cucumber.rb
|
273
273
|
- lib/appmap/event.rb
|
274
274
|
- lib/appmap/hook.rb
|
275
|
+
- lib/appmap/metadata.rb
|
275
276
|
- lib/appmap/middleware/remote_recording.rb
|
276
277
|
- lib/appmap/rails/action_handler.rb
|
277
278
|
- lib/appmap/rails/sql_handler.rb
|
278
279
|
- lib/appmap/railtie.rb
|
279
280
|
- lib/appmap/rspec.rb
|
280
281
|
- lib/appmap/trace.rb
|
282
|
+
- lib/appmap/util.rb
|
281
283
|
- lib/appmap/version.rb
|
282
284
|
- lore/pages/2019-05-21-install-and-record/index.pug
|
283
285
|
- lore/pages/2019-05-21-install-and-record/install_example_appmap.png
|
@@ -437,6 +439,10 @@ files:
|
|
437
439
|
- spec/fixtures/rails_users_app/db/migrate/20190728211408_create_users.rb
|
438
440
|
- spec/fixtures/rails_users_app/db/schema.rb
|
439
441
|
- spec/fixtures/rails_users_app/docker-compose.yml
|
442
|
+
- spec/fixtures/rails_users_app/features/api_users.feature
|
443
|
+
- spec/fixtures/rails_users_app/features/support/env.rb
|
444
|
+
- spec/fixtures/rails_users_app/features/support/hooks.rb
|
445
|
+
- spec/fixtures/rails_users_app/features/support/steps.rb
|
440
446
|
- spec/fixtures/rails_users_app/lib/tasks/.keep
|
441
447
|
- spec/fixtures/rails_users_app/log/.keep
|
442
448
|
- spec/fixtures/rails_users_app/public/robots.txt
|
@@ -453,9 +459,26 @@ files:
|
|
453
459
|
- spec/remote_recording_spec.rb
|
454
460
|
- spec/rspec_feature_metadata_spec.rb
|
455
461
|
- spec/spec_helper.rb
|
462
|
+
- spec/util_spec.rb
|
456
463
|
- test/cli_test.rb
|
464
|
+
- test/cucumber_test.rb
|
457
465
|
- test/fixtures/cli_record_test/appmap.yml
|
458
466
|
- test/fixtures/cli_record_test/lib/cli_record_test/main.rb
|
467
|
+
- test/fixtures/cucumber4_recorder/Gemfile
|
468
|
+
- test/fixtures/cucumber4_recorder/appmap.yml
|
469
|
+
- test/fixtures/cucumber4_recorder/features/say_hello.feature
|
470
|
+
- test/fixtures/cucumber4_recorder/features/support/env.rb
|
471
|
+
- test/fixtures/cucumber4_recorder/features/support/hooks.rb
|
472
|
+
- test/fixtures/cucumber4_recorder/features/support/steps.rb
|
473
|
+
- test/fixtures/cucumber4_recorder/lib/hello.rb
|
474
|
+
- test/fixtures/cucumber_recorder/.bundle/config
|
475
|
+
- test/fixtures/cucumber_recorder/Gemfile
|
476
|
+
- test/fixtures/cucumber_recorder/appmap.yml
|
477
|
+
- test/fixtures/cucumber_recorder/features/say_hello.feature
|
478
|
+
- test/fixtures/cucumber_recorder/features/support/env.rb
|
479
|
+
- test/fixtures/cucumber_recorder/features/support/hooks.rb
|
480
|
+
- test/fixtures/cucumber_recorder/features/support/steps.rb
|
481
|
+
- test/fixtures/cucumber_recorder/lib/hello.rb
|
459
482
|
- test/fixtures/rspec_recorder/Gemfile
|
460
483
|
- test/fixtures/rspec_recorder/appmap.yml
|
461
484
|
- test/fixtures/rspec_recorder/lib/hello.rb
|
@@ -1,101 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'json'
|
4
|
-
require 'faraday'
|
5
|
-
|
6
|
-
module AppMap
|
7
|
-
module Command
|
8
|
-
UploadResponse = Struct.new(:batch_id, :scenario_uuid)
|
9
|
-
|
10
|
-
UploadStruct = Struct.new(:data, :url, :user, :org)
|
11
|
-
class Upload < UploadStruct
|
12
|
-
MAX_DEPTH = 12
|
13
|
-
|
14
|
-
attr_accessor :batch_id
|
15
|
-
|
16
|
-
def initialize(data, url, user, org)
|
17
|
-
super
|
18
|
-
|
19
|
-
# TODO: Make this an option
|
20
|
-
@max_depth = MAX_DEPTH
|
21
|
-
end
|
22
|
-
|
23
|
-
def perform
|
24
|
-
appmap = data.clone
|
25
|
-
|
26
|
-
events = data.delete('events')
|
27
|
-
class_map = data.delete('classMap') || []
|
28
|
-
|
29
|
-
unless events.blank?
|
30
|
-
pruned_events = []
|
31
|
-
stack = []
|
32
|
-
events.each do |evt|
|
33
|
-
if evt['event'] == 'call'
|
34
|
-
stack << evt
|
35
|
-
stack_depth = stack.length
|
36
|
-
else
|
37
|
-
stack_depth = stack.length
|
38
|
-
stack.pop
|
39
|
-
end
|
40
|
-
|
41
|
-
prune = stack_depth > @max_depth
|
42
|
-
|
43
|
-
pruned_events << evt unless prune
|
44
|
-
end
|
45
|
-
|
46
|
-
warn "Pruned events to #{pruned_events.length}" if events.length > pruned_events.length
|
47
|
-
|
48
|
-
appmap[:events] = pruned_events
|
49
|
-
appmap[:classMap] = prune(class_map, events: pruned_events)
|
50
|
-
else
|
51
|
-
appmap[:events] = []
|
52
|
-
appmap[:classMap] = prune(class_map)
|
53
|
-
end
|
54
|
-
|
55
|
-
upload_file = { user: user, org: org, data: appmap }.compact
|
56
|
-
|
57
|
-
conn = Faraday.new(url: url)
|
58
|
-
response = conn.post do |req|
|
59
|
-
req.url '/api/scenarios'
|
60
|
-
req.headers['Content-Type'] = 'application/json'
|
61
|
-
req.headers[AppMap::BATCH_HEADER_NAME] = @batch_id if @batch_id
|
62
|
-
req.body = JSON.generate(upload_file)
|
63
|
-
end
|
64
|
-
|
65
|
-
unless response.body.blank?
|
66
|
-
message = begin
|
67
|
-
JSON.parse(response.body)
|
68
|
-
rescue JSON::ParserError => e
|
69
|
-
warn "Response is not valid JSON (#{e.message})"
|
70
|
-
nil
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
unless response.success?
|
75
|
-
error = [ 'Upload failed' ]
|
76
|
-
error << ": #{message}" if message
|
77
|
-
raise error.join
|
78
|
-
end
|
79
|
-
|
80
|
-
batch_id = @batch_id || response.headers[AppMap::BATCH_HEADER_NAME]
|
81
|
-
|
82
|
-
uuid = message['uuid']
|
83
|
-
UploadResponse.new(batch_id, uuid)
|
84
|
-
end
|
85
|
-
|
86
|
-
protected
|
87
|
-
|
88
|
-
def debug?
|
89
|
-
ENV['DEBUG'] == 'true' || ENV['GLI_DEBUG'] == 'true'
|
90
|
-
end
|
91
|
-
|
92
|
-
def prune(class_map, events: nil)
|
93
|
-
require 'appmap/algorithm/prune_class_map'
|
94
|
-
Algorithm::PruneClassMap.new(class_map).tap do |alg|
|
95
|
-
alg.events = events if events
|
96
|
-
alg.logger = ->(msg) { warn msg } if debug?
|
97
|
-
end.perform
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|