retest 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/bin/debug +1 -31
- data/exe/retest +18 -5
- data/lib/retest/command.rb +3 -4
- data/lib/retest/options.rb +9 -22
- data/lib/retest/program.rb +8 -23
- data/lib/retest/repository.rb +8 -8
- data/lib/retest/runners/change_runner.rb +2 -2
- data/lib/retest/runners/runner.rb +8 -3
- data/lib/retest/runners/test_runner.rb +2 -2
- data/lib/retest/runners/variable_runner.rb +3 -3
- data/lib/retest/sounds.rb +19 -1
- data/lib/retest/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21de32982072708c695512ab52031d4eccfd6efbd0d7f464b71723f42be7101d
|
4
|
+
data.tar.gz: 987a1e9b14fc4df355a68aae5f3234499ace34b2419a2fb7bc6607326f3c58f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7efb10c87d677fe3fbe1a2922d5991aaa770269f4ad9f226d5087b96a0cb9486f43b6a53f70efd2a3149a6bc8467b9c7e5e28bd55d945a7dda7258ee6cd3c3e8
|
7
|
+
data.tar.gz: 5df599fad13aff034cec088012f760dc863e362f64cb8c0aa525885ffc80ef74ca547f823e354f397a7d52275a21627ccd59f0c221d00164f4e10f863c79c228
|
data/Gemfile.lock
CHANGED
data/bin/debug
CHANGED
@@ -1,36 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require "bundler/setup"
|
4
|
-
require "retest"
|
5
4
|
require "byebug"
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
options = Retest::Options.new(ARGV)
|
10
|
-
|
11
|
-
if options.help?
|
12
|
-
$stdout.puts options.help
|
13
|
-
return
|
14
|
-
end
|
15
|
-
|
16
|
-
repository = Retest::Repository.new(files: Retest::VersionControl.files)
|
17
|
-
command = Retest::Command.for_options(options)
|
18
|
-
runner = Retest::Runners.runner_for(command.to_s)
|
19
|
-
sounds = Retest::Sounds.for(options)
|
20
|
-
|
21
|
-
sounds.play(:tests_pass)
|
22
|
-
runner.add_observer(sounds)
|
23
|
-
|
24
|
-
program = Retest::Program.new(
|
25
|
-
extension: options.extension,
|
26
|
-
repository: repository,
|
27
|
-
command: command,
|
28
|
-
runner: runner
|
29
|
-
)
|
30
|
-
|
31
|
-
if options.params[:diff]
|
32
|
-
program.diff(options.params[:diff])
|
33
|
-
else
|
34
|
-
program.start # not blocking
|
35
|
-
sleep
|
36
|
-
end
|
6
|
+
eval(File.read("exe/retest"))
|
data/exe/retest
CHANGED
@@ -16,11 +16,10 @@ command = Retest::Command.for_options(options)
|
|
16
16
|
runner = Retest::Runners.runner_for(command.to_s)
|
17
17
|
sounds = Retest::Sounds.for(options)
|
18
18
|
|
19
|
-
sounds.play(:
|
19
|
+
sounds.play(:start)
|
20
20
|
runner.add_observer(sounds)
|
21
21
|
|
22
22
|
program = Retest::Program.new(
|
23
|
-
extension: options.extension,
|
24
23
|
repository: repository,
|
25
24
|
command: command,
|
26
25
|
runner: runner
|
@@ -28,7 +27,21 @@ program = Retest::Program.new(
|
|
28
27
|
|
29
28
|
if options.params[:diff]
|
30
29
|
program.diff(options.params[:diff])
|
31
|
-
|
32
|
-
program.start # not blocking
|
33
|
-
sleep
|
30
|
+
return
|
34
31
|
end
|
32
|
+
|
33
|
+
# Main action
|
34
|
+
|
35
|
+
$stdout.puts "Launching Retest..."
|
36
|
+
Listen.to('.', only: options.extension, relative: true) do |modified, added, removed|
|
37
|
+
begin
|
38
|
+
program.run(modified, added, removed)
|
39
|
+
rescue => e
|
40
|
+
$stdout.puts "Something went wrong: #{e.message}"
|
41
|
+
end
|
42
|
+
end.start
|
43
|
+
$stdout.puts "Ready to refactor! You can make file changes now"
|
44
|
+
|
45
|
+
# not blocking
|
46
|
+
|
47
|
+
sleep
|
data/lib/retest/command.rb
CHANGED
@@ -19,14 +19,13 @@ module Retest
|
|
19
19
|
def_delegators :options, :params, :full_suite?, :auto?
|
20
20
|
|
21
21
|
attr_accessor :options, :setup
|
22
|
-
def initialize(options: Options.new, setup: Setup.new,
|
22
|
+
def initialize(options: Options.new, setup: Setup.new, stdout: $stdout)
|
23
23
|
@options = options
|
24
24
|
@setup = setup
|
25
|
-
@
|
25
|
+
@stdout = stdout
|
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
|
|
@@ -52,7 +51,7 @@ module Retest
|
|
52
51
|
end
|
53
52
|
|
54
53
|
def default_command
|
55
|
-
@
|
54
|
+
@stdout.puts "Setup identified: [#{type.upcase}]. Using command: '#{setup_command}'"
|
56
55
|
setup_command
|
57
56
|
end
|
58
57
|
|
data/lib/retest/options.rb
CHANGED
@@ -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 '
|
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 '
|
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>
|
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)"
|
@@ -130,11 +128,6 @@ module Retest
|
|
130
128
|
params[:all]
|
131
129
|
end
|
132
130
|
|
133
|
-
def auto?
|
134
|
-
return true if no_options_passed?
|
135
|
-
params[:auto]
|
136
|
-
end
|
137
|
-
|
138
131
|
def notify?
|
139
132
|
params[:notify]
|
140
133
|
end
|
@@ -142,11 +135,5 @@ module Retest
|
|
142
135
|
def extension
|
143
136
|
Regexp.new(params[:ext])
|
144
137
|
end
|
145
|
-
|
146
|
-
private
|
147
|
-
|
148
|
-
def no_options_passed?
|
149
|
-
params.to_h.values.compact.uniq == ["\\.rb$", false]
|
150
|
-
end
|
151
138
|
end
|
152
139
|
end
|
data/lib/retest/program.rb
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
module Retest
|
2
2
|
class Program
|
3
|
-
attr_accessor :runner, :repository, :command
|
4
|
-
def initialize(runner: nil, repository: nil, command: nil
|
3
|
+
attr_accessor :runner, :repository, :command
|
4
|
+
def initialize(runner: nil, repository: nil, command: nil)
|
5
5
|
@runner = runner
|
6
6
|
@repository = repository
|
7
7
|
@command = command
|
8
|
-
@extension = extension
|
9
8
|
end
|
10
9
|
|
11
|
-
def
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
def run(modified, added, removed)
|
11
|
+
repository.sync(added: added, removed: removed)
|
12
|
+
runner.sync(added: added, removed: removed)
|
13
|
+
system('clear 2>/dev/null') || system('cls 2>/dev/null')
|
14
|
+
|
15
|
+
runner.run (modified + added).first, repository: repository
|
15
16
|
end
|
16
17
|
|
17
18
|
def diff(branch)
|
@@ -24,21 +25,5 @@ module Retest
|
|
24
25
|
puts "Running tests..."
|
25
26
|
runner.run_all_tests command.format_batch(test_files)
|
26
27
|
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def build
|
31
|
-
Listen.to('.', only: extension, relative: true) do |modified, added, removed|
|
32
|
-
begin
|
33
|
-
repository.sync(added: added, removed: removed)
|
34
|
-
runner.sync(added: added, removed: removed)
|
35
|
-
system('clear 2>/dev/null') || system('cls 2>/dev/null')
|
36
|
-
|
37
|
-
runner.run (modified + added).first, repository: repository
|
38
|
-
rescue => e
|
39
|
-
puts "Something went wrong: #{e.message}"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
28
|
end
|
44
29
|
end
|
data/lib/retest/repository.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
module Retest
|
2
2
|
class Repository
|
3
|
-
attr_accessor :files, :cache, :
|
3
|
+
attr_accessor :files, :cache, :stdin, :stdout
|
4
4
|
|
5
|
-
def initialize(files: [], cache: {},
|
6
|
-
@cache
|
7
|
-
@files
|
8
|
-
@
|
9
|
-
@
|
5
|
+
def initialize(files: [], cache: {}, stdin: $stdin, stdout: $stdout)
|
6
|
+
@cache = cache
|
7
|
+
@files = files
|
8
|
+
@stdin = stdin
|
9
|
+
@stdout = stdout
|
10
10
|
end
|
11
11
|
|
12
12
|
def find_test(path)
|
@@ -61,7 +61,7 @@ module Retest
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def ask_question(tests)
|
64
|
-
|
64
|
+
stdout.puts(<<~QUESTION)
|
65
65
|
We found few tests matching: #{@path}
|
66
66
|
#{list_options(tests)}
|
67
67
|
|
@@ -77,7 +77,7 @@ module Retest
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def get_input
|
80
|
-
|
80
|
+
stdin.gets.chomp.to_i
|
81
81
|
end
|
82
82
|
end
|
83
83
|
end
|
@@ -3,10 +3,10 @@ module Retest
|
|
3
3
|
class ChangeRunner < Runner
|
4
4
|
def run(changed_file = nil, repository: nil)
|
5
5
|
if changed_file
|
6
|
-
|
6
|
+
log("Changed File Selected: #{changed_file}")
|
7
7
|
system_run command.gsub('<changed>', changed_file)
|
8
8
|
else
|
9
|
-
|
9
|
+
log(<<~ERROR)
|
10
10
|
404 - Test File Not Found
|
11
11
|
Retest could not find a changed file to run.
|
12
12
|
ERROR
|
@@ -3,8 +3,9 @@ module Retest
|
|
3
3
|
class Runner
|
4
4
|
include Observable
|
5
5
|
|
6
|
-
attr_accessor :command
|
7
|
-
def initialize(command)
|
6
|
+
attr_accessor :command, :stdout
|
7
|
+
def initialize(command, stdout: $stdout)
|
8
|
+
@stdout = stdout
|
8
9
|
@command = command
|
9
10
|
end
|
10
11
|
|
@@ -17,7 +18,7 @@ module Retest
|
|
17
18
|
end
|
18
19
|
|
19
20
|
def run_all_tests(tests_string)
|
20
|
-
|
21
|
+
log("Test File Selected: #{tests_string}")
|
21
22
|
system_run command.gsub('<test>', tests_string)
|
22
23
|
end
|
23
24
|
|
@@ -31,6 +32,10 @@ module Retest
|
|
31
32
|
changed
|
32
33
|
notify_observers(result)
|
33
34
|
end
|
35
|
+
|
36
|
+
def log(message)
|
37
|
+
stdout.puts(message)
|
38
|
+
end
|
34
39
|
end
|
35
40
|
end
|
36
41
|
end
|
@@ -13,10 +13,10 @@ module Retest
|
|
13
13
|
self.cached_test_file = repository.find_test(changed_file)
|
14
14
|
|
15
15
|
if cached_test_file
|
16
|
-
|
16
|
+
log("Test File Selected: #{cached_test_file}")
|
17
17
|
system_run command.gsub('<test>', cached_test_file)
|
18
18
|
else
|
19
|
-
|
19
|
+
log(<<~ERROR)
|
20
20
|
404 - Test File Not Found
|
21
21
|
Retest could not find a matching test file to run.
|
22
22
|
ERROR
|
@@ -14,9 +14,9 @@ module Retest
|
|
14
14
|
|
15
15
|
return print_test_file_not_found unless cached_test_file
|
16
16
|
|
17
|
-
|
17
|
+
log(<<~FILES)
|
18
18
|
Files Selected:
|
19
|
-
-
|
19
|
+
- changed: #{changed_file}
|
20
20
|
- test: #{cached_test_file}
|
21
21
|
|
22
22
|
FILES
|
@@ -33,7 +33,7 @@ module Retest
|
|
33
33
|
private
|
34
34
|
|
35
35
|
def print_test_file_not_found
|
36
|
-
|
36
|
+
log(<<~ERROR)
|
37
37
|
404 - Test File Not Found
|
38
38
|
Retest could not find a matching test file to run.
|
39
39
|
ERROR
|
data/lib/retest/sounds.rb
CHANGED
@@ -24,6 +24,8 @@ module Retest
|
|
24
24
|
['afplay', '/System/Library/Sounds/Sosumi.aiff']
|
25
25
|
when :tests_pass
|
26
26
|
['afplay', '/System/Library/Sounds/Funk.aiff']
|
27
|
+
when :start
|
28
|
+
['afplay', '/System/Library/Sounds/Blow.aiff']
|
27
29
|
else
|
28
30
|
raise ArgumentError.new("No sounds were found for type: #{sound}.")
|
29
31
|
end
|
@@ -33,4 +35,20 @@ module Retest
|
|
33
35
|
alias update play
|
34
36
|
end
|
35
37
|
end
|
36
|
-
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# List of Mac Audio Files:
|
41
|
+
# afplay /System/Library/Sounds/Basso.aiff
|
42
|
+
# afplay /System/Library/Sounds/Bottle.aiff
|
43
|
+
# afplay /System/Library/Sounds/Funk.aiff
|
44
|
+
# afplay /System/Library/Sounds/Hero.aiff
|
45
|
+
# afplay /System/Library/Sounds/Ping.aiff
|
46
|
+
# afplay /System/Library/Sounds/Purr.aiff
|
47
|
+
# afplay /System/Library/Sounds/Submarine.aiff
|
48
|
+
# afplay /System/Library/Sounds/Blow.aiff
|
49
|
+
# afplay /System/Library/Sounds/Frog.aiff
|
50
|
+
# afplay /System/Library/Sounds/Glass.aiff
|
51
|
+
# afplay /System/Library/Sounds/Morse.aiff
|
52
|
+
# afplay /System/Library/Sounds/Pop.aiff
|
53
|
+
# afplay /System/Library/Sounds/Sosumi.aiff
|
54
|
+
# afplay /System/Library/Sounds/Tink.aiff
|
data/lib/retest/version.rb
CHANGED
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.
|
4
|
+
version: 1.7.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-
|
11
|
+
date: 2022-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: string-similarity
|