drake 0.8.1.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +386 -0
- data/MIT-LICENSE +21 -0
- data/README +396 -0
- data/Rakefile +505 -0
- data/TODO +20 -0
- data/bin/drake +31 -0
- data/bin/rake +31 -0
- data/doc/example/Rakefile1 +38 -0
- data/doc/example/Rakefile2 +35 -0
- data/doc/example/a.c +6 -0
- data/doc/example/b.c +6 -0
- data/doc/example/main.c +11 -0
- data/doc/glossary.rdoc +51 -0
- data/doc/jamis.rb +591 -0
- data/doc/proto_rake.rdoc +127 -0
- data/doc/rake.1.gz +0 -0
- data/doc/rakefile.rdoc +534 -0
- data/doc/rational.rdoc +151 -0
- data/doc/release_notes/rake-0.4.14.rdoc +23 -0
- data/doc/release_notes/rake-0.4.15.rdoc +35 -0
- data/doc/release_notes/rake-0.5.0.rdoc +53 -0
- data/doc/release_notes/rake-0.5.3.rdoc +78 -0
- data/doc/release_notes/rake-0.5.4.rdoc +46 -0
- data/doc/release_notes/rake-0.6.0.rdoc +141 -0
- data/doc/release_notes/rake-0.7.0.rdoc +119 -0
- data/doc/release_notes/rake-0.7.1.rdoc +59 -0
- data/doc/release_notes/rake-0.7.2.rdoc +121 -0
- data/doc/release_notes/rake-0.7.3.rdoc +47 -0
- data/doc/release_notes/rake-0.8.0.rdoc +114 -0
- data/doc/release_notes/rake-0.8.2.rdoc +163 -0
- data/install.rb +88 -0
- data/lib/rake.rb +2538 -0
- data/lib/rake/classic_namespace.rb +8 -0
- data/lib/rake/clean.rb +33 -0
- data/lib/rake/comp_tree/algorithm.rb +234 -0
- data/lib/rake/comp_tree/bucket_ipc.rb +175 -0
- data/lib/rake/comp_tree/driver.rb +291 -0
- data/lib/rake/comp_tree/error.rb +51 -0
- data/lib/rake/comp_tree/node.rb +189 -0
- data/lib/rake/comp_tree/quix/builtin/kernel/tap.rb +57 -0
- data/lib/rake/comp_tree/quix/diagnostic.rb +92 -0
- data/lib/rake/comp_tree/quix/kernel.rb +109 -0
- data/lib/rake/comp_tree/retriable_fork.rb +66 -0
- data/lib/rake/comp_tree/task_node.rb +46 -0
- data/lib/rake/contrib/compositepublisher.rb +24 -0
- data/lib/rake/contrib/ftptools.rb +153 -0
- data/lib/rake/contrib/publisher.rb +75 -0
- data/lib/rake/contrib/rubyforgepublisher.rb +18 -0
- data/lib/rake/contrib/sshpublisher.rb +47 -0
- data/lib/rake/contrib/sys.rb +209 -0
- data/lib/rake/gempackagetask.rb +103 -0
- data/lib/rake/loaders/makefile.rb +35 -0
- data/lib/rake/packagetask.rb +185 -0
- data/lib/rake/parallel.rb +54 -0
- data/lib/rake/rake_test_loader.rb +5 -0
- data/lib/rake/rdoctask.rb +147 -0
- data/lib/rake/ruby182_test_unit_fix.rb +23 -0
- data/lib/rake/runtest.rb +23 -0
- data/lib/rake/tasklib.rb +23 -0
- data/lib/rake/testtask.rb +161 -0
- data/test/capture_stdout.rb +26 -0
- data/test/check_expansion.rb +5 -0
- data/test/contrib/test_sys.rb +47 -0
- data/test/data/chains/Rakefile +15 -0
- data/test/data/default/Rakefile +19 -0
- data/test/data/dryrun/Rakefile +22 -0
- data/test/data/file_creation_task/Rakefile +33 -0
- data/test/data/imports/Rakefile +19 -0
- data/test/data/imports/deps.mf +1 -0
- data/test/data/multidesc/Rakefile +17 -0
- data/test/data/namespace/Rakefile +57 -0
- data/test/data/rakelib/test1.rb +3 -0
- data/test/data/rbext/rakefile.rb +3 -0
- data/test/data/sample.mf +12 -0
- data/test/data/statusreturn/Rakefile +8 -0
- data/test/data/unittest/Rakefile +1 -0
- data/test/filecreation.rb +32 -0
- data/test/functional.rb +15 -0
- data/test/in_environment.rb +30 -0
- data/test/parallel.rb +3 -0
- data/test/rake_test_setup.rb +5 -0
- data/test/reqfile.rb +3 -0
- data/test/reqfile2.rb +3 -0
- data/test/session_functional.rb +324 -0
- data/test/shellcommand.rb +3 -0
- data/test/single_threaded.rb +2 -0
- data/test/test_application.rb +714 -0
- data/test/test_clean.rb +14 -0
- data/test/test_definitions.rb +82 -0
- data/test/test_earlytime.rb +35 -0
- data/test/test_extension.rb +63 -0
- data/test/test_file_creation_task.rb +62 -0
- data/test/test_file_task.rb +139 -0
- data/test/test_filelist.rb +618 -0
- data/test/test_fileutils.rb +250 -0
- data/test/test_ftp.rb +59 -0
- data/test/test_invocation_chain.rb +75 -0
- data/test/test_makefile_loader.rb +25 -0
- data/test/test_namespace.rb +36 -0
- data/test/test_package_task.rb +116 -0
- data/test/test_parallel.rb +47 -0
- data/test/test_pathmap.rb +209 -0
- data/test/test_rake.rb +41 -0
- data/test/test_require.rb +33 -0
- data/test/test_rules.rb +348 -0
- data/test/test_task_arguments.rb +89 -0
- data/test/test_task_manager.rb +172 -0
- data/test/test_tasklib.rb +12 -0
- data/test/test_tasks.rb +373 -0
- data/test/test_test_task.rb +75 -0
- data/test/test_top_level_functions.rb +84 -0
- metadata +190 -0
@@ -0,0 +1,250 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rake'
|
4
|
+
require 'test/unit'
|
5
|
+
require 'test/filecreation'
|
6
|
+
require 'fileutils'
|
7
|
+
require 'stringio'
|
8
|
+
|
9
|
+
class TestFileUtils < Test::Unit::TestCase
|
10
|
+
include FileCreation
|
11
|
+
|
12
|
+
def setup
|
13
|
+
File.chmod(0750,"test/shellcommand.rb")
|
14
|
+
end
|
15
|
+
|
16
|
+
def teardown
|
17
|
+
FileUtils.rm_rf("testdata")
|
18
|
+
FileUtils::LN_SUPPORTED[0] = true
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_rm_one_file
|
22
|
+
create_file("testdata/a")
|
23
|
+
FileUtils.rm_rf "testdata/a"
|
24
|
+
assert ! File.exist?("testdata/a")
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_rm_two_files
|
28
|
+
create_file("testdata/a")
|
29
|
+
create_file("testdata/b")
|
30
|
+
FileUtils.rm_rf ["testdata/a", "testdata/b"]
|
31
|
+
assert ! File.exist?("testdata/a")
|
32
|
+
assert ! File.exist?("testdata/b")
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_rm_filelist
|
36
|
+
list = Rake::FileList.new << "testdata/a" << "testdata/b"
|
37
|
+
list.each { |fn| create_file(fn) }
|
38
|
+
FileUtils.rm_r list
|
39
|
+
assert ! File.exist?("testdata/a")
|
40
|
+
assert ! File.exist?("testdata/b")
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_ln
|
44
|
+
create_dir("testdata")
|
45
|
+
open("testdata/a", "w") { |f| f.puts "TEST_LN" }
|
46
|
+
RakeFileUtils.safe_ln("testdata/a", "testdata/b", :verbose => false)
|
47
|
+
assert_equal "TEST_LN\n", open("testdata/b") { |f| f.read }
|
48
|
+
end
|
49
|
+
|
50
|
+
class BadLink
|
51
|
+
include RakeFileUtils
|
52
|
+
attr_reader :cp_args
|
53
|
+
def initialize(klass)
|
54
|
+
@failure_class = klass
|
55
|
+
end
|
56
|
+
def cp(*args)
|
57
|
+
@cp_args = args
|
58
|
+
end
|
59
|
+
def ln(*args)
|
60
|
+
fail @failure_class, "ln not supported"
|
61
|
+
end
|
62
|
+
public :safe_ln
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_safe_ln_failover_to_cp_on_standard_error
|
66
|
+
FileUtils::LN_SUPPORTED[0] = true
|
67
|
+
c = BadLink.new(StandardError)
|
68
|
+
c.safe_ln "a", "b"
|
69
|
+
assert_equal ['a', 'b'], c.cp_args
|
70
|
+
c.safe_ln "x", "y"
|
71
|
+
assert_equal ['x', 'y'], c.cp_args
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_safe_ln_failover_to_cp_on_not_implemented_error
|
75
|
+
FileUtils::LN_SUPPORTED[0] = true
|
76
|
+
c = BadLink.new(NotImplementedError)
|
77
|
+
c.safe_ln "a", "b"
|
78
|
+
assert_equal ['a', 'b'], c.cp_args
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_safe_ln_fails_on_script_error
|
82
|
+
FileUtils::LN_SUPPORTED[0] = true
|
83
|
+
c = BadLink.new(ScriptError)
|
84
|
+
assert_raise(ScriptError) do c.safe_ln "a", "b" end
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_verbose
|
88
|
+
verbose true
|
89
|
+
assert_equal true, verbose
|
90
|
+
verbose false
|
91
|
+
assert_equal false, verbose
|
92
|
+
verbose(true) {
|
93
|
+
assert_equal true, verbose
|
94
|
+
}
|
95
|
+
assert_equal false, verbose
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_nowrite
|
99
|
+
nowrite true
|
100
|
+
assert_equal true, nowrite
|
101
|
+
nowrite false
|
102
|
+
assert_equal false, nowrite
|
103
|
+
nowrite(true){
|
104
|
+
assert_equal true, nowrite
|
105
|
+
}
|
106
|
+
assert_equal false, nowrite
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_file_utils_methods_are_available_at_top_level
|
110
|
+
create_file("testdata/a")
|
111
|
+
rm_rf "testdata/a"
|
112
|
+
assert ! File.exist?("testdata/a")
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_fileutils_methods_dont_leak
|
116
|
+
obj = Object.new
|
117
|
+
assert_raise(NoMethodError) { obj.copy } # from FileUtils
|
118
|
+
assert_raise(NoMethodError) { obj.ruby } # from RubyFileUtils
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_sh
|
122
|
+
verbose(false) { sh %{ruby test/shellcommand.rb} }
|
123
|
+
assert true, "should not fail"
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_sh_multiple_arguments
|
127
|
+
ENV['RAKE_TEST_SH'] = 'someval'
|
128
|
+
expanded = windows? ? '%RAKE_TEST_SH%' : '$RAKE_TEST_SH'
|
129
|
+
# This one gets expanded by the shell
|
130
|
+
verbose(false) { sh %{ruby test/check_expansion.rb #{expanded} someval} }
|
131
|
+
assert true, "should not fail"
|
132
|
+
assert_raises(RuntimeError) {
|
133
|
+
# This one does not get expanded
|
134
|
+
verbose(false) { sh 'ruby', 'test/check_expansion.rb', expanded, 'someval' }
|
135
|
+
}
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_sh_failure
|
139
|
+
assert_raises(RuntimeError) {
|
140
|
+
verbose(false) { sh %{ruby test/shellcommand.rb 1} }
|
141
|
+
}
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_sh_special_handling
|
145
|
+
count = 0
|
146
|
+
verbose(false) {
|
147
|
+
sh(%{ruby test/shellcommand.rb}) do |ok, res|
|
148
|
+
assert(ok)
|
149
|
+
assert_equal 0, res.exitstatus
|
150
|
+
count += 1
|
151
|
+
end
|
152
|
+
sh(%{ruby test/shellcommand.rb 1}) do |ok, res|
|
153
|
+
assert(!ok)
|
154
|
+
assert_equal 1, res.exitstatus
|
155
|
+
count += 1
|
156
|
+
end
|
157
|
+
}
|
158
|
+
assert_equal 2, count, "Block count should be 2"
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_sh_noop
|
162
|
+
verbose(false) { sh %{test/shellcommand.rb 1}, :noop=>true }
|
163
|
+
assert true, "should not fail"
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_sh_bad_option
|
167
|
+
ex = assert_raise(ArgumentError) {
|
168
|
+
verbose(false) { sh %{test/shellcommand.rb}, :bad_option=>true }
|
169
|
+
}
|
170
|
+
assert_match(/bad_option/, ex.message)
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_sh_verbose
|
174
|
+
out = redirect_stderr {
|
175
|
+
verbose(true) {
|
176
|
+
sh %{test/shellcommand.rb}, :noop=>true
|
177
|
+
}
|
178
|
+
}
|
179
|
+
assert_match(/^test\/shellcommand\.rb$/, out)
|
180
|
+
end
|
181
|
+
|
182
|
+
def test_sh_no_verbose
|
183
|
+
out = redirect_stderr {
|
184
|
+
verbose(false) {
|
185
|
+
sh %{test/shellcommand.rb}, :noop=>true
|
186
|
+
}
|
187
|
+
}
|
188
|
+
assert_equal '', out
|
189
|
+
end
|
190
|
+
|
191
|
+
def test_sh_default_is_no_verbose
|
192
|
+
out = redirect_stderr {
|
193
|
+
sh %{test/shellcommand.rb}, :noop=>true
|
194
|
+
}
|
195
|
+
assert_equal '', out
|
196
|
+
end
|
197
|
+
|
198
|
+
def test_ruby
|
199
|
+
verbose(false) do
|
200
|
+
ENV['RAKE_TEST_RUBY'] = "123"
|
201
|
+
block_run = false
|
202
|
+
# This one gets expanded by the shell
|
203
|
+
env_var = windows? ? '%RAKE_TEST_RUBY%' : '$RAKE_TEST_RUBY'
|
204
|
+
ruby %{-e "exit #{env_var}"} do |ok, status| # " (emacs wart)
|
205
|
+
assert(!ok)
|
206
|
+
assert_equal 123, status.exitstatus
|
207
|
+
block_run = true
|
208
|
+
end
|
209
|
+
assert block_run, "The block must be run"
|
210
|
+
|
211
|
+
if windows?
|
212
|
+
puts "SKIPPING test_ruby/part 2 when in windows"
|
213
|
+
else
|
214
|
+
# This one does not get expanded
|
215
|
+
block_run = false
|
216
|
+
ruby '-e', %{exit "#{env_var}".length} do |ok, status| # " (emacs wart)
|
217
|
+
assert(!ok)
|
218
|
+
assert_equal 15, status.exitstatus
|
219
|
+
block_run = true
|
220
|
+
end
|
221
|
+
assert block_run, "The block must be run"
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
def test_split_all
|
227
|
+
assert_equal ['a'], RakeFileUtils.split_all('a')
|
228
|
+
assert_equal ['..'], RakeFileUtils.split_all('..')
|
229
|
+
assert_equal ['/'], RakeFileUtils.split_all('/')
|
230
|
+
assert_equal ['a', 'b'], RakeFileUtils.split_all('a/b')
|
231
|
+
assert_equal ['/', 'a', 'b'], RakeFileUtils.split_all('/a/b')
|
232
|
+
assert_equal ['..', 'a', 'b'], RakeFileUtils.split_all('../a/b')
|
233
|
+
end
|
234
|
+
|
235
|
+
private
|
236
|
+
|
237
|
+
def redirect_stderr
|
238
|
+
old_err = $stderr
|
239
|
+
$stderr = StringIO.new
|
240
|
+
yield
|
241
|
+
$stderr.string
|
242
|
+
ensure
|
243
|
+
$stderr = old_err
|
244
|
+
end
|
245
|
+
|
246
|
+
def windows?
|
247
|
+
! File::ALT_SEPARATOR.nil?
|
248
|
+
end
|
249
|
+
|
250
|
+
end
|
data/test/test_ftp.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
require 'time'
|
5
|
+
require 'test/unit'
|
6
|
+
require 'rake/contrib/ftptools'
|
7
|
+
|
8
|
+
class FakeDate
|
9
|
+
def self.today
|
10
|
+
Date.new(2003,10,3)
|
11
|
+
end
|
12
|
+
def self.now
|
13
|
+
Time.local(2003,10,3,12,00,00)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
class TestFtpFile < Test::Unit::TestCase
|
19
|
+
|
20
|
+
def setup
|
21
|
+
Rake::FtpFile.class_eval { @date_class = FakeDate; @time_class = FakeDate }
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_general
|
25
|
+
file = Rake::FtpFile.new("here", "-rw-r--r-- 1 a279376 develop 121770 Mar 6 14:50 wiki.pl")
|
26
|
+
assert_equal "wiki.pl", file.name
|
27
|
+
assert_equal "here/wiki.pl", file.path
|
28
|
+
assert_equal "a279376", file.owner
|
29
|
+
assert_equal "develop", file.group
|
30
|
+
assert_equal 0644, file.mode
|
31
|
+
assert_equal 121770, file.size
|
32
|
+
assert_equal Time.mktime(2003,3,6,14,50,0,0), file.time
|
33
|
+
assert ! file.directory?
|
34
|
+
assert ! file.symlink?
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_far_date
|
38
|
+
file = Rake::FtpFile.new(".", "drwxr-xr-x 3 a279376 develop 4096 Nov 26 2001 vss")
|
39
|
+
assert_equal Time.mktime(2001,11,26,0,0,0,0), file.time
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_close_date
|
43
|
+
file = Rake::FtpFile.new(".", "drwxr-xr-x 3 a279376 develop 4096 Nov 26 15:35 vss")
|
44
|
+
assert_equal Time.mktime(2002,11,26,15,35,0,0), file.time
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_directory
|
48
|
+
file = Rake::FtpFile.new(".", "drwxrwxr-x 9 a279376 develop 4096 Mar 13 14:32 working")
|
49
|
+
assert file.directory?
|
50
|
+
assert !file.symlink?
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_symlink
|
54
|
+
file = Rake::FtpFile.new(".", "lrwxrwxrwx 1 a279376 develop 64 Mar 26 2002 xtrac -> /home/a279376/working/ics/development/java/com/fmr/fwp/ics/xtrac")
|
55
|
+
assert_equal 'xtrac', file.name
|
56
|
+
assert file.symlink?
|
57
|
+
assert !file.directory?
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rake'
|
5
|
+
|
6
|
+
######################################################################
|
7
|
+
class TestAnEmptyInvocationChain < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@empty = Rake::InvocationChain::EMPTY
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_should_be_able_to_add_members
|
14
|
+
assert_nothing_raised do
|
15
|
+
@empty.append("A")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_to_s
|
20
|
+
assert_equal "TOP", @empty.to_s
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
######################################################################
|
25
|
+
class TestAnInvocationChainWithOneMember < Test::Unit::TestCase
|
26
|
+
def setup
|
27
|
+
@empty = Rake::InvocationChain::EMPTY
|
28
|
+
@first_member = "A"
|
29
|
+
@chain = @empty.append(@first_member)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_should_report_first_member_as_a_member
|
33
|
+
assert @chain.member?(@first_member)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_should_fail_when_adding_original_member
|
37
|
+
ex = assert_raise RuntimeError do
|
38
|
+
@chain.append(@first_member)
|
39
|
+
end
|
40
|
+
assert_match(/circular +dependency/i, ex.message)
|
41
|
+
assert_match(/A.*=>.*A/, ex.message)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_to_s
|
45
|
+
assert_equal "TOP => A", @chain.to_s
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
######################################################################
|
51
|
+
class TestAnInvocationChainWithMultipleMember < Test::Unit::TestCase
|
52
|
+
def setup
|
53
|
+
@first_member = "A"
|
54
|
+
@second_member = "B"
|
55
|
+
ch = Rake::InvocationChain::EMPTY.append(@first_member)
|
56
|
+
@chain = ch.append(@second_member)
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_should_report_first_member_as_a_member
|
60
|
+
assert @chain.member?(@first_member)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_should_report_second_member_as_a_member
|
64
|
+
assert @chain.member?(@second_member)
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_should_fail_when_adding_original_member
|
68
|
+
ex = assert_raise RuntimeError do
|
69
|
+
@chain.append(@first_member)
|
70
|
+
end
|
71
|
+
assert_match(/A.*=>.*B.*=>.*A/, ex.message)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rake'
|
5
|
+
require 'rake/loaders/makefile'
|
6
|
+
|
7
|
+
class TestMakefileLoader < Test::Unit::TestCase
|
8
|
+
include Rake
|
9
|
+
|
10
|
+
def test_parse
|
11
|
+
Task.clear
|
12
|
+
loader = Rake::MakefileLoader.new
|
13
|
+
loader.load("test/data/sample.mf")
|
14
|
+
%w(a b c d).each do |t|
|
15
|
+
assert Task.task_defined?(t), "#{t} should be a defined task"
|
16
|
+
end
|
17
|
+
assert_equal %w(a1 a2 a3 a4 a5 a6 a7).sort, Task['a'].prerequisites.sort
|
18
|
+
assert_equal %w(b1 b2 b3 b4 b5 b6 b7).sort, Task['b'].prerequisites.sort
|
19
|
+
assert_equal %w(c1).sort, Task['c'].prerequisites.sort
|
20
|
+
assert_equal %w(d1 d2).sort, Task['d'].prerequisites.sort
|
21
|
+
assert_equal %w(e1 f1).sort, Task['e'].prerequisites.sort
|
22
|
+
assert_equal %w(e1 f1).sort, Task['f'].prerequisites.sort
|
23
|
+
assert_equal 6, Task.tasks.size
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
begin
|
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
|
+
|
13
|
+
class TestNameSpace < Test::Unit::TestCase
|
14
|
+
|
15
|
+
def test_namespace_creation
|
16
|
+
mgr = flexmock("TaskManager")
|
17
|
+
ns = Rake::NameSpace.new(mgr, [])
|
18
|
+
assert_not_nil ns
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_namespace_lookup
|
22
|
+
mgr = flexmock("TaskManager")
|
23
|
+
mgr.should_receive(:lookup).with(:t, ["a"]).
|
24
|
+
and_return(:dummy).once
|
25
|
+
ns = Rake::NameSpace.new(mgr, ["a"])
|
26
|
+
assert_equal :dummy, ns[:t]
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_namespace_reports_tasks_it_owns
|
30
|
+
mgr = flexmock("TaskManager")
|
31
|
+
mgr.should_receive(:tasks).with().
|
32
|
+
and_return([:x, :y, :z]).once
|
33
|
+
ns = Rake::NameSpace.new(mgr, ["a"])
|
34
|
+
assert_equal [:x, :y, :z], ns.tasks
|
35
|
+
end
|
36
|
+
end
|