appmap 0.34.0 → 0.34.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: 47030df4910179ac636b8a2c4c3c29c25225deb1b9cbce851264d1e2ae8dacf1
4
- data.tar.gz: 84bc3de36a1f7700fe32128c40f8d2bf6d698208689e856fd2bc696c38be6500
3
+ metadata.gz: 39576d59d2648a009f888fa9c5720d8fdb91b04fcb4d08949a05a0a5c453d0c8
4
+ data.tar.gz: 8b1d5442421d9dd37c3db4fa0329321e6b6e6ebc87e94bb67be3da9b3f1467b0
5
5
  SHA512:
6
- metadata.gz: 98d8933599f9cdb39d2ab9d69d1c11c7f06972603c30b5d79b3c57dc2ec246aec2c432da4835bcab805d49ec17e757fc0377d583908c6894380e951071b2d797
7
- data.tar.gz: eefe2496acc6be7ebfe20eee2ab9ed0e708658a039c196757dd00ca18351e0425d3a6d1f0599cca37bd4a2c786469d61fdc7ad0e50a56d9223360204e2bc4206
6
+ metadata.gz: 40bc1a630b65a83f7516085ec4cd25a72f83e574a9c2f150f8e302c9756c376a1fc820d490393d9625aeb3f5b781ca44d34431efe2722a7a0031b49334ccbca7
7
+ data.tar.gz: 9d32eb02deebdfb16e99ee0f157f5c9de6cb77cafa46233867e0173577609d4390b98a675f67c11868d57370066666bf9f9da39b2ee2ab25ba16cbaf4ebcd8ca
@@ -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`.
@@ -42,4 +42,5 @@ Gem::Specification.new do |spec|
42
42
  spec.add_development_dependency 'rspec'
43
43
  spec.add_development_dependency 'selenium-webdriver'
44
44
  spec.add_development_dependency 'webdrivers', '~> 4.0'
45
+ spec.add_development_dependency 'timecop'
45
46
  end
@@ -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
- FileUtils.mkdir_p 'tmp/appmap/cucumber'
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
@@ -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, Time.now ]
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 = Time.now - start_time
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
@@ -3,7 +3,7 @@
3
3
  module AppMap
4
4
  URL = 'https://github.com/applandinc/appmap-ruby'
5
5
 
6
- VERSION = '0.34.0'
6
+ VERSION = '0.34.1'
7
7
 
8
8
  APPMAP_FORMAT_VERSION = '1.2'
9
9
  end
@@ -20,4 +20,8 @@ class InstanceMethod
20
20
  def say_block(&block)
21
21
  yield
22
22
  end
23
+
24
+ def say_the_time
25
+ Time.now.to_s
26
+ end
23
27
  end
@@ -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.0
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-08-21 00:00:00.000000000 Z
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