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 +4 -4
- data/lib/testprune/cli.rb +33 -2
- data/lib/testprune/runner.rb +12 -0
- data/lib/testprune/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b7bf54ed9c34296fa818e99f946ff10d003e20246d5e4271ea7afd080d4e6af9
|
|
4
|
+
data.tar.gz: 5da304b9575bd2feb2e1a59e16ebd21a85d45b165bf08bfe1504df06607b169a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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)
|
|
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)
|
data/lib/testprune/runner.rb
CHANGED
|
@@ -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
|
data/lib/testprune/version.rb
CHANGED
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.
|
|
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:
|
|
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
|