hoe 3.26.0 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/History.rdoc +14 -0
- data/Manifest.txt +0 -1
- data/lib/hoe/package.rb +4 -1
- data/lib/hoe/test.rb +2 -128
- data/lib/hoe.rb +2 -5
- data/test/test_hoe.rb +2 -6
- data/test/test_hoe_test.rb +0 -48
- data.tar.gz.sig +0 -0
- metadata +2 -3
- metadata.gz.sig +0 -0
- data/lib/minitest/test_task.rb +0 -314
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2316ca92b08d9ee9dc3e5a4807286e04d2e4f0fc3c9b61c8cc70a2485ae397c
|
4
|
+
data.tar.gz: d63e03cc57d175aef89e24300d9978869920a554201105bcc09c24be5042fe3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08f7ed795e6ce73952b9cb96b95d23a9ae6ceed1d53ed0dc691d3367cd0ad526ba9970ef5d4b8603e813ce5163246711d1da34e97c6a0a742e5a231c7716020b'
|
7
|
+
data.tar.gz: 7ed6679c63d7d20423fadc9dcb3dac777a0aba93cc9ba0a2b64cfc167dfa64c6efb9bcfd28eae5ca82068e2557810e9cb693fb438a257f4939d3c7843d11b05a
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/History.rdoc
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
=== 4.0.1 / 2022-12-17
|
2
|
+
|
3
|
+
* 1 bug fix:
|
4
|
+
|
5
|
+
* Add extra checks to release_sanity to ensure history file is updated before release.
|
6
|
+
|
7
|
+
=== 4.0.0 / 2022-12-16
|
8
|
+
|
9
|
+
* 3 major enhancements:
|
10
|
+
|
11
|
+
* Removed Minitest::TestTask. Shipped with minitest 5.16+ now!
|
12
|
+
* Removed direct support for rspec, test/unit. Still extendable tho.
|
13
|
+
* Removed support for old style readme parsing.
|
14
|
+
|
1
15
|
=== 3.26.0 / 2022-10-20
|
2
16
|
|
3
17
|
* 2 minor enhancements:
|
data/Manifest.txt
CHANGED
data/lib/hoe/package.rb
CHANGED
@@ -72,7 +72,10 @@ module Hoe::Package
|
|
72
72
|
pre = ENV["PRERELEASE"] || ENV["PRE"]
|
73
73
|
v += ".#{pre}" if pre
|
74
74
|
|
75
|
-
|
75
|
+
c = changes[/\d\S+/]
|
76
|
+
|
77
|
+
abort "Versions don't match: %s vs %s" % [v, version] if v != version
|
78
|
+
abort "Versions don't match %s: %s vs %s" % [history_file, v, c] if v != c
|
76
79
|
end
|
77
80
|
end
|
78
81
|
|
data/lib/hoe/test.rb
CHANGED
@@ -10,17 +10,10 @@
|
|
10
10
|
# test_deps:: Show which test files fail when run alone.
|
11
11
|
|
12
12
|
module Hoe::Test
|
13
|
-
def deprecate msg # :nodoc:
|
14
|
-
where = caller_locations[1]
|
15
|
-
|
16
|
-
warn "DEPRECATED: %s from %s" % [msg, where]
|
17
|
-
end
|
18
|
-
|
19
13
|
##
|
20
14
|
# Configuration for the supported test frameworks for test task.
|
21
15
|
|
22
16
|
SUPPORTED_TEST_FRAMEWORKS = {
|
23
|
-
:testunit => "test/unit",
|
24
17
|
:minitest => "minitest/autorun",
|
25
18
|
:none => nil,
|
26
19
|
}
|
@@ -46,16 +39,6 @@ module Hoe::Test
|
|
46
39
|
|
47
40
|
attr_accessor :test_prelude
|
48
41
|
|
49
|
-
##
|
50
|
-
# Optional: RSpec dirs. [default: %w(spec lib)]
|
51
|
-
|
52
|
-
attr_accessor :rspec_dirs
|
53
|
-
|
54
|
-
##
|
55
|
-
# Optional: RSpec options. [default: []]
|
56
|
-
|
57
|
-
attr_accessor :rspec_options
|
58
|
-
|
59
42
|
##
|
60
43
|
# The test task created for this plugin.
|
61
44
|
|
@@ -68,8 +51,7 @@ module Hoe::Test
|
|
68
51
|
self.multiruby_skip ||= []
|
69
52
|
self.testlib ||= :minitest
|
70
53
|
self.test_prelude ||= nil
|
71
|
-
self.
|
72
|
-
self.rspec_options ||= []
|
54
|
+
self.test_task = nil
|
73
55
|
end
|
74
56
|
|
75
57
|
##
|
@@ -83,44 +65,13 @@ module Hoe::Test
|
|
83
65
|
if File.directory? "test" then
|
84
66
|
case testlib
|
85
67
|
when :minitest then
|
86
|
-
require "minitest/test_task" #
|
68
|
+
require "minitest/test_task" # in minitest 5.16+
|
87
69
|
|
88
70
|
test_prelude = self.test_prelude
|
89
71
|
self.test_task = Minitest::TestTask.create :test do |t|
|
90
72
|
t.test_prelude = test_prelude
|
91
73
|
t.libs.prepend Hoe.include_dirs.uniq
|
92
74
|
end
|
93
|
-
when :testunit then
|
94
|
-
desc "Run the test suite. Use FILTER or TESTOPTS to add flags/args."
|
95
|
-
task :test do
|
96
|
-
ruby make_test_cmd
|
97
|
-
end
|
98
|
-
|
99
|
-
desc "Print out the test command. Good for profiling and other tools."
|
100
|
-
task :test_cmd do
|
101
|
-
puts make_test_cmd
|
102
|
-
end
|
103
|
-
|
104
|
-
desc "Show which test files fail when run alone."
|
105
|
-
task :test_deps do
|
106
|
-
tests = Dir[*self.test_globs].uniq
|
107
|
-
|
108
|
-
paths = %w[bin lib test].join(File::PATH_SEPARATOR)
|
109
|
-
null_dev = Hoe::WINDOZE ? "> NUL 2>&1" : "> /dev/null 2>&1"
|
110
|
-
|
111
|
-
tests.each do |test|
|
112
|
-
unless system "ruby -I#{paths} #{test} #{null_dev}" then
|
113
|
-
puts "Dependency Issues: #{test}"
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
if testlib == :minitest then
|
119
|
-
desc "Show bottom 25 tests wrt time."
|
120
|
-
task "test:slow" do
|
121
|
-
sh "rake TESTOPTS=-v | sort -n -k2 -t= | tail -25"
|
122
|
-
end
|
123
|
-
end
|
124
75
|
when :none then
|
125
76
|
# do nothing
|
126
77
|
else
|
@@ -140,16 +91,6 @@ module Hoe::Test
|
|
140
91
|
default_tasks << :test
|
141
92
|
end
|
142
93
|
|
143
|
-
if File.directory? "spec" then
|
144
|
-
found = try_loading_rspec2 || try_loading_rspec1
|
145
|
-
|
146
|
-
if found then
|
147
|
-
default_tasks << :spec
|
148
|
-
else
|
149
|
-
warn "Found spec dir, but couldn't load rspec (1 or 2) task. skipping."
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
94
|
desc "Run the default task(s)."
|
154
95
|
task :default => default_tasks
|
155
96
|
|
@@ -159,71 +100,4 @@ module Hoe::Test
|
|
159
100
|
sh "zentest -I=#{libs} #{spec.files.grep(/^(lib|test)/).join(" ")}"
|
160
101
|
end
|
161
102
|
end
|
162
|
-
|
163
|
-
##
|
164
|
-
# Generate the test command-line.
|
165
|
-
|
166
|
-
def make_test_cmd
|
167
|
-
unless SUPPORTED_TEST_FRAMEWORKS.key?(testlib)
|
168
|
-
raise "unsupported test framework #{testlib}"
|
169
|
-
end
|
170
|
-
|
171
|
-
deprecate "Moving to Minitest::TestTask. Let me know if you use this!"
|
172
|
-
|
173
|
-
framework = SUPPORTED_TEST_FRAMEWORKS[testlib]
|
174
|
-
|
175
|
-
tests = ["rubygems"]
|
176
|
-
tests << framework if framework
|
177
|
-
tests << test_globs.sort.map { |g| Dir.glob(g) }
|
178
|
-
tests.flatten!
|
179
|
-
tests.map! { |f| %(require "#{f}") }
|
180
|
-
|
181
|
-
tests.insert 1, test_prelude if test_prelude
|
182
|
-
|
183
|
-
filter = (ENV["FILTER"] || ENV["TESTOPTS"] || "").dup
|
184
|
-
filter << " -n #{ENV["N"]}" if ENV["N"]
|
185
|
-
filter << " -e #{ENV["X"]}" if ENV["X"]
|
186
|
-
|
187
|
-
"#{Hoe::RUBY_FLAGS} -e '#{tests.join("; ")}' -- #{filter}"
|
188
|
-
end
|
189
|
-
|
190
|
-
##
|
191
|
-
# Attempt to load RSpec 2, returning true if successful
|
192
|
-
|
193
|
-
def try_loading_rspec2
|
194
|
-
deprecate "I want to drop this entirely. Let me know if you use this!"
|
195
|
-
|
196
|
-
require "rspec/core/rake_task"
|
197
|
-
|
198
|
-
desc "Run all specifications"
|
199
|
-
RSpec::Core::RakeTask.new(:spec) do |t|
|
200
|
-
t.rspec_opts = self.rspec_options
|
201
|
-
t.rspec_opts << "-I#{self.rspec_dirs.join(":")}" unless
|
202
|
-
rspec_dirs.empty?
|
203
|
-
end
|
204
|
-
|
205
|
-
true
|
206
|
-
rescue LoadError => err
|
207
|
-
warn "%p while trying to load RSpec 2: %s" % [ err.class, err.message ]
|
208
|
-
false
|
209
|
-
end
|
210
|
-
|
211
|
-
##
|
212
|
-
# Attempt to load RSpec 1, returning true if successful
|
213
|
-
|
214
|
-
def try_loading_rspec1
|
215
|
-
deprecate "I want to drop this entirely. Let me know if you use this!"
|
216
|
-
|
217
|
-
require "spec/rake/spectask"
|
218
|
-
|
219
|
-
desc "Run all specifications"
|
220
|
-
Spec::Rake::SpecTask.new(:spec) do |t|
|
221
|
-
t.libs = self.rspec_dirs
|
222
|
-
t.spec_opts = self.rspec_options
|
223
|
-
end
|
224
|
-
true
|
225
|
-
rescue LoadError => err
|
226
|
-
warn "%p while trying to load RSpec 1: %s" % [ err.class, err.message ]
|
227
|
-
false
|
228
|
-
end
|
229
103
|
end
|
data/lib/hoe.rb
CHANGED
@@ -87,7 +87,7 @@ class Hoe
|
|
87
87
|
include Rake::DSL if defined?(Rake::DSL)
|
88
88
|
|
89
89
|
# duh
|
90
|
-
VERSION = "
|
90
|
+
VERSION = "4.0.1"
|
91
91
|
|
92
92
|
@@plugins = [:clean, :debug, :deps, :flay, :flog, :newb, :package,
|
93
93
|
:publish, :gemcutter, :signing, :test]
|
@@ -726,10 +726,7 @@ class Hoe
|
|
726
726
|
if lines.first =~ /::/ then
|
727
727
|
Hash[lines.map { |line| line.split(/\s*::\s*/) }]
|
728
728
|
else
|
729
|
-
|
730
|
-
warn " Only defining 'home' url."
|
731
|
-
warn " This will be removed on or after 2020-10-28."
|
732
|
-
{ "home" => lines.first }
|
729
|
+
raise "Please switch readme to hash format for urls."
|
733
730
|
end
|
734
731
|
end
|
735
732
|
|
data/test/test_hoe.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
require "minitest/autorun"
|
3
2
|
require "hoe"
|
4
3
|
require "tempfile"
|
@@ -192,11 +191,8 @@ class TestHoe < Minitest::Test
|
|
192
191
|
"* http://docs.seattlerb.org/hoe/Hoe.pdf",
|
193
192
|
"* http://github.com/jbarnette/hoe-plugin-examples"].join "\n"
|
194
193
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
assert_output "", err do
|
199
|
-
assert_equal exp, hoe.parse_urls(ary)
|
194
|
+
assert_raises RuntimeError do
|
195
|
+
hoe.parse_urls ary
|
200
196
|
end
|
201
197
|
end
|
202
198
|
|
data/test/test_hoe_test.rb
CHANGED
@@ -19,14 +19,6 @@ class TestHoeTest < Minitest::Test
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
def assert_deprecated
|
23
|
-
err_re = /DEPRECATED:/
|
24
|
-
|
25
|
-
assert_output "", err_re do
|
26
|
-
yield
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
22
|
path = %w[lib bin test .].join File::PATH_SEPARATOR
|
31
23
|
mt_path = %w[lib test .].join File::PATH_SEPARATOR
|
32
24
|
|
@@ -38,26 +30,6 @@ class TestHoeTest < Minitest::Test
|
|
38
30
|
-e '%srequire "test/test_hoe_test.rb"'
|
39
31
|
--].join(" ") + " "
|
40
32
|
|
41
|
-
def test_make_test_cmd_defaults_to_minitest
|
42
|
-
skip "Using TESTOPTS... skipping" if ENV["TESTOPTS"]
|
43
|
-
|
44
|
-
# default
|
45
|
-
assert_deprecated do
|
46
|
-
autorun = %(require "minitest/autorun"; )
|
47
|
-
assert_equal EXPECTED % autorun, @tester.make_test_cmd
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_make_test_cmd_for_testunit
|
52
|
-
skip "Using TESTOPTS... skipping" if ENV["TESTOPTS"]
|
53
|
-
|
54
|
-
assert_deprecated do
|
55
|
-
@tester.testlib = :testunit
|
56
|
-
testunit = %(require "test/unit"; )
|
57
|
-
assert_equal EXPECTED % testunit, @tester.make_test_cmd
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
33
|
def test_make_test_cmd_for_minitest
|
62
34
|
skip "Using TESTOPTS... skipping" if ENV["TESTOPTS"]
|
63
35
|
|
@@ -85,24 +57,4 @@ class TestHoeTest < Minitest::Test
|
|
85
57
|
|
86
58
|
assert_equal MT_EXPECTED % [prelude, framework].join("; "), @tester.make_test_cmd
|
87
59
|
end
|
88
|
-
|
89
|
-
def test_make_test_cmd_for_no_framework
|
90
|
-
skip "Using TESTOPTS... skipping" if ENV["TESTOPTS"]
|
91
|
-
|
92
|
-
assert_deprecated do
|
93
|
-
@tester.testlib = :none
|
94
|
-
assert_equal EXPECTED % "", @tester.make_test_cmd
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def test_make_test_cmd_for_faketestlib
|
99
|
-
skip "Using TESTOPTS... skipping" if ENV["TESTOPTS"]
|
100
|
-
|
101
|
-
@tester.testlib = :faketestlib
|
102
|
-
e = assert_raises(RuntimeError) do
|
103
|
-
@tester.make_test_cmd
|
104
|
-
end
|
105
|
-
|
106
|
-
assert_equal "unsupported test framework faketestlib", e.to_s
|
107
|
-
end
|
108
60
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hoe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
@@ -29,7 +29,7 @@ cert_chain:
|
|
29
29
|
JFmxn4h9YO/pVdB962BdBNNDia0kgIjI3ENnkLq0dKpYU3+F3KhEuTksLO0L6X/V
|
30
30
|
YsuyUzsMz6GQA4khyaMgKNSD
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date: 2022-
|
32
|
+
date: 2022-12-17 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: rake
|
@@ -132,7 +132,6 @@ files:
|
|
132
132
|
- lib/hoe/rdoc.rb
|
133
133
|
- lib/hoe/signing.rb
|
134
134
|
- lib/hoe/test.rb
|
135
|
-
- lib/minitest/test_task.rb
|
136
135
|
- template/.autotest.erb
|
137
136
|
- template/History.txt.erb
|
138
137
|
- template/Manifest.txt.erb
|
metadata.gz.sig
CHANGED
Binary file
|
data/lib/minitest/test_task.rb
DELETED
@@ -1,314 +0,0 @@
|
|
1
|
-
require "shellwords"
|
2
|
-
require "rbconfig"
|
3
|
-
require "rake/tasklib"
|
4
|
-
|
5
|
-
warn <<~EOM
|
6
|
-
minitest/test_task.rb is now packaged with minitest. If you see
|
7
|
-
this, you are getting it from hoe instead. If you're NOT able to
|
8
|
-
upgrade minitest to pick this up, please drop an issue on
|
9
|
-
seattlerb/hoe and let me know.
|
10
|
-
|
11
|
-
Required from #{caller[2]}
|
12
|
-
EOM
|
13
|
-
|
14
|
-
module Minitest # :nodoc:
|
15
|
-
|
16
|
-
##
|
17
|
-
# Minitest::TestTask is a rake helper that generates several rake
|
18
|
-
# tasks under the main test task's name-space.
|
19
|
-
#
|
20
|
-
# task <name> :: the main test task
|
21
|
-
# task <name>:cmd :: prints the command to use
|
22
|
-
# task <name>:deps :: runs each test file by itself to find dependency errors
|
23
|
-
# task <name>:slow :: runs the tests and reports the slowest 25 tests.
|
24
|
-
#
|
25
|
-
# Examples:
|
26
|
-
#
|
27
|
-
# Minitest::TestTask.create
|
28
|
-
#
|
29
|
-
# The most basic and default setup.
|
30
|
-
#
|
31
|
-
# Minitest::TestTask.create :my_tests
|
32
|
-
#
|
33
|
-
# The most basic/default setup, but with a custom name
|
34
|
-
#
|
35
|
-
# Minitest::TestTask.create :unit do |t|
|
36
|
-
# t.test_globs = ["test/unit/**/*_test.rb"]
|
37
|
-
# t.warning = false
|
38
|
-
# end
|
39
|
-
#
|
40
|
-
# Customize the name and only run unit tests.
|
41
|
-
|
42
|
-
class TestTask < Rake::TaskLib
|
43
|
-
WINDOWS = RbConfig::CONFIG["host_os"] =~ /mswin|mingw/ # :nodoc:
|
44
|
-
|
45
|
-
##
|
46
|
-
# Create several test-oriented tasks under +name+. Takes an
|
47
|
-
# optional block to customize variables.
|
48
|
-
|
49
|
-
def self.create name = :test, &block
|
50
|
-
task = new name
|
51
|
-
task.instance_eval(&block) if block
|
52
|
-
task.process_env
|
53
|
-
task.define
|
54
|
-
task
|
55
|
-
end
|
56
|
-
|
57
|
-
##
|
58
|
-
# Extra arguments to pass to the tests. Defaults empty but gets
|
59
|
-
# populated by a number of enviroment variables:
|
60
|
-
#
|
61
|
-
# N (-n flag) :: a string or regexp of tests to run.
|
62
|
-
# X (-e flag) :: a string or regexp of tests to exclude.
|
63
|
-
# A (arg) :: quick way to inject an arbitrary argument (eg A=--help).
|
64
|
-
#
|
65
|
-
# See #process_env
|
66
|
-
|
67
|
-
attr_accessor :extra_args
|
68
|
-
|
69
|
-
##
|
70
|
-
# The code to load the framework. Defaults to requiring
|
71
|
-
# minitest/autorun...
|
72
|
-
#
|
73
|
-
# Why do I have this as an option?
|
74
|
-
|
75
|
-
attr_accessor :framework
|
76
|
-
|
77
|
-
##
|
78
|
-
# Extra library directories to include. Defaults to %w[lib test
|
79
|
-
# .]. Also uses $MT_LIB_EXTRAS allowing you to dynamically
|
80
|
-
# override/inject directories for custom runs.
|
81
|
-
|
82
|
-
attr_accessor :libs
|
83
|
-
|
84
|
-
##
|
85
|
-
# The name of the task and base name for the other tasks generated.
|
86
|
-
|
87
|
-
attr_accessor :name
|
88
|
-
|
89
|
-
##
|
90
|
-
# File globs to find test files. Defaults to something sensible to
|
91
|
-
# find test files under the test directory.
|
92
|
-
|
93
|
-
attr_accessor :test_globs
|
94
|
-
|
95
|
-
##
|
96
|
-
# Turn on ruby warnings (-w flag). Defaults to true.
|
97
|
-
|
98
|
-
attr_accessor :warning
|
99
|
-
|
100
|
-
##
|
101
|
-
# Optional: Additional ruby to run before the test framework is loaded.
|
102
|
-
|
103
|
-
attr_accessor :test_prelude
|
104
|
-
|
105
|
-
##
|
106
|
-
# Print out commands as they run. Defaults to Rake's +trace+ (-t
|
107
|
-
# flag) option.
|
108
|
-
|
109
|
-
attr_accessor :verbose
|
110
|
-
|
111
|
-
##
|
112
|
-
# Use TestTask.create instead.
|
113
|
-
|
114
|
-
def initialize name = :test # :nodoc:
|
115
|
-
self.extra_args = []
|
116
|
-
self.framework = %(require "minitest/autorun")
|
117
|
-
self.libs = %w[lib test .]
|
118
|
-
self.name = name
|
119
|
-
self.test_globs = ["test/**/{test,spec}_*.rb",
|
120
|
-
"test/**/*_{test,spec}.rb"]
|
121
|
-
self.test_prelude = nil
|
122
|
-
self.verbose = Rake.application.options.trace
|
123
|
-
self.warning = true
|
124
|
-
end
|
125
|
-
|
126
|
-
##
|
127
|
-
# Extract variables from the environment and convert them to
|
128
|
-
# command line arguments. See #extra_args.
|
129
|
-
#
|
130
|
-
# Environment Variables:
|
131
|
-
#
|
132
|
-
# MT_LIB_EXTRAS :: Extra libs to dynamically override/inject for custom runs.
|
133
|
-
# N :: Tests to run (string or /regexp/).
|
134
|
-
# X :: Tests to exclude (string or /regexp/).
|
135
|
-
# A :: Any extra arguments. Honors shell quoting.
|
136
|
-
#
|
137
|
-
# Deprecated:
|
138
|
-
#
|
139
|
-
# TESTOPTS :: For argument passing, use +A+.
|
140
|
-
# N :: For parallel testing, use +MT_CPU+.
|
141
|
-
# FILTER :: Same as +TESTOPTS+.
|
142
|
-
|
143
|
-
def process_env
|
144
|
-
warn "TESTOPTS is deprecated in Minitest::TestTask. Use A instead" if
|
145
|
-
ENV["TESTOPTS"]
|
146
|
-
warn "FILTER is deprecated in Minitest::TestTask. Use A instead" if
|
147
|
-
ENV["FILTER"]
|
148
|
-
warn "N is deprecated in Minitest::TestTask. Use MT_CPU instead" if
|
149
|
-
ENV["N"] && ENV["N"].to_i > 0
|
150
|
-
|
151
|
-
lib_extras = (ENV["MT_LIB_EXTRAS"] || "").split File::PATH_SEPARATOR
|
152
|
-
self.libs[0,0] = lib_extras
|
153
|
-
|
154
|
-
extra_args << "-n" << ENV["N"] if ENV["N"]
|
155
|
-
extra_args << "-e" << ENV["X"] if ENV["X"]
|
156
|
-
extra_args.concat Shellwords.split(ENV["TESTOPTS"]) if ENV["TESTOPTS"]
|
157
|
-
extra_args.concat Shellwords.split(ENV["FILTER"]) if ENV["FILTER"]
|
158
|
-
extra_args.concat Shellwords.split(ENV["A"]) if ENV["A"]
|
159
|
-
|
160
|
-
ENV.delete "N" if ENV["N"]
|
161
|
-
|
162
|
-
# TODO? RUBY_DEBUG = ENV["RUBY_DEBUG"]
|
163
|
-
# TODO? ENV["RUBY_FLAGS"]
|
164
|
-
|
165
|
-
extra_args.compact!
|
166
|
-
end
|
167
|
-
|
168
|
-
def define # :nodoc:
|
169
|
-
default_tasks = []
|
170
|
-
|
171
|
-
desc "Run the test suite. Use N, X, A, and TESTOPTS to add flags/args."
|
172
|
-
task name do
|
173
|
-
ruby make_test_cmd, verbose:verbose
|
174
|
-
end
|
175
|
-
|
176
|
-
desc "Print out the test command. Good for profiling and other tools."
|
177
|
-
task "#{name}:cmd" do
|
178
|
-
puts "ruby #{make_test_cmd}"
|
179
|
-
end
|
180
|
-
|
181
|
-
desc "Show which test files fail when run in isolation."
|
182
|
-
task "#{name}:isolated" do
|
183
|
-
tests = Dir[*self.test_globs].uniq
|
184
|
-
|
185
|
-
# 3 seems to be the magic number... (tho not by that much)
|
186
|
-
bad, good, n = {}, [], (ENV.delete("K") || 3).to_i
|
187
|
-
file = ENV.delete("F")
|
188
|
-
times = {}
|
189
|
-
|
190
|
-
tt0 = Time.now
|
191
|
-
|
192
|
-
n.threads_do tests.sort do |path|
|
193
|
-
t0 = Time.now
|
194
|
-
output = `#{Gem.ruby} #{make_test_cmd path} 2>&1`
|
195
|
-
t1 = Time.now - t0
|
196
|
-
|
197
|
-
times[path] = t1
|
198
|
-
|
199
|
-
if $?.success?
|
200
|
-
$stderr.print "."
|
201
|
-
good << path
|
202
|
-
else
|
203
|
-
$stderr.print "x"
|
204
|
-
bad[path] = output
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
puts "done"
|
209
|
-
puts "Ran in %.2f seconds" % [ Time.now - tt0 ]
|
210
|
-
|
211
|
-
if file then
|
212
|
-
require "json"
|
213
|
-
File.open file, "w" do |io|
|
214
|
-
io.puts JSON.pretty_generate times
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
unless good.empty?
|
219
|
-
puts
|
220
|
-
puts "# Good tests:"
|
221
|
-
puts
|
222
|
-
good.sort.each do |path|
|
223
|
-
puts "%.2fs: %s" % [times[path], path]
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
|
-
unless bad.empty?
|
228
|
-
puts
|
229
|
-
puts "# Bad tests:"
|
230
|
-
puts
|
231
|
-
bad.keys.sort.each do |path|
|
232
|
-
puts "%.2fs: %s" % [times[path], path]
|
233
|
-
end
|
234
|
-
puts
|
235
|
-
puts "# Bad Test Output:"
|
236
|
-
puts
|
237
|
-
bad.sort.each do |path, output|
|
238
|
-
puts
|
239
|
-
puts "# #{path}:"
|
240
|
-
puts output
|
241
|
-
end
|
242
|
-
exit 1
|
243
|
-
end
|
244
|
-
end
|
245
|
-
|
246
|
-
task "#{name}:deps" => "#{name}:isolated" # now just an alias
|
247
|
-
|
248
|
-
desc "Show bottom 25 tests wrt time."
|
249
|
-
task "#{name}:slow" do
|
250
|
-
sh ["rake #{name} TESTOPTS=-v",
|
251
|
-
"egrep '#test_.* s = .'",
|
252
|
-
"sort -n -k2 -t=",
|
253
|
-
"tail -25"].join " | "
|
254
|
-
end
|
255
|
-
|
256
|
-
default_tasks << name
|
257
|
-
|
258
|
-
desc "Run the default task(s)."
|
259
|
-
task :default => default_tasks
|
260
|
-
end
|
261
|
-
|
262
|
-
##
|
263
|
-
# Generate the test command-line.
|
264
|
-
|
265
|
-
def make_test_cmd globs = test_globs
|
266
|
-
tests = []
|
267
|
-
tests.concat Dir[*globs].sort.shuffle # TODO: SEED -> srand first?
|
268
|
-
tests.map! { |f| %(require "#{f}") }
|
269
|
-
|
270
|
-
runner = []
|
271
|
-
runner << test_prelude if test_prelude
|
272
|
-
runner << framework
|
273
|
-
runner.concat tests
|
274
|
-
runner = runner.join "; "
|
275
|
-
|
276
|
-
args = []
|
277
|
-
args << "-I#{libs.join(File::PATH_SEPARATOR)}" unless libs.empty?
|
278
|
-
args << "-w" if warning
|
279
|
-
args << '-e'
|
280
|
-
args << "'#{runner}'"
|
281
|
-
args << '--'
|
282
|
-
args << extra_args.map(&:shellescape)
|
283
|
-
|
284
|
-
args.join " "
|
285
|
-
end
|
286
|
-
end
|
287
|
-
end
|
288
|
-
|
289
|
-
class Work < Queue
|
290
|
-
def initialize jobs = []
|
291
|
-
super()
|
292
|
-
|
293
|
-
jobs.each do |job|
|
294
|
-
self << job
|
295
|
-
end
|
296
|
-
|
297
|
-
close
|
298
|
-
end
|
299
|
-
end
|
300
|
-
|
301
|
-
class Integer
|
302
|
-
def threads_do(jobs) # :nodoc:
|
303
|
-
require "thread"
|
304
|
-
q = Work.new jobs
|
305
|
-
|
306
|
-
self.times.map {
|
307
|
-
Thread.new do
|
308
|
-
while job = q.pop # go until quit value
|
309
|
-
yield job
|
310
|
-
end
|
311
|
-
end
|
312
|
-
}.each(&:join)
|
313
|
-
end
|
314
|
-
end
|