affected_tests 0.8.0 → 1.0.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: b58188063779a6e80ac7492a25ff19ae11dd846597419428b649f9de12f8fb34
4
- data.tar.gz: 7ed0d79d416f63969500e8290bfe12a6ba8d8d13fc06b9ed308ef0329c26e327
3
+ metadata.gz: aba033bbf0c484e7a26a9a58cecdf28da51caa55ba9ccd4f12c4ff63f5db1dd8
4
+ data.tar.gz: 9669ed400572ff49bf35c4e1d6e0912b8a53332646e93a0fef73231ba81a8e6d
5
5
  SHA512:
6
- metadata.gz: 1cedd3e13bc961f27ee295efb577ac846bfd24909724517e2676d95af2ab04157a217cd735b74f1da75bba1b0a4b3eb986f416089337c3a9a04898e5a54270ce
7
- data.tar.gz: 05ab37b0587c12ea71b918e4ebbe6ed5452e250a7d5989546e83bd79734723fbd021a986a075eb894b459ea4b06c2b5c41eea2a7fad050ebffcbe069c78fe40e
6
+ metadata.gz: bdf0dcb1bf128f8dced4830d52ff426ca203fc03d6981a5e18ad6d8a19b0ffec6e8894687defa80f6b16ac43961862fda67e0abc921d6a69684e0bdc82842296
7
+ data.tar.gz: 4caeeedab8d327fa963859a5de7b768096b66f1050ce00dd1b7383b8da97d6b746e5a23127c30a40fe63ee7d7061f07cccfecf394c249026efe1149b1424c718
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --require spec_helper
3
+ --exclude-pattern spec/fixtures/**/*_spec.rb
data/Gemfile CHANGED
@@ -6,3 +6,7 @@ source "https://rubygems.org"
6
6
  gemspec
7
7
 
8
8
  gem "rake", "~> 13.0"
9
+ gem "rspec"
10
+
11
+ # Optional engine, which users choose by themselves
12
+ gem "calleree"
data/README.md CHANGED
@@ -12,10 +12,9 @@ If bundler is not being used to manage dependencies, install the gem by executin
12
12
 
13
13
  ### About engine
14
14
 
15
- affected_tests support 3 engines to find out test, source relation:
15
+ affected_tests support 2 engines to find out test, source relation:
16
16
 
17
- - rotoscope (default)
18
- - coverage
17
+ - coverage (default)
19
18
  - calleree
20
19
 
21
20
  each engine require its library, so you need to add proper gem according to your selection(except coverage which is stdlib).
@@ -33,7 +32,7 @@ require "affected_tests"
33
32
  require "affected_tests/rspec"
34
33
 
35
34
  AffectedTests.setup(
36
- engine: :rotoscope,
35
+ engine: :coverage,
37
36
  project_path: File.expand_path("../../", __FILE__),
38
37
  test_dir_path: "spec/",
39
38
  output_path: "log/affected-tests-map.json",
data/Rakefile CHANGED
@@ -1,3 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -8,6 +8,12 @@ RSpec.configure do |config|
8
8
  config.append_after(:each) do
9
9
  AffectedTests.stop_trace
10
10
  target_spec = self.class.declaration_locations.last[0]
11
+ # Shared examples are declared outside of the spec file including them,
12
+ # so walk up to the group which the spec file itself declares.
13
+ unless target_spec.end_with?("_spec.rb")
14
+ spec_group = self.class.parent_groups.detect { |group| group.declaration_locations.first[0].end_with?("_spec.rb") }
15
+ target_spec = spec_group.declaration_locations.first[0] if spec_group
16
+ end
11
17
  AffectedTests.checkpoint(target_spec)
12
18
  end
13
19
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AffectedTests
4
- VERSION = "0.8.0"
4
+ VERSION = "1.0.0"
5
5
  end
@@ -34,7 +34,7 @@ module AffectedTests
34
34
 
35
35
  module_function
36
36
 
37
- def setup(engine: :rotoscope, project_path:, test_dir_path:, output_path:, revision: nil)
37
+ def setup(engine: :coverage, project_path:, test_dir_path:, output_path:, revision: nil)
38
38
  @config = Configuration.new(
39
39
  project_path: project_path,
40
40
  output_path: output_path,
@@ -47,10 +47,6 @@ module AffectedTests
47
47
 
48
48
  def select_engine(engine)
49
49
  case engine
50
- when :rotoscope
51
- require "rotoscope"
52
- require "affected_tests/engine/rotoscope"
53
- AffectedTests::Engine::Rotoscope
54
50
  when :calleree
55
51
  require "calleree"
56
52
  require "affected_tests/engine/calleree"
data/mise.toml ADDED
@@ -0,0 +1,3 @@
1
+ [tools]
2
+ ruby = "4.0"
3
+ pinact = "latest"
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: affected_tests
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shia
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2022-09-23 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: Tool-kit for testing based on changed files.
14
13
  email:
@@ -17,9 +16,9 @@ executables: []
17
16
  extensions: []
18
17
  extra_rdoc_files: []
19
18
  files:
19
+ - ".rspec"
20
20
  - CODE_OF_CONDUCT.md
21
21
  - Gemfile
22
- - Gemfile.lock
23
22
  - LICENSE.txt
24
23
  - README.md
25
24
  - Rakefile
@@ -27,10 +26,10 @@ files:
27
26
  - lib/affected_tests/differ.rb
28
27
  - lib/affected_tests/engine/calleree.rb
29
28
  - lib/affected_tests/engine/coverage.rb
30
- - lib/affected_tests/engine/rotoscope.rb
31
29
  - lib/affected_tests/map_merger.rb
32
30
  - lib/affected_tests/rspec.rb
33
31
  - lib/affected_tests/version.rb
32
+ - mise.toml
34
33
  - scripts/calculate-target-tests
35
34
  - scripts/generate-diff-files-from-github
36
35
  homepage: https://github.com/riseshia/affected_tests
@@ -39,7 +38,6 @@ licenses:
39
38
  metadata:
40
39
  homepage_uri: https://github.com/riseshia/affected_tests
41
40
  source_code_uri: https://github.com/riseshia/affected_tests
42
- post_install_message:
43
41
  rdoc_options: []
44
42
  require_paths:
45
43
  - lib
@@ -54,8 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
54
52
  - !ruby/object:Gem::Version
55
53
  version: '0'
56
54
  requirements: []
57
- rubygems_version: 3.3.7
58
- signing_key:
55
+ rubygems_version: 4.0.16
59
56
  specification_version: 4
60
57
  summary: Tool-kit for testing based on changed files.
61
58
  test_files: []
data/Gemfile.lock DELETED
@@ -1,21 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- affected_tests (0.5.0)
5
- rotoscope
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- rake (13.0.6)
11
- rotoscope (0.3.0)
12
-
13
- PLATFORMS
14
- ruby
15
-
16
- DEPENDENCIES
17
- affected_tests!
18
- rake (~> 13.0)
19
-
20
- BUNDLED WITH
21
- 2.3.17
@@ -1,73 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module AffectedTests
4
- module Engine
5
- class Rotoscope
6
- def initialize(config)
7
- @config = config
8
-
9
- @rotoscope = ::Rotoscope.new do |call|
10
- next if self == call.receiver
11
-
12
- if call.caller_path && @config.target_path?(call.caller_path)
13
- buffer << call.caller_path
14
- end
15
- end
16
- @rotoscope.start_trace
17
- end
18
-
19
- def start_trace
20
- # Clear buffer
21
- buffer.clear
22
- end
23
-
24
- def stop_trace
25
- # do nothing
26
- end
27
-
28
- def tracing?
29
- @rotoscope.tracing?
30
- end
31
-
32
- def checkpoint(target_test_path)
33
- diff = buffer
34
- import(target_test_path, diff)
35
- buffer.clear
36
- end
37
-
38
- def import(target_test_path, result)
39
- all_related_paths = result.uniq.map do |caller_path|
40
- @config.format_path(caller_path)
41
- end
42
-
43
- formatted_target_test_path = @config.format_path(target_test_path)
44
-
45
- all_related_paths.each do |path|
46
- next if path.start_with?(@config.test_dir_path)
47
-
48
- if path != formatted_target_test_path
49
- add(formatted_target_test_path, path)
50
- end
51
- end
52
- end
53
-
54
- def add(caller, callee)
55
- cache[callee] ||= Set.new
56
- cache[callee].add(caller)
57
- end
58
-
59
- def buffer
60
- Thread.current[:buffer] ||= []
61
- end
62
-
63
- def cache
64
- Thread.current[:cache] ||= {}
65
- end
66
-
67
- def dump
68
- @rotoscope.stop_trace
69
- cache.transform_values(&:to_a)
70
- end
71
- end
72
- end
73
- end