podoy 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/README.md +35 -0
  4. data/Rakefile +4 -0
  5. data/lib/podoy/version.rb +5 -0
  6. data/lib/podoy.rb +8 -0
  7. data/sig/podoy.rbs +4 -0
  8. data/vendor/bundle/ruby/3.3.0+0/bin/rake +29 -0
  9. data/vendor/bundle/ruby/3.3.0+0/cache/rake-13.1.0.gem +0 -0
  10. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/History.rdoc +2403 -0
  11. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/MIT-LICENSE +21 -0
  12. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/README.rdoc +155 -0
  13. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/doc/command_line_usage.rdoc +158 -0
  14. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/doc/example/Rakefile1 +38 -0
  15. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/doc/example/Rakefile2 +35 -0
  16. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/doc/example/a.c +6 -0
  17. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/doc/example/b.c +6 -0
  18. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/doc/example/main.c +11 -0
  19. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/doc/glossary.rdoc +42 -0
  20. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/doc/jamis.rb +592 -0
  21. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/doc/proto_rake.rdoc +127 -0
  22. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/doc/rake.1 +156 -0
  23. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/doc/rakefile.rdoc +622 -0
  24. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/doc/rational.rdoc +151 -0
  25. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/exe/rake +27 -0
  26. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/application.rb +855 -0
  27. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/backtrace.rb +24 -0
  28. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/clean.rb +78 -0
  29. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/cloneable.rb +17 -0
  30. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/cpu_counter.rb +107 -0
  31. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/default_loader.rb +15 -0
  32. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/dsl_definition.rb +195 -0
  33. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/early_time.rb +22 -0
  34. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/ext/core.rb +26 -0
  35. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/ext/string.rb +176 -0
  36. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/file_creation_task.rb +25 -0
  37. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/file_list.rb +435 -0
  38. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/file_task.rb +58 -0
  39. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/file_utils.rb +132 -0
  40. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/file_utils_ext.rb +134 -0
  41. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/invocation_chain.rb +57 -0
  42. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/invocation_exception_mixin.rb +17 -0
  43. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/late_time.rb +18 -0
  44. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/linked_list.rb +112 -0
  45. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/loaders/makefile.rb +54 -0
  46. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/multi_task.rb +14 -0
  47. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/name_space.rb +38 -0
  48. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/packagetask.rb +222 -0
  49. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/phony.rb +16 -0
  50. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/private_reader.rb +21 -0
  51. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/promise.rb +100 -0
  52. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/pseudo_status.rb +30 -0
  53. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/rake_module.rb +67 -0
  54. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/rake_test_loader.rb +27 -0
  55. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/rule_recursion_overflow_error.rb +20 -0
  56. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/scope.rb +43 -0
  57. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/task.rb +434 -0
  58. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/task_argument_error.rb +8 -0
  59. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/task_arguments.rb +109 -0
  60. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/task_manager.rb +331 -0
  61. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/tasklib.rb +12 -0
  62. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/testtask.rb +189 -0
  63. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/thread_history_display.rb +49 -0
  64. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/thread_pool.rb +163 -0
  65. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/trace_output.rb +23 -0
  66. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/version.rb +10 -0
  67. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake/win32.rb +51 -0
  68. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/lib/rake.rb +71 -0
  69. data/vendor/bundle/ruby/3.3.0+0/gems/rake-13.1.0/rake.gemspec +101 -0
  70. data/vendor/bundle/ruby/3.3.0+0/specifications/rake-13.1.0.gemspec +26 -0
  71. metadata +117 -0
@@ -0,0 +1,331 @@
1
+ # frozen_string_literal: true
2
+ module Rake
3
+
4
+ # The TaskManager module is a mixin for managing tasks.
5
+ module TaskManager
6
+ # Track the last comment made in the Rakefile.
7
+ attr_accessor :last_description
8
+
9
+ def initialize # :nodoc:
10
+ super
11
+ @tasks = Hash.new
12
+ @rules = Array.new
13
+ @scope = Scope.make
14
+ @last_description = nil
15
+ end
16
+
17
+ def create_rule(*args, &block) # :nodoc:
18
+ pattern, args, deps, order_only = resolve_args(args)
19
+ pattern = Regexp.new(Regexp.quote(pattern) + "$") if String === pattern
20
+ @rules << [pattern, args, deps, order_only, block]
21
+ end
22
+
23
+ def define_task(task_class, *args, &block) # :nodoc:
24
+ task_name, arg_names, deps, order_only = resolve_args(args)
25
+
26
+ original_scope = @scope
27
+ if String === task_name and
28
+ not task_class.ancestors.include? Rake::FileTask
29
+ task_name, *definition_scope = *(task_name.split(":").reverse)
30
+ @scope = Scope.make(*(definition_scope + @scope.to_a))
31
+ end
32
+
33
+ task_name = task_class.scope_name(@scope, task_name)
34
+ task = intern(task_class, task_name)
35
+ task.set_arg_names(arg_names) unless arg_names.empty?
36
+ if Rake::TaskManager.record_task_metadata
37
+ add_location(task)
38
+ task.add_description(get_description(task))
39
+ end
40
+ task.enhance(Task.format_deps(deps), &block)
41
+ task | order_only unless order_only.nil?
42
+ task
43
+ ensure
44
+ @scope = original_scope
45
+ end
46
+
47
+ # Lookup a task. Return an existing task if found, otherwise
48
+ # create a task of the current type.
49
+ def intern(task_class, task_name)
50
+ @tasks[task_name.to_s] ||= task_class.new(task_name, self)
51
+ end
52
+
53
+ # Find a matching task for +task_name+.
54
+ def [](task_name, scopes=nil)
55
+ task_name = task_name.to_s
56
+ self.lookup(task_name, scopes) or
57
+ enhance_with_matching_rule(task_name) or
58
+ synthesize_file_task(task_name) or
59
+ fail generate_message_for_undefined_task(task_name)
60
+ end
61
+
62
+ def generate_message_for_undefined_task(task_name)
63
+ message = "Don't know how to build task '#{task_name}' "\
64
+ "(See the list of available tasks with `#{Rake.application.name} --tasks`)"
65
+ message + generate_did_you_mean_suggestions(task_name)
66
+ end
67
+
68
+ def generate_did_you_mean_suggestions(task_name)
69
+ return "" unless defined?(::DidYouMean::SpellChecker)
70
+
71
+ suggestions = ::DidYouMean::SpellChecker.new(dictionary: @tasks.keys).correct(task_name.to_s)
72
+ if ::DidYouMean.respond_to?(:formatter)# did_you_mean v1.2.0 or later
73
+ ::DidYouMean.formatter.message_for(suggestions)
74
+ elsif defined?(::DidYouMean::Formatter) # before did_you_mean v1.2.0
75
+ ::DidYouMean::Formatter.new(suggestions).to_s
76
+ else
77
+ ""
78
+ end
79
+ end
80
+
81
+ def synthesize_file_task(task_name) # :nodoc:
82
+ return nil unless File.exist?(task_name)
83
+ define_task(Rake::FileTask, task_name)
84
+ end
85
+
86
+ # Resolve the arguments for a task/rule. Returns a tuple of
87
+ # [task_name, arg_name_list, prerequisites, order_only_prerequisites].
88
+ def resolve_args(args)
89
+ if args.last.is_a?(Hash)
90
+ deps = args.pop
91
+ resolve_args_with_dependencies(args, deps)
92
+ else
93
+ resolve_args_without_dependencies(args)
94
+ end
95
+ end
96
+
97
+ # Resolve task arguments for a task or rule when there are no
98
+ # dependencies declared.
99
+ #
100
+ # The patterns recognized by this argument resolving function are:
101
+ #
102
+ # task :t
103
+ # task :t, [:a]
104
+ #
105
+ def resolve_args_without_dependencies(args)
106
+ task_name = args.shift
107
+ if args.size == 1 && args.first.respond_to?(:to_ary)
108
+ arg_names = args.first.to_ary
109
+ else
110
+ arg_names = args
111
+ end
112
+ [task_name, arg_names, [], nil]
113
+ end
114
+ private :resolve_args_without_dependencies
115
+
116
+ # Resolve task arguments for a task or rule when there are
117
+ # dependencies declared.
118
+ #
119
+ # The patterns recognized by this argument resolving function are:
120
+ #
121
+ # task :t, order_only: [:e]
122
+ # task :t => [:d]
123
+ # task :t => [:d], order_only: [:e]
124
+ # task :t, [a] => [:d]
125
+ # task :t, [a] => [:d], order_only: [:e]
126
+ #
127
+ def resolve_args_with_dependencies(args, hash) # :nodoc:
128
+ fail "Task Argument Error" if
129
+ hash.size != 1 &&
130
+ (hash.size != 2 || !hash.key?(:order_only))
131
+ order_only = hash.delete(:order_only)
132
+ key, value = hash.map { |k, v| [k, v] }.first
133
+ if args.empty?
134
+ task_name = key
135
+ arg_names = []
136
+ deps = value || []
137
+ else
138
+ task_name = args.shift
139
+ arg_names = key || args.shift|| []
140
+ deps = value || []
141
+ end
142
+ deps = [deps] unless deps.respond_to?(:to_ary)
143
+ [task_name, arg_names, deps, order_only]
144
+ end
145
+ private :resolve_args_with_dependencies
146
+
147
+ # If a rule can be found that matches the task name, enhance the
148
+ # task with the prerequisites and actions from the rule. Set the
149
+ # source attribute of the task appropriately for the rule. Return
150
+ # the enhanced task or nil of no rule was found.
151
+ def enhance_with_matching_rule(task_name, level=0)
152
+ fail Rake::RuleRecursionOverflowError,
153
+ "Rule Recursion Too Deep" if level >= 16
154
+ @rules.each do |pattern, args, extensions, order_only, block|
155
+ if pattern && pattern.match(task_name)
156
+ task = attempt_rule(task_name, pattern, args, extensions, block, level)
157
+ task | order_only unless order_only.nil?
158
+ return task if task
159
+ end
160
+ end
161
+ nil
162
+ rescue Rake::RuleRecursionOverflowError => ex
163
+ ex.add_target(task_name)
164
+ fail ex
165
+ end
166
+
167
+ # List of all defined tasks in this application.
168
+ def tasks
169
+ @tasks.values.sort_by { |t| t.name }
170
+ end
171
+
172
+ # List of all the tasks defined in the given scope (and its
173
+ # sub-scopes).
174
+ def tasks_in_scope(scope)
175
+ prefix = scope.path
176
+ tasks.select { |t|
177
+ /^#{prefix}:/ =~ t.name
178
+ }
179
+ end
180
+
181
+ # Clear all tasks in this application.
182
+ def clear
183
+ @tasks.clear
184
+ @rules.clear
185
+ end
186
+
187
+ # Lookup a task, using scope and the scope hints in the task name.
188
+ # This method performs straight lookups without trying to
189
+ # synthesize file tasks or rules. Special scope names (e.g. '^')
190
+ # are recognized. If no scope argument is supplied, use the
191
+ # current scope. Return nil if the task cannot be found.
192
+ def lookup(task_name, initial_scope=nil)
193
+ initial_scope ||= @scope
194
+ task_name = task_name.to_s
195
+ if task_name =~ /^rake:/
196
+ scopes = Scope.make
197
+ task_name = task_name.sub(/^rake:/, "")
198
+ elsif task_name =~ /^(\^+)/
199
+ scopes = initial_scope.trim($1.size)
200
+ task_name = task_name.sub(/^(\^+)/, "")
201
+ else
202
+ scopes = initial_scope
203
+ end
204
+ lookup_in_scope(task_name, scopes)
205
+ end
206
+
207
+ # Lookup the task name
208
+ def lookup_in_scope(name, scope)
209
+ loop do
210
+ tn = scope.path_with_task_name(name)
211
+ task = @tasks[tn]
212
+ return task if task
213
+ break if scope.empty?
214
+ scope = scope.tail
215
+ end
216
+ nil
217
+ end
218
+ private :lookup_in_scope
219
+
220
+ # Return the list of scope names currently active in the task
221
+ # manager.
222
+ def current_scope
223
+ @scope
224
+ end
225
+
226
+ # Evaluate the block in a nested namespace named +name+. Create
227
+ # an anonymous namespace if +name+ is nil.
228
+ def in_namespace(name)
229
+ name ||= generate_name
230
+ @scope = Scope.new(name, @scope)
231
+ ns = NameSpace.new(self, @scope)
232
+ yield(ns)
233
+ ns
234
+ ensure
235
+ @scope = @scope.tail
236
+ end
237
+
238
+ private
239
+
240
+ # Add a location to the locations field of the given task.
241
+ def add_location(task)
242
+ loc = find_location
243
+ task.locations << loc if loc
244
+ task
245
+ end
246
+
247
+ # Find the location that called into the dsl layer.
248
+ def find_location
249
+ locations = caller
250
+ i = 0
251
+ while locations[i]
252
+ return locations[i + 1] if locations[i] =~ /rake\/dsl_definition.rb/
253
+ i += 1
254
+ end
255
+ nil
256
+ end
257
+
258
+ # Generate an anonymous namespace name.
259
+ def generate_name
260
+ @seed ||= 0
261
+ @seed += 1
262
+ "_anon_#{@seed}"
263
+ end
264
+
265
+ def trace_rule(level, message) # :nodoc:
266
+ options.trace_output.puts "#{" " * level}#{message}" if
267
+ Rake.application.options.trace_rules
268
+ end
269
+
270
+ # Attempt to create a rule given the list of prerequisites.
271
+ def attempt_rule(task_name, task_pattern, args, extensions, block, level)
272
+ sources = make_sources(task_name, task_pattern, extensions)
273
+ prereqs = sources.map { |source|
274
+ trace_rule level, "Attempting Rule #{task_name} => #{source}"
275
+ if File.exist?(source) || Rake::Task.task_defined?(source)
276
+ trace_rule level, "(#{task_name} => #{source} ... EXIST)"
277
+ source
278
+ elsif parent = enhance_with_matching_rule(source, level + 1)
279
+ trace_rule level, "(#{task_name} => #{source} ... ENHANCE)"
280
+ parent.name
281
+ else
282
+ trace_rule level, "(#{task_name} => #{source} ... FAIL)"
283
+ return nil
284
+ end
285
+ }
286
+ task = FileTask.define_task(task_name, { args => prereqs }, &block)
287
+ task.sources = prereqs
288
+ task
289
+ end
290
+
291
+ # Make a list of sources from the list of file name extensions /
292
+ # translation procs.
293
+ def make_sources(task_name, task_pattern, extensions)
294
+ result = extensions.map { |ext|
295
+ case ext
296
+ when /%/
297
+ task_name.pathmap(ext)
298
+ when %r{/}
299
+ ext
300
+ when /^\./
301
+ source = task_name.sub(task_pattern, ext)
302
+ source == ext ? task_name.ext(ext) : source
303
+ when String, Symbol
304
+ ext.to_s
305
+ when Proc, Method
306
+ if ext.arity == 1
307
+ ext.call(task_name)
308
+ else
309
+ ext.call
310
+ end
311
+ else
312
+ fail "Don't know how to handle rule dependent: #{ext.inspect}"
313
+ end
314
+ }
315
+ result.flatten
316
+ end
317
+
318
+ # Return the current description, clearing it in the process.
319
+ def get_description(task)
320
+ desc = @last_description
321
+ @last_description = nil
322
+ desc
323
+ end
324
+
325
+ class << self
326
+ attr_accessor :record_task_metadata # :nodoc:
327
+ TaskManager.record_task_metadata = false
328
+ end
329
+ end
330
+
331
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+ require "rake"
3
+
4
+ module Rake
5
+
6
+ # Base class for Task Libraries.
7
+ class TaskLib
8
+ include Cloneable
9
+ include Rake::DSL
10
+ end
11
+
12
+ end
@@ -0,0 +1,189 @@
1
+ # frozen_string_literal: true
2
+ require "rake"
3
+ require "rake/tasklib"
4
+
5
+ module Rake
6
+
7
+ # Create a task that runs a set of tests.
8
+ #
9
+ # Example:
10
+ # require "rake/testtask"
11
+ #
12
+ # Rake::TestTask.new do |t|
13
+ # t.libs << "test"
14
+ # t.test_files = FileList['test/test*.rb']
15
+ # t.verbose = true
16
+ # end
17
+ #
18
+ # If rake is invoked with a "TEST=filename" command line option,
19
+ # then the list of test files will be overridden to include only the
20
+ # filename specified on the command line. This provides an easy way
21
+ # to run just one test.
22
+ #
23
+ # If rake is invoked with a "TESTOPTS=options" command line option,
24
+ # then the given options are passed to the test process after a
25
+ # '--'. This allows Test::Unit options to be passed to the test
26
+ # suite.
27
+ #
28
+ # Examples:
29
+ #
30
+ # rake test # run tests normally
31
+ # rake test TEST=just_one_file.rb # run just one test file.
32
+ # rake test TESTOPTS="-v" # run in verbose mode
33
+ # rake test TESTOPTS="--runner=fox" # use the fox test runner
34
+ #
35
+ class TestTask < TaskLib
36
+
37
+ # Name of test task. (default is :test)
38
+ attr_accessor :name
39
+
40
+ # List of directories added to $LOAD_PATH before running the
41
+ # tests. (default is 'lib')
42
+ attr_accessor :libs
43
+
44
+ # True if verbose test output desired. (default is false)
45
+ attr_accessor :verbose
46
+
47
+ # Test options passed to the test suite. An explicit
48
+ # TESTOPTS=opts on the command line will override this. (default
49
+ # is NONE)
50
+ attr_accessor :options
51
+
52
+ # Request that the tests be run with the warning flag set.
53
+ # E.g. warning=true implies "ruby -w" used to run the tests.
54
+ # (default is true)
55
+ attr_accessor :warning
56
+
57
+ # Glob pattern to match test files. (default is 'test/test*.rb')
58
+ attr_accessor :pattern
59
+
60
+ # Style of test loader to use. Options are:
61
+ #
62
+ # * :rake -- Rake provided test loading script (default).
63
+ # * :testrb -- Ruby provided test loading script.
64
+ # * :direct -- Load tests using command line loader.
65
+ #
66
+ attr_accessor :loader
67
+
68
+ # Array of command line options to pass to ruby when running test loader.
69
+ attr_accessor :ruby_opts
70
+
71
+ # Description of the test task. (default is 'Run tests')
72
+ attr_accessor :description
73
+
74
+ # Task prerequisites.
75
+ attr_accessor :deps
76
+
77
+ # Explicitly define the list of test files to be included in a
78
+ # test. +list+ is expected to be an array of file names (a
79
+ # FileList is acceptable). If both +pattern+ and +test_files+ are
80
+ # used, then the list of test files is the union of the two.
81
+ def test_files=(list)
82
+ @test_files = list
83
+ end
84
+
85
+ # Create a testing task.
86
+ def initialize(name=:test)
87
+ @name = name
88
+ @libs = ["lib"]
89
+ @pattern = nil
90
+ @options = nil
91
+ @test_files = nil
92
+ @verbose = false
93
+ @warning = true
94
+ @loader = :rake
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
102
+ yield self if block_given?
103
+ @pattern = "test/test*.rb" if @pattern.nil? && @test_files.nil?
104
+ define
105
+ end
106
+
107
+ # Create the tasks defined by this task lib.
108
+ def define
109
+ desc @description
110
+ task @name => Array(deps) do
111
+ FileUtilsExt.verbose(@verbose) do
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
133
+ end
134
+ end
135
+ self
136
+ end
137
+
138
+ def option_list # :nodoc:
139
+ (ENV["TESTOPTS"] ||
140
+ ENV["TESTOPT"] ||
141
+ ENV["TEST_OPTS"] ||
142
+ ENV["TEST_OPT"] ||
143
+ @options ||
144
+ "")
145
+ end
146
+
147
+ def ruby_opts_string # :nodoc:
148
+ opts = @ruby_opts.dup
149
+ opts.unshift("-I\"#{lib_path}\"") unless @libs.empty?
150
+ opts.unshift("-w") if @warning
151
+ opts.join(" ")
152
+ end
153
+
154
+ def lib_path # :nodoc:
155
+ @libs.join(File::PATH_SEPARATOR)
156
+ end
157
+
158
+ def file_list_string # :nodoc:
159
+ file_list.map { |fn| "\"#{fn}\"" }.join(" ")
160
+ end
161
+
162
+ def file_list # :nodoc:
163
+ if ENV["TEST"]
164
+ FileList[ENV["TEST"]]
165
+ else
166
+ result = []
167
+ result += @test_files.to_a if @test_files
168
+ result += FileList[@pattern].to_a if @pattern
169
+ result
170
+ end
171
+ end
172
+
173
+ def ruby_version # :nodoc:
174
+ RUBY_VERSION
175
+ end
176
+
177
+ def run_code # :nodoc:
178
+ case @loader
179
+ when :direct
180
+ "-e \"ARGV.each{|f| require f}\""
181
+ when :testrb
182
+ "-S testrb"
183
+ when :rake
184
+ "#{__dir__}/rake_test_loader.rb"
185
+ end
186
+ end
187
+
188
+ end
189
+ 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