rake 0.9.2 → 13.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CONTRIBUTING.rdoc +43 -0
- data/Gemfile +10 -0
- data/History.rdoc +2386 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +64 -109
- data/Rakefile +22 -386
- data/bin/bundle +105 -0
- data/bin/console +7 -0
- data/bin/rake +20 -23
- data/bin/rdoc +29 -0
- data/bin/rubocop +29 -0
- data/bin/setup +6 -0
- data/doc/command_line_usage.rdoc +65 -21
- data/doc/glossary.rdoc +40 -49
- data/doc/jamis.rb +1 -0
- data/doc/rake.1 +156 -0
- data/doc/rakefile.rdoc +127 -62
- data/exe/rake +27 -0
- data/lib/rake.rb +37 -31
- data/lib/rake/application.rb +507 -272
- data/lib/rake/backtrace.rb +24 -0
- data/lib/rake/clean.rb +55 -8
- data/lib/rake/cloneable.rb +11 -19
- data/lib/rake/cpu_counter.rb +107 -0
- data/lib/rake/default_loader.rb +5 -0
- data/lib/rake/dsl_definition.rb +74 -46
- data/lib/rake/early_time.rb +5 -1
- data/lib/rake/ext/core.rb +5 -6
- data/lib/rake/ext/string.rb +61 -52
- data/lib/rake/file_creation_task.rb +4 -3
- data/lib/rake/file_list.rb +81 -49
- data/lib/rake/file_task.rb +15 -8
- data/lib/rake/file_utils.rb +69 -47
- data/lib/rake/file_utils_ext.rb +18 -26
- data/lib/rake/invocation_chain.rb +25 -19
- data/lib/rake/invocation_exception_mixin.rb +1 -0
- data/lib/rake/late_time.rb +18 -0
- data/lib/rake/linked_list.rb +112 -0
- data/lib/rake/loaders/makefile.rb +23 -9
- data/lib/rake/multi_task.rb +4 -6
- data/lib/rake/name_space.rb +36 -23
- data/lib/rake/packagetask.rb +71 -34
- data/lib/rake/phony.rb +16 -0
- data/lib/rake/private_reader.rb +21 -0
- data/lib/rake/promise.rb +100 -0
- data/lib/rake/pseudo_status.rb +8 -2
- data/lib/rake/rake_module.rb +41 -3
- data/lib/rake/rake_test_loader.rb +21 -7
- data/lib/rake/rule_recursion_overflow_error.rb +2 -2
- data/lib/rake/scope.rb +43 -0
- data/lib/rake/task.rb +186 -79
- data/lib/rake/task_argument_error.rb +1 -0
- data/lib/rake/task_arguments.rb +50 -15
- data/lib/rake/task_manager.rb +89 -65
- data/lib/rake/tasklib.rb +2 -12
- data/lib/rake/testtask.rb +61 -63
- data/lib/rake/thread_history_display.rb +49 -0
- data/lib/rake/thread_pool.rb +163 -0
- data/lib/rake/trace_output.rb +23 -0
- data/lib/rake/version.rb +7 -7
- data/lib/rake/win32.rb +14 -18
- data/rake.gemspec +43 -0
- metadata +82 -221
- data/.gemtest +0 -0
- data/CHANGES +0 -509
- data/RRR +0 -9
- data/TODO +0 -20
- data/doc/rake.1.gz +0 -0
- data/doc/release_notes/rake-0.4.14.rdoc +0 -23
- data/doc/release_notes/rake-0.4.15.rdoc +0 -35
- data/doc/release_notes/rake-0.5.0.rdoc +0 -53
- data/doc/release_notes/rake-0.5.3.rdoc +0 -78
- data/doc/release_notes/rake-0.5.4.rdoc +0 -46
- data/doc/release_notes/rake-0.6.0.rdoc +0 -141
- data/doc/release_notes/rake-0.7.0.rdoc +0 -119
- data/doc/release_notes/rake-0.7.1.rdoc +0 -59
- data/doc/release_notes/rake-0.7.2.rdoc +0 -121
- data/doc/release_notes/rake-0.7.3.rdoc +0 -47
- data/doc/release_notes/rake-0.8.0.rdoc +0 -114
- data/doc/release_notes/rake-0.8.2.rdoc +0 -165
- data/doc/release_notes/rake-0.8.3.rdoc +0 -112
- data/doc/release_notes/rake-0.8.4.rdoc +0 -147
- data/doc/release_notes/rake-0.8.5.rdoc +0 -53
- data/doc/release_notes/rake-0.8.6.rdoc +0 -55
- data/doc/release_notes/rake-0.8.7.rdoc +0 -55
- data/doc/release_notes/rake-0.9.0.rdoc +0 -112
- data/doc/release_notes/rake-0.9.1.rdoc +0 -52
- data/doc/release_notes/rake-0.9.2.rdoc +0 -49
- data/install.rb +0 -90
- data/lib/rake/alt_system.rb +0 -109
- data/lib/rake/classic_namespace.rb +0 -9
- data/lib/rake/contrib/compositepublisher.rb +0 -21
- data/lib/rake/contrib/ftptools.rb +0 -150
- data/lib/rake/contrib/publisher.rb +0 -69
- data/lib/rake/contrib/rubyforgepublisher.rb +0 -16
- data/lib/rake/contrib/sshpublisher.rb +0 -45
- data/lib/rake/contrib/sys.rb +0 -191
- data/lib/rake/ext/module.rb +0 -39
- data/lib/rake/ext/time.rb +0 -14
- data/lib/rake/gempackagetask.rb +0 -13
- data/lib/rake/pathmap.rb +0 -1
- data/lib/rake/rdoctask.rb +0 -230
- data/lib/rake/ruby182_test_unit_fix.rb +0 -25
- data/lib/rake/runtest.rb +0 -21
- data/test/check_expansion.rb +0 -5
- data/test/check_no_expansion.rb +0 -5
- data/test/data/access/Rakefile +0 -35
- data/test/data/chains/Rakefile +0 -15
- data/test/data/comments/Rakefile +0 -18
- data/test/data/default/Rakefile +0 -17
- data/test/data/deprecated_import/Rakefile +0 -1
- data/test/data/dryrun/Rakefile +0 -22
- data/test/data/extra/Rakefile +0 -1
- data/test/data/file_creation_task/Rakefile +0 -31
- data/test/data/imports/Rakefile +0 -19
- data/test/data/imports/deps.mf +0 -1
- data/test/data/multidesc/Rakefile +0 -15
- data/test/data/namespace/Rakefile +0 -64
- data/test/data/rakelib/test1.rb +0 -4
- data/test/data/rbext/rakefile.rb +0 -3
- data/test/data/sample.mf +0 -14
- data/test/data/statusreturn/Rakefile +0 -6
- data/test/data/unittest/Rakefile +0 -1
- data/test/data/verbose/Rakefile +0 -34
- data/test/file_creation.rb +0 -34
- data/test/helper.rb +0 -44
- data/test/in_environment.rb +0 -35
- data/test/reqfile.rb +0 -3
- data/test/reqfile2.rb +0 -3
- data/test/shellcommand.rb +0 -3
- data/test/test_rake.rb +0 -38
- data/test/test_rake_application.rb +0 -364
- data/test/test_rake_application_options.rb +0 -382
- data/test/test_rake_clean.rb +0 -12
- data/test/test_rake_definitions.rb +0 -80
- data/test/test_rake_directory_task.rb +0 -55
- data/test/test_rake_dsl.rb +0 -73
- data/test/test_rake_early_time.rb +0 -31
- data/test/test_rake_extension.rb +0 -59
- data/test/test_rake_file_creation_task.rb +0 -62
- data/test/test_rake_file_list.rb +0 -633
- data/test/test_rake_file_list_path_map.rb +0 -8
- data/test/test_rake_file_task.rb +0 -104
- data/test/test_rake_file_utils.rb +0 -252
- data/test/test_rake_ftp_file.rb +0 -59
- data/test/test_rake_functional.rb +0 -468
- data/test/test_rake_invocation_chain.rb +0 -52
- data/test/test_rake_makefile_loader.rb +0 -23
- data/test/test_rake_multi_task.rb +0 -51
- data/test/test_rake_name_space.rb +0 -43
- data/test/test_rake_package_task.rb +0 -78
- data/test/test_rake_path_map.rb +0 -157
- data/test/test_rake_path_map_explode.rb +0 -31
- data/test/test_rake_path_map_partial.rb +0 -18
- data/test/test_rake_pseudo_status.rb +0 -20
- data/test/test_rake_rdoc_task.rb +0 -81
- data/test/test_rake_require.rb +0 -35
- data/test/test_rake_rules.rb +0 -346
- data/test/test_rake_task.rb +0 -271
- data/test/test_rake_task_argument_parsing.rb +0 -116
- data/test/test_rake_task_arguments.rb +0 -86
- data/test/test_rake_task_lib.rb +0 -9
- data/test/test_rake_task_manager.rb +0 -145
- data/test/test_rake_task_manager_argument_resolution.rb +0 -36
- data/test/test_rake_task_with_arguments.rb +0 -162
- data/test/test_rake_test_task.rb +0 -122
- data/test/test_rake_top_level_functions.rb +0 -76
- data/test/test_rake_win32.rb +0 -83
- data/test/test_sys.rb +0 -20
data/lib/rake/testtask.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
require
|
4
|
-
require 'rake/tasklib'
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "rake"
|
3
|
+
require "rake/tasklib"
|
5
4
|
|
6
5
|
module Rake
|
7
6
|
|
8
7
|
# Create a task that runs a set of tests.
|
9
8
|
#
|
10
9
|
# Example:
|
10
|
+
# require "rake/testtask"
|
11
11
|
#
|
12
12
|
# Rake::TestTask.new do |t|
|
13
13
|
# t.libs << "test"
|
@@ -37,7 +37,7 @@ module Rake
|
|
37
37
|
# Name of test task. (default is :test)
|
38
38
|
attr_accessor :name
|
39
39
|
|
40
|
-
# List of directories
|
40
|
+
# List of directories added to $LOAD_PATH before running the
|
41
41
|
# tests. (default is 'lib')
|
42
42
|
attr_accessor :libs
|
43
43
|
|
@@ -51,6 +51,7 @@ module Rake
|
|
51
51
|
|
52
52
|
# Request that the tests be run with the warning flag set.
|
53
53
|
# E.g. warning=true implies "ruby -w" used to run the tests.
|
54
|
+
# (default is true)
|
54
55
|
attr_accessor :warning
|
55
56
|
|
56
57
|
# Glob pattern to match test files. (default is 'test/test*.rb')
|
@@ -64,9 +65,15 @@ module Rake
|
|
64
65
|
#
|
65
66
|
attr_accessor :loader
|
66
67
|
|
67
|
-
# Array of
|
68
|
+
# Array of command line options to pass to ruby when running test loader.
|
68
69
|
attr_accessor :ruby_opts
|
69
70
|
|
71
|
+
# Description of the test task. (default is 'Run tests')
|
72
|
+
attr_accessor :description
|
73
|
+
|
74
|
+
# Task prerequisites.
|
75
|
+
attr_accessor :deps
|
76
|
+
|
70
77
|
# Explicitly define the list of test files to be included in a
|
71
78
|
# test. +list+ is expected to be an array of file names (a
|
72
79
|
# FileList is acceptable). If both +pattern+ and +test_files+ are
|
@@ -83,108 +90,99 @@ module Rake
|
|
83
90
|
@options = nil
|
84
91
|
@test_files = nil
|
85
92
|
@verbose = false
|
86
|
-
@warning =
|
93
|
+
@warning = true
|
87
94
|
@loader = :rake
|
88
95
|
@ruby_opts = []
|
96
|
+
@description = "Run tests" + (@name == :test ? "" : " for #{@name}")
|
97
|
+
@deps = []
|
98
|
+
if @name.is_a?(Hash)
|
99
|
+
@deps = @name.values.first
|
100
|
+
@name = @name.keys.first
|
101
|
+
end
|
89
102
|
yield self if block_given?
|
90
|
-
@pattern =
|
103
|
+
@pattern = "test/test*.rb" if @pattern.nil? && @test_files.nil?
|
91
104
|
define
|
92
105
|
end
|
93
106
|
|
94
107
|
# Create the tasks defined by this task lib.
|
95
108
|
def define
|
96
|
-
desc
|
97
|
-
task @name do
|
109
|
+
desc @description
|
110
|
+
task @name => Array(deps) do
|
98
111
|
FileUtilsExt.verbose(@verbose) do
|
99
|
-
|
112
|
+
puts "Use TESTOPTS=\"--verbose\" to pass --verbose" \
|
113
|
+
", etc. to runners." if ARGV.include? "--verbose"
|
114
|
+
args =
|
115
|
+
"#{ruby_opts_string} #{run_code} " +
|
116
|
+
"#{file_list_string} #{option_list}"
|
117
|
+
ruby args do |ok, status|
|
118
|
+
if !ok && status.respond_to?(:signaled?) && status.signaled?
|
119
|
+
raise SignalException.new(status.termsig)
|
120
|
+
elsif !ok
|
121
|
+
status = "Command failed with status (#{status.exitstatus})"
|
122
|
+
details = ": [ruby #{args}]"
|
123
|
+
message =
|
124
|
+
if Rake.application.options.trace or @verbose
|
125
|
+
status + details
|
126
|
+
else
|
127
|
+
status
|
128
|
+
end
|
129
|
+
|
130
|
+
fail message
|
131
|
+
end
|
132
|
+
end
|
100
133
|
end
|
101
134
|
end
|
102
135
|
self
|
103
136
|
end
|
104
137
|
|
105
138
|
def option_list # :nodoc:
|
106
|
-
(ENV[
|
107
|
-
ENV[
|
108
|
-
ENV[
|
109
|
-
ENV[
|
139
|
+
(ENV["TESTOPTS"] ||
|
140
|
+
ENV["TESTOPT"] ||
|
141
|
+
ENV["TEST_OPTS"] ||
|
142
|
+
ENV["TEST_OPT"] ||
|
110
143
|
@options ||
|
111
144
|
"")
|
112
145
|
end
|
113
146
|
|
114
|
-
def ruby_opts_string
|
147
|
+
def ruby_opts_string # :nodoc:
|
115
148
|
opts = @ruby_opts.dup
|
116
|
-
opts.unshift(
|
117
|
-
opts.unshift(
|
149
|
+
opts.unshift("-I\"#{lib_path}\"") unless @libs.empty?
|
150
|
+
opts.unshift("-w") if @warning
|
118
151
|
opts.join(" ")
|
119
152
|
end
|
120
153
|
|
121
|
-
def lib_path
|
154
|
+
def lib_path # :nodoc:
|
122
155
|
@libs.join(File::PATH_SEPARATOR)
|
123
156
|
end
|
124
157
|
|
125
|
-
def file_list_string
|
126
|
-
file_list.
|
158
|
+
def file_list_string # :nodoc:
|
159
|
+
file_list.map { |fn| "\"#{fn}\"" }.join(" ")
|
127
160
|
end
|
128
161
|
|
129
162
|
def file_list # :nodoc:
|
130
|
-
if ENV[
|
131
|
-
FileList[
|
163
|
+
if ENV["TEST"]
|
164
|
+
FileList[ENV["TEST"]]
|
132
165
|
else
|
133
166
|
result = []
|
134
167
|
result += @test_files.to_a if @test_files
|
135
|
-
result
|
168
|
+
result += FileList[@pattern].to_a if @pattern
|
136
169
|
result
|
137
170
|
end
|
138
171
|
end
|
139
172
|
|
140
|
-
def
|
141
|
-
case ruby_version
|
142
|
-
when '1.8.2'
|
143
|
-
"\"#{find_file 'rake/ruby182_test_unit_fix'}\""
|
144
|
-
else
|
145
|
-
nil
|
146
|
-
end || ''
|
147
|
-
end
|
148
|
-
|
149
|
-
def ruby_version
|
173
|
+
def ruby_version # :nodoc:
|
150
174
|
RUBY_VERSION
|
151
175
|
end
|
152
176
|
|
153
|
-
def run_code
|
177
|
+
def run_code # :nodoc:
|
154
178
|
case @loader
|
155
179
|
when :direct
|
156
180
|
"-e \"ARGV.each{|f| require f}\""
|
157
181
|
when :testrb
|
158
|
-
"-S testrb
|
182
|
+
"-S testrb"
|
159
183
|
when :rake
|
160
|
-
"
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
def rake_loader # :nodoc:
|
165
|
-
find_file('rake/rake_test_loader') or
|
166
|
-
fail "unable to find rake test loader"
|
167
|
-
end
|
168
|
-
|
169
|
-
def find_file(fn) # :nodoc:
|
170
|
-
$LOAD_PATH.each do |path|
|
171
|
-
file_path = File.join(path, "#{fn}.rb")
|
172
|
-
return file_path if File.exist? file_path
|
173
|
-
end
|
174
|
-
nil
|
175
|
-
end
|
176
|
-
|
177
|
-
def rake_lib_dir # :nodoc:
|
178
|
-
find_dir('rake') or
|
179
|
-
fail "unable to find rake lib"
|
180
|
-
end
|
181
|
-
|
182
|
-
def find_dir(fn) # :nodoc:
|
183
|
-
$LOAD_PATH.each do |path|
|
184
|
-
file_path = File.join(path, "#{fn}.rb")
|
185
|
-
return path if File.exist? file_path
|
184
|
+
"#{__dir__}/rake_test_loader.rb"
|
186
185
|
end
|
187
|
-
nil
|
188
186
|
end
|
189
187
|
|
190
188
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "rake/private_reader"
|
3
|
+
|
4
|
+
module Rake
|
5
|
+
|
6
|
+
class ThreadHistoryDisplay # :nodoc: all
|
7
|
+
include Rake::PrivateReader
|
8
|
+
|
9
|
+
private_reader :stats, :items, :threads
|
10
|
+
|
11
|
+
def initialize(stats)
|
12
|
+
@stats = stats
|
13
|
+
@items = { _seq_: 1 }
|
14
|
+
@threads = { _seq_: "A" }
|
15
|
+
end
|
16
|
+
|
17
|
+
def show
|
18
|
+
puts "Job History:"
|
19
|
+
stats.each do |stat|
|
20
|
+
stat[:data] ||= {}
|
21
|
+
rename(stat, :thread, threads)
|
22
|
+
rename(stat[:data], :item_id, items)
|
23
|
+
rename(stat[:data], :new_thread, threads)
|
24
|
+
rename(stat[:data], :deleted_thread, threads)
|
25
|
+
printf("%8d %2s %-20s %s\n",
|
26
|
+
(stat[:time] * 1_000_000).round,
|
27
|
+
stat[:thread],
|
28
|
+
stat[:event],
|
29
|
+
stat[:data].map do |k, v| "#{k}:#{v}" end.join(" "))
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def rename(hash, key, renames)
|
36
|
+
if hash && hash[key]
|
37
|
+
original = hash[key]
|
38
|
+
value = renames[original]
|
39
|
+
unless value
|
40
|
+
value = renames[:_seq_]
|
41
|
+
renames[:_seq_] = renames[:_seq_].succ
|
42
|
+
renames[original] = value
|
43
|
+
end
|
44
|
+
hash[key] = value
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,163 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "set"
|
3
|
+
|
4
|
+
require "rake/promise"
|
5
|
+
|
6
|
+
module Rake
|
7
|
+
|
8
|
+
class ThreadPool # :nodoc: all
|
9
|
+
|
10
|
+
# Creates a ThreadPool object. The +thread_count+ parameter is the size
|
11
|
+
# of the pool.
|
12
|
+
def initialize(thread_count)
|
13
|
+
@max_active_threads = [thread_count, 0].max
|
14
|
+
@threads = Set.new
|
15
|
+
@threads_mon = Monitor.new
|
16
|
+
@queue = Queue.new
|
17
|
+
@join_cond = @threads_mon.new_cond
|
18
|
+
|
19
|
+
@history_start_time = nil
|
20
|
+
@history = []
|
21
|
+
@history_mon = Monitor.new
|
22
|
+
@total_threads_in_play = 0
|
23
|
+
end
|
24
|
+
|
25
|
+
# Creates a future executed by the +ThreadPool+.
|
26
|
+
#
|
27
|
+
# The args are passed to the block when executing (similarly to
|
28
|
+
# Thread#new) The return value is an object representing
|
29
|
+
# a future which has been created and added to the queue in the
|
30
|
+
# pool. Sending #value to the object will sleep the
|
31
|
+
# current thread until the future is finished and will return the
|
32
|
+
# result (or raise an exception thrown from the future)
|
33
|
+
def future(*args, &block)
|
34
|
+
promise = Promise.new(args, &block)
|
35
|
+
promise.recorder = lambda { |*stats| stat(*stats) }
|
36
|
+
|
37
|
+
@queue.enq promise
|
38
|
+
stat :queued, item_id: promise.object_id
|
39
|
+
start_thread
|
40
|
+
promise
|
41
|
+
end
|
42
|
+
|
43
|
+
# Waits until the queue of futures is empty and all threads have exited.
|
44
|
+
def join
|
45
|
+
@threads_mon.synchronize do
|
46
|
+
begin
|
47
|
+
stat :joining
|
48
|
+
@join_cond.wait unless @threads.empty?
|
49
|
+
stat :joined
|
50
|
+
rescue Exception => e
|
51
|
+
stat :joined
|
52
|
+
$stderr.puts e
|
53
|
+
$stderr.print "Queue contains #{@queue.size} items. " +
|
54
|
+
"Thread pool contains #{@threads.count} threads\n"
|
55
|
+
$stderr.print "Current Thread #{Thread.current} status = " +
|
56
|
+
"#{Thread.current.status}\n"
|
57
|
+
$stderr.puts e.backtrace.join("\n")
|
58
|
+
@threads.each do |t|
|
59
|
+
$stderr.print "Thread #{t} status = #{t.status}\n"
|
60
|
+
$stderr.puts t.backtrace.join("\n")
|
61
|
+
end
|
62
|
+
raise e
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# Enable the gathering of history events.
|
68
|
+
def gather_history #:nodoc:
|
69
|
+
@history_start_time = Time.now if @history_start_time.nil?
|
70
|
+
end
|
71
|
+
|
72
|
+
# Return a array of history events for the thread pool.
|
73
|
+
#
|
74
|
+
# History gathering must be enabled to be able to see the events
|
75
|
+
# (see #gather_history). Best to call this when the job is
|
76
|
+
# complete (i.e. after ThreadPool#join is called).
|
77
|
+
def history # :nodoc:
|
78
|
+
@history_mon.synchronize { @history.dup }.
|
79
|
+
sort_by { |i| i[:time] }.
|
80
|
+
each { |i| i[:time] -= @history_start_time }
|
81
|
+
end
|
82
|
+
|
83
|
+
# Return a hash of always collected statistics for the thread pool.
|
84
|
+
def statistics # :nodoc:
|
85
|
+
{
|
86
|
+
total_threads_in_play: @total_threads_in_play,
|
87
|
+
max_active_threads: @max_active_threads,
|
88
|
+
}
|
89
|
+
end
|
90
|
+
|
91
|
+
private
|
92
|
+
|
93
|
+
# processes one item on the queue. Returns true if there was an
|
94
|
+
# item to process, false if there was no item
|
95
|
+
def process_queue_item #:nodoc:
|
96
|
+
return false if @queue.empty?
|
97
|
+
|
98
|
+
# Even though we just asked if the queue was empty, it
|
99
|
+
# still could have had an item which by this statement
|
100
|
+
# is now gone. For this reason we pass true to Queue#deq
|
101
|
+
# because we will sleep indefinitely if it is empty.
|
102
|
+
promise = @queue.deq(true)
|
103
|
+
stat :dequeued, item_id: promise.object_id
|
104
|
+
promise.work
|
105
|
+
return true
|
106
|
+
|
107
|
+
rescue ThreadError # this means the queue is empty
|
108
|
+
false
|
109
|
+
end
|
110
|
+
|
111
|
+
def safe_thread_count
|
112
|
+
@threads_mon.synchronize do
|
113
|
+
@threads.count
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def start_thread # :nodoc:
|
118
|
+
@threads_mon.synchronize do
|
119
|
+
next unless @threads.count < @max_active_threads
|
120
|
+
|
121
|
+
t = Thread.new do
|
122
|
+
begin
|
123
|
+
while safe_thread_count <= @max_active_threads
|
124
|
+
break unless process_queue_item
|
125
|
+
end
|
126
|
+
ensure
|
127
|
+
@threads_mon.synchronize do
|
128
|
+
@threads.delete Thread.current
|
129
|
+
stat :ended, thread_count: @threads.count
|
130
|
+
@join_cond.broadcast if @threads.empty?
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
@threads << t
|
136
|
+
stat(
|
137
|
+
:spawned,
|
138
|
+
new_thread: t.object_id,
|
139
|
+
thread_count: @threads.count)
|
140
|
+
@total_threads_in_play = @threads.count if
|
141
|
+
@threads.count > @total_threads_in_play
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def stat(event, data=nil) # :nodoc:
|
146
|
+
return if @history_start_time.nil?
|
147
|
+
info = {
|
148
|
+
event: event,
|
149
|
+
data: data,
|
150
|
+
time: Time.now,
|
151
|
+
thread: Thread.current.object_id,
|
152
|
+
}
|
153
|
+
@history_mon.synchronize { @history << info }
|
154
|
+
end
|
155
|
+
|
156
|
+
# for testing only
|
157
|
+
|
158
|
+
def __queue__ # :nodoc:
|
159
|
+
@queue
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Rake
|
3
|
+
module TraceOutput # :nodoc: all
|
4
|
+
|
5
|
+
# Write trace output to output stream +out+.
|
6
|
+
#
|
7
|
+
# The write is done as a single IO call (to print) to lessen the
|
8
|
+
# chance that the trace output is interrupted by other tasks also
|
9
|
+
# producing output.
|
10
|
+
def trace_on(out, *strings)
|
11
|
+
sep = $\ || "\n"
|
12
|
+
if strings.empty?
|
13
|
+
output = sep
|
14
|
+
else
|
15
|
+
output = strings.map { |s|
|
16
|
+
next if s.nil?
|
17
|
+
s.end_with?(sep) ? s : s + sep
|
18
|
+
}.join
|
19
|
+
end
|
20
|
+
out.print(output)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/rake/version.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Rake
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
]
|
3
|
+
VERSION = "13.0.3"
|
4
|
+
|
5
|
+
module Version # :nodoc: all
|
6
|
+
MAJOR, MINOR, BUILD, *OTHER = Rake::VERSION.split "."
|
7
|
+
|
8
|
+
NUMBERS = [MAJOR, MINOR, BUILD, *OTHER]
|
8
9
|
end
|
9
|
-
VERSION = Version::NUMBERS.join('.')
|
10
10
|
end
|