rake 0.9.0 → 0.9.1
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 +9 -8
- data/RRR +10 -0
- data/Rakefile +9 -45
- data/bin/rake +4 -3
- data/doc/release_notes/rake-0.9.1.rdoc +52 -0
- data/lib/rake/dsl_definition.rb +19 -0
- data/lib/rake/version.rb +1 -1
- data/test/data/access/Rakefile +3 -1
- data/test/data/default/Rakefile +0 -2
- data/test/data/file_creation_task/Rakefile +0 -2
- data/test/data/multidesc/Rakefile +0 -2
- data/test/data/namespace/Rakefile +0 -2
- data/test/data/statusreturn/Rakefile +0 -2
- data/test/file_creation.rb +0 -2
- data/test/helper.rb +44 -0
- data/test/in_environment.rb +4 -1
- data/test/{lib/rake_test.rb → test_rake.rb} +2 -5
- data/test/test_rake_application.rb +364 -0
- data/test/test_rake_application_options.rb +382 -0
- data/test/{lib/clean_test.rb → test_rake_clean.rb} +2 -5
- data/test/{lib/definitions_test.rb → test_rake_definitions.rb} +5 -10
- data/test/test_rake_directory_task.rb +55 -0
- data/test/test_rake_dsl.rb +53 -0
- data/test/{lib/earlytime_test.rb → test_rake_early_time.rb} +2 -5
- data/test/{lib/extension_test.rb → test_rake_extension.rb} +2 -6
- data/test/{lib/file_creation_task_test.rb → test_rake_file_creation_task.rb} +7 -7
- data/test/{lib/filelist_test.rb → test_rake_file_list.rb} +18 -22
- data/test/test_rake_file_list_path_map.rb +8 -0
- data/test/{lib/file_task_test.rb → test_rake_file_task.rb} +22 -61
- data/test/{lib/fileutils_test.rb → test_rake_file_utils.rb} +11 -15
- data/test/{lib/ftp_test.rb → test_rake_ftp_file.rb} +5 -5
- data/test/{functional/session_based_tests.rb → test_rake_functional.rb} +35 -24
- data/test/test_rake_invocation_chain.rb +52 -0
- data/test/{lib/makefile_loader_test.rb → test_rake_makefile_loader.rb} +2 -5
- data/test/{lib/multitask_test.rb → test_rake_multi_task.rb} +5 -7
- data/test/{lib/namespace_test.rb → test_rake_name_space.rb} +4 -16
- data/test/{lib/package_task_test.rb → test_rake_package_task.rb} +2 -6
- data/test/{lib/pathmap_test.rb → test_rake_path_map.rb} +4 -58
- data/test/test_rake_path_map_explode.rb +31 -0
- data/test/test_rake_path_map_partial.rb +18 -0
- data/test/{lib/pseudo_status_test.rb → test_rake_pseudo_status.rb} +2 -8
- data/test/{lib/rdoc_task_test.rb → test_rake_rdoc_task.rb} +4 -7
- data/test/{lib/require_test.rb → test_rake_require.rb} +3 -9
- data/test/{lib/rules_test.rb → test_rake_rules.rb} +11 -13
- data/test/{lib/task_test.rb → test_rake_task.rb} +16 -182
- data/test/test_rake_task_argument_parsing.rb +116 -0
- data/test/{lib/task_arguments_test.rb → test_rake_task_arguments.rb} +2 -5
- data/test/{lib/tasklib_test.rb → test_rake_task_lib.rb} +2 -5
- data/test/{lib/task_manager_test.rb → test_rake_task_manager.rb} +7 -45
- data/test/test_rake_task_manager_argument_resolution.rb +36 -0
- data/test/test_rake_task_with_arguments.rb +162 -0
- data/test/{lib/test_task_test.rb → test_rake_test_task.rb} +52 -7
- data/test/{lib/top_level_functions_test.rb → test_rake_top_level_functions.rb} +8 -20
- data/test/{lib/win32_test.rb → test_rake_win32.rb} +4 -12
- data/test/{contrib/test_sys.rb → test_sys.rb} +2 -6
- metadata +60 -44
- data/lib/rake/dsl.rb +0 -2
- data/test/capture_stdout.rb +0 -26
- data/test/functional/functional_test.rb +0 -25
- data/test/lib/application_test.rb +0 -863
- data/test/lib/dsl_test.rb +0 -52
- data/test/lib/invocation_chain_test.rb +0 -81
- data/test/lib/testtask_test.rb +0 -49
- data/test/rake_test_setup.rb +0 -20
- data/test/ruby_version_test.rb +0 -3
- data/test/test_helper.rb +0 -19
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
|
+
|
3
|
+
class TestRakeInvocationChain < Rake::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
super
|
7
|
+
|
8
|
+
@empty = Rake::InvocationChain::EMPTY
|
9
|
+
|
10
|
+
@first_member = "A"
|
11
|
+
@second_member = "B"
|
12
|
+
@one = @empty.append(@first_member)
|
13
|
+
@two = @one.append(@second_member)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_append
|
17
|
+
chain = @empty.append("A")
|
18
|
+
|
19
|
+
assert_equal 'TOP => A', chain.to_s # HACK
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_append_one_circular
|
23
|
+
ex = assert_raises RuntimeError do
|
24
|
+
@one.append(@first_member)
|
25
|
+
end
|
26
|
+
assert_match(/circular +dependency/i, ex.message)
|
27
|
+
assert_match(/A.*=>.*A/, ex.message)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_append_two_circular
|
31
|
+
ex = assert_raises RuntimeError do
|
32
|
+
@two.append(@first_member)
|
33
|
+
end
|
34
|
+
assert_match(/A.*=>.*B.*=>.*A/, ex.message)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_member_eh_one
|
38
|
+
assert @one.member?(@first_member)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_member_eh_two
|
42
|
+
assert @two.member?(@first_member)
|
43
|
+
assert @two.member?(@second_member)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_to_s_empty
|
47
|
+
assert_equal "TOP", @empty.to_s
|
48
|
+
assert_equal "TOP => A", @one.to_s
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
@@ -1,10 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rake'
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
5
2
|
require 'rake/loaders/makefile'
|
6
3
|
|
7
|
-
class
|
4
|
+
class TestRakeMakefileLoader < Rake::TestCase
|
8
5
|
include Rake
|
9
6
|
|
10
7
|
def test_parse
|
@@ -1,14 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'test/unit'
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
4
2
|
require 'thread'
|
5
|
-
require 'rake'
|
6
3
|
|
7
|
-
|
8
|
-
class TestMultiTask < Test::Unit::TestCase
|
4
|
+
class TestRakeMultiTask < Rake::TestCase
|
9
5
|
include Rake
|
6
|
+
include Rake::DSL
|
10
7
|
|
11
8
|
def setup
|
9
|
+
super
|
10
|
+
|
12
11
|
Task.clear
|
13
12
|
@runs = Array.new
|
14
13
|
@mutex = Mutex.new
|
@@ -50,4 +49,3 @@ class TestMultiTask < Test::Unit::TestCase
|
|
50
49
|
end
|
51
50
|
end
|
52
51
|
|
53
|
-
|
@@ -1,18 +1,6 @@
|
|
1
|
-
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
2
|
|
3
|
-
|
4
|
-
require 'rubygems'
|
5
|
-
rescue LoadError
|
6
|
-
# got no gems
|
7
|
-
end
|
8
|
-
|
9
|
-
require 'test/unit'
|
10
|
-
require 'flexmock/test_unit'
|
11
|
-
require 'rake'
|
12
|
-
require 'test/rake_test_setup'
|
13
|
-
|
14
|
-
class TestNameSpace < Test::Unit::TestCase
|
15
|
-
include TestMethods
|
3
|
+
class TestRakeNameSpace < Rake::TestCase
|
16
4
|
|
17
5
|
class TM
|
18
6
|
include Rake::TaskManager
|
@@ -21,7 +9,7 @@ class TestNameSpace < Test::Unit::TestCase
|
|
21
9
|
def test_namespace_creation
|
22
10
|
mgr = TM.new
|
23
11
|
ns = Rake::NameSpace.new(mgr, [])
|
24
|
-
|
12
|
+
refute_nil ns
|
25
13
|
end
|
26
14
|
|
27
15
|
def test_namespace_lookup
|
@@ -30,7 +18,7 @@ class TestNameSpace < Test::Unit::TestCase
|
|
30
18
|
mgr.define_task(Rake::Task, "t")
|
31
19
|
end
|
32
20
|
|
33
|
-
|
21
|
+
refute_nil ns["t"]
|
34
22
|
assert_equal mgr["n:t"], ns["t"]
|
35
23
|
end
|
36
24
|
|
@@ -1,11 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'test/unit'
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
4
2
|
require 'rake/packagetask'
|
5
|
-
require 'test/rake_test_setup'
|
6
3
|
|
7
|
-
class
|
8
|
-
include TestMethods
|
4
|
+
class TestRakePackageTask < Rake::TestCase
|
9
5
|
|
10
6
|
def test_initialize
|
11
7
|
pkg = Rake::PackageTask.new("pkgr", "1.2.3") { |p|
|
@@ -1,12 +1,6 @@
|
|
1
|
-
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
2
|
|
3
|
-
|
4
|
-
require 'test/rake_test_setup'
|
5
|
-
require 'rake'
|
6
|
-
|
7
|
-
# ====================================================================
|
8
|
-
class TestPathMap < Test::Unit::TestCase
|
9
|
-
include TestMethods
|
3
|
+
class TestRakePathMap < Rake::TestCase
|
10
4
|
|
11
5
|
def test_returns_self_with_no_args
|
12
6
|
assert_equal "abc.rb", "abc.rb".pathmap
|
@@ -88,7 +82,7 @@ class TestPathMap < Test::Unit::TestCase
|
|
88
82
|
end
|
89
83
|
|
90
84
|
def test_undefined_percent_causes_error
|
91
|
-
|
85
|
+
assert_raises(ArgumentError) {
|
92
86
|
"dir/abc.rb".pathmap("%z")
|
93
87
|
}
|
94
88
|
end
|
@@ -132,7 +126,7 @@ class TestPathMap < Test::Unit::TestCase
|
|
132
126
|
end
|
133
127
|
|
134
128
|
def test_pattern_with_invalid_operator
|
135
|
-
ex =
|
129
|
+
ex = assert_raises(ArgumentError) do
|
136
130
|
"abc.xyz".pathmap("%{src,bin}z")
|
137
131
|
end
|
138
132
|
assert_match(/unknown.*pathmap.*spec.*z/i, ex.message)
|
@@ -161,51 +155,3 @@ class TestPathMap < Test::Unit::TestCase
|
|
161
155
|
end
|
162
156
|
end
|
163
157
|
|
164
|
-
class TestPathMapExplode < Test::Unit::TestCase
|
165
|
-
def setup
|
166
|
-
String.class_eval { public :pathmap_explode }
|
167
|
-
end
|
168
|
-
|
169
|
-
def teardown
|
170
|
-
String.class_eval { protected :pathmap_explode }
|
171
|
-
end
|
172
|
-
|
173
|
-
def test_explode
|
174
|
-
assert_equal ['a'], 'a'.pathmap_explode
|
175
|
-
assert_equal ['a', 'b'], 'a/b'.pathmap_explode
|
176
|
-
assert_equal ['a', 'b', 'c'], 'a/b/c'.pathmap_explode
|
177
|
-
assert_equal ['/', 'a'], '/a'.pathmap_explode
|
178
|
-
assert_equal ['/', 'a', 'b'], '/a/b'.pathmap_explode
|
179
|
-
assert_equal ['/', 'a', 'b', 'c'], '/a/b/c'.pathmap_explode
|
180
|
-
if File::ALT_SEPARATOR
|
181
|
-
assert_equal ['c:.', 'a'], 'c:a'.pathmap_explode
|
182
|
-
assert_equal ['c:.', 'a', 'b'], 'c:a/b'.pathmap_explode
|
183
|
-
assert_equal ['c:.', 'a', 'b', 'c'], 'c:a/b/c'.pathmap_explode
|
184
|
-
assert_equal ['c:/', 'a'], 'c:/a'.pathmap_explode
|
185
|
-
assert_equal ['c:/', 'a', 'b'], 'c:/a/b'.pathmap_explode
|
186
|
-
assert_equal ['c:/', 'a', 'b', 'c'], 'c:/a/b/c'.pathmap_explode
|
187
|
-
end
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
class TestPathMapPartial < Test::Unit::TestCase
|
192
|
-
def test_pathmap_partial
|
193
|
-
@path = "1/2/file"
|
194
|
-
def @path.call(n)
|
195
|
-
pathmap_partial(n)
|
196
|
-
end
|
197
|
-
assert_equal("1", @path.call(1))
|
198
|
-
assert_equal("1/2", @path.call(2))
|
199
|
-
assert_equal("1/2", @path.call(3))
|
200
|
-
assert_equal(".", @path.call(0))
|
201
|
-
assert_equal("2", @path.call(-1))
|
202
|
-
assert_equal("1/2", @path.call(-2))
|
203
|
-
assert_equal("1/2", @path.call(-3))
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
class TestFileListPathMap < Test::Unit::TestCase
|
208
|
-
def test_file_list_supports_pathmap
|
209
|
-
assert_equal ['a', 'b'], FileList['dir/a.rb', 'dir/b.rb'].pathmap("%n")
|
210
|
-
end
|
211
|
-
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
|
+
|
3
|
+
class TestRakePathMapExplode < Rake::TestCase
|
4
|
+
def setup
|
5
|
+
super
|
6
|
+
|
7
|
+
String.class_eval { public :pathmap_explode }
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
String.class_eval { protected :pathmap_explode }
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_explode
|
15
|
+
assert_equal ['a'], 'a'.pathmap_explode
|
16
|
+
assert_equal ['a', 'b'], 'a/b'.pathmap_explode
|
17
|
+
assert_equal ['a', 'b', 'c'], 'a/b/c'.pathmap_explode
|
18
|
+
assert_equal ['/', 'a'], '/a'.pathmap_explode
|
19
|
+
assert_equal ['/', 'a', 'b'], '/a/b'.pathmap_explode
|
20
|
+
assert_equal ['/', 'a', 'b', 'c'], '/a/b/c'.pathmap_explode
|
21
|
+
if File::ALT_SEPARATOR
|
22
|
+
assert_equal ['c:.', 'a'], 'c:a'.pathmap_explode
|
23
|
+
assert_equal ['c:.', 'a', 'b'], 'c:a/b'.pathmap_explode
|
24
|
+
assert_equal ['c:.', 'a', 'b', 'c'], 'c:a/b/c'.pathmap_explode
|
25
|
+
assert_equal ['c:/', 'a'], 'c:/a'.pathmap_explode
|
26
|
+
assert_equal ['c:/', 'a', 'b'], 'c:/a/b'.pathmap_explode
|
27
|
+
assert_equal ['c:/', 'a', 'b', 'c'], 'c:/a/b/c'.pathmap_explode
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
|
+
|
3
|
+
class TestRakePathMapPartial < Rake::TestCase
|
4
|
+
def test_pathmap_partial
|
5
|
+
@path = "1/2/file"
|
6
|
+
def @path.call(n)
|
7
|
+
pathmap_partial(n)
|
8
|
+
end
|
9
|
+
assert_equal("1", @path.call(1))
|
10
|
+
assert_equal("1/2", @path.call(2))
|
11
|
+
assert_equal("1/2", @path.call(3))
|
12
|
+
assert_equal(".", @path.call(0))
|
13
|
+
assert_equal("2", @path.call(-1))
|
14
|
+
assert_equal("1/2", @path.call(-2))
|
15
|
+
assert_equal("1/2", @path.call(-3))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
@@ -1,12 +1,6 @@
|
|
1
|
-
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
2
|
|
3
|
-
|
4
|
-
require 'rake'
|
5
|
-
|
6
|
-
require 'test/capture_stdout'
|
7
|
-
require 'test/rake_test_setup'
|
8
|
-
|
9
|
-
class PseudoStatusTest < Test::Unit::TestCase
|
3
|
+
class TestRakePseudoStatus < Rake::TestCase
|
10
4
|
def test_with_zero_exit_status
|
11
5
|
s = Rake::PseudoStatus.new
|
12
6
|
assert_equal 0, s.exitstatus
|
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'test/capture_stdout'
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
5
2
|
begin
|
6
3
|
old_verbose = $VERBOSE
|
7
4
|
$VERBOSE = nil
|
@@ -9,13 +6,13 @@ begin
|
|
9
6
|
ensure
|
10
7
|
$VERBOSE = old_verbose
|
11
8
|
end
|
12
|
-
require 'test/rake_test_setup'
|
13
9
|
|
14
|
-
class
|
10
|
+
class TestRakeRDocTask < Rake::TestCase
|
15
11
|
include Rake
|
16
|
-
include TestMethods
|
17
12
|
|
18
13
|
def setup
|
14
|
+
super
|
15
|
+
|
19
16
|
Task.clear
|
20
17
|
end
|
21
18
|
|
@@ -1,12 +1,6 @@
|
|
1
|
-
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
2
2
|
|
3
|
-
|
4
|
-
require 'rake'
|
5
|
-
require 'test/rake_test_setup'
|
6
|
-
|
7
|
-
# ====================================================================
|
8
|
-
class TestRequire < Test::Unit::TestCase
|
9
|
-
include TestMethods
|
3
|
+
class TestRakeRequire < Rake::TestCase
|
10
4
|
|
11
5
|
def test_can_load_rake_library
|
12
6
|
app = Rake::Application.new
|
@@ -29,7 +23,7 @@ class TestRequire < Test::Unit::TestCase
|
|
29
23
|
|
30
24
|
def test_throws_error_if_library_not_found
|
31
25
|
app = Rake::Application.new
|
32
|
-
ex =
|
26
|
+
ex = assert_raises(LoadError) {
|
33
27
|
assert app.instance_eval {
|
34
28
|
rake_require("testx", ['test/data/rakelib'], [])
|
35
29
|
}
|
@@ -1,16 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'test/unit'
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
4
2
|
require 'fileutils'
|
5
|
-
require 'rake'
|
6
|
-
require 'test/file_creation'
|
7
|
-
require 'test/rake_test_setup'
|
8
3
|
|
9
4
|
######################################################################
|
10
|
-
class
|
5
|
+
class TestRakeRules < Rake::TestCase
|
11
6
|
include Rake
|
12
|
-
include FileCreation
|
13
|
-
include TestMethods
|
14
7
|
|
15
8
|
SRCFILE = "testdata/abc.c"
|
16
9
|
SRCFILE2 = "testdata/xyz.c"
|
@@ -20,12 +13,17 @@ class TestRules < Test::Unit::TestCase
|
|
20
13
|
DOTFOOFILE = "testdata/.foo"
|
21
14
|
|
22
15
|
def setup
|
16
|
+
super
|
17
|
+
|
23
18
|
Task.clear
|
24
19
|
@runs = []
|
20
|
+
FileUtils.mkdir_p 'testdata' # HACK use tmpdir
|
25
21
|
end
|
26
22
|
|
27
23
|
def teardown
|
28
24
|
FileList['testdata/*'].uniq.each do |f| rm_r(f, :verbose=>false) end
|
25
|
+
|
26
|
+
super
|
29
27
|
end
|
30
28
|
|
31
29
|
def test_multiple_rules1
|
@@ -192,8 +190,8 @@ class TestRules < Test::Unit::TestCase
|
|
192
190
|
rule '.o' => ['.c'] do |t|
|
193
191
|
@runs << t.name
|
194
192
|
end
|
195
|
-
|
196
|
-
|
193
|
+
assert_raises(RuntimeError) { Task['testdata/x.obj'].invoke }
|
194
|
+
assert_raises(RuntimeError) { Task['testdata/x.xyo'].invoke }
|
197
195
|
end
|
198
196
|
|
199
197
|
def test_rule_rebuilds_obj_when_source_is_newer
|
@@ -333,7 +331,7 @@ class TestRules < Test::Unit::TestCase
|
|
333
331
|
rule ".#{letter}" => ".#{prev}" do |t| puts "#{t.name}" end
|
334
332
|
prev = letter
|
335
333
|
end
|
336
|
-
ex =
|
334
|
+
ex = assert_raises(Rake::RuleRecursionOverflowError) {
|
337
335
|
Task["testdata/a.z"].invoke
|
338
336
|
}
|
339
337
|
assert_match(/a\.z => testdata\/a.y/, ex.message)
|
@@ -341,7 +339,7 @@ class TestRules < Test::Unit::TestCase
|
|
341
339
|
|
342
340
|
def test_rules_with_bad_dependents_will_fail
|
343
341
|
rule "a" => [ 1 ] do |t| puts t.name end
|
344
|
-
|
342
|
+
assert_raises(RuntimeError) do Task['a'].invoke end
|
345
343
|
end
|
346
344
|
|
347
345
|
end
|
@@ -1,25 +1,20 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'test/unit'
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
4
2
|
require 'fileutils'
|
5
|
-
require 'rake'
|
6
|
-
require 'test/rake_test_setup'
|
7
3
|
|
8
|
-
|
9
|
-
class TestTask < Test::Unit::TestCase
|
10
|
-
include CaptureStdout
|
4
|
+
class TestRakeTask < Rake::TestCase
|
11
5
|
include Rake
|
12
|
-
include TestMethods
|
13
|
-
include Rake::DSL
|
14
6
|
|
15
7
|
def setup
|
8
|
+
super
|
9
|
+
|
16
10
|
Task.clear
|
17
11
|
Rake::TaskManager.record_task_metadata = true
|
18
12
|
end
|
19
13
|
|
20
14
|
def teardown
|
21
|
-
super
|
22
15
|
Rake::TaskManager.record_task_metadata = false
|
16
|
+
|
17
|
+
super
|
23
18
|
end
|
24
19
|
|
25
20
|
def test_create
|
@@ -58,7 +53,7 @@ class TestTask < Test::Unit::TestCase
|
|
58
53
|
t2 = task(:t2 => [:t1]) { |t| runlist << t.name }
|
59
54
|
assert_equal ["t2"], t1.prerequisites
|
60
55
|
assert_equal ["t1"], t2.prerequisites
|
61
|
-
ex =
|
56
|
+
ex = assert_raises RuntimeError do
|
62
57
|
t1.invoke
|
63
58
|
end
|
64
59
|
assert_match(/circular dependency/i, ex.message)
|
@@ -69,10 +64,10 @@ class TestTask < Test::Unit::TestCase
|
|
69
64
|
Rake.application.options.dryrun = true
|
70
65
|
runlist = []
|
71
66
|
t1 = task(:t1) { |t| runlist << t.name; 3321 }
|
72
|
-
|
73
|
-
assert_match(/execute .*t1/i,
|
74
|
-
assert_match(/dry run/i,
|
75
|
-
|
67
|
+
_, err = capture_io { t1.invoke }
|
68
|
+
assert_match(/execute .*t1/i, err)
|
69
|
+
assert_match(/dry run/i, err)
|
70
|
+
refute_match(/invoke/i, err)
|
76
71
|
assert_equal [], runlist
|
77
72
|
ensure
|
78
73
|
Rake.application.options.dryrun = false
|
@@ -81,11 +76,11 @@ class TestTask < Test::Unit::TestCase
|
|
81
76
|
def test_tasks_can_be_traced
|
82
77
|
Rake.application.options.trace = true
|
83
78
|
t1 = task(:t1)
|
84
|
-
|
79
|
+
_, err = capture_io {
|
85
80
|
t1.invoke
|
86
81
|
}
|
87
|
-
assert_match(/invoke t1/i,
|
88
|
-
assert_match(/execute t1/i,
|
82
|
+
assert_match(/invoke t1/i, err)
|
83
|
+
assert_match(/execute t1/i, err)
|
89
84
|
ensure
|
90
85
|
Rake.application.options.trace = false
|
91
86
|
end
|
@@ -131,7 +126,7 @@ class TestTask < Test::Unit::TestCase
|
|
131
126
|
def test_find
|
132
127
|
task :tfind
|
133
128
|
assert_equal "tfind", Task[:tfind].name
|
134
|
-
ex =
|
129
|
+
ex = assert_raises(RuntimeError) { Task[:leaves] }
|
135
130
|
assert_equal "Don't know how to build task 'leaves'", ex.message
|
136
131
|
end
|
137
132
|
|
@@ -192,7 +187,7 @@ class TestTask < Test::Unit::TestCase
|
|
192
187
|
def test_prerequiste_tasks_fails_if_prerequisites_are_undefined
|
193
188
|
a = task :a => ["b", "c"]
|
194
189
|
b = task :b
|
195
|
-
|
190
|
+
assert_raises(RuntimeError) do
|
196
191
|
a.prerequisite_tasks
|
197
192
|
end
|
198
193
|
end
|
@@ -274,164 +269,3 @@ class TestTask < Test::Unit::TestCase
|
|
274
269
|
end
|
275
270
|
end
|
276
271
|
|
277
|
-
######################################################################
|
278
|
-
class TestTaskWithArguments < Test::Unit::TestCase
|
279
|
-
include CaptureStdout
|
280
|
-
include Rake
|
281
|
-
include TestMethods
|
282
|
-
include Rake::DSL
|
283
|
-
|
284
|
-
def setup
|
285
|
-
super
|
286
|
-
Task.clear
|
287
|
-
Rake::TaskManager.record_task_metadata = true
|
288
|
-
end
|
289
|
-
|
290
|
-
def teardown
|
291
|
-
Rake::TaskManager.record_task_metadata = false
|
292
|
-
super
|
293
|
-
end
|
294
|
-
|
295
|
-
def test_no_args_given
|
296
|
-
t = task :t
|
297
|
-
assert_equal [], t.arg_names
|
298
|
-
end
|
299
|
-
|
300
|
-
def test_args_given
|
301
|
-
t = task :t, :a, :b
|
302
|
-
assert_equal [:a, :b], t.arg_names
|
303
|
-
end
|
304
|
-
|
305
|
-
def test_name_and_needs
|
306
|
-
t = task(:t => [:pre])
|
307
|
-
assert_equal "t", t.name
|
308
|
-
assert_equal [], t.arg_names
|
309
|
-
assert_equal ["pre"], t.prerequisites
|
310
|
-
end
|
311
|
-
|
312
|
-
def test_name_args_and_explicit_needs
|
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
|
319
|
-
end
|
320
|
-
|
321
|
-
def test_illegal_keys_in_task_name_hash
|
322
|
-
ignore_deprecations do
|
323
|
-
assert_exception RuntimeError do
|
324
|
-
t = task(:t, :x, :y => 1, :needs => [:pre])
|
325
|
-
end
|
326
|
-
end
|
327
|
-
end
|
328
|
-
|
329
|
-
def test_arg_list_is_empty_if_no_args_given
|
330
|
-
t = task(:t) { |tt, args| assert_equal({}, args.to_hash) }
|
331
|
-
t.invoke(1, 2, 3)
|
332
|
-
end
|
333
|
-
|
334
|
-
def test_tasks_can_access_arguments_as_hash
|
335
|
-
t = task :t, :a, :b, :c do |tt, args|
|
336
|
-
assert_equal({:a => 1, :b => 2, :c => 3}, args.to_hash)
|
337
|
-
assert_equal 1, args[:a]
|
338
|
-
assert_equal 2, args[:b]
|
339
|
-
assert_equal 3, args[:c]
|
340
|
-
assert_equal 1, args.a
|
341
|
-
assert_equal 2, args.b
|
342
|
-
assert_equal 3, args.c
|
343
|
-
end
|
344
|
-
t.invoke(1, 2, 3)
|
345
|
-
end
|
346
|
-
|
347
|
-
def test_actions_of_various_arity_are_ok_with_args
|
348
|
-
notes = []
|
349
|
-
t = task(:t, :x) do
|
350
|
-
notes << :a
|
351
|
-
end
|
352
|
-
t.enhance do | |
|
353
|
-
notes << :b
|
354
|
-
end
|
355
|
-
t.enhance do |task|
|
356
|
-
notes << :c
|
357
|
-
assert_kind_of Task, task
|
358
|
-
end
|
359
|
-
t.enhance do |t2, args|
|
360
|
-
notes << :d
|
361
|
-
assert_equal t, t2
|
362
|
-
assert_equal({:x => 1}, args.to_hash)
|
363
|
-
end
|
364
|
-
assert_nothing_raised do t.invoke(1) end
|
365
|
-
assert_equal [:a, :b, :c, :d], notes
|
366
|
-
end
|
367
|
-
|
368
|
-
def test_arguments_are_passed_to_block
|
369
|
-
t = task(:t, :a, :b) { |tt, args|
|
370
|
-
assert_equal( { :a => 1, :b => 2 }, args.to_hash )
|
371
|
-
}
|
372
|
-
t.invoke(1, 2)
|
373
|
-
end
|
374
|
-
|
375
|
-
def test_extra_parameters_are_ignored
|
376
|
-
t = task(:t, :a) { |tt, args|
|
377
|
-
assert_equal 1, args.a
|
378
|
-
assert_nil args.b
|
379
|
-
}
|
380
|
-
t.invoke(1, 2)
|
381
|
-
end
|
382
|
-
|
383
|
-
def test_arguments_are_passed_to_all_blocks
|
384
|
-
counter = 0
|
385
|
-
t = task :t, :a
|
386
|
-
task :t do |tt, args|
|
387
|
-
assert_equal 1, args.a
|
388
|
-
counter += 1
|
389
|
-
end
|
390
|
-
task :t do |tt, args|
|
391
|
-
assert_equal 1, args.a
|
392
|
-
counter += 1
|
393
|
-
end
|
394
|
-
t.invoke(1)
|
395
|
-
assert_equal 2, counter
|
396
|
-
end
|
397
|
-
|
398
|
-
def test_block_with_no_parameters_is_ok
|
399
|
-
t = task(:t) { }
|
400
|
-
t.invoke(1, 2)
|
401
|
-
end
|
402
|
-
|
403
|
-
def test_name_with_args
|
404
|
-
desc "T"
|
405
|
-
t = task(:tt, :a, :b)
|
406
|
-
assert_equal "tt", t.name
|
407
|
-
assert_equal "T", t.comment
|
408
|
-
assert_equal "[a,b]", t.arg_description
|
409
|
-
assert_equal "tt[a,b]", t.name_with_args
|
410
|
-
assert_equal [:a, :b],t.arg_names
|
411
|
-
end
|
412
|
-
|
413
|
-
def test_named_args_are_passed_to_prereqs
|
414
|
-
value = nil
|
415
|
-
pre = task(:pre, :rev) { |t, args| value = args.rev }
|
416
|
-
t = task(:t, [:name, :rev] => [:pre])
|
417
|
-
t.invoke("bill", "1.2")
|
418
|
-
assert_equal "1.2", value
|
419
|
-
end
|
420
|
-
|
421
|
-
def test_args_not_passed_if_no_prereq_names
|
422
|
-
pre = task(:pre) { |t, args|
|
423
|
-
assert_equal({}, args.to_hash)
|
424
|
-
assert_equal "bill", args.name
|
425
|
-
}
|
426
|
-
t = task(:t, [:name, :rev] => [:pre])
|
427
|
-
t.invoke("bill", "1.2")
|
428
|
-
end
|
429
|
-
|
430
|
-
def test_args_not_passed_if_no_arg_names
|
431
|
-
pre = task(:pre, :rev) { |t, args|
|
432
|
-
assert_equal({}, args.to_hash)
|
433
|
-
}
|
434
|
-
t = task(:t => [:pre])
|
435
|
-
t.invoke("bill", "1.2")
|
436
|
-
end
|
437
|
-
end
|