testprune 0.1.0 → 0.2.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: d3484c32e59411fd94af756cfaec78df0a07c6ce0f7f7dfaf16cf82c6745d84f
4
- data.tar.gz: 47e74f078c45818060d393c08473a66275fd5a002e750a24ed02ca6b47d8f412
3
+ metadata.gz: b7bf54ed9c34296fa818e99f946ff10d003e20246d5e4271ea7afd080d4e6af9
4
+ data.tar.gz: 5da304b9575bd2feb2e1a59e16ebd21a85d45b165bf08bfe1504df06607b169a
5
5
  SHA512:
6
- metadata.gz: 0c9cc56ac84e87e994165c3abce1238a84924f3ecf980042ee876b0c0b6fa551021780d23a903494298f37bd248c546d1655c282285c98f6a2111ba37a9ab67b
7
- data.tar.gz: f6c4748cde9a7e89dbaaeb67cc609e8c17de9173b75c723d0f0c4f22f84e77034b52a51187233418778920ddec58953585942002b10771a8ce726201632522fd
6
+ metadata.gz: 15ddcc701c6981bce16ea78d9b9de586c1d1c991f4b23c1c05fcee62b9040f2d1578bd7d6315c2ddab3f9379dae47b9bd222b5f8a5758e81c7f28cb16aa1658f
7
+ data.tar.gz: 6e7a7622fa857a5dd36be377920d42b90e97231d5e87c89be82fe9d599b540bc83cbf0ce66d2633c9ce7a6a12598ef312787d65ca5c75b9b71b0c4b0bc63c243
data/lib/testprune/cli.rb CHANGED
@@ -9,6 +9,8 @@ module Testprune
9
9
  # report analyzes run.json and prints grouped candidates (read-only)
10
10
  # apply prompts for approval, then writes a removal patch (never edits in place)
11
11
  class CLI
12
+ NOISY_PATTERNS = %w[selenium request piper integration].freeze
13
+
12
14
  BANNER = <<~TXT
13
15
  testprune — audit a Ruby test suite for redundant coverage
14
16
 
@@ -90,10 +92,39 @@ module Testprune
90
92
 
91
93
  def cmd_run(argv)
92
94
  cmd_argv, test_command = split_test_command(argv)
93
- opts, = parse_options(cmd_argv)
95
+ opts, paths = parse_options(cmd_argv)
94
96
  apply_config(opts)
95
97
  require_relative 'runner'
96
- Runner.new(Testprune.config).call(test_command)
98
+ runner = Runner.new(Testprune.config)
99
+ if test_command.nil? && paths.empty?
100
+ test_command = prompt_noisy_exclusions(runner)
101
+ elsif test_command.nil?
102
+ test_command = runner.command_for_paths(paths)
103
+ end
104
+ runner.call(test_command)
105
+ end
106
+
107
+ def prompt_noisy_exclusions(runner)
108
+ test_dir = File.join(Testprune.config.root, 'test')
109
+ return nil unless File.directory?(test_dir)
110
+
111
+ all_subdirs = Dir.children(test_dir)
112
+ .select { |d| File.directory?(File.join(test_dir, d)) }
113
+ .sort
114
+ noisy = all_subdirs.select { |d| NOISY_PATTERNS.any? { |p| d.downcase.include?(p) } }
115
+ return nil if noisy.empty?
116
+
117
+ warn("testprune: found folders that may be slow or integration-heavy:")
118
+ noisy.each { |d| warn(" test/#{d}") }
119
+ $stderr.print("Include them in this run? [y/N]: ")
120
+ answer = $stdin.gets&.strip&.downcase
121
+
122
+ return nil if %w[y yes].include?(answer)
123
+
124
+ kept = (all_subdirs - noisy).map { |d| "test/#{d}" }
125
+ return nil if kept.empty?
126
+
127
+ runner.command_for_paths(kept)
97
128
  end
98
129
 
99
130
  def cmd_report(argv)
@@ -39,6 +39,18 @@ module Testprune
39
39
  ok
40
40
  end
41
41
 
42
+ def command_for_paths(paths)
43
+ bundler = File.exist?(File.join(@config.root, 'Gemfile'))
44
+ prefix = bundler ? %w[bundle exec] : []
45
+ if File.directory?(File.join(@config.root, 'spec'))
46
+ prefix + %w[rspec] + paths
47
+ elsif File.exist?(File.join(@config.root, 'bin', 'rails'))
48
+ prefix + %w[rails test] + paths
49
+ else
50
+ prefix + %w[rake test] + paths
51
+ end
52
+ end
53
+
42
54
  private
43
55
 
44
56
  def env
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Testprune
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testprune
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth MacPherson
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  - !ruby/object:Gem::Version
84
84
  version: '0'
85
85
  requirements: []
86
- rubygems_version: 3.6.9
86
+ rubygems_version: 4.0.3
87
87
  specification_version: 4
88
88
  summary: Audits a Ruby test suite for duplicate/redundant coverage using Prism AST
89
89
  + Coverage data