retest 1.4.0 → 1.6.1
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 +4 -4
- data/.github/workflows/ci.yml +2 -0
- data/.ruby-version +1 -1
- data/Gemfile.lock +5 -5
- data/README.md +17 -2
- data/bin/debug +1 -27
- data/exe/retest +22 -5
- data/lib/retest/command/rails.rb +2 -2
- data/lib/retest/command/rake.rb +2 -2
- data/lib/retest/command/rspec.rb +2 -2
- data/lib/retest/command/ruby.rb +2 -3
- data/lib/retest/command.rb +3 -3
- data/lib/retest/options.rb +9 -0
- data/lib/retest/program.rb +9 -29
- data/lib/retest/repository.rb +13 -8
- data/lib/retest/runners/change_runner.rb +17 -0
- data/lib/retest/runners/runner.rb +41 -0
- data/lib/retest/runners/test_runner.rb +47 -0
- data/lib/retest/runners/variable_runner.rb +57 -0
- data/lib/retest/runners.rb +22 -0
- data/lib/retest/sounds.rb +36 -0
- data/lib/retest/version.rb +1 -1
- data/lib/retest.rb +3 -1
- metadata +13 -8
- data/lib/retest/runner.rb +0 -86
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1574e44c17347c9a6e737481bfcbff782800cf68baef56f7f1dc2e1006f4f5b6
|
4
|
+
data.tar.gz: abe7fda8889c342859457f87b44a91e6e9e4a8cd0d8c764d6738422a8c9ed087
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9732e40769bbdc74ec7783dede4255c6cfb64a2517a8a92cffcbb838b54b714cd71f4244f7c06c6e238ce008facbd4e49f5fd0e6a4c5d73e2c225328254cf427
|
7
|
+
data.tar.gz: 791f6b3bf4d6b8b1eec931bff738bd6e795d51a41c17263c9ab6c0e47d15e1acfd70d18679387ce40520b871c8aabb184f4298f84a965c8e4c43b0b990465b62
|
data/.github/workflows/ci.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7.5
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
retest (1.
|
4
|
+
retest (1.6.0)
|
5
5
|
listen (~> 3.2)
|
6
6
|
string-similarity (~> 2.1)
|
7
7
|
tty-option (~> 0.1)
|
@@ -10,13 +10,13 @@ GEM
|
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
12
|
byebug (11.1.3)
|
13
|
-
ffi (1.15.
|
14
|
-
listen (3.7.
|
13
|
+
ffi (1.15.5)
|
14
|
+
listen (3.7.1)
|
15
15
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
16
16
|
rb-inotify (~> 0.9, >= 0.9.10)
|
17
|
-
minitest (5.
|
17
|
+
minitest (5.15.0)
|
18
18
|
rake (12.3.3)
|
19
|
-
rb-fsevent (0.11.
|
19
|
+
rb-fsevent (0.11.1)
|
20
20
|
rb-inotify (0.10.1)
|
21
21
|
ffi (~> 1.0)
|
22
22
|
string-similarity (2.1.0)
|
data/README.md
CHANGED
@@ -6,7 +6,8 @@ Retest is a small command-line tool to help you refactor code by watching a file
|
|
6
6
|
|
7
7
|
## Demo
|
8
8
|
|
9
|
-
|
9
|
+
|
10
|
+
https://user-images.githubusercontent.com/7149034/153734043-1d136f27-5c24-4676-868b-0fde76016b13.mp4
|
10
11
|
|
11
12
|
## Installation
|
12
13
|
|
@@ -36,7 +37,11 @@ Example:
|
|
36
37
|
|
37
38
|
In this example, the feature spec `spec/features/posts_spec.rb` will be tested after any ruby file is updated.
|
38
39
|
|
39
|
-
#### 2. Run a dynamic command
|
40
|
+
#### 2. Run a dynamic command with placeholders
|
41
|
+
|
42
|
+
Retest provides few placeholders to help you run a command after every file change. The placeholders can be used on their own or together.
|
43
|
+
|
44
|
+
1. `<test>` placeholder
|
40
45
|
|
41
46
|
You can use the placeholder `<test>` to tell the gem where to put the test file path in your command. When a file is changed, the gem will find its matching test and run the test command with it.
|
42
47
|
|
@@ -45,6 +50,16 @@ Example:
|
|
45
50
|
$ retest 'bin/rails test <test>'
|
46
51
|
|
47
52
|
In this example, if `app/models/post.rb` is changed then retest will run `bin/rails test test/models/post_test.rb`
|
53
|
+
|
54
|
+
2. `<changed>` placeholder
|
55
|
+
|
56
|
+
You can use the placeholder `<changed>` to tell the gem where to put the changed file path in your command. When a file is changed, the gem will run the command with it.
|
57
|
+
|
58
|
+
Example:
|
59
|
+
|
60
|
+
$ retest 'rubocop <changed>'
|
61
|
+
|
62
|
+
In this example, if `app/models/post.rb` is changed then retest will run `rubocop app/models/post.rb`
|
48
63
|
|
49
64
|
#### 3. Run a dynamic command with shortcuts
|
50
65
|
|
data/bin/debug
CHANGED
@@ -1,32 +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::Runner.for(command.to_s)
|
19
|
-
|
20
|
-
program = Retest::Program.new(
|
21
|
-
extension: options.extension,
|
22
|
-
repository: repository,
|
23
|
-
command: command,
|
24
|
-
runner: runner
|
25
|
-
)
|
26
|
-
|
27
|
-
if options.params[:diff]
|
28
|
-
program.diff(options.params[:diff])
|
29
|
-
else
|
30
|
-
program.start # not blocking
|
31
|
-
sleep
|
32
|
-
end
|
6
|
+
eval(File.read("exe/retest"))
|
data/exe/retest
CHANGED
@@ -13,10 +13,13 @@ end
|
|
13
13
|
|
14
14
|
repository = Retest::Repository.new(files: Retest::VersionControl.files)
|
15
15
|
command = Retest::Command.for_options(options)
|
16
|
-
runner = Retest::
|
16
|
+
runner = Retest::Runners.runner_for(command.to_s)
|
17
|
+
sounds = Retest::Sounds.for(options)
|
18
|
+
|
19
|
+
sounds.play(:tests_pass)
|
20
|
+
runner.add_observer(sounds)
|
17
21
|
|
18
22
|
program = Retest::Program.new(
|
19
|
-
extension: options.extension,
|
20
23
|
repository: repository,
|
21
24
|
command: command,
|
22
25
|
runner: runner
|
@@ -24,7 +27,21 @@ program = Retest::Program.new(
|
|
24
27
|
|
25
28
|
if options.params[:diff]
|
26
29
|
program.diff(options.params[:diff])
|
27
|
-
|
28
|
-
program.start # not blocking
|
29
|
-
sleep
|
30
|
+
return
|
30
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/rails.rb
CHANGED
data/lib/retest/command/rake.rb
CHANGED
data/lib/retest/command/rspec.rb
CHANGED
data/lib/retest/command/ruby.rb
CHANGED
@@ -8,9 +8,8 @@ module Retest
|
|
8
8
|
@all = all
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
|
13
|
-
runner.run %Q{-e "#{paths}"}
|
11
|
+
def format_batch(*files)
|
12
|
+
%Q{-e "#{files.map { |file| "require './#{file}';" }.join}"}
|
14
13
|
end
|
15
14
|
|
16
15
|
def to_s
|
data/lib/retest/command.rb
CHANGED
@@ -19,10 +19,10 @@ 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
|
@@ -52,7 +52,7 @@ module Retest
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def default_command
|
55
|
-
@
|
55
|
+
@stdout.puts "Setup identified: [#{type.upcase}]. Using command: '#{setup_command}'"
|
56
56
|
setup_command
|
57
57
|
end
|
58
58
|
|
data/lib/retest/options.rb
CHANGED
@@ -76,6 +76,11 @@ module Retest
|
|
76
76
|
desc "Indentify repository setup and runs appropriate command"
|
77
77
|
end
|
78
78
|
|
79
|
+
flag :notify do
|
80
|
+
long "--notify"
|
81
|
+
desc "Play a sound when specs pass or fail (macOS only)"
|
82
|
+
end
|
83
|
+
|
79
84
|
flag :help do
|
80
85
|
short "-h"
|
81
86
|
long "--help"
|
@@ -130,6 +135,10 @@ module Retest
|
|
130
135
|
params[:auto]
|
131
136
|
end
|
132
137
|
|
138
|
+
def notify?
|
139
|
+
params[:notify]
|
140
|
+
end
|
141
|
+
|
133
142
|
def extension
|
134
143
|
Regexp.new(params[:ext])
|
135
144
|
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)
|
@@ -22,28 +23,7 @@ module Retest
|
|
22
23
|
test_files.each { |test_file| puts " - #{test_file}" }
|
23
24
|
|
24
25
|
puts "Running tests..."
|
25
|
-
command.
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def build
|
31
|
-
Listen.to('.', only: extension, relative: true) do |modified, added, removed|
|
32
|
-
begin
|
33
|
-
repository.add(added)
|
34
|
-
repository.remove(removed)
|
35
|
-
runner.remove(removed)
|
36
|
-
system('clear 2>/dev/null') || system('cls 2>/dev/null')
|
37
|
-
|
38
|
-
runner.run test_file_to_run(modified + added)
|
39
|
-
rescue => e
|
40
|
-
puts "Something went wrong: #{e.message}"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_file_to_run(changed_files)
|
46
|
-
repository.find_test changed_files.first if runner.matching?
|
26
|
+
runner.run_all_tests command.format_batch(test_files)
|
47
27
|
end
|
48
28
|
end
|
49
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)
|
@@ -26,6 +26,11 @@ module Retest
|
|
26
26
|
.sort
|
27
27
|
end
|
28
28
|
|
29
|
+
def sync(added:, removed:)
|
30
|
+
add(added)
|
31
|
+
remove(removed)
|
32
|
+
end
|
33
|
+
|
29
34
|
def add(added)
|
30
35
|
return if added&.empty?
|
31
36
|
|
@@ -56,7 +61,7 @@ module Retest
|
|
56
61
|
end
|
57
62
|
|
58
63
|
def ask_question(tests)
|
59
|
-
|
64
|
+
stdout.puts(<<~QUESTION)
|
60
65
|
We found few tests matching: #{@path}
|
61
66
|
#{list_options(tests)}
|
62
67
|
|
@@ -72,7 +77,7 @@ module Retest
|
|
72
77
|
end
|
73
78
|
|
74
79
|
def get_input
|
75
|
-
|
80
|
+
stdin.gets.chomp.to_i
|
76
81
|
end
|
77
82
|
end
|
78
83
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Retest
|
2
|
+
module Runners
|
3
|
+
class ChangeRunner < Runner
|
4
|
+
def run(changed_file = nil, repository: nil)
|
5
|
+
if changed_file
|
6
|
+
log("Changed File Selected: #{changed_file}")
|
7
|
+
system_run command.gsub('<changed>', changed_file)
|
8
|
+
else
|
9
|
+
log(<<~ERROR)
|
10
|
+
404 - Test File Not Found
|
11
|
+
Retest could not find a changed file to run.
|
12
|
+
ERROR
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Retest
|
2
|
+
module Runners
|
3
|
+
class Runner
|
4
|
+
include Observable
|
5
|
+
|
6
|
+
attr_accessor :command, :stdout
|
7
|
+
def initialize(command, stdout: $stdout)
|
8
|
+
@stdout = stdout
|
9
|
+
@command = command
|
10
|
+
end
|
11
|
+
|
12
|
+
def ==(obj)
|
13
|
+
command == obj.command && obj.class == self.class
|
14
|
+
end
|
15
|
+
|
16
|
+
def run(changed_file = nil, repository: nil)
|
17
|
+
system_run command
|
18
|
+
end
|
19
|
+
|
20
|
+
def run_all_tests(tests_string)
|
21
|
+
log("Test File Selected: #{tests_string}")
|
22
|
+
system_run command.gsub('<test>', tests_string)
|
23
|
+
end
|
24
|
+
|
25
|
+
def sync(added:, removed:)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def system_run(command)
|
31
|
+
result = system(command) ? :tests_pass : :tests_fail
|
32
|
+
changed
|
33
|
+
notify_observers(result)
|
34
|
+
end
|
35
|
+
|
36
|
+
def log(message)
|
37
|
+
stdout.puts(message)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Retest
|
2
|
+
module Runners
|
3
|
+
class TestRunner < Runner
|
4
|
+
def cached_test_file
|
5
|
+
@cached_test_file
|
6
|
+
end
|
7
|
+
|
8
|
+
def cached_test_file=(value)
|
9
|
+
@cached_test_file = value || @cached_test_file
|
10
|
+
end
|
11
|
+
|
12
|
+
def run(changed_file, repository:)
|
13
|
+
self.cached_test_file = repository.find_test(changed_file)
|
14
|
+
|
15
|
+
if cached_test_file
|
16
|
+
log("Test File Selected: #{cached_test_file}")
|
17
|
+
system_run command.gsub('<test>', cached_test_file)
|
18
|
+
else
|
19
|
+
log(<<~ERROR)
|
20
|
+
404 - Test File Not Found
|
21
|
+
Retest could not find a matching test file to run.
|
22
|
+
ERROR
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def sync(added:, removed:)
|
27
|
+
remove(removed)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def remove(purged)
|
33
|
+
return if purged.empty?
|
34
|
+
|
35
|
+
if purged.is_a? Array
|
36
|
+
purge_cache if purged.include? cached_test_file
|
37
|
+
elsif purged.is_a? String
|
38
|
+
purge_cache if purged == cached_test_file
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def purge_cache
|
43
|
+
@cached_test_file = nil
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Retest
|
2
|
+
module Runners
|
3
|
+
class VariableRunner < Runner
|
4
|
+
def cached_test_file
|
5
|
+
@cached_test_file
|
6
|
+
end
|
7
|
+
|
8
|
+
def cached_test_file=(value)
|
9
|
+
@cached_test_file = value || @cached_test_file
|
10
|
+
end
|
11
|
+
|
12
|
+
def run(changed_file, repository:)
|
13
|
+
self.cached_test_file = repository.find_test(changed_file)
|
14
|
+
|
15
|
+
return print_test_file_not_found unless cached_test_file
|
16
|
+
|
17
|
+
log(<<~FILES)
|
18
|
+
Files Selected:
|
19
|
+
- file: #{changed_file}
|
20
|
+
- test: #{cached_test_file}
|
21
|
+
|
22
|
+
FILES
|
23
|
+
|
24
|
+
system_run command
|
25
|
+
.gsub('<test>', cached_test_file)
|
26
|
+
.gsub('<changed>', changed_file)
|
27
|
+
end
|
28
|
+
|
29
|
+
def sync(added:, removed:)
|
30
|
+
remove(removed)
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def print_test_file_not_found
|
36
|
+
log(<<~ERROR)
|
37
|
+
404 - Test File Not Found
|
38
|
+
Retest could not find a matching test file to run.
|
39
|
+
ERROR
|
40
|
+
end
|
41
|
+
|
42
|
+
def remove(purged)
|
43
|
+
return if purged.empty?
|
44
|
+
|
45
|
+
if purged.is_a? Array
|
46
|
+
purge_cache if purged.include? cached_test_file
|
47
|
+
elsif purged.is_a? String
|
48
|
+
purge_cache if purged == cached_test_file
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def purge_cache
|
53
|
+
@cached_test_file = nil
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative 'runners/runner'
|
2
|
+
require_relative 'runners/test_runner'
|
3
|
+
require_relative 'runners/change_runner'
|
4
|
+
require_relative 'runners/variable_runner'
|
5
|
+
|
6
|
+
module Retest
|
7
|
+
module Runners
|
8
|
+
module_function
|
9
|
+
|
10
|
+
def runner_for(command)
|
11
|
+
if command.include?('<test>') && command.include?('<changed>')
|
12
|
+
VariableRunner
|
13
|
+
elsif command.include?('<test>')
|
14
|
+
TestRunner
|
15
|
+
elsif command.include?('<changed>')
|
16
|
+
ChangeRunner
|
17
|
+
else
|
18
|
+
Runner
|
19
|
+
end.new command
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Retest
|
2
|
+
module Sounds
|
3
|
+
module_function
|
4
|
+
|
5
|
+
def for(options)
|
6
|
+
options.notify? ? MacOS.new : Mute.new
|
7
|
+
end
|
8
|
+
|
9
|
+
class Mute
|
10
|
+
def play(_)
|
11
|
+
end
|
12
|
+
alias update play
|
13
|
+
end
|
14
|
+
|
15
|
+
class MacOS
|
16
|
+
def initialize(kernel: Kernel, thread: Thread)
|
17
|
+
@kernel = kernel
|
18
|
+
@thread = thread
|
19
|
+
end
|
20
|
+
|
21
|
+
def play(sound)
|
22
|
+
args = case sound
|
23
|
+
when :tests_fail
|
24
|
+
['afplay', '/System/Library/Sounds/Sosumi.aiff']
|
25
|
+
when :tests_pass
|
26
|
+
['afplay', '/System/Library/Sounds/Funk.aiff']
|
27
|
+
else
|
28
|
+
raise ArgumentError.new("No sounds were found for type: #{sound}.")
|
29
|
+
end
|
30
|
+
|
31
|
+
@thread.new { @kernel.system(*args) }
|
32
|
+
end
|
33
|
+
alias update play
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/retest/version.rb
CHANGED
data/lib/retest.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'listen'
|
2
2
|
require 'string/similarity'
|
3
|
+
require 'observer'
|
3
4
|
|
4
5
|
require "retest/version"
|
5
|
-
require "retest/
|
6
|
+
require "retest/runners"
|
6
7
|
require "retest/repository"
|
7
8
|
require "retest/test_options"
|
8
9
|
require "retest/options"
|
@@ -11,6 +12,7 @@ require "retest/setup"
|
|
11
12
|
require "retest/command"
|
12
13
|
require "retest/file_system"
|
13
14
|
require "retest/program"
|
15
|
+
require "retest/sounds"
|
14
16
|
|
15
17
|
module Retest
|
16
18
|
class Error < StandardError; 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.
|
4
|
+
version: 1.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexandre Barret
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: string-similarity
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.1'
|
55
|
-
description:
|
55
|
+
description:
|
56
56
|
email:
|
57
57
|
- alex@abletech.nz
|
58
58
|
executables:
|
@@ -90,8 +90,13 @@ files:
|
|
90
90
|
- lib/retest/options.rb
|
91
91
|
- lib/retest/program.rb
|
92
92
|
- lib/retest/repository.rb
|
93
|
-
- lib/retest/
|
93
|
+
- lib/retest/runners.rb
|
94
|
+
- lib/retest/runners/change_runner.rb
|
95
|
+
- lib/retest/runners/runner.rb
|
96
|
+
- lib/retest/runners/test_runner.rb
|
97
|
+
- lib/retest/runners/variable_runner.rb
|
94
98
|
- lib/retest/setup.rb
|
99
|
+
- lib/retest/sounds.rb
|
95
100
|
- lib/retest/test_options.rb
|
96
101
|
- lib/retest/version.rb
|
97
102
|
- lib/retest/version_control.rb
|
@@ -104,7 +109,7 @@ licenses:
|
|
104
109
|
metadata:
|
105
110
|
homepage_uri: https://github.com/AlexB52/retest
|
106
111
|
source_code_uri: https://github.com/AlexB52/retest
|
107
|
-
post_install_message:
|
112
|
+
post_install_message:
|
108
113
|
rdoc_options: []
|
109
114
|
require_paths:
|
110
115
|
- lib
|
@@ -119,8 +124,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
124
|
- !ruby/object:Gem::Version
|
120
125
|
version: '0'
|
121
126
|
requirements: []
|
122
|
-
rubygems_version: 3.
|
123
|
-
signing_key:
|
127
|
+
rubygems_version: 3.1.6
|
128
|
+
signing_key:
|
124
129
|
specification_version: 4
|
125
130
|
summary: A simple command line tool to watch file change and run its matching spec.
|
126
131
|
test_files: []
|
data/lib/retest/runner.rb
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
module Retest
|
2
|
-
class Runner
|
3
|
-
def self.for(test_command)
|
4
|
-
if test_command.include? '<test>'
|
5
|
-
VariableRunner
|
6
|
-
else
|
7
|
-
HardcodedRunner
|
8
|
-
end.new test_command
|
9
|
-
end
|
10
|
-
|
11
|
-
class VariableRunner
|
12
|
-
attr_reader :command
|
13
|
-
|
14
|
-
def initialize(command)
|
15
|
-
@command = command
|
16
|
-
@cached_test_file = nil
|
17
|
-
end
|
18
|
-
|
19
|
-
def ==(obj)
|
20
|
-
command == obj.command && obj.class == self.class
|
21
|
-
end
|
22
|
-
|
23
|
-
def cached_test_file
|
24
|
-
@cached_test_file
|
25
|
-
end
|
26
|
-
|
27
|
-
def cached_test_file=(value)
|
28
|
-
@cached_test_file = value || @cached_test_file
|
29
|
-
end
|
30
|
-
|
31
|
-
def run(test_file = nil)
|
32
|
-
self.cached_test_file = test_file
|
33
|
-
|
34
|
-
if cached_test_file
|
35
|
-
puts "Test File Selected: #{cached_test_file}"
|
36
|
-
system command.gsub('<test>', cached_test_file)
|
37
|
-
else
|
38
|
-
puts <<~ERROR
|
39
|
-
404 - Test File Not Found
|
40
|
-
Retest could not find a matching test file to run.
|
41
|
-
ERROR
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def remove(purged)
|
46
|
-
return if purged.empty?
|
47
|
-
|
48
|
-
if purged.is_a? Array
|
49
|
-
purge_cache if purged.include? cached_test_file
|
50
|
-
elsif purged.is_a? String
|
51
|
-
purge_cache if purged == cached_test_file
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def unmatching?
|
56
|
-
!matching?
|
57
|
-
end
|
58
|
-
|
59
|
-
def matching?
|
60
|
-
true
|
61
|
-
end
|
62
|
-
|
63
|
-
private
|
64
|
-
|
65
|
-
def purge_cache
|
66
|
-
@cached_test_file = nil
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
HardcodedRunner = Struct.new(:command) do
|
71
|
-
def run(_ = nil)
|
72
|
-
system command
|
73
|
-
end
|
74
|
-
|
75
|
-
def remove(_ = nil); end
|
76
|
-
|
77
|
-
def unmatching?
|
78
|
-
!matching?
|
79
|
-
end
|
80
|
-
|
81
|
-
def matching?
|
82
|
-
false
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|