appmap 0.35.0 → 0.37.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dockerignore +1 -1
- data/.gitignore +2 -1
- data/.rubocop.yml +10 -0
- data/CHANGELOG.md +22 -0
- data/README.md +11 -8
- data/Rakefile +3 -2
- data/appmap.gemspec +2 -1
- data/appmap.yml +1 -7
- data/lib/appmap.rb +2 -2
- data/lib/appmap/class_map.rb +20 -6
- data/lib/appmap/config.rb +53 -23
- data/lib/appmap/event.rb +21 -6
- data/lib/appmap/hook.rb +1 -1
- data/lib/appmap/rails/request_handler.rb +8 -1
- data/lib/appmap/railtie.rb +1 -1
- data/lib/appmap/rspec.rb +1 -1
- data/lib/appmap/version.rb +2 -2
- data/spec/abstract_controller4_base_spec.rb +27 -28
- data/spec/abstract_controller_base_spec.rb +43 -39
- data/spec/class_map_spec.rb +36 -0
- data/spec/fixtures/hook/exception_method.rb +44 -0
- data/spec/fixtures/hook/instance_method.rb +4 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/.dockerignore +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/.gitignore +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/.rspec +0 -0
- data/{.ruby-version → spec/fixtures/rails5_users_app/.ruby-version} +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/Dockerfile +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/Dockerfile.pg +0 -0
- data/spec/fixtures/rails5_users_app/Gemfile +51 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/Rakefile +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/app/controllers/api/users_controller.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/app/controllers/application_controller.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/app/controllers/concerns/.keep +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/app/controllers/health_controller.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/app/controllers/users_controller.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/app/models/activerecord/user.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/app/models/concerns/.keep +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/app/models/sequel/user.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/app/views/layouts/application.html.haml +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/app/views/users/index.html.haml +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/appmap.yml +1 -1
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/appmap +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/byebug +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/gli +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/htmldiff +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/ldiff +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/nokogiri +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/rackup +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/rails +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/rake +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/rspec +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/ruby-parse +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/ruby-rewrite +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/sequel +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/setup +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/sprockets +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/thor +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/bin/update +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config.ru +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/application.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/boot.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/credentials.yml.enc +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/database.yml +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/environment.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/environments/development.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/environments/production.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/environments/test.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/application_controller_renderer.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/backtrace_silencers.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/cors.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/filter_parameter_logging.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/inflections.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/mime_types.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/record_button.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/initializers/wrap_parameters.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/locales/en.yml +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/config/routes.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/create_app +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/db/migrate/20190728211408_create_users.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/db/schema.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/docker-compose.yml +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/features/api_users.feature +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/features/support/env.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/features/support/hooks.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/features/support/steps.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/lib/tasks/.keep +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/log/.keep +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/public/robots.txt +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/spec/controllers/users_controller_api_spec.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/spec/models/user_spec.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/spec/rails_helper.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/spec/spec_helper.rb +0 -0
- data/spec/fixtures/{rails_users_app → rails5_users_app}/users_app/.gitignore +0 -0
- data/spec/fixtures/rails6_users_app/.dockerignore +1 -0
- data/spec/fixtures/rails6_users_app/.gitignore +39 -0
- data/spec/fixtures/rails6_users_app/.rspec +1 -0
- data/spec/fixtures/{rails_users_app → rails6_users_app}/.ruby-version +0 -0
- data/spec/fixtures/rails6_users_app/Dockerfile +29 -0
- data/spec/fixtures/rails6_users_app/Dockerfile.pg +3 -0
- data/spec/fixtures/{rails_users_app → rails6_users_app}/Gemfile +0 -0
- data/spec/fixtures/rails6_users_app/Rakefile +6 -0
- data/spec/fixtures/rails6_users_app/app/controllers/api/users_controller.rb +27 -0
- data/spec/fixtures/rails6_users_app/app/controllers/application_controller.rb +2 -0
- data/spec/fixtures/rails6_users_app/app/controllers/concerns/.keep +0 -0
- data/spec/fixtures/rails6_users_app/app/controllers/health_controller.rb +5 -0
- data/spec/fixtures/rails6_users_app/app/controllers/users_controller.rb +5 -0
- data/spec/fixtures/rails6_users_app/app/models/activerecord/user.rb +18 -0
- data/spec/fixtures/rails6_users_app/app/models/concerns/.keep +0 -0
- data/spec/fixtures/rails6_users_app/app/models/sequel/user.rb +25 -0
- data/spec/fixtures/rails6_users_app/app/views/layouts/application.html.haml +7 -0
- data/spec/fixtures/rails6_users_app/app/views/users/index.html.haml +7 -0
- data/spec/fixtures/rails6_users_app/appmap.yml +3 -0
- data/spec/fixtures/rails6_users_app/bin/appmap +29 -0
- data/spec/fixtures/rails6_users_app/bin/byebug +29 -0
- data/spec/fixtures/rails6_users_app/bin/gli +29 -0
- data/spec/fixtures/rails6_users_app/bin/htmldiff +29 -0
- data/spec/fixtures/rails6_users_app/bin/ldiff +29 -0
- data/spec/fixtures/rails6_users_app/bin/nokogiri +29 -0
- data/spec/fixtures/rails6_users_app/bin/rackup +29 -0
- data/spec/fixtures/rails6_users_app/bin/rails +4 -0
- data/spec/fixtures/rails6_users_app/bin/rake +29 -0
- data/spec/fixtures/rails6_users_app/bin/rspec +29 -0
- data/spec/fixtures/rails6_users_app/bin/ruby-parse +29 -0
- data/spec/fixtures/rails6_users_app/bin/ruby-rewrite +29 -0
- data/spec/fixtures/rails6_users_app/bin/sequel +29 -0
- data/spec/fixtures/rails6_users_app/bin/setup +25 -0
- data/spec/fixtures/rails6_users_app/bin/sprockets +29 -0
- data/spec/fixtures/rails6_users_app/bin/thor +29 -0
- data/spec/fixtures/rails6_users_app/bin/update +25 -0
- data/spec/fixtures/rails6_users_app/config.ru +5 -0
- data/spec/fixtures/rails6_users_app/config/application.rb +51 -0
- data/spec/fixtures/rails6_users_app/config/boot.rb +3 -0
- data/spec/fixtures/rails6_users_app/config/credentials.yml.enc +1 -0
- data/spec/fixtures/rails6_users_app/config/database.yml +18 -0
- data/spec/fixtures/rails6_users_app/config/environment.rb +5 -0
- data/spec/fixtures/rails6_users_app/config/environments/development.rb +40 -0
- data/spec/fixtures/rails6_users_app/config/environments/production.rb +68 -0
- data/spec/fixtures/rails6_users_app/config/environments/test.rb +36 -0
- data/spec/fixtures/rails6_users_app/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/fixtures/rails6_users_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/fixtures/rails6_users_app/config/initializers/cors.rb +16 -0
- data/spec/fixtures/rails6_users_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/fixtures/rails6_users_app/config/initializers/inflections.rb +16 -0
- data/spec/fixtures/rails6_users_app/config/initializers/mime_types.rb +4 -0
- data/spec/fixtures/rails6_users_app/config/initializers/record_button.rb +3 -0
- data/spec/fixtures/rails6_users_app/config/initializers/wrap_parameters.rb +9 -0
- data/spec/fixtures/rails6_users_app/config/locales/en.yml +33 -0
- data/spec/fixtures/rails6_users_app/config/routes.rb +11 -0
- data/spec/fixtures/rails6_users_app/create_app +27 -0
- data/spec/fixtures/rails6_users_app/db/migrate/20190728211408_create_users.rb +9 -0
- data/spec/fixtures/rails6_users_app/db/schema.rb +23 -0
- data/spec/fixtures/rails6_users_app/docker-compose.yml +28 -0
- data/spec/fixtures/rails6_users_app/features/api_users.feature +13 -0
- data/spec/fixtures/rails6_users_app/features/support/env.rb +4 -0
- data/spec/fixtures/rails6_users_app/features/support/hooks.rb +11 -0
- data/spec/fixtures/rails6_users_app/features/support/steps.rb +18 -0
- data/spec/fixtures/rails6_users_app/lib/tasks/.keep +0 -0
- data/spec/fixtures/rails6_users_app/log/.keep +0 -0
- data/spec/fixtures/rails6_users_app/public/robots.txt +1 -0
- data/spec/fixtures/rails6_users_app/spec/controllers/users_controller_api_spec.rb +29 -0
- data/spec/fixtures/rails6_users_app/spec/models/user_spec.rb +39 -0
- data/spec/fixtures/rails6_users_app/spec/rails_helper.rb +66 -0
- data/spec/fixtures/rails6_users_app/spec/spec_helper.rb +96 -0
- data/spec/fixtures/rails6_users_app/users_app/.gitignore +20 -0
- data/spec/hook_spec.rb +196 -11
- data/spec/rails_spec_helper.rb +5 -5
- data/spec/railtie_spec.rb +31 -32
- data/spec/record_sql_rails4_pg_spec.rb +47 -48
- data/spec/record_sql_rails_pg_spec.rb +62 -63
- data/spec/remote_recording_spec.rb +90 -89
- data/spec/rspec_feature_metadata_spec.rb +17 -18
- data/test/cli_test.rb +0 -10
- data/test/expectations/openssl_test_key_sign1.json +55 -0
- data/test/expectations/openssl_test_key_sign2.json +58 -0
- data/test/fixtures/gem_test/Gemfile +6 -0
- data/test/fixtures/gem_test/appmap.yml +3 -0
- data/test/fixtures/gem_test/test/to_param_test.rb +14 -0
- data/test/gem_test.rb +34 -0
- data/test/minitest_test.rb +2 -2
- data/test/openssl_test.rb +10 -165
- metadata +171 -80
@@ -3,30 +3,29 @@
|
|
3
3
|
require 'rails_spec_helper'
|
4
4
|
|
5
5
|
describe 'RSpec feature and feature group metadata' do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
cmd = "docker-compose run --rm -e APPMAP=true -v #{File.absolute_path(tmpdir).shellescape}:/app/tmp app ./bin/rspec spec/models/user_spec.rb"
|
13
|
-
run_cmd cmd, chdir: @fixture_dir
|
6
|
+
include_examples 'Rails app pg database', 'spec/fixtures/rails5_users_app' do
|
7
|
+
around(:each) do |example|
|
8
|
+
FileUtils.rm_rf tmpdir
|
9
|
+
FileUtils.mkdir_p tmpdir
|
10
|
+
cmd = "docker-compose run --rm -e APPMAP=true -v #{File.absolute_path(tmpdir).shellescape}:/app/tmp app ./bin/rspec spec/models/user_spec.rb"
|
11
|
+
run_cmd cmd, chdir: fixture_dir
|
14
12
|
|
15
|
-
|
16
|
-
|
13
|
+
example.run
|
14
|
+
end
|
17
15
|
|
18
|
-
|
19
|
-
|
16
|
+
let(:tmpdir) { 'tmp/spec/RSpec feature and feature group metadata' }
|
17
|
+
let(:appmap_json) { File.join(tmpdir, %(appmap/rspec/User_creation_creates_charles.appmap.json)) }
|
20
18
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
describe do
|
20
|
+
it 'are recorded in the appmap' do
|
21
|
+
expect(File).to exist(appmap_json)
|
22
|
+
appmap = JSON.parse(File.read(appmap_json)).to_yaml
|
25
23
|
|
26
|
-
|
24
|
+
expect(appmap).to include(<<-METADATA.strip)
|
27
25
|
feature: Create a user
|
28
26
|
feature_group: User
|
29
|
-
|
27
|
+
METADATA
|
28
|
+
end
|
30
29
|
end
|
31
30
|
end
|
32
31
|
end
|
data/test/cli_test.rb
CHANGED
@@ -56,12 +56,10 @@ class CLITest < Minitest::Test
|
|
56
56
|
Class frequency:
|
57
57
|
----------------
|
58
58
|
1 Main
|
59
|
-
1 IO
|
60
59
|
|
61
60
|
Method frequency:
|
62
61
|
----------------
|
63
62
|
1 Main.say_hello
|
64
|
-
1 IO#write
|
65
63
|
OUTPUT
|
66
64
|
end
|
67
65
|
|
@@ -82,20 +80,12 @@ class CLITest < Minitest::Test
|
|
82
80
|
{
|
83
81
|
"name": "Main",
|
84
82
|
"count": 1
|
85
|
-
},
|
86
|
-
{
|
87
|
-
"name": "IO",
|
88
|
-
"count": 1
|
89
83
|
}
|
90
84
|
],
|
91
85
|
"method_frequency": [
|
92
86
|
{
|
93
87
|
"name": "Main.say_hello",
|
94
88
|
"count": 1
|
95
|
-
},
|
96
|
-
{
|
97
|
-
"name": "IO#write",
|
98
|
-
"count": 1
|
99
89
|
}
|
100
90
|
]
|
101
91
|
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"name": "lib",
|
4
|
+
"type": "package",
|
5
|
+
"children": [
|
6
|
+
{
|
7
|
+
"name": "Example",
|
8
|
+
"type": "class",
|
9
|
+
"children": [
|
10
|
+
{
|
11
|
+
"name": "sign",
|
12
|
+
"type": "function",
|
13
|
+
"location": "lib/openssl_key_sign.rb:10",
|
14
|
+
"static": true,
|
15
|
+
"source": " def Example.sign\n key = OpenSSL::PKey::RSA.new 2048\n\n document = 'the document'\n\n digest = OpenSSL::Digest::SHA256.new\n key.sign digest, document\n end\n"
|
16
|
+
}
|
17
|
+
]
|
18
|
+
}
|
19
|
+
]
|
20
|
+
},
|
21
|
+
{
|
22
|
+
"name": "openssl",
|
23
|
+
"type": "package",
|
24
|
+
"children": [
|
25
|
+
{
|
26
|
+
"name": "OpenSSL",
|
27
|
+
"type": "class",
|
28
|
+
"children": [
|
29
|
+
{
|
30
|
+
"name": "PKey",
|
31
|
+
"type": "class",
|
32
|
+
"children": [
|
33
|
+
{
|
34
|
+
"name": "PKey",
|
35
|
+
"type": "class",
|
36
|
+
"children": [
|
37
|
+
{
|
38
|
+
"name": "sign",
|
39
|
+
"type": "function",
|
40
|
+
"location": "OpenSSL::PKey::PKey#sign",
|
41
|
+
"static": false,
|
42
|
+
"labels": [
|
43
|
+
"security",
|
44
|
+
"crypto"
|
45
|
+
]
|
46
|
+
}
|
47
|
+
]
|
48
|
+
}
|
49
|
+
]
|
50
|
+
}
|
51
|
+
]
|
52
|
+
}
|
53
|
+
]
|
54
|
+
}
|
55
|
+
]
|
@@ -0,0 +1,58 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"id": 1,
|
4
|
+
"event": "call",
|
5
|
+
"defined_class": "Example",
|
6
|
+
"method_id": "sign",
|
7
|
+
"path": "lib/openssl_key_sign.rb",
|
8
|
+
"lineno": 10,
|
9
|
+
"static": true,
|
10
|
+
"parameters": [
|
11
|
+
|
12
|
+
],
|
13
|
+
"receiver": {
|
14
|
+
"class": "Module"
|
15
|
+
}
|
16
|
+
},
|
17
|
+
{
|
18
|
+
"id": 2,
|
19
|
+
"event": "call",
|
20
|
+
"defined_class": "OpenSSL::PKey::PKey",
|
21
|
+
"method_id": "sign",
|
22
|
+
"path": "OpenSSL::PKey::PKey#sign",
|
23
|
+
"static": false,
|
24
|
+
"parameters": [
|
25
|
+
{
|
26
|
+
"name": "arg",
|
27
|
+
"class": "OpenSSL::Digest::SHA256",
|
28
|
+
"value": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
29
|
+
"kind": "req"
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"name": "arg",
|
33
|
+
"class": "String",
|
34
|
+
"value": "the document",
|
35
|
+
"kind": "req"
|
36
|
+
}
|
37
|
+
],
|
38
|
+
"receiver": {
|
39
|
+
"class": "OpenSSL::PKey::RSA"
|
40
|
+
}
|
41
|
+
},
|
42
|
+
{
|
43
|
+
"id": 3,
|
44
|
+
"event": "return",
|
45
|
+
"parent_id": 2,
|
46
|
+
"return_value": {
|
47
|
+
"class": "String"
|
48
|
+
}
|
49
|
+
},
|
50
|
+
{
|
51
|
+
"id": 4,
|
52
|
+
"event": "return",
|
53
|
+
"parent_id": 1,
|
54
|
+
"return_value": {
|
55
|
+
"class": "String"
|
56
|
+
}
|
57
|
+
}
|
58
|
+
]
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'appmap/minitest'
|
5
|
+
require 'minitest/autorun'
|
6
|
+
require 'active_support'
|
7
|
+
require 'active_support/core_ext'
|
8
|
+
|
9
|
+
class ToParamTest < ::Minitest::Test
|
10
|
+
def test_to_param
|
11
|
+
# record use of a core extension
|
12
|
+
assert_equal 'my+id', 'my+id'.to_param
|
13
|
+
end
|
14
|
+
end
|
data/test/gem_test.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'test_helper'
|
5
|
+
require 'English'
|
6
|
+
|
7
|
+
class MinitestTest < Minitest::Test
|
8
|
+
def perform_gem_test(test_name)
|
9
|
+
Bundler.with_clean_env do
|
10
|
+
Dir.chdir 'test/fixtures/gem_test' do
|
11
|
+
FileUtils.rm_rf 'tmp'
|
12
|
+
system 'bundle config --local local.appmap ../../..'
|
13
|
+
system 'bundle'
|
14
|
+
system({ 'APPMAP' => 'true' }, %(bundle exec ruby -Ilib -Itest test/#{test_name}_test.rb))
|
15
|
+
|
16
|
+
yield
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_record_gem
|
22
|
+
perform_gem_test 'to_param' do
|
23
|
+
appmap_file = 'tmp/appmap/minitest/To_param_to_param.appmap.json'
|
24
|
+
appmap = JSON.parse(File.read(appmap_file))
|
25
|
+
events = appmap['events']
|
26
|
+
assert_equal 2, events.size
|
27
|
+
assert_equal 'call', events.first['event']
|
28
|
+
assert_equal 'to_param', events.first['method_id']
|
29
|
+
assert_equal "#{Gem.loaded_specs['activesupport'].gem_dir}/lib/active_support/core_ext/object/to_query.rb", events.first['path']
|
30
|
+
assert_equal 'return', events.second['event']
|
31
|
+
assert_equal 1, events.second['parent_id']
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/test/minitest_test.rb
CHANGED
@@ -5,7 +5,7 @@ require 'test_helper'
|
|
5
5
|
require 'English'
|
6
6
|
|
7
7
|
class MinitestTest < Minitest::Test
|
8
|
-
def
|
8
|
+
def perform_minitest_test(test_name)
|
9
9
|
Bundler.with_clean_env do
|
10
10
|
Dir.chdir 'test/fixtures/minitest_recorder' do
|
11
11
|
FileUtils.rm_rf 'tmp'
|
@@ -19,7 +19,7 @@ class MinitestTest < Minitest::Test
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def test_hello
|
22
|
-
|
22
|
+
perform_minitest_test 'hello' do
|
23
23
|
appmap_file = 'tmp/appmap/minitest/Hello_hello.appmap.json'
|
24
24
|
|
25
25
|
assert File.file?(appmap_file), 'appmap output file does not exist'
|
data/test/openssl_test.rb
CHANGED
@@ -11,13 +11,17 @@ class OpenSSLTest < Minitest::Test
|
|
11
11
|
FileUtils.rm_rf 'tmp'
|
12
12
|
system 'bundle config --local local.appmap ../../..'
|
13
13
|
system 'bundle'
|
14
|
-
system({ 'APPMAP' => 'true'
|
14
|
+
system({ 'APPMAP' => 'true' }, %(bundle exec ruby lib/openssl_#{test_name}.rb))
|
15
15
|
|
16
16
|
yield
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
def expectation(name)
|
22
|
+
File.read File.join __dir__, 'expectations', name
|
23
|
+
end
|
24
|
+
|
21
25
|
def test_key_sign
|
22
26
|
perform_test 'key_sign' do
|
23
27
|
appmap_file = 'appmap.json'
|
@@ -26,83 +30,7 @@ class OpenSSLTest < Minitest::Test
|
|
26
30
|
appmap = JSON.parse(File.read(appmap_file))
|
27
31
|
assert_equal AppMap::APPMAP_FORMAT_VERSION, appmap['version']
|
28
32
|
assert_equal [ { 'recorder' => 'lib/openssl_key_sign.rb' } ], appmap['metadata']
|
29
|
-
assert_equal JSON.parse(
|
30
|
-
[
|
31
|
-
{
|
32
|
-
"name": "lib",
|
33
|
-
"type": "package",
|
34
|
-
"children": [
|
35
|
-
{
|
36
|
-
"name": "Example",
|
37
|
-
"type": "class",
|
38
|
-
"children": [
|
39
|
-
{
|
40
|
-
"name": "sign",
|
41
|
-
"type": "function",
|
42
|
-
"location": "lib/openssl_key_sign.rb:10",
|
43
|
-
"static": true
|
44
|
-
}
|
45
|
-
]
|
46
|
-
}
|
47
|
-
]
|
48
|
-
},
|
49
|
-
{
|
50
|
-
"name": "openssl",
|
51
|
-
"type": "package",
|
52
|
-
"children": [
|
53
|
-
{
|
54
|
-
"name": "OpenSSL",
|
55
|
-
"type": "class",
|
56
|
-
"children": [
|
57
|
-
{
|
58
|
-
"name": "PKey",
|
59
|
-
"type": "class",
|
60
|
-
"children": [
|
61
|
-
{
|
62
|
-
"name": "PKey",
|
63
|
-
"type": "class",
|
64
|
-
"children": [
|
65
|
-
{
|
66
|
-
"name": "sign",
|
67
|
-
"type": "function",
|
68
|
-
"location": "OpenSSL::PKey::PKey#sign",
|
69
|
-
"static": false,
|
70
|
-
"labels": [
|
71
|
-
"security",
|
72
|
-
"crypto"
|
73
|
-
]
|
74
|
-
}
|
75
|
-
]
|
76
|
-
}
|
77
|
-
]
|
78
|
-
}
|
79
|
-
]
|
80
|
-
}
|
81
|
-
]
|
82
|
-
},
|
83
|
-
{
|
84
|
-
"name": "io",
|
85
|
-
"type": "package",
|
86
|
-
"children": [
|
87
|
-
{
|
88
|
-
"name": "IO",
|
89
|
-
"type": "class",
|
90
|
-
"children": [
|
91
|
-
{
|
92
|
-
"name": "write",
|
93
|
-
"type": "function",
|
94
|
-
"location": "IO#write",
|
95
|
-
"static": false,
|
96
|
-
"labels": [
|
97
|
-
"io"
|
98
|
-
]
|
99
|
-
}
|
100
|
-
]
|
101
|
-
}
|
102
|
-
]
|
103
|
-
}
|
104
|
-
]
|
105
|
-
JSON
|
33
|
+
assert_equal JSON.parse(expectation('openssl_test_key_sign1.json')), appmap['classMap']
|
106
34
|
sanitized_events = appmap['events'].map(&:deep_symbolize_keys).map(&AppMap::Util.method(:sanitize_event)).map do |event|
|
107
35
|
delete_value = ->(obj) { (obj || {}).delete(:value) }
|
108
36
|
delete_value.call(event[:receiver])
|
@@ -110,93 +38,10 @@ class OpenSSLTest < Minitest::Test
|
|
110
38
|
event
|
111
39
|
end
|
112
40
|
|
113
|
-
diff = Diffy::Diff.new(
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
"event": "call",
|
118
|
-
"defined_class": "Example",
|
119
|
-
"method_id": "sign",
|
120
|
-
"path": "lib/openssl_key_sign.rb",
|
121
|
-
"lineno": 10,
|
122
|
-
"static": true,
|
123
|
-
"parameters": [
|
124
|
-
|
125
|
-
],
|
126
|
-
"receiver": {
|
127
|
-
"class": "Module"
|
128
|
-
}
|
129
|
-
},
|
130
|
-
{
|
131
|
-
"id": 2,
|
132
|
-
"event": "call",
|
133
|
-
"defined_class": "OpenSSL::PKey::PKey",
|
134
|
-
"method_id": "sign",
|
135
|
-
"path": "OpenSSL::PKey::PKey#sign",
|
136
|
-
"static": false,
|
137
|
-
"parameters": [
|
138
|
-
{
|
139
|
-
"name": "arg",
|
140
|
-
"class": "OpenSSL::Digest::SHA256",
|
141
|
-
"value": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
142
|
-
"kind": "req"
|
143
|
-
},
|
144
|
-
{
|
145
|
-
"name": "arg",
|
146
|
-
"class": "String",
|
147
|
-
"value": "the document",
|
148
|
-
"kind": "req"
|
149
|
-
}
|
150
|
-
],
|
151
|
-
"receiver": {
|
152
|
-
"class": "OpenSSL::PKey::RSA"
|
153
|
-
}
|
154
|
-
},
|
155
|
-
{
|
156
|
-
"id": 3,
|
157
|
-
"event": "return",
|
158
|
-
"parent_id": 2,
|
159
|
-
"return_value": {
|
160
|
-
"class": "String"
|
161
|
-
}
|
162
|
-
},
|
163
|
-
{
|
164
|
-
"id": 4,
|
165
|
-
"event": "return",
|
166
|
-
"parent_id": 1,
|
167
|
-
"return_value": {
|
168
|
-
"class": "String"
|
169
|
-
}
|
170
|
-
},
|
171
|
-
{
|
172
|
-
"id": 5,
|
173
|
-
"event": "call",
|
174
|
-
"defined_class": "IO",
|
175
|
-
"method_id": "write",
|
176
|
-
"path": "IO#write",
|
177
|
-
"static": false,
|
178
|
-
"parameters": [
|
179
|
-
{
|
180
|
-
"name": "arg",
|
181
|
-
"class": "String",
|
182
|
-
"value": "Computed signature",
|
183
|
-
"kind": "rest"
|
184
|
-
}
|
185
|
-
],
|
186
|
-
"receiver": {
|
187
|
-
"class": "IO"
|
188
|
-
}
|
189
|
-
},
|
190
|
-
{
|
191
|
-
"id": 6,
|
192
|
-
"event": "return",
|
193
|
-
"parent_id": 5,
|
194
|
-
"return_value": {
|
195
|
-
"class": "Integer"
|
196
|
-
}
|
197
|
-
}
|
198
|
-
]
|
199
|
-
JSON
|
41
|
+
diff = Diffy::Diff.new(
|
42
|
+
expectation('openssl_test_key_sign2.json').strip,
|
43
|
+
JSON.pretty_generate(sanitized_events).strip
|
44
|
+
)
|
200
45
|
assert_equal '', diff.to_s
|
201
46
|
end
|
202
47
|
end
|