retest 1.4.0 → 1.5.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 -1
- data/exe/retest +1 -1
- 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/program.rb +4 -9
- data/lib/retest/repository.rb +6 -1
- data/lib/retest/runners/change_runner.rb +17 -0
- data/lib/retest/runners/runner.rb +26 -0
- data/lib/retest/{runner.rb → runners/test_runner.rb} +11 -50
- data/lib/retest/runners/variable_runner.rb +57 -0
- data/lib/retest/runners.rb +22 -0
- data/lib/retest/version.rb +1 -1
- data/lib/retest.rb +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce75120a1212540c1e510e4fd3d28e505f68d79e4e557b48e34cfda769d35613
|
4
|
+
data.tar.gz: ff2a3cc3644ce392adb38d8a87ffea711bbc6baaeb20f70099b2c0771cce3cf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6741101b8345dfcba37002b1265d6ed5170c8b82eccc8a143b20a7fb77d196f05b9c4b4af142a7fed62952aa5251769523243c997884334cc8a3d484f93f3207
|
7
|
+
data.tar.gz: 3c4f2484eb2400a47d35c22a33f6db47ede1e0fc401dccdede644114f90bc2765f1e1e6df5b2fea7e761d77983a863f2c917cfb5afd71ffabd89e884f1ad85c6
|
data/Gemfile.lock
CHANGED
data/bin/debug
CHANGED
@@ -15,7 +15,7 @@ end
|
|
15
15
|
|
16
16
|
repository = Retest::Repository.new(files: Retest::VersionControl.files)
|
17
17
|
command = Retest::Command.for_options(options)
|
18
|
-
runner = Retest::
|
18
|
+
runner = Retest::Runners.runner_for(command.to_s)
|
19
19
|
|
20
20
|
program = Retest::Program.new(
|
21
21
|
extension: options.extension,
|
data/exe/retest
CHANGED
@@ -13,7 +13,7 @@ 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
17
|
|
18
18
|
program = Retest::Program.new(
|
19
19
|
extension: options.extension,
|
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/program.rb
CHANGED
@@ -22,7 +22,7 @@ module Retest
|
|
22
22
|
test_files.each { |test_file| puts " - #{test_file}" }
|
23
23
|
|
24
24
|
puts "Running tests..."
|
25
|
-
command.
|
25
|
+
runner.run_all_tests command.format_batch(test_files)
|
26
26
|
end
|
27
27
|
|
28
28
|
private
|
@@ -30,20 +30,15 @@ module Retest
|
|
30
30
|
def build
|
31
31
|
Listen.to('.', only: extension, relative: true) do |modified, added, removed|
|
32
32
|
begin
|
33
|
-
repository.
|
34
|
-
|
35
|
-
runner.remove(removed)
|
33
|
+
repository.sync(added: added, removed: removed)
|
34
|
+
runner.sync(added: added, removed: removed)
|
36
35
|
system('clear 2>/dev/null') || system('cls 2>/dev/null')
|
37
36
|
|
38
|
-
runner.run
|
37
|
+
runner.run (modified + added).first, repository: repository
|
39
38
|
rescue => e
|
40
39
|
puts "Something went wrong: #{e.message}"
|
41
40
|
end
|
42
41
|
end
|
43
42
|
end
|
44
|
-
|
45
|
-
def test_file_to_run(changed_files)
|
46
|
-
repository.find_test changed_files.first if runner.matching?
|
47
|
-
end
|
48
43
|
end
|
49
44
|
end
|
data/lib/retest/repository.rb
CHANGED
@@ -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
|
-
output_stream.puts
|
64
|
+
output_stream.puts(<<~QUESTION)
|
60
65
|
We found few tests matching: #{@path}
|
61
66
|
#{list_options(tests)}
|
62
67
|
|
@@ -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
|
+
puts "Changed File Selected: #{changed_file}"
|
7
|
+
system command.gsub('<changed>', changed_file)
|
8
|
+
else
|
9
|
+
puts <<~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,26 @@
|
|
1
|
+
module Retest
|
2
|
+
module Runners
|
3
|
+
class Runner
|
4
|
+
attr_accessor :command
|
5
|
+
def initialize(command)
|
6
|
+
@command = command
|
7
|
+
end
|
8
|
+
|
9
|
+
def ==(obj)
|
10
|
+
command == obj.command && obj.class == self.class
|
11
|
+
end
|
12
|
+
|
13
|
+
def run(changed_file = nil, repository: nil)
|
14
|
+
system command
|
15
|
+
end
|
16
|
+
|
17
|
+
def run_all_tests(tests_string)
|
18
|
+
puts "Test File Selected: #{tests_string}"
|
19
|
+
system command.gsub('<test>', tests_string)
|
20
|
+
end
|
21
|
+
|
22
|
+
def sync(added:, removed:)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,25 +1,6 @@
|
|
1
1
|
module Retest
|
2
|
-
|
3
|
-
|
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
|
-
|
2
|
+
module Runners
|
3
|
+
class TestRunner < Runner
|
23
4
|
def cached_test_file
|
24
5
|
@cached_test_file
|
25
6
|
end
|
@@ -28,8 +9,8 @@ module Retest
|
|
28
9
|
@cached_test_file = value || @cached_test_file
|
29
10
|
end
|
30
11
|
|
31
|
-
def run(
|
32
|
-
self.cached_test_file =
|
12
|
+
def run(changed_file, repository:)
|
13
|
+
self.cached_test_file = repository.find_test(changed_file)
|
33
14
|
|
34
15
|
if cached_test_file
|
35
16
|
puts "Test File Selected: #{cached_test_file}"
|
@@ -42,6 +23,12 @@ module Retest
|
|
42
23
|
end
|
43
24
|
end
|
44
25
|
|
26
|
+
def sync(added:, removed:)
|
27
|
+
remove(removed)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
45
32
|
def remove(purged)
|
46
33
|
return if purged.empty?
|
47
34
|
|
@@ -52,35 +39,9 @@ module Retest
|
|
52
39
|
end
|
53
40
|
end
|
54
41
|
|
55
|
-
def unmatching?
|
56
|
-
!matching?
|
57
|
-
end
|
58
|
-
|
59
|
-
def matching?
|
60
|
-
true
|
61
|
-
end
|
62
|
-
|
63
|
-
private
|
64
|
-
|
65
42
|
def purge_cache
|
66
43
|
@cached_test_file = nil
|
67
44
|
end
|
68
45
|
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
46
|
end
|
86
|
-
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
|
+
puts(<<~FILES)
|
18
|
+
Files Selected:
|
19
|
+
- file: #{changed_file}
|
20
|
+
- test: #{cached_test_file}
|
21
|
+
|
22
|
+
FILES
|
23
|
+
|
24
|
+
system 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
|
+
puts <<~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
|
data/lib/retest/version.rb
CHANGED
data/lib/retest.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.5.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: 2021-10-
|
11
|
+
date: 2021-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: string-similarity
|
@@ -90,7 +90,11 @@ 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
|
95
99
|
- lib/retest/test_options.rb
|
96
100
|
- lib/retest/version.rb
|