affected_tests 0.6.0 → 0.8.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9f7612b94dce034b4d89f2891cdc08bc1ee7781449b1f99c5896a22654e9c9e1
4
- data.tar.gz: c56ce89c20979413b0af7f0bef9566bf19d6d073b01a27d79a98ac57b2d738da
3
+ metadata.gz: b58188063779a6e80ac7492a25ff19ae11dd846597419428b649f9de12f8fb34
4
+ data.tar.gz: 7ed0d79d416f63969500e8290bfe12a6ba8d8d13fc06b9ed308ef0329c26e327
5
5
  SHA512:
6
- metadata.gz: b19b06a01002be005295109ca9cf81c1d8177f40730ade142f9e3a5293fcb91286302398fb06299d5c56e8248615adae0223735302a4bd60ec845467d85af5fd
7
- data.tar.gz: f52bf08410c743a5032ebae1fb260a54ab0fa8098d3f76e043855d18d92df8c4bdf27e637b962a45fbda5c4aa5cec56d8954efebe6be201fd989d6040ac0ac28
6
+ metadata.gz: 1cedd3e13bc961f27ee295efb577ac846bfd24909724517e2676d95af2ab04157a217cd735b74f1da75bba1b0a4b3eb986f416089337c3a9a04898e5a54270ce
7
+ data.tar.gz: 05ab37b0587c12ea71b918e4ebbe6ed5452e250a7d5989546e83bd79734723fbd021a986a075eb894b459ea4b06c2b5c41eea2a7fad050ebffcbe069c78fe40e
data/README.md CHANGED
@@ -1,9 +1,5 @@
1
1
  # AffectedTests
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/affected_tests`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
3
  ## Installation
8
4
 
9
5
  Install the gem and add to the application's Gemfile by executing:
@@ -14,6 +10,16 @@ If bundler is not being used to manage dependencies, install the gem by executin
14
10
 
15
11
  $ gem install affected_tests
16
12
 
13
+ ### About engine
14
+
15
+ affected_tests support 3 engines to find out test, source relation:
16
+
17
+ - rotoscope (default)
18
+ - coverage
19
+ - calleree
20
+
21
+ each engine require its library, so you need to add proper gem according to your selection(except coverage which is stdlib).
22
+
17
23
  ## Usage
18
24
 
19
25
  ### Aggregate data
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AffectedTests
4
+ module Engine
5
+ class Calleree
6
+ def initialize(config)
7
+ @config = config
8
+ @tracing = true
9
+
10
+ ::Calleree.start
11
+ end
12
+
13
+ def start_trace
14
+ # Clear buffer in calleree
15
+ ::Calleree.result(clear: true)
16
+ end
17
+
18
+ def stop_trace
19
+ # do nothing
20
+ end
21
+
22
+ def tracing?
23
+ @tracing # Calleree doesn't have tracing status
24
+ end
25
+
26
+ def checkpoint(target_test_path)
27
+ res = ::Calleree.result(clear: true)
28
+ import(target_test_path, res)
29
+ end
30
+
31
+ def import(target_test_path, result)
32
+ caller_in_project = result.select do |(caller_info, _callee_info, _count)|
33
+ caller_path = caller_info.first
34
+ @config.target_path?(caller_path)
35
+ end.map do |(caller_info, _callee_info, _count)|
36
+ @config.format_path(caller_info.first)
37
+ end
38
+
39
+ called_in_project = result.select do |(_caller_info, callee_info, _count)|
40
+ callee_path = callee_info.first
41
+ @config.target_path?(callee_path)
42
+ end.map do |(_caller_info, callee_info, _count)|
43
+ @config.format_path(callee_info.first)
44
+ end
45
+
46
+ all_related_paths = (called_in_project + caller_in_project).uniq
47
+ formatted_target_test_path = @config.format_path(target_test_path)
48
+
49
+ all_related_paths.each do |path|
50
+ next if path.start_with?(@config.test_dir_path)
51
+
52
+ if path != formatted_target_test_path
53
+ add(formatted_target_test_path, path)
54
+ end
55
+ end
56
+ end
57
+
58
+ def add(caller, callee)
59
+ cache[callee] ||= Set.new
60
+ cache[callee].add(caller)
61
+ end
62
+
63
+ def cache
64
+ Thread.current[:cache] ||= {}
65
+ end
66
+
67
+ def dump
68
+ cache.transform_values(&:to_a)
69
+ ensure
70
+ ::Calleree.stop
71
+ @tracing = false
72
+ end
73
+ end
74
+ end
75
+ end
@@ -13,14 +13,16 @@ module AffectedTests
13
13
  buffer << call.caller_path
14
14
  end
15
15
  end
16
+ @rotoscope.start_trace
16
17
  end
17
18
 
18
19
  def start_trace
19
- @rotoscope.start_trace
20
+ # Clear buffer
21
+ buffer.clear
20
22
  end
21
23
 
22
24
  def stop_trace
23
- @rotoscope.stop_trace
25
+ # do nothing
24
26
  end
25
27
 
26
28
  def tracing?
@@ -63,6 +65,7 @@ module AffectedTests
63
65
  end
64
66
 
65
67
  def dump
68
+ @rotoscope.stop_trace
66
69
  cache.transform_values(&:to_a)
67
70
  end
68
71
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AffectedTests
4
- VERSION = "0.6.0"
4
+ VERSION = "0.8.0"
5
5
  end
@@ -51,6 +51,10 @@ module AffectedTests
51
51
  require "rotoscope"
52
52
  require "affected_tests/engine/rotoscope"
53
53
  AffectedTests::Engine::Rotoscope
54
+ when :calleree
55
+ require "calleree"
56
+ require "affected_tests/engine/calleree"
57
+ AffectedTests::Engine::Calleree
54
58
  when :coverage
55
59
  require "coverage"
56
60
  require "affected_tests/engine/coverage"
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: affected_tests
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shia
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-13 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rotoscope
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
11
+ date: 2022-09-23 00:00:00.000000000 Z
12
+ dependencies: []
27
13
  description: Tool-kit for testing based on changed files.
28
14
  email:
29
15
  - rise.shia@gmail.com
@@ -39,6 +25,7 @@ files:
39
25
  - Rakefile
40
26
  - lib/affected_tests.rb
41
27
  - lib/affected_tests/differ.rb
28
+ - lib/affected_tests/engine/calleree.rb
42
29
  - lib/affected_tests/engine/coverage.rb
43
30
  - lib/affected_tests/engine/rotoscope.rb
44
31
  - lib/affected_tests/map_merger.rb