guard-phpunit 0.1.3 → 0.1.4
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.
- data/CHANGELOG.md +37 -0
- data/LICENSE +19 -19
- data/README.md +106 -106
- data/lib/guard/phpunit.rb +112 -112
- data/lib/guard/phpunit/formatter.rb +64 -64
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/PHPUnit/Extensions/Progress/ResultPrinter.php +498 -498
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/README.markdown +44 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/Tests/_files/Number.php +78 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/Tests/_files/NumberTest.php +99 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/Tests/_files/emptyTest.php +6 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/Tests/printer_basic.phpt +22 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/Tests/printer_errors.phpt +27 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/Tests/printer_errors_variation.phpt +28 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/Tests/printer_failing.phpt +31 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/Tests/printer_failing_variation.phpt +32 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/Tests/printer_incomplete.phpt +19 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/Tests/printer_incomplete_variation.phpt +20 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/Tests/printer_passing.phpt +19 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/Tests/printer_passing_variation.phpt +20 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/Tests/printer_skipped.phpt +19 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/Tests/printer_skipped_variation.phpt +20 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/phpunit.xml +4 -0
- data/lib/guard/phpunit/formatters/PHPUnit-Progress/screenshot.png +0 -0
- data/lib/guard/phpunit/inspector.rb +54 -54
- data/lib/guard/phpunit/notifier.rb +68 -68
- data/lib/guard/phpunit/runner.rb +197 -194
- data/lib/guard/phpunit/templates/Guardfile +3 -3
- data/lib/guard/phpunit/version.rb +6 -6
- metadata +37 -3
data/CHANGELOG.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
## 0.1.4 - August 09, 2012
|
2
|
+
|
3
|
+
- [#2][]: Add support for Windows.
|
4
|
+
|
5
|
+
## 0.1.3 - June 15, 2012
|
6
|
+
|
7
|
+
- [#3][]: Support Guard v1.1 API.
|
8
|
+
|
9
|
+
## 0.1.2 - January 26, 2012
|
10
|
+
|
11
|
+
- Fix checking phpunit existence on zsh.
|
12
|
+
- Update Guard to it's first gold release.
|
13
|
+
- Small bug fixes.
|
14
|
+
|
15
|
+
## 0.1.1 - January 03, 2012
|
16
|
+
|
17
|
+
- Update gem dependencies.
|
18
|
+
- Small bug fixes.
|
19
|
+
|
20
|
+
## 0.1.0 - November 30, 2011
|
21
|
+
|
22
|
+
- Add detection for phpunit existence.
|
23
|
+
- Add the `:keep_failed` option.
|
24
|
+
- Add the `:all_after_pass` option.
|
25
|
+
- Refactor a portion of the code and small bug fixes.
|
26
|
+
|
27
|
+
## 0.0.2 - 0.0.3 - November 25, 2011
|
28
|
+
|
29
|
+
- Small bug fixes.
|
30
|
+
|
31
|
+
## 0.0.1 - November 24, 2011
|
32
|
+
|
33
|
+
- Initial release.
|
34
|
+
|
35
|
+
<!--- The following link definition list is generated by PimpMyChangelog --->
|
36
|
+
[#2]: https://github.com/Maher4Ever/guard-phpunit/issues/2
|
37
|
+
[#3]: https://github.com/Maher4Ever/guard-phpunit/issues/3
|
data/LICENSE
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
Copyright (C) 2011 by Maher Sallam
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
-
of this software and associated documentation files (the "Software"), to deal
|
5
|
-
in the Software without restriction, including without limitation the rights
|
6
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
-
copies of the Software, and to permit persons to whom the Software is
|
8
|
-
furnished to do so, subject to the following conditions:
|
9
|
-
|
10
|
-
The above copyright notice and this permission notice shall be included in
|
11
|
-
all copies or substantial portions of the Software.
|
12
|
-
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
-
THE SOFTWARE.
|
1
|
+
Copyright (C) 2011 by Maher Sallam
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,106 +1,106 @@
|
|
1
|
-
Guard::PHPUnit [](http://travis-ci.org/Maher4Ever/guard-phpunit) [](https://gemnasium.com/Maher4Ever/guard-phpunit)
|
2
|
-
==============
|
3
|
-
|
4
|
-
Guard-phpunit allows you to automatically run [PHPUnit][6] tests when sources
|
5
|
-
are modified. It helps with integrating test-driven development (TDD) into
|
6
|
-
your development process: Just launch guard-phpunit before you start working
|
7
|
-
and it will notify you about the status of your tests!
|
8
|
-
|
9
|
-
*Note*: Although guard-phpunit should work with any [PHP][7] version [PHPUnit][6] supports,
|
10
|
-
it has only been tested on [PHP][7] 5.3.8 and 5.4.4.
|
11
|
-
|
12
|
-
Install
|
13
|
-
-------
|
14
|
-
|
15
|
-
Please be sure to have [PHP][7], [PHPUnit][6] and [Ruby][1] installed on your machine before
|
16
|
-
you proceed with the installation.
|
17
|
-
|
18
|
-
The latest versions of [Ruby][1] come with a packages-manager called `gem`. `gem` can be used to
|
19
|
-
install various packages, including guard-phpunit.
|
20
|
-
|
21
|
-
To install guard-phpunit, run the following command in the terminal:
|
22
|
-
|
23
|
-
```shell
|
24
|
-
$ gem install guard-phpunit
|
25
|
-
```
|
26
|
-
|
27
|
-
Usage
|
28
|
-
-----
|
29
|
-
|
30
|
-
Please read the [Guard usage documentation][3].
|
31
|
-
|
32
|
-
Guardfile
|
33
|
-
---------
|
34
|
-
|
35
|
-
Guard-phpunit can be used with any kind of [PHP][7] projects that uses PHPUnit as
|
36
|
-
its testing framwork. Please read the [Guard documentation][3] for more information
|
37
|
-
about the Guardfile DSL.
|
38
|
-
|
39
|
-
By default, guard-phpunit will use the current working directory (pwd) to
|
40
|
-
search for tests and run them on start (if you enabled the `:all_on_start` option).
|
41
|
-
|
42
|
-
### Example PHP project
|
43
|
-
|
44
|
-
The [PHPUnit documentaion][4] uses the [Object Freezer][5] library as an example on how
|
45
|
-
to organize tests. This project uses the `Tests` directory for its tests.
|
46
|
-
|
47
|
-
An example of the Guardfile for the same project would look
|
48
|
-
something like:
|
49
|
-
|
50
|
-
```ruby
|
51
|
-
guard 'phpunit', :tests_path => 'Tests', :cli => '--colors' do
|
52
|
-
# Watch tests files
|
53
|
-
watch(%r{^.+Test\.php$})
|
54
|
-
|
55
|
-
# Watch library files and run their tests
|
56
|
-
watch(%r{^Object/(.+)\.php}) { |m| "Tests/#{m[1]}Test.php" }
|
57
|
-
end
|
58
|
-
```
|
59
|
-
|
60
|
-
Options
|
61
|
-
-------
|
62
|
-
|
63
|
-
The following options can be passed to Guard::PHPUnit:
|
64
|
-
|
65
|
-
```ruby
|
66
|
-
:all_on_start => false # Run all tests on startup.
|
67
|
-
# default: true
|
68
|
-
|
69
|
-
:all_after_pass => false # Run all tests after changed tests pass. This ensures
|
70
|
-
# that the process of making changed tests pass didn't
|
71
|
-
# break something else.
|
72
|
-
# default: true
|
73
|
-
|
74
|
-
:keep_failed => false # Remember failed tests and keep running them with
|
75
|
-
# each change until they pass.
|
76
|
-
# default: true
|
77
|
-
|
78
|
-
:tests_path => 'tests' # Relative path to the tests directory. This path
|
79
|
-
# is used when running all the tests.
|
80
|
-
# default: the current working directory (pwd)
|
81
|
-
|
82
|
-
:cli => '--colors' # The options passed to the phpunit command
|
83
|
-
# when running the tests.
|
84
|
-
# default: nil
|
85
|
-
```
|
86
|
-
|
87
|
-
Development
|
88
|
-
-----------
|
89
|
-
|
90
|
-
* Source hosted at [GitHub](https://github.com/Maher4Ever/guard-phpunit)
|
91
|
-
* Report issues/Questions/Feature requests on [GitHub Issues](https://github.com/Maher4Ever/guard-phpunit/issues)
|
92
|
-
|
93
|
-
Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change
|
94
|
-
you make.
|
95
|
-
|
96
|
-
Author
|
97
|
-
------
|
98
|
-
|
99
|
-
[Maher Sallam](https://github.com/Maher4Ever)
|
100
|
-
|
101
|
-
[1]:http://ruby-lang.org
|
102
|
-
[3]:https://github.com/guard/guard#readme
|
103
|
-
[4]:http://www.phpunit.de/manual/current/en/
|
104
|
-
[5]:https://github.com/sebastianbergmann/php-object-freezer/
|
105
|
-
[6]:http://www.phpunit.de
|
106
|
-
[7]:http://php.net
|
1
|
+
Guard::PHPUnit [](http://travis-ci.org/Maher4Ever/guard-phpunit) [](https://gemnasium.com/Maher4Ever/guard-phpunit)
|
2
|
+
==============
|
3
|
+
|
4
|
+
Guard-phpunit allows you to automatically run [PHPUnit][6] tests when sources
|
5
|
+
are modified. It helps with integrating test-driven development (TDD) into
|
6
|
+
your development process: Just launch guard-phpunit before you start working
|
7
|
+
and it will notify you about the status of your tests!
|
8
|
+
|
9
|
+
*Note*: Although guard-phpunit should work with any [PHP][7] version [PHPUnit][6] supports,
|
10
|
+
it has only been tested on [PHP][7] 5.3.8 and 5.4.4.
|
11
|
+
|
12
|
+
Install
|
13
|
+
-------
|
14
|
+
|
15
|
+
Please be sure to have [PHP][7], [PHPUnit][6] and [Ruby][1] installed on your machine before
|
16
|
+
you proceed with the installation.
|
17
|
+
|
18
|
+
The latest versions of [Ruby][1] come with a packages-manager called `gem`. `gem` can be used to
|
19
|
+
install various packages, including guard-phpunit.
|
20
|
+
|
21
|
+
To install guard-phpunit, run the following command in the terminal:
|
22
|
+
|
23
|
+
```shell
|
24
|
+
$ gem install guard-phpunit
|
25
|
+
```
|
26
|
+
|
27
|
+
Usage
|
28
|
+
-----
|
29
|
+
|
30
|
+
Please read the [Guard usage documentation][3].
|
31
|
+
|
32
|
+
Guardfile
|
33
|
+
---------
|
34
|
+
|
35
|
+
Guard-phpunit can be used with any kind of [PHP][7] projects that uses PHPUnit as
|
36
|
+
its testing framwork. Please read the [Guard documentation][3] for more information
|
37
|
+
about the Guardfile DSL.
|
38
|
+
|
39
|
+
By default, guard-phpunit will use the current working directory (pwd) to
|
40
|
+
search for tests and run them on start (if you enabled the `:all_on_start` option).
|
41
|
+
|
42
|
+
### Example PHP project
|
43
|
+
|
44
|
+
The [PHPUnit documentaion][4] uses the [Object Freezer][5] library as an example on how
|
45
|
+
to organize tests. This project uses the `Tests` directory for its tests.
|
46
|
+
|
47
|
+
An example of the Guardfile for the same project would look
|
48
|
+
something like:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
guard 'phpunit', :tests_path => 'Tests', :cli => '--colors' do
|
52
|
+
# Watch tests files
|
53
|
+
watch(%r{^.+Test\.php$})
|
54
|
+
|
55
|
+
# Watch library files and run their tests
|
56
|
+
watch(%r{^Object/(.+)\.php}) { |m| "Tests/#{m[1]}Test.php" }
|
57
|
+
end
|
58
|
+
```
|
59
|
+
|
60
|
+
Options
|
61
|
+
-------
|
62
|
+
|
63
|
+
The following options can be passed to Guard::PHPUnit:
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
:all_on_start => false # Run all tests on startup.
|
67
|
+
# default: true
|
68
|
+
|
69
|
+
:all_after_pass => false # Run all tests after changed tests pass. This ensures
|
70
|
+
# that the process of making changed tests pass didn't
|
71
|
+
# break something else.
|
72
|
+
# default: true
|
73
|
+
|
74
|
+
:keep_failed => false # Remember failed tests and keep running them with
|
75
|
+
# each change until they pass.
|
76
|
+
# default: true
|
77
|
+
|
78
|
+
:tests_path => 'tests' # Relative path to the tests directory. This path
|
79
|
+
# is used when running all the tests.
|
80
|
+
# default: the current working directory (pwd)
|
81
|
+
|
82
|
+
:cli => '--colors' # The options passed to the phpunit command
|
83
|
+
# when running the tests.
|
84
|
+
# default: nil
|
85
|
+
```
|
86
|
+
|
87
|
+
Development
|
88
|
+
-----------
|
89
|
+
|
90
|
+
* Source hosted at [GitHub](https://github.com/Maher4Ever/guard-phpunit)
|
91
|
+
* Report issues/Questions/Feature requests on [GitHub Issues](https://github.com/Maher4Ever/guard-phpunit/issues)
|
92
|
+
|
93
|
+
Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change
|
94
|
+
you make.
|
95
|
+
|
96
|
+
Author
|
97
|
+
------
|
98
|
+
|
99
|
+
[Maher Sallam](https://github.com/Maher4Ever)
|
100
|
+
|
101
|
+
[1]:http://ruby-lang.org
|
102
|
+
[3]:https://github.com/guard/guard#readme
|
103
|
+
[4]:http://www.phpunit.de/manual/current/en/
|
104
|
+
[5]:https://github.com/sebastianbergmann/php-object-freezer/
|
105
|
+
[6]:http://www.phpunit.de
|
106
|
+
[7]:http://php.net
|
data/lib/guard/phpunit.rb
CHANGED
@@ -1,112 +1,112 @@
|
|
1
|
-
require 'guard'
|
2
|
-
require 'guard/guard'
|
3
|
-
|
4
|
-
module Guard
|
5
|
-
|
6
|
-
# The PHPUnit guard gets notified about system
|
7
|
-
# events.
|
8
|
-
#
|
9
|
-
class PHPUnit < Guard
|
10
|
-
|
11
|
-
autoload :Inspector, 'guard/phpunit/inspector'
|
12
|
-
autoload :Formatter, 'guard/phpunit/formatter'
|
13
|
-
autoload :Notifier, 'guard/phpunit/notifier'
|
14
|
-
autoload :Runner, 'guard/phpunit/runner'
|
15
|
-
|
16
|
-
DEFAULT_OPTIONS = {
|
17
|
-
:all_on_start => true,
|
18
|
-
:all_after_pass => true,
|
19
|
-
:keep_failed => true,
|
20
|
-
:cli => nil,
|
21
|
-
:tests_path => Dir.pwd
|
22
|
-
}
|
23
|
-
|
24
|
-
# Initialize Guard::PHPUnit.
|
25
|
-
#
|
26
|
-
# @param [Array<Guard::Watcher>] watchers the watchers in the Guard block
|
27
|
-
# @param [Hash] options the options for the Guard
|
28
|
-
# @option options [Boolean] :all_on_start run all tests on start
|
29
|
-
# @option options [Boolean] :all_after_pass run all tests after failed tests pass
|
30
|
-
# @option options [Boolean] :keep_failed remember failed tests or not
|
31
|
-
# @option options [String] :cli The CLI arguments passed to phpunit
|
32
|
-
# @option options [String] :tests_path the path where all tests exist
|
33
|
-
#
|
34
|
-
def initialize(watchers = [], options = {})
|
35
|
-
defaults = DEFAULT_OPTIONS.clone
|
36
|
-
@options = defaults.merge(options)
|
37
|
-
super(watchers, @options)
|
38
|
-
|
39
|
-
@failed_paths = []
|
40
|
-
@previous_failed = false
|
41
|
-
|
42
|
-
Inspector.tests_path = @options[:tests_path]
|
43
|
-
end
|
44
|
-
|
45
|
-
# Gets called once when Guard starts.
|
46
|
-
#
|
47
|
-
# @raise [:task_has_failed] when stop has failed
|
48
|
-
#
|
49
|
-
def start
|
50
|
-
run_all if options[:all_on_start]
|
51
|
-
end
|
52
|
-
|
53
|
-
# Gets called when all tests should be run.
|
54
|
-
#
|
55
|
-
# @raise (see #start)
|
56
|
-
#
|
57
|
-
def run_all
|
58
|
-
success = Runner.run(options[:tests_path], options.merge(
|
59
|
-
:message => 'Running all tests'
|
60
|
-
))
|
61
|
-
|
62
|
-
@previous_failed = !success
|
63
|
-
throw :task_has_failed unless success
|
64
|
-
end
|
65
|
-
|
66
|
-
# Gets called when the watched tests have changes.
|
67
|
-
#
|
68
|
-
# @param [Array<String>] paths to the changed tests
|
69
|
-
# @raise (see #start)
|
70
|
-
#
|
71
|
-
def run_on_changes(paths)
|
72
|
-
paths = Inspector.clean(paths + @failed_paths)
|
73
|
-
success = Runner.run(paths, options)
|
74
|
-
|
75
|
-
update_failed_paths(success, paths)
|
76
|
-
run_all_after_pass(success)
|
77
|
-
throw :task_has_failed unless success
|
78
|
-
end
|
79
|
-
|
80
|
-
private
|
81
|
-
|
82
|
-
# Adds or removes path to the failed_paths bassed
|
83
|
-
# on the tests result.
|
84
|
-
#
|
85
|
-
# @param [Boolean] tests_passed whether the tests passed or not
|
86
|
-
# @param [Array<String>] paths the tests paths
|
87
|
-
#
|
88
|
-
def update_failed_paths(tests_passed, paths)
|
89
|
-
return unless @options[:keep_failed]
|
90
|
-
|
91
|
-
if tests_passed
|
92
|
-
@failed_paths -= paths
|
93
|
-
else
|
94
|
-
@failed_paths += paths
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
# Runs all tests after the failed tests pass.
|
99
|
-
#
|
100
|
-
# @param (see .update_failed_paths)
|
101
|
-
#
|
102
|
-
def run_all_after_pass(tests_passed)
|
103
|
-
return unless @options[:all_after_pass]
|
104
|
-
|
105
|
-
if tests_passed
|
106
|
-
run_all if @previous_failed
|
107
|
-
else
|
108
|
-
@previous_failed = true
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
1
|
+
require 'guard'
|
2
|
+
require 'guard/guard'
|
3
|
+
|
4
|
+
module Guard
|
5
|
+
|
6
|
+
# The PHPUnit guard gets notified about system
|
7
|
+
# events.
|
8
|
+
#
|
9
|
+
class PHPUnit < Guard
|
10
|
+
|
11
|
+
autoload :Inspector, 'guard/phpunit/inspector'
|
12
|
+
autoload :Formatter, 'guard/phpunit/formatter'
|
13
|
+
autoload :Notifier, 'guard/phpunit/notifier'
|
14
|
+
autoload :Runner, 'guard/phpunit/runner'
|
15
|
+
|
16
|
+
DEFAULT_OPTIONS = {
|
17
|
+
:all_on_start => true,
|
18
|
+
:all_after_pass => true,
|
19
|
+
:keep_failed => true,
|
20
|
+
:cli => nil,
|
21
|
+
:tests_path => Dir.pwd
|
22
|
+
}
|
23
|
+
|
24
|
+
# Initialize Guard::PHPUnit.
|
25
|
+
#
|
26
|
+
# @param [Array<Guard::Watcher>] watchers the watchers in the Guard block
|
27
|
+
# @param [Hash] options the options for the Guard
|
28
|
+
# @option options [Boolean] :all_on_start run all tests on start
|
29
|
+
# @option options [Boolean] :all_after_pass run all tests after failed tests pass
|
30
|
+
# @option options [Boolean] :keep_failed remember failed tests or not
|
31
|
+
# @option options [String] :cli The CLI arguments passed to phpunit
|
32
|
+
# @option options [String] :tests_path the path where all tests exist
|
33
|
+
#
|
34
|
+
def initialize(watchers = [], options = {})
|
35
|
+
defaults = DEFAULT_OPTIONS.clone
|
36
|
+
@options = defaults.merge(options)
|
37
|
+
super(watchers, @options)
|
38
|
+
|
39
|
+
@failed_paths = []
|
40
|
+
@previous_failed = false
|
41
|
+
|
42
|
+
Inspector.tests_path = @options[:tests_path]
|
43
|
+
end
|
44
|
+
|
45
|
+
# Gets called once when Guard starts.
|
46
|
+
#
|
47
|
+
# @raise [:task_has_failed] when stop has failed
|
48
|
+
#
|
49
|
+
def start
|
50
|
+
run_all if options[:all_on_start]
|
51
|
+
end
|
52
|
+
|
53
|
+
# Gets called when all tests should be run.
|
54
|
+
#
|
55
|
+
# @raise (see #start)
|
56
|
+
#
|
57
|
+
def run_all
|
58
|
+
success = Runner.run(options[:tests_path], options.merge(
|
59
|
+
:message => 'Running all tests'
|
60
|
+
))
|
61
|
+
|
62
|
+
@previous_failed = !success
|
63
|
+
throw :task_has_failed unless success
|
64
|
+
end
|
65
|
+
|
66
|
+
# Gets called when the watched tests have changes.
|
67
|
+
#
|
68
|
+
# @param [Array<String>] paths to the changed tests
|
69
|
+
# @raise (see #start)
|
70
|
+
#
|
71
|
+
def run_on_changes(paths)
|
72
|
+
paths = Inspector.clean(paths + @failed_paths)
|
73
|
+
success = Runner.run(paths, options)
|
74
|
+
|
75
|
+
update_failed_paths(success, paths)
|
76
|
+
run_all_after_pass(success)
|
77
|
+
throw :task_has_failed unless success
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
# Adds or removes path to the failed_paths bassed
|
83
|
+
# on the tests result.
|
84
|
+
#
|
85
|
+
# @param [Boolean] tests_passed whether the tests passed or not
|
86
|
+
# @param [Array<String>] paths the tests paths
|
87
|
+
#
|
88
|
+
def update_failed_paths(tests_passed, paths)
|
89
|
+
return unless @options[:keep_failed]
|
90
|
+
|
91
|
+
if tests_passed
|
92
|
+
@failed_paths -= paths
|
93
|
+
else
|
94
|
+
@failed_paths += paths
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# Runs all tests after the failed tests pass.
|
99
|
+
#
|
100
|
+
# @param (see .update_failed_paths)
|
101
|
+
#
|
102
|
+
def run_all_after_pass(tests_passed)
|
103
|
+
return unless @options[:all_after_pass]
|
104
|
+
|
105
|
+
if tests_passed
|
106
|
+
run_all if @previous_failed
|
107
|
+
else
|
108
|
+
@previous_failed = true
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|