test-prof 1.3.2 → 1.3.3

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: ed617176a00461b30a96b07f086b52ea89d28fff7d1e4b085110e1b2333b6c60
4
- data.tar.gz: c2e425a439407505f4ac1ecbfe25d84517343d7e9d7f1260ce675382f3ee6f1f
3
+ metadata.gz: a719a17544a705f447aeefc448f75bb2ffc11c268661735c11095b593e0d9417
4
+ data.tar.gz: 3d461a0c4573a0a7c43a7db57b8ecce96baf2c1a60998f56019c437a20ad1f60
5
5
  SHA512:
6
- metadata.gz: 3548abd19a6f283dd230e340a0651fc2196b7253bc4fcf4f5115d53a3e55b35e43ece87a875d4267a00edfa5105c303365bc1b7e9f787a0fcd5d3d8ffd86634b
7
- data.tar.gz: 911ed9f79a48b4fd72b1ea7885f2eb5d3f75410421946cdd61966b9ffc50a245bb1f0c88b93b256ec5b06159267b16ccfcf129c06fde3d021605f1b15375c7cf
6
+ metadata.gz: '0549376752f1b0e6d718333f2e378c2d0cd3bee94a18f52440c0110710f9ab9bc1a23aaaadcd84e1cbf1171402d11cd4eaa98718bbc736cfdcc3f50740cc7e89'
7
+ data.tar.gz: 3f6546e3d091b6c0aba067d94c12bfd1bf8542d0725b851f06cac81b8507685de4ef7ca25bd38b2bec9b2a98f21c99cfddd68997dca90ab739bbc3f19820fef6
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 1.3.3 (2024-04-19)
6
+
7
+ - Fix MemProf bugs. ([@palkan][])
8
+
5
9
  ## 1.3.2 (2024-03-08) 🌷
6
10
 
7
11
  - Add Minitest support for TagProf. ([@lioneldebauge][])
@@ -66,7 +66,7 @@ module TestProf
66
66
  private
67
67
 
68
68
  def filters_apply?(metadata)
69
- return true unless filters.present? && TestProf.rspec?
69
+ return true unless filters.is_a?(Hash) && TestProf.rspec?
70
70
 
71
71
  ::RSpec::Core::MetadataFilter.apply?(
72
72
  :all?,
@@ -50,6 +50,8 @@ module TestProf
50
50
  end
51
51
 
52
52
  def memory_percentage(item)
53
+ return 0 if tracker.total_memory.zero? || item[:memory].zero?
54
+
53
55
  (100.0 * item[:memory] / tracker.total_memory).round(2)
54
56
  end
55
57
 
@@ -16,23 +16,26 @@ module TestProf
16
16
  @tracker = MemoryProf.tracker
17
17
  @printer = MemoryProf.printer(tracker)
18
18
 
19
+ @current_group = nil
20
+ @current_example = nil
21
+
19
22
  @tracker.start
20
23
  end
21
24
 
22
25
  def example_started(notification)
23
- tracker.example_started(example(notification))
26
+ tracker.example_started(notification.example, example(notification))
24
27
  end
25
28
 
26
29
  def example_finished(notification)
27
- tracker.example_finished(example(notification))
30
+ tracker.example_finished(notification.example)
28
31
  end
29
32
 
30
33
  def example_group_started(notification)
31
- tracker.group_started(group(notification))
34
+ tracker.group_started(notification.group, group(notification))
32
35
  end
33
36
 
34
37
  def example_group_finished(notification)
35
- tracker.group_finished(group(notification))
38
+ tracker.group_finished(notification.group)
36
39
  end
37
40
 
38
41
  def report
@@ -52,19 +52,20 @@ module TestProf
52
52
  attr_reader :head
53
53
 
54
54
  def initialize(memory_at_start)
55
- add_node(:total, memory_at_start)
55
+ add_node(:total, :total, memory_at_start)
56
56
  end
57
57
 
58
- def add_node(item, memory_at_start)
58
+ def add_node(id, item, memory_at_start)
59
59
  @head = LinkedListNode.new(
60
+ id: id,
60
61
  item: item,
61
62
  previous: head,
62
63
  memory_at_start: memory_at_start
63
64
  )
64
65
  end
65
66
 
66
- def remove_node(item, memory_at_finish)
67
- return if head.item != item
67
+ def remove_node(id, memory_at_finish)
68
+ return if head.id != id
68
69
  head.finish(memory_at_finish)
69
70
 
70
71
  current = head
@@ -75,9 +76,10 @@ module TestProf
75
76
  end
76
77
 
77
78
  class LinkedListNode
78
- attr_reader :item, :previous, :memory_at_start, :memory_at_finish, :nested_memory
79
+ attr_reader :id, :item, :previous, :memory_at_start, :memory_at_finish, :nested_memory
79
80
 
80
- def initialize(item:, memory_at_start:, previous:)
81
+ def initialize(id:, item:, memory_at_start:, previous:)
82
+ @id = id
81
83
  @item = item
82
84
  @previous = previous
83
85
 
@@ -36,22 +36,26 @@ module TestProf
36
36
  @total_memory = node.total_memory
37
37
  end
38
38
 
39
- def example_started(example)
40
- list.add_node(example, track)
39
+ def example_started(id, example = id)
40
+ list.add_node(id, example, track)
41
41
  end
42
42
 
43
- def example_finished(example)
44
- node = list.remove_node(example, track)
45
- examples << {**example, memory: node.total_memory}
43
+ def example_finished(id)
44
+ node = list.remove_node(id, track)
45
+ return unless node
46
+
47
+ examples << {**node.item, memory: node.total_memory}
46
48
  end
47
49
 
48
- def group_started(group)
49
- list.add_node(group, track)
50
+ def group_started(id, group = id)
51
+ list.add_node(id, group, track)
50
52
  end
51
53
 
52
- def group_finished(group)
53
- node = list.remove_node(group, track)
54
- groups << {**group, memory: node.hooks_memory}
54
+ def group_finished(id)
55
+ node = list.remove_node(id, track)
56
+ return unless node
57
+
58
+ groups << {**node.item, memory: node.hooks_memory}
55
59
  end
56
60
  end
57
61
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TestProf
4
- VERSION = "1.3.2"
4
+ VERSION = "1.3.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-prof
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Dementyev
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-08 00:00:00.000000000 Z
11
+ date: 2024-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -235,7 +235,7 @@ metadata:
235
235
  homepage_uri: https://test-prof.evilmartians.io/
236
236
  source_code_uri: https://github.com/test-prof/test-prof
237
237
  funding_uri: https://github.com/sponsors/test-prof
238
- post_install_message:
238
+ post_install_message:
239
239
  rdoc_options: []
240
240
  require_paths:
241
241
  - lib
@@ -250,8 +250,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
250
250
  - !ruby/object:Gem::Version
251
251
  version: '0'
252
252
  requirements: []
253
- rubygems_version: 3.4.20
254
- signing_key:
253
+ rubygems_version: 3.4.19
254
+ signing_key:
255
255
  specification_version: 4
256
256
  summary: Ruby applications tests profiling tools
257
257
  test_files: []