rake 0.9.0.beta.1 → 0.9.0.beta.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rake might be problematic. Click here for more details.
- data/CHANGES +8 -0
- data/Rakefile +3 -6
- data/doc/rakefile.rdoc +12 -7
- data/lib/rake/application.rb +17 -13
- data/lib/rake/dsl_definition.rb +25 -21
- data/lib/rake/environment.rb +6 -6
- data/lib/rake/task_manager.rb +4 -0
- data/lib/rake/version.rb +1 -1
- data/test/data/access/Rakefile +33 -0
- data/test/data/deprecated_import/Rakefile +1 -0
- data/test/functional/session_based_tests.rb +23 -0
- data/test/in_environment.rb +1 -1
- data/test/lib/environment_test.rb +17 -5
- data/test/lib/task_manager_test.rb +10 -0
- data/test/lib/task_test.rb +15 -17
- data/test/lib/top_level_functions_test.rb +3 -1
- data/test/rake_test_setup.rb +1 -0
- data/test/test_helper.rb +7 -0
- metadata +4 -2
data/CHANGES
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
== Pre-Version 0.9.x
|
4
4
|
|
5
|
+
* Rake now warns when the deprecated :needs syntax used.
|
6
|
+
|
7
|
+
* Moved Rake DSL commands to top level ruby object 'main'. Rake DSL
|
8
|
+
commands are no longer private methods in Object. (Suggested by
|
9
|
+
James M. Lawrence/quix)
|
10
|
+
|
11
|
+
* Deprecated 'import'. Use 'Rake.import' instead.
|
12
|
+
|
5
13
|
* Rake history is now UTF-8 encoded.
|
6
14
|
|
7
15
|
* Rake now uses case-insensitive comparisons to find the Rakefile on Windows.
|
data/Rakefile
CHANGED
@@ -328,8 +328,7 @@ task :noop
|
|
328
328
|
#plugin "release_manager"
|
329
329
|
|
330
330
|
desc "Make a new release"
|
331
|
-
task :release, :rel, :reuse, :reltest
|
332
|
-
:needs => [
|
331
|
+
task :release, [:rel, :reuse, :reltest] => [
|
333
332
|
:prerelease,
|
334
333
|
:clobber,
|
335
334
|
"test:all",
|
@@ -379,8 +378,7 @@ task :prerelease, :rel, :reuse, :reltest do |t, args|
|
|
379
378
|
end
|
380
379
|
end
|
381
380
|
|
382
|
-
task :update_version, :rel, :reuse, :reltest,
|
383
|
-
:needs => [:prerelease] do |t, args|
|
381
|
+
task :update_version, [:rel, :reuse, :reltest] => [:prerelease] do |t, args|
|
384
382
|
if args.rel == CURRENT_VERSION
|
385
383
|
announce "No version change ... skipping version update"
|
386
384
|
else
|
@@ -406,8 +404,7 @@ task :update_version, :rel, :reuse, :reltest,
|
|
406
404
|
end
|
407
405
|
|
408
406
|
desc "Tag all the CVS files with the latest release number (REL=x.y.z)"
|
409
|
-
task :tag, :rel, :reuse, :reltest,
|
410
|
-
:needs => [:prerelease] do |t, args|
|
407
|
+
task :tag, [:rel, :reuse, :reltest] => [:prerelease] do |t, args|
|
411
408
|
reltag = "REL_#{args.rel.gsub(/\./, '_')}"
|
412
409
|
reltag << args.reuse.gsub(/\./, '_') if args.reuse
|
413
410
|
announce "Tagging Repository with [#{reltag}]"
|
data/doc/rakefile.rdoc
CHANGED
@@ -358,12 +358,17 @@ invoked. This make generated dependency files difficult to use. By
|
|
358
358
|
the time rake gets around to updating the dependencies file, it is too
|
359
359
|
late to load it.
|
360
360
|
|
361
|
-
The +import+ command addresses this by specifying a file to be
|
362
|
-
_after_ the main rakefile is loaded, but _before_ any targets
|
363
|
-
command line are
|
364
|
-
explicit task, that task is invoked before loading the
|
365
|
-
allows dependency files to be generated and used in a
|
366
|
-
command invocation.
|
361
|
+
The +Rake.import+ command addresses this by specifying a file to be
|
362
|
+
loaded _after_ the main rakefile is loaded, but _before_ any targets
|
363
|
+
on the command line are invoked. In addition, if the file name
|
364
|
+
matches an explicit task, that task is invoked before loading the
|
365
|
+
file. This allows dependency files to be generated and used in a
|
366
|
+
single rake command invocation.
|
367
|
+
|
368
|
+
<b>NOTE:</b> Starting in Rake version 0.9.0, the top level +import+
|
369
|
+
command is deprecated and we recommend using the scoped
|
370
|
+
"+Rake.import+" command mentioned above. Future versions of Rake will
|
371
|
+
drop support for the top level +import+ command.
|
367
372
|
|
368
373
|
=== Example:
|
369
374
|
|
@@ -373,7 +378,7 @@ command invocation.
|
|
373
378
|
sh "makedepend -f- -- #{CFLAGS} -- #{t.prerequisites} > #{t.name}"
|
374
379
|
end
|
375
380
|
|
376
|
-
import ".depends.mf"
|
381
|
+
Rake.import ".depends.mf"
|
377
382
|
|
378
383
|
If ".depends" does not exist, or is out of date w.r.t. the source
|
379
384
|
files, a new ".depends" file is generated using +makedepend+ before
|
data/lib/rake/application.rb
CHANGED
@@ -153,6 +153,18 @@ module Rake
|
|
153
153
|
$stderr.puts "(See full trace by running task with --trace)" unless options.trace
|
154
154
|
end
|
155
155
|
|
156
|
+
# Warn about deprecated usage.
|
157
|
+
#
|
158
|
+
# Example:
|
159
|
+
# Rake.application.deprecate("import", "Rake.import", caller.first)
|
160
|
+
#
|
161
|
+
def deprecate(old_usage, new_usage, call_site)
|
162
|
+
return if options.ignore_deprecate
|
163
|
+
$stderr.puts "WARNING: '#{old_usage}' is deprecated. " +
|
164
|
+
"Please use '#{new_usage}' instead.\n" +
|
165
|
+
" at #{call_site}"
|
166
|
+
end
|
167
|
+
|
156
168
|
# Does the exception have a task invocation chain?
|
157
169
|
def has_chain?(exception)
|
158
170
|
exception.respond_to?(:chain) && exception.chain
|
@@ -370,16 +382,6 @@ module Rake
|
|
370
382
|
Rake::TaskManager.record_task_metadata = true
|
371
383
|
}
|
372
384
|
],
|
373
|
-
['--no-top-level-dsl', '-X', "Do not put Rake DSL commands in the top level scope.",
|
374
|
-
lambda { |value|
|
375
|
-
options.top_level_dsl = ! value
|
376
|
-
}
|
377
|
-
],
|
378
|
-
['--top-level-dsl', "Put Rake DSL commands in the top level scope (default).",
|
379
|
-
lambda { |value|
|
380
|
-
options.top_level_dsl = value
|
381
|
-
}
|
382
|
-
],
|
383
385
|
['--trace', '-t', "Turn on invoke/execute tracing, enable full backtrace.",
|
384
386
|
lambda { |value|
|
385
387
|
options.trace = true
|
@@ -402,13 +404,17 @@ module Rake
|
|
402
404
|
Rake::TaskManager.record_task_metadata = true
|
403
405
|
}
|
404
406
|
],
|
407
|
+
['--no-deprecation-warnings', '-X', "Disable the deprecation warnings.",
|
408
|
+
lambda { |value|
|
409
|
+
options.ignore_deprecate = true
|
410
|
+
}
|
411
|
+
],
|
405
412
|
]
|
406
413
|
end
|
407
414
|
|
408
415
|
# Read and handle the command line options.
|
409
416
|
def handle_options
|
410
417
|
options.rakelib = ['rakelib']
|
411
|
-
options.top_level_dsl = true
|
412
418
|
|
413
419
|
OptionParser.new do |opts|
|
414
420
|
opts.banner = "rake [-f rakefile] {options} targets..."
|
@@ -424,8 +430,6 @@ module Rake
|
|
424
430
|
opts.environment('RAKEOPT')
|
425
431
|
end.parse!
|
426
432
|
|
427
|
-
Rake::DSL.include_in_top_scope if options.top_level_dsl
|
428
|
-
|
429
433
|
# If class namespaces are requested, set the global options
|
430
434
|
# according to the values in the options structure.
|
431
435
|
if options.classic_namespace
|
data/lib/rake/dsl_definition.rb
CHANGED
@@ -116,31 +116,35 @@ module Rake
|
|
116
116
|
Rake.application.last_description = description
|
117
117
|
end
|
118
118
|
|
119
|
-
#
|
120
|
-
#
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
#
|
125
|
-
# A common use of the import statement is to include files
|
126
|
-
# containing dependency declarations.
|
127
|
-
#
|
128
|
-
# See also the --rakelibdir command line option.
|
129
|
-
#
|
130
|
-
# Example:
|
131
|
-
# import ".depend", "my_rules"
|
132
|
-
#
|
133
|
-
def import(*fns)
|
134
|
-
fns.each do |fn|
|
135
|
-
Rake.application.add_import(fn)
|
136
|
-
end
|
119
|
+
# The DSL level import command is now deprecated and moved the
|
120
|
+
# Rake.import.
|
121
|
+
def import(*fn)
|
122
|
+
Rake.application.deprecate("import", "Rake.import", caller.first)
|
123
|
+
Rake.import(*fn)
|
137
124
|
end
|
125
|
+
end
|
138
126
|
|
139
|
-
|
140
|
-
|
141
|
-
|
127
|
+
# Import the partial Rakefiles +fn+. Imported files are loaded
|
128
|
+
# _after_ the current file is completely loaded. This allows the
|
129
|
+
# import statement to appear anywhere in the importing file, and yet
|
130
|
+
# allowing the imported files to depend on objects defined in the
|
131
|
+
# importing file.
|
132
|
+
#
|
133
|
+
# A common use of the import statement is to include files
|
134
|
+
# containing dependency declarations.
|
135
|
+
#
|
136
|
+
# See also the --rakelibdir command line option.
|
137
|
+
#
|
138
|
+
# Example:
|
139
|
+
# import ".depend", "my_rules"
|
140
|
+
#
|
141
|
+
def Rake.import(*fns)
|
142
|
+
fns.each do |fn|
|
143
|
+
Rake.application.add_import(fn)
|
142
144
|
end
|
143
145
|
end
|
144
146
|
|
145
147
|
extend FileUtilsExt
|
146
148
|
end
|
149
|
+
|
150
|
+
self.extend Rake::DSL
|
data/lib/rake/environment.rb
CHANGED
@@ -16,16 +16,16 @@ module Rake
|
|
16
16
|
load_string(rakefile, rakefile_path)
|
17
17
|
end
|
18
18
|
|
19
|
+
# Run a block of code in the Rake DSL environment.
|
20
|
+
def run(&block)
|
21
|
+
block.call
|
22
|
+
end
|
23
|
+
|
19
24
|
# Load a string of code in the Rake DSL environment. If the
|
20
25
|
# string comes from a file, include the file path so that proper
|
21
26
|
# line numbers references may be retained.
|
22
27
|
def load_string(code, file_name=nil)
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
# Run a block of code in the Rake DSL environment.
|
27
|
-
def run(&block)
|
28
|
-
module_eval(&block)
|
28
|
+
eval(code, binding, file_name)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
data/lib/rake/task_manager.rb
CHANGED
@@ -103,6 +103,10 @@ module Rake
|
|
103
103
|
arg_names = []
|
104
104
|
deps = value
|
105
105
|
elsif key == :needs
|
106
|
+
Rake.application.deprecate(
|
107
|
+
"task :t, arg, :needs => [deps]",
|
108
|
+
"task :t, [args] => [deps]",
|
109
|
+
caller.detect { |c| c !~ /\blib\/rake\b/ })
|
106
110
|
task_name = args.shift
|
107
111
|
arg_names = args
|
108
112
|
deps = value
|
data/lib/rake/version.rb
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
TOP_LEVEL_CONSTANT = 0
|
2
|
+
|
3
|
+
def a_top_level_function
|
4
|
+
end
|
5
|
+
|
6
|
+
task :default => [:work, :obj, :const]
|
7
|
+
|
8
|
+
task :work do
|
9
|
+
begin
|
10
|
+
a_top_level_function
|
11
|
+
puts "GOOD:M Top level methods can be called in tasks"
|
12
|
+
rescue NameError => ex
|
13
|
+
puts "BAD:M Top level methods can not be called in tasks"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
task :obj do
|
18
|
+
begin
|
19
|
+
Object.new.instance_eval { task :xyzzy }
|
20
|
+
puts "BAD:D Rake DSL are polluting objects"
|
21
|
+
rescue StandardError => ex
|
22
|
+
puts "GOOD:D Rake DSL are not polluting objects"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
task :const do
|
27
|
+
begin
|
28
|
+
TOP_LEVEL_CONSTANT
|
29
|
+
puts "GOOD:C Top level constants are available in tasks"
|
30
|
+
rescue StandardError => ex
|
31
|
+
puts "BAD:C Top level constants are NOT available in tasks"
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
import "a"
|
@@ -91,6 +91,13 @@ class SessionBasedTests < Test::Unit::TestCase
|
|
91
91
|
assert_no_match %r{^rake c\n}m, @out
|
92
92
|
end
|
93
93
|
|
94
|
+
def test_proper_namespace_access
|
95
|
+
in_environment("PWD" => "test/data/access") do
|
96
|
+
rake
|
97
|
+
end
|
98
|
+
assert_not_match %r{^BAD:}, @out
|
99
|
+
end
|
100
|
+
|
94
101
|
def test_rbext
|
95
102
|
in_environment("PWD" => "test/data/rbext") do
|
96
103
|
rake "-N"
|
@@ -247,6 +254,22 @@ class SessionBasedTests < Test::Unit::TestCase
|
|
247
254
|
assert_status
|
248
255
|
end
|
249
256
|
|
257
|
+
def test_deprecated_import
|
258
|
+
in_environment("PWD" => "test/data/deprecated_import") do
|
259
|
+
rake "imported"
|
260
|
+
end
|
261
|
+
assert_match(/deprecated/, @err)
|
262
|
+
assert_match(/imported!/, @out)
|
263
|
+
end
|
264
|
+
|
265
|
+
def test_suppressed_deprecated_message
|
266
|
+
in_environment("PWD" => "test/data/deprecated_import") do
|
267
|
+
rake "imported -X"
|
268
|
+
end
|
269
|
+
assert_not_match(/deprecated/, @err)
|
270
|
+
assert_match(/imported!/, @out)
|
271
|
+
end
|
272
|
+
|
250
273
|
def test_imports
|
251
274
|
open("test/data/imports/static_deps", "w") do |f|
|
252
275
|
f.puts 'puts "STATIC"'
|
data/test/in_environment.rb
CHANGED
@@ -4,15 +4,27 @@ require 'test/test_helper'
|
|
4
4
|
require 'rake/environment'
|
5
5
|
|
6
6
|
class TestEnvironment < Test::Unit::TestCase
|
7
|
-
def
|
7
|
+
def test_load_rakefile
|
8
8
|
Rake::Task.clear
|
9
|
-
Rake::Environment.
|
10
|
-
assert Rake::Task[:
|
9
|
+
Rake::Environment.load_rakefile("test/data/default/Rakefile")
|
10
|
+
assert Rake::Task[:default], "Should have a default task"
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
13
|
+
def test_run
|
14
14
|
Rake::Task.clear
|
15
|
-
Rake::Environment.
|
15
|
+
Rake::Environment.run do
|
16
|
+
desc "demo comment"
|
17
|
+
task :default
|
18
|
+
end
|
19
|
+
assert Rake::Task[:default], "Should have a default task"
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_environment
|
23
|
+
Rake::Task.clear
|
24
|
+
Rake::DSL.environment do
|
25
|
+
desc "demo comment"
|
26
|
+
task :default
|
27
|
+
end
|
16
28
|
assert Rake::Task[:default], "Should have a default task"
|
17
29
|
end
|
18
30
|
end
|
@@ -151,6 +151,16 @@ class TestTaskManager < Test::Unit::TestCase
|
|
151
151
|
end
|
152
152
|
|
153
153
|
class TestTaskManagerArgumentResolution < Test::Unit::TestCase
|
154
|
+
def setup
|
155
|
+
super
|
156
|
+
Rake.application.options.ignore_deprecate = true
|
157
|
+
end
|
158
|
+
|
159
|
+
def teardown
|
160
|
+
Rake.application.options.ignore_deprecate = false
|
161
|
+
super
|
162
|
+
end
|
163
|
+
|
154
164
|
def test_good_arg_patterns
|
155
165
|
assert_equal [:t, [], []], task(:t)
|
156
166
|
assert_equal [:t, [], [:x]], task(:t => :x)
|
data/test/lib/task_test.rb
CHANGED
@@ -37,7 +37,8 @@ class TestTask < Test::Unit::TestCase
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_inspect
|
40
|
-
t = task(:foo, :needs => [:bar, :baz])
|
40
|
+
# t = task(:foo, :needs => [:bar, :baz])
|
41
|
+
t = task(:foo => [:bar, :baz])
|
41
42
|
assert_equal "<Rake::Task foo => [bar, baz]>", t.inspect
|
42
43
|
end
|
43
44
|
|
@@ -308,23 +309,20 @@ class TestTaskWithArguments < Test::Unit::TestCase
|
|
308
309
|
assert_equal ["pre"], t.prerequisites
|
309
310
|
end
|
310
311
|
|
311
|
-
def test_name_and_explicit_needs
|
312
|
-
t = task(:t, :needs => [:pre])
|
313
|
-
assert_equal "t", t.name
|
314
|
-
assert_equal [], t.arg_names
|
315
|
-
assert_equal ["pre"], t.prerequisites
|
316
|
-
end
|
317
|
-
|
318
312
|
def test_name_args_and_explicit_needs
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
313
|
+
ignore_deprecations do
|
314
|
+
t = task(:t, :x, :y, :needs => [:pre])
|
315
|
+
assert_equal "t", t.name
|
316
|
+
assert_equal [:x, :y], t.arg_names
|
317
|
+
assert_equal ["pre"], t.prerequisites
|
318
|
+
end
|
323
319
|
end
|
324
320
|
|
325
321
|
def test_illegal_keys_in_task_name_hash
|
326
|
-
|
327
|
-
|
322
|
+
ignore_deprecations do
|
323
|
+
assert_exception RuntimeError do
|
324
|
+
t = task(:t, :x, :y => 1, :needs => [:pre])
|
325
|
+
end
|
328
326
|
end
|
329
327
|
end
|
330
328
|
|
@@ -415,7 +413,7 @@ class TestTaskWithArguments < Test::Unit::TestCase
|
|
415
413
|
def test_named_args_are_passed_to_prereqs
|
416
414
|
value = nil
|
417
415
|
pre = task(:pre, :rev) { |t, args| value = args.rev }
|
418
|
-
t = task(:t, :name, :rev
|
416
|
+
t = task(:t, [:name, :rev] => [:pre])
|
419
417
|
t.invoke("bill", "1.2")
|
420
418
|
assert_equal "1.2", value
|
421
419
|
end
|
@@ -425,7 +423,7 @@ class TestTaskWithArguments < Test::Unit::TestCase
|
|
425
423
|
assert_equal({}, args.to_hash)
|
426
424
|
assert_equal "bill", args.name
|
427
425
|
}
|
428
|
-
t = task(:t, :name, :rev
|
426
|
+
t = task(:t, [:name, :rev] => [:pre])
|
429
427
|
t.invoke("bill", "1.2")
|
430
428
|
end
|
431
429
|
|
@@ -433,7 +431,7 @@ class TestTaskWithArguments < Test::Unit::TestCase
|
|
433
431
|
pre = task(:pre, :rev) { |t, args|
|
434
432
|
assert_equal({}, args.to_hash)
|
435
433
|
}
|
436
|
-
t = task(:t
|
434
|
+
t = task(:t => [:pre])
|
437
435
|
t.invoke("bill", "1.2")
|
438
436
|
end
|
439
437
|
end
|
@@ -20,6 +20,8 @@ class TestTopLevelFunctions < Test::Unit::TestCase
|
|
20
20
|
super
|
21
21
|
@app = Rake.application
|
22
22
|
Rake.application = flexmock("app")
|
23
|
+
Rake.application.should_receive(:deprecate).
|
24
|
+
and_return { |old, new, call| @app.deprecate(old, new, call) }
|
23
25
|
end
|
24
26
|
|
25
27
|
def teardown
|
@@ -36,7 +38,7 @@ class TestTopLevelFunctions < Test::Unit::TestCase
|
|
36
38
|
Rake.application.should_receive(:add_import).with("x").once.ordered
|
37
39
|
Rake.application.should_receive(:add_import).with("y").once.ordered
|
38
40
|
Rake.application.should_receive(:add_import).with("z").once.ordered
|
39
|
-
import('x', 'y', 'z')
|
41
|
+
Rake.import('x', 'y', 'z')
|
40
42
|
end
|
41
43
|
|
42
44
|
def test_when_writing
|
data/test/rake_test_setup.rb
CHANGED
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: 6
|
5
|
-
version: 0.9.0.beta.
|
5
|
+
version: 0.9.0.beta.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jim Weirich
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-03-05 00:00:00 -05:00
|
14
14
|
default_executable: rake
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -175,9 +175,11 @@ files:
|
|
175
175
|
- test/test_helper.rb
|
176
176
|
- test/data/imports/deps.mf
|
177
177
|
- test/data/sample.mf
|
178
|
+
- test/data/access/Rakefile
|
178
179
|
- test/data/chains/Rakefile
|
179
180
|
- test/data/comments/Rakefile
|
180
181
|
- test/data/default/Rakefile
|
182
|
+
- test/data/deprecated_import/Rakefile
|
181
183
|
- test/data/dryrun/Rakefile
|
182
184
|
- test/data/file_creation_task/Rakefile
|
183
185
|
- test/data/imports/Rakefile
|