retest 2.3.0 → 2.4.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: 0e1f85f23a2480aa8ba17ec5a43cd3a4f00011908376b94be4d75d5c5c413c93
4
- data.tar.gz: 20e98b0513e9b708cecfd1644feb0d3a9d61f858bc26bc3e9a48385f1e74186a
3
+ metadata.gz: ddcd17a0606fa3fd4fc58ea7b6ac625f6eb441b05e7f6ee5e219d4e5c4772ada
4
+ data.tar.gz: 1230ff83093919562a6a15a49889ebc26711d23e8270341b9032e8d8772ea929
5
5
  SHA512:
6
- metadata.gz: 016afcce2763dcfd44072a809fc4e7c18c8eec08622882a4214ad82babe554f8df864c156dd21bef2342ab993558ce06c33e56498f3bb9e544a04ac339b9a6bc
7
- data.tar.gz: 83f58964d34d1e3a4d1bdd8477e941c6fa67ec700c39fddd98a371dfc501de2eea1a4d57861a0d3476638e60dce7b350b37e54c5dd4a7d3b5971e36eb7df63ec
6
+ metadata.gz: 6b647c571bc496405e43719a26820f58d12220724e2d772daee4ceeeb4dfdafdeecb116d9e156907ed1a8870804ee076480fcc757cfec01073bec8e60d180edf
7
+ data.tar.gz: f5e52d42d5dd8f23f4a29a8eddebfb421d8398bf31fb991ab3f9ab07e420ec828df7173677552765c4b6da734cbe1a45ee5e5593c8277ccd5e5970e56e824be3
@@ -28,7 +28,6 @@ jobs:
28
28
  - version: '3.2'
29
29
  - version: '3.3'
30
30
  - version: '3.4'
31
- gemfile: Gemfile-3.4
32
31
  name: Ruby ${{ matrix.ruby.version }} test (${{ matrix.os }})
33
32
  env:
34
33
  BUNDLE_GEMFILE: ${{ matrix.ruby.gemfile || 'Gemfile' }}
@@ -39,6 +38,9 @@ jobs:
39
38
  with:
40
39
  ruby-version: ${{ matrix.ruby.version }}
41
40
  bundler-cache: true
41
+ - run: rm -f Gemfile.lock
42
+ - run: bundle config set deployment false
43
+ - run: bundle config
42
44
  - run: bundle install
43
45
  - run: bundle exec rake
44
46
 
data/.gitignore CHANGED
@@ -8,4 +8,5 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  .ruby-version
11
- *.DS_Store
11
+ *.DS_Store
12
+ Gemfile.lock
data/Gemfile CHANGED
@@ -3,6 +3,3 @@ source "https://rubygems.org"
3
3
  # Specify your gem's dependencies in retest.gemspec
4
4
  gemspec
5
5
 
6
- gem "rake", "~> 13.0"
7
- gem "minitest", "~> 5.0"
8
- gem "byebug", require: false
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
- * 'h', 'help' # Prints help.
62
- * 'p', 'pause' # Pauses Retest. Tests aren't run on file change events until unpaused.
63
- * 'u', 'unpause' # Unpauses Retest.
64
- * <ENTER> # Runs last changed triggered command.
65
- * 'ra, 'run all' # Runs all tests.
66
- * 'f', 'force' # Forces a selection of test to run on every file change.
67
- * 'r', 'reset' # Disables forced selection.
68
- * 'd', 'diff' [GIT BRANCH] # Runs matching specs that changed from a target branch.
69
- * 'c' # Clears window.
70
- * 'e', 'exit' # Exits Retest.
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? Join the discussion for Retest 2.0 and share your thoughts:
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 at [GitHub](https://github.com/alexb52/retest).
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
@@ -112,6 +112,10 @@ def run_command(input:, program:)
112
112
  filter: true, min: 1
113
113
  )
114
114
  program.run(nil, force_run: true)
115
+ when 'fb', 'force batch'
116
+ require 'tty-prompt'
117
+ prompt = TTY::Prompt.new
118
+ program.force_batch prompt.multiline("Enter list of test files to run").join
115
119
  when ''
116
120
  puts "Running last command: '#{program.last_command}'\n"
117
121
  program.run_last_command
@@ -120,21 +124,23 @@ def run_command(input:, program:)
120
124
  program.run_all
121
125
  when /^di?f?f?\s(.*)$/
122
126
  program.diff($1)
123
- when 'c'
127
+ when 'c', 'clear'
124
128
  program.clear_terminal
125
129
  when 'h', 'help'
126
130
  puts <<~HELP
127
131
 
128
- * 'h', 'help' # Prints help.
129
- * 'p', 'pause' # Pauses Retest. Tests aren't run on file change events until unpaused.
130
- * 'u', 'unpause' # Unpauses Retest.
131
- * <ENTER> # Runs last changed triggered command.
132
- * 'ra, 'run all' # Runs all tests.
133
- * 'f', 'force' # Forces a selection of test to run on every file change.
134
- * 'r', 'reset' # Disables forced selection.
135
- * 'd', 'diff' [GIT BRANCH] # Runs matching specs that changed from a target branch.
136
- * 'c' # Clears window.
137
- * 'e', 'exit' # Exits Retest.
132
+ Commands:
133
+ <ENTER> Run last changed triggered command
134
+ h, help Show help
135
+ p, pause Pause Retest (tests won't run on file changes)
136
+ u, unpause Unpause Retest
137
+ ra, run all Run all tests
138
+ f, force Force a selection of tests to run on every file change
139
+ fb, force batch Force a selection of tests based on raw data list
140
+ r, reset Reset forced selection
141
+ d, diff [BRANCH] Run specs changed relative to a Git branch
142
+ c, clear Clear the window
143
+ e, exit Exit Retest
138
144
  HELP
139
145
  else
140
146
  puts "Unknown interactive command #{input}\n"
@@ -12,6 +12,10 @@ module Retest
12
12
  @pathname = Pathname(path)
13
13
  end
14
14
 
15
+ def ==(other)
16
+ pathname == other.pathname
17
+ end
18
+
15
19
  def reversed_dirnames
16
20
  @reversed_dirnames ||= dirnames.reverse
17
21
  end
@@ -28,14 +32,23 @@ module Retest
28
32
  test_regexs.any? { |regex| regex =~ to_s }
29
33
  end
30
34
 
31
- def possible_test?(file)
32
- possible_test_regexs.any? { |regex| regex =~ file }
35
+ def possible_test?(file, test_directories: nil)
36
+ if test?(test_directories: test_directories)
37
+ other = Path.new(file)
38
+ self == other || test_subset?(other)
39
+ else
40
+ possible_test_regexs.any? { |regex| regex =~ file }
41
+ end
33
42
  end
34
43
 
35
44
  def similarity_score(file)
36
45
  String::Similarity.levenshtein(to_s, file)
37
46
  end
38
47
 
48
+ def filename
49
+ basename(extname)
50
+ end
51
+
39
52
  private
40
53
 
41
54
  def test_regexs
@@ -52,8 +65,15 @@ module Retest
52
65
  ]
53
66
  end
54
67
 
55
- def filename
56
- basename(extname)
68
+ # This method checks whether the test file is included in the path of
69
+ # another test file
70
+ # Example: fixture_test.rb is included in test/valuation/fixture_test.rb
71
+ def test_subset?(other)
72
+ if dirnames == ['.']
73
+ filename == other.filename
74
+ else
75
+ filename == other.filename && Set.new(dirnames).subset?(Set.new(other.dirnames))
76
+ end
57
77
  end
58
78
  end
59
79
  end
@@ -16,8 +16,8 @@ module Retest
16
16
  end
17
17
 
18
18
  def filtered_results
19
- if path.test?(test_directories: test_directories)
20
- [path]
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
@@ -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
@@ -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
@@ -23,14 +23,25 @@ module Retest
23
23
  end
24
24
 
25
25
  def find_tests(paths)
26
- paths
27
- .select { |path| Regexp.new("\.rb$") =~ path }
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
@@ -1,3 +1,3 @@
1
1
  module Retest
2
- VERSION = "2.3.0"
2
+ VERSION = "2.4.0"
3
3
  end
data/lib/retest.rb CHANGED
@@ -14,6 +14,7 @@ require "retest/program"
14
14
  require "retest/prompt"
15
15
  require "retest/sounds"
16
16
  require "retest/watcher"
17
+ require "retest/output"
17
18
 
18
19
  module Retest
19
20
  class Error < StandardError; end
data/retest.gemspec CHANGED
@@ -30,4 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.add_runtime_dependency "tty-option", ["~> 0.1"]
31
31
  spec.add_runtime_dependency "tty-prompt", ["~> 0.1"]
32
32
  spec.add_runtime_dependency "observer", ["~> 0.1"]
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,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: retest
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandre Barret
8
+ autorequire:
8
9
  bindir: exe
9
10
  cert_chain: []
10
- date: 2025-05-23 00:00:00.000000000 Z
11
+ date: 2025-08-20 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: string-similarity
@@ -79,6 +80,49 @@ dependencies:
79
80
  - - "~>"
80
81
  - !ruby/object:Gem::Version
81
82
  version: '0.1'
83
+ - !ruby/object:Gem::Dependency
84
+ name: minitest
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '5.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '5.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '13.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '13.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: byebug
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '11.1'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '11.1'
125
+ description:
82
126
  email:
83
127
  - alex@abletech.nz
84
128
  executables:
@@ -90,9 +134,6 @@ files:
90
134
  - ".github/workflows/ci.yml"
91
135
  - ".gitignore"
92
136
  - Gemfile
93
- - Gemfile-3.4
94
- - Gemfile-3.4.lock
95
- - Gemfile.lock
96
137
  - LICENSE.txt
97
138
  - README.md
98
139
  - README/demo.gif
@@ -126,6 +167,7 @@ files:
126
167
  - lib/retest/matching_options.rb
127
168
  - lib/retest/matching_options/path.rb
128
169
  - lib/retest/options.rb
170
+ - lib/retest/output.rb
129
171
  - lib/retest/program.rb
130
172
  - lib/retest/program/forced_selection.rb
131
173
  - lib/retest/program/pausable.rb
@@ -148,6 +190,7 @@ licenses:
148
190
  metadata:
149
191
  homepage_uri: https://github.com/AlexB52/retest
150
192
  source_code_uri: https://github.com/AlexB52/retest
193
+ post_install_message:
151
194
  rdoc_options: []
152
195
  require_paths:
153
196
  - lib
@@ -162,7 +205,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
205
  - !ruby/object:Gem::Version
163
206
  version: '0'
164
207
  requirements: []
165
- rubygems_version: 3.6.2
208
+ rubygems_version: 3.5.22
209
+ signing_key:
166
210
  specification_version: 4
167
211
  summary: A simple command line tool to watch file change and run its matching spec.
168
212
  test_files: []
data/Gemfile-3.4 DELETED
@@ -1,8 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in retest.gemspec
4
- gemspec
5
-
6
- gem "rake", "~> 13.0"
7
- gem "minitest", "~> 5.0"
8
- gem "byebug", require: false
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