minitest-profile 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MmIxMDEzODg1OTI0Y2I3N2MzMjFkZGVlYTU0ZTZjMzRmNWY3MGFhZQ==
5
+ data.tar.gz: !binary |-
6
+ YzUwNzNlMWVjNzBlNzY0MzdiYmViZTEyZGVjZGNiZTI1YmM3Yjc0Ng==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MjcxMzhmMGVkZjE2ZmM0MzE4NzExZGJkYzM0NDQ0MGU1YTg4ODZiNzdmYjNl
10
+ Njk4ODU3MWI2MTAxNzRiMGE4NDcwZGEwMDZkNDIyNmFkNmQ5ZTg1OTMxYzQ3
11
+ NzI3MDQ0NmZjZDA5OWMyMDIxODYxNTczNWRjMzMxOTcwMzVjOTA=
12
+ data.tar.gz: !binary |-
13
+ ZDg1ZWM4NjQ2MDI2ZTY3ODEyZWExOWJjOGY1NTlkMDJjZDk4NmY5NDhjN2E1
14
+ YjAyNGFhNDU4MTc5MTBhOGEzOTZiMWJhMGM5ZGQ3ZWE2MzhlYjNkZWFlNDZl
15
+ OTAzMTAzNWU2YmZjN2U4Mjk5NmEzN2RmNWQwYjVmNWI4YjgwNTE=
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in minitest-profile.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Nickolas Means
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,71 @@
1
+ # Minitest::Profile
2
+
3
+ Outputs a list of your 10 slowest tests at the end of a test run:
4
+
5
+ ```
6
+ % ruby test/test_minitest_profile.rb --profile
7
+ run options: --profile --seed 4106
8
+
9
+ # Running:
10
+
11
+ ..................................................
12
+
13
+ Finished in 1.352722s, 36.9625 runs/s, 36.9625 assertions/s.
14
+
15
+ 50 runs, 50 assertions, 0 failures, 0 errors, 0 skips
16
+
17
+ ================================================================================
18
+ Your 10 Slowest Tests
19
+ ================================================================================
20
+
21
+ 0.0525ms - a random smattering of tests#test_0050_will take 0.049ms
22
+ 0.0507ms - a random smattering of tests#test_0047_will take 0.046ms
23
+ 0.0503ms - a random smattering of tests#test_0049_will take 0.048ms
24
+ 0.0489ms - a random smattering of tests#test_0048_will take 0.047ms
25
+ 0.0486ms - a random smattering of tests#test_0046_will take 0.045ms
26
+ 0.0480ms - a random smattering of tests#test_0045_will take 0.044ms
27
+ 0.0474ms - a random smattering of tests#test_0044_will take 0.043ms
28
+ 0.0464ms - a random smattering of tests#test_0043_will take 0.042ms
29
+ 0.0430ms - a random smattering of tests#test_0042_will take 0.041ms
30
+ 0.0425ms - a random smattering of tests#test_0041_will take 0.04ms
31
+
32
+ ```
33
+
34
+ ## Installation
35
+
36
+ Add this line to your application's Gemfile:
37
+
38
+ gem 'minitest-profile'
39
+
40
+ And then execute:
41
+
42
+ $ bundle
43
+
44
+ Or install it yourself as:
45
+
46
+ $ gem install minitest-profile
47
+
48
+ Then add this line to your application's test_helper/spec_helper:
49
+
50
+ require 'minitest/profile'
51
+
52
+ ## Usage
53
+
54
+ Use the `--profile` flag to invoke the plugin.
55
+
56
+ Direct invocation:
57
+
58
+ `ruby test_thing.rb --profile`
59
+
60
+ Via rake test runner:
61
+
62
+ `TESTOPTS='--profile' rake test`
63
+
64
+ ## Contributing
65
+
66
+ 1. Fork it
67
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
68
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
69
+ 4. Push to the branch (`git push origin my-new-feature`)
70
+ 5. Create new Pull Request
71
+
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ end
7
+
8
+ task :default => :test
@@ -0,0 +1 @@
1
+ require_relative './profile_plugin'
@@ -0,0 +1,47 @@
1
+ require 'minitest'
2
+
3
+ module Minitest
4
+
5
+ def self.plugin_profile_options(opts, options)
6
+ opts.on("--profile", "Display list of slowest tests") do |p|
7
+ options[:profile] = true
8
+ end
9
+ end
10
+
11
+ def self.plugin_profile_init(options)
12
+ self.reporter << ProfileReporter.new(options) if options[:profile]
13
+ end
14
+
15
+ class ProfileReporter < AbstractReporter
16
+ VERSION = "0.0.1"
17
+
18
+ attr_accessor :io, :results
19
+
20
+ def initialize(options)
21
+ self.io = options[:io]
22
+ self.results = []
23
+ end
24
+
25
+ def record(result)
26
+ results << [result.time, result.location]
27
+ end
28
+
29
+ def report
30
+ return unless passed?
31
+ puts
32
+ puts "=" * 80
33
+ puts "Your 10 Slowest Tests"
34
+ puts "=" * 80
35
+ puts
36
+ sorted_results[0,10].each do |time, test_name|
37
+ puts "#{sprintf("%7.4f",time)}ms - #{test_name}"
38
+ end
39
+
40
+ puts
41
+ end
42
+
43
+ def sorted_results
44
+ results.sort { |a, b| b[0] <=> a[0] }
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'minitest/profile_plugin'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "minitest-profile"
8
+ spec.version = Minitest::ProfileReporter::VERSION
9
+ spec.authors = ["Nickolas Means"]
10
+ spec.email = ["nick@heliumsyndicate.com"]
11
+ spec.description = %q{Outputter to display the slowest tests in a minitest suite}
12
+ spec.summary = %q{Outputter to display the slowest tests in a minitest suite}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "minitest", "~> 5.0"
24
+ end
@@ -0,0 +1,13 @@
1
+ require 'minitest'
2
+ require 'minitest/autorun'
3
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
4
+ require 'minitest/profile'
5
+
6
+ describe 'a random smattering of tests' do
7
+ 50.times do |i|
8
+ it "will take #{i/1000.0}ms" do
9
+ sleep(i/1000.0)
10
+ assert true
11
+ end
12
+ end
13
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: minitest-profile
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nickolas Means
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ description: Outputter to display the slowest tests in a minitest suite
56
+ email:
57
+ - nick@heliumsyndicate.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - .travis.yml
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - lib/minitest/profile.rb
69
+ - lib/minitest/profile_plugin.rb
70
+ - minitest-profile.gemspec
71
+ - test/test_minitest_profile.rb
72
+ homepage: ''
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.0.3
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Outputter to display the slowest tests in a minitest suite
96
+ test_files:
97
+ - test/test_minitest_profile.rb