affected_tests 0.7.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: 32deac2b7ba23269acfb008ef35c099cc3c109200169485edb240fd7287daae3
4
- data.tar.gz: c0fa16f41e7043e39443b7813504711d7be5b4e2004aea06518e190ce28b5ae8
3
+ metadata.gz: b58188063779a6e80ac7492a25ff19ae11dd846597419428b649f9de12f8fb34
4
+ data.tar.gz: 7ed0d79d416f63969500e8290bfe12a6ba8d8d13fc06b9ed308ef0329c26e327
5
5
  SHA512:
6
- metadata.gz: 64f16bea896df2943bfd71f506ad664b8d2d4206ecf2527912eedc62776e8a0a8d7b3aa9bb25e24b4621e468d496601c41e03ee7157cf30da6eb004dea743837
7
- data.tar.gz: b568db5e8c365b6f39c0198aa3930d7d52f2d824c9429cd3eb4709ae2905fc48c27d48e4a11272111e26dc9afcfeb61ccd5c361149ac218a95c408d9a70e8b96
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AffectedTests
4
- VERSION = "0.7.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.7.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-14 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