retest 1.6.2 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa89818d98ad713bc6982f8f68b94afe80a09dc1677068dda42dbad1a2300c72
4
- data.tar.gz: 60206dca5d68cdf634c47424e8712c2b8e4884b543bd85bb55fc0429300b4265
3
+ metadata.gz: a4a4d202f2a63a0cabc5afc27b9beb0c2bf4a6b71a02d7827246536cc82961ee
4
+ data.tar.gz: 6e9822b0c5153506ec6c3a3df5c5a05ecc9f56c946c1bb5e432f7b32068eb108
5
5
  SHA512:
6
- metadata.gz: 64777879959eed5656066cca23508738deb78566ee87144e67066c9e15e3d6da6dfcce1bd7bac9ff3f66c94cf66976f709663b1b4df3a5242cd9a6a0e6cb9491
7
- data.tar.gz: bd55fd227c159b11eb7b2389c319e38e931af90ca0b29b0bdc343b5a7ca3996086bebf6d4099fcc67e654da30022bd53797c437911defeda1f98b6196c988ec4
6
+ metadata.gz: 77aabd6ad0bfd3b27b2c4ed2958cdeac3cc92bfe1e15cbf99bf88af6cfb3161ab455197d1dcfabc509477c03177827ff178fea4f6b8321984c7967cf7d972000
7
+ data.tar.gz: 75b55fe45e376a6a1f95ec46d258835be120826fe1a2a4644070ba213a4d1a1a41027818ed8fa6b4a45600c16b6c307d138a50db1ef7c9037e361246672eb4f0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- retest (1.6.2)
4
+ retest (1.9.0)
5
5
  listen (~> 3.2)
6
6
  string-similarity (~> 2.1)
7
7
  tty-option (~> 0.1)
data/exe/retest CHANGED
@@ -4,6 +4,8 @@ require 'retest'
4
4
 
5
5
  $stdout.sync = true
6
6
 
7
+ Signal.trap(:INT) { $stdout.puts "Goodbye"; exit }
8
+
7
9
  options = Retest::Options.new(ARGV)
8
10
 
9
11
  if options.help?
@@ -30,16 +32,21 @@ if options.params[:diff]
30
32
  return
31
33
  end
32
34
 
35
+ launching_message = "Launching Retest..."
36
+ if options.force_polling?
37
+ launching_message = "Launching Retest with polling method..."
38
+ end
39
+
33
40
  # Main action
34
41
 
35
- $stdout.puts "Launching Retest..."
36
- Listen.to('.', only: options.extension, relative: true) do |modified, added, removed|
42
+ $stdout.puts launching_message
43
+ Retest.listen(options) do |modified, added, removed|
37
44
  begin
38
45
  program.run(modified, added, removed)
39
46
  rescue => e
40
47
  $stdout.puts "Something went wrong: #{e.message}"
41
48
  end
42
- end.start
49
+ end
43
50
  $stdout.puts "Ready to refactor! You can make file changes now"
44
51
 
45
52
  # not blocking
@@ -26,7 +26,6 @@ module Retest
26
26
  end
27
27
 
28
28
  def command
29
- return default_command if auto?
30
29
  options_command || default_command
31
30
  end
32
31
 
@@ -13,13 +13,18 @@ module Retest
13
13
 
14
14
  example <<~EOS
15
15
  Runs a matching rails test after a file change
16
- $ retest 'bundle exec rails test <test>'
16
+ $ retest 'bin/rails test <test>'
17
17
  $ retest --rails
18
18
  EOS
19
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
+
20
25
  example <<~EOS
21
26
  Runs all rails tests after a file change
22
- $ retest 'bundle exec rails test'
27
+ $ retest 'bin/rails test'
23
28
  $ retest --rails --all
24
29
  EOS
25
30
 
@@ -31,19 +36,17 @@ module Retest
31
36
  example <<~EOS
32
37
  Let retest identify which command to run
33
38
  $ retest
34
- $ retest --auto
35
39
  EOS
36
40
 
37
41
  example <<~EOS
38
42
  Let retest identify which command to run for all tests
39
43
  $ retest --all
40
- $ retest --auto --all
41
44
  EOS
42
45
 
43
46
  example <<~EOS
44
47
  Run a sanity check on changed files from a branch
48
+ $ retest --diff main
45
49
  $ retest --diff origin/main --rails
46
- $ retest --diff main --auto
47
50
  EOS
48
51
  end
49
52
 
@@ -51,7 +54,7 @@ module Retest
51
54
  optional
52
55
  desc <<~EOS
53
56
  The test command to rerun when a file changes.
54
- Use <test> placeholder to tell retest where to put the matching spec.
57
+ Use <test> or <changed> placeholders to tell retest where to reference the matching spec or the changed file in the command.
55
58
  EOS
56
59
  end
57
60
 
@@ -71,11 +74,6 @@ module Retest
71
74
  desc "Run all the specs of a specificied ruby setup"
72
75
  end
73
76
 
74
- flag :auto do
75
- long "--auto"
76
- desc "Indentify repository setup and runs appropriate command"
77
- end
78
-
79
77
  flag :notify do
80
78
  long "--notify"
81
79
  desc "Play a sound when specs pass or fail (macOS only)"
@@ -87,6 +85,15 @@ module Retest
87
85
  desc "Print usage"
88
86
  end
89
87
 
88
+ option :polling do
89
+ long '--polling'
90
+ desc <<~DESC.strip
91
+ Use polling method when listening to file changes
92
+ Some filesystems won't work without it
93
+ VM/Vagrant Shared folders, NFS, Samba, sshfs...
94
+ DESC
95
+ end
96
+
90
97
  flag :rspec do
91
98
  long "--rspec"
92
99
  desc "Shortcut for a standard RSpec setup"
@@ -130,23 +137,16 @@ module Retest
130
137
  params[:all]
131
138
  end
132
139
 
133
- def auto?
134
- return true if no_options_passed?
135
- params[:auto]
136
- end
137
-
138
140
  def notify?
139
141
  params[:notify]
140
142
  end
141
143
 
142
- def extension
143
- Regexp.new(params[:ext])
144
+ def force_polling?
145
+ params[:polling]
144
146
  end
145
147
 
146
- private
147
-
148
- def no_options_passed?
149
- params.to_h.values.compact.uniq == ["\\.rb$", false]
148
+ def extension
149
+ Regexp.new(params[:ext])
150
150
  end
151
151
  end
152
152
  end
@@ -1,3 +1,3 @@
1
1
  module Retest
2
- VERSION = "1.6.2"
2
+ VERSION = "1.9.0"
3
3
  end
data/lib/retest.rb CHANGED
@@ -16,4 +16,10 @@ require "retest/sounds"
16
16
 
17
17
  module Retest
18
18
  class Error < StandardError; end
19
+
20
+ def self.listen(options, listener: Listen)
21
+ listener.to('.', only: options.extension, relative: true, force_polling: options.force_polling?) do |modified, added, removed|
22
+ yield modified, added, removed
23
+ end.start
24
+ end
19
25
  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: 1.6.2
4
+ version: 1.9.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: 2022-06-26 00:00:00.000000000 Z
11
+ date: 2022-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: string-similarity