guard-test 2.0.6 → 2.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -3
- data/lib/guard/test/command.rb +25 -0
- data/lib/guard/test/deprecator.rb +39 -0
- data/lib/guard/test/inspectors/base_inspector.rb +76 -0
- data/lib/guard/test/inspectors/factory.rb +29 -0
- data/lib/guard/test/inspectors/focused_inspector.rb +39 -0
- data/lib/guard/test/inspectors/keeping_inspector.rb +45 -0
- data/lib/guard/test/inspectors/simple_inspector.rb +23 -0
- data/lib/guard/test/options.rb +33 -0
- data/lib/guard/test/runner.rb +1 -1
- data/lib/guard/test/version.rb +1 -1
- metadata +11 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6545f67730c6d67d0c3019c5a5e474c70d1a7f6
|
4
|
+
data.tar.gz: 761a6bdc0b36ff34f263bcf6f1413d77b9f1923a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 064846bc8b88760dcb64d2d7732054f1c3ec0a608337b19f06d4e05407c90a2d30ef03231595dc724959ccc764a25f9958f9b2306b9d0fe32f62b88afd529807
|
7
|
+
data.tar.gz: 215c3d18ad61b34dc41dd838df9f905c2bbcdb1c7cba5c9a2954f5eaa5361863a7dfa056e71dc3aa99d0f4e6d932a4f4e292ce3db105f0eda7ee50af2b95477a
|
data/README.md
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
+
:exclamation: [Guard::Minitest](https://github.com/guard/guard-minitest) is a better alternative to Guard::Test, you should definitely check it out: https://github.com/guard/guard-minitest. :exclamation:
|
2
|
+
|
1
3
|
# Guard::Test
|
2
4
|
|
3
5
|
[![Gem Version](https://img.shields.io/gem/v/guard-test.svg?style=flat)](https://rubygems.org/gems/guard-test) [![Build Status](https://travis-ci.org/guard/guard-test.svg?branch=master)](https://travis-ci.org/guard/guard-test) [![Dependency Status](https://gemnasium.com/guard/guard-test.svg)](https://gemnasium.com/guard/guard-test) [![Code Climate](https://codeclimate.com/github/guard/guard-test/badges/gpa.svg)](https://codeclimate.com/github/guard/guard-test) [![Test Coverage](https://codeclimate.com/github/guard/guard-test/badges/coverage.svg)](https://codeclimate.com/github/guard/guard-test)
|
4
6
|
|
5
|
-
Guard::Test allows to automatically & intelligently launch tests when
|
7
|
+
Guard::Test allows to automatically & intelligently launch tests when you create or modify files.
|
6
8
|
|
7
9
|
* Compatible with Test::Unit 2.
|
8
|
-
* Tested against Ruby
|
10
|
+
* Tested against Ruby 2.1, 2.2, Rubinius & JRuby (1.9 mode only).
|
9
11
|
|
10
12
|
## Install
|
11
13
|
|
@@ -53,7 +55,7 @@ Or remove the test if it isn't necessary.
|
|
53
55
|
|
54
56
|
Please read the [Guard usage doc](https://github.com/guard/guard#readme).
|
55
57
|
|
56
|
-
By default, Guard::Test watch for files matching `test_*.rb` or `*_test{s,}.rb` in the `test` directory (
|
58
|
+
By default, Guard::Test watch for files matching `test_*.rb` or `*_test{s,}.rb` in the `test` directory (you can change this directory with the `test_paths` option, see below).
|
57
59
|
|
58
60
|
## Guardfile
|
59
61
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Guard
|
2
|
+
class Test < Plugin
|
3
|
+
class Command < String
|
4
|
+
|
5
|
+
attr_accessor :paths, :options
|
6
|
+
|
7
|
+
def initialize(paths, options = {})
|
8
|
+
@paths = paths
|
9
|
+
@options = options
|
10
|
+
super(_parts.join(' '))
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def _parts
|
16
|
+
parts = [options[:cmd]]
|
17
|
+
parts << '-Ilib:test'
|
18
|
+
parts << "-r #{File.dirname(__FILE__)}/guard_test_runner.rb"
|
19
|
+
parts << "-e \"%w[#{paths.join(' ')}].each { |p| load p }\""
|
20
|
+
# parts << Array(options[:include]).map { |path| "-I\"#{path}\"" } unless zeus? || spring?
|
21
|
+
parts << '-- --use-color --runner=guard_test'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Guard
|
2
|
+
class Test < Plugin
|
3
|
+
class Deprecator
|
4
|
+
attr_accessor :options
|
5
|
+
|
6
|
+
def self.warns_about_deprecated_options(options = {})
|
7
|
+
new(options).warns_about_deprecated_options
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(options = {})
|
11
|
+
@options = options
|
12
|
+
end
|
13
|
+
|
14
|
+
def warns_about_deprecated_options
|
15
|
+
_use_cmd_option
|
16
|
+
_keep_failed_option
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def _use_cmd_option
|
22
|
+
%w[bundler rubygems cli rvm drb spring zeus include].each do |option|
|
23
|
+
next unless options.key?(option.to_sym)
|
24
|
+
_deprecated("The :#{option} option is deprecated. Please customize the new :cmd option to fit your need.")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def _keep_failed_option
|
29
|
+
return unless options.key?(:keep_failed)
|
30
|
+
_deprecated('The :keep_failed option is deprecated. Please set new :failed_mode option value to :keep instead. https://github.com/guard/guard-test#list-of-available-options')
|
31
|
+
end
|
32
|
+
|
33
|
+
def _deprecated(message)
|
34
|
+
UI.warning %{Guard::RSpec DEPRECATION WARNING: #{message}}
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module Guard
|
2
|
+
class Test < Plugin
|
3
|
+
module Inspectors
|
4
|
+
|
5
|
+
class BaseInspector
|
6
|
+
attr_accessor :options, :test_paths
|
7
|
+
|
8
|
+
def initialize(options = {})
|
9
|
+
@options = options
|
10
|
+
@test_paths = @options[:test_paths]
|
11
|
+
end
|
12
|
+
|
13
|
+
def paths(paths)
|
14
|
+
raise _abstract
|
15
|
+
end
|
16
|
+
|
17
|
+
def failed(locations)
|
18
|
+
raise _abstract
|
19
|
+
end
|
20
|
+
|
21
|
+
def reload
|
22
|
+
raise _abstract
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def _abstract
|
28
|
+
'Must be implemented in subclass'
|
29
|
+
end
|
30
|
+
|
31
|
+
def _clean(paths)
|
32
|
+
cleaned_paths = paths.dup
|
33
|
+
|
34
|
+
paths.each do |path|
|
35
|
+
if _test_folder?(path)
|
36
|
+
cleaned_paths.delete(path)
|
37
|
+
cleaned_paths += _check_test_files(path)
|
38
|
+
else
|
39
|
+
cleaned_paths.delete(path) unless _test_file?(path)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
cleaned_paths.uniq!
|
44
|
+
cleaned_paths.compact!
|
45
|
+
_clear_test_files_list
|
46
|
+
puts "cleaned #{cleaned_paths}"
|
47
|
+
|
48
|
+
cleaned_paths.sort - ['test/test_helper.rb']
|
49
|
+
end
|
50
|
+
|
51
|
+
def _test_folder?(path)
|
52
|
+
paths = test_paths.join("|")
|
53
|
+
path.match(%r{^\/?(#{paths})}) && !path.match(/\..+$/) && File.directory?(path)
|
54
|
+
end
|
55
|
+
|
56
|
+
def _test_file?(path)
|
57
|
+
_test_files.include?(path)
|
58
|
+
end
|
59
|
+
|
60
|
+
def _test_files
|
61
|
+
@_test_files ||= test_paths.collect { |path| _check_test_files(path) }.flatten
|
62
|
+
end
|
63
|
+
|
64
|
+
def _clear_test_files_list
|
65
|
+
@_test_files = nil
|
66
|
+
end
|
67
|
+
|
68
|
+
def _check_test_files(path)
|
69
|
+
Dir[File.join(path, '**', 'test_*.rb')] +
|
70
|
+
Dir[File.join(path, '**', '*_test{s,}.rb')]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'guard/test/inspectors/focused_inspector'
|
2
|
+
require 'guard/test/inspectors/keeping_inspector'
|
3
|
+
require 'guard/test/inspectors/simple_inspector'
|
4
|
+
|
5
|
+
module Guard
|
6
|
+
class Test < Plugin
|
7
|
+
module Inspectors
|
8
|
+
|
9
|
+
class Factory
|
10
|
+
class << self
|
11
|
+
def create(options = {})
|
12
|
+
case options[:failed_mode]
|
13
|
+
when :focus
|
14
|
+
FocusedInspector.new(options)
|
15
|
+
when :keep
|
16
|
+
KeepingInspector.new(options)
|
17
|
+
else
|
18
|
+
SimpleInspector.new(options)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private :new
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'guard/test/inspectors/base_inspector'
|
2
|
+
|
3
|
+
module Guard
|
4
|
+
class Test < Plugin
|
5
|
+
module Inspectors
|
6
|
+
|
7
|
+
# Inspector that focuses on set of paths if any of them is failing.
|
8
|
+
# Returns only that set of paths on all future calls to #paths
|
9
|
+
# until they all pass
|
10
|
+
class FocusedInspector < BaseInspector
|
11
|
+
def initialize(options = {})
|
12
|
+
super
|
13
|
+
@focused_locations = []
|
14
|
+
end
|
15
|
+
|
16
|
+
def paths(paths)
|
17
|
+
if @focused_locations.any?
|
18
|
+
@focused_locations
|
19
|
+
else
|
20
|
+
_clean(paths)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def failed(locations)
|
25
|
+
if locations.empty?
|
26
|
+
@focused_locations = []
|
27
|
+
else
|
28
|
+
@focused_locations = locations if @focused_locations.empty?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def reload
|
33
|
+
@focused_locations = []
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'guard/test/inspectors/base_inspector'
|
2
|
+
|
3
|
+
module Guard
|
4
|
+
class Test < Plugin
|
5
|
+
module Inspectors
|
6
|
+
|
7
|
+
# Inspector that remembers all failed paths and
|
8
|
+
# returns that paths in future calls to #paths method
|
9
|
+
# along with any new paths passed as parameter to #paths
|
10
|
+
class KeepingInspector < BaseInspector
|
11
|
+
def initialize(options = {})
|
12
|
+
super
|
13
|
+
@failed_locations = []
|
14
|
+
end
|
15
|
+
|
16
|
+
def paths(paths)
|
17
|
+
_with_failed_locations(_clean(paths))
|
18
|
+
end
|
19
|
+
|
20
|
+
def failed(locations)
|
21
|
+
@failed_locations = locations
|
22
|
+
end
|
23
|
+
|
24
|
+
def reload
|
25
|
+
@failed_locations = []
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
# Return paths + failed locations.
|
31
|
+
# Do not include location in result if its path is already included.
|
32
|
+
def _with_failed_locations(paths)
|
33
|
+
failed_paths = @failed_locations.map { |l| _location_path(l) }
|
34
|
+
(paths | failed_paths).uniq
|
35
|
+
end
|
36
|
+
|
37
|
+
# Extract file path from location
|
38
|
+
def _location_path(location)
|
39
|
+
location.match(/^(\.\/)?(.*?)(:\d+)?$/)[2]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'guard/test/inspectors/base_inspector'
|
2
|
+
|
3
|
+
module Guard
|
4
|
+
class Test < Plugin
|
5
|
+
module Inspectors
|
6
|
+
|
7
|
+
class SimpleInspector < BaseInspector
|
8
|
+
def paths(paths)
|
9
|
+
_clean(paths)
|
10
|
+
end
|
11
|
+
|
12
|
+
def failed(locations)
|
13
|
+
# Don't care
|
14
|
+
end
|
15
|
+
|
16
|
+
def reload
|
17
|
+
# Nothing to reload
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Guard
|
2
|
+
class Test
|
3
|
+
module Options
|
4
|
+
DEFAULTS = {
|
5
|
+
all_on_start: false,
|
6
|
+
all_after_pass: false,
|
7
|
+
run_all: { message: 'Running all tests' },
|
8
|
+
failed_mode: :focus, # :keep and :none are other posibilities
|
9
|
+
test_paths: %w[test],
|
10
|
+
cmd: 'ruby',
|
11
|
+
notification: true
|
12
|
+
}.freeze
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def with_defaults(options = {})
|
16
|
+
_deep_merge(DEFAULTS, options).freeze
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def _deep_merge(hash1, hash2)
|
22
|
+
hash1.merge(hash2) do |key, oldval, newval|
|
23
|
+
if oldval.instance_of?(Hash) && newval.instance_of?(Hash)
|
24
|
+
_deep_merge(oldval, newval)
|
25
|
+
else
|
26
|
+
newval
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/guard/test/runner.rb
CHANGED
@@ -100,7 +100,7 @@ module Guard
|
|
100
100
|
def includes_and_requires(paths)
|
101
101
|
parts = []
|
102
102
|
parts << Array(options[:include]).map { |path| "-I\"#{path}\"" } unless zeus? || spring?
|
103
|
-
parts << paths if zeus? || spring?
|
103
|
+
parts << paths if zeus? || spring? || drb?
|
104
104
|
parts << '-r bundler/setup' if bundler?
|
105
105
|
parts << '-r rubygems' if rubygems?
|
106
106
|
|
data/lib/guard/test/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rémy Coutable
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-unit
|
@@ -62,9 +62,17 @@ files:
|
|
62
62
|
- LICENSE
|
63
63
|
- README.md
|
64
64
|
- lib/guard/test.rb
|
65
|
+
- lib/guard/test/command.rb
|
66
|
+
- lib/guard/test/deprecator.rb
|
65
67
|
- lib/guard/test/guard_test_runner.rb
|
66
68
|
- lib/guard/test/inspector.rb
|
69
|
+
- lib/guard/test/inspectors/base_inspector.rb
|
70
|
+
- lib/guard/test/inspectors/factory.rb
|
71
|
+
- lib/guard/test/inspectors/focused_inspector.rb
|
72
|
+
- lib/guard/test/inspectors/keeping_inspector.rb
|
73
|
+
- lib/guard/test/inspectors/simple_inspector.rb
|
67
74
|
- lib/guard/test/notifier.rb
|
75
|
+
- lib/guard/test/options.rb
|
68
76
|
- lib/guard/test/runner.rb
|
69
77
|
- lib/guard/test/templates/Guardfile
|
70
78
|
- lib/guard/test/version.rb
|
@@ -88,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
96
|
version: '0'
|
89
97
|
requirements: []
|
90
98
|
rubyforge_project:
|
91
|
-
rubygems_version: 2.
|
99
|
+
rubygems_version: 2.4.5.1
|
92
100
|
signing_key:
|
93
101
|
specification_version: 4
|
94
102
|
summary: Guard plugin for Test::Unit 2
|