minitest-flyordie 0.0.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 +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +45 -0
- data/Rakefile +2 -0
- data/lib/minitest/flyordie.rb +48 -0
- data/lib/minitest/flyordie/version.rb +5 -0
- data/lib/minitest/flyordie_plugin.rb +3 -0
- data/minitest-flyordie.gemspec +22 -0
- data/test/_flyordie_reporter_test.rb +13 -0
- data/test/flyordie_reporter_test.rb +19 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 28addd70acbe2d5ac79b1edc5f7731b31ee335b2
|
4
|
+
data.tar.gz: af9671b96c82c93ab4bcd782648222d8b7da9516
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 65b647cc5a187468bcb4430c7de3854d49d8c723d34a521f2e02228c487564bfdaff7a02e294c0fe33051f130a6327238fde8136ef4d2aa8199c15f51fb47102
|
7
|
+
data.tar.gz: 2701fdf468f4406f1baa433e16e2a9ce993f7dab0b0822ce5250d0e9c8c9e2be61cbea0aeea672161effa943c6a9b48f7a513f0fa6c7575a43f27e31072fe5c1
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 John Stewart
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# Minitest::Flyordie
|
2
|
+
|
3
|
+
FlyOrDie is a simple plugin for Minitest that allows you to specify via command-line options a maximum duration for a test to be marked as "slow", and a maximum number of allowable slow tests.
|
4
|
+
If the thresholds are exceeded, the test run will be marked as failed and the list of slow tests will be output.
|
5
|
+
FlyOrDie is primarily meant to be used as part of a Continuous Integration (CI) process to ensure test quality, sometimes referred to as a 'test ratchet'.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem "minitest-flyordie"
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'minitest-flyordie'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
Use the `--maxslow COUNT` flag to set the maximum allowed number of slow tests
|
25
|
+
Use the `--slowtime DURATION` flag to specify the duration for a tests to be slow, in milliseconds
|
26
|
+
|
27
|
+
Direct invocation:
|
28
|
+
|
29
|
+
`ruby test_thing.rb --maxslow 3 --slowtime 30`
|
30
|
+
|
31
|
+
Via rake test runner:
|
32
|
+
|
33
|
+
`TESTOPTS='--maxslow 4 --slowtime 42' rake test`
|
34
|
+
|
35
|
+
## Credits
|
36
|
+
|
37
|
+
Based on ideas from [Step](https://github.com/stephenaument) and [Nick](https://github.com/nmeans). And code liberally copied from Nick's [minitest-profile](https://github.com/nmeans/minitest-profile) gem.
|
38
|
+
|
39
|
+
## Contributing
|
40
|
+
|
41
|
+
1. Fork it ( https://github.com/[my-github-username]/minitest-flyordie/fork )
|
42
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
43
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
44
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
45
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'minitest'
|
2
|
+
|
3
|
+
module Minitest
|
4
|
+
|
5
|
+
def self.plugin_flyordie_options(opts, options)
|
6
|
+
opts.on "--maxslow COUNT", Integer, "Maximum number of allowable slow tests before build failed." do |c|
|
7
|
+
options[:maxslow] = c
|
8
|
+
end
|
9
|
+
opts.on "--slowtime DURATION", Integer, "Duration of time before a tests is considered slow, in milliseconds" do |c|
|
10
|
+
options[:slowtime] = c
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.plugin_flyordie_init(options)
|
15
|
+
self.reporter << FlyOrDieReporter.new(options) if options[:maxslow]
|
16
|
+
end
|
17
|
+
|
18
|
+
class FlyOrDieReporter < AbstractReporter
|
19
|
+
attr_accessor :slowtests, :maxslow, :slowtime
|
20
|
+
|
21
|
+
def initialize(options)
|
22
|
+
self.maxslow = options[:maxslow] || 5
|
23
|
+
self.slowtime = options[:slowtime] || 50
|
24
|
+
self.slowtests = []
|
25
|
+
end
|
26
|
+
|
27
|
+
def record(result)
|
28
|
+
slowtests << result if (result.time * 1000) > slowtime
|
29
|
+
end
|
30
|
+
|
31
|
+
def passed?
|
32
|
+
slowtests.length < maxslow
|
33
|
+
end
|
34
|
+
|
35
|
+
def report
|
36
|
+
return if passed?
|
37
|
+
puts
|
38
|
+
puts "#{slowtests.count} tests exceeded the maximum duration of #{slowtime} msec"
|
39
|
+
puts
|
40
|
+
self.slowtests.each do |st|
|
41
|
+
puts "#{sprintf("%5.2f", st.time*1000)} msec ----- #{st.name}"
|
42
|
+
end
|
43
|
+
puts
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'minitest/flyordie/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "minitest-flyordie"
|
8
|
+
spec.version = Minitest::Flyordie::VERSION
|
9
|
+
spec.authors = ["John Stewart"]
|
10
|
+
spec.email = ["johns@wellmatchhealth.com"]
|
11
|
+
spec.summary = %q{Simple Minitest extension to fail test runs on slow tests}
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.files = `git ls-files -z`.split("\x0")
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'minitest'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
4
|
+
require 'minitest/flyordie'
|
5
|
+
|
6
|
+
describe Minitest::FlyOrDieReporter do
|
7
|
+
it "fails if more than the default are slow" do
|
8
|
+
output = `ruby -Ilib:test test/_flyordie_reporter_test.rb --maxslow 2 2>&1`
|
9
|
+
output.must_match 'test_0001_is slow'
|
10
|
+
end
|
11
|
+
it "succeeds if no tests are slow" do
|
12
|
+
output = `ruby -Ilib:test test/_flyordie_reporter_test.rb --maxslow 2 --slowtime 100 2>&1`
|
13
|
+
output.wont_match 'test_0001_is slow'
|
14
|
+
end
|
15
|
+
it "succeeds if less than the max are slow" do
|
16
|
+
output = `ruby -Ilib:test test/_flyordie_reporter_test.rb --maxslow 6 2>&1`
|
17
|
+
output.wont_match 'test_0001_is slow'
|
18
|
+
end
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: minitest-flyordie
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John Stewart
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: minitest
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- johns@wellmatchhealth.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- lib/minitest/flyordie.rb
|
68
|
+
- lib/minitest/flyordie/version.rb
|
69
|
+
- lib/minitest/flyordie_plugin.rb
|
70
|
+
- minitest-flyordie.gemspec
|
71
|
+
- test/_flyordie_reporter_test.rb
|
72
|
+
- test/flyordie_reporter_test.rb
|
73
|
+
homepage:
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.4.3
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: Simple Minitest extension to fail test runs on slow tests
|
97
|
+
test_files:
|
98
|
+
- test/_flyordie_reporter_test.rb
|
99
|
+
- test/flyordie_reporter_test.rb
|
100
|
+
has_rdoc:
|