retest 2.2.2 → 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: e3c873cec57f9fc325d7b69a04910bc00014af31c4e065c9aa978751a4828f20
4
- data.tar.gz: 2bbbb2031a9f0833ae37b954349d7134b8e2b4d3b6aa50b7b2edcfdd0b08e357
3
+ metadata.gz: ddcd17a0606fa3fd4fc58ea7b6ac625f6eb441b05e7f6ee5e219d4e5c4772ada
4
+ data.tar.gz: 1230ff83093919562a6a15a49889ebc26711d23e8270341b9032e8d8772ea929
5
5
  SHA512:
6
- metadata.gz: 1c389288c74f66002ff5862d081dc116687748360cfd4e8df04cd5a2e3e462b58ba253a39923a6d625775ba9fd123a2866901517ee58bd12f07769a1d8799e52
7
- data.tar.gz: d6a80bca3f44cbe7ecd46d6bbcc72d237060b5e9eca7253f5b0579b72de0e20c59cacd083440597c90e72606ec36bd2c61b4bda6b4b6c6192a8a2d7b586f423a
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,19 +91,29 @@ 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
 
100
100
  Want to contribute to Retest? Follow these steps to set up your environment
101
101
 
102
102
  1. Clone the repo and install dependencies: `bin/setup`
103
- 2. Run tests to ensure everything is working: `rake test`
104
- 3. Experiment with an interactive console: `bin/console`
105
- 4. To run integration tests (e.g., for a Hanami app): `bin/test/hanami-app`
103
+ 2. Experiment with an interactive console: `bin/console`
104
+ 3. Run retest with local changes applied: `bin/debug`
105
+ 4. Run tests to ensure everything is working: `rake test`
106
+ 5. To run integration tests:
107
+ * bundler-app: `bin/test/bundler-app`
108
+ * git-ruby: `bin/test/git-ruby`
109
+ * hanami-app: `bin/test/hanami-app`
110
+ * rails-app: `bin/test/rails-app`
111
+ * rspec-rails: `bin/test/rspec-rails`
112
+ * rspec-ruby: `bin/test/rspec-ruby`
113
+ * ruby-app: `bin/test/ruby-app`
114
+ * ruby-bare: `bin/test/ruby-bare`
115
+
116
+ Note, we squash all PRs and may edit commit messages for clarity or consistency.
106
117
 
107
118
  ## 📜 **License**
108
119
 
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
data/lib/retest/prompt.rb CHANGED
@@ -37,9 +37,8 @@ module Retest
37
37
  private
38
38
 
39
39
  def options(files, blank_option: 'none')
40
- result = {}
40
+ result = { blank_option => nil } # blank option first
41
41
  files.each { |file| result[file] = file }
42
- result[blank_option] = nil # blank option last
43
42
  result
44
43
  end
45
44
 
@@ -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.2.2"
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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: retest
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandre Barret
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-04-12 00:00:00.000000000 Z
11
+ date: 2025-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: string-similarity
@@ -80,6 +80,48 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
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'
83
125
  description:
84
126
  email:
85
127
  - alex@abletech.nz
@@ -92,9 +134,6 @@ files:
92
134
  - ".github/workflows/ci.yml"
93
135
  - ".gitignore"
94
136
  - Gemfile
95
- - Gemfile-3.4
96
- - Gemfile-3.4.lock
97
- - Gemfile.lock
98
137
  - LICENSE.txt
99
138
  - README.md
100
139
  - README/demo.gif
@@ -128,6 +167,7 @@ files:
128
167
  - lib/retest/matching_options.rb
129
168
  - lib/retest/matching_options/path.rb
130
169
  - lib/retest/options.rb
170
+ - lib/retest/output.rb
131
171
  - lib/retest/program.rb
132
172
  - lib/retest/program/forced_selection.rb
133
173
  - lib/retest/program/pausable.rb
@@ -165,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
205
  - !ruby/object:Gem::Version
166
206
  version: '0'
167
207
  requirements: []
168
- rubygems_version: 3.4.14
208
+ rubygems_version: 3.5.22
169
209
  signing_key:
170
210
  specification_version: 4
171
211
  summary: A simple command line tool to watch file change and run its matching spec.
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,71 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- retest (2.2.1)
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.1)
16
- ffi (1.17.1-aarch64-linux-gnu)
17
- ffi (1.17.1-aarch64-linux-musl)
18
- ffi (1.17.1-arm-linux-gnu)
19
- ffi (1.17.1-arm-linux-musl)
20
- ffi (1.17.1-arm64-darwin)
21
- ffi (1.17.1-x86-linux-gnu)
22
- ffi (1.17.1-x86-linux-musl)
23
- ffi (1.17.1-x86_64-darwin)
24
- ffi (1.17.1-x86_64-linux-gnu)
25
- ffi (1.17.1-x86_64-linux-musl)
26
- listen (3.9.0)
27
- rb-fsevent (~> 0.10, >= 0.10.3)
28
- rb-inotify (~> 0.9, >= 0.9.10)
29
- minitest (5.25.5)
30
- observer (0.1.2)
31
- pastel (0.8.0)
32
- tty-color (~> 0.5)
33
- rake (13.2.1)
34
- rb-fsevent (0.11.2)
35
- rb-inotify (0.11.1)
36
- ffi (~> 1.0)
37
- string-similarity (2.1.0)
38
- tty-color (0.6.0)
39
- tty-cursor (0.7.1)
40
- tty-option (0.3.0)
41
- tty-prompt (0.23.1)
42
- pastel (~> 0.8)
43
- tty-reader (~> 0.8)
44
- tty-reader (0.9.0)
45
- tty-cursor (~> 0.7)
46
- tty-screen (~> 0.8)
47
- wisper (~> 2.0)
48
- tty-screen (0.8.2)
49
- wisper (2.0.1)
50
-
51
- PLATFORMS
52
- aarch64-linux-gnu
53
- aarch64-linux-musl
54
- arm-linux-gnu
55
- arm-linux-musl
56
- arm64-darwin
57
- ruby
58
- x86-linux-gnu
59
- x86-linux-musl
60
- x86_64-darwin
61
- x86_64-linux-gnu
62
- x86_64-linux-musl
63
-
64
- DEPENDENCIES
65
- byebug
66
- minitest (~> 5.0)
67
- rake (~> 13.0)
68
- retest!
69
-
70
- BUNDLED WITH
71
- 2.6.6
data/Gemfile.lock DELETED
@@ -1,51 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- retest (2.2.2)
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.1)
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