appmap 0.48.2 → 0.51.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 +4 -4
- data/CHANGELOG.md +45 -0
- data/README.md +3 -332
- data/appmap.gemspec +3 -0
- data/exe/appmap-agent-setup +47 -0
- data/lib/appmap.rb +74 -7
- data/lib/appmap/command/init.rb +42 -0
- data/lib/appmap/config.rb +104 -33
- data/lib/appmap/handler/rails/template.rb +19 -5
- data/lib/appmap/minitest.rb +8 -2
- data/lib/appmap/railtie.rb +7 -0
- data/lib/appmap/rspec.rb +8 -2
- data/lib/appmap/service/guesser.rb +26 -0
- data/lib/appmap/trace.rb +4 -2
- data/lib/appmap/util.rb +21 -0
- data/lib/appmap/version.rb +4 -1
- data/spec/abstract_controller_base_spec.rb +57 -18
- data/spec/config_spec.rb +21 -0
- data/spec/fixtures/rails5_users_app/config/application.rb +0 -8
- data/spec/fixtures/rails5_users_app/spec/rails_helper.rb +0 -2
- data/spec/fixtures/rails6_users_app/config/application.rb +0 -8
- data/spec/fixtures/rails6_users_app/spec/rails_helper.rb +0 -2
- data/spec/hook_spec.rb +2 -2
- data/spec/record_net_http_spec.rb +1 -1
- data/test/cli_test.rb +37 -0
- metadata +9 -6
- data/spec/fixtures/rails5_users_app/config/initializers/record_button.rb +0 -3
- data/spec/fixtures/rails6_users_app/config/initializers/record_button.rb +0 -3
data/lib/appmap/trace.rb
CHANGED
@@ -2,10 +2,12 @@
|
|
2
2
|
|
3
3
|
module AppMap
|
4
4
|
module Trace
|
5
|
-
class RubyMethod
|
5
|
+
class RubyMethod < SimpleDelegator
|
6
6
|
attr_reader :class_name, :static
|
7
7
|
|
8
8
|
def initialize(package, class_name, method, static)
|
9
|
+
super(method)
|
10
|
+
|
9
11
|
@package = package
|
10
12
|
@class_name = class_name
|
11
13
|
@method = method
|
@@ -111,7 +113,7 @@ module AppMap
|
|
111
113
|
@last_package_for_thread[Thread.current.object_id] = package if package
|
112
114
|
@events << event
|
113
115
|
static = event.static if event.respond_to?(:static)
|
114
|
-
|
116
|
+
record_method Trace::RubyMethod.new(package, defined_class, method, static) \
|
115
117
|
if package && defined_class && method && (event.event == :call)
|
116
118
|
end
|
117
119
|
|
data/lib/appmap/util.rb
CHANGED
@@ -4,6 +4,21 @@ require 'bundler'
|
|
4
4
|
|
5
5
|
module AppMap
|
6
6
|
module Util
|
7
|
+
# https://wynnnetherland.com/journal/a-stylesheet-author-s-guide-to-terminal-colors/
|
8
|
+
# Embed in a String to clear all previous ANSI sequences.
|
9
|
+
CLEAR = "\e[0m"
|
10
|
+
BOLD = "\e[1m"
|
11
|
+
|
12
|
+
# Colors
|
13
|
+
BLACK = "\e[30m"
|
14
|
+
RED = "\e[31m"
|
15
|
+
GREEN = "\e[32m"
|
16
|
+
YELLOW = "\e[33m"
|
17
|
+
BLUE = "\e[34m"
|
18
|
+
MAGENTA = "\e[35m"
|
19
|
+
CYAN = "\e[36m"
|
20
|
+
WHITE = "\e[37m"
|
21
|
+
|
7
22
|
class << self
|
8
23
|
# scenario_filename builds a suitable file name from a scenario name.
|
9
24
|
# Special characters are removed, and the file name is truncated to fit within
|
@@ -128,6 +143,12 @@ module AppMap
|
|
128
143
|
FileUtils.mv tempfile.path, filename
|
129
144
|
end
|
130
145
|
end
|
146
|
+
|
147
|
+
def color(text, color, bold: false)
|
148
|
+
color = Util.const_get(color.to_s.upcase) if color.is_a?(Symbol)
|
149
|
+
bold = bold ? BOLD : ""
|
150
|
+
"#{bold}#{color}#{text}#{CLEAR}"
|
151
|
+
end
|
131
152
|
end
|
132
153
|
end
|
133
154
|
end
|
data/lib/appmap/version.rb
CHANGED
@@ -1,9 +1,30 @@
|
|
1
1
|
require 'rails_spec_helper'
|
2
2
|
|
3
3
|
describe 'Rails' do
|
4
|
+
shared_context 'rails integration test setup' do
|
5
|
+
def tmpdir
|
6
|
+
'tmp/spec/AbstractControllerBase'
|
7
|
+
end
|
8
|
+
|
9
|
+
unless use_existing_data?
|
10
|
+
before(:all) do
|
11
|
+
FileUtils.rm_rf tmpdir
|
12
|
+
FileUtils.mkdir_p tmpdir
|
13
|
+
run_spec 'spec/controllers/users_controller_spec.rb'
|
14
|
+
run_spec 'spec/controllers/users_controller_api_spec.rb'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:appmap) { JSON.parse File.read File.join tmpdir, 'appmap/rspec', appmap_json_file }
|
19
|
+
let(:appmap_json_path) { File.join(tmpdir, 'appmap/rspec', appmap_json_file) }
|
20
|
+
let(:appmap) { JSON.parse File.read(appmap_json_path) }
|
21
|
+
let(:events) { appmap['events'] }
|
22
|
+
end
|
23
|
+
|
4
24
|
%w[5 6].each do |rails_major_version| # rubocop:disable Metrics/BlockLength
|
5
25
|
context "#{rails_major_version}" do
|
6
26
|
include_context 'Rails app pg database', "spec/fixtures/rails#{rails_major_version}_users_app" unless use_existing_data?
|
27
|
+
include_context 'rails integration test setup'
|
7
28
|
|
8
29
|
def run_spec(spec_name)
|
9
30
|
cmd = <<~CMD.gsub "\n", ' '
|
@@ -13,24 +34,6 @@ describe 'Rails' do
|
|
13
34
|
run_cmd cmd, chdir: fixture_dir
|
14
35
|
end
|
15
36
|
|
16
|
-
def tmpdir
|
17
|
-
'tmp/spec/AbstractControllerBase'
|
18
|
-
end
|
19
|
-
|
20
|
-
unless use_existing_data?
|
21
|
-
before(:all) do
|
22
|
-
FileUtils.rm_rf tmpdir
|
23
|
-
FileUtils.mkdir_p tmpdir
|
24
|
-
run_spec 'spec/controllers/users_controller_spec.rb'
|
25
|
-
run_spec 'spec/controllers/users_controller_api_spec.rb'
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
let(:appmap) { JSON.parse File.read File.join tmpdir, 'appmap/rspec', appmap_json_file }
|
30
|
-
let(:appmap_json_path) { File.join(tmpdir, 'appmap/rspec', appmap_json_file) }
|
31
|
-
let(:appmap) { JSON.parse File.read(appmap_json_path) }
|
32
|
-
let(:events) { appmap['events'] }
|
33
|
-
|
34
37
|
describe 'an API route' do
|
35
38
|
describe 'creating an object' do
|
36
39
|
let(:appmap_json_file) do
|
@@ -253,4 +256,40 @@ describe 'Rails' do
|
|
253
256
|
end
|
254
257
|
end
|
255
258
|
end
|
259
|
+
|
260
|
+
describe 'with default appmap.yml' do
|
261
|
+
include_context 'Rails app pg database', "spec/fixtures/rails5_users_app" unless use_existing_data?
|
262
|
+
include_context 'rails integration test setup'
|
263
|
+
|
264
|
+
def run_spec(spec_name)
|
265
|
+
cmd = <<~CMD.gsub "\n", ' '
|
266
|
+
docker-compose run --rm -e RAILS_ENV=test -e APPMAP=true -e APPMAP_CONFIG_FILE=no/such/file
|
267
|
+
-v #{File.absolute_path tmpdir}:/app/tmp app ./bin/rspec #{spec_name}
|
268
|
+
CMD
|
269
|
+
run_cmd cmd, chdir: fixture_dir
|
270
|
+
end
|
271
|
+
|
272
|
+
let(:appmap_json_file) do
|
273
|
+
'Api_UsersController_POST_api_users_with_required_parameters_creates_a_user.appmap.json'
|
274
|
+
end
|
275
|
+
|
276
|
+
it 'http_server_request is recorded' do
|
277
|
+
expect(events).to include(
|
278
|
+
hash_including(
|
279
|
+
'http_server_request' => hash_including(
|
280
|
+
'request_method' => 'POST',
|
281
|
+
'path_info' => '/api/users'
|
282
|
+
)
|
283
|
+
)
|
284
|
+
)
|
285
|
+
end
|
286
|
+
|
287
|
+
it 'controller method is recorded' do
|
288
|
+
expect(events).to include hash_including(
|
289
|
+
'defined_class' => 'Api::UsersController',
|
290
|
+
'method_id' => 'build_user',
|
291
|
+
'path' => 'app/controllers/api/users_controller.rb',
|
292
|
+
)
|
293
|
+
end
|
294
|
+
end
|
256
295
|
end
|
data/spec/config_spec.rb
CHANGED
@@ -55,4 +55,25 @@ describe AppMap::Config, docker: false do
|
|
55
55
|
|
56
56
|
expect(config.to_h.deep_stringify_keys!).to eq(config_expectation)
|
57
57
|
end
|
58
|
+
|
59
|
+
context do
|
60
|
+
let(:warnings) { @warnings ||= [] }
|
61
|
+
let(:warning) { warnings.join }
|
62
|
+
before do
|
63
|
+
expect(AppMap::Config).to receive(:warn).at_least(1) { |msg| warnings << msg }
|
64
|
+
end
|
65
|
+
it 'prints a warning and uses a default config' do
|
66
|
+
config = AppMap::Config.load_from_file 'no/such/file'
|
67
|
+
expect(config.to_h).to eq(YAML.load(<<~CONFIG))
|
68
|
+
:name: appmap-ruby
|
69
|
+
:packages:
|
70
|
+
- :path: lib
|
71
|
+
:handler_class: AppMap::Handler::Function
|
72
|
+
:shallow: false
|
73
|
+
:functions: []
|
74
|
+
:exclude: []
|
75
|
+
CONFIG
|
76
|
+
expect(warning).to include('NOTICE: The AppMap config file no/such/file was not found!')
|
77
|
+
end
|
78
|
+
end
|
58
79
|
end
|
@@ -21,14 +21,6 @@ when 'activerecord'
|
|
21
21
|
require 'database_cleaner-active_record' if Rails.env.test?
|
22
22
|
end
|
23
23
|
|
24
|
-
require 'appmap/railtie' if defined?(AppMap)
|
25
|
-
|
26
|
-
# require "active_storage/engine"
|
27
|
-
# require "action_mailer/railtie"
|
28
|
-
# require "action_cable/engine"
|
29
|
-
# require "sprockets/railtie"
|
30
|
-
# require "rails/test_unit/railtie"
|
31
|
-
|
32
24
|
# Require the gems listed in Gemfile, including any gems
|
33
25
|
# you've limited to :test, :development, or :production.
|
34
26
|
Bundler.require(*Rails.groups)
|
@@ -7,8 +7,6 @@ abort("The Rails environment is running in production mode!") if Rails.env.produ
|
|
7
7
|
require 'rspec/rails'
|
8
8
|
# Add additional requires below this line. Rails is not loaded until this point!
|
9
9
|
|
10
|
-
require 'appmap/rspec'
|
11
|
-
|
12
10
|
# Requires supporting ruby files with custom matchers and macros, etc, in
|
13
11
|
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
14
12
|
# run as spec files by default. This means that files in spec/support that end
|
@@ -21,14 +21,6 @@ when 'activerecord'
|
|
21
21
|
require 'database_cleaner-active_record' if Rails.env.test?
|
22
22
|
end
|
23
23
|
|
24
|
-
require 'appmap/railtie' if defined?(AppMap)
|
25
|
-
|
26
|
-
# require "active_storage/engine"
|
27
|
-
# require "action_mailer/railtie"
|
28
|
-
# require "action_cable/engine"
|
29
|
-
# require "sprockets/railtie"
|
30
|
-
# require "rails/test_unit/railtie"
|
31
|
-
|
32
24
|
# Require the gems listed in Gemfile, including any gems
|
33
25
|
# you've limited to :test, :development, or :production.
|
34
26
|
Bundler.require(*Rails.groups)
|
@@ -7,8 +7,6 @@ abort("The Rails environment is running in production mode!") if Rails.env.produ
|
|
7
7
|
require 'rspec/rails'
|
8
8
|
# Add additional requires below this line. Rails is not loaded until this point!
|
9
9
|
|
10
|
-
require 'appmap/rspec'
|
11
|
-
|
12
10
|
# Requires supporting ruby files with custom matchers and macros, etc, in
|
13
11
|
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
14
12
|
# run as spec files by default. This means that files in spec/support that end
|
data/spec/hook_spec.rb
CHANGED
@@ -21,7 +21,7 @@ describe 'AppMap class Hooking', docker: false do
|
|
21
21
|
def invoke_test_file(file, setup: nil, &block)
|
22
22
|
AppMap.configuration = nil
|
23
23
|
package = AppMap::Config::Package.build_from_path(file)
|
24
|
-
config = AppMap::Config.new('hook_spec', [ package ])
|
24
|
+
config = AppMap::Config.new('hook_spec', packages: [ package ])
|
25
25
|
AppMap.configuration = config
|
26
26
|
tracer = nil
|
27
27
|
AppMap::Hook.new(config).enable do
|
@@ -57,7 +57,7 @@ describe 'AppMap class Hooking', docker: false do
|
|
57
57
|
it 'excludes named classes and methods' do
|
58
58
|
load 'spec/fixtures/hook/exclude.rb'
|
59
59
|
package = AppMap::Config::Package.build_from_path('spec/fixtures/hook/exclude.rb')
|
60
|
-
config = AppMap::Config.new('hook_spec', [ package ], exclude: %w[ExcludeTest])
|
60
|
+
config = AppMap::Config.new('hook_spec', packages: [ package ], exclude: %w[ExcludeTest])
|
61
61
|
AppMap.configuration = config
|
62
62
|
|
63
63
|
expect(config.never_hook?(ExcludeTest, ExcludeTest.new.method(:instance_method))).to be_truthy
|
@@ -62,7 +62,7 @@ describe 'Net::HTTP handler' do
|
|
62
62
|
end
|
63
63
|
|
64
64
|
context 'with trace enabled' do
|
65
|
-
let(:configuration) { AppMap::Config.new('record_net_http_spec'
|
65
|
+
let(:configuration) { AppMap::Config.new('record_net_http_spec') }
|
66
66
|
|
67
67
|
after do
|
68
68
|
AppMap.configuration = nil
|
data/test/cli_test.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'test_helper'
|
5
|
+
|
6
|
+
class CLITest < Minitest::Test
|
7
|
+
CONFIG_FILENAME = '123.yml'
|
8
|
+
SUBFOLDER_CONFIG_FILEPATH = 'conf/123.yml'
|
9
|
+
EXPECTED_CONFIG_CONTENT = %(name: appmap-ruby
|
10
|
+
packages:
|
11
|
+
- path: lib
|
12
|
+
)
|
13
|
+
|
14
|
+
def test_init_when_config_exists
|
15
|
+
output = `./exe/appmap-agent-setup init`
|
16
|
+
assert_equal 0, $CHILD_STATUS.exitstatus
|
17
|
+
assert_includes output, 'The AppMap config file appmap.yml already exists.'
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_init_with_custom_config_filename
|
21
|
+
output = `./exe/appmap-agent-setup -c #{CONFIG_FILENAME} init`
|
22
|
+
assert_equal 0, $CHILD_STATUS.exitstatus
|
23
|
+
assert_includes output, "The following AppMap config file #{CONFIG_FILENAME} has been created:"
|
24
|
+
assert_equal EXPECTED_CONFIG_CONTENT, File.read(CONFIG_FILENAME)
|
25
|
+
ensure
|
26
|
+
File.delete(CONFIG_FILENAME) if File.exist?(CONFIG_FILENAME)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_init_with_custom_config_file_in_subfolder
|
30
|
+
output = `./exe/appmap-agent-setup -c #{SUBFOLDER_CONFIG_FILEPATH} init`
|
31
|
+
assert_equal 0, $CHILD_STATUS.exitstatus
|
32
|
+
assert_includes output, "The following AppMap config file #{SUBFOLDER_CONFIG_FILEPATH} has been created:"
|
33
|
+
assert_equal EXPECTED_CONFIG_CONTENT, File.read(SUBFOLDER_CONFIG_FILEPATH)
|
34
|
+
ensure
|
35
|
+
File.delete(SUBFOLDER_CONFIG_FILEPATH) if File.exist?(SUBFOLDER_CONFIG_FILEPATH)
|
36
|
+
end
|
37
|
+
end
|
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.51.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Gilpin
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -307,7 +307,8 @@ dependencies:
|
|
307
307
|
description:
|
308
308
|
email:
|
309
309
|
- kgilpin@gmail.com
|
310
|
-
executables:
|
310
|
+
executables:
|
311
|
+
- appmap-agent-setup
|
311
312
|
extensions:
|
312
313
|
- ext/appmap/extconf.rb
|
313
314
|
extra_rdoc_files: []
|
@@ -335,12 +336,14 @@ files:
|
|
335
336
|
- examples/mock_webapp/lib/mock_webapp/controller.rb
|
336
337
|
- examples/mock_webapp/lib/mock_webapp/request.rb
|
337
338
|
- examples/mock_webapp/lib/mock_webapp/user.rb
|
339
|
+
- exe/appmap-agent-setup
|
338
340
|
- ext/appmap/appmap.c
|
339
341
|
- ext/appmap/extconf.rb
|
340
342
|
- lib/appmap.rb
|
341
343
|
- lib/appmap/algorithm/prune_class_map.rb
|
342
344
|
- lib/appmap/algorithm/stats.rb
|
343
345
|
- lib/appmap/class_map.rb
|
346
|
+
- lib/appmap/command/init.rb
|
344
347
|
- lib/appmap/command/record.rb
|
345
348
|
- lib/appmap/command/stats.rb
|
346
349
|
- lib/appmap/config.rb
|
@@ -360,6 +363,7 @@ files:
|
|
360
363
|
- lib/appmap/railtie.rb
|
361
364
|
- lib/appmap/record.rb
|
362
365
|
- lib/appmap/rspec.rb
|
366
|
+
- lib/appmap/service/guesser.rb
|
363
367
|
- lib/appmap/trace.rb
|
364
368
|
- lib/appmap/util.rb
|
365
369
|
- lib/appmap/version.rb
|
@@ -455,7 +459,6 @@ files:
|
|
455
459
|
- spec/fixtures/rails5_users_app/config/initializers/filter_parameter_logging.rb
|
456
460
|
- spec/fixtures/rails5_users_app/config/initializers/inflections.rb
|
457
461
|
- spec/fixtures/rails5_users_app/config/initializers/mime_types.rb
|
458
|
-
- spec/fixtures/rails5_users_app/config/initializers/record_button.rb
|
459
462
|
- spec/fixtures/rails5_users_app/config/initializers/wrap_parameters.rb
|
460
463
|
- spec/fixtures/rails5_users_app/config/locales/en.yml
|
461
464
|
- spec/fixtures/rails5_users_app/config/routes.rb
|
@@ -527,7 +530,6 @@ files:
|
|
527
530
|
- spec/fixtures/rails6_users_app/config/initializers/filter_parameter_logging.rb
|
528
531
|
- spec/fixtures/rails6_users_app/config/initializers/inflections.rb
|
529
532
|
- spec/fixtures/rails6_users_app/config/initializers/mime_types.rb
|
530
|
-
- spec/fixtures/rails6_users_app/config/initializers/record_button.rb
|
531
533
|
- spec/fixtures/rails6_users_app/config/initializers/wrap_parameters.rb
|
532
534
|
- spec/fixtures/rails6_users_app/config/locales/en.yml
|
533
535
|
- spec/fixtures/rails6_users_app/config/routes.rb
|
@@ -558,6 +560,7 @@ files:
|
|
558
560
|
- spec/spec_helper.rb
|
559
561
|
- spec/util_spec.rb
|
560
562
|
- test/bundle_vendor_test.rb
|
563
|
+
- test/cli_test.rb
|
561
564
|
- test/cucumber_test.rb
|
562
565
|
- test/expectations/openssl_test_key_sign1.json
|
563
566
|
- test/expectations/openssl_test_key_sign2.json
|