retest 2.3.0 → 2.5.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/.github/workflows/ci.yml +4 -1
- data/.gitignore +2 -1
- data/Gemfile +0 -3
- data/README.md +14 -21
- data/exe/retest +18 -13
- data/lib/retest/matching_options/path.rb +25 -4
- data/lib/retest/matching_options.rb +3 -3
- data/lib/retest/options.rb +97 -131
- data/lib/retest/output.rb +25 -0
- data/lib/retest/program.rb +15 -0
- data/lib/retest/repository.rb +14 -3
- data/lib/retest/runner.rb +3 -1
- data/lib/retest/version.rb +1 -1
- data/lib/retest.rb +1 -0
- data/retest.gemspec +4 -1
- metadata +51 -11
- data/Gemfile-3.4 +0 -8
- data/Gemfile-3.4.lock +0 -61
- data/Gemfile.lock +0 -51
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bec5345ea68a0b916e57d954a04f236f25d34d051ae1f73a6ab5aef60269a271
|
|
4
|
+
data.tar.gz: 7eceaf7914b3b8be86027fe0e16637051fe7e4a8d334b856cb070dc62e356d05
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d102ac7842a67f1bea01b9d2ba3e8d37623edb834a637b0937ff72808cafaa1f2fc64f7fc4d7330bf110190abfdc13fbfb870b15608286668c7c922d91257730
|
|
7
|
+
data.tar.gz: d5720c3eafe0493b705abb665021ec8d828fbbf17615bd6040af3b5258ce0a6aaa5cd87e2775c828b8b6d877c9c581fdf560b26647ea702298b1c9e89dfe567e
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -28,7 +28,7 @@ jobs:
|
|
|
28
28
|
- version: '3.2'
|
|
29
29
|
- version: '3.3'
|
|
30
30
|
- version: '3.4'
|
|
31
|
-
|
|
31
|
+
- version: '4.0'
|
|
32
32
|
name: Ruby ${{ matrix.ruby.version }} test (${{ matrix.os }})
|
|
33
33
|
env:
|
|
34
34
|
BUNDLE_GEMFILE: ${{ matrix.ruby.gemfile || 'Gemfile' }}
|
|
@@ -39,6 +39,9 @@ jobs:
|
|
|
39
39
|
with:
|
|
40
40
|
ruby-version: ${{ matrix.ruby.version }}
|
|
41
41
|
bundler-cache: true
|
|
42
|
+
- run: rm -f Gemfile.lock
|
|
43
|
+
- run: bundle config set deployment false
|
|
44
|
+
- run: bundle config
|
|
42
45
|
- run: bundle install
|
|
43
46
|
- run: bundle exec rake
|
|
44
47
|
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -58,17 +58,18 @@ Ready to refactor! You can make file changes now
|
|
|
58
58
|
Type interactive command and press enter. Enter 'h' for help.
|
|
59
59
|
> h
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
61
|
+
Commands:
|
|
62
|
+
<ENTER> Run last changed triggered command
|
|
63
|
+
h, help Show help
|
|
64
|
+
p, pause Pause Retest (tests won't run on file changes)
|
|
65
|
+
u, unpause Unpause Retest
|
|
66
|
+
ra, run all Run all tests
|
|
67
|
+
f, force Force a selection of tests to run on every file change
|
|
68
|
+
fb, force batch Force a selection of tests based on raw data list
|
|
69
|
+
r, reset Reset forced selection
|
|
70
|
+
d, diff [BRANCH] Run specs changed relative to a Git branch
|
|
71
|
+
c, clear Clear the window
|
|
72
|
+
e, exit Exit Retest
|
|
72
73
|
```
|
|
73
74
|
### **Supports Multiple Watchers**
|
|
74
75
|
Retest ships with [Listen](https://github.com/guard/listen) for file monitoring but can use the more performant [Watchexec](https://github.com/watchexec/watchexec) if installed.
|
|
@@ -90,10 +91,9 @@ retest 'bundle exec rails test <test>'
|
|
|
90
91
|
|
|
91
92
|
## ❤️ **Contributing**
|
|
92
93
|
|
|
93
|
-
Got feedback or ideas?
|
|
94
|
-
[Discussion - Retest V2.0 - Interactive Panel](https://github.com/AlexB52/retest/discussions/216)
|
|
94
|
+
Got feedback or ideas? [Start a new discussion](https://github.com/AlexB52/retest/discussions).
|
|
95
95
|
|
|
96
|
-
Bug reports and pull requests are welcome
|
|
96
|
+
Bug reports and pull requests are welcome.
|
|
97
97
|
|
|
98
98
|
## 🛠️ **Development**
|
|
99
99
|
|
|
@@ -115,13 +115,6 @@ Want to contribute to Retest? Follow these steps to set up your environment
|
|
|
115
115
|
|
|
116
116
|
Note, we squash all PRs and may edit commit messages for clarity or consistency.
|
|
117
117
|
|
|
118
|
-
## 🏁 Release
|
|
119
|
-
|
|
120
|
-
Ruby 3.4 requires to be bundled with Gemfile-3.4.
|
|
121
|
-
When creating a new version make sure to also bundle with 3.4
|
|
122
|
-
|
|
123
|
-
BUNDLE_GEMFILE=Gemfile-3.4 bundle install
|
|
124
|
-
|
|
125
118
|
## 📜 **License**
|
|
126
119
|
|
|
127
120
|
Retest is open-source and available under the [MIT License](https://opensource.org/licenses/MIT).
|
data/exe/retest
CHANGED
|
@@ -56,8 +56,7 @@ end
|
|
|
56
56
|
|
|
57
57
|
# === DIFF ACTION ===
|
|
58
58
|
if options.params[:diff]
|
|
59
|
-
program.diff(options.params[:diff])
|
|
60
|
-
return
|
|
59
|
+
exit program.diff(options.params[:diff])
|
|
61
60
|
end
|
|
62
61
|
|
|
63
62
|
# === LOGGING ===
|
|
@@ -112,6 +111,10 @@ def run_command(input:, program:)
|
|
|
112
111
|
filter: true, min: 1
|
|
113
112
|
)
|
|
114
113
|
program.run(nil, force_run: true)
|
|
114
|
+
when 'fb', 'force batch'
|
|
115
|
+
require 'tty-prompt'
|
|
116
|
+
prompt = TTY::Prompt.new
|
|
117
|
+
program.force_batch prompt.multiline("Enter list of test files to run").join
|
|
115
118
|
when ''
|
|
116
119
|
puts "Running last command: '#{program.last_command}'\n"
|
|
117
120
|
program.run_last_command
|
|
@@ -120,21 +123,23 @@ def run_command(input:, program:)
|
|
|
120
123
|
program.run_all
|
|
121
124
|
when /^di?f?f?\s(.*)$/
|
|
122
125
|
program.diff($1)
|
|
123
|
-
when 'c'
|
|
126
|
+
when 'c', 'clear'
|
|
124
127
|
program.clear_terminal
|
|
125
128
|
when 'h', 'help'
|
|
126
129
|
puts <<~HELP
|
|
127
130
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
131
|
+
Commands:
|
|
132
|
+
<ENTER> Run last changed triggered command
|
|
133
|
+
h, help Show help
|
|
134
|
+
p, pause Pause Retest (tests won't run on file changes)
|
|
135
|
+
u, unpause Unpause Retest
|
|
136
|
+
ra, run all Run all tests
|
|
137
|
+
f, force Force a selection of tests to run on every file change
|
|
138
|
+
fb, force batch Force a selection of tests based on raw data list
|
|
139
|
+
r, reset Reset forced selection
|
|
140
|
+
d, diff [BRANCH] Run specs changed relative to a Git branch
|
|
141
|
+
c, clear Clear the window
|
|
142
|
+
e, exit Exit Retest
|
|
138
143
|
HELP
|
|
139
144
|
else
|
|
140
145
|
puts "Unknown interactive command #{input}\n"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require 'forwardable'
|
|
2
|
+
require 'set'
|
|
2
3
|
|
|
3
4
|
module Retest
|
|
4
5
|
class MatchingOptions
|
|
@@ -12,6 +13,10 @@ module Retest
|
|
|
12
13
|
@pathname = Pathname(path)
|
|
13
14
|
end
|
|
14
15
|
|
|
16
|
+
def ==(other)
|
|
17
|
+
pathname == other.pathname
|
|
18
|
+
end
|
|
19
|
+
|
|
15
20
|
def reversed_dirnames
|
|
16
21
|
@reversed_dirnames ||= dirnames.reverse
|
|
17
22
|
end
|
|
@@ -28,14 +33,23 @@ module Retest
|
|
|
28
33
|
test_regexs.any? { |regex| regex =~ to_s }
|
|
29
34
|
end
|
|
30
35
|
|
|
31
|
-
def possible_test?(file)
|
|
32
|
-
|
|
36
|
+
def possible_test?(file, test_directories: nil)
|
|
37
|
+
if test?(test_directories: test_directories)
|
|
38
|
+
other = Path.new(file)
|
|
39
|
+
self == other || test_subset?(other)
|
|
40
|
+
else
|
|
41
|
+
possible_test_regexs.any? { |regex| regex =~ file }
|
|
42
|
+
end
|
|
33
43
|
end
|
|
34
44
|
|
|
35
45
|
def similarity_score(file)
|
|
36
46
|
String::Similarity.levenshtein(to_s, file)
|
|
37
47
|
end
|
|
38
48
|
|
|
49
|
+
def filename
|
|
50
|
+
basename(extname)
|
|
51
|
+
end
|
|
52
|
+
|
|
39
53
|
private
|
|
40
54
|
|
|
41
55
|
def test_regexs
|
|
@@ -52,8 +66,15 @@ module Retest
|
|
|
52
66
|
]
|
|
53
67
|
end
|
|
54
68
|
|
|
55
|
-
|
|
56
|
-
|
|
69
|
+
# This method checks whether the test file is included in the path of
|
|
70
|
+
# another test file
|
|
71
|
+
# Example: fixture_test.rb is included in test/valuation/fixture_test.rb
|
|
72
|
+
def test_subset?(other)
|
|
73
|
+
if dirnames == ['.']
|
|
74
|
+
filename == other.filename
|
|
75
|
+
else
|
|
76
|
+
filename == other.filename && Set.new(dirnames).subset?(Set.new(other.dirnames))
|
|
77
|
+
end
|
|
57
78
|
end
|
|
58
79
|
end
|
|
59
80
|
end
|
|
@@ -16,8 +16,8 @@ module Retest
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def filtered_results
|
|
19
|
-
if path.
|
|
20
|
-
[
|
|
19
|
+
if (test_file = possible_tests.find { |file| file == path.to_s })
|
|
20
|
+
[test_file]
|
|
21
21
|
elsif (screened_tests = screen_namespaces(possible_tests)).any?
|
|
22
22
|
screened_tests
|
|
23
23
|
else
|
|
@@ -29,7 +29,7 @@ module Retest
|
|
|
29
29
|
|
|
30
30
|
def possible_tests
|
|
31
31
|
@possible_tests ||= files
|
|
32
|
-
.select { |file| path.possible_test?(file) }
|
|
32
|
+
.select { |file| path.possible_test?(file, test_directories: test_directories) }
|
|
33
33
|
.sort_by { |file| [-path.similarity_score(file), file] }
|
|
34
34
|
.first(@limit)
|
|
35
35
|
end
|
data/lib/retest/options.rb
CHANGED
|
@@ -1,147 +1,49 @@
|
|
|
1
|
-
require '
|
|
1
|
+
require 'optparse'
|
|
2
2
|
|
|
3
3
|
module Retest
|
|
4
4
|
class Options
|
|
5
|
-
|
|
5
|
+
DEFAULT_PARAMS = {
|
|
6
|
+
all: false,
|
|
7
|
+
diff: nil,
|
|
8
|
+
exts: %w[rb],
|
|
9
|
+
help: false,
|
|
10
|
+
notify: false,
|
|
11
|
+
polling: false,
|
|
12
|
+
rake: false,
|
|
13
|
+
rails: false,
|
|
14
|
+
rspec: false,
|
|
15
|
+
ruby: false,
|
|
16
|
+
version: false,
|
|
17
|
+
watcher: nil,
|
|
18
|
+
command: nil
|
|
19
|
+
}.freeze
|
|
20
|
+
|
|
21
|
+
attr_reader :args, :params
|
|
6
22
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
command nil
|
|
11
|
-
|
|
12
|
-
desc "Watch a file change and run it matching spec."
|
|
13
|
-
|
|
14
|
-
example <<~EOS
|
|
15
|
-
Runs a matching rails test after a file change
|
|
16
|
-
$ retest 'bin/rails test <test>'
|
|
17
|
-
$ retest --rails
|
|
18
|
-
EOS
|
|
19
|
-
|
|
20
|
-
example <<~EOS
|
|
21
|
-
Runs rubocop and matching rails test after a file change
|
|
22
|
-
$ retest 'rubocop <changed> && bin/rails test <test>'
|
|
23
|
-
EOS
|
|
24
|
-
|
|
25
|
-
example <<~EOS
|
|
26
|
-
Runs all rails tests after a file change
|
|
27
|
-
$ retest 'bin/rails test'
|
|
28
|
-
$ retest --rails --all
|
|
29
|
-
EOS
|
|
30
|
-
|
|
31
|
-
example <<~EOS
|
|
32
|
-
Runs a hardcoded command after a file change
|
|
33
|
-
$ retest 'ruby lib/bottles_test.rb'
|
|
34
|
-
EOS
|
|
35
|
-
|
|
36
|
-
example <<~EOS
|
|
37
|
-
Let retest identify which command to run
|
|
38
|
-
$ retest
|
|
39
|
-
EOS
|
|
40
|
-
|
|
41
|
-
example <<~EOS
|
|
42
|
-
Let retest identify which command to run for all tests
|
|
43
|
-
$ retest --all
|
|
44
|
-
EOS
|
|
45
|
-
|
|
46
|
-
example <<~EOS
|
|
47
|
-
Run a sanity check on changed files from a branch
|
|
48
|
-
$ retest --diff main
|
|
49
|
-
$ retest --diff origin/main --rails
|
|
50
|
-
EOS
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
argument :command do
|
|
54
|
-
optional
|
|
55
|
-
desc <<~EOS
|
|
56
|
-
The test command to rerun when a file changes.
|
|
57
|
-
Use <test> or <changed> placeholders to tell retest where to reference the matching spec or the changed file in the command.
|
|
58
|
-
EOS
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
option :diff do
|
|
62
|
-
desc "Pipes all matching tests from diffed branch to test command"
|
|
63
|
-
long "--diff=git-branch"
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
option :exts do
|
|
67
|
-
desc "Comma separated of filenames extensions to filter to"
|
|
68
|
-
long "--exts=<EXTENSIONS>"
|
|
69
|
-
default "rb"
|
|
70
|
-
convert :list
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
option :watcher do
|
|
74
|
-
desc "Tool used to watch file events"
|
|
75
|
-
permit %i[listen watchexec]
|
|
76
|
-
long "--watcher=<WATCHER>"
|
|
77
|
-
short "-w"
|
|
78
|
-
convert :sym
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
flag :all do
|
|
82
|
-
long "--all"
|
|
83
|
-
desc "Run all the specs of a specificied ruby setup"
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
flag :notify do
|
|
87
|
-
long "--notify"
|
|
88
|
-
desc "Play a sound when specs pass or fail (macOS only)"
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
flag :help do
|
|
92
|
-
short "-h"
|
|
93
|
-
long "--help"
|
|
94
|
-
desc "Print usage"
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
flag :version do
|
|
98
|
-
short "-v"
|
|
99
|
-
long "--version"
|
|
100
|
-
desc "Print retest version"
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
option :polling do
|
|
104
|
-
long '--polling'
|
|
105
|
-
desc <<~DESC.strip
|
|
106
|
-
Use polling method when listening to file changes
|
|
107
|
-
Some filesystems won't work without it
|
|
108
|
-
VM/Vagrant Shared folders, NFS, Samba, sshfs...
|
|
109
|
-
DESC
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
flag :rspec do
|
|
113
|
-
long "--rspec"
|
|
114
|
-
desc "Shortcut for a standard RSpec setup"
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
flag :rake do
|
|
118
|
-
long "--rake"
|
|
119
|
-
desc "Shortcut for a standard Rake setup"
|
|
23
|
+
def self.command(args)
|
|
24
|
+
new(args).command
|
|
120
25
|
end
|
|
121
26
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
desc "Shortcut for a standard Rails setup"
|
|
27
|
+
def initialize(args = [])
|
|
28
|
+
self.args = args
|
|
125
29
|
end
|
|
126
30
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
31
|
+
def args=(args)
|
|
32
|
+
@args = args.dup
|
|
33
|
+
@params = DEFAULT_PARAMS.transform_values(&:dup)
|
|
34
|
+
parse(@args)
|
|
130
35
|
end
|
|
131
36
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
def self.command(args)
|
|
135
|
-
new(args).command
|
|
37
|
+
def help
|
|
38
|
+
parser.to_s
|
|
136
39
|
end
|
|
137
40
|
|
|
138
|
-
def
|
|
139
|
-
|
|
41
|
+
def command
|
|
42
|
+
params[:command]
|
|
140
43
|
end
|
|
141
44
|
|
|
142
|
-
def
|
|
143
|
-
|
|
144
|
-
parse args
|
|
45
|
+
def auto?
|
|
46
|
+
command.nil?
|
|
145
47
|
end
|
|
146
48
|
|
|
147
49
|
def help?
|
|
@@ -175,5 +77,69 @@ module Retest
|
|
|
175
77
|
def merge(options = [])
|
|
176
78
|
self.class.new(@args.dup.concat(options))
|
|
177
79
|
end
|
|
80
|
+
|
|
81
|
+
private
|
|
82
|
+
|
|
83
|
+
def parse(args)
|
|
84
|
+
remaining = args.dup
|
|
85
|
+
parser.parse!(remaining)
|
|
86
|
+
params[:command] = remaining.shift
|
|
87
|
+
raise OptionParser::InvalidArgument, remaining.join(' ') unless remaining.empty?
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def parser
|
|
91
|
+
OptionParser.new do |opts|
|
|
92
|
+
opts.banner = 'Usage: retest [options] [COMMAND]'
|
|
93
|
+
opts.separator <<~ARGUMENTS
|
|
94
|
+
|
|
95
|
+
Watch files and rerun matching tests when they change.
|
|
96
|
+
|
|
97
|
+
Arguments:
|
|
98
|
+
COMMAND Command to rerun when a file changes.
|
|
99
|
+
Use <test> for the matching test file and
|
|
100
|
+
<changed> for the changed file.
|
|
101
|
+
|
|
102
|
+
ARGUMENTS
|
|
103
|
+
opts.separator 'Options:'
|
|
104
|
+
opts.on('--all', 'Run the full test suite for the selected setup') { params[:all] = true }
|
|
105
|
+
opts.on('--diff BRANCH', 'Run tests matching files changed from BRANCH') { |value| params[:diff] = value }
|
|
106
|
+
opts.on('--exts EXTENSIONS', 'Comma-separated file extensions to watch (default: rb)'){ |value| params[:exts] = parse_extensions(value) }
|
|
107
|
+
opts.on('-h', '--help', 'Show this help') { params[:help] = true }
|
|
108
|
+
opts.on('--notify', 'Play a sound when tests pass or fail (macOS only)') { params[:notify] = true }
|
|
109
|
+
opts.on('--polling', 'Use polling for file watching') { params[:polling] = true } #Some filesystems won't work without it VM/Vagrant Shared folders, NFS, Samba, sshfs...
|
|
110
|
+
opts.on('--rails', 'Use the standard Rails test command') { params[:rails] = true }
|
|
111
|
+
opts.on('--rake', 'Use the standard Rake test command') { params[:rake] = true }
|
|
112
|
+
opts.on('--rspec', 'Use the standard RSpec test command') { params[:rspec] = true }
|
|
113
|
+
opts.on('--ruby', 'Use the standard Ruby test command') { params[:ruby] = true }
|
|
114
|
+
opts.on('-v', '--version', 'Show retest version') { params[:version] = true }
|
|
115
|
+
opts.on('-w', '--watcher WATCHER', %w[listen watchexec], 'File watcher to use (listen or watchexec)') { |value| params[:watcher] = value.to_sym }
|
|
116
|
+
|
|
117
|
+
opts.separator <<~EXAMPLES
|
|
118
|
+
|
|
119
|
+
Examples:
|
|
120
|
+
$ retest
|
|
121
|
+
Auto-detect the project setup and rerun matching tests
|
|
122
|
+
|
|
123
|
+
$ retest --all
|
|
124
|
+
Auto-detect the project setup and run the full suite
|
|
125
|
+
|
|
126
|
+
$ retest --rails
|
|
127
|
+
Use the standard Rails test command
|
|
128
|
+
|
|
129
|
+
$ retest 'bin/rails test <test>'
|
|
130
|
+
Rerun the matching Rails test file
|
|
131
|
+
|
|
132
|
+
$ retest 'rubocop <changed> && bin/rails test <test>'
|
|
133
|
+
Run a check on the changed file, then run the matching test
|
|
134
|
+
|
|
135
|
+
$ retest --diff main
|
|
136
|
+
Run tests matching files changed from main
|
|
137
|
+
EXAMPLES
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def parse_extensions(value)
|
|
142
|
+
value.split(',').map(&:strip).reject(&:empty?)
|
|
143
|
+
end
|
|
178
144
|
end
|
|
179
|
-
end
|
|
145
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Retest
|
|
2
|
+
# This library formats output messages displayed to the user
|
|
3
|
+
module Output
|
|
4
|
+
module_function
|
|
5
|
+
|
|
6
|
+
# This method formats the force batch search failures and prints it to IO if
|
|
7
|
+
# passed in or returns the message otherwise.
|
|
8
|
+
def force_batch_failures(paths, out: nil)
|
|
9
|
+
return unless paths&.any?
|
|
10
|
+
|
|
11
|
+
output = "\n"
|
|
12
|
+
output += "Retest could not find matching tests for these inputs:\n"
|
|
13
|
+
paths.each do |invalid_path|
|
|
14
|
+
output += " - #{invalid_path}\n"
|
|
15
|
+
end
|
|
16
|
+
output += "\n"
|
|
17
|
+
|
|
18
|
+
if out
|
|
19
|
+
out.puts output
|
|
20
|
+
else
|
|
21
|
+
output
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
data/lib/retest/program.rb
CHANGED
|
@@ -54,6 +54,21 @@ module Retest
|
|
|
54
54
|
runner.run_all
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
+
def force_batch(multiline_input)
|
|
58
|
+
failures, successes = repository
|
|
59
|
+
.search_tests(multiline_input.split(/\s+/))
|
|
60
|
+
.partition { |k,v| v.nil? }
|
|
61
|
+
|
|
62
|
+
Output.force_batch_failures(failures.map(&:first), out: @stdout)
|
|
63
|
+
|
|
64
|
+
if (successes = successes.to_h).empty?
|
|
65
|
+
@stdout.puts "No test files found"
|
|
66
|
+
else
|
|
67
|
+
force_selection(successes.values.uniq.compact.sort)
|
|
68
|
+
run(nil, force_run: true)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
57
72
|
def clear_terminal
|
|
58
73
|
system('clear 2>/dev/null') || system('cls 2>/dev/null')
|
|
59
74
|
end
|
data/lib/retest/repository.rb
CHANGED
|
@@ -23,14 +23,25 @@ module Retest
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def find_tests(paths)
|
|
26
|
-
paths
|
|
27
|
-
.
|
|
28
|
-
.map { |path| find_test(path) }
|
|
26
|
+
search_tests(paths)
|
|
27
|
+
.values
|
|
29
28
|
.compact
|
|
30
29
|
.uniq
|
|
31
30
|
.sort
|
|
32
31
|
end
|
|
33
32
|
|
|
33
|
+
def search_tests(paths)
|
|
34
|
+
result = {}
|
|
35
|
+
ruby_files = paths.select { |path| path.end_with?('.rb') }
|
|
36
|
+
|
|
37
|
+
ruby_files.each do |path|
|
|
38
|
+
result[path] ||= find_test(path)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
result
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
|
|
34
45
|
def test_files
|
|
35
46
|
files.select { |file| MatchingOptions::Path.new(file).test? }
|
|
36
47
|
end
|
data/lib/retest/runner.rb
CHANGED
|
@@ -101,9 +101,11 @@ module Retest
|
|
|
101
101
|
@pid = spawn(command)
|
|
102
102
|
Process.wait
|
|
103
103
|
@pid = nil
|
|
104
|
-
|
|
104
|
+
exit_status = $?.exitstatus
|
|
105
|
+
result = exit_status&.zero? ? :tests_pass : :tests_fail
|
|
105
106
|
changed
|
|
106
107
|
notify_observers(result)
|
|
108
|
+
exit_status
|
|
107
109
|
end
|
|
108
110
|
|
|
109
111
|
def log(message)
|
data/lib/retest/version.rb
CHANGED
data/lib/retest.rb
CHANGED
data/retest.gemspec
CHANGED
|
@@ -27,7 +27,10 @@ Gem::Specification.new do |spec|
|
|
|
27
27
|
spec.require_paths = ["lib"]
|
|
28
28
|
spec.add_runtime_dependency "string-similarity", ["~> 2.1"]
|
|
29
29
|
spec.add_runtime_dependency "listen", ["~> 3.9"]
|
|
30
|
-
spec.add_runtime_dependency "tty-option", ["~> 0.1"]
|
|
31
30
|
spec.add_runtime_dependency "tty-prompt", ["~> 0.1"]
|
|
32
31
|
spec.add_runtime_dependency "observer", ["~> 0.1"]
|
|
32
|
+
spec.add_runtime_dependency "logger", ["~> 1.7"]
|
|
33
|
+
spec.add_development_dependency "minitest", ["~> 5.0"]
|
|
34
|
+
spec.add_development_dependency "rake", ["~> 13.0"]
|
|
35
|
+
spec.add_development_dependency "byebug", ["~> 11.1"]
|
|
33
36
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: retest
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alexandre Barret
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: string-similarity
|
|
@@ -38,7 +38,7 @@ dependencies:
|
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
39
|
version: '3.9'
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
|
-
name: tty-
|
|
41
|
+
name: tty-prompt
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
|
43
43
|
requirements:
|
|
44
44
|
- - "~>"
|
|
@@ -52,7 +52,7 @@ dependencies:
|
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
53
|
version: '0.1'
|
|
54
54
|
- !ruby/object:Gem::Dependency
|
|
55
|
-
name:
|
|
55
|
+
name: observer
|
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
|
57
57
|
requirements:
|
|
58
58
|
- - "~>"
|
|
@@ -66,19 +66,61 @@ dependencies:
|
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
67
|
version: '0.1'
|
|
68
68
|
- !ruby/object:Gem::Dependency
|
|
69
|
-
name:
|
|
69
|
+
name: logger
|
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
|
71
71
|
requirements:
|
|
72
72
|
- - "~>"
|
|
73
73
|
- !ruby/object:Gem::Version
|
|
74
|
-
version: '
|
|
74
|
+
version: '1.7'
|
|
75
75
|
type: :runtime
|
|
76
76
|
prerelease: false
|
|
77
77
|
version_requirements: !ruby/object:Gem::Requirement
|
|
78
78
|
requirements:
|
|
79
79
|
- - "~>"
|
|
80
80
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: '
|
|
81
|
+
version: '1.7'
|
|
82
|
+
- !ruby/object:Gem::Dependency
|
|
83
|
+
name: minitest
|
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - "~>"
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '5.0'
|
|
89
|
+
type: :development
|
|
90
|
+
prerelease: false
|
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - "~>"
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: '5.0'
|
|
96
|
+
- !ruby/object:Gem::Dependency
|
|
97
|
+
name: rake
|
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
|
99
|
+
requirements:
|
|
100
|
+
- - "~>"
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
version: '13.0'
|
|
103
|
+
type: :development
|
|
104
|
+
prerelease: false
|
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
106
|
+
requirements:
|
|
107
|
+
- - "~>"
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '13.0'
|
|
110
|
+
- !ruby/object:Gem::Dependency
|
|
111
|
+
name: byebug
|
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
|
113
|
+
requirements:
|
|
114
|
+
- - "~>"
|
|
115
|
+
- !ruby/object:Gem::Version
|
|
116
|
+
version: '11.1'
|
|
117
|
+
type: :development
|
|
118
|
+
prerelease: false
|
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
120
|
+
requirements:
|
|
121
|
+
- - "~>"
|
|
122
|
+
- !ruby/object:Gem::Version
|
|
123
|
+
version: '11.1'
|
|
82
124
|
email:
|
|
83
125
|
- alex@abletech.nz
|
|
84
126
|
executables:
|
|
@@ -90,9 +132,6 @@ files:
|
|
|
90
132
|
- ".github/workflows/ci.yml"
|
|
91
133
|
- ".gitignore"
|
|
92
134
|
- Gemfile
|
|
93
|
-
- Gemfile-3.4
|
|
94
|
-
- Gemfile-3.4.lock
|
|
95
|
-
- Gemfile.lock
|
|
96
135
|
- LICENSE.txt
|
|
97
136
|
- README.md
|
|
98
137
|
- README/demo.gif
|
|
@@ -126,6 +165,7 @@ files:
|
|
|
126
165
|
- lib/retest/matching_options.rb
|
|
127
166
|
- lib/retest/matching_options/path.rb
|
|
128
167
|
- lib/retest/options.rb
|
|
168
|
+
- lib/retest/output.rb
|
|
129
169
|
- lib/retest/program.rb
|
|
130
170
|
- lib/retest/program/forced_selection.rb
|
|
131
171
|
- lib/retest/program/pausable.rb
|
|
@@ -162,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
162
202
|
- !ruby/object:Gem::Version
|
|
163
203
|
version: '0'
|
|
164
204
|
requirements: []
|
|
165
|
-
rubygems_version:
|
|
205
|
+
rubygems_version: 4.0.14
|
|
166
206
|
specification_version: 4
|
|
167
207
|
summary: A simple command line tool to watch file change and run its matching spec.
|
|
168
208
|
test_files: []
|
data/Gemfile-3.4
DELETED
data/Gemfile-3.4.lock
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: .
|
|
3
|
-
specs:
|
|
4
|
-
retest (2.3.0)
|
|
5
|
-
listen (~> 3.9)
|
|
6
|
-
observer (~> 0.1)
|
|
7
|
-
string-similarity (~> 2.1)
|
|
8
|
-
tty-option (~> 0.1)
|
|
9
|
-
tty-prompt (~> 0.1)
|
|
10
|
-
|
|
11
|
-
GEM
|
|
12
|
-
remote: https://rubygems.org/
|
|
13
|
-
specs:
|
|
14
|
-
byebug (11.1.3)
|
|
15
|
-
ffi (1.17.2)
|
|
16
|
-
listen (3.9.0)
|
|
17
|
-
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
18
|
-
rb-inotify (~> 0.9, >= 0.9.10)
|
|
19
|
-
minitest (5.25.5)
|
|
20
|
-
observer (0.1.2)
|
|
21
|
-
pastel (0.8.0)
|
|
22
|
-
tty-color (~> 0.5)
|
|
23
|
-
rake (13.2.1)
|
|
24
|
-
rb-fsevent (0.11.2)
|
|
25
|
-
rb-inotify (0.11.1)
|
|
26
|
-
ffi (~> 1.0)
|
|
27
|
-
string-similarity (2.1.0)
|
|
28
|
-
tty-color (0.6.0)
|
|
29
|
-
tty-cursor (0.7.1)
|
|
30
|
-
tty-option (0.3.0)
|
|
31
|
-
tty-prompt (0.23.1)
|
|
32
|
-
pastel (~> 0.8)
|
|
33
|
-
tty-reader (~> 0.8)
|
|
34
|
-
tty-reader (0.9.0)
|
|
35
|
-
tty-cursor (~> 0.7)
|
|
36
|
-
tty-screen (~> 0.8)
|
|
37
|
-
wisper (~> 2.0)
|
|
38
|
-
tty-screen (0.8.2)
|
|
39
|
-
wisper (2.0.1)
|
|
40
|
-
|
|
41
|
-
PLATFORMS
|
|
42
|
-
aarch64-linux
|
|
43
|
-
aarch64-linux-musl
|
|
44
|
-
arm-linux
|
|
45
|
-
arm-linux-musl
|
|
46
|
-
arm64-darwin
|
|
47
|
-
ruby
|
|
48
|
-
x86-linux
|
|
49
|
-
x86-linux-musl
|
|
50
|
-
x86_64-darwin
|
|
51
|
-
x86_64-linux
|
|
52
|
-
x86_64-linux-musl
|
|
53
|
-
|
|
54
|
-
DEPENDENCIES
|
|
55
|
-
byebug
|
|
56
|
-
minitest (~> 5.0)
|
|
57
|
-
rake (~> 13.0)
|
|
58
|
-
retest!
|
|
59
|
-
|
|
60
|
-
BUNDLED WITH
|
|
61
|
-
2.6.6
|
data/Gemfile.lock
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: .
|
|
3
|
-
specs:
|
|
4
|
-
retest (2.3.0)
|
|
5
|
-
listen (~> 3.9)
|
|
6
|
-
observer (~> 0.1)
|
|
7
|
-
string-similarity (~> 2.1)
|
|
8
|
-
tty-option (~> 0.1)
|
|
9
|
-
tty-prompt (~> 0.1)
|
|
10
|
-
|
|
11
|
-
GEM
|
|
12
|
-
remote: https://rubygems.org/
|
|
13
|
-
specs:
|
|
14
|
-
byebug (11.1.3)
|
|
15
|
-
ffi (1.17.2)
|
|
16
|
-
listen (3.9.0)
|
|
17
|
-
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
18
|
-
rb-inotify (~> 0.9, >= 0.9.10)
|
|
19
|
-
minitest (5.15.0)
|
|
20
|
-
observer (0.1.2)
|
|
21
|
-
pastel (0.8.0)
|
|
22
|
-
tty-color (~> 0.5)
|
|
23
|
-
rake (13.0.6)
|
|
24
|
-
rb-fsevent (0.11.2)
|
|
25
|
-
rb-inotify (0.11.1)
|
|
26
|
-
ffi (~> 1.0)
|
|
27
|
-
string-similarity (2.1.0)
|
|
28
|
-
tty-color (0.6.0)
|
|
29
|
-
tty-cursor (0.7.1)
|
|
30
|
-
tty-option (0.3.0)
|
|
31
|
-
tty-prompt (0.23.1)
|
|
32
|
-
pastel (~> 0.8)
|
|
33
|
-
tty-reader (~> 0.8)
|
|
34
|
-
tty-reader (0.9.0)
|
|
35
|
-
tty-cursor (~> 0.7)
|
|
36
|
-
tty-screen (~> 0.8)
|
|
37
|
-
wisper (~> 2.0)
|
|
38
|
-
tty-screen (0.8.2)
|
|
39
|
-
wisper (2.0.1)
|
|
40
|
-
|
|
41
|
-
PLATFORMS
|
|
42
|
-
ruby
|
|
43
|
-
|
|
44
|
-
DEPENDENCIES
|
|
45
|
-
byebug
|
|
46
|
-
minitest (~> 5.0)
|
|
47
|
-
rake (~> 13.0)
|
|
48
|
-
retest!
|
|
49
|
-
|
|
50
|
-
BUNDLED WITH
|
|
51
|
-
2.3.27
|