retest 0.9.0 → 1.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +1 -0
- data/Gemfile.lock +2 -2
- data/README.md +4 -0
- data/bin/debug +10 -2
- data/bin/test/git-ruby +6 -0
- data/exe/retest +10 -2
- data/lib/retest.rb +27 -9
- data/lib/retest/options.rb +11 -0
- data/lib/retest/repository.rb +12 -2
- data/lib/retest/runner.rb +16 -0
- data/lib/retest/version.rb +1 -1
- data/lib/retest/version_control.rb +3 -38
- data/lib/retest/version_control/git.rb +33 -0
- data/lib/retest/version_control/no_version_control.rb +15 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 283264ef544ab1d67927bd21f53d36e3f210570453bf59ca09edf83cef6111d2
|
4
|
+
data.tar.gz: 05304a016fc791d8ea4a21b3a44fd4e74d5ccd1ec659db3f3227cc3c04e17f87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d458a1d91538f3a8bc0b60baff4f399c7cfa495c83a1fa47a1cd054c809239084c640fbd15b89efd15e53ea7110d3291b054567f2d0b599f6541c615a8e985e
|
7
|
+
data.tar.gz: 0d55c10145f7f77c755d66aff6f719731401026444f1c3911ccbee3ffeb089257303e87b80de6edd98a273138b6e481c0af97aaaab395ff9c81f1cdf8659bfcb
|
data/.github/workflows/ci.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
retest (0.
|
4
|
+
retest (1.0.0.pre)
|
5
5
|
listen (~> 3.2)
|
6
6
|
string-similarity (~> 2.1)
|
7
7
|
tty-option (~> 0.1)
|
@@ -11,7 +11,7 @@ GEM
|
|
11
11
|
specs:
|
12
12
|
byebug (11.1.3)
|
13
13
|
ffi (1.15.0)
|
14
|
-
listen (3.
|
14
|
+
listen (3.5.0)
|
15
15
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
16
16
|
rb-inotify (~> 0.9, >= 0.9.10)
|
17
17
|
minitest (5.14.1)
|
data/README.md
CHANGED
@@ -82,6 +82,10 @@ Examples:
|
|
82
82
|
Let retest identify which command to run for all tests
|
83
83
|
$ retest --all
|
84
84
|
$ retest --auto --all
|
85
|
+
|
86
|
+
Run a sanity check on changed files from a branch
|
87
|
+
$ retest --diff origin/main --rails
|
88
|
+
$ retest --diff main --auto
|
85
89
|
```
|
86
90
|
|
87
91
|
## Why?
|
data/bin/debug
CHANGED
@@ -13,6 +13,14 @@ if options.help?
|
|
13
13
|
return
|
14
14
|
end
|
15
15
|
|
16
|
-
Retest.
|
16
|
+
program = Retest::Program.new(
|
17
|
+
repository: Retest::Repository.new(files: Retest::VersionControl.files),
|
18
|
+
runner: Retest::Runner.for(options.command)
|
19
|
+
)
|
17
20
|
|
18
|
-
|
21
|
+
if options.params[:diff]
|
22
|
+
program.diff(options.params[:diff])
|
23
|
+
else
|
24
|
+
program.start # not blocking
|
25
|
+
sleep
|
26
|
+
end
|
data/bin/test/git-ruby
ADDED
data/exe/retest
CHANGED
@@ -11,6 +11,14 @@ if options.help?
|
|
11
11
|
return
|
12
12
|
end
|
13
13
|
|
14
|
-
Retest.
|
14
|
+
program = Retest::Program.new(
|
15
|
+
repository: Retest::Repository.new(files: Retest::VersionControl.files),
|
16
|
+
runner: Retest::Runner.for(options.command)
|
17
|
+
)
|
15
18
|
|
16
|
-
|
19
|
+
if options.params[:diff]
|
20
|
+
program.diff(options.params[:diff])
|
21
|
+
else
|
22
|
+
program.start # not blocking
|
23
|
+
sleep
|
24
|
+
end
|
data/lib/retest.rb
CHANGED
@@ -12,19 +12,33 @@ require "retest/setup"
|
|
12
12
|
module Retest
|
13
13
|
class Error < StandardError; end
|
14
14
|
|
15
|
-
class
|
16
|
-
|
15
|
+
class Program
|
16
|
+
attr_accessor :runner, :repository
|
17
|
+
def initialize(runner: nil, repository: nil)
|
18
|
+
@runner = runner
|
19
|
+
@repository = repository
|
20
|
+
end
|
21
|
+
|
22
|
+
def start
|
17
23
|
puts "Launching Retest..."
|
24
|
+
build.start
|
25
|
+
puts "Ready to refactor! You can make file changes now"
|
26
|
+
end
|
18
27
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
).start
|
28
|
+
def diff(branch)
|
29
|
+
raise "Git not installed" unless VersionControl::Git.installed?
|
30
|
+
test_files = repository.find_tests VersionControl::Git.diff_files(branch)
|
23
31
|
|
24
|
-
puts "
|
32
|
+
puts "Tests found:"
|
33
|
+
test_files.each { |test_file| puts " - #{test_file}" }
|
34
|
+
|
35
|
+
puts "Running tests..."
|
36
|
+
test_files.each { |test_file| runner.run test_file }
|
25
37
|
end
|
26
38
|
|
27
|
-
|
39
|
+
private
|
40
|
+
|
41
|
+
def build
|
28
42
|
Listen.to('.', only: /\.rb$/, relative: true) do |modified, added, removed|
|
29
43
|
begin
|
30
44
|
repository.add(added)
|
@@ -32,11 +46,15 @@ module Retest
|
|
32
46
|
runner.remove(removed)
|
33
47
|
system('clear 2>/dev/null') || system('cls 2>/dev/null')
|
34
48
|
|
35
|
-
runner.run
|
49
|
+
runner.run test_file_to_run(modified + added)
|
36
50
|
rescue => e
|
37
51
|
puts "Something went wrong: #{e.message}"
|
38
52
|
end
|
39
53
|
end
|
40
54
|
end
|
55
|
+
|
56
|
+
def test_file_to_run(changed_files)
|
57
|
+
repository.find_test changed_files.first if runner.matching?
|
58
|
+
end
|
41
59
|
end
|
42
60
|
end
|
data/lib/retest/options.rb
CHANGED
@@ -48,6 +48,12 @@ module Retest
|
|
48
48
|
$ retest --all
|
49
49
|
$ retest --auto --all
|
50
50
|
EOS
|
51
|
+
|
52
|
+
example <<~EOS
|
53
|
+
Run a sanity check on changed files from a branch
|
54
|
+
$ retest --diff origin/main --rails
|
55
|
+
$ retest --diff main --auto
|
56
|
+
EOS
|
51
57
|
end
|
52
58
|
|
53
59
|
argument :command do
|
@@ -58,6 +64,11 @@ module Retest
|
|
58
64
|
EOS
|
59
65
|
end
|
60
66
|
|
67
|
+
option :diff do
|
68
|
+
desc "Pipes all matching tests from diffed branch to test command"
|
69
|
+
long "--diff=git-branch"
|
70
|
+
end
|
71
|
+
|
61
72
|
flag :all do
|
62
73
|
long "--all"
|
63
74
|
desc "Run all the specs of a specificied ruby setup"
|
data/lib/retest/repository.rb
CHANGED
@@ -13,7 +13,17 @@ module Retest
|
|
13
13
|
return unless path
|
14
14
|
return if path.empty?
|
15
15
|
|
16
|
-
|
16
|
+
@path = path
|
17
|
+
cache[@path] ||= select_from TestOptions.for(@path, files: files)
|
18
|
+
end
|
19
|
+
|
20
|
+
def find_tests(paths)
|
21
|
+
paths
|
22
|
+
.select { |path| Regexp.new("\.rb$") =~ path }
|
23
|
+
.map { |path| find_test(path) }
|
24
|
+
.compact
|
25
|
+
.uniq
|
26
|
+
.sort
|
17
27
|
end
|
18
28
|
|
19
29
|
def add(added)
|
@@ -47,7 +57,7 @@ module Retest
|
|
47
57
|
|
48
58
|
def ask_question(tests)
|
49
59
|
output_stream.puts <<~QUESTION
|
50
|
-
We found few tests matching:
|
60
|
+
We found few tests matching: #{@path}
|
51
61
|
#{list_options(tests)}
|
52
62
|
|
53
63
|
Which file do you want to use?
|
data/lib/retest/runner.rb
CHANGED
@@ -52,6 +52,14 @@ module Retest
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
+
def unmatching?
|
56
|
+
!matching?
|
57
|
+
end
|
58
|
+
|
59
|
+
def matching?
|
60
|
+
true
|
61
|
+
end
|
62
|
+
|
55
63
|
private
|
56
64
|
|
57
65
|
def purge_cache
|
@@ -65,6 +73,14 @@ module Retest
|
|
65
73
|
end
|
66
74
|
|
67
75
|
def remove(_ = nil); end
|
76
|
+
|
77
|
+
def unmatching?
|
78
|
+
!matching?
|
79
|
+
end
|
80
|
+
|
81
|
+
def matching?
|
82
|
+
false
|
83
|
+
end
|
68
84
|
end
|
69
85
|
end
|
70
86
|
end
|
data/lib/retest/version.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
require_relative 'version_control/git'
|
2
|
+
require_relative 'version_control/no_version_control'
|
3
|
+
|
1
4
|
module Retest
|
2
5
|
class VersionControl
|
3
6
|
def self.files
|
@@ -6,43 +9,5 @@ module Retest
|
|
6
9
|
|
7
10
|
def name; end
|
8
11
|
alias :to_s :name
|
9
|
-
|
10
|
-
class NoVersionControl
|
11
|
-
def self.installed?
|
12
|
-
true
|
13
|
-
end
|
14
|
-
|
15
|
-
def name
|
16
|
-
'default'
|
17
|
-
end
|
18
|
-
|
19
|
-
def files
|
20
|
-
Dir.glob('**/*') - Dir.glob('{tmp,node_modules}/**/*')
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
class Git
|
25
|
-
def self.installed?
|
26
|
-
system "git -C . rev-parse 2>/dev/null"
|
27
|
-
end
|
28
|
-
|
29
|
-
def name
|
30
|
-
'git'
|
31
|
-
end
|
32
|
-
|
33
|
-
def files
|
34
|
-
(untracked_files + tracked_files).sort
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def untracked_files
|
40
|
-
`git ls-files --other --exclude-standard -z`.split("\x0")
|
41
|
-
end
|
42
|
-
|
43
|
-
def tracked_files
|
44
|
-
`git ls-files -z`.split("\x0")
|
45
|
-
end
|
46
|
-
end
|
47
12
|
end
|
48
13
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class Retest::VersionControl
|
2
|
+
class Git
|
3
|
+
def self.installed?
|
4
|
+
system "git -C . rev-parse 2>/dev/null"
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.diff_files(branch)
|
8
|
+
new.diff_files(branch)
|
9
|
+
end
|
10
|
+
|
11
|
+
def name
|
12
|
+
'git'
|
13
|
+
end
|
14
|
+
|
15
|
+
def files
|
16
|
+
(untracked_files + tracked_files).sort
|
17
|
+
end
|
18
|
+
|
19
|
+
def diff_files(branch)
|
20
|
+
`git diff #{branch} --name-only --diff-filter=ACMRT -z`.split("\x0")
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def untracked_files
|
26
|
+
`git ls-files --other --exclude-standard -z`.split("\x0")
|
27
|
+
end
|
28
|
+
|
29
|
+
def tracked_files
|
30
|
+
`git ls-files -z`.split("\x0")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
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: 0.
|
4
|
+
version: 1.0.0.pre
|
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-03-
|
11
|
+
date: 2021-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: string-similarity
|
@@ -72,6 +72,7 @@ files:
|
|
72
72
|
- bin/console
|
73
73
|
- bin/debug
|
74
74
|
- bin/setup
|
75
|
+
- bin/test/git-ruby
|
75
76
|
- bin/test/hanami-app
|
76
77
|
- bin/test/rails-app
|
77
78
|
- bin/test/rspec-rails
|
@@ -86,6 +87,8 @@ files:
|
|
86
87
|
- lib/retest/test_options.rb
|
87
88
|
- lib/retest/version.rb
|
88
89
|
- lib/retest/version_control.rb
|
90
|
+
- lib/retest/version_control/git.rb
|
91
|
+
- lib/retest/version_control/no_version_control.rb
|
89
92
|
- retest.gemspec
|
90
93
|
homepage: https://github.com/AlexB52/retest
|
91
94
|
licenses:
|
@@ -104,9 +107,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
104
107
|
version: 2.3.0
|
105
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
109
|
requirements:
|
107
|
-
- - "
|
110
|
+
- - ">"
|
108
111
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
112
|
+
version: 1.3.1
|
110
113
|
requirements: []
|
111
114
|
rubygems_version: 3.0.3
|
112
115
|
signing_key:
|