appmap 0.59.1 → 0.61.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 63240e66f2942705bc89667ac6bdf7af49fc9e1c2225d4a6ffd243ad43ccbb80
4
- data.tar.gz: 7f0d20e3b75dee93c32cab9d99844528ba35aa2e4987ec649e3194a806b1de8e
3
+ metadata.gz: 8238a1a1651c5fb157b7603ff92169e3e44097318057eb3ef29d57d600817335
4
+ data.tar.gz: dd805a2bfa96ae3da4ea3bc47df524aa606e9b6dc69d943daa0a360f8da98ea5
5
5
  SHA512:
6
- metadata.gz: 5f3892093241092685b18ebd1f5f2a63e4f697c6099b32bd6cabfe2edba79448542ecc7c3080c69e4bdad8732805e69bd80b5bbc2c3b21a15f4085d3034520d1
7
- data.tar.gz: 8279d3bd2403bf28f255c7c985e90760e7700a865259865a89ec793cf5539a5caab7810b153a1bc9ca2b09c9654edd84db94c1535fdd155ea4d7181dfc914eef
6
+ metadata.gz: 41e1766995e26ebf75d33403c7b4d72e562b8d14202d3e34f094a276254f67e193b957ea1e26b8e0a561328ed7594fb1dce8cf554ee780df7155e276f7e04e5f
7
+ data.tar.gz: ba4c314bf9b07b377ea7e3714c082f9121bc082add10d04118e59c9cc0fd4ccdc9575159f6e6023bf0acf25a28cf8559f4d3a00f6942b1f0c17bdd7face0c2f1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,32 @@
1
+ ## [0.61.1](https://github.com/applandinc/appmap-ruby/compare/v0.61.0...v0.61.1) (2021-07-16)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add `DISABLE_SPRING` flag by default ([51ffd76](https://github.com/applandinc/appmap-ruby/commit/51ffd769558dd473f993889fe694c761779f5ef1))
7
+
8
+ # [0.61.0](https://github.com/applandinc/appmap-ruby/compare/v0.60.0...v0.61.0) (2021-07-14)
9
+
10
+
11
+ ### Features
12
+
13
+ * check if rails is present in `appmap-agent-validate` ([b584c2d](https://github.com/applandinc/appmap-ruby/commit/b584c2d9bb37f166932c0b91eed4db94fbafa8a7))
14
+
15
+ # [0.60.0](https://github.com/applandinc/appmap-ruby/compare/v0.59.2...v0.60.0) (2021-07-08)
16
+
17
+
18
+ ### Features
19
+
20
+ * add agent-setup-validate command ([d9b3bc1](https://github.com/applandinc/appmap-ruby/commit/d9b3bc15e01bf89994aa67b0256dd69b9983be76))
21
+ * validate ruby version (+ better config loading validation) ([1756e6c](https://github.com/applandinc/appmap-ruby/commit/1756e6c30b5c44a033c23eb47c27c56732d12470))
22
+
23
+ ## [0.59.2](https://github.com/applandinc/appmap-ruby/compare/v0.59.1...v0.59.2) (2021-07-08)
24
+
25
+
26
+ ### Bug Fixes
27
+
28
+ * Remove improper reliance on Rails 'try' ([c6b5b16](https://github.com/applandinc/appmap-ruby/commit/c6b5b16a6963988e20bab5f88b99401e25691f3c))
29
+
1
30
  ## [0.59.1](https://github.com/applandinc/appmap-ruby/compare/v0.59.0...v0.59.1) (2021-07-08)
2
31
 
3
32
 
data/config-schema.yml ADDED
@@ -0,0 +1,57 @@
1
+ type: object
2
+ additionalProperties: false
3
+ required:
4
+ - name
5
+ properties:
6
+ name:
7
+ type: string
8
+ packages:
9
+ type: array
10
+ items:
11
+ anyOf:
12
+ - type: object
13
+ additionalProperties: false
14
+ required:
15
+ - path
16
+ properties:
17
+ path:
18
+ type: string
19
+ shallow:
20
+ type: boolean
21
+ exclude:
22
+ type: array
23
+ items:
24
+ type: string
25
+ - type: object
26
+ additionalProperties: false
27
+ required:
28
+ - gem
29
+ properties:
30
+ gem:
31
+ type: string
32
+ shallow:
33
+ type: boolean
34
+ exclude:
35
+ type: array
36
+ items:
37
+ type: string
38
+ exclude:
39
+ type: array
40
+ items:
41
+ type: string
42
+ functions:
43
+ type: array
44
+ items:
45
+ type: object
46
+ additionalProperties: false
47
+ properties:
48
+ package:
49
+ type: string
50
+ class:
51
+ type: string
52
+ function:
53
+ type: string
54
+ labels:
55
+ type: array
56
+ items:
57
+ type: string
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'optparse'
5
+ require 'appmap'
6
+ require 'appmap/command/agent_setup/validate'
7
+
8
+ @options = { config_file: AppMap::DEFAULT_CONFIG_FILE_PATH }
9
+
10
+ OptionParser.new do |parser|
11
+ parser.banner = 'Usage: appmap-agent-validate [options]'
12
+
13
+ description = "AppMap configuration file path (default: #{AppMap::DEFAULT_CONFIG_FILE_PATH})"
14
+ parser.on('-c', '--config=FILEPATH', description) do |filepath|
15
+ @options[:config_file] = filepath
16
+ end
17
+ end.parse!
18
+
19
+ AppMap::Command::AgentSetup::Validate.new(@options[:config_file]).perform
@@ -24,7 +24,7 @@ module AppMap
24
24
  agentVersion: AppMap::VERSION,
25
25
  language: 'ruby',
26
26
  remoteRecordingCapable: Gem.loaded_specs.has_key?('rails'),
27
- integrationTests: Service::IntegrationTestPathFinder.count_paths > 0
27
+ integrationTests: Service::IntegrationTestPathFinder.new.count_paths > 0
28
28
  }
29
29
  }
30
30
  }
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+ require 'appmap/service/validator/config_validator'
5
+
6
+ module AppMap
7
+ module Command
8
+ module AgentSetup
9
+ ValidateStruct = Struct.new(:config_file)
10
+
11
+ class Validate < ValidateStruct
12
+ def perform
13
+ puts JSON.pretty_generate(config_validator.valid? ? [] : config_validator.violations.map(&:to_h))
14
+ end
15
+
16
+ private
17
+
18
+ def config_validator
19
+ @validator ||= Service::Validator::ConfigValidator.new(config_file)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
data/lib/appmap/event.rb CHANGED
@@ -248,7 +248,7 @@ module AppMap
248
248
  next_exception = exception
249
249
  exceptions = []
250
250
  while next_exception
251
- exception_backtrace = next_exception.backtrace_locations.try(:[], 0)
251
+ exception_backtrace = AppMap::Util.try(next_exception.backtrace_locations, :[], 0)
252
252
  exceptions << {
253
253
  class: best_class_name(next_exception),
254
254
  message: display_string(next_exception.message),
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'appmap/service/validator/config_validator'
4
+
3
5
  module AppMap
4
6
  module Service
5
7
  class ConfigAnalyzer
@@ -7,11 +9,10 @@ module AppMap
7
9
 
8
10
  def initialize(config_file)
9
11
  @config_file = config_file
10
- @config = load_config
11
12
  end
12
13
 
13
14
  def app_name
14
- @config.to_h[:name] if present?
15
+ config_validator.config.to_h['name'] if present?
15
16
  end
16
17
 
17
18
  def present?
@@ -19,16 +20,14 @@ module AppMap
19
20
  end
20
21
 
21
22
  def valid?
22
- present? && @config.to_h.key?(:name) && @config.to_h.key?(:packages)
23
+ config_validator.valid?
23
24
  end
24
25
 
25
26
  private
26
27
 
27
- def load_config
28
- AppMap::Config.load_from_file @config_file if present?
29
- rescue
30
- nil
28
+ def config_validator
29
+ @validator ||= AppMap::Service::Validator::ConfigValidator.new(@config_file)
31
30
  end
32
31
  end
33
32
  end
34
- end
33
+ end
@@ -5,39 +5,43 @@ require 'appmap/service/test_framework_detector'
5
5
  module AppMap
6
6
  module Service
7
7
  class IntegrationTestPathFinder
8
- class << self
9
- def find
10
- @paths ||= begin
11
- paths = { rspec: [], minitest: [], cucumber: [] }
12
- paths[:rspec] = find_rspec_paths if TestFrameworkDetector.rspec_present?
13
- paths[:minitest] = find_minitest_paths if TestFrameworkDetector.minitest_present?
14
- paths[:cucumber] = find_cucumber_paths if TestFrameworkDetector.cucumber_present?
15
- paths
16
- end
17
- end
8
+ def initialize(base_path = '')
9
+ @base_path = base_path
10
+ end
18
11
 
19
- def count_paths
20
- find.flatten(2).length - 3
12
+ def find
13
+ @paths ||= begin
14
+ paths = { rspec: [], minitest: [], cucumber: [] }
15
+ paths[:rspec] = find_rspec_paths if TestFrameworkDetector.rspec_present?
16
+ paths[:minitest] = find_minitest_paths if TestFrameworkDetector.minitest_present?
17
+ paths[:cucumber] = find_cucumber_paths if TestFrameworkDetector.cucumber_present?
18
+ paths
21
19
  end
20
+ end
22
21
 
23
- private
22
+ def count_paths
23
+ find.flatten(2).length - 3
24
+ end
24
25
 
25
- def find_rspec_paths
26
- find_non_empty_paths(%w[spec/controllers spec/requests spec/integration spec/api spec/features spec/system])
27
- end
26
+ private
27
+
28
+ def find_rspec_paths
29
+ find_non_empty_paths(%w[spec/controllers spec/requests spec/integration spec/api spec/features spec/system])
30
+ end
28
31
 
29
32
 
30
- def find_minitest_paths
31
- find_non_empty_paths(%w[test/controllers test/integration])
32
- end
33
+ def find_minitest_paths
34
+ top_level_paths = %w[test/controllers test/integration]
35
+ children_paths = Dir.glob('test/**/{controllers,integration}')
36
+ find_non_empty_paths((top_level_paths + children_paths).uniq).sort
37
+ end
33
38
 
34
- def find_cucumber_paths
35
- find_non_empty_paths(%w[features])
36
- end
39
+ def find_cucumber_paths
40
+ find_non_empty_paths(%w[features])
41
+ end
37
42
 
38
- def find_non_empty_paths(paths)
39
- paths.select { |path| Dir.exist?(path) && !Dir.empty?(path) }
40
- end
43
+ def find_non_empty_paths(paths)
44
+ paths.select { |path| Dir.exist?(@base_path + path) && !Dir.empty?(@base_path + path) }
41
45
  end
42
46
  end
43
47
  end
@@ -16,9 +16,7 @@ module AppMap
16
16
  command: {
17
17
  program: 'bundle',
18
18
  args: %w[exec rspec] + integration_test_paths[:rspec].map { |path| "./#{path}" },
19
- environment: {
20
- APPMAP: 'true'
21
- }
19
+ environment: { APPMAP: 'true', DISABLE_SPRING: 'true' }
22
20
  }
23
21
  }
24
22
  end
@@ -32,7 +30,7 @@ module AppMap
32
30
  command: {
33
31
  program: 'bundle',
34
32
  args: %w[exec cucumber],
35
- environment: { APPMAP: 'true' }
33
+ environment: { APPMAP: 'true', DISABLE_SPRING: 'true' }
36
34
  }
37
35
  }
38
36
  end
@@ -50,7 +48,7 @@ module AppMap
50
48
  command: {
51
49
  program: 'bundle',
52
50
  args: %w[exec rails test] + integration_test_paths[:minitest].map { |path| "./#{path}" },
53
- environment: { APPMAP: 'true' }
51
+ environment: { APPMAP: 'true', DISABLE_SPRING: 'true' }
54
52
  }
55
53
  }
56
54
  ]
@@ -61,7 +59,7 @@ module AppMap
61
59
  command: {
62
60
  program: 'bundle',
63
61
  args: ['exec', 'ruby', "./#{path}"],
64
- environment: { APPMAP: 'true' }
62
+ environment: { APPMAP: 'true', DISABLE_SPRING: 'true' }
65
63
  }
66
64
  }
67
65
  end
@@ -69,7 +67,7 @@ module AppMap
69
67
  end
70
68
 
71
69
  def integration_test_paths
72
- @paths ||= Service::IntegrationTestPathFinder.find
70
+ @paths ||= Service::IntegrationTestPathFinder.new.find
73
71
  end
74
72
  end
75
73
  end
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'appmap/service/validator/violation'
4
+
5
+ module AppMap
6
+ module Service
7
+ module Validator
8
+ class ConfigValidator
9
+ attr_reader :violations
10
+
11
+ def initialize(config_file)
12
+ @config_file = config_file
13
+ @violations = []
14
+ end
15
+
16
+ def config
17
+ parse_config
18
+ end
19
+
20
+ def valid?
21
+ validate_ruby_version
22
+ validate_rails_presence
23
+ validate_config_presence
24
+ parse_config
25
+ validate_config_load
26
+ @violations.empty?
27
+ end
28
+
29
+ private
30
+
31
+ def present?
32
+ File.exist?(@config_file)
33
+ end
34
+
35
+ def parse_config
36
+ return unless present?
37
+
38
+ @config_data ||= YAML.load_file(@config_file)
39
+ rescue Psych::SyntaxError => e
40
+ @violations << Violation.error(
41
+ filename: @config_file,
42
+ message: 'AppMap configuration is not valid YAML',
43
+ detailed_message: e.message
44
+ )
45
+ nil
46
+ end
47
+
48
+ def validate_config_load
49
+ return unless @config_data
50
+
51
+ AppMap::Config.load(@config_data)
52
+ rescue StandardError => e
53
+ @violations << Violation.error(
54
+ filename: @config_file,
55
+ message: 'AppMap configuration could not be loaded',
56
+ detailed_message: e.message
57
+ )
58
+ nil
59
+ end
60
+
61
+ def validate_config_presence
62
+ unless present?
63
+ @violations << Violation.error(
64
+ filename: @config_file,
65
+ message: 'AppMap configuration file does not exist'
66
+ )
67
+ end
68
+ end
69
+
70
+ def validate_rails_presence
71
+ unless Gem.loaded_specs.has_key?('rails')
72
+ @violations << Violation.error(
73
+ message: 'AppMap auto-configuration is currently not available for non Rails projects'
74
+ )
75
+ end
76
+ end
77
+
78
+ def validate_ruby_version
79
+ unless RUBY_VERSION =~ AppMap::SUPPORTED_RUBY_VERSIONS_REGEX
80
+ @violations << Violation.error(
81
+ message: "AppMap does not support Ruby #{RUBY_VERSION}. " \
82
+ "Supported versions are: #{AppMap::SUPPORTED_RUBY_VERSIONS.join(', ')}."
83
+ )
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AppMap
4
+ module Service
5
+ module Validator
6
+ class Violation
7
+ attr_reader :level, :setting, :filename, :message, :detailed_message, :help_urls
8
+
9
+ class << self
10
+ def error(message:, setting: nil, filename: nil, detailed_message: nil, help_urls: nil)
11
+ self.new(
12
+ level: :error,
13
+ message: message,
14
+ setting: setting,
15
+ filename: filename,
16
+ detailed_message: detailed_message,
17
+ help_urls: help_urls
18
+ )
19
+ end
20
+
21
+ def warning(message:, setting: nil, filename: nil, detailed_message: nil, help_urls: nil)
22
+ self.new(
23
+ level: :warning,
24
+ message: message,
25
+ setting: setting,
26
+ filename: filename,
27
+ detailed_message: detailed_message,
28
+ help_urls: help_urls
29
+ )
30
+ end
31
+ end
32
+
33
+ def initialize(level:, message:, setting:, filename:, detailed_message:, help_urls:)
34
+ @level = level
35
+ @setting = setting
36
+ @filename = filename
37
+ @message = message
38
+ @detailed_message = detailed_message
39
+ @help_urls = help_urls
40
+ end
41
+
42
+ def to_h
43
+ instance_variables.each_with_object({}) do |var, hash|
44
+ hash[var.to_s.delete("@")] = self.instance_variable_get(var)
45
+ end.compact
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
data/lib/appmap/util.rb CHANGED
@@ -183,6 +183,15 @@ module AppMap
183
183
  false
184
184
  end
185
185
 
186
+ # https://github.com/rails/rails/blob/8cd143900978902ed9bbba10b34099a3140de5c6/activesupport/lib/active_support/core_ext/object/try.rb
187
+ def try(obj, *methods)
188
+ return nil if methods.empty?
189
+
190
+ return nil unless obj.respond_to?(methods.first)
191
+
192
+ obj.public_send(*methods)
193
+ end
194
+
186
195
  def startup_message(msg)
187
196
  if defined?(::Rails) && defined?(::Rails.logger) && ::Rails.logger
188
197
  ::Rails.logger.info msg
@@ -3,10 +3,13 @@
3
3
  module AppMap
4
4
  URL = 'https://github.com/applandinc/appmap-ruby'
5
5
 
6
- VERSION = '0.59.1'
6
+ VERSION = '0.61.1'
7
7
 
8
8
  APPMAP_FORMAT_VERSION = '1.5.1'
9
9
 
10
+ SUPPORTED_RUBY_VERSIONS_REGEX = /^2\.[567]\./.freeze
11
+ SUPPORTED_RUBY_VERSIONS = %w[2.5 2.6 2.7].freeze
12
+
10
13
  DEFAULT_APPMAP_DIR = 'tmp/appmap'.freeze
11
14
  DEFAULT_CONFIG_FILE_PATH = 'appmap.yml'.freeze
12
15
  end
@@ -1,2 +1,2 @@
1
- name: -123- %
2
- packages: ~{}~ ''
1
+ name: name
2
+ packages: [1,2,3]
@@ -0,0 +1,3 @@
1
+ name:
2
+ -
3
+ packages: "[]" asd
@@ -28,7 +28,7 @@ describe AppMap::Service::ConfigAnalyzer do
28
28
  end
29
29
  end
30
30
 
31
- context 'with valid config' do
31
+ context 'with valid but non rails config' do
32
32
  let(:config_file) { 'spec/fixtures/config/valid_config.yml'}
33
33
 
34
34
  describe '.app_name' do
@@ -39,7 +39,7 @@ describe AppMap::Service::ConfigAnalyzer do
39
39
 
40
40
  describe '.is_valid?' do
41
41
  it 'returns true' do
42
- expect(subject.valid?).to be_truthy
42
+ expect(subject.valid?).to be_falsey
43
43
  end
44
44
  end
45
45
 
@@ -51,7 +51,7 @@ describe AppMap::Service::ConfigAnalyzer do
51
51
  end
52
52
 
53
53
  context 'with invalid YAML config' do
54
- let(:config_file) { 'spec/fixtures/config/invalid_config.yml'}
54
+ let(:config_file) { 'spec/fixtures/config/invalid_yaml_config.yml'}
55
55
 
56
56
  describe '.app_name' do
57
57
  it 'returns app name value from config' do
@@ -83,7 +83,7 @@ describe AppMap::Service::ConfigAnalyzer do
83
83
 
84
84
  describe '.is_valid?' do
85
85
  it 'guesses paths and returns true ' do
86
- expect(subject.valid?).to be_truthy
86
+ expect(subject.valid?).to be_falsey
87
87
  end
88
88
  end
89
89
 
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'appmap/service/integration_test_path_finder'
5
+
6
+ describe AppMap::Service::IntegrationTestPathFinder do
7
+ subject { described_class.new('./spec/fixtures/rails6_users_app/') }
8
+
9
+ describe '.count' do
10
+ it 'counts existing paths' do
11
+ expect(subject.count_paths).to be(3)
12
+ end
13
+ end
14
+
15
+ describe '.find' do
16
+ it 'finds paths' do
17
+ expect(subject.find).to eq({
18
+ rspec: %w[spec/controllers],
19
+ minitest: %w[test/controllers test/integration],
20
+ cucumber: []
21
+ })
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'appmap/service/validator/violation'
5
+
6
+ describe AppMap::Service::Validator::Violation do
7
+ describe '.error' do
8
+ let(:message) { 'error' }
9
+
10
+ context 'with default parameters' do
11
+ subject { described_class.error(message: :message) }
12
+
13
+ it 'builds an error' do
14
+ expect(subject.level).to be :error
15
+ expect(subject.message).to be :message
16
+ end
17
+ end
18
+
19
+ context 'with default parameters' do
20
+ subject do
21
+ described_class.error(
22
+ message: :message,
23
+ setting: :setting,
24
+ filename: :filename,
25
+ detailed_message: :detailed_message,
26
+ help_urls: :help_urls
27
+ )
28
+ end
29
+
30
+ let(:filename) { 'filename' }
31
+ let(:setting) { 'setting' }
32
+ let(:detailed_message) { 'details' }
33
+ let(:help_urls) { %w[123 456] }
34
+
35
+ it 'builds an error' do
36
+ expect(subject.level).to be :error
37
+ expect(subject.message).to be :message
38
+ expect(subject.setting).to be :setting
39
+ expect(subject.detailed_message).to be :detailed_message
40
+ expect(subject.help_urls).to be :help_urls
41
+ end
42
+ end
43
+
44
+ describe '.warning' do
45
+ let(:message) { 'warning' }
46
+
47
+ context 'with default parameters' do
48
+ subject { described_class.warning(message: :message) }
49
+
50
+ it 'builds an error' do
51
+ expect(subject.level).to be :warning
52
+ expect(subject.message).to be :message
53
+ end
54
+ end
55
+ end
56
+
57
+ describe '#to_hash' do
58
+ subject { described_class.warning(message: :message) }
59
+
60
+ let(:message) { 'warning' }
61
+
62
+ it 'returns correct hash' do
63
+ expect(subject.to_h['level']).to be :warning
64
+ expect(subject.to_h['message']).to be :message
65
+ end
66
+ end
67
+ end
68
+ end
@@ -13,7 +13,7 @@ class AgentSetupInitTest < Minitest::Test
13
13
  config: {
14
14
  app: 'AppMap Rubygem',
15
15
  present: true,
16
- valid: true
16
+ valid: false
17
17
  },
18
18
  project: {
19
19
  agentVersion: AppMap::VERSION,
@@ -37,7 +37,8 @@ class AgentSetupInitTest < Minitest::Test
37
37
  program: 'bundle',
38
38
  args: %w[exec rspec ./spec/controllers],
39
39
  environment: {
40
- APPMAP: 'true'
40
+ APPMAP: 'true',
41
+ DISABLE_SPRING: 'true'
41
42
  }
42
43
  }
43
44
  },
@@ -47,7 +48,8 @@ class AgentSetupInitTest < Minitest::Test
47
48
  program: 'bundle',
48
49
  args: %w[exec ruby ./test/controllers],
49
50
  environment: {
50
- APPMAP: 'true'
51
+ APPMAP: 'true',
52
+ DISABLE_SPRING: 'true'
51
53
  }
52
54
  }
53
55
  },
@@ -57,14 +59,15 @@ class AgentSetupInitTest < Minitest::Test
57
59
  program: 'bundle',
58
60
  args: %w[exec ruby ./test/integration],
59
61
  environment: {
60
- APPMAP: 'true'
62
+ APPMAP: 'true',
63
+ DISABLE_SPRING: 'true'
61
64
  }
62
65
  }
63
66
  }
64
67
  ],
65
68
  properties: {
66
69
  config: {
67
- app: nil,
70
+ app: 'rails6_users_app',
68
71
  present: true,
69
72
  valid: false
70
73
  },
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+
5
+ class AgentSetupValidateTest < Minitest::Test
6
+ NON_EXISTING_CONFIG_FILENAME = '123.yml'
7
+ INVALID_YAML_CONFIG_FILENAME = 'spec/fixtures/config/invalid_yaml_config.yml'
8
+ INVALID_CONFIG_FILENAME = 'spec/fixtures/config/invalid_config.yml'
9
+
10
+ def test_init_when_config_exists
11
+ output = `./exe/appmap-agent-validate`
12
+ assert_equal 0, $CHILD_STATUS.exitstatus
13
+ expected = JSON.pretty_generate([
14
+ {
15
+ level: :error,
16
+ message: 'AppMap auto-configuration is currently not available for non Rails projects'
17
+ }
18
+ ])
19
+ assert_equal expected, output.strip
20
+ end
21
+
22
+ def test_init_with_non_existing_config_file
23
+ output = `./exe/appmap-agent-validate -c #{NON_EXISTING_CONFIG_FILENAME}`
24
+ assert_equal 0, $CHILD_STATUS.exitstatus
25
+ expected = JSON.pretty_generate([
26
+ {
27
+ level: :error,
28
+ message: 'AppMap auto-configuration is currently not available for non Rails projects'
29
+ },
30
+ {
31
+ level: :error,
32
+ filename: NON_EXISTING_CONFIG_FILENAME,
33
+ message: 'AppMap configuration file does not exist'
34
+ }
35
+ ])
36
+ assert_equal expected, output.strip
37
+ end
38
+
39
+ def test_init_with_invalid_YAML
40
+ output = `./exe/appmap-agent-validate -c #{INVALID_YAML_CONFIG_FILENAME}`
41
+ assert_equal 0, $CHILD_STATUS.exitstatus
42
+ expected = JSON.pretty_generate([
43
+ {
44
+ level: :error,
45
+ message: 'AppMap auto-configuration is currently not available for non Rails projects'
46
+ },
47
+ {
48
+ level: :error,
49
+ filename: INVALID_YAML_CONFIG_FILENAME,
50
+ message: 'AppMap configuration is not valid YAML',
51
+ detailed_message: "(#{INVALID_YAML_CONFIG_FILENAME}): " \
52
+ 'did not find expected key while parsing a block mapping at line 1 column 1'
53
+ }
54
+ ])
55
+ assert_equal expected, output.strip
56
+ end
57
+
58
+ def test_init_with_invalid_data_config
59
+ output = `./exe/appmap-agent-validate -c #{INVALID_CONFIG_FILENAME}`
60
+ assert_equal 0, $CHILD_STATUS.exitstatus
61
+ expected = JSON.pretty_generate([
62
+ {
63
+ level: :error,
64
+ message: 'AppMap auto-configuration is currently not available for non Rails projects'
65
+ },
66
+ {
67
+ level: :error,
68
+ filename: INVALID_CONFIG_FILENAME,
69
+ message: 'AppMap configuration could not be loaded',
70
+ detailed_message: "no implicit conversion of String into Integer"
71
+ }
72
+ ])
73
+ assert_equal expected, output.strip
74
+ end
75
+ 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.59.1
4
+ version: 0.61.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Gilpin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-08 00:00:00.000000000 Z
11
+ date: 2021-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -296,6 +296,7 @@ email:
296
296
  executables:
297
297
  - appmap-agent-init
298
298
  - appmap-agent-status
299
+ - appmap-agent-validate
299
300
  - appmap-inspect
300
301
  extensions:
301
302
  - ext/appmap/extconf.rb
@@ -317,6 +318,7 @@ files:
317
318
  - Rakefile
318
319
  - appmap.gemspec
319
320
  - appmap.yml
321
+ - config-schema.yml
320
322
  - examples/install.rb
321
323
  - examples/mock_webapp/Gemfile
322
324
  - examples/mock_webapp/appmap.yml
@@ -326,6 +328,7 @@ files:
326
328
  - examples/mock_webapp/lib/mock_webapp/user.rb
327
329
  - exe/appmap-agent-init
328
330
  - exe/appmap-agent-status
331
+ - exe/appmap-agent-validate
329
332
  - exe/appmap-inspect
330
333
  - ext/appmap/appmap.c
331
334
  - ext/appmap/extconf.rb
@@ -334,6 +337,7 @@ files:
334
337
  - lib/appmap/class_map.rb
335
338
  - lib/appmap/command/agent_setup/init.rb
336
339
  - lib/appmap/command/agent_setup/status.rb
340
+ - lib/appmap/command/agent_setup/validate.rb
337
341
  - lib/appmap/command/inspect.rb
338
342
  - lib/appmap/command_error.rb
339
343
  - lib/appmap/config.rb
@@ -359,6 +363,8 @@ files:
359
363
  - lib/appmap/service/integration_test_path_finder.rb
360
364
  - lib/appmap/service/test_command_provider.rb
361
365
  - lib/appmap/service/test_framework_detector.rb
366
+ - lib/appmap/service/validator/config_validator.rb
367
+ - lib/appmap/service/validator/violation.rb
362
368
  - lib/appmap/swagger.rb
363
369
  - lib/appmap/swagger/configuration.rb
364
370
  - lib/appmap/swagger/markdown_descriptions.rb
@@ -373,6 +379,7 @@ files:
373
379
  - spec/config_spec.rb
374
380
  - spec/fixtures/config/incomplete_config.yml
375
381
  - spec/fixtures/config/invalid_config.yml
382
+ - spec/fixtures/config/invalid_yaml_config.yml
376
383
  - spec/fixtures/config/valid_config.yml
377
384
  - spec/fixtures/hook/.gitignore
378
385
  - spec/fixtures/hook/app/controllers/api/api_keys_controller.rb
@@ -558,11 +565,14 @@ files:
558
565
  - spec/record_sql_rails_pg_spec.rb
559
566
  - spec/remote_recording_spec.rb
560
567
  - spec/service/config_analyzer_spec.rb
568
+ - spec/service/integration_test_path_finder_spec.rb
569
+ - spec/service/validator/violation_spec.rb
561
570
  - spec/spec_helper.rb
562
571
  - spec/swagger/swagger_spec.rb
563
572
  - spec/util_spec.rb
564
573
  - test/agent_setup_init_test.rb
565
574
  - test/agent_setup_status_test.rb
575
+ - test/agent_setup_validate_test.rb
566
576
  - test/bundle_vendor_test.rb
567
577
  - test/cucumber_test.rb
568
578
  - test/expectations/openssl_test_key_sign1.json