appmap 0.22.0 → 0.23.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +38 -0
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/Rakefile +25 -10
- data/exe/appmap +51 -0
- data/lib/appmap/algorithm/prune_class_map.rb +1 -1
- data/lib/appmap/algorithm/stats.rb +88 -0
- data/lib/appmap/command/stats.rb +12 -0
- data/lib/appmap/command/upload.rb +1 -1
- data/lib/appmap/version.rb +1 -1
- data/spec/abstract_controller4_base_spec.rb +1 -1
- data/spec/abstract_controller_base_spec.rb +1 -1
- data/spec/fixtures/rails_users_app/create_app +16 -1
- data/spec/rails_spec_helper.rb +18 -3
- data/spec/railtie_spec.rb +12 -3
- data/spec/record_sql_rails4_pg_spec.rb +2 -2
- data/spec/record_sql_rails_pg_spec.rb +2 -1
- data/spec/rspec_feature_metadata_spec.rb +1 -1
- data/test/cli_test.rb +68 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ba1394503aa1c8f498901ed3c7b903af4bcf5b60b16fe48eee08d9c64f66d67
|
4
|
+
data.tar.gz: 665c48d0d450b2500277b2bdcb54dc356e0b31d442c1f7d9fcb47d0c5c054de6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 279932323e5ca1ba95eb42a7bc4410e795fb308b2861c1b3ee2bb29ece31e54664983731648967e82ce4367813eb67557791c21bab16cfc67192d743b34d7568
|
7
|
+
data.tar.gz: 0141f02617969b168a2dd0c158e8fbfd5b85caa5bc3fa23691c049ae37adefa269d8e76c3c37b4f08f139bc20071b53bf7b31056b2df1c5dfafef44123a7136b
|
data/.travis.yml
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
language: ruby
|
2
|
+
|
3
|
+
services:
|
4
|
+
- docker
|
5
|
+
|
6
|
+
# We expect RAILS_ENV to start off unset, then adjust its value as
|
7
|
+
# necessary.
|
8
|
+
before_script:
|
9
|
+
- unset RAILS_ENV
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
include:
|
13
|
+
- stage: minitest
|
14
|
+
script:
|
15
|
+
- mkdir tmp
|
16
|
+
- bundle exec rake minitest
|
17
|
+
|
18
|
+
- stage: base
|
19
|
+
script:
|
20
|
+
- bundle exec rake build:base:2.5
|
21
|
+
- stage: base
|
22
|
+
script:
|
23
|
+
- bundle exec rake build:base:2.6
|
24
|
+
|
25
|
+
- stage: fixtures
|
26
|
+
script:
|
27
|
+
- bundle exec rake build:fixtures:2.5:all
|
28
|
+
- stage: fixtures
|
29
|
+
script:
|
30
|
+
- bundle exec rake build:fixtures:2.6:all
|
31
|
+
|
32
|
+
- stage: spec
|
33
|
+
script:
|
34
|
+
- bundle exec rake spec:2.5
|
35
|
+
- stage: spec
|
36
|
+
script:
|
37
|
+
- bundle exec rake spec:2.6
|
38
|
+
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -171,5 +171,5 @@ Batch Id: a116f1df-ee57-4bde-8eef-851af0f3d7bc
|
|
171
171
|
```
|
172
172
|
|
173
173
|
# Build status
|
174
|
+
[![Build Status](https://travis-ci.org/applandinc/appmap-ruby.svg?branch=master)](https://travis-ci.org/applandinc/appmap-ruby)
|
174
175
|
|
175
|
-
![Build status](https://travis-ci.org/applandinc/appmap-ruby.svg?branch=master)
|
data/Rakefile
CHANGED
@@ -4,6 +4,8 @@ GEM_VERSION = AppMap::VERSION
|
|
4
4
|
require 'rake/testtask'
|
5
5
|
require 'rdoc/task'
|
6
6
|
|
7
|
+
require 'open3'
|
8
|
+
|
7
9
|
namespace 'gem' do
|
8
10
|
require 'bundler/gem_tasks'
|
9
11
|
end
|
@@ -11,20 +13,32 @@ end
|
|
11
13
|
RUBY_VERSIONS=%w[2.5 2.6]
|
12
14
|
FIXTURE_APPS=%w[rack_users_app rails_users_app rails4_users_app]
|
13
15
|
|
16
|
+
def run_cmd(*cmd)
|
17
|
+
$stderr.puts "Running: #{cmd}"
|
18
|
+
out,s = Open3.capture2e(*cmd)
|
19
|
+
unless s.success?
|
20
|
+
$stderr.puts <<-END
|
21
|
+
Command failed:
|
22
|
+
<<< Output:
|
23
|
+
#{out}
|
24
|
+
>>> End of output
|
25
|
+
END
|
26
|
+
raise 'Docker build failed'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
14
30
|
def build_base_image(ruby_version)
|
15
|
-
|
31
|
+
run_cmd "docker build" \
|
16
32
|
" --build-arg RUBY_VERSION=#{ruby_version} --build-arg GEM_VERSION=#{GEM_VERSION}" \
|
17
|
-
" -t appmap:#{GEM_VERSION} -f Dockerfile.appmap ."
|
18
|
-
or raise 'Docker build failed'
|
33
|
+
" -t appmap:#{GEM_VERSION} -f Dockerfile.appmap ."
|
19
34
|
end
|
20
35
|
|
21
36
|
def build_app_image(app, ruby_version)
|
22
37
|
Dir.chdir "spec/fixtures/#{app}" do
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
or raise 'docker-compose build failed'
|
38
|
+
run_cmd( {"RUBY_VERSION" => ruby_version, "GEM_VERSION" => GEM_VERSION},
|
39
|
+
" docker-compose build" \
|
40
|
+
" --build-arg RUBY_VERSION=#{ruby_version}" \
|
41
|
+
" --build-arg GEM_VERSION=#{GEM_VERSION}")
|
28
42
|
end
|
29
43
|
end
|
30
44
|
|
@@ -76,8 +90,7 @@ def run_specs(ruby_version, task_args)
|
|
76
90
|
# cause it to be ignored. Setting it to '' or +nil+ causes an
|
77
91
|
# empty argument to get passed to rspec, which confuses it.
|
78
92
|
task.pattern = 'never match this'
|
79
|
-
task.rspec_opts = '
|
80
|
-
task.rspec_opts += args.to_a.join(' ')
|
93
|
+
task.rspec_opts = args.to_a.join(' ')
|
81
94
|
end
|
82
95
|
end
|
83
96
|
|
@@ -112,6 +125,8 @@ Rake::TestTask.new(:minitest) do |t|
|
|
112
125
|
t.test_files = FileList['test/**/*_test.rb']
|
113
126
|
end
|
114
127
|
|
128
|
+
task spec: "spec:all"
|
129
|
+
|
115
130
|
task test: %i[spec:all minitest]
|
116
131
|
|
117
132
|
task default: :test
|
data/exe/appmap
CHANGED
@@ -85,6 +85,57 @@ module AppMap
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
+
desc 'Calculate and print statistics of scenario files.'
|
89
|
+
arg_name 'filename'
|
90
|
+
command :stats do |c|
|
91
|
+
output_file_flag(c, default_value: '-')
|
92
|
+
|
93
|
+
c.desc 'Display format for the result (text | json)'
|
94
|
+
c.default_value 'text'
|
95
|
+
c.flag %i[f format]
|
96
|
+
|
97
|
+
c.desc 'Maximum number of lines to display for each stat'
|
98
|
+
c.flag %i[l limit]
|
99
|
+
|
100
|
+
c.action do |_, options, args|
|
101
|
+
require 'appmap/command/stats'
|
102
|
+
|
103
|
+
limit = options[:limit].to_i if options[:limit]
|
104
|
+
|
105
|
+
# Name of the file to analyze. GLI will ensure that it's present.
|
106
|
+
filenames = args
|
107
|
+
help_now!("'filename' argument is required") if filenames.empty?
|
108
|
+
|
109
|
+
require 'appmap/algorithm/stats'
|
110
|
+
result = filenames.inject(::AppMap::Algorithm::Stats::Result.new([], [])) do |stats_result, filename|
|
111
|
+
appmap = begin
|
112
|
+
JSON.parse(File.read(filename))
|
113
|
+
rescue JSON::ParserError
|
114
|
+
STDERR.puts "#{filename} is not valid JSON : #{$!}"
|
115
|
+
nil
|
116
|
+
end
|
117
|
+
stats_result.tap do
|
118
|
+
if appmap
|
119
|
+
limit = options[:limit].to_i if options[:limit]
|
120
|
+
stats_for_file = AppMap::Command::Stats.new(appmap).perform(limit: limit)
|
121
|
+
stats_result.merge!(stats_for_file)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
result.sort!
|
127
|
+
result.limit!(limit) if limit
|
128
|
+
|
129
|
+
display = case options[:format]
|
130
|
+
when 'json'
|
131
|
+
JSON.pretty_generate(result.as_json)
|
132
|
+
else
|
133
|
+
result.as_text
|
134
|
+
end
|
135
|
+
@output_file.write display
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
88
139
|
desc 'Upload a scenario file to AppLand.'
|
89
140
|
arg_name 'filename'
|
90
141
|
command :upload do |c|
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module AppMap
|
2
|
+
module Algorithm
|
3
|
+
StatsStruct = Struct.new(:appmap)
|
4
|
+
|
5
|
+
# Compute AppMap statistics.
|
6
|
+
class Stats < StatsStruct
|
7
|
+
Result = Struct.new(:class_frequency, :method_frequency) do
|
8
|
+
def merge!(other)
|
9
|
+
merge = lambda do |freq, other_freq|
|
10
|
+
freq_by_name = freq.inject({}) do |table, entry|
|
11
|
+
table.tap do
|
12
|
+
table[entry.name] = entry
|
13
|
+
end
|
14
|
+
end
|
15
|
+
other_freq.each do |other_entry|
|
16
|
+
entry = freq_by_name[other_entry.name]
|
17
|
+
if entry
|
18
|
+
entry.count += other_entry.count
|
19
|
+
else
|
20
|
+
freq << other_entry
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
merge.call(class_frequency, other.class_frequency)
|
25
|
+
merge.call(method_frequency, other.method_frequency)
|
26
|
+
|
27
|
+
self
|
28
|
+
end
|
29
|
+
|
30
|
+
def sort!
|
31
|
+
comparator = ->(a,b) { b.count <=> a.count }
|
32
|
+
class_frequency.sort!(&comparator)
|
33
|
+
method_frequency.sort!(&comparator)
|
34
|
+
|
35
|
+
self
|
36
|
+
end
|
37
|
+
|
38
|
+
def limit!(limit)
|
39
|
+
self.class_frequency = class_frequency[0...limit]
|
40
|
+
self.method_frequency = method_frequency[0...limit]
|
41
|
+
|
42
|
+
self
|
43
|
+
end
|
44
|
+
|
45
|
+
def as_text
|
46
|
+
lines = [
|
47
|
+
"Class frequency:",
|
48
|
+
"----------------",
|
49
|
+
] + class_frequency.map(&:to_a).map(&:reverse).map { |line | line.join("\t") } + [
|
50
|
+
"",
|
51
|
+
"Method frequency:",
|
52
|
+
"----------------",
|
53
|
+
] + method_frequency.map(&:to_a).map(&:reverse).map { |line | line.join("\t") }
|
54
|
+
lines.join("\n")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
Frequency = Struct.new(:name, :count)
|
58
|
+
|
59
|
+
def perform(limit: nil)
|
60
|
+
events = appmap['events'] || []
|
61
|
+
frequency_calc = lambda do |key_func|
|
62
|
+
events_by_key = events.inject(Hash.new(0)) do |memo, event|
|
63
|
+
key = key_func.call(event)
|
64
|
+
memo.tap do
|
65
|
+
memo[key] += 1 if key
|
66
|
+
end
|
67
|
+
end
|
68
|
+
events_by_key.map do |key, count|
|
69
|
+
Frequency.new(key, count)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
class_name_func = ->(event) { event['defined_class'] }
|
74
|
+
full_name_func = lambda do |event|
|
75
|
+
class_name = event['defined_class']
|
76
|
+
static = event['static']
|
77
|
+
function_name = event['method_id']
|
78
|
+
[ class_name, static ? '.' : '#', function_name ].join if class_name && !static.nil? && function_name
|
79
|
+
end
|
80
|
+
|
81
|
+
class_frequency = frequency_calc.call(class_name_func)
|
82
|
+
method_frequency = frequency_calc.call(full_name_func)
|
83
|
+
|
84
|
+
Result.new(class_frequency, method_frequency)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
data/lib/appmap/version.rb
CHANGED
@@ -8,7 +8,7 @@ describe 'AbstractControllerBase' do
|
|
8
8
|
FileUtils.rm_rf tmpdir
|
9
9
|
FileUtils.mkdir_p tmpdir
|
10
10
|
cmd = "docker-compose run --rm -e APPMAP=true -v #{File.absolute_path tmpdir}:/app/tmp app ./bin/rspec spec/controllers/users_controller_api_spec.rb:8"
|
11
|
-
|
11
|
+
run_cmd cmd, chdir: @fixture_dir
|
12
12
|
|
13
13
|
example.run
|
14
14
|
end
|
@@ -8,7 +8,7 @@ describe 'AbstractControllerBase' do
|
|
8
8
|
FileUtils.rm_rf tmpdir
|
9
9
|
FileUtils.mkdir_p tmpdir
|
10
10
|
cmd = "docker-compose run --rm -e APPMAP=true -v #{File.absolute_path tmpdir}:/app/tmp app ./bin/rspec spec/controllers/users_controller_api_spec.rb:8"
|
11
|
-
|
11
|
+
run_cmd cmd, chdir: @fixture_dir
|
12
12
|
|
13
13
|
example.run
|
14
14
|
end
|
@@ -1,11 +1,26 @@
|
|
1
1
|
#!/usr/bin/env bash
|
2
2
|
|
3
|
+
# Just checking for a healthy container isn't enough, apparently. If
|
4
|
+
# we don't wait here, sometimes the database is inaccessible.
|
5
|
+
for i in {1..10}; do
|
6
|
+
psql -h pg -U postgres postgres -c 'select 1' >/dev/null 2>&1 && break
|
7
|
+
printf ' .'
|
8
|
+
sleep 1
|
9
|
+
done
|
10
|
+
echo
|
11
|
+
out="$(psql -h pg -U postgres postgres -c 'select 1' 2>&1)"
|
12
|
+
if [[ $? != 0 ]]; then
|
13
|
+
echo "Postgres didn't start in time:"
|
14
|
+
echo "$out"
|
15
|
+
exit 1
|
16
|
+
fi
|
17
|
+
|
3
18
|
psql -h pg -U postgres -c "create database app_development"
|
4
19
|
psql -h pg -U postgres -c "create database app_test"
|
5
20
|
|
6
21
|
set -e
|
7
22
|
|
8
|
-
./bin/rake db:migrate
|
23
|
+
RAILS_ENV=development ./bin/rake db:migrate
|
9
24
|
RAILS_ENV=test ./bin/rake db:migrate
|
10
25
|
|
11
26
|
echo "INSERT INTO users ( login ) VALUES ( 'admin' ) " | psql -h pg -U postgres app_development
|
data/spec/rails_spec_helper.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'open3'
|
2
3
|
|
3
4
|
def wait_for_container(app_name)
|
4
5
|
start_time = Time.now
|
@@ -11,24 +12,38 @@ def wait_for_container(app_name)
|
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
15
|
+
def run_cmd(*cmd)
|
16
|
+
out,s = Open3.capture2e(*cmd)
|
17
|
+
unless s.success?
|
18
|
+
$stderr.puts <<~END
|
19
|
+
Command failed:
|
20
|
+
#{cmd}
|
21
|
+
<<< Output:
|
22
|
+
#{out}
|
23
|
+
>>> End of output
|
24
|
+
END
|
25
|
+
raise 'Command failed'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
14
29
|
shared_context 'Rails app pg database' do
|
15
30
|
before(:all) do
|
16
31
|
raise "you must set @fixure_dir" unless @fixture_dir
|
17
32
|
|
18
33
|
Dir.chdir @fixture_dir do
|
19
34
|
cmd = 'docker-compose up -d pg'
|
20
|
-
|
35
|
+
run_cmd cmd
|
21
36
|
wait_for_container 'pg'
|
22
37
|
|
23
38
|
cmd = 'docker-compose run --rm app ./create_app'
|
24
|
-
|
39
|
+
run_cmd cmd
|
25
40
|
end
|
26
41
|
end
|
27
42
|
|
28
43
|
after(:all) do
|
29
44
|
if ENV['NOKILL'] != 'true'
|
30
45
|
cmd = 'docker-compose down -v'
|
31
|
-
|
46
|
+
run_cmd cmd, chdir: @fixture_dir
|
32
47
|
end
|
33
48
|
end
|
34
49
|
end
|
data/spec/railtie_spec.rb
CHANGED
@@ -9,12 +9,21 @@ describe 'AppMap tracer via Railtie' do
|
|
9
9
|
let(:cmd) { %(docker-compose run --rm -e RAILS_ENV -e APPMAP app ./bin/rails r "puts Rails.configuration.appmap.enabled.inspect") }
|
10
10
|
let(:command_capture2) do
|
11
11
|
require 'open3'
|
12
|
-
Open3.
|
13
|
-
|
12
|
+
Open3.capture3(env, cmd, chdir: @fixture_dir).tap do |result|
|
13
|
+
unless result[2] == 0
|
14
|
+
$stderr.puts <<~END
|
15
|
+
Failed to run rails_users_app container
|
16
|
+
<<< Output:
|
17
|
+
#{result[0]}
|
18
|
+
#{result[1]}
|
19
|
+
>>> End of output
|
20
|
+
END
|
21
|
+
raise 'Failed to run rails_users_app container'
|
22
|
+
end
|
14
23
|
end
|
15
24
|
end
|
16
25
|
let(:command_output) { command_capture2[0].strip }
|
17
|
-
let(:command_result) { command_capture2[
|
26
|
+
let(:command_result) { command_capture2[2] }
|
18
27
|
|
19
28
|
it 'is disabled by default' do
|
20
29
|
expect(command_output).to eq('nil')
|
@@ -7,8 +7,8 @@ describe 'Record SQL queries in a Rails4 app' do
|
|
7
7
|
around(:each) do |example|
|
8
8
|
FileUtils.rm_rf tmpdir
|
9
9
|
FileUtils.mkdir_p tmpdir
|
10
|
-
cmd = "docker-compose run --rm -e ORM_MODULE=#{orm_module} -e APPMAP=true -v #{File.absolute_path tmpdir}:/app/tmp app ./bin/rspec
|
11
|
-
|
10
|
+
cmd = "docker-compose run --rm -e ORM_MODULE=#{orm_module} -e APPMAP=true -v #{File.absolute_path tmpdir}:/app/tmp app ./bin/rspec spec/controllers/users_controller_api_spec.rb:#{test_line_number}"
|
11
|
+
run_cmd cmd, chdir: @fixture_dir
|
12
12
|
|
13
13
|
example.run
|
14
14
|
end
|
@@ -8,7 +8,8 @@ describe 'Record SQL queries in a Rails app' do
|
|
8
8
|
FileUtils.rm_rf tmpdir
|
9
9
|
FileUtils.mkdir_p tmpdir
|
10
10
|
cmd = "docker-compose run --rm -e ORM_MODULE=#{orm_module} -e APPMAP=true -v #{File.absolute_path tmpdir}:/app/tmp app ./bin/rspec spec/controllers/users_controller_api_spec.rb:#{test_line_number}"
|
11
|
-
|
11
|
+
run_cmd cmd, chdir: @fixture_dir
|
12
|
+
|
12
13
|
|
13
14
|
example.run
|
14
15
|
end
|
@@ -8,7 +8,7 @@ describe 'RSpec feature and feature group metadata' do
|
|
8
8
|
FileUtils.rm_rf tmpdir
|
9
9
|
FileUtils.mkdir_p tmpdir
|
10
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
|
-
|
11
|
+
run_cmd cmd, chdir: @fixture_dir
|
12
12
|
|
13
13
|
example.run
|
14
14
|
end
|
data/test/cli_test.rb
CHANGED
@@ -6,9 +6,11 @@ require 'English'
|
|
6
6
|
|
7
7
|
class CLITest < Minitest::Test
|
8
8
|
OUTPUT_FILENAME = File.expand_path('../tmp/appmap.json', __dir__)
|
9
|
+
STATS_OUTPUT_FILENAME = File.expand_path('../tmp/stats.txt', __dir__)
|
9
10
|
|
10
11
|
def setup
|
11
12
|
FileUtils.rm_f OUTPUT_FILENAME
|
13
|
+
FileUtils.rm_f STATS_OUTPUT_FILENAME
|
12
14
|
end
|
13
15
|
|
14
16
|
def test_config_file_must_exist
|
@@ -58,6 +60,72 @@ class CLITest < Minitest::Test
|
|
58
60
|
assert output['events'], 'Output should contain events'
|
59
61
|
end
|
60
62
|
|
63
|
+
def test_stats_to_file
|
64
|
+
Dir.chdir 'test/fixtures/cli_record_test' do
|
65
|
+
`#{File.expand_path '../exe/appmap', __dir__} record -o #{OUTPUT_FILENAME} ./lib/cli_record_test/main.rb`.strip
|
66
|
+
end
|
67
|
+
assert_equal 0, $CHILD_STATUS.exitstatus
|
68
|
+
|
69
|
+
output = Dir.chdir 'test/fixtures/cli_record_test' do
|
70
|
+
`#{File.expand_path '../exe/appmap', __dir__} stats -o #{STATS_OUTPUT_FILENAME} #{OUTPUT_FILENAME}`.strip
|
71
|
+
end
|
72
|
+
assert_equal 0, $CHILD_STATUS.exitstatus
|
73
|
+
assert_equal '', output
|
74
|
+
assert File.file?(OUTPUT_FILENAME), "#{OUTPUT_FILENAME} does not exist"
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
def test_stats_text
|
79
|
+
Dir.chdir 'test/fixtures/cli_record_test' do
|
80
|
+
`#{File.expand_path '../exe/appmap', __dir__} record -o #{OUTPUT_FILENAME} ./lib/cli_record_test/main.rb`.strip
|
81
|
+
end
|
82
|
+
assert_equal 0, $CHILD_STATUS.exitstatus
|
83
|
+
|
84
|
+
output = Dir.chdir 'test/fixtures/cli_record_test' do
|
85
|
+
`#{File.expand_path '../exe/appmap', __dir__} stats -o - #{OUTPUT_FILENAME}`.strip
|
86
|
+
end
|
87
|
+
|
88
|
+
assert_equal 0, $CHILD_STATUS.exitstatus
|
89
|
+
assert_equal <<~OUTPUT.strip, output.strip
|
90
|
+
Class frequency:
|
91
|
+
----------------
|
92
|
+
2 Main
|
93
|
+
|
94
|
+
Method frequency:
|
95
|
+
----------------
|
96
|
+
2 Main.say_hello
|
97
|
+
OUTPUT
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_stats_json
|
101
|
+
Dir.chdir 'test/fixtures/cli_record_test' do
|
102
|
+
`#{File.expand_path '../exe/appmap', __dir__} record -o #{OUTPUT_FILENAME} ./lib/cli_record_test/main.rb`.strip
|
103
|
+
end
|
104
|
+
assert_equal 0, $CHILD_STATUS.exitstatus
|
105
|
+
|
106
|
+
output = Dir.chdir 'test/fixtures/cli_record_test' do
|
107
|
+
`#{File.expand_path '../exe/appmap', __dir__} stats -f json -o - #{OUTPUT_FILENAME}`.strip
|
108
|
+
end
|
109
|
+
|
110
|
+
assert_equal 0, $CHILD_STATUS.exitstatus
|
111
|
+
assert_equal <<~OUTPUT.strip, output.strip
|
112
|
+
{
|
113
|
+
"class_frequency": [
|
114
|
+
{
|
115
|
+
"name": "Main",
|
116
|
+
"count": 2
|
117
|
+
}
|
118
|
+
],
|
119
|
+
"method_frequency": [
|
120
|
+
{
|
121
|
+
"name": "Main.say_hello",
|
122
|
+
"count": 2
|
123
|
+
}
|
124
|
+
]
|
125
|
+
}
|
126
|
+
OUTPUT
|
127
|
+
end
|
128
|
+
|
61
129
|
def test_record_to_default_location
|
62
130
|
Dir.chdir 'test/fixtures/cli_record_test' do
|
63
131
|
system({ 'APPMAP_FILE' => OUTPUT_FILENAME }, "#{File.expand_path '../exe/appmap', __dir__} record ./lib/cli_record_test/main.rb")
|
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.23.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Gilpin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -219,6 +219,7 @@ files:
|
|
219
219
|
- ".gitignore"
|
220
220
|
- ".rubocop.yml"
|
221
221
|
- ".ruby-version"
|
222
|
+
- ".travis.yml"
|
222
223
|
- CHANGELOG.md
|
223
224
|
- Dockerfile.appmap
|
224
225
|
- Gemfile
|
@@ -238,8 +239,10 @@ files:
|
|
238
239
|
- exe/appmap
|
239
240
|
- lib/appmap.rb
|
240
241
|
- lib/appmap/algorithm/prune_class_map.rb
|
242
|
+
- lib/appmap/algorithm/stats.rb
|
241
243
|
- lib/appmap/command/inspect.rb
|
242
244
|
- lib/appmap/command/record.rb
|
245
|
+
- lib/appmap/command/stats.rb
|
243
246
|
- lib/appmap/command/upload.rb
|
244
247
|
- lib/appmap/config.rb
|
245
248
|
- lib/appmap/config/directory.rb
|