appmap 0.34.0 → 0.34.1
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/CHANGELOG.md +6 -0
- data/appmap.gemspec +1 -0
- data/lib/appmap/cucumber.rb +19 -2
- data/lib/appmap/hook/method.rb +7 -2
- data/lib/appmap/version.rb +1 -1
- data/spec/fixtures/hook/instance_method.rb +4 -0
- data/spec/hook_spec.rb +36 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39576d59d2648a009f888fa9c5720d8fdb91b04fcb4d08949a05a0a5c453d0c8
|
4
|
+
data.tar.gz: 8b1d5442421d9dd37c3db4fa0329321e6b6e6ebc87e94bb67be3da9b3f1467b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40bc1a630b65a83f7516085ec4cd25a72f83e574a9c2f150f8e302c9756c376a1fc820d490393d9625aeb3f5b781ca44d34431efe2722a7a0031b49334ccbca7
|
7
|
+
data.tar.gz: 9d32eb02deebdfb16e99ee0f157f5c9de6cb77cafa46233867e0173577609d4390b98a675f67c11868d57370066666bf9f9da39b2ee2ab25ba16cbaf4ebcd8ca
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# v0.34.1
|
2
|
+
* Ensure that capturing events doesn't change the behavior of a hooked method that uses
|
3
|
+
`Time.now`. For example, if a test expects that `Time.now` will be called a certain
|
4
|
+
number of times by a hooked method, that expectation will now be met.
|
5
|
+
* Make sure `appmap/cucumber` requires `appmap`.
|
6
|
+
|
1
7
|
# v0.34.0
|
2
8
|
|
3
9
|
* Records builtin security and I/O methods from `OpenSSL`, `Net`, and `IO`.
|
data/appmap.gemspec
CHANGED
data/lib/appmap/cucumber.rb
CHANGED
@@ -4,6 +4,8 @@ require 'appmap/util'
|
|
4
4
|
|
5
5
|
module AppMap
|
6
6
|
module Cucumber
|
7
|
+
APPMAP_OUTPUT_DIR = 'tmp/appmap/cucumber'
|
8
|
+
|
7
9
|
ScenarioAttributes = Struct.new(:name, :feature, :feature_group)
|
8
10
|
|
9
11
|
ProviderStruct = Struct.new(:scenario) do
|
@@ -38,18 +40,27 @@ module AppMap
|
|
38
40
|
end
|
39
41
|
|
40
42
|
class << self
|
43
|
+
def init
|
44
|
+
warn 'Configuring AppMap recorder for Cucumber'
|
45
|
+
|
46
|
+
FileUtils.mkdir_p APPMAP_OUTPUT_DIR
|
47
|
+
end
|
48
|
+
|
41
49
|
def write_scenario(scenario, appmap)
|
42
50
|
appmap['metadata'] = update_metadata(scenario, appmap['metadata'])
|
43
51
|
scenario_filename = AppMap::Util.scenario_filename(appmap['metadata']['name'])
|
44
52
|
|
45
|
-
|
46
|
-
File.write(File.join('tmp/appmap/cucumber', scenario_filename), JSON.generate(appmap))
|
53
|
+
File.write(File.join(APPMAP_OUTPUT_DIR, scenario_filename), JSON.generate(appmap))
|
47
54
|
end
|
48
55
|
|
49
56
|
def enabled?
|
50
57
|
ENV['APPMAP'] == 'true'
|
51
58
|
end
|
52
59
|
|
60
|
+
def run
|
61
|
+
init
|
62
|
+
end
|
63
|
+
|
53
64
|
protected
|
54
65
|
|
55
66
|
def cucumber_version
|
@@ -87,3 +98,9 @@ module AppMap
|
|
87
98
|
end
|
88
99
|
end
|
89
100
|
end
|
101
|
+
|
102
|
+
if AppMap::Cucumber.enabled?
|
103
|
+
require 'appmap'
|
104
|
+
|
105
|
+
AppMap::Cucumber.run
|
106
|
+
end
|
data/lib/appmap/hook/method.rb
CHANGED
@@ -6,6 +6,11 @@ module AppMap
|
|
6
6
|
HOOK_DISABLE_KEY = 'AppMap::Hook.disable'
|
7
7
|
private_constant :HOOK_DISABLE_KEY
|
8
8
|
|
9
|
+
# Grab the definition of Time.now here, to avoid interfering
|
10
|
+
# with the method we're hooking.
|
11
|
+
TIME_NOW = Time.method(:now)
|
12
|
+
private_constant :TIME_NOW
|
13
|
+
|
9
14
|
def initialize(hook_class, hook_method)
|
10
15
|
@hook_class = hook_class
|
11
16
|
@hook_method = hook_method
|
@@ -52,12 +57,12 @@ module AppMap
|
|
52
57
|
require 'appmap/event'
|
53
58
|
call_event = AppMap::Event::MethodCall.build_from_invocation(defined_class, hook_method, receiver, args)
|
54
59
|
AppMap.tracing.record_event call_event, defined_class: defined_class, method: hook_method
|
55
|
-
[ call_event,
|
60
|
+
[ call_event, TIME_NOW.call ]
|
56
61
|
end
|
57
62
|
|
58
63
|
def after_hook(call_event, start_time, return_value, exception)
|
59
64
|
require 'appmap/event'
|
60
|
-
elapsed =
|
65
|
+
elapsed = TIME_NOW.call - start_time
|
61
66
|
return_event = \
|
62
67
|
AppMap::Event::MethodReturn.build_from_invocation call_event.id, elapsed, return_value, exception
|
63
68
|
AppMap.tracing.record_event return_event
|
data/lib/appmap/version.rb
CHANGED
data/spec/hook_spec.rb
CHANGED
@@ -599,4 +599,40 @@ describe 'AppMap class Hooking', docker: false do
|
|
599
599
|
expect(Diffy::Diff.new(classmap_yaml, cm.to_yaml).to_s).to eq('')
|
600
600
|
end
|
601
601
|
end
|
602
|
+
|
603
|
+
it "doesn't cause expectations on Time.now to fail" do
|
604
|
+
events_yaml = <<~YAML
|
605
|
+
---
|
606
|
+
- :id: 1
|
607
|
+
:event: :call
|
608
|
+
:defined_class: InstanceMethod
|
609
|
+
:method_id: say_the_time
|
610
|
+
:path: spec/fixtures/hook/instance_method.rb
|
611
|
+
:lineno: 24
|
612
|
+
:static: false
|
613
|
+
:parameters: []
|
614
|
+
:receiver:
|
615
|
+
:class: InstanceMethod
|
616
|
+
:value: Instance Method fixture
|
617
|
+
- :id: 2
|
618
|
+
:event: :return
|
619
|
+
:parent_id: 1
|
620
|
+
:return_value:
|
621
|
+
:class: String
|
622
|
+
:value: '2020-01-01 00:00:00 +0000'
|
623
|
+
YAML
|
624
|
+
test_hook_behavior 'spec/fixtures/hook/instance_method.rb', events_yaml do
|
625
|
+
require 'timecop'
|
626
|
+
begin
|
627
|
+
tz = ENV['TZ']
|
628
|
+
ENV['TZ'] = 'UTC'
|
629
|
+
Timecop.freeze(Time.utc('2020-01-01')) do
|
630
|
+
expect(Time).to receive(:now).exactly(3).times.and_call_original
|
631
|
+
expect(InstanceMethod.new.say_the_time).to be
|
632
|
+
end
|
633
|
+
ensure
|
634
|
+
ENV['TZ'] = tz
|
635
|
+
end
|
636
|
+
end
|
637
|
+
end
|
602
638
|
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.34.
|
4
|
+
version: 0.34.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: 2020-
|
11
|
+
date: 2020-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -248,6 +248,20 @@ dependencies:
|
|
248
248
|
- - "~>"
|
249
249
|
- !ruby/object:Gem::Version
|
250
250
|
version: '4.0'
|
251
|
+
- !ruby/object:Gem::Dependency
|
252
|
+
name: timecop
|
253
|
+
requirement: !ruby/object:Gem::Requirement
|
254
|
+
requirements:
|
255
|
+
- - ">="
|
256
|
+
- !ruby/object:Gem::Version
|
257
|
+
version: '0'
|
258
|
+
type: :development
|
259
|
+
prerelease: false
|
260
|
+
version_requirements: !ruby/object:Gem::Requirement
|
261
|
+
requirements:
|
262
|
+
- - ">="
|
263
|
+
- !ruby/object:Gem::Version
|
264
|
+
version: '0'
|
251
265
|
description:
|
252
266
|
email:
|
253
267
|
- kgilpin@gmail.com
|