retest 2.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ddcd17a0606fa3fd4fc58ea7b6ac625f6eb441b05e7f6ee5e219d4e5c4772ada
4
- data.tar.gz: 1230ff83093919562a6a15a49889ebc26711d23e8270341b9032e8d8772ea929
3
+ metadata.gz: bec5345ea68a0b916e57d954a04f236f25d34d051ae1f73a6ab5aef60269a271
4
+ data.tar.gz: 7eceaf7914b3b8be86027fe0e16637051fe7e4a8d334b856cb070dc62e356d05
5
5
  SHA512:
6
- metadata.gz: 6b647c571bc496405e43719a26820f58d12220724e2d772daee4ceeeb4dfdafdeecb116d9e156907ed1a8870804ee076480fcc757cfec01073bec8e60d180edf
7
- data.tar.gz: f5e52d42d5dd8f23f4a29a8eddebfb421d8398bf31fb991ab3f9ab07e420ec828df7173677552765c4b6da734cbe1a45ee5e5593c8277ccd5e5970e56e824be3
6
+ metadata.gz: d102ac7842a67f1bea01b9d2ba3e8d37623edb834a637b0937ff72808cafaa1f2fc64f7fc4d7330bf110190abfdc13fbfb870b15608286668c7c922d91257730
7
+ data.tar.gz: d5720c3eafe0493b705abb665021ec8d828fbbf17615bd6040af3b5258ce0a6aaa5cd87e2775c828b8b6d877c9c581fdf560b26647ea702298b1c9e89dfe567e
@@ -28,6 +28,7 @@ jobs:
28
28
  - version: '3.2'
29
29
  - version: '3.3'
30
30
  - version: '3.4'
31
+ - version: '4.0'
31
32
  name: Ruby ${{ matrix.ruby.version }} test (${{ matrix.os }})
32
33
  env:
33
34
  BUNDLE_GEMFILE: ${{ matrix.ruby.gemfile || 'Gemfile' }}
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 ===
@@ -1,4 +1,5 @@
1
1
  require 'forwardable'
2
+ require 'set'
2
3
 
3
4
  module Retest
4
5
  class MatchingOptions
@@ -1,147 +1,49 @@
1
- require 'tty-option'
1
+ require 'optparse'
2
2
 
3
3
  module Retest
4
4
  class Options
5
- include TTY::Option
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
- usage do
8
- program "retest"
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
- flag :rails do
123
- long "--rails"
124
- desc "Shortcut for a standard Rails setup"
27
+ def initialize(args = [])
28
+ self.args = args
125
29
  end
126
30
 
127
- flag :ruby do
128
- long "--ruby"
129
- desc "Shortcut for a Ruby project"
31
+ def args=(args)
32
+ @args = args.dup
33
+ @params = DEFAULT_PARAMS.transform_values(&:dup)
34
+ parse(@args)
130
35
  end
131
36
 
132
- attr_reader :args
133
-
134
- def self.command(args)
135
- new(args).command
37
+ def help
38
+ parser.to_s
136
39
  end
137
40
 
138
- def initialize(args = [])
139
- self.args = args
41
+ def command
42
+ params[:command]
140
43
  end
141
44
 
142
- def args=(args)
143
- @args = args
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
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
- result = $?.exitstatus&.zero? ? :tests_pass : :tests_fail
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)
@@ -1,3 +1,3 @@
1
1
  module Retest
2
- VERSION = "2.4.0"
2
+ VERSION = "2.5.0"
3
3
  end
data/retest.gemspec CHANGED
@@ -27,9 +27,9 @@ 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
33
  spec.add_development_dependency "minitest", ["~> 5.0"]
34
34
  spec.add_development_dependency "rake", ["~> 13.0"]
35
35
  spec.add_development_dependency "byebug", ["~> 11.1"]
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: retest
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandre Barret
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2025-08-20 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: string-similarity
@@ -39,7 +38,7 @@ dependencies:
39
38
  - !ruby/object:Gem::Version
40
39
  version: '3.9'
41
40
  - !ruby/object:Gem::Dependency
42
- name: tty-option
41
+ name: tty-prompt
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
44
  - - "~>"
@@ -53,7 +52,7 @@ dependencies:
53
52
  - !ruby/object:Gem::Version
54
53
  version: '0.1'
55
54
  - !ruby/object:Gem::Dependency
56
- name: tty-prompt
55
+ name: observer
57
56
  requirement: !ruby/object:Gem::Requirement
58
57
  requirements:
59
58
  - - "~>"
@@ -67,19 +66,19 @@ dependencies:
67
66
  - !ruby/object:Gem::Version
68
67
  version: '0.1'
69
68
  - !ruby/object:Gem::Dependency
70
- name: observer
69
+ name: logger
71
70
  requirement: !ruby/object:Gem::Requirement
72
71
  requirements:
73
72
  - - "~>"
74
73
  - !ruby/object:Gem::Version
75
- version: '0.1'
74
+ version: '1.7'
76
75
  type: :runtime
77
76
  prerelease: false
78
77
  version_requirements: !ruby/object:Gem::Requirement
79
78
  requirements:
80
79
  - - "~>"
81
80
  - !ruby/object:Gem::Version
82
- version: '0.1'
81
+ version: '1.7'
83
82
  - !ruby/object:Gem::Dependency
84
83
  name: minitest
85
84
  requirement: !ruby/object:Gem::Requirement
@@ -122,7 +121,6 @@ dependencies:
122
121
  - - "~>"
123
122
  - !ruby/object:Gem::Version
124
123
  version: '11.1'
125
- description:
126
124
  email:
127
125
  - alex@abletech.nz
128
126
  executables:
@@ -190,7 +188,6 @@ licenses:
190
188
  metadata:
191
189
  homepage_uri: https://github.com/AlexB52/retest
192
190
  source_code_uri: https://github.com/AlexB52/retest
193
- post_install_message:
194
191
  rdoc_options: []
195
192
  require_paths:
196
193
  - lib
@@ -205,8 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
205
202
  - !ruby/object:Gem::Version
206
203
  version: '0'
207
204
  requirements: []
208
- rubygems_version: 3.5.22
209
- signing_key:
205
+ rubygems_version: 4.0.14
210
206
  specification_version: 4
211
207
  summary: A simple command line tool to watch file change and run its matching spec.
212
208
  test_files: []