jimweirich-rake 0.8.1.9 → 0.8.1.10
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.
- data/Rakefile +6 -2
- data/doc/rakefile.rdoc +12 -5
- data/lib/rake/rdoctask.rb +4 -4
- data/lib/rake/tasklib.rb +8 -3
- data/lib/rake.rb +118 -71
- data/test/contrib/{testsys.rb → test_sys.rb} +0 -0
- data/test/data/file_creation_task/Rakefile +4 -1
- data/test/in_environment.rb +2 -0
- data/test/session_functional.rb +0 -6
- data/test/test_application.rb +208 -59
- data/test/test_task_manager.rb +23 -1
- data/test/test_tasklib.rb +12 -0
- metadata +4 -3
data/Rakefile
CHANGED
@@ -95,9 +95,13 @@ begin
|
|
95
95
|
|
96
96
|
Rcov::RcovTask.new do |t|
|
97
97
|
t.libs << "test"
|
98
|
+
dot_rakes =
|
98
99
|
t.rcov_opts = [
|
99
|
-
'-xRakefile', '-xrakefile', '-xpublish.rf',
|
100
|
-
|
100
|
+
'-xRakefile', '-xrakefile', '-xpublish.rf',
|
101
|
+
'-xlib/rake/contrib', '-x/Library',
|
102
|
+
'--text-report',
|
103
|
+
'--sort coverage'
|
104
|
+
] + FileList['rakelib/*.rake'].pathmap("-x%p")
|
101
105
|
t.test_files = FileList[
|
102
106
|
'test/test*.rb', 'test/functional.rb'
|
103
107
|
]
|
data/doc/rakefile.rdoc
CHANGED
@@ -192,16 +192,16 @@ tasks has been extended slightly.
|
|
192
192
|
For example, a task that needs a first name and last name might be
|
193
193
|
declared as:
|
194
194
|
|
195
|
-
task :name, :first_name, :last_name
|
195
|
+
task :name, [:first_name, :last_name]
|
196
196
|
|
197
197
|
The first argument is still the name of the task (:name in this case).
|
198
198
|
The next to argumements are the names of the parameters expected by
|
199
|
-
:name (:first_name and :last_name in the example).
|
199
|
+
:name in an array (:first_name and :last_name in the example).
|
200
200
|
|
201
201
|
To access the values of the paramters, the block defining the task
|
202
202
|
behaviour can now accept a second parameter:
|
203
203
|
|
204
|
-
task :name, :first_name, :last_name do |t, args|
|
204
|
+
task :name, [:first_name, :last_name] do |t, args|
|
205
205
|
puts "First name is #{args.first_name}"
|
206
206
|
puts "Last name is #{args.last_name}"
|
207
207
|
end
|
@@ -216,7 +216,7 @@ If you wish to specify default values for the arguments, you can use
|
|
216
216
|
the with_defaults method in the task body. Here is the above example
|
217
217
|
where we specify default values for the first and last names:
|
218
218
|
|
219
|
-
task :name, :first_name, :last_name do |t, args|
|
219
|
+
task :name, [:first_name, :last_name] do |t, args|
|
220
220
|
args.with_defaults(:first_name => "John", :last_name => "Dough")
|
221
221
|
puts "First name is #{args.first_name}"
|
222
222
|
puts "Last name is #{args.last_name}"
|
@@ -228,12 +228,19 @@ Tasks that use parameters have a slightly different format for
|
|
228
228
|
prerequisites. Use the <tt>:needs</tt> keyword to specify the
|
229
229
|
prerequisites for tasks with arguments. For example:
|
230
230
|
|
231
|
-
task :name, :first_name, :last_name
|
231
|
+
task :name, [:first_name, :last_name] => [:pre_name] do |t, args|
|
232
232
|
args.with_defaults(:first_name => "John", :last_name => "Dough")
|
233
233
|
puts "First name is #{args.first_name}"
|
234
234
|
puts "Last name is #{args.last_name}"
|
235
235
|
end
|
236
236
|
|
237
|
+
=== Deprecated Task Parameters Format
|
238
|
+
|
239
|
+
There is an older format for declaring task parameters that omitted
|
240
|
+
the task array and used the :needs keyword to introduce the
|
241
|
+
dependencies. That format is still supported for compatibility, but
|
242
|
+
is not recommended for use.
|
243
|
+
|
237
244
|
== Accessing Task Programatically
|
238
245
|
|
239
246
|
Sometimes it is useful to manipulate tasks programatically in a
|
data/lib/rake/rdoctask.rb
CHANGED
@@ -91,14 +91,14 @@ module Rake
|
|
91
91
|
task name
|
92
92
|
|
93
93
|
desc "Force a rebuild of the RDOC files"
|
94
|
-
task
|
94
|
+
task "re#{name}" => ["clobber_#{name}", name]
|
95
95
|
|
96
96
|
desc "Remove rdoc products"
|
97
|
-
task
|
97
|
+
task "clobber_#{name}" do
|
98
98
|
rm_r rdoc_dir rescue nil
|
99
99
|
end
|
100
|
-
|
101
|
-
task :clobber => [
|
100
|
+
|
101
|
+
task :clobber => ["clobber_#{name}"]
|
102
102
|
|
103
103
|
directory @rdoc_dir
|
104
104
|
task name => [rdoc_target]
|
data/lib/rake/tasklib.rb
CHANGED
@@ -6,11 +6,16 @@ module Rake
|
|
6
6
|
|
7
7
|
# Base class for Task Libraries.
|
8
8
|
class TaskLib
|
9
|
-
|
10
9
|
include Cloneable
|
11
10
|
|
12
|
-
# Make a symbol by pasting two strings together.
|
13
|
-
|
11
|
+
# Make a symbol by pasting two strings together.
|
12
|
+
#
|
13
|
+
# NOTE: DEPRECATED! This method is kinda stupid. I don't know why
|
14
|
+
# I didn't just use string interpolation. But now other task
|
15
|
+
# libraries depend on this so I can't remove it without breaking
|
16
|
+
# other people's code. So for now it stays for backwards
|
17
|
+
# compatibility. BUT DON'T USE IT.
|
18
|
+
def paste(a,b) # :nodoc:
|
14
19
|
(a.to_s + b.to_s).intern
|
15
20
|
end
|
16
21
|
end
|
data/lib/rake.rb
CHANGED
@@ -29,7 +29,7 @@
|
|
29
29
|
# as a library via a require statement, but it can be distributed
|
30
30
|
# independently as an application.
|
31
31
|
|
32
|
-
RAKEVERSION = '0.8.1.
|
32
|
+
RAKEVERSION = '0.8.1.10'
|
33
33
|
|
34
34
|
require 'rbconfig'
|
35
35
|
require 'getoptlong'
|
@@ -240,6 +240,33 @@ end # class String
|
|
240
240
|
##############################################################################
|
241
241
|
module Rake
|
242
242
|
|
243
|
+
# Errors -----------------------------------------------------------
|
244
|
+
|
245
|
+
# Error indicating an ill-formed task declaration.
|
246
|
+
class TaskArgumentError < ArgumentError
|
247
|
+
end
|
248
|
+
|
249
|
+
# Error indicating a recursion overflow error in task selection.
|
250
|
+
class RuleRecursionOverflowError < StandardError
|
251
|
+
def initialize(*args)
|
252
|
+
super
|
253
|
+
@targets = []
|
254
|
+
end
|
255
|
+
|
256
|
+
def add_target(target)
|
257
|
+
@targets << target
|
258
|
+
end
|
259
|
+
|
260
|
+
def message
|
261
|
+
super + ": [" + @targets.reverse.join(' => ') + "]"
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
# Error indicating a problem in locating the home directory on a
|
266
|
+
# Win32 system.
|
267
|
+
class Win32HomeError < RuntimeError
|
268
|
+
end
|
269
|
+
|
243
270
|
# --------------------------------------------------------------------------
|
244
271
|
# Rake module singleton methods.
|
245
272
|
#
|
@@ -1148,21 +1175,6 @@ private(*RakeFileUtils.instance_methods(false))
|
|
1148
1175
|
######################################################################
|
1149
1176
|
module Rake
|
1150
1177
|
|
1151
|
-
class RuleRecursionOverflowError < StandardError
|
1152
|
-
def initialize(*args)
|
1153
|
-
super
|
1154
|
-
@targets = []
|
1155
|
-
end
|
1156
|
-
|
1157
|
-
def add_target(target)
|
1158
|
-
@targets << target
|
1159
|
-
end
|
1160
|
-
|
1161
|
-
def message
|
1162
|
-
super + ": [" + @targets.reverse.join(' => ') + "]"
|
1163
|
-
end
|
1164
|
-
end
|
1165
|
-
|
1166
1178
|
# #########################################################################
|
1167
1179
|
# A FileList is essentially an array with a few helper methods defined to
|
1168
1180
|
# make file manipulation a bit easier.
|
@@ -1696,23 +1708,65 @@ module Rake
|
|
1696
1708
|
# Resolve the arguments for a task/rule. Returns a triplet of
|
1697
1709
|
# [task_name, arg_name_list, prerequisites].
|
1698
1710
|
def resolve_args(args)
|
1711
|
+
if args.last.is_a?(Hash)
|
1712
|
+
deps = args.pop
|
1713
|
+
resolve_args_with_dependencies(args, deps)
|
1714
|
+
else
|
1715
|
+
resolve_args_without_dependencies(args)
|
1716
|
+
end
|
1717
|
+
end
|
1718
|
+
|
1719
|
+
# Resolve task arguments for a task or rule when there are no
|
1720
|
+
# dependencies declared.
|
1721
|
+
#
|
1722
|
+
# The patterns recognized by this argument resolving function are:
|
1723
|
+
#
|
1724
|
+
# task :t
|
1725
|
+
# task :t, [:a]
|
1726
|
+
# task :t, :a (deprecated)
|
1727
|
+
#
|
1728
|
+
def resolve_args_without_dependencies(args)
|
1699
1729
|
task_name = args.shift
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
task_name = hash.keys[0]
|
1705
|
-
needs = hash[task_name]
|
1730
|
+
if args.size == 1 && args.first.respond_to?(:to_ary)
|
1731
|
+
arg_names = args.first.to_ary
|
1732
|
+
else
|
1733
|
+
arg_names = args
|
1706
1734
|
end
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1735
|
+
[task_name, arg_names, []]
|
1736
|
+
end
|
1737
|
+
private :resolve_args_without_dependencies
|
1738
|
+
|
1739
|
+
# Resolve task arguments for a task or rule when there are
|
1740
|
+
# dependencies declared.
|
1741
|
+
#
|
1742
|
+
# The patterns recognized by this argument resolving function are:
|
1743
|
+
#
|
1744
|
+
# task :t => [:d]
|
1745
|
+
# task :t, [a] => [:d]
|
1746
|
+
# task :t, :needs => [:d] (deprecated)
|
1747
|
+
# task :t, :a, :needs => [:d] (deprecated)
|
1748
|
+
#
|
1749
|
+
def resolve_args_with_dependencies(args, hash) # :nodoc:
|
1750
|
+
fail "Task Argument Error" if hash.size != 1
|
1751
|
+
key, value = hash.map { |k, v| [k,v] }.first
|
1752
|
+
if args.empty?
|
1753
|
+
task_name = key
|
1754
|
+
arg_names = []
|
1755
|
+
deps = value
|
1756
|
+
elsif key == :needs
|
1757
|
+
task_name = args.shift
|
1758
|
+
arg_names = args
|
1759
|
+
deps = value
|
1760
|
+
else
|
1761
|
+
task_name = args.shift
|
1762
|
+
arg_names = key
|
1763
|
+
deps = value
|
1711
1764
|
end
|
1712
|
-
|
1713
|
-
[task_name, arg_names,
|
1765
|
+
deps = [deps] unless deps.respond_to?(:to_ary)
|
1766
|
+
[task_name, arg_names, deps]
|
1714
1767
|
end
|
1715
|
-
|
1768
|
+
private :resolve_args_with_dependencies
|
1769
|
+
|
1716
1770
|
# If a rule can be found that matches the task name, enhance the
|
1717
1771
|
# task with the prerequisites and actions from the rule. Set the
|
1718
1772
|
# source attribute of the task appropriately for the rule. Return
|
@@ -2092,16 +2146,10 @@ module Rake
|
|
2092
2146
|
end
|
2093
2147
|
end
|
2094
2148
|
|
2095
|
-
#
|
2096
|
-
#
|
2097
|
-
def
|
2098
|
-
|
2099
|
-
end
|
2100
|
-
|
2101
|
-
# Read and handle the command line options.
|
2102
|
-
def handle_options
|
2103
|
-
# optparse version of OPTIONS
|
2104
|
-
op_options = [
|
2149
|
+
# A list of all the standard options used in rake, suitable for
|
2150
|
+
# passing to OptionParser.
|
2151
|
+
def standard_rake_options
|
2152
|
+
[
|
2105
2153
|
['--classic-namespace', '-C', "Put Task and FileTask in the top level namespace",
|
2106
2154
|
lambda { |value|
|
2107
2155
|
require 'rake/classic_namespace'
|
@@ -2135,22 +2183,13 @@ module Rake
|
|
2135
2183
|
exit
|
2136
2184
|
}
|
2137
2185
|
],
|
2138
|
-
['--execute-continue', '-E',
|
2186
|
+
['--execute-continue', '-E CODE',
|
2139
2187
|
"Execute some Ruby code, then continue with normal task processing.",
|
2140
2188
|
lambda { |value| eval(value) }
|
2141
2189
|
],
|
2142
2190
|
['--libdir', '-I LIBDIR', "Include LIBDIR in the search path for required modules.",
|
2143
2191
|
lambda { |value| $:.push(value) }
|
2144
2192
|
],
|
2145
|
-
['--system', '-G', "Run tasks using system wide (global) rakefiles (usually '~/.rake/*.rake'). Project Rakefiles are ignored.",
|
2146
|
-
lambda { |value| options.load_system = true }
|
2147
|
-
],
|
2148
|
-
['--no-system', '-g', "Run tasks using standard project Rakefile search paths, ignoring system wide rakefiles.",
|
2149
|
-
lambda { |value| options.ignore_system = true }
|
2150
|
-
],
|
2151
|
-
['--nosearch', '-N', "Do not search parent directories for the Rakefile.",
|
2152
|
-
lambda { |value| options.nosearch = true }
|
2153
|
-
],
|
2154
2193
|
['--prereqs', '-P', "Display the tasks and dependencies, then exit.",
|
2155
2194
|
lambda { |value| options.show_prereqs = true }
|
2156
2195
|
],
|
@@ -2184,6 +2223,9 @@ module Rake
|
|
2184
2223
|
['--rules', "Trace the rules resolution.",
|
2185
2224
|
lambda { |value| options.trace_rules = true }
|
2186
2225
|
],
|
2226
|
+
['--no-search', '--nosearch', '-N', "Do not search parent directories for the Rakefile.",
|
2227
|
+
lambda { |value| options.nosearch = true }
|
2228
|
+
],
|
2187
2229
|
['--silent', '-s', "Like --quiet, but also suppresses the 'in directory' announcement.",
|
2188
2230
|
lambda { |value|
|
2189
2231
|
verbose(false)
|
@@ -2194,7 +2236,7 @@ module Rake
|
|
2194
2236
|
"Using system wide (global) rakefiles (usually '~/.rake/*.rake').",
|
2195
2237
|
lambda { |value| options.load_system = true }
|
2196
2238
|
],
|
2197
|
-
['--no-system',
|
2239
|
+
['--no-system', '--nosystem', '-G',
|
2198
2240
|
"Use standard project Rakefile search paths, ignore system wide rakefiles.",
|
2199
2241
|
lambda { |value| options.ignore_system = true }
|
2200
2242
|
],
|
@@ -2219,25 +2261,26 @@ module Rake
|
|
2219
2261
|
puts "rake, version #{RAKEVERSION}"
|
2220
2262
|
exit
|
2221
2263
|
}
|
2222
|
-
]
|
2264
|
+
]
|
2223
2265
|
]
|
2266
|
+
end
|
2224
2267
|
|
2268
|
+
# Read and handle the command line options.
|
2269
|
+
def handle_options
|
2225
2270
|
options.rakelib = ['rakelib']
|
2226
2271
|
|
2227
|
-
|
2228
|
-
opts =
|
2229
|
-
|
2230
|
-
|
2231
|
-
|
2232
|
-
|
2233
|
-
|
2234
|
-
|
2235
|
-
exit
|
2236
|
-
end
|
2237
|
-
|
2238
|
-
op_options.each { |args| opts.on(*args) }
|
2239
|
-
parsed_argv = opts.parse(ARGV)
|
2272
|
+
opts = OptionParser.new
|
2273
|
+
opts.banner = "rake [-f rakefile] {options} targets..."
|
2274
|
+
opts.separator ""
|
2275
|
+
opts.separator "Options are ..."
|
2276
|
+
|
2277
|
+
opts.on_tail("-h", "--help", "-H", "Display this help message.") do
|
2278
|
+
puts opts
|
2279
|
+
exit
|
2240
2280
|
end
|
2281
|
+
|
2282
|
+
standard_rake_options.each { |args| opts.on(*args) }
|
2283
|
+
parsed_argv = opts.parse(ARGV)
|
2241
2284
|
|
2242
2285
|
# If class namespaces are requested, set the global options
|
2243
2286
|
# according to the values in the options structure.
|
@@ -2248,9 +2291,7 @@ module Rake
|
|
2248
2291
|
$dryrun = options.dryrun
|
2249
2292
|
$silent = options.silent
|
2250
2293
|
end
|
2251
|
-
|
2252
|
-
rescue NoMethodError => ex
|
2253
|
-
raise OptionParser::InvalidOption, "While parsing options, error = #{ex.class}:#{ex.message}"
|
2294
|
+
parsed_argv
|
2254
2295
|
end
|
2255
2296
|
|
2256
2297
|
# Similar to the regular Ruby +require+ command, but will check
|
@@ -2287,7 +2328,7 @@ module Rake
|
|
2287
2328
|
rakefile, location = find_rakefile_location
|
2288
2329
|
if (! options.ignore_system) &&
|
2289
2330
|
(options.load_system || rakefile.nil?) &&
|
2290
|
-
|
2331
|
+
directory?(system_dir)
|
2291
2332
|
puts "(in #{Dir.pwd})" unless options.silent
|
2292
2333
|
Dir["#{system_dir}/*.rake"].each do |name|
|
2293
2334
|
add_import name
|
@@ -2298,7 +2339,7 @@ module Rake
|
|
2298
2339
|
@rakefile = rakefile
|
2299
2340
|
Dir.chdir(location)
|
2300
2341
|
puts "(in #{Dir.pwd})" unless options.silent
|
2301
|
-
$rakefile = @rakefile
|
2342
|
+
$rakefile = @rakefile if options.classic_namespace
|
2302
2343
|
load File.expand_path(@rakefile) if @rakefile && @rakefile != ''
|
2303
2344
|
end
|
2304
2345
|
options.rakelib.each do |rlib|
|
@@ -2327,14 +2368,20 @@ module Rake
|
|
2327
2368
|
# The standard directory containing system wide rake files on Win
|
2328
2369
|
# 32 systems.
|
2329
2370
|
def win32_system_dir #:nodoc:
|
2330
|
-
|
2331
|
-
|
2371
|
+
win32home = File.join(ENV['APPDATA'], 'Rake')
|
2372
|
+
unless directory?(win32home)
|
2373
|
+
raise Win32HomeError, "Unable to determine home path environment variable."
|
2332
2374
|
else
|
2333
2375
|
win32home
|
2334
2376
|
end
|
2335
2377
|
end
|
2336
2378
|
private :win32_system_dir
|
2337
2379
|
|
2380
|
+
def directory?(path)
|
2381
|
+
File.directory?(path)
|
2382
|
+
end
|
2383
|
+
private :directory?
|
2384
|
+
|
2338
2385
|
# Collect the list of tasks on the command line. If no tasks are
|
2339
2386
|
# given, return a list containing only the default task.
|
2340
2387
|
# Environmental assignments are processed at this time as well.
|
File without changes
|
@@ -1,3 +1,5 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
1
3
|
N = 2
|
2
4
|
|
3
5
|
task :default => :run
|
@@ -17,7 +19,7 @@ FileList['src/*'].each do |src|
|
|
17
19
|
target = File.join TARGET_DIR, File.basename(src)
|
18
20
|
file target => [src, TARGET_DIR] do
|
19
21
|
cp src, target
|
20
|
-
sleep 3 if src !~ /foo#{N-1}$/
|
22
|
+
# sleep 3 if src !~ /foo#{N-1}$/ # I'm commenting out this sleep, it doesn't seem to do anything.
|
21
23
|
end
|
22
24
|
task :run => target
|
23
25
|
end
|
@@ -25,6 +27,7 @@ end
|
|
25
27
|
task :prep => :clean do
|
26
28
|
mkdir_p 'src'
|
27
29
|
N.times do |n|
|
30
|
+
puts "DBG: Touching src/foo#{n}"
|
28
31
|
touch "src/foo#{n}"
|
29
32
|
end
|
30
33
|
end
|
data/test/in_environment.rb
CHANGED
data/test/session_functional.rb
CHANGED
@@ -29,8 +29,6 @@ class FunctionalTest < Test::Unit::TestCase
|
|
29
29
|
|
30
30
|
def setup
|
31
31
|
@rake_path = File.expand_path("bin/rake")
|
32
|
-
@coverage_aggregate_file = File.expand_path("rcov_aggregate")
|
33
|
-
@rcov_dir = File.expand_path("coverage")
|
34
32
|
lib_path = File.expand_path("lib")
|
35
33
|
@ruby_options = "-I#{lib_path} -I."
|
36
34
|
@verbose = ! ENV['VERBOSE'].nil?
|
@@ -306,10 +304,6 @@ class FunctionalTest < Test::Unit::TestCase
|
|
306
304
|
end
|
307
305
|
|
308
306
|
def rake(*option_list)
|
309
|
-
# self.class.format_command = lambda { |ruby_options, rake_path, options|
|
310
|
-
# "rcov --output=#{@rcov_dir} --aggregate=#{@coverage_aggregate_file} #{ruby_options} #{rake_path} -- #{options}"
|
311
|
-
# }
|
312
|
-
|
313
307
|
options = option_list.join(' ')
|
314
308
|
shell = Session::Shell.new
|
315
309
|
command = self.class.format_command[@ruby_options, @rake_path, options]
|
data/test/test_application.rb
CHANGED
@@ -169,6 +169,66 @@ class TestApplication < Test::Unit::TestCase
|
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
172
|
+
def test_load_from_system_rakefile_on_unix
|
173
|
+
flexmock(@app, :windows? => false,
|
174
|
+
:win32_system_dir => nil,
|
175
|
+
:load => nil)
|
176
|
+
flexmock(File).should_receive(:expand_path).with("~").and_return("/HOME")
|
177
|
+
flexmock(File).should_receive(:expand_path).and_return { |fn| fn }
|
178
|
+
|
179
|
+
in_environment('RAKE_SYSTEM' => nil) do
|
180
|
+
@app.options.rakelib = []
|
181
|
+
@app.instance_eval do
|
182
|
+
handle_options
|
183
|
+
options.silent = true
|
184
|
+
options.load_system = true
|
185
|
+
load_rakefile
|
186
|
+
end
|
187
|
+
assert_equal "/HOME/.rake", @app.system_dir
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
def test_windows
|
192
|
+
assert ! (@app.windows? && @app.unix?)
|
193
|
+
end
|
194
|
+
|
195
|
+
def test_load_from_system_rakefile_on_windows
|
196
|
+
flexmock(@app, :windows? => true,
|
197
|
+
:standard_system_dir => "XX")
|
198
|
+
flexmock(@app).should_receive(:directory?).with("/AD/Rake").and_return(true)
|
199
|
+
flexmock(@app).should_receive(:load).and_return { |fn| puts "LOADING #{fn}" }
|
200
|
+
in_environment('RAKE_SYSTEM' => nil, 'APPDATA' => '/AD') do
|
201
|
+
@app.options.rakelib = []
|
202
|
+
@app.instance_eval do
|
203
|
+
handle_options
|
204
|
+
options.silent = true
|
205
|
+
options.load_system = true
|
206
|
+
load_rakefile
|
207
|
+
end
|
208
|
+
assert_equal "/AD/Rake", @app.system_dir
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
def test_load_from_system_rakefile_on_windows_with_no_appdata
|
213
|
+
flexmock(@app, :windows? => true,
|
214
|
+
:standard_system_dir => "XX"
|
215
|
+
)
|
216
|
+
flexmock(File).should_receive(:exists?).with("/AD/Rake").and_return(false)
|
217
|
+
out = capture_stderr do
|
218
|
+
assert_raise(SystemExit) do
|
219
|
+
in_environment('RAKE_SYSTEM' => nil, 'APPDATA' => "/AD") do
|
220
|
+
@app.options.rakelib = []
|
221
|
+
@app.instance_eval do
|
222
|
+
handle_options
|
223
|
+
options.silent = true
|
224
|
+
options.load_system = true
|
225
|
+
load_rakefile
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
172
232
|
def test_loading_imports
|
173
233
|
mock = flexmock("loader")
|
174
234
|
mock.should_receive(:load).with("x.dummy").once
|
@@ -199,7 +259,9 @@ class TestApplication < Test::Unit::TestCase
|
|
199
259
|
@app.instance_eval do
|
200
260
|
intern(Rake::Task, "default").enhance { ran = true }
|
201
261
|
end
|
202
|
-
|
262
|
+
in_environment("PWD" => "test/data/default") do
|
263
|
+
@app.run
|
264
|
+
end
|
203
265
|
assert ran
|
204
266
|
end
|
205
267
|
|
@@ -295,54 +357,73 @@ class TestApplicationOptions < Test::Unit::TestCase
|
|
295
357
|
|
296
358
|
def test_default_options
|
297
359
|
opts = command_line
|
298
|
-
assert_nil opts.
|
360
|
+
assert_nil opts.classic_namespace
|
299
361
|
assert_nil opts.dryrun
|
300
|
-
assert_nil opts.
|
362
|
+
assert_nil opts.full_description
|
363
|
+
assert_nil opts.ignore_system
|
364
|
+
assert_nil opts.load_system
|
301
365
|
assert_nil opts.nosearch
|
302
|
-
|
366
|
+
assert_equal ['rakelib'], opts.rakelib
|
303
367
|
assert_nil opts.show_prereqs
|
368
|
+
assert_nil opts.show_task_pattern
|
304
369
|
assert_nil opts.show_tasks
|
305
|
-
assert_nil opts.
|
370
|
+
assert_nil opts.silent
|
371
|
+
assert_nil opts.trace
|
306
372
|
assert_equal ['rakelib'], opts.rakelib
|
307
373
|
assert ! RakeFileUtils.verbose_flag
|
308
374
|
assert ! RakeFileUtils.nowrite_flag
|
309
375
|
end
|
310
376
|
|
311
|
-
def
|
312
|
-
|
313
|
-
|
314
|
-
flags('--bad', '-t') do |opts|
|
315
|
-
end
|
316
|
-
end
|
317
|
-
end
|
318
|
-
end
|
319
|
-
|
320
|
-
def test_trace_option
|
321
|
-
flags('--trace', '-t') do |opts|
|
377
|
+
def test_dry_run
|
378
|
+
flags('--dry-run', '-n') do |opts|
|
379
|
+
assert opts.dryrun
|
322
380
|
assert opts.trace
|
323
381
|
assert RakeFileUtils.verbose_flag
|
324
|
-
assert
|
382
|
+
assert RakeFileUtils.nowrite_flag
|
325
383
|
end
|
326
384
|
end
|
327
385
|
|
328
|
-
def
|
329
|
-
flags('--
|
330
|
-
assert opts.
|
386
|
+
def test_describe
|
387
|
+
flags('--describe') do |opts|
|
388
|
+
assert opts.full_description
|
389
|
+
assert opts.show_tasks
|
390
|
+
assert_equal(//.to_s, opts.show_task_pattern.to_s)
|
331
391
|
end
|
332
392
|
end
|
333
393
|
|
334
|
-
def
|
335
|
-
flags('--
|
336
|
-
assert opts.
|
394
|
+
def test_describe_with_pattern
|
395
|
+
flags('--describe=X') do |opts|
|
396
|
+
assert opts.full_description
|
397
|
+
assert opts.show_tasks
|
398
|
+
assert_equal(/X/.to_s, opts.show_task_pattern.to_s)
|
337
399
|
end
|
338
400
|
end
|
339
401
|
|
340
|
-
def
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
402
|
+
def test_execute
|
403
|
+
$xyzzy = 0
|
404
|
+
flags('--execute=$xyzzy=1', '-e $xyzzy=1') do |opts|
|
405
|
+
assert_equal 1, $xyzzy
|
406
|
+
assert_equal :exit, @exit
|
407
|
+
$xyzzy = 0
|
408
|
+
end
|
409
|
+
end
|
410
|
+
|
411
|
+
def test_execute_and_continue
|
412
|
+
$xyzzy = 0
|
413
|
+
flags('--execute-continue=$xyzzy=1', '-E $xyzzy=1') do |opts|
|
414
|
+
assert_equal 1, $xyzzy
|
415
|
+
assert_not_equal :exit, @exit
|
416
|
+
$xyzzy = 0
|
417
|
+
end
|
418
|
+
end
|
419
|
+
|
420
|
+
def test_execute_and_print
|
421
|
+
$xyzzy = 0
|
422
|
+
flags('--execute-print=$xyzzy="pugh"', '-p $xyzzy="pugh"') do |opts|
|
423
|
+
assert_equal 'pugh', $xyzzy
|
424
|
+
assert_equal :exit, @exit
|
425
|
+
assert_match(/^pugh$/, @out)
|
426
|
+
$xyzzy = 0
|
346
427
|
end
|
347
428
|
end
|
348
429
|
|
@@ -356,14 +437,6 @@ class TestApplicationOptions < Test::Unit::TestCase
|
|
356
437
|
end
|
357
438
|
end
|
358
439
|
|
359
|
-
def test_describe
|
360
|
-
flags('--describe') do |opts|
|
361
|
-
assert opts.full_description
|
362
|
-
assert opts.show_tasks
|
363
|
-
assert_equal(//.to_s, opts.show_task_pattern.to_s)
|
364
|
-
end
|
365
|
-
end
|
366
|
-
|
367
440
|
def test_libdir
|
368
441
|
flags(['--libdir', 'xx'], ['-I', 'xx'], ['-Ixx']) do |opts|
|
369
442
|
$:.include?('xx')
|
@@ -372,13 +445,37 @@ class TestApplicationOptions < Test::Unit::TestCase
|
|
372
445
|
$:.delete('xx')
|
373
446
|
end
|
374
447
|
|
375
|
-
def
|
376
|
-
flags('--
|
377
|
-
|
448
|
+
def test_rakefile
|
449
|
+
flags(['--rakefile', 'RF'], ['--rakefile=RF'], ['-f', 'RF'], ['-fRF']) do |opts|
|
450
|
+
assert_equal ['RF'], @app.instance_eval { @rakefiles }
|
451
|
+
end
|
452
|
+
end
|
453
|
+
|
454
|
+
def test_rakelib
|
455
|
+
flags(['--rakelibdir', 'A:B:C'], ['--rakelibdir=A:B:C'], ['-R', 'A:B:C'], ['-RA:B:C']) do |opts|
|
456
|
+
assert_equal ['A', 'B', 'C'], opts.rakelib
|
457
|
+
end
|
458
|
+
end
|
459
|
+
|
460
|
+
def test_require
|
461
|
+
flags(['--require', 'test/reqfile'], '-rtest/reqfile2', '-rtest/reqfile3') do |opts|
|
462
|
+
end
|
463
|
+
assert TESTING_REQUIRE.include?(1)
|
464
|
+
assert TESTING_REQUIRE.include?(2)
|
465
|
+
assert TESTING_REQUIRE.include?(3)
|
466
|
+
assert_equal 3, TESTING_REQUIRE.size
|
467
|
+
end
|
468
|
+
|
469
|
+
def test_missing_require
|
470
|
+
ex = assert_raises(LoadError) do
|
471
|
+
flags(['--require', 'test/missing']) do |opts|
|
472
|
+
end
|
378
473
|
end
|
474
|
+
assert_match(/no such file/, ex.message)
|
475
|
+
assert_match(/test\/missing/, ex.message)
|
379
476
|
end
|
380
477
|
|
381
|
-
def
|
478
|
+
def test_prereqs
|
382
479
|
flags('--prereqs', '-P') do |opts|
|
383
480
|
assert opts.show_prereqs
|
384
481
|
end
|
@@ -391,6 +488,12 @@ class TestApplicationOptions < Test::Unit::TestCase
|
|
391
488
|
end
|
392
489
|
end
|
393
490
|
|
491
|
+
def test_no_search
|
492
|
+
flags('--nosearch', '--no-search', '-N') do |opts|
|
493
|
+
assert opts.nosearch
|
494
|
+
end
|
495
|
+
end
|
496
|
+
|
394
497
|
def test_silent
|
395
498
|
flags('--silent', '-s') do |opts|
|
396
499
|
assert ! RakeFileUtils.verbose_flag
|
@@ -398,34 +501,30 @@ class TestApplicationOptions < Test::Unit::TestCase
|
|
398
501
|
end
|
399
502
|
end
|
400
503
|
|
401
|
-
def
|
402
|
-
flags(
|
403
|
-
|
504
|
+
def test_system
|
505
|
+
flags('--system', '-g') do |opts|
|
506
|
+
assert opts.load_system
|
404
507
|
end
|
405
508
|
end
|
406
509
|
|
407
|
-
def
|
408
|
-
flags(
|
409
|
-
|
510
|
+
def test_no_system
|
511
|
+
flags('--no-system', '-G') do |opts|
|
512
|
+
assert opts.ignore_system
|
410
513
|
end
|
411
514
|
end
|
412
515
|
|
413
|
-
def
|
414
|
-
flags(
|
516
|
+
def test_trace
|
517
|
+
flags('--trace', '-t') do |opts|
|
518
|
+
assert opts.trace
|
519
|
+
assert RakeFileUtils.verbose_flag
|
520
|
+
assert ! RakeFileUtils.nowrite_flag
|
415
521
|
end
|
416
|
-
assert TESTING_REQUIRE.include?(1)
|
417
|
-
assert TESTING_REQUIRE.include?(2)
|
418
|
-
assert TESTING_REQUIRE.include?(3)
|
419
|
-
assert_equal 3, TESTING_REQUIRE.size
|
420
522
|
end
|
421
523
|
|
422
|
-
def
|
423
|
-
|
424
|
-
|
425
|
-
end
|
524
|
+
def test_trace_rules
|
525
|
+
flags('--rules') do |opts|
|
526
|
+
assert opts.trace_rules
|
426
527
|
end
|
427
|
-
assert_match(/no such file/, ex.message)
|
428
|
-
assert_match(/test\/missing/, ex.message)
|
429
528
|
end
|
430
529
|
|
431
530
|
def test_tasks
|
@@ -500,6 +599,7 @@ class TestApplicationOptions < Test::Unit::TestCase
|
|
500
599
|
|
501
600
|
def flags(*sets)
|
502
601
|
sets.each do |set|
|
602
|
+
ARGV.clear
|
503
603
|
@out = capture_stdout {
|
504
604
|
@exit = catch(:system_exit) { opts = command_line(*set) }
|
505
605
|
}
|
@@ -563,3 +663,52 @@ class TestTaskArgumentParsing < Test::Unit::TestCase
|
|
563
663
|
end
|
564
664
|
|
565
665
|
end
|
666
|
+
|
667
|
+
class TestTaskArgumentParsing < Test::Unit::TestCase
|
668
|
+
include InEnvironment
|
669
|
+
|
670
|
+
def test_terminal_width_using_env
|
671
|
+
app = Rake::Application.new
|
672
|
+
in_environment('RAKE_COLUMNS' => '1234') do
|
673
|
+
assert_equal 1234, app.terminal_width
|
674
|
+
end
|
675
|
+
end
|
676
|
+
|
677
|
+
def test_terminal_width_using_stty
|
678
|
+
app = Rake::Application.new
|
679
|
+
flexmock(app,
|
680
|
+
:unix? => true,
|
681
|
+
:dynamic_width_stty => 1235,
|
682
|
+
:dynamic_width_tput => 0)
|
683
|
+
in_environment('RAKE_COLUMNS' => nil) do
|
684
|
+
assert_equal 1235, app.terminal_width
|
685
|
+
end
|
686
|
+
end
|
687
|
+
|
688
|
+
def test_terminal_width_using_tput
|
689
|
+
app = Rake::Application.new
|
690
|
+
flexmock(app,
|
691
|
+
:unix? => true,
|
692
|
+
:dynamic_width_stty => 0,
|
693
|
+
:dynamic_width_tput => 1236)
|
694
|
+
in_environment('RAKE_COLUMNS' => nil) do
|
695
|
+
assert_equal 1236, app.terminal_width
|
696
|
+
end
|
697
|
+
end
|
698
|
+
|
699
|
+
def test_terminal_width_using_hardcoded_80
|
700
|
+
app = Rake::Application.new
|
701
|
+
flexmock(app, :unix? => false)
|
702
|
+
in_environment('RAKE_COLUMNS' => nil) do
|
703
|
+
assert_equal 80, app.terminal_width
|
704
|
+
end
|
705
|
+
end
|
706
|
+
|
707
|
+
def test_terminal_width_with_failure
|
708
|
+
app = Rake::Application.new
|
709
|
+
flexmock(app).should_receive(:unix?).and_throw(RuntimeError)
|
710
|
+
in_environment('RAKE_COLUMNS' => nil) do
|
711
|
+
assert_equal 80, app.terminal_width
|
712
|
+
end
|
713
|
+
end
|
714
|
+
end
|
data/test/test_task_manager.rb
CHANGED
@@ -53,7 +53,7 @@ class TestTaskManager < Test::Unit::TestCase
|
|
53
53
|
assert_equal ["fn"], @tm.tasks.collect { |t| t.name }
|
54
54
|
end
|
55
55
|
|
56
|
-
def
|
56
|
+
def test_namespace_yields_same_namespace_as_returned
|
57
57
|
yielded_namespace = nil
|
58
58
|
returned_namespace = @tm.in_namespace("x") do |ns|
|
59
59
|
yielded_namespace = ns
|
@@ -146,3 +146,25 @@ class TestTaskManager < Test::Unit::TestCase
|
|
146
146
|
end
|
147
147
|
|
148
148
|
end
|
149
|
+
|
150
|
+
class TestTaskManagerArgumentResolution < Test::Unit::TestCase
|
151
|
+
def test_good_arg_patterns
|
152
|
+
assert_equal [:t, [], []], task(:t)
|
153
|
+
assert_equal [:t, [], [:x]], task(:t => :x)
|
154
|
+
assert_equal [:t, [], [:x, :y]], task(:t => [:x, :y])
|
155
|
+
|
156
|
+
assert_equal [:t, [:a, :b], []], task(:t, :a, :b)
|
157
|
+
assert_equal [:t, [], [:x]], task(:t, :needs => :x)
|
158
|
+
assert_equal [:t, [:a, :b], [:x]], task(:t, :a, :b, :needs => :x)
|
159
|
+
assert_equal [:t, [:a, :b], [:x, :y]], task(:t, :a, :b, :needs => [:x, :y])
|
160
|
+
|
161
|
+
assert_equal [:t, [:a, :b], []], task(:t, [:a, :b])
|
162
|
+
assert_equal [:t, [:a, :b], [:x]], task(:t, [:a, :b] => :x)
|
163
|
+
assert_equal [:t, [:a, :b], [:x, :y]], task(:t, [:a, :b] => [:x, :y])
|
164
|
+
end
|
165
|
+
|
166
|
+
def task(*args)
|
167
|
+
tm = TaskManager.new
|
168
|
+
tm.resolve_args(args)
|
169
|
+
end
|
170
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jimweirich-rake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.1.
|
4
|
+
version: 0.8.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Weirich
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-08-
|
12
|
+
date: 2008-08-31 21:00:00 -07:00
|
13
13
|
default_executable: rake
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -68,7 +68,7 @@ files:
|
|
68
68
|
- lib/rake/testtask.rb
|
69
69
|
- lib/rake.rb
|
70
70
|
- test/capture_stdout.rb
|
71
|
-
- test/contrib/
|
71
|
+
- test/contrib/test_sys.rb
|
72
72
|
- test/data/rakelib/test1.rb
|
73
73
|
- test/data/rbext/rakefile.rb
|
74
74
|
- test/filecreation.rb
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- test/test_rules.rb
|
101
101
|
- test/test_task_arguments.rb
|
102
102
|
- test/test_task_manager.rb
|
103
|
+
- test/test_tasklib.rb
|
103
104
|
- test/test_tasks.rb
|
104
105
|
- test/test_test_task.rb
|
105
106
|
- test/test_top_level_functions.rb
|