elliottcable-echoe 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +69 -0
- data/LICENSE +184 -0
- data/MIT-LICENSE +21 -0
- data/Manifest +113 -0
- data/README +114 -0
- data/Rakefile +15 -0
- data/TODO +4 -0
- data/echoe.gemspec +37 -0
- data/lib/echoe/client.rb +25 -0
- data/lib/echoe/extensions.rb +57 -0
- data/lib/echoe/platform.rb +36 -0
- data/lib/echoe/rubygems.rb +41 -0
- data/lib/echoe.rb +717 -0
- data/vendor/rake/CHANGES +400 -0
- data/vendor/rake/MIT-LICENSE +21 -0
- data/vendor/rake/README +285 -0
- data/vendor/rake/Rakefile +418 -0
- data/vendor/rake/TODO +20 -0
- data/vendor/rake/bin/rake +31 -0
- data/vendor/rake/doc/example/Rakefile1 +38 -0
- data/vendor/rake/doc/example/Rakefile2 +35 -0
- data/vendor/rake/doc/example/a.c +6 -0
- data/vendor/rake/doc/example/b.c +6 -0
- data/vendor/rake/doc/example/main.c +11 -0
- data/vendor/rake/doc/glossary.rdoc +51 -0
- data/vendor/rake/doc/jamis.rb +591 -0
- data/vendor/rake/doc/proto_rake.rdoc +127 -0
- data/vendor/rake/doc/rake.1.gz +0 -0
- data/vendor/rake/doc/rakefile.rdoc +534 -0
- data/vendor/rake/doc/rational.rdoc +151 -0
- data/vendor/rake/doc/release_notes/rake-0.4.14.rdoc +23 -0
- data/vendor/rake/doc/release_notes/rake-0.4.15.rdoc +35 -0
- data/vendor/rake/doc/release_notes/rake-0.5.0.rdoc +53 -0
- data/vendor/rake/doc/release_notes/rake-0.5.3.rdoc +78 -0
- data/vendor/rake/doc/release_notes/rake-0.5.4.rdoc +46 -0
- data/vendor/rake/doc/release_notes/rake-0.6.0.rdoc +141 -0
- data/vendor/rake/doc/release_notes/rake-0.7.0.rdoc +119 -0
- data/vendor/rake/doc/release_notes/rake-0.7.1.rdoc +59 -0
- data/vendor/rake/doc/release_notes/rake-0.7.2.rdoc +121 -0
- data/vendor/rake/doc/release_notes/rake-0.7.3.rdoc +47 -0
- data/vendor/rake/doc/release_notes/rake-0.8.0.rdoc +114 -0
- data/vendor/rake/doc/release_notes/rake-0.8.2.rdoc +165 -0
- data/vendor/rake/doc/release_notes/rake-0.8.3.rdoc +112 -0
- data/vendor/rake/install.rb +88 -0
- data/vendor/rake/lib/rake/classic_namespace.rb +8 -0
- data/vendor/rake/lib/rake/clean.rb +33 -0
- data/vendor/rake/lib/rake/contrib/compositepublisher.rb +24 -0
- data/vendor/rake/lib/rake/contrib/ftptools.rb +153 -0
- data/vendor/rake/lib/rake/contrib/publisher.rb +75 -0
- data/vendor/rake/lib/rake/contrib/rubyforgepublisher.rb +18 -0
- data/vendor/rake/lib/rake/contrib/sshpublisher.rb +47 -0
- data/vendor/rake/lib/rake/contrib/sys.rb +209 -0
- data/vendor/rake/lib/rake/gempackagetask.rb +103 -0
- data/vendor/rake/lib/rake/loaders/makefile.rb +35 -0
- data/vendor/rake/lib/rake/packagetask.rb +185 -0
- data/vendor/rake/lib/rake/rake_test_loader.rb +5 -0
- data/vendor/rake/lib/rake/rdoctask.rb +147 -0
- data/vendor/rake/lib/rake/ruby182_test_unit_fix.rb +23 -0
- data/vendor/rake/lib/rake/runtest.rb +23 -0
- data/vendor/rake/lib/rake/tasklib.rb +23 -0
- data/vendor/rake/lib/rake/testtask.rb +161 -0
- data/vendor/rake/lib/rake/win32.rb +54 -0
- data/vendor/rake/lib/rake.rb +2468 -0
- data/vendor/rake/test/capture_stdout.rb +26 -0
- data/vendor/rake/test/check_expansion.rb +5 -0
- data/vendor/rake/test/contrib/test_sys.rb +47 -0
- data/vendor/rake/test/data/chains/Rakefile +15 -0
- data/vendor/rake/test/data/default/Rakefile +19 -0
- data/vendor/rake/test/data/dryrun/Rakefile +22 -0
- data/vendor/rake/test/data/file_creation_task/Rakefile +33 -0
- data/vendor/rake/test/data/imports/Rakefile +19 -0
- data/vendor/rake/test/data/imports/deps.mf +1 -0
- data/vendor/rake/test/data/multidesc/Rakefile +17 -0
- data/vendor/rake/test/data/namespace/Rakefile +57 -0
- data/vendor/rake/test/data/rakelib/test1.rb +3 -0
- data/vendor/rake/test/data/rbext/rakefile.rb +3 -0
- data/vendor/rake/test/data/sample.mf +12 -0
- data/vendor/rake/test/data/statusreturn/Rakefile +8 -0
- data/vendor/rake/test/data/unittest/Rakefile +1 -0
- data/vendor/rake/test/filecreation.rb +32 -0
- data/vendor/rake/test/functional.rb +15 -0
- data/vendor/rake/test/in_environment.rb +30 -0
- data/vendor/rake/test/rake_test_setup.rb +10 -0
- data/vendor/rake/test/reqfile.rb +3 -0
- data/vendor/rake/test/reqfile2.rb +3 -0
- data/vendor/rake/test/session_functional.rb +337 -0
- data/vendor/rake/test/shellcommand.rb +3 -0
- data/vendor/rake/test/test_application.rb +694 -0
- data/vendor/rake/test/test_clean.rb +14 -0
- data/vendor/rake/test/test_definitions.rb +82 -0
- data/vendor/rake/test/test_earlytime.rb +35 -0
- data/vendor/rake/test/test_extension.rb +63 -0
- data/vendor/rake/test/test_file_creation_task.rb +62 -0
- data/vendor/rake/test/test_file_task.rb +139 -0
- data/vendor/rake/test/test_filelist.rb +618 -0
- data/vendor/rake/test/test_fileutils.rb +250 -0
- data/vendor/rake/test/test_ftp.rb +59 -0
- data/vendor/rake/test/test_invocation_chain.rb +75 -0
- data/vendor/rake/test/test_makefile_loader.rb +25 -0
- data/vendor/rake/test/test_multitask.rb +45 -0
- data/vendor/rake/test/test_namespace.rb +36 -0
- data/vendor/rake/test/test_package_task.rb +116 -0
- data/vendor/rake/test/test_pathmap.rb +209 -0
- data/vendor/rake/test/test_rake.rb +41 -0
- data/vendor/rake/test/test_require.rb +33 -0
- data/vendor/rake/test/test_rules.rb +347 -0
- data/vendor/rake/test/test_task_arguments.rb +89 -0
- data/vendor/rake/test/test_task_manager.rb +170 -0
- data/vendor/rake/test/test_tasklib.rb +12 -0
- data/vendor/rake/test/test_tasks.rb +371 -0
- data/vendor/rake/test/test_test_task.rb +75 -0
- data/vendor/rake/test/test_top_level_functions.rb +84 -0
- data/vendor/rake/test/test_win32.rb +57 -0
- metadata +195 -0
@@ -0,0 +1,89 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rake'
|
5
|
+
|
6
|
+
######################################################################
|
7
|
+
class TestTaskArguments < Test::Unit::TestCase
|
8
|
+
def teardown
|
9
|
+
ENV.delete('rev')
|
10
|
+
ENV.delete('VER')
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_empty_arg_list_is_empty
|
14
|
+
ta = Rake::TaskArguments.new([], [])
|
15
|
+
assert_equal({}, ta.to_hash)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_multiple_values_in_args
|
19
|
+
ta = Rake::TaskArguments.new([:a, :b, :c], [:one, :two, :three])
|
20
|
+
assert_equal({:a => :one, :b => :two, :c => :three}, ta.to_hash)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_to_s
|
24
|
+
ta = Rake::TaskArguments.new([:a, :b, :c], [1, 2, 3])
|
25
|
+
assert_equal ta.to_hash.inspect, ta.to_s
|
26
|
+
assert_equal ta.to_hash.inspect, ta.inspect
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_enumerable_behavior
|
30
|
+
ta = Rake::TaskArguments.new([:a, :b, :c], [1, 2 ,3])
|
31
|
+
assert_equal [10, 20, 30], ta.collect { |k,v| v * 10 }.sort
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_named_args
|
35
|
+
ta = Rake::TaskArguments.new(["aa", "bb"], [1, 2])
|
36
|
+
assert_equal 1, ta.aa
|
37
|
+
assert_equal 1, ta[:aa]
|
38
|
+
assert_equal 1, ta["aa"]
|
39
|
+
assert_equal 2, ta.bb
|
40
|
+
assert_nil ta.cc
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_args_knows_its_names
|
44
|
+
ta = Rake::TaskArguments.new(["aa", "bb"], [1, 2])
|
45
|
+
assert_equal ["aa", "bb"], ta.names
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_extra_names_are_nil
|
49
|
+
ta = Rake::TaskArguments.new(["aa", "bb", "cc"], [1, 2])
|
50
|
+
assert_nil ta.cc
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_args_can_reference_env_values
|
54
|
+
ta = Rake::TaskArguments.new(["aa"], [1])
|
55
|
+
ENV['rev'] = "1.2"
|
56
|
+
ENV['VER'] = "2.3"
|
57
|
+
assert_equal "1.2", ta.rev
|
58
|
+
assert_equal "2.3", ta.ver
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_creating_new_argument_scopes
|
62
|
+
parent = Rake::TaskArguments.new(['p'], [1])
|
63
|
+
child = parent.new_scope(['c', 'p'])
|
64
|
+
assert_equal({:p=>1}, child.to_hash)
|
65
|
+
assert_equal 1, child.p
|
66
|
+
assert_equal 1, child["p"]
|
67
|
+
assert_equal 1, child[:p]
|
68
|
+
assert_nil child.c
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_child_hides_parent_arg_names
|
72
|
+
parent = Rake::TaskArguments.new(['aa'], [1])
|
73
|
+
child = Rake::TaskArguments.new(['aa'], [2], parent)
|
74
|
+
assert_equal 2, child.aa
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_default_arguments_values_can_be_merged
|
78
|
+
ta = Rake::TaskArguments.new(["aa", "bb"], [nil, "original_val"])
|
79
|
+
ta.with_defaults({ :aa => 'default_val' })
|
80
|
+
assert_equal 'default_val', ta[:aa]
|
81
|
+
assert_equal 'original_val', ta[:bb]
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_default_arguements_that_dont_match_names_are_ignored
|
85
|
+
ta = Rake::TaskArguments.new(["aa", "bb"], [nil, "original_val"])
|
86
|
+
ta.with_defaults({ "cc" => "default_val" })
|
87
|
+
assert_nil ta[:cc]
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,170 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rake'
|
5
|
+
|
6
|
+
class TaskManager
|
7
|
+
include Rake::TaskManager
|
8
|
+
end
|
9
|
+
|
10
|
+
class TestTaskManager < Test::Unit::TestCase
|
11
|
+
def setup
|
12
|
+
@tm = TaskManager.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_create_task_manager
|
16
|
+
assert_not_nil @tm
|
17
|
+
assert_equal [], @tm.tasks
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_define_task
|
21
|
+
t = @tm.define_task(Rake::Task, :t)
|
22
|
+
assert_equal "t", t.name
|
23
|
+
assert_equal @tm, t.application
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_name_lookup
|
27
|
+
t = @tm.define_task(Rake::Task, :t)
|
28
|
+
assert_equal t, @tm[:t]
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_namespace_task_create
|
32
|
+
@tm.in_namespace("x") do
|
33
|
+
t = @tm.define_task(Rake::Task, :t)
|
34
|
+
assert_equal "x:t", t.name
|
35
|
+
end
|
36
|
+
assert_equal ["x:t"], @tm.tasks.collect { |t| t.name }
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_anonymous_namespace
|
40
|
+
anon_ns = @tm.in_namespace(nil) do
|
41
|
+
t = @tm.define_task(Rake::Task, :t)
|
42
|
+
assert_equal "_anon_1:t", t.name
|
43
|
+
end
|
44
|
+
task = anon_ns[:t]
|
45
|
+
assert_equal "_anon_1:t", task.name
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_create_filetask_in_namespace
|
49
|
+
@tm.in_namespace("x") do
|
50
|
+
t = @tm.define_task(Rake::FileTask, "fn")
|
51
|
+
assert_equal "fn", t.name
|
52
|
+
end
|
53
|
+
assert_equal ["fn"], @tm.tasks.collect { |t| t.name }
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_namespace_yields_same_namespace_as_returned
|
57
|
+
yielded_namespace = nil
|
58
|
+
returned_namespace = @tm.in_namespace("x") do |ns|
|
59
|
+
yielded_namespace = ns
|
60
|
+
end
|
61
|
+
assert_equal returned_namespace, yielded_namespace
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_name_lookup_with_implicit_file_tasks
|
65
|
+
t = @tm["README"]
|
66
|
+
assert_equal "README", t.name
|
67
|
+
assert Rake::FileTask === t
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_name_lookup_with_nonexistent_task
|
71
|
+
assert_raise(RuntimeError) {
|
72
|
+
t = @tm["DOES NOT EXIST"]
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_name_lookup_in_multiple_scopes
|
77
|
+
aa = nil
|
78
|
+
bb = nil
|
79
|
+
xx = @tm.define_task(Rake::Task, :xx)
|
80
|
+
top_z = @tm.define_task(Rake::Task, :z)
|
81
|
+
@tm.in_namespace("a") do
|
82
|
+
aa = @tm.define_task(Rake::Task, :aa)
|
83
|
+
mid_z = @tm.define_task(Rake::Task, :z)
|
84
|
+
@tm.in_namespace("b") do
|
85
|
+
bb = @tm.define_task(Rake::Task, :bb)
|
86
|
+
bot_z = @tm.define_task(Rake::Task, :z)
|
87
|
+
|
88
|
+
assert_equal ["a", "b"], @tm.current_scope
|
89
|
+
|
90
|
+
assert_equal bb, @tm["a:b:bb"]
|
91
|
+
assert_equal aa, @tm["a:aa"]
|
92
|
+
assert_equal xx, @tm["xx"]
|
93
|
+
assert_equal bot_z, @tm["z"]
|
94
|
+
assert_equal mid_z, @tm["^z"]
|
95
|
+
assert_equal top_z, @tm["^^z"]
|
96
|
+
assert_equal top_z, @tm["rake:z"]
|
97
|
+
end
|
98
|
+
|
99
|
+
assert_equal ["a"], @tm.current_scope
|
100
|
+
|
101
|
+
assert_equal bb, @tm["a:b:bb"]
|
102
|
+
assert_equal aa, @tm["a:aa"]
|
103
|
+
assert_equal xx, @tm["xx"]
|
104
|
+
assert_equal bb, @tm["b:bb"]
|
105
|
+
assert_equal aa, @tm["aa"]
|
106
|
+
assert_equal mid_z, @tm["z"]
|
107
|
+
assert_equal top_z, @tm["^z"]
|
108
|
+
assert_equal top_z, @tm["rake:z"]
|
109
|
+
end
|
110
|
+
|
111
|
+
assert_equal [], @tm.current_scope
|
112
|
+
|
113
|
+
assert_equal [], xx.scope
|
114
|
+
assert_equal ['a'], aa.scope
|
115
|
+
assert_equal ['a', 'b'], bb.scope
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_lookup_with_explicit_scopes
|
119
|
+
t1, t2, t3, s = (0...4).collect { nil }
|
120
|
+
t1 = @tm.define_task(Rake::Task, :t)
|
121
|
+
@tm.in_namespace("a") do
|
122
|
+
t2 = @tm.define_task(Rake::Task, :t)
|
123
|
+
s = @tm.define_task(Rake::Task, :s)
|
124
|
+
@tm.in_namespace("b") do
|
125
|
+
t3 = @tm.define_task(Rake::Task, :t)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
assert_equal t1, @tm[:t, []]
|
129
|
+
assert_equal t2, @tm[:t, ["a"]]
|
130
|
+
assert_equal t3, @tm[:t, ["a", "b"]]
|
131
|
+
assert_equal s, @tm[:s, ["a", "b"]]
|
132
|
+
assert_equal s, @tm[:s, ["a"]]
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_correctly_scoped_prerequisites_are_invoked
|
136
|
+
values = []
|
137
|
+
@tm = Rake::Application.new
|
138
|
+
@tm.define_task(Rake::Task, :z) do values << "top z" end
|
139
|
+
@tm.in_namespace("a") do
|
140
|
+
@tm.define_task(Rake::Task, :z) do values << "next z" end
|
141
|
+
@tm.define_task(Rake::Task, :x => :z)
|
142
|
+
end
|
143
|
+
|
144
|
+
@tm["a:x"].invoke
|
145
|
+
assert_equal ["next z"], values
|
146
|
+
end
|
147
|
+
|
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
|
@@ -0,0 +1,371 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'rake'
|
6
|
+
require 'test/filecreation'
|
7
|
+
require 'test/capture_stdout'
|
8
|
+
|
9
|
+
######################################################################
|
10
|
+
class TestTask < Test::Unit::TestCase
|
11
|
+
include CaptureStdout
|
12
|
+
include Rake
|
13
|
+
|
14
|
+
def setup
|
15
|
+
Task.clear
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_create
|
19
|
+
arg = nil
|
20
|
+
t = task(:name) { |task| arg = task; 1234 }
|
21
|
+
assert_equal "name", t.name
|
22
|
+
assert_equal [], t.prerequisites
|
23
|
+
assert t.needed?
|
24
|
+
t.execute(0)
|
25
|
+
assert_equal t, arg
|
26
|
+
assert_nil t.source
|
27
|
+
assert_equal [], t.sources
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_inspect
|
31
|
+
t = task(:foo, :needs => [:bar, :baz])
|
32
|
+
assert_equal "<Rake::Task foo => [bar, baz]>", t.inspect
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_invoke
|
36
|
+
runlist = []
|
37
|
+
t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 }
|
38
|
+
t2 = task(:t2) { |t| runlist << t.name }
|
39
|
+
t3 = task(:t3) { |t| runlist << t.name }
|
40
|
+
assert_equal ["t2", "t3"], t1.prerequisites
|
41
|
+
t1.invoke
|
42
|
+
assert_equal ["t2", "t3", "t1"], runlist
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_invoke_with_circular_dependencies
|
46
|
+
runlist = []
|
47
|
+
t1 = task(:t1 => [:t2]) { |t| runlist << t.name; 3321 }
|
48
|
+
t2 = task(:t2 => [:t1]) { |t| runlist << t.name }
|
49
|
+
assert_equal ["t2"], t1.prerequisites
|
50
|
+
assert_equal ["t1"], t2.prerequisites
|
51
|
+
ex = assert_raise RuntimeError do
|
52
|
+
t1.invoke
|
53
|
+
end
|
54
|
+
assert_match(/circular dependency/i, ex.message)
|
55
|
+
assert_match(/t1 => t2 => t1/, ex.message)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_dry_run_prevents_actions
|
59
|
+
Rake.application.options.dryrun = true
|
60
|
+
runlist = []
|
61
|
+
t1 = task(:t1) { |t| runlist << t.name; 3321 }
|
62
|
+
out = capture_stdout { t1.invoke }
|
63
|
+
assert_match(/execute .*t1/i, out)
|
64
|
+
assert_match(/dry run/i, out)
|
65
|
+
assert_no_match(/invoke/i, out)
|
66
|
+
assert_equal [], runlist
|
67
|
+
ensure
|
68
|
+
Rake.application.options.dryrun = false
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_tasks_can_be_traced
|
72
|
+
Rake.application.options.trace = true
|
73
|
+
t1 = task(:t1)
|
74
|
+
out = capture_stdout {
|
75
|
+
t1.invoke
|
76
|
+
}
|
77
|
+
assert_match(/invoke t1/i, out)
|
78
|
+
assert_match(/execute t1/i, out)
|
79
|
+
ensure
|
80
|
+
Rake.application.options.trace = false
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_no_double_invoke
|
84
|
+
runlist = []
|
85
|
+
t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 }
|
86
|
+
t2 = task(:t2 => [:t3]) { |t| runlist << t.name }
|
87
|
+
t3 = task(:t3) { |t| runlist << t.name }
|
88
|
+
t1.invoke
|
89
|
+
assert_equal ["t3", "t2", "t1"], runlist
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_can_double_invoke_with_reenable
|
93
|
+
runlist = []
|
94
|
+
t1 = task(:t1) { |t| runlist << t.name }
|
95
|
+
t1.invoke
|
96
|
+
t1.reenable
|
97
|
+
t1.invoke
|
98
|
+
assert_equal ["t1", "t1"], runlist
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_clear
|
102
|
+
t = task("t" => "a") { }
|
103
|
+
t.clear
|
104
|
+
assert t.prerequisites.empty?, "prerequisites should be empty"
|
105
|
+
assert t.actions.empty?, "actions should be empty"
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_clear_prerequisites
|
109
|
+
t = task("t" => ["a", "b"])
|
110
|
+
assert_equal ['a', 'b'], t.prerequisites
|
111
|
+
t.clear_prerequisites
|
112
|
+
assert_equal [], t.prerequisites
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_clear_actions
|
116
|
+
t = task("t") { }
|
117
|
+
t.clear_actions
|
118
|
+
assert t.actions.empty?, "actions should be empty"
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_find
|
122
|
+
task :tfind
|
123
|
+
assert_equal "tfind", Task[:tfind].name
|
124
|
+
ex = assert_raises(RuntimeError) { Task[:leaves] }
|
125
|
+
assert_equal "Don't know how to build task 'leaves'", ex.message
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_defined
|
129
|
+
assert ! Task.task_defined?(:a)
|
130
|
+
task :a
|
131
|
+
assert Task.task_defined?(:a)
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_multi_invocations
|
135
|
+
runs = []
|
136
|
+
p = proc do |t| runs << t.name end
|
137
|
+
task({:t1=>[:t2,:t3]}, &p)
|
138
|
+
task({:t2=>[:t3]}, &p)
|
139
|
+
task(:t3, &p)
|
140
|
+
Task[:t1].invoke
|
141
|
+
assert_equal ["t1", "t2", "t3"], runs.sort
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_task_list
|
145
|
+
task :t2
|
146
|
+
task :t1 => [:t2]
|
147
|
+
assert_equal ["t1", "t2"], Task.tasks.collect {|t| t.name}
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_task_gives_name_on_to_s
|
151
|
+
task :abc
|
152
|
+
assert_equal "abc", Task[:abc].to_s
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_symbols_can_be_prerequisites
|
156
|
+
task :a => :b
|
157
|
+
assert_equal ["b"], Task[:a].prerequisites
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_strings_can_be_prerequisites
|
161
|
+
task :a => "b"
|
162
|
+
assert_equal ["b"], Task[:a].prerequisites
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_arrays_can_be_prerequisites
|
166
|
+
task :a => ["b", "c"]
|
167
|
+
assert_equal ["b", "c"], Task[:a].prerequisites
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_filelists_can_be_prerequisites
|
171
|
+
task :a => FileList.new.include("b", "c")
|
172
|
+
assert_equal ["b", "c"], Task[:a].prerequisites
|
173
|
+
end
|
174
|
+
|
175
|
+
def test_investigation_output
|
176
|
+
t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 }
|
177
|
+
task(:t2)
|
178
|
+
task(:t3)
|
179
|
+
out = t1.investigation
|
180
|
+
assert_match(/class:\s*Rake::Task/, out)
|
181
|
+
assert_match(/needed:\s*true/, out)
|
182
|
+
assert_match(/pre-requisites:\s*--t2/, out)
|
183
|
+
end
|
184
|
+
|
185
|
+
|
186
|
+
def test_extended_comments
|
187
|
+
desc %{
|
188
|
+
This is a comment.
|
189
|
+
|
190
|
+
And this is the extended comment.
|
191
|
+
name -- Name of task to execute.
|
192
|
+
rev -- Software revision to use.
|
193
|
+
}
|
194
|
+
t = task(:t, :name, :rev)
|
195
|
+
assert_equal "[name,rev]", t.arg_description
|
196
|
+
assert_equal "This is a comment.", t.comment
|
197
|
+
assert_match(/^\s*name -- Name/, t.full_comment)
|
198
|
+
assert_match(/^\s*rev -- Software/, t.full_comment)
|
199
|
+
assert_match(/\A\s*This is a comment\.$/, t.full_comment)
|
200
|
+
end
|
201
|
+
|
202
|
+
def test_multiple_comments
|
203
|
+
desc "line one"
|
204
|
+
t = task(:t)
|
205
|
+
desc "line two"
|
206
|
+
task(:t)
|
207
|
+
assert_equal "line one / line two", t.comment
|
208
|
+
end
|
209
|
+
|
210
|
+
def test_settable_comments
|
211
|
+
t = task(:t)
|
212
|
+
t.comment = "HI"
|
213
|
+
assert_equal "HI", t.comment
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
######################################################################
|
218
|
+
class TestTaskWithArguments < Test::Unit::TestCase
|
219
|
+
include CaptureStdout
|
220
|
+
include Rake
|
221
|
+
|
222
|
+
def setup
|
223
|
+
Task.clear
|
224
|
+
end
|
225
|
+
|
226
|
+
def test_no_args_given
|
227
|
+
t = task :t
|
228
|
+
assert_equal [], t.arg_names
|
229
|
+
end
|
230
|
+
|
231
|
+
def test_args_given
|
232
|
+
t = task :t, :a, :b
|
233
|
+
assert_equal [:a, :b], t.arg_names
|
234
|
+
end
|
235
|
+
|
236
|
+
def test_name_and_needs
|
237
|
+
t = task(:t => [:pre])
|
238
|
+
assert_equal "t", t.name
|
239
|
+
assert_equal [], t.arg_names
|
240
|
+
assert_equal ["pre"], t.prerequisites
|
241
|
+
end
|
242
|
+
|
243
|
+
def test_name_and_explicit_needs
|
244
|
+
t = task(:t, :needs => [:pre])
|
245
|
+
assert_equal "t", t.name
|
246
|
+
assert_equal [], t.arg_names
|
247
|
+
assert_equal ["pre"], t.prerequisites
|
248
|
+
end
|
249
|
+
|
250
|
+
def test_name_args_and_explicit_needs
|
251
|
+
t = task(:t, :x, :y, :needs => [:pre])
|
252
|
+
assert_equal "t", t.name
|
253
|
+
assert_equal [:x, :y], t.arg_names
|
254
|
+
assert_equal ["pre"], t.prerequisites
|
255
|
+
end
|
256
|
+
|
257
|
+
def test_illegal_keys_in_task_name_hash
|
258
|
+
assert_raise RuntimeError do
|
259
|
+
t = task(:t, :x, :y => 1, :needs => [:pre])
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
def test_arg_list_is_empty_if_no_args_given
|
264
|
+
t = task(:t) { |tt, args| assert_equal({}, args.to_hash) }
|
265
|
+
t.invoke(1, 2, 3)
|
266
|
+
end
|
267
|
+
|
268
|
+
def test_tasks_can_access_arguments_as_hash
|
269
|
+
t = task :t, :a, :b, :c do |tt, args|
|
270
|
+
assert_equal({:a => 1, :b => 2, :c => 3}, args.to_hash)
|
271
|
+
assert_equal 1, args[:a]
|
272
|
+
assert_equal 2, args[:b]
|
273
|
+
assert_equal 3, args[:c]
|
274
|
+
assert_equal 1, args.a
|
275
|
+
assert_equal 2, args.b
|
276
|
+
assert_equal 3, args.c
|
277
|
+
end
|
278
|
+
t.invoke(1, 2, 3)
|
279
|
+
end
|
280
|
+
|
281
|
+
def test_actions_of_various_arity_are_ok_with_args
|
282
|
+
notes = []
|
283
|
+
t = task(:t, :x) do
|
284
|
+
notes << :a
|
285
|
+
end
|
286
|
+
t.enhance do | |
|
287
|
+
notes << :b
|
288
|
+
end
|
289
|
+
t.enhance do |task|
|
290
|
+
notes << :c
|
291
|
+
assert_kind_of Task, task
|
292
|
+
end
|
293
|
+
t.enhance do |t2, args|
|
294
|
+
notes << :d
|
295
|
+
assert_equal t, t2
|
296
|
+
assert_equal({:x => 1}, args.to_hash)
|
297
|
+
end
|
298
|
+
assert_nothing_raised do t.invoke(1) end
|
299
|
+
assert_equal [:a, :b, :c, :d], notes
|
300
|
+
end
|
301
|
+
|
302
|
+
def test_arguments_are_passed_to_block
|
303
|
+
t = task(:t, :a, :b) { |tt, args|
|
304
|
+
assert_equal( { :a => 1, :b => 2 }, args.to_hash )
|
305
|
+
}
|
306
|
+
t.invoke(1, 2)
|
307
|
+
end
|
308
|
+
|
309
|
+
def test_extra_parameters_are_ignored
|
310
|
+
t = task(:t, :a) { |tt, args|
|
311
|
+
assert_equal 1, args.a
|
312
|
+
assert_nil args.b
|
313
|
+
}
|
314
|
+
t.invoke(1, 2)
|
315
|
+
end
|
316
|
+
|
317
|
+
def test_arguments_are_passed_to_all_blocks
|
318
|
+
counter = 0
|
319
|
+
t = task :t, :a
|
320
|
+
task :t do |tt, args|
|
321
|
+
assert_equal 1, args.a
|
322
|
+
counter += 1
|
323
|
+
end
|
324
|
+
task :t do |tt, args|
|
325
|
+
assert_equal 1, args.a
|
326
|
+
counter += 1
|
327
|
+
end
|
328
|
+
t.invoke(1)
|
329
|
+
assert_equal 2, counter
|
330
|
+
end
|
331
|
+
|
332
|
+
def test_block_with_no_parameters_is_ok
|
333
|
+
t = task(:t) { }
|
334
|
+
t.invoke(1, 2)
|
335
|
+
end
|
336
|
+
|
337
|
+
def test_name_with_args
|
338
|
+
desc "T"
|
339
|
+
t = task(:tt, :a, :b)
|
340
|
+
assert_equal "tt", t.name
|
341
|
+
assert_equal "T", t.comment
|
342
|
+
assert_equal "[a,b]", t.arg_description
|
343
|
+
assert_equal "tt[a,b]", t.name_with_args
|
344
|
+
assert_equal [:a, :b],t.arg_names
|
345
|
+
end
|
346
|
+
|
347
|
+
def test_named_args_are_passed_to_prereqs
|
348
|
+
value = nil
|
349
|
+
pre = task(:pre, :rev) { |t, args| value = args.rev }
|
350
|
+
t = task(:t, :name, :rev, :needs => [:pre])
|
351
|
+
t.invoke("bill", "1.2")
|
352
|
+
assert_equal "1.2", value
|
353
|
+
end
|
354
|
+
|
355
|
+
def test_args_not_passed_if_no_prereq_names
|
356
|
+
pre = task(:pre) { |t, args|
|
357
|
+
assert_equal({}, args.to_hash)
|
358
|
+
assert_equal "bill", args.name
|
359
|
+
}
|
360
|
+
t = task(:t, :name, :rev, :needs => [:pre])
|
361
|
+
t.invoke("bill", "1.2")
|
362
|
+
end
|
363
|
+
|
364
|
+
def test_args_not_passed_if_no_arg_names
|
365
|
+
pre = task(:pre, :rev) { |t, args|
|
366
|
+
assert_equal({}, args.to_hash)
|
367
|
+
}
|
368
|
+
t = task(:t, :needs => [:pre])
|
369
|
+
t.invoke("bill", "1.2")
|
370
|
+
end
|
371
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rake/testtask'
|
5
|
+
|
6
|
+
class TestTestTask < Test::Unit::TestCase
|
7
|
+
include Rake
|
8
|
+
def setup
|
9
|
+
Task.clear
|
10
|
+
ENV.delete('TEST')
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown
|
14
|
+
FileUtils.rm_rf("testdata")
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_no_task
|
18
|
+
assert ! Task.task_defined?(:test)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_defaults
|
22
|
+
tt = Rake::TestTask.new do |t| end
|
23
|
+
assert_not_nil tt
|
24
|
+
assert_equal :test, tt.name
|
25
|
+
assert_equal ['lib'], tt.libs
|
26
|
+
assert_equal 'test/test*.rb', tt.pattern
|
27
|
+
assert_equal false, tt.verbose
|
28
|
+
assert Task.task_defined?(:test)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_non_defaults
|
32
|
+
tt = Rake::TestTask.new(:example) do |t|
|
33
|
+
t.libs = ['src', 'ext']
|
34
|
+
t.pattern = 'test/tc_*.rb'
|
35
|
+
t.verbose = true
|
36
|
+
end
|
37
|
+
assert_not_nil tt
|
38
|
+
assert_equal :example, tt.name
|
39
|
+
assert_equal ['src', 'ext'], tt.libs
|
40
|
+
assert_equal 'test/tc_*.rb', tt.pattern
|
41
|
+
assert_equal true, tt.verbose
|
42
|
+
assert Task.task_defined?(:example)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_pattern
|
46
|
+
tt = Rake::TestTask.new do |t|
|
47
|
+
t.pattern = '*.rb'
|
48
|
+
end
|
49
|
+
assert_equal ['install.rb'], tt.file_list.to_a
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_env_test
|
53
|
+
ENV['TEST'] = 'testfile.rb'
|
54
|
+
tt = Rake::TestTask.new do |t|
|
55
|
+
t.pattern = '*'
|
56
|
+
end
|
57
|
+
assert_equal ["testfile.rb"], tt.file_list.to_a
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_test_files
|
61
|
+
tt = Rake::TestTask.new do |t|
|
62
|
+
t.test_files = FileList['a.rb', 'b.rb']
|
63
|
+
end
|
64
|
+
assert_equal ["a.rb", 'b.rb'], tt.file_list.to_a
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_both_pattern_and_test_files
|
68
|
+
tt = Rake::TestTask.new do |t|
|
69
|
+
t.test_files = FileList['a.rb', 'b.rb']
|
70
|
+
t.pattern = '*.rb'
|
71
|
+
end
|
72
|
+
assert_equal ['a.rb', 'b.rb', 'install.rb'], tt.file_list.to_a
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|