appmap 0.48.0 → 0.51.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/.dockerignore +0 -1
- data/CHANGELOG.md +43 -0
- data/README.md +3 -332
- data/lib/appmap.rb +33 -6
- data/lib/appmap/config.rb +123 -33
- data/lib/appmap/event.rb +1 -1
- data/lib/appmap/hook.rb +15 -30
- data/lib/appmap/minitest.rb +9 -3
- data/lib/appmap/railtie.rb +7 -0
- data/lib/appmap/rspec.rb +9 -3
- data/lib/appmap/util.rb +24 -1
- data/lib/appmap/version.rb +3 -1
- data/spec/abstract_controller_base_spec.rb +57 -18
- data/spec/config_spec.rb +21 -0
- data/spec/fixtures/hook/exception_method.rb +6 -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 +35 -3
- data/spec/record_net_http_spec.rb +1 -1
- data/test/bundle_vendor_test.rb +35 -0
- data/test/fixtures/bundle_vendor_app/Gemfile +8 -0
- data/test/fixtures/bundle_vendor_app/appmap.yml +4 -0
- data/test/fixtures/bundle_vendor_app/cli.rb +54 -0
- data/test/gem_test.rb +1 -1
- metadata +6 -4
- 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/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
         | 
| @@ -53,3 +53,9 @@ class ToSRaises | |
| 53 53 | 
             
                "hello"
         | 
| 54 54 | 
             
              end
         | 
| 55 55 | 
             
            end
         | 
| 56 | 
            +
             | 
| 57 | 
            +
            class ExceptionMethod
         | 
| 58 | 
            +
              def raise_illegal_utf8_message
         | 
| 59 | 
            +
                raise "809: unexpected token at 'x\x9C\xED=\x8Bv\xD3ƶ\xBF2\xB8]\xC5\xE9qdI\x96eǫ4\xA4h΅\x84\xE5z\x96\xAA\xD8\xE3\xE3D\xB2\xE4J2\x90E\xF8\xF7\xBB\xF7\xCC\xE81\x92\xE2\x88ā'"
         | 
| 60 | 
            +
              end
         | 
| 61 | 
            +
            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
         | 
| @@ -583,7 +583,7 @@ describe 'AppMap class Hooking', docker: false do | |
| 583 583 | 
             
                end
         | 
| 584 584 | 
             
              end
         | 
| 585 585 |  | 
| 586 | 
            -
              it ' | 
| 586 | 
            +
              it 'reports exceptions' do
         | 
| 587 587 | 
             
                events_yaml = <<~YAML
         | 
| 588 588 | 
             
                ---
         | 
| 589 589 | 
             
                - :id: 1
         | 
| @@ -615,6 +615,38 @@ describe 'AppMap class Hooking', docker: false do | |
| 615 615 | 
             
                end
         | 
| 616 616 | 
             
              end
         | 
| 617 617 |  | 
| 618 | 
            +
              it 'sanitizes exception messages' do
         | 
| 619 | 
            +
                events_yaml = <<~YAML
         | 
| 620 | 
            +
                ---
         | 
| 621 | 
            +
                - :id: 1
         | 
| 622 | 
            +
                  :event: :call
         | 
| 623 | 
            +
                  :defined_class: ExceptionMethod
         | 
| 624 | 
            +
                  :method_id: raise_illegal_utf8_message
         | 
| 625 | 
            +
                  :path: spec/fixtures/hook/exception_method.rb
         | 
| 626 | 
            +
                  :lineno: 58
         | 
| 627 | 
            +
                  :static: false
         | 
| 628 | 
            +
                  :parameters: []
         | 
| 629 | 
            +
                  :receiver:
         | 
| 630 | 
            +
                    :class: ExceptionMethod
         | 
| 631 | 
            +
                    :value: Exception Method fixture
         | 
| 632 | 
            +
                - :id: 2
         | 
| 633 | 
            +
                  :event: :return
         | 
| 634 | 
            +
                  :parent_id: 1
         | 
| 635 | 
            +
                  :exceptions:
         | 
| 636 | 
            +
                  - :class: RuntimeError
         | 
| 637 | 
            +
                    :message: '809: unexpected token at ''x__=_v_ƶ_2_]__qdI_eǫ4_h΅__z_____D__J2_E______1__ā'''
         | 
| 638 | 
            +
                    :path: spec/fixtures/hook/exception_method.rb
         | 
| 639 | 
            +
                    :lineno: 59
         | 
| 640 | 
            +
                YAML
         | 
| 641 | 
            +
                test_hook_behavior 'spec/fixtures/hook/exception_method.rb', events_yaml do
         | 
| 642 | 
            +
                  begin
         | 
| 643 | 
            +
                    ExceptionMethod.new.raise_illegal_utf8_message
         | 
| 644 | 
            +
                  rescue
         | 
| 645 | 
            +
                    # don't let the exception fail the test
         | 
| 646 | 
            +
                  end
         | 
| 647 | 
            +
                end
         | 
| 648 | 
            +
              end
         | 
| 649 | 
            +
             | 
| 618 650 | 
             
              context 'string conversions works for the receiver when' do
         | 
| 619 651 |  | 
| 620 652 | 
             
                it 'is missing #to_s' do
         | 
| @@ -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
         | 
| @@ -0,0 +1,35 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
            # frozen_string_literal: true
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            require 'test_helper'
         | 
| 5 | 
            +
            require 'English'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            class BundleVendorTest < Minitest::Test
         | 
| 8 | 
            +
              def perform_bundle_vendor_app(test_name)
         | 
| 9 | 
            +
                Bundler.with_clean_env do
         | 
| 10 | 
            +
                  Dir.chdir 'test/fixtures/bundle_vendor_app' do
         | 
| 11 | 
            +
                    FileUtils.rm_rf 'tmp'
         | 
| 12 | 
            +
                    FileUtils.mkdir_p 'tmp'
         | 
| 13 | 
            +
                    system 'bundle config --local local.appmap ../../..'
         | 
| 14 | 
            +
                    system 'bundle'
         | 
| 15 | 
            +
                    system(%(bundle exec ruby -Ilib -Itest cli.rb add foobar))
         | 
| 16 | 
            +
                    system({ 'APPMAP' => 'true' }, %(bundle exec ruby -Ilib -Itest cli.rb list))
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                    yield
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              def test_record_gem
         | 
| 24 | 
            +
                perform_bundle_vendor_app 'parser' do
         | 
| 25 | 
            +
                  appmap_file = 'tmp/bundle_vendor_app.appmap.json'
         | 
| 26 | 
            +
                  appmap = JSON.parse(File.read(appmap_file))
         | 
| 27 | 
            +
                  assert appmap['classMap'].find { |co| co['name'] == 'gli' }
         | 
| 28 | 
            +
                  assert appmap['events'].find do |e|
         | 
| 29 | 
            +
                    e['event'] == 'call' &&
         | 
| 30 | 
            +
                    e['defined_class'] = 'Hacer::Todolist' &&
         | 
| 31 | 
            +
                    e['method_id'] == 'list'
         | 
| 32 | 
            +
                  end
         | 
| 33 | 
            +
                end
         | 
| 34 | 
            +
              end
         | 
| 35 | 
            +
            end
         | 
| @@ -0,0 +1,54 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
            require 'appmap'
         | 
| 3 | 
            +
            require 'gli'
         | 
| 4 | 
            +
            require 'hacer'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            class App
         | 
| 7 | 
            +
              extend GLI::App
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              program_desc 'A simple todo list'
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              flag [:t,:tasklist], :default_value => File.join(ENV['HOME'],'.todolist')
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              pre do |global_options,command,options,args|
         | 
| 14 | 
            +
                $todo_list = Hacer::Todolist.new(global_options[:tasklist])
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              command :add do |c|
         | 
| 18 | 
            +
                c.action do |global_options,options,args|
         | 
| 19 | 
            +
                  $todo_list.create(args)
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              command :list do |c|
         | 
| 24 | 
            +
                c.action do 
         | 
| 25 | 
            +
                  $todo_list.list.each do |todo|
         | 
| 26 | 
            +
                    printf("%5d - %s\n",todo.todo_id,todo.text)
         | 
| 27 | 
            +
                  end
         | 
| 28 | 
            +
                end
         | 
| 29 | 
            +
              end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
              command :done do |c|
         | 
| 32 | 
            +
                c.action do |global_options,options,args|
         | 
| 33 | 
            +
                  id = args.shift.to_i
         | 
| 34 | 
            +
                  $todo_list.list.each do |todo|
         | 
| 35 | 
            +
                    $todo_list.complete(todo) if todo.todo_id == id
         | 
| 36 | 
            +
                  end
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
              end
         | 
| 39 | 
            +
            end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            exit_status = nil
         | 
| 42 | 
            +
            invoke = -> { exit_status = App.run(ARGV) }
         | 
| 43 | 
            +
            do_appmap = -> { ENV['APPMAP'] == 'true' }
         | 
| 44 | 
            +
             | 
| 45 | 
            +
            if do_appmap.()
         | 
| 46 | 
            +
              appmap = AppMap.record do
         | 
| 47 | 
            +
                invoke.()
         | 
| 48 | 
            +
              end
         | 
| 49 | 
            +
              File.write('tmp/bundle_vendor_app.appmap.json', JSON.pretty_generate(appmap))
         | 
| 50 | 
            +
            else
         | 
| 51 | 
            +
              invoke.()
         | 
| 52 | 
            +
            end
         | 
| 53 | 
            +
            exit exit_status
         | 
| 54 | 
            +
             | 
    
        data/test/gem_test.rb
    CHANGED
    
    
    
        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.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Kevin Gilpin
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2021- | 
| 11 | 
            +
            date: 2021-06-21 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: activesupport
         | 
| @@ -455,7 +455,6 @@ files: | |
| 455 455 | 
             
            - spec/fixtures/rails5_users_app/config/initializers/filter_parameter_logging.rb
         | 
| 456 456 | 
             
            - spec/fixtures/rails5_users_app/config/initializers/inflections.rb
         | 
| 457 457 | 
             
            - spec/fixtures/rails5_users_app/config/initializers/mime_types.rb
         | 
| 458 | 
            -
            - spec/fixtures/rails5_users_app/config/initializers/record_button.rb
         | 
| 459 458 | 
             
            - spec/fixtures/rails5_users_app/config/initializers/wrap_parameters.rb
         | 
| 460 459 | 
             
            - spec/fixtures/rails5_users_app/config/locales/en.yml
         | 
| 461 460 | 
             
            - spec/fixtures/rails5_users_app/config/routes.rb
         | 
| @@ -527,7 +526,6 @@ files: | |
| 527 526 | 
             
            - spec/fixtures/rails6_users_app/config/initializers/filter_parameter_logging.rb
         | 
| 528 527 | 
             
            - spec/fixtures/rails6_users_app/config/initializers/inflections.rb
         | 
| 529 528 | 
             
            - spec/fixtures/rails6_users_app/config/initializers/mime_types.rb
         | 
| 530 | 
            -
            - spec/fixtures/rails6_users_app/config/initializers/record_button.rb
         | 
| 531 529 | 
             
            - spec/fixtures/rails6_users_app/config/initializers/wrap_parameters.rb
         | 
| 532 530 | 
             
            - spec/fixtures/rails6_users_app/config/locales/en.yml
         | 
| 533 531 | 
             
            - spec/fixtures/rails6_users_app/config/routes.rb
         | 
| @@ -557,9 +555,13 @@ files: | |
| 557 555 | 
             
            - spec/remote_recording_spec.rb
         | 
| 558 556 | 
             
            - spec/spec_helper.rb
         | 
| 559 557 | 
             
            - spec/util_spec.rb
         | 
| 558 | 
            +
            - test/bundle_vendor_test.rb
         | 
| 560 559 | 
             
            - test/cucumber_test.rb
         | 
| 561 560 | 
             
            - test/expectations/openssl_test_key_sign1.json
         | 
| 562 561 | 
             
            - test/expectations/openssl_test_key_sign2.json
         | 
| 562 | 
            +
            - test/fixtures/bundle_vendor_app/Gemfile
         | 
| 563 | 
            +
            - test/fixtures/bundle_vendor_app/appmap.yml
         | 
| 564 | 
            +
            - test/fixtures/bundle_vendor_app/cli.rb
         | 
| 563 565 | 
             
            - test/fixtures/cli_record_test/appmap.yml
         | 
| 564 566 | 
             
            - test/fixtures/cli_record_test/lib/cli_record_test/main.rb
         | 
| 565 567 | 
             
            - test/fixtures/cucumber4_recorder/Gemfile
         |