appmap 0.18.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.dockerignore +5 -0
- data/.gitignore +17 -0
- data/.rubocop.yml +18 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +100 -0
- data/Dockerfile.appmap +5 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +133 -0
- data/Rakefile +117 -0
- data/appmap.gemspec +41 -0
- data/appmap.yml +8 -0
- data/examples/install.rb +76 -0
- data/examples/mock_webapp/Gemfile +1 -0
- data/examples/mock_webapp/appmap.yml +2 -0
- data/examples/mock_webapp/exe/mock_webapp_request +12 -0
- data/examples/mock_webapp/lib/mock_webapp/controller.rb +23 -0
- data/examples/mock_webapp/lib/mock_webapp/request.rb +12 -0
- data/examples/mock_webapp/lib/mock_webapp/user.rb +18 -0
- data/exe/_appmap-record-self +49 -0
- data/exe/appmap +168 -0
- data/lib/appmap/algorithm/prune_class_map.rb +65 -0
- data/lib/appmap/command/inspect.rb +11 -0
- data/lib/appmap/command/record.rb +91 -0
- data/lib/appmap/command/upload.rb +103 -0
- data/lib/appmap/config/directory.rb +65 -0
- data/lib/appmap/config/file.rb +13 -0
- data/lib/appmap/config/named_function.rb +21 -0
- data/lib/appmap/config/package_dir.rb +52 -0
- data/lib/appmap/config/path.rb +25 -0
- data/lib/appmap/config.rb +65 -0
- data/lib/appmap/feature.rb +262 -0
- data/lib/appmap/inspect/inspector.rb +99 -0
- data/lib/appmap/inspect/parse_node.rb +170 -0
- data/lib/appmap/inspect/parser.rb +15 -0
- data/lib/appmap/inspect.rb +91 -0
- data/lib/appmap/middleware/remote_recording.rb +122 -0
- data/lib/appmap/parser.rb +60 -0
- data/lib/appmap/rails/action_handler.rb +77 -0
- data/lib/appmap/rails/sql_handler.rb +148 -0
- data/lib/appmap/railtie.rb +32 -0
- data/lib/appmap/rspec/parse_node.rb +41 -0
- data/lib/appmap/rspec/parser.rb +15 -0
- data/lib/appmap/rspec.rb +288 -0
- data/lib/appmap/trace/event_handler/rack_handler_webrick.rb +65 -0
- data/lib/appmap/trace/tracer.rb +347 -0
- data/lib/appmap/version.rb +5 -0
- data/lib/appmap.rb +26 -0
- data/lore/pages/2019-05-21-install-and-record/index.pug +51 -0
- data/lore/pages/2019-05-21-install-and-record/install_example_appmap.png +0 -0
- data/lore/pages/2019-05-21-install-and-record/metadata.yml +5 -0
- data/lore/pages/layout.pug +66 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap-grid.css +1912 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap-grid.css.map +1 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap-grid.min.css +7 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap-grid.min.css.map +1 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap-reboot.css +331 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap-reboot.css.map +1 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap-reboot.min.css +8 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap-reboot.min.css.map +1 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap.css +9030 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap.css.map +1 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap.min.css +7 -0
- data/lore/public/lib/bootstrap-4.1.3/css/bootstrap.min.css.map +1 -0
- data/lore/public/stylesheets/style.css +8 -0
- data/package-lock.json +1066 -0
- data/package.json +24 -0
- data/spec/abstract_controller4_base_spec.rb +58 -0
- data/spec/abstract_controller_base_spec.rb +59 -0
- data/spec/fixtures/rack_users_app/.dockerignore +2 -0
- data/spec/fixtures/rack_users_app/.gitignore +2 -0
- data/spec/fixtures/rack_users_app/Dockerfile +32 -0
- data/spec/fixtures/rack_users_app/Gemfile +10 -0
- data/spec/fixtures/rack_users_app/appmap.yml +3 -0
- data/spec/fixtures/rack_users_app/config.ru +2 -0
- data/spec/fixtures/rack_users_app/docker-compose.yml +9 -0
- data/spec/fixtures/rack_users_app/lib/app.rb +36 -0
- data/spec/fixtures/rails4_users_app/.gitignore +13 -0
- data/spec/fixtures/rails4_users_app/.rbenv-gemsets +2 -0
- data/spec/fixtures/rails4_users_app/.ruby-version +1 -0
- data/spec/fixtures/rails4_users_app/Dockerfile +30 -0
- data/spec/fixtures/rails4_users_app/Dockerfile.pg +3 -0
- data/spec/fixtures/rails4_users_app/Gemfile +77 -0
- data/spec/fixtures/rails4_users_app/README.rdoc +28 -0
- data/spec/fixtures/rails4_users_app/Rakefile +6 -0
- data/spec/fixtures/rails4_users_app/app/assets/images/.keep +0 -0
- data/spec/fixtures/rails4_users_app/app/assets/javascripts/application.js +16 -0
- data/spec/fixtures/rails4_users_app/app/assets/stylesheets/application.css +15 -0
- data/spec/fixtures/rails4_users_app/app/controllers/api/users_controller.rb +27 -0
- data/spec/fixtures/rails4_users_app/app/controllers/application_controller.rb +5 -0
- data/spec/fixtures/rails4_users_app/app/controllers/concerns/.keep +0 -0
- data/spec/fixtures/rails4_users_app/app/controllers/health_controller.rb +5 -0
- data/spec/fixtures/rails4_users_app/app/controllers/users_controller.rb +5 -0
- data/spec/fixtures/rails4_users_app/app/helpers/application_helper.rb +2 -0
- data/spec/fixtures/rails4_users_app/app/mailers/.keep +0 -0
- data/spec/fixtures/rails4_users_app/app/models/.keep +0 -0
- data/spec/fixtures/rails4_users_app/app/models/concerns/.keep +0 -0
- data/spec/fixtures/rails4_users_app/app/models/user.rb +18 -0
- data/spec/fixtures/rails4_users_app/app/views/layouts/application.html.haml +7 -0
- data/spec/fixtures/rails4_users_app/app/views/users/index.html.haml +7 -0
- data/spec/fixtures/rails4_users_app/appmap.yml +3 -0
- data/spec/fixtures/rails4_users_app/bin/rails +9 -0
- data/spec/fixtures/rails4_users_app/bin/setup +29 -0
- data/spec/fixtures/rails4_users_app/bin/spring +17 -0
- data/spec/fixtures/rails4_users_app/config/application.rb +26 -0
- data/spec/fixtures/rails4_users_app/config/boot.rb +3 -0
- data/spec/fixtures/rails4_users_app/config/database.yml +17 -0
- data/spec/fixtures/rails4_users_app/config/environment.rb +5 -0
- data/spec/fixtures/rails4_users_app/config/environments/development.rb +41 -0
- data/spec/fixtures/rails4_users_app/config/environments/production.rb +79 -0
- data/spec/fixtures/rails4_users_app/config/environments/test.rb +42 -0
- data/spec/fixtures/rails4_users_app/config/initializers/assets.rb +11 -0
- data/spec/fixtures/rails4_users_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/fixtures/rails4_users_app/config/initializers/cookies_serializer.rb +3 -0
- data/spec/fixtures/rails4_users_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/fixtures/rails4_users_app/config/initializers/inflections.rb +16 -0
- data/spec/fixtures/rails4_users_app/config/initializers/mime_types.rb +4 -0
- data/spec/fixtures/rails4_users_app/config/initializers/session_store.rb +3 -0
- data/spec/fixtures/rails4_users_app/config/initializers/to_time_preserves_timezone.rb +10 -0
- data/spec/fixtures/rails4_users_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/fixtures/rails4_users_app/config/locales/en.yml +23 -0
- data/spec/fixtures/rails4_users_app/config/routes.rb +12 -0
- data/spec/fixtures/rails4_users_app/config/secrets.yml +22 -0
- data/spec/fixtures/rails4_users_app/config.ru +4 -0
- data/spec/fixtures/rails4_users_app/create_app +23 -0
- data/spec/fixtures/rails4_users_app/db/migrate/20191127112304_create_users.rb +10 -0
- data/spec/fixtures/rails4_users_app/db/schema.rb +26 -0
- data/spec/fixtures/rails4_users_app/db/seeds.rb +7 -0
- data/spec/fixtures/rails4_users_app/docker-compose.yml +24 -0
- data/spec/fixtures/rails4_users_app/lib/assets/.keep +0 -0
- data/spec/fixtures/rails4_users_app/lib/tasks/.keep +0 -0
- data/spec/fixtures/rails4_users_app/log/.keep +0 -0
- data/spec/fixtures/rails4_users_app/public/404.html +67 -0
- data/spec/fixtures/rails4_users_app/public/422.html +67 -0
- data/spec/fixtures/rails4_users_app/public/500.html +66 -0
- data/spec/fixtures/rails4_users_app/public/favicon.ico +0 -0
- data/spec/fixtures/rails4_users_app/public/robots.txt +5 -0
- data/spec/fixtures/rails4_users_app/spec/controllers/users_controller_api_spec.rb +49 -0
- data/spec/fixtures/rails4_users_app/spec/rails_helper.rb +95 -0
- data/spec/fixtures/rails4_users_app/spec/spec_helper.rb +96 -0
- data/spec/fixtures/rails4_users_app/test/fixtures/users.yml +9 -0
- data/spec/fixtures/rails_users_app/.dockerignore +1 -0
- data/spec/fixtures/rails_users_app/.gitignore +39 -0
- data/spec/fixtures/rails_users_app/.rspec +1 -0
- data/spec/fixtures/rails_users_app/.ruby-version +1 -0
- data/spec/fixtures/rails_users_app/Dockerfile +29 -0
- data/spec/fixtures/rails_users_app/Dockerfile.pg +3 -0
- data/spec/fixtures/rails_users_app/Gemfile +51 -0
- data/spec/fixtures/rails_users_app/Rakefile +6 -0
- data/spec/fixtures/rails_users_app/app/controllers/api/users_controller.rb +27 -0
- data/spec/fixtures/rails_users_app/app/controllers/application_controller.rb +2 -0
- data/spec/fixtures/rails_users_app/app/controllers/concerns/.keep +0 -0
- data/spec/fixtures/rails_users_app/app/controllers/health_controller.rb +5 -0
- data/spec/fixtures/rails_users_app/app/controllers/users_controller.rb +5 -0
- data/spec/fixtures/rails_users_app/app/models/activerecord/user.rb +18 -0
- data/spec/fixtures/rails_users_app/app/models/concerns/.keep +0 -0
- data/spec/fixtures/rails_users_app/app/models/sequel/user.rb +25 -0
- data/spec/fixtures/rails_users_app/app/views/layouts/application.html.haml +7 -0
- data/spec/fixtures/rails_users_app/app/views/users/index.html.haml +7 -0
- data/spec/fixtures/rails_users_app/appmap.yml +3 -0
- data/spec/fixtures/rails_users_app/bin/_appmap-record-self +29 -0
- data/spec/fixtures/rails_users_app/bin/appmap +29 -0
- data/spec/fixtures/rails_users_app/bin/byebug +29 -0
- data/spec/fixtures/rails_users_app/bin/gli +29 -0
- data/spec/fixtures/rails_users_app/bin/htmldiff +29 -0
- data/spec/fixtures/rails_users_app/bin/ldiff +29 -0
- data/spec/fixtures/rails_users_app/bin/nokogiri +29 -0
- data/spec/fixtures/rails_users_app/bin/rackup +29 -0
- data/spec/fixtures/rails_users_app/bin/rails +4 -0
- data/spec/fixtures/rails_users_app/bin/rake +29 -0
- data/spec/fixtures/rails_users_app/bin/rspec +29 -0
- data/spec/fixtures/rails_users_app/bin/ruby-parse +29 -0
- data/spec/fixtures/rails_users_app/bin/ruby-rewrite +29 -0
- data/spec/fixtures/rails_users_app/bin/sequel +29 -0
- data/spec/fixtures/rails_users_app/bin/setup +25 -0
- data/spec/fixtures/rails_users_app/bin/sprockets +29 -0
- data/spec/fixtures/rails_users_app/bin/thor +29 -0
- data/spec/fixtures/rails_users_app/bin/update +25 -0
- data/spec/fixtures/rails_users_app/config/application.rb +51 -0
- data/spec/fixtures/rails_users_app/config/boot.rb +3 -0
- data/spec/fixtures/rails_users_app/config/credentials.yml.enc +1 -0
- data/spec/fixtures/rails_users_app/config/database.yml +17 -0
- data/spec/fixtures/rails_users_app/config/environment.rb +5 -0
- data/spec/fixtures/rails_users_app/config/environments/development.rb +40 -0
- data/spec/fixtures/rails_users_app/config/environments/production.rb +68 -0
- data/spec/fixtures/rails_users_app/config/environments/test.rb +36 -0
- data/spec/fixtures/rails_users_app/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/fixtures/rails_users_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/fixtures/rails_users_app/config/initializers/cors.rb +16 -0
- data/spec/fixtures/rails_users_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/fixtures/rails_users_app/config/initializers/inflections.rb +16 -0
- data/spec/fixtures/rails_users_app/config/initializers/mime_types.rb +4 -0
- data/spec/fixtures/rails_users_app/config/initializers/record_button.rb +3 -0
- data/spec/fixtures/rails_users_app/config/initializers/wrap_parameters.rb +9 -0
- data/spec/fixtures/rails_users_app/config/locales/en.yml +33 -0
- data/spec/fixtures/rails_users_app/config/routes.rb +11 -0
- data/spec/fixtures/rails_users_app/config.ru +5 -0
- data/spec/fixtures/rails_users_app/create_app +11 -0
- data/spec/fixtures/rails_users_app/db/migrate/20190728211408_create_users.rb +9 -0
- data/spec/fixtures/rails_users_app/db/schema.rb +23 -0
- data/spec/fixtures/rails_users_app/docker-compose.yml +24 -0
- data/spec/fixtures/rails_users_app/lib/tasks/.keep +0 -0
- data/spec/fixtures/rails_users_app/log/.keep +0 -0
- data/spec/fixtures/rails_users_app/public/robots.txt +1 -0
- data/spec/fixtures/rails_users_app/spec/controllers/users_controller_api_spec.rb +29 -0
- data/spec/fixtures/rails_users_app/spec/models/user_spec.rb +39 -0
- data/spec/fixtures/rails_users_app/spec/rails_helper.rb +66 -0
- data/spec/fixtures/rails_users_app/spec/spec_helper.rb +96 -0
- data/spec/fixtures/rails_users_app/users_app/.gitignore +20 -0
- data/spec/rack_handler_webrick_spec.rb +59 -0
- data/spec/rails_spec_helper.rb +34 -0
- data/spec/railtie_spec.rb +35 -0
- data/spec/record_sql_rails4_pg_spec.rb +76 -0
- data/spec/record_sql_rails_pg_spec.rb +68 -0
- data/spec/rspec_feature_metadata_spec.rb +30 -0
- data/spec/spec_helper.rb +6 -0
- data/test/cli_test.rb +81 -0
- data/test/config_test.rb +149 -0
- data/test/explict_inspect_test.rb +29 -0
- data/test/fixtures/active_record_like/active_record/aggregations.rb +4 -0
- data/test/fixtures/active_record_like/active_record/association.rb +4 -0
- data/test/fixtures/active_record_like/active_record/associations/join_dependency/join_base.rb +8 -0
- data/test/fixtures/active_record_like/active_record/associations/join_dependency/join_part.rb +8 -0
- data/test/fixtures/active_record_like/active_record/associations/join_dependency.rb +6 -0
- data/test/fixtures/active_record_like/active_record/caps/caps.rb +4 -0
- data/test/fixtures/active_record_like/active_record.rb +2 -0
- data/test/fixtures/cli_record_test/appmap.yml +2 -0
- data/test/fixtures/cli_record_test/lib/cli_record_test/main.rb +7 -0
- data/test/fixtures/ignore_non_ruby_file/class.rb +3 -0
- data/test/fixtures/ignore_non_ruby_file/non-ruby.txt +1 -0
- data/test/fixtures/includes_excludes/lib/a/a_1.rb +6 -0
- data/test/fixtures/includes_excludes/lib/a/a_2.rb +6 -0
- data/test/fixtures/includes_excludes/lib/a/x/x_1.rb +8 -0
- data/test/fixtures/includes_excludes/lib/b/b_1.rb +6 -0
- data/test/fixtures/includes_excludes/lib/root_1.rb +4 -0
- data/test/fixtures/inspect_multiple_subdirs/module_a/class_a.rb +5 -0
- data/test/fixtures/inspect_multiple_subdirs/module_a.rb +2 -0
- data/test/fixtures/inspect_multiple_subdirs/module_b/class_b.rb +5 -0
- data/test/fixtures/inspect_multiple_subdirs/module_b/class_c.rb +5 -0
- data/test/fixtures/inspect_multiple_subdirs/module_b.rb +2 -0
- data/test/fixtures/inspect_package/module_a/module_b/class_in_module.rb +6 -0
- data/test/fixtures/parse_file/defs_static_function.rb +96 -0
- data/test/fixtures/parse_file/function_within_class.rb +36 -0
- data/test/fixtures/parse_file/include_public_methods.rb +127 -0
- data/test/fixtures/parse_file/instance_function.rb +17 -0
- data/test/fixtures/parse_file/modules.rb +71 -0
- data/test/fixtures/parse_file/sclass_static_function.rb +88 -0
- data/test/fixtures/parse_file/toplevel_class.rb +13 -0
- data/test/fixtures/parse_file/toplevel_function.rb +14 -0
- data/test/fixtures/rspec_recorder/Gemfile +5 -0
- data/test/fixtures/rspec_recorder/appmap.yml +3 -0
- data/test/fixtures/rspec_recorder/lib/hello.rb +5 -0
- data/test/fixtures/rspec_recorder/spec/hello_spec.rb +9 -0
- data/test/fixtures/trace_test/trace_program_1.rb +44 -0
- data/test/implicit_inspect_test.rb +33 -0
- data/test/include_exclude_test.rb +48 -0
- data/test/prerecorded_trace_test.rb +76 -0
- data/test/rspec_test.rb +22 -0
- data/test/test_helper.rb +46 -0
- data/test/trace_test.rb +92 -0
- metadata +501 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rails_spec_helper'
|
2
|
+
|
3
|
+
describe 'RSpec feature and feature group metadata' do
|
4
|
+
before(:all) { @fixture_dir = 'spec/fixtures/rails_users_app' }
|
5
|
+
include_examples 'Rails app pg database'
|
6
|
+
|
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
|
+
system cmd, chdir: @fixture_dir or raise 'Failed to run rails_users_app container'
|
12
|
+
|
13
|
+
example.run
|
14
|
+
end
|
15
|
+
|
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)) }
|
18
|
+
|
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
|
23
|
+
|
24
|
+
expect(appmap).to include(<<-METADATA.strip)
|
25
|
+
feature: Create a user
|
26
|
+
feature_group: User
|
27
|
+
METADATA
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/test/cli_test.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'test_helper'
|
5
|
+
require 'English'
|
6
|
+
|
7
|
+
class CLITest < Minitest::Test
|
8
|
+
OUTPUT_FILENAME = File.expand_path('../tmp/appmap.json', __dir__)
|
9
|
+
|
10
|
+
def setup
|
11
|
+
FileUtils.rm_f OUTPUT_FILENAME
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_config_file_must_exist
|
15
|
+
output = `./exe/appmap -c foobar inspect 2>&1`
|
16
|
+
|
17
|
+
assert_equal 1, $CHILD_STATUS.exitstatus
|
18
|
+
assert_includes output, 'No such file or directory'
|
19
|
+
assert_includes output, 'foobar'
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_inspect_to_file
|
23
|
+
`./exe/appmap inspect -o #{OUTPUT_FILENAME}`
|
24
|
+
|
25
|
+
assert_equal 0, $CHILD_STATUS.exitstatus
|
26
|
+
assert File.file?(OUTPUT_FILENAME), "#{OUTPUT_FILENAME} does not exist"
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_inspect_to_stdout
|
30
|
+
output = `./exe/appmap inspect -o -`
|
31
|
+
|
32
|
+
assert !File.file?(OUTPUT_FILENAME), "#{OUTPUT_FILENAME} should not exist"
|
33
|
+
|
34
|
+
assert_equal 0, $CHILD_STATUS.exitstatus
|
35
|
+
assert !output.blank?, 'Output should exist in stdout'
|
36
|
+
JSON.parse(output)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_record
|
40
|
+
output = Dir.chdir 'test/fixtures/cli_record_test' do
|
41
|
+
`#{File.expand_path '../exe/appmap', __dir__} record -o #{OUTPUT_FILENAME} ./lib/cli_record_test/main.rb`.strip
|
42
|
+
end
|
43
|
+
|
44
|
+
assert_equal 0, $CHILD_STATUS.exitstatus
|
45
|
+
assert File.file?(OUTPUT_FILENAME), "#{OUTPUT_FILENAME} does not exist"
|
46
|
+
assert_equal 'Hello', output
|
47
|
+
output = JSON.parse(File.read(OUTPUT_FILENAME))
|
48
|
+
assert output['classMap'], 'Output should contain classMap'
|
49
|
+
assert output['events'], 'Output should contain events'
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_record_to_default_location
|
53
|
+
Dir.chdir 'test/fixtures/cli_record_test' do
|
54
|
+
system({ 'APPMAP_FILE' => OUTPUT_FILENAME }, "#{File.expand_path '../exe/appmap', __dir__} record ./lib/cli_record_test/main.rb")
|
55
|
+
end
|
56
|
+
|
57
|
+
assert_equal 0, $CHILD_STATUS.exitstatus
|
58
|
+
assert File.file?(OUTPUT_FILENAME), 'appmap.json does not exist'
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_record_to_stdout
|
62
|
+
output = Dir.chdir 'test/fixtures/cli_record_test' do
|
63
|
+
`#{File.expand_path '../exe/appmap', __dir__} record -o - ./lib/cli_record_test/main.rb`
|
64
|
+
end
|
65
|
+
|
66
|
+
assert_equal 0, $CHILD_STATUS.exitstatus
|
67
|
+
assert_includes output, %("location":"lib/cli_record_test")
|
68
|
+
assert !File.file?(OUTPUT_FILENAME), "#{OUTPUT_FILENAME} should not exist"
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_upload
|
72
|
+
`./exe/appmap inspect -o #{OUTPUT_FILENAME}`
|
73
|
+
|
74
|
+
upload_output = `./exe/appmap upload --no-open #{OUTPUT_FILENAME}`
|
75
|
+
assert_equal 0, $CHILD_STATUS.exitstatus
|
76
|
+
# Example: 93e1e07d-4b39-49ac-82bf-27d63e296cae
|
77
|
+
assert_match(/Scenario Id/, upload_output)
|
78
|
+
assert_match(/Batch Id/, upload_output)
|
79
|
+
assert_match(/[0-9a-f]+\-[0-9a-f\-]+/, upload_output)
|
80
|
+
end
|
81
|
+
end
|
data/test/config_test.rb
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'appmap/config'
|
3
|
+
require 'appmap/inspect'
|
4
|
+
|
5
|
+
class ConfigTest < Minitest::Test
|
6
|
+
include FixtureFile
|
7
|
+
|
8
|
+
def test_explicit_module_path_naming
|
9
|
+
config = AppMap::Config::PackageDir.new(INSPECT_PACKAGE_FIXTURE_DIR).tap do |c|
|
10
|
+
c.mode = :explicit
|
11
|
+
c.exclude = [ 'module_a/ignore_module_c' ]
|
12
|
+
end
|
13
|
+
feature = AppMap::Inspect.detect_features(config)
|
14
|
+
|
15
|
+
assert_equal %w[inspect_package module_a module_b], feature_names(feature)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_implicit_module_path_naming
|
19
|
+
config = AppMap::Config::PackageDir.new(INSPECT_PACKAGE_FIXTURE_DIR).tap do |c|
|
20
|
+
c.exclude = [ 'module_a/ignore_module_c' ]
|
21
|
+
end
|
22
|
+
feature = AppMap::Inspect.detect_features(config)
|
23
|
+
|
24
|
+
assert_equal %w[inspect_package module_a module_b A B Main], feature_names(feature)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_ignore_non_ruby_file
|
28
|
+
config = AppMap::Config::PackageDir.new(File.join(FIXTURE_DIR, 'ignore_non_ruby_file'))
|
29
|
+
feature = AppMap::Inspect.detect_features(config)
|
30
|
+
assert_equal %w[ignore_non_ruby_file Cls], feature_names(feature)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_inspect_multiple_subdirs
|
34
|
+
config_yaml = <<-YAML
|
35
|
+
packages:
|
36
|
+
- path: module_a
|
37
|
+
- path: module_b
|
38
|
+
named_functions: []
|
39
|
+
YAML
|
40
|
+
|
41
|
+
require 'yaml'
|
42
|
+
config = AppMap::Config.load YAML.safe_load(config_yaml)
|
43
|
+
features = Dir.chdir File.join(FIXTURE_DIR, 'inspect_multiple_subdirs') do
|
44
|
+
config.source_locations.map(&AppMap::Inspect.method(:detect_features))
|
45
|
+
end.flatten
|
46
|
+
features = features.map(&:reparent)
|
47
|
+
assert_equal %w[module_a ModuleA ClassA module_b ModuleB ClassB ClassC], features.map(&method(:feature_names)).flatten
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_active_record_like
|
51
|
+
config_yaml = <<-YAML
|
52
|
+
packages:
|
53
|
+
- path: .
|
54
|
+
name: ROOT
|
55
|
+
named_functions: []
|
56
|
+
YAML
|
57
|
+
|
58
|
+
require 'yaml'
|
59
|
+
config = AppMap::Config.load YAML.safe_load(config_yaml)
|
60
|
+
features = Dir.chdir File.join(FIXTURE_DIR, 'active_record_like') do
|
61
|
+
config.source_locations.map(&AppMap::Inspect.method(:detect_features))
|
62
|
+
end.flatten
|
63
|
+
features = features.map(&:reparent)
|
64
|
+
|
65
|
+
assert_equal <<-FEATURES.strip, JSON.pretty_generate(features)
|
66
|
+
[
|
67
|
+
{
|
68
|
+
"name": "ROOT",
|
69
|
+
"location": ".",
|
70
|
+
"type": "package",
|
71
|
+
"children": [
|
72
|
+
{
|
73
|
+
"name": "ActiveRecord",
|
74
|
+
"location": "./active_record.rb:1",
|
75
|
+
"type": "class",
|
76
|
+
"children": [
|
77
|
+
{
|
78
|
+
"name": "Aggregations",
|
79
|
+
"location": "./active_record/aggregations.rb:2",
|
80
|
+
"type": "class"
|
81
|
+
},
|
82
|
+
{
|
83
|
+
"name": "Associations",
|
84
|
+
"location": "./active_record/association.rb:2",
|
85
|
+
"type": "class",
|
86
|
+
"children": [
|
87
|
+
{
|
88
|
+
"name": "JoinDependency",
|
89
|
+
"location": "./active_record/associations/join_dependency.rb:3",
|
90
|
+
"type": "class",
|
91
|
+
"children": [
|
92
|
+
{
|
93
|
+
"name": "JoinBase",
|
94
|
+
"location": "./active_record/associations/join_dependency/join_base.rb:4",
|
95
|
+
"type": "class"
|
96
|
+
},
|
97
|
+
{
|
98
|
+
"name": "JoinPart",
|
99
|
+
"location": "./active_record/associations/join_dependency/join_part.rb:4",
|
100
|
+
"type": "class"
|
101
|
+
}
|
102
|
+
]
|
103
|
+
}
|
104
|
+
]
|
105
|
+
},
|
106
|
+
{
|
107
|
+
"name": "CAPS",
|
108
|
+
"location": "./active_record/caps/caps.rb:2",
|
109
|
+
"type": "class"
|
110
|
+
}
|
111
|
+
]
|
112
|
+
},
|
113
|
+
{
|
114
|
+
"name": "active_record",
|
115
|
+
"location": "./active_record",
|
116
|
+
"type": "package",
|
117
|
+
"children": [
|
118
|
+
{
|
119
|
+
"name": "associations",
|
120
|
+
"location": "./active_record/associations",
|
121
|
+
"type": "package",
|
122
|
+
"children": [
|
123
|
+
{
|
124
|
+
"name": "join_dependency",
|
125
|
+
"location": "./active_record/associations/join_dependency",
|
126
|
+
"type": "package"
|
127
|
+
}
|
128
|
+
]
|
129
|
+
},
|
130
|
+
{
|
131
|
+
"name": "caps",
|
132
|
+
"location": "./active_record/caps",
|
133
|
+
"type": "package"
|
134
|
+
}
|
135
|
+
]
|
136
|
+
}
|
137
|
+
]
|
138
|
+
}
|
139
|
+
]
|
140
|
+
FEATURES
|
141
|
+
end
|
142
|
+
|
143
|
+
def feature_names(feature, names = [])
|
144
|
+
names.tap do |_|
|
145
|
+
names << feature.name
|
146
|
+
feature.children.each { |child| feature_names(child, names) }
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ExplicitInspectTest < Minitest::Test
|
4
|
+
include FixtureFile
|
5
|
+
|
6
|
+
def test_toplevel_class
|
7
|
+
assert_fixture_features :explicit, 'toplevel_class.rb'
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_defs_static_function
|
11
|
+
assert_fixture_features :explicit, 'defs_static_function.rb'
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_sclass_static_function
|
15
|
+
assert_fixture_features :explicit, 'sclass_static_function.rb'
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_toplevel_function
|
19
|
+
assert_fixture_features :explicit, 'toplevel_function.rb'
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_function_within_class
|
23
|
+
assert_fixture_features :explicit, 'function_within_class.rb'
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_include_public_methods
|
27
|
+
assert_fixture_features :explicit, 'include_public_methods.rb'
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
This is not ruby.
|
@@ -0,0 +1,96 @@
|
|
1
|
+
class Main
|
2
|
+
# @appmap
|
3
|
+
def self.main_func; end
|
4
|
+
end
|
5
|
+
|
6
|
+
class Sub < Main
|
7
|
+
# @appmap
|
8
|
+
def self.sub_func; end
|
9
|
+
|
10
|
+
# @appmap
|
11
|
+
def Main.sub_func_2; end
|
12
|
+
|
13
|
+
# @appmap
|
14
|
+
def self.sub_func_3; end
|
15
|
+
|
16
|
+
protected
|
17
|
+
|
18
|
+
# TODO: ensure that this is ignored by implicit scan
|
19
|
+
def self.sub_func_protected; end
|
20
|
+
end
|
21
|
+
|
22
|
+
puts DATA.read
|
23
|
+
__END__
|
24
|
+
{
|
25
|
+
"explicit": [
|
26
|
+
{
|
27
|
+
"name": "main_func",
|
28
|
+
"location": "$FIXTURE_DIR/defs_static_function.rb:3",
|
29
|
+
"type": "function",
|
30
|
+
"class_name": "Main",
|
31
|
+
"static": true
|
32
|
+
},
|
33
|
+
{
|
34
|
+
"name": "sub_func",
|
35
|
+
"location": "$FIXTURE_DIR/defs_static_function.rb:8",
|
36
|
+
"type": "function",
|
37
|
+
"class_name": "Sub",
|
38
|
+
"static": true
|
39
|
+
},
|
40
|
+
{
|
41
|
+
"name": "sub_func_2",
|
42
|
+
"location": "$FIXTURE_DIR/defs_static_function.rb:11",
|
43
|
+
"type": "function",
|
44
|
+
"class_name": "Main",
|
45
|
+
"static": true
|
46
|
+
},
|
47
|
+
{
|
48
|
+
"name": "sub_func_3",
|
49
|
+
"location": "$FIXTURE_DIR/defs_static_function.rb:14",
|
50
|
+
"type": "function",
|
51
|
+
"class_name": "Sub",
|
52
|
+
"static": true
|
53
|
+
}
|
54
|
+
],
|
55
|
+
"implicit": [
|
56
|
+
{
|
57
|
+
"name": "Main",
|
58
|
+
"location": "$FIXTURE_DIR/defs_static_function.rb:1",
|
59
|
+
"type": "class",
|
60
|
+
"children": [
|
61
|
+
{
|
62
|
+
"name": "main_func",
|
63
|
+
"location": "$FIXTURE_DIR/defs_static_function.rb:3",
|
64
|
+
"type": "function",
|
65
|
+
"static": true
|
66
|
+
}
|
67
|
+
]
|
68
|
+
},
|
69
|
+
{
|
70
|
+
"name": "Sub",
|
71
|
+
"location": "$FIXTURE_DIR/defs_static_function.rb:6",
|
72
|
+
"type": "class",
|
73
|
+
"children": [
|
74
|
+
{
|
75
|
+
"name": "sub_func",
|
76
|
+
"location": "$FIXTURE_DIR/defs_static_function.rb:8",
|
77
|
+
"type": "function",
|
78
|
+
"static": true
|
79
|
+
},
|
80
|
+
{
|
81
|
+
"name": "sub_func_2",
|
82
|
+
"location": "$FIXTURE_DIR/defs_static_function.rb:11",
|
83
|
+
"type": "function",
|
84
|
+
"class_name": "Main",
|
85
|
+
"static": true
|
86
|
+
},
|
87
|
+
{
|
88
|
+
"name": "sub_func_3",
|
89
|
+
"location": "$FIXTURE_DIR/defs_static_function.rb:14",
|
90
|
+
"type": "function",
|
91
|
+
"static": true
|
92
|
+
}
|
93
|
+
]
|
94
|
+
}
|
95
|
+
]
|
96
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# @appmap
|
2
|
+
class Main
|
3
|
+
class << self
|
4
|
+
# @appmap
|
5
|
+
def sclass_function
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
# @appmap
|
10
|
+
def instance_function
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
puts DATA.read
|
15
|
+
__END__
|
16
|
+
[
|
17
|
+
{
|
18
|
+
"name": "Main",
|
19
|
+
"location": "$FIXTURE_DIR/function_within_class.rb:2",
|
20
|
+
"type": "class",
|
21
|
+
"children": [
|
22
|
+
{
|
23
|
+
"name": "sclass_function",
|
24
|
+
"location": "$FIXTURE_DIR/function_within_class.rb:5",
|
25
|
+
"type": "function",
|
26
|
+
"static": true
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"name": "instance_function",
|
30
|
+
"location": "$FIXTURE_DIR/function_within_class.rb:10",
|
31
|
+
"type": "function",
|
32
|
+
"static": false
|
33
|
+
}
|
34
|
+
]
|
35
|
+
}
|
36
|
+
]
|