rake 0.9.2 → 0.9.2.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 +13 -0
- data/README.rdoc +12 -15
- data/Rakefile +8 -44
- data/bin/rake +1 -0
- data/lib/rake.rb +4 -0
- data/lib/rake/application.rb +9 -3
- data/lib/rake/classic_namespace.rb +2 -0
- data/lib/rake/clean.rb +1 -0
- data/lib/rake/contrib/publisher.rb +10 -6
- data/lib/rake/contrib/sshpublisher.rb +5 -0
- data/lib/rake/dsl_definition.rb +13 -4
- data/lib/rake/ext/time.rb +3 -3
- data/lib/rake/file_utils.rb +9 -7
- data/lib/rake/file_utils_ext.rb +4 -1
- data/lib/rake/gempackagetask.rb +2 -0
- data/lib/rake/rake_test_loader.rb +15 -6
- data/lib/rake/rdoctask.rb +5 -1
- data/lib/rake/task_arguments.rb +4 -0
- data/lib/rake/version.rb +5 -7
- data/test/file_creation.rb +2 -2
- data/test/helper.rb +460 -12
- data/test/test_rake.rb +3 -1
- data/test/test_rake_application.rb +250 -125
- data/test/test_rake_application_options.rb +146 -193
- data/test/test_rake_clean.rb +2 -0
- data/test/test_rake_definitions.rb +6 -6
- data/test/test_rake_directory_task.rb +26 -35
- data/test/test_rake_dsl.rb +4 -0
- data/test/test_rake_file_creation_task.rb +1 -7
- data/test/test_rake_file_list.rb +128 -133
- data/test/test_rake_file_task.rb +1 -3
- data/test/test_rake_file_utils.rb +123 -70
- data/test/test_rake_functional.rb +234 -252
- data/test/test_rake_makefile_loader.rb +22 -1
- data/test/test_rake_package_task.rb +10 -9
- data/test/test_rake_path_map_explode.rb +3 -0
- data/test/test_rake_pseudo_status.rb +3 -2
- data/test/test_rake_rake_test_loader.rb +21 -0
- data/test/test_rake_rdoc_task.rb +5 -3
- data/test/test_rake_require.rb +8 -3
- data/test/test_rake_rules.rb +56 -75
- data/test/test_rake_task.rb +5 -9
- data/test/test_rake_task_argument_parsing.rb +33 -46
- data/test/test_rake_task_arguments.rb +2 -0
- data/test/test_rake_task_manager.rb +12 -0
- data/test/test_rake_task_with_arguments.rb +11 -0
- data/test/test_rake_test_task.rb +55 -57
- data/test/test_rake_top_level_functions.rb +52 -17
- data/test/test_rake_win32.rb +31 -42
- metadata +6 -52
- data/RRR +0 -9
- data/test/check_expansion.rb +0 -5
- data/test/check_no_expansion.rb +0 -5
- data/test/data/access/Rakefile +0 -35
- data/test/data/chains/Rakefile +0 -15
- data/test/data/comments/Rakefile +0 -18
- data/test/data/default/Rakefile +0 -17
- data/test/data/deprecated_import/Rakefile +0 -1
- data/test/data/dryrun/Rakefile +0 -22
- data/test/data/extra/Rakefile +0 -1
- data/test/data/file_creation_task/Rakefile +0 -31
- data/test/data/imports/Rakefile +0 -19
- data/test/data/imports/deps.mf +0 -1
- data/test/data/multidesc/Rakefile +0 -15
- data/test/data/namespace/Rakefile +0 -64
- data/test/data/rakelib/test1.rb +0 -4
- data/test/data/rbext/rakefile.rb +0 -3
- data/test/data/sample.mf +0 -14
- data/test/data/statusreturn/Rakefile +0 -6
- data/test/data/unittest/Rakefile +0 -1
- data/test/data/verbose/Rakefile +0 -34
- data/test/in_environment.rb +0 -35
- data/test/reqfile.rb +0 -3
- data/test/reqfile2.rb +0 -3
- data/test/shellcommand.rb +0 -3
data/test/test_rake_file_task.rb
CHANGED
@@ -4,47 +4,41 @@ require 'stringio'
|
|
4
4
|
|
5
5
|
class TestRakeFileUtils < Rake::TestCase
|
6
6
|
|
7
|
-
def setup
|
8
|
-
super
|
9
|
-
|
10
|
-
File.chmod(0750, "test/shellcommand.rb")
|
11
|
-
end
|
12
|
-
|
13
7
|
def teardown
|
14
|
-
File.chmod(0755, "test/shellcommand.rb")
|
15
|
-
FileUtils.rm_rf("testdata")
|
16
8
|
FileUtils::LN_SUPPORTED[0] = true
|
9
|
+
RakeFileUtils.verbose_flag = Rake::FileUtilsExt::DEFAULT
|
17
10
|
|
18
11
|
super
|
19
12
|
end
|
20
13
|
|
21
14
|
def test_rm_one_file
|
22
|
-
create_file("
|
23
|
-
FileUtils.rm_rf "
|
24
|
-
|
15
|
+
create_file("a")
|
16
|
+
FileUtils.rm_rf "a"
|
17
|
+
refute File.exist?("a")
|
25
18
|
end
|
26
19
|
|
27
20
|
def test_rm_two_files
|
28
|
-
create_file("
|
29
|
-
create_file("
|
30
|
-
FileUtils.rm_rf ["
|
31
|
-
|
32
|
-
|
21
|
+
create_file("a")
|
22
|
+
create_file("b")
|
23
|
+
FileUtils.rm_rf ["a", "b"]
|
24
|
+
refute File.exist?("a")
|
25
|
+
refute File.exist?("b")
|
33
26
|
end
|
34
27
|
|
35
28
|
def test_rm_filelist
|
36
|
-
list = Rake::FileList.new << "
|
29
|
+
list = Rake::FileList.new << "a" << "b"
|
37
30
|
list.each { |fn| create_file(fn) }
|
38
31
|
FileUtils.rm_r list
|
39
|
-
|
40
|
-
|
32
|
+
refute File.exist?("a")
|
33
|
+
refute File.exist?("b")
|
41
34
|
end
|
42
35
|
|
43
36
|
def test_ln
|
44
|
-
|
45
|
-
|
46
|
-
Rake::FileUtilsExt.safe_ln("
|
47
|
-
|
37
|
+
open("a", "w") { |f| f.puts "TEST_LN" }
|
38
|
+
|
39
|
+
Rake::FileUtilsExt.safe_ln("a", "b", :verbose => false)
|
40
|
+
|
41
|
+
assert_equal "TEST_LN\n", File.read('b')
|
48
42
|
end
|
49
43
|
|
50
44
|
class BadLink
|
@@ -107,9 +101,13 @@ class TestRakeFileUtils < Rake::TestCase
|
|
107
101
|
end
|
108
102
|
|
109
103
|
def test_file_utils_methods_are_available_at_top_level
|
110
|
-
create_file("
|
111
|
-
|
112
|
-
|
104
|
+
create_file("a")
|
105
|
+
|
106
|
+
capture_io do
|
107
|
+
rm_rf "a"
|
108
|
+
end
|
109
|
+
|
110
|
+
refute File.exist?("a")
|
113
111
|
end
|
114
112
|
|
115
113
|
def test_fileutils_methods_dont_leak
|
@@ -119,56 +117,49 @@ class TestRakeFileUtils < Rake::TestCase
|
|
119
117
|
end
|
120
118
|
|
121
119
|
def test_sh
|
122
|
-
|
123
|
-
assert true, "should not fail"
|
124
|
-
end
|
120
|
+
shellcommand
|
125
121
|
|
126
|
-
|
127
|
-
|
128
|
-
# than the kernel version of fail. So we run :sh from within a
|
129
|
-
# non-test class to avoid the problem.
|
130
|
-
class Sh
|
131
|
-
include FileUtils
|
132
|
-
def run(*args)
|
133
|
-
sh(*args)
|
134
|
-
end
|
135
|
-
def self.run(*args)
|
136
|
-
new.run(*args)
|
137
|
-
end
|
138
|
-
def self.ruby(*args)
|
139
|
-
Sh.run(RUBY, *args)
|
140
|
-
end
|
122
|
+
verbose(false) { sh %{#{Rake::TestCase::RUBY} shellcommand.rb} }
|
123
|
+
assert true, "should not fail"
|
141
124
|
end
|
142
125
|
|
143
126
|
def test_sh_with_a_single_string_argument
|
127
|
+
check_expansion
|
128
|
+
|
144
129
|
ENV['RAKE_TEST_SH'] = 'someval'
|
145
130
|
verbose(false) {
|
146
|
-
sh %{#{
|
131
|
+
sh %{#{RUBY} check_expansion.rb #{env_var} someval}
|
147
132
|
}
|
148
133
|
end
|
149
134
|
|
150
135
|
def test_sh_with_multiple_arguments
|
136
|
+
check_no_expansion
|
151
137
|
ENV['RAKE_TEST_SH'] = 'someval'
|
138
|
+
|
152
139
|
verbose(false) {
|
153
|
-
|
140
|
+
sh RUBY, 'check_no_expansion.rb', env_var, 'someval'
|
154
141
|
}
|
155
142
|
end
|
156
143
|
|
157
144
|
def test_sh_failure
|
145
|
+
shellcommand
|
146
|
+
|
158
147
|
assert_raises(RuntimeError) {
|
159
|
-
verbose(false) {
|
148
|
+
verbose(false) { sh %{#{RUBY} shellcommand.rb 1} }
|
160
149
|
}
|
161
150
|
end
|
162
151
|
|
163
152
|
def test_sh_special_handling
|
153
|
+
shellcommand
|
154
|
+
|
164
155
|
count = 0
|
165
156
|
verbose(false) {
|
166
|
-
sh(%{#{
|
157
|
+
sh(%{#{RUBY} shellcommand.rb}) do |ok, res|
|
167
158
|
assert(ok)
|
168
159
|
assert_equal 0, res.exitstatus
|
169
160
|
count += 1
|
170
161
|
end
|
171
|
-
sh(%{#{
|
162
|
+
sh(%{#{RUBY} shellcommand.rb 1}) do |ok, res|
|
172
163
|
assert(!ok)
|
173
164
|
assert_equal 1, res.exitstatus
|
174
165
|
count += 1
|
@@ -178,46 +169,75 @@ class TestRakeFileUtils < Rake::TestCase
|
|
178
169
|
end
|
179
170
|
|
180
171
|
def test_sh_noop
|
181
|
-
|
172
|
+
shellcommand
|
173
|
+
|
174
|
+
verbose(false) { sh %{shellcommand.rb 1}, :noop=>true }
|
182
175
|
assert true, "should not fail"
|
183
176
|
end
|
184
177
|
|
185
178
|
def test_sh_bad_option
|
179
|
+
shellcommand
|
180
|
+
|
186
181
|
ex = assert_raises(ArgumentError) {
|
187
|
-
verbose(false) { sh %{
|
182
|
+
verbose(false) { sh %{shellcommand.rb}, :bad_option=>true }
|
188
183
|
}
|
189
184
|
assert_match(/bad_option/, ex.message)
|
190
185
|
end
|
191
186
|
|
192
187
|
def test_sh_verbose
|
193
|
-
|
188
|
+
shellcommand
|
189
|
+
|
190
|
+
_, err = capture_io do
|
194
191
|
verbose(true) {
|
195
|
-
sh %{
|
192
|
+
sh %{shellcommand.rb}, :noop=>true
|
196
193
|
}
|
197
|
-
|
198
|
-
|
194
|
+
end
|
195
|
+
|
196
|
+
assert_equal "shellcommand.rb\n", err
|
199
197
|
end
|
200
198
|
|
201
|
-
def
|
202
|
-
|
199
|
+
def test_sh_verbose_false
|
200
|
+
shellcommand
|
201
|
+
|
202
|
+
_, err = capture_io do
|
203
203
|
verbose(false) {
|
204
|
-
sh %{
|
204
|
+
sh %{shellcommand.rb}, :noop=>true
|
205
205
|
}
|
206
|
-
|
207
|
-
|
206
|
+
end
|
207
|
+
|
208
|
+
assert_equal '', err
|
209
|
+
end
|
210
|
+
|
211
|
+
def test_sh_verbose_flag_nil
|
212
|
+
shellcommand
|
213
|
+
|
214
|
+
RakeFileUtils.verbose_flag = nil
|
215
|
+
|
216
|
+
assert_silent do
|
217
|
+
sh %{shellcommand.rb}, :noop=>true
|
218
|
+
end
|
208
219
|
end
|
209
220
|
|
210
221
|
def test_ruby_with_a_single_string_argument
|
222
|
+
check_expansion
|
223
|
+
|
211
224
|
ENV['RAKE_TEST_SH'] = 'someval'
|
225
|
+
|
212
226
|
verbose(false) {
|
213
|
-
|
227
|
+
replace_ruby {
|
228
|
+
ruby %{check_expansion.rb #{env_var} someval}
|
229
|
+
}
|
214
230
|
}
|
215
231
|
end
|
216
232
|
|
217
233
|
def test_ruby_with_multiple_arguments
|
234
|
+
check_no_expansion
|
235
|
+
|
218
236
|
ENV['RAKE_TEST_SH'] = 'someval'
|
219
237
|
verbose(false) {
|
220
|
-
|
238
|
+
replace_ruby {
|
239
|
+
ruby 'check_no_expansion.rb', env_var, 'someval'
|
240
|
+
}
|
221
241
|
}
|
222
242
|
end
|
223
243
|
|
@@ -230,23 +250,56 @@ class TestRakeFileUtils < Rake::TestCase
|
|
230
250
|
assert_equal ['..', 'a', 'b'], Rake::FileUtilsExt.split_all('../a/b')
|
231
251
|
end
|
232
252
|
|
233
|
-
|
253
|
+
def command name, text
|
254
|
+
open name, 'w', 0750 do |io|
|
255
|
+
io << text
|
256
|
+
end
|
257
|
+
end
|
234
258
|
|
235
|
-
def
|
236
|
-
|
237
|
-
|
259
|
+
def check_no_expansion
|
260
|
+
command 'check_no_expansion.rb', <<-CHECK_EXPANSION
|
261
|
+
if ARGV[0] != ARGV[1]
|
262
|
+
exit 0
|
263
|
+
else
|
264
|
+
exit 1
|
265
|
+
end
|
266
|
+
CHECK_EXPANSION
|
267
|
+
end
|
268
|
+
|
269
|
+
def check_expansion
|
270
|
+
command 'check_expansion.rb', <<-CHECK_EXPANSION
|
271
|
+
if ARGV[0] != ARGV[1]
|
272
|
+
exit 1
|
273
|
+
else
|
274
|
+
exit 0
|
275
|
+
end
|
276
|
+
CHECK_EXPANSION
|
277
|
+
end
|
278
|
+
|
279
|
+
def replace_ruby
|
280
|
+
ruby = FileUtils::RUBY
|
281
|
+
FileUtils.send :remove_const, :RUBY
|
282
|
+
FileUtils.const_set :RUBY, RUBY
|
238
283
|
yield
|
239
|
-
$stderr.string
|
240
284
|
ensure
|
241
|
-
|
285
|
+
FileUtils.send :remove_const, :RUBY
|
286
|
+
FileUtils.const_set:RUBY, ruby
|
242
287
|
end
|
243
288
|
|
244
|
-
def
|
245
|
-
|
289
|
+
def shellcommand
|
290
|
+
command 'shellcommand.rb', <<-SHELLCOMMAND
|
291
|
+
#!/usr/bin/env ruby
|
292
|
+
|
293
|
+
exit((ARGV[0] || "0").to_i)
|
294
|
+
SHELLCOMMAND
|
246
295
|
end
|
247
296
|
|
248
297
|
def env_var
|
249
298
|
windows? ? '%RAKE_TEST_SH%' : '$RAKE_TEST_SH'
|
250
299
|
end
|
251
300
|
|
301
|
+
def windows?
|
302
|
+
! File::ALT_SEPARATOR.nil?
|
303
|
+
end
|
304
|
+
|
252
305
|
end
|
@@ -1,91 +1,64 @@
|
|
1
|
-
begin
|
2
|
-
old_verbose = $VERBOSE
|
3
|
-
$VERBOSE = nil
|
4
|
-
require 'session'
|
5
|
-
rescue LoadError
|
6
|
-
if File::ALT_SEPARATOR
|
7
|
-
puts "Unable to run functional tests on MS Windows. Skipping."
|
8
|
-
else
|
9
|
-
puts "Unable to run functional tests -- please run \"gem install session\""
|
10
|
-
end
|
11
|
-
ensure
|
12
|
-
$VERBOSE = old_verbose
|
13
|
-
end
|
14
|
-
|
15
|
-
if defined?(Session)
|
16
|
-
if File::ALT_SEPARATOR
|
17
|
-
puts "Unable to run functional tests on MS Windows. Skipping."
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
1
|
require File.expand_path('../helper', __FILE__)
|
22
2
|
require 'fileutils'
|
23
|
-
|
24
|
-
# Version 2.1.9 of session has a bug where the @debug instance
|
25
|
-
# variable is not initialized, causing warning messages. This snippet
|
26
|
-
# of code fixes that problem.
|
27
|
-
module Session
|
28
|
-
class AbstractSession
|
29
|
-
alias old_initialize initialize
|
30
|
-
def initialize(*args)
|
31
|
-
@debug = nil
|
32
|
-
old_initialize(*args)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end if defined? Session
|
3
|
+
require 'open3'
|
36
4
|
|
37
5
|
class TestRakeFunctional < Rake::TestCase
|
38
6
|
|
39
|
-
RUBY_COMMAND = 'ruby'
|
40
|
-
|
41
7
|
def setup
|
42
|
-
super
|
43
|
-
|
44
8
|
@rake_path = File.expand_path("bin/rake")
|
45
9
|
lib_path = File.expand_path("lib")
|
46
10
|
@ruby_options = ["-I#{lib_path}", "-I."]
|
47
|
-
@verbose =
|
11
|
+
@verbose = ENV['VERBOSE']
|
48
12
|
|
49
13
|
if @verbose
|
50
14
|
puts
|
51
15
|
puts
|
52
|
-
puts
|
53
|
-
puts
|
54
|
-
puts
|
16
|
+
puts '-' * 80
|
17
|
+
puts @__name__
|
18
|
+
puts '-' * 80
|
55
19
|
end
|
20
|
+
|
21
|
+
super
|
56
22
|
end
|
57
23
|
|
58
24
|
def test_rake_default
|
59
|
-
|
25
|
+
rakefile_default
|
26
|
+
|
27
|
+
rake
|
28
|
+
|
60
29
|
assert_match(/^DEFAULT$/, @out)
|
61
|
-
assert_status
|
62
30
|
end
|
63
31
|
|
64
32
|
def test_rake_error_on_bad_task
|
65
|
-
|
33
|
+
rakefile_default
|
34
|
+
|
35
|
+
rake '-t', 'xyz'
|
36
|
+
|
66
37
|
assert_match(/rake aborted/, @err)
|
67
|
-
assert_status(1)
|
68
38
|
end
|
69
39
|
|
70
40
|
def test_env_available_at_top_scope
|
71
|
-
|
41
|
+
rakefile_default
|
42
|
+
|
43
|
+
rake "TESTTOPSCOPE=1"
|
44
|
+
|
72
45
|
assert_match(/^TOPSCOPE$/, @out)
|
73
|
-
assert_status
|
74
46
|
end
|
75
47
|
|
76
48
|
def test_env_available_at_task_scope
|
77
|
-
|
49
|
+
rakefile_default
|
50
|
+
|
51
|
+
rake 'TESTTASKSCOPE=1', 'task_scope'
|
52
|
+
|
78
53
|
assert_match(/^TASKSCOPE$/, @out)
|
79
|
-
assert_status
|
80
54
|
end
|
81
55
|
|
82
56
|
def test_multi_desc
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
end
|
57
|
+
ENV['RAKE_COLUMNS'] = '80'
|
58
|
+
rakefile_multidesc
|
59
|
+
|
60
|
+
rake "-T"
|
61
|
+
|
89
62
|
assert_match %r{^rake a *# A / A2 *$}, @out
|
90
63
|
assert_match %r{^rake b *# B *$}, @out
|
91
64
|
refute_match %r{^rake c}, @out
|
@@ -93,9 +66,10 @@ class TestRakeFunctional < Rake::TestCase
|
|
93
66
|
end
|
94
67
|
|
95
68
|
def test_long_description
|
96
|
-
|
97
|
-
|
98
|
-
|
69
|
+
rakefile_multidesc
|
70
|
+
|
71
|
+
rake "--describe"
|
72
|
+
|
99
73
|
assert_match %r{^rake a\n *A / A2 *$}m, @out
|
100
74
|
assert_match %r{^rake b\n *B *$}m, @out
|
101
75
|
assert_match %r{^rake d\n *x{80}}m, @out
|
@@ -103,136 +77,159 @@ class TestRakeFunctional < Rake::TestCase
|
|
103
77
|
end
|
104
78
|
|
105
79
|
def test_proper_namespace_access
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
80
|
+
rakefile_access
|
81
|
+
|
82
|
+
rake
|
83
|
+
|
84
|
+
refute_match %r{^BAD:}, @out
|
110
85
|
end
|
111
86
|
|
112
87
|
def test_rbext
|
113
|
-
|
114
|
-
|
115
|
-
|
88
|
+
rakefile_rbext
|
89
|
+
|
90
|
+
rake "-N"
|
91
|
+
|
116
92
|
assert_match %r{^OK$}, @out
|
117
93
|
end
|
118
94
|
|
119
95
|
def test_system
|
120
|
-
|
121
|
-
|
122
|
-
|
96
|
+
rake_system_dir
|
97
|
+
|
98
|
+
rake '-g', "sys1"
|
99
|
+
|
123
100
|
assert_match %r{^SYS1}, @out
|
124
101
|
end
|
125
102
|
|
126
103
|
def test_system_excludes_rakelib_files_too
|
127
|
-
|
128
|
-
|
129
|
-
|
104
|
+
rake_system_dir
|
105
|
+
|
106
|
+
rake '-g', "sys1", '-T', 'extra'
|
107
|
+
|
130
108
|
refute_match %r{extra:extra}, @out
|
131
109
|
end
|
132
110
|
|
133
111
|
def test_by_default_rakelib_files_are_included
|
134
|
-
|
135
|
-
|
136
|
-
|
112
|
+
rake_system_dir
|
113
|
+
rakefile_extra
|
114
|
+
|
115
|
+
rake '-T', 'extra', '--trace'
|
116
|
+
|
137
117
|
assert_match %r{extra:extra}, @out
|
138
118
|
end
|
139
119
|
|
140
120
|
def test_implicit_system
|
141
|
-
|
142
|
-
|
143
|
-
|
121
|
+
rake_system_dir
|
122
|
+
Dir.chdir @tempdir
|
123
|
+
|
124
|
+
rake "sys1", "--trace"
|
125
|
+
|
144
126
|
assert_match %r{^SYS1}, @out
|
145
127
|
end
|
146
128
|
|
147
129
|
def test_no_system
|
148
|
-
|
149
|
-
|
150
|
-
|
130
|
+
rake_system_dir
|
131
|
+
rakefile_extra
|
132
|
+
|
133
|
+
rake '-G', "sys1"
|
134
|
+
|
151
135
|
assert_match %r{^Don't know how to build task}, @err # emacs wart: '
|
152
136
|
end
|
153
137
|
|
154
138
|
def test_nosearch_with_rakefile_uses_local_rakefile
|
155
|
-
|
156
|
-
|
157
|
-
|
139
|
+
rakefile_default
|
140
|
+
|
141
|
+
rake "--nosearch"
|
142
|
+
|
158
143
|
assert_match %r{^DEFAULT}, @out
|
159
144
|
end
|
160
145
|
|
161
146
|
def test_nosearch_without_rakefile_finds_system
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
end
|
147
|
+
rakefile_nosearch
|
148
|
+
rake_system_dir
|
149
|
+
|
150
|
+
rake "--nosearch", "sys1"
|
151
|
+
|
168
152
|
assert_match %r{^SYS1}, @out
|
169
153
|
end
|
170
154
|
|
171
155
|
def test_nosearch_without_rakefile_and_no_system_fails
|
172
|
-
|
173
|
-
|
174
|
-
|
156
|
+
rakefile_nosearch
|
157
|
+
ENV['RAKE_SYSTEM'] = 'not_exist'
|
158
|
+
|
159
|
+
rake "--nosearch"
|
160
|
+
|
175
161
|
assert_match %r{^No Rakefile found}, @err
|
176
162
|
end
|
177
163
|
|
178
164
|
def test_invalid_command_line_options
|
179
|
-
|
180
|
-
|
181
|
-
|
165
|
+
rakefile_default
|
166
|
+
|
167
|
+
rake "--bad-options"
|
168
|
+
|
182
169
|
assert_match %r{invalid +option}i, @err
|
183
170
|
end
|
184
171
|
|
185
172
|
def test_inline_verbose_default_should_show_command
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
173
|
+
rakefile_verbose
|
174
|
+
|
175
|
+
rake "inline_verbose_default"
|
176
|
+
|
177
|
+
assert_match(/#{Regexp.quote(RUBY)} -e/, @err)
|
190
178
|
end
|
191
179
|
|
192
180
|
def test_inline_verbose_true_should_show_command
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
181
|
+
rakefile_verbose
|
182
|
+
|
183
|
+
rake "inline_verbose_true"
|
184
|
+
|
185
|
+
assert_match(/#{Regexp.quote(RUBY)} -e/, @err)
|
197
186
|
end
|
198
187
|
|
199
188
|
def test_inline_verbose_false_should_not_show_command
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
189
|
+
rakefile_verbose
|
190
|
+
|
191
|
+
rake "inline_verbose_false"
|
192
|
+
|
193
|
+
refute_match(/#{Regexp.quote(RUBY)} -e/, @err)
|
204
194
|
end
|
205
195
|
|
206
196
|
def test_block_verbose_false_should_not_show_command
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
197
|
+
rakefile_verbose
|
198
|
+
|
199
|
+
rake "block_verbose_false"
|
200
|
+
|
201
|
+
refute_match(/#{Regexp.quote(RUBY)} -e/, @err)
|
211
202
|
end
|
212
203
|
|
213
204
|
def test_block_verbose_true_should_show_command
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
205
|
+
rakefile_verbose
|
206
|
+
|
207
|
+
rake "block_verbose_true"
|
208
|
+
|
209
|
+
assert_match(/#{Regexp.quote(RUBY)} -e/, @err)
|
218
210
|
end
|
219
211
|
|
220
212
|
def test_standalone_verbose_true_should_show_command
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
213
|
+
rakefile_verbose
|
214
|
+
|
215
|
+
rake "standalone_verbose_true"
|
216
|
+
|
217
|
+
assert_match(/#{Regexp.quote(RUBY)} -e/, @err)
|
225
218
|
end
|
226
219
|
|
227
220
|
def test_standalone_verbose_false_should_not_show_command
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
221
|
+
rakefile_verbose
|
222
|
+
|
223
|
+
rake "standalone_verbose_false"
|
224
|
+
|
225
|
+
refute_match(/#{Regexp.quote(RUBY)} -e/, @err)
|
232
226
|
end
|
233
227
|
|
234
228
|
def test_dry_run
|
235
|
-
|
229
|
+
rakefile_default
|
230
|
+
|
231
|
+
rake "-n", "other"
|
232
|
+
|
236
233
|
assert_match %r{Execute \(dry run\) default}, @err
|
237
234
|
assert_match %r{Execute \(dry run\) other}, @err
|
238
235
|
refute_match %r{DEFAULT}, @out
|
@@ -241,228 +238,213 @@ class TestRakeFunctional < Rake::TestCase
|
|
241
238
|
|
242
239
|
# Test for the trace/dry_run bug found by Brian Chandler
|
243
240
|
def test_dry_run_bug
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
241
|
+
rakefile_dryrun
|
242
|
+
|
243
|
+
rake
|
244
|
+
|
245
|
+
FileUtils.rm_f 'temp_one'
|
246
|
+
|
247
|
+
rake "--dry-run"
|
248
|
+
|
251
249
|
refute_match(/No such file/, @out)
|
252
|
-
assert_status
|
253
250
|
end
|
254
251
|
|
255
252
|
# Test for the trace/dry_run bug found by Brian Chandler
|
256
253
|
def test_trace_bug
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
254
|
+
rakefile_dryrun
|
255
|
+
|
256
|
+
rake
|
257
|
+
|
258
|
+
FileUtils.rm_f 'temp_one'
|
259
|
+
|
260
|
+
rake "--trace"
|
261
|
+
|
264
262
|
refute_match(/No such file/, @out)
|
265
|
-
assert_status
|
266
263
|
end
|
267
264
|
|
268
265
|
def test_imports
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
end
|
276
|
-
assert File.exist?("test/data/imports/dynamic_deps"),
|
277
|
-
"'dynamic_deps' file should exist"
|
266
|
+
rakefile_imports
|
267
|
+
|
268
|
+
rake
|
269
|
+
|
270
|
+
assert File.exist?(File.join(@tempdir, 'dynamic_deps')),
|
271
|
+
"'dynamic_deps' file should exist"
|
278
272
|
assert_match(/^FIRST$\s+^DYNAMIC$\s+^STATIC$\s+^OTHER$/, @out)
|
279
|
-
assert_status
|
280
|
-
FileUtils.rm_f "test/data/imports/dynamic_deps"
|
281
|
-
FileUtils.rm_f "test/data/imports/static_deps"
|
282
273
|
end
|
283
274
|
|
284
275
|
def test_rules_chaining_to_file_task
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
assert File.exist?(
|
290
|
-
|
291
|
-
assert_status
|
292
|
-
remove_chaining_files
|
276
|
+
rakefile_chains
|
277
|
+
|
278
|
+
rake
|
279
|
+
|
280
|
+
assert File.exist?(File.join(@tempdir, 'play.app')),
|
281
|
+
"'play.app' file should exist"
|
293
282
|
end
|
294
283
|
|
295
284
|
def test_file_creation_task
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
285
|
+
rakefile_file_creation
|
286
|
+
|
287
|
+
rake "prep"
|
288
|
+
rake "run"
|
289
|
+
rake "run"
|
290
|
+
|
301
291
|
assert(@err !~ /^cp src/, "Should not recopy data")
|
302
292
|
end
|
303
293
|
|
304
294
|
def test_dash_f_with_no_arg_foils_rakefile_lookup
|
305
|
-
|
295
|
+
rakefile_rakelib
|
296
|
+
|
297
|
+
rake '-I', 'rakelib', '-rtest1', '-f'
|
298
|
+
|
306
299
|
assert_match(/^TEST1$/, @out)
|
307
300
|
end
|
308
301
|
|
309
302
|
def test_dot_rake_files_can_be_loaded_with_dash_r
|
310
|
-
|
303
|
+
rakefile_rakelib
|
304
|
+
|
305
|
+
rake '-I', 'rakelib', '-rtest2', '-f'
|
306
|
+
|
307
|
+
assert_empty @err
|
311
308
|
assert_match(/^TEST2$/, @out)
|
312
309
|
end
|
313
310
|
|
314
311
|
def test_can_invoke_task_in_toplevel_namespace
|
315
|
-
|
316
|
-
|
317
|
-
|
312
|
+
rakefile_namespace
|
313
|
+
|
314
|
+
rake "copy"
|
315
|
+
|
318
316
|
assert_match(/^COPY$/, @out)
|
319
317
|
end
|
320
318
|
|
321
319
|
def test_can_invoke_task_in_nested_namespace
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
320
|
+
rakefile_namespace
|
321
|
+
|
322
|
+
rake "nest:copy"
|
323
|
+
|
324
|
+
assert_match(/^NEST COPY$/, @out)
|
326
325
|
end
|
327
326
|
|
328
327
|
def test_tasks_can_reference_task_in_same_namespace
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
328
|
+
rakefile_namespace
|
329
|
+
|
330
|
+
rake "nest:xx"
|
331
|
+
|
332
|
+
assert_match(/^NEST COPY$/m, @out)
|
333
333
|
end
|
334
334
|
|
335
335
|
def test_tasks_can_reference_task_in_other_namespaces
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
336
|
+
rakefile_namespace
|
337
|
+
|
338
|
+
rake "b:run"
|
339
|
+
|
340
|
+
assert_match(/^IN A\nIN B$/m, @out)
|
340
341
|
end
|
341
342
|
|
342
343
|
def test_anonymous_tasks_can_be_invoked_indirectly
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
344
|
+
rakefile_namespace
|
345
|
+
|
346
|
+
rake "anon"
|
347
|
+
|
348
|
+
assert_match(/^ANON COPY$/m, @out)
|
347
349
|
end
|
348
350
|
|
349
351
|
def test_rake_namespace_refers_to_toplevel
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
352
|
+
rakefile_namespace
|
353
|
+
|
354
|
+
rake "very:nested:run"
|
355
|
+
|
356
|
+
assert_match(/^COPY$/m, @out)
|
354
357
|
end
|
355
358
|
|
356
359
|
def test_file_task_are_not_scoped_by_namespaces
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
360
|
+
rakefile_namespace
|
361
|
+
|
362
|
+
rake "xyz.rb"
|
363
|
+
|
364
|
+
assert_match(/^XYZ1\nXYZ2$/m, @out)
|
361
365
|
end
|
362
366
|
|
363
367
|
def test_file_task_dependencies_scoped_by_namespaces
|
364
|
-
|
365
|
-
rake "scopedep.rb"
|
366
|
-
assert_match(/^PREPARE\nSCOPEDEP$/m, @out)
|
367
|
-
end
|
368
|
-
ensure
|
369
|
-
remove_namespace_files
|
370
|
-
end
|
368
|
+
rakefile_namespace
|
371
369
|
|
372
|
-
|
373
|
-
in_environment("PWD" => "test/data/statusreturn") do
|
374
|
-
rake "exit5"
|
375
|
-
assert_status(5)
|
376
|
-
end
|
377
|
-
end
|
370
|
+
rake "scopedep.rb"
|
378
371
|
|
379
|
-
|
380
|
-
in_environment("PWD" => "test/data/statusreturn") do
|
381
|
-
rake "normal"
|
382
|
-
assert_status(0)
|
383
|
-
end
|
372
|
+
assert_match(/^PREPARE\nSCOPEDEP$/m, @out)
|
384
373
|
end
|
385
374
|
|
386
375
|
def test_comment_before_task_acts_like_desc
|
387
|
-
|
388
|
-
|
389
|
-
|
376
|
+
rakefile_comments
|
377
|
+
|
378
|
+
rake "-T"
|
379
|
+
|
390
380
|
refute_match(/comment for t1/, @out)
|
391
381
|
end
|
392
382
|
|
393
383
|
def test_comment_separated_from_task_by_blank_line_is_not_picked_up
|
394
|
-
|
395
|
-
|
384
|
+
rakefile_comments
|
385
|
+
|
386
|
+
rake "-T"
|
387
|
+
|
388
|
+
refute_match("t2", @out)
|
396
389
|
end
|
397
390
|
|
398
391
|
def test_comment_after_desc_is_ignored
|
399
|
-
|
392
|
+
rakefile_comments
|
393
|
+
|
394
|
+
rake "-T"
|
395
|
+
|
400
396
|
assert_match("override comment for t3", @out)
|
401
397
|
end
|
402
398
|
|
403
399
|
def test_comment_before_desc_is_ignored
|
404
|
-
|
400
|
+
rakefile_comments
|
401
|
+
|
402
|
+
rake "-T"
|
403
|
+
|
405
404
|
assert_match("override comment for t4", @out)
|
406
405
|
end
|
407
406
|
|
408
407
|
def test_correct_number_of_tasks_reported
|
409
|
-
|
408
|
+
rakefile_comments
|
409
|
+
|
410
|
+
rake "-T"
|
411
|
+
|
410
412
|
assert_equal(2, @out.split(/\n/).grep(/t\d/).size)
|
411
413
|
end
|
412
414
|
|
413
415
|
def test_file_list_is_requirable_separately
|
414
|
-
ruby
|
416
|
+
ruby '-rrake/file_list', '-e', 'puts Rake::FileList["a"].size'
|
415
417
|
assert_equal "1\n", @out
|
416
|
-
assert_equal 0, @status
|
417
418
|
end
|
418
419
|
|
419
420
|
private
|
420
421
|
|
421
|
-
def assert_not_match(pattern, string, comment="'#{pattern}' was found (incorrectly) in '#{string}.inspect")
|
422
|
-
assert_nil Regexp.new(pattern).match(string), comment
|
423
|
-
end
|
424
|
-
|
425
|
-
def remove_chaining_files
|
426
|
-
%w(play.scpt play.app base).each do |fn|
|
427
|
-
FileUtils.rm_f File.join("test/data/chains", fn)
|
428
|
-
end
|
429
|
-
end
|
430
|
-
|
431
|
-
def remove_namespace_files
|
432
|
-
%w(scopedep.rb).each do |fn|
|
433
|
-
FileUtils.rm_f File.join("test/data/namespace", fn)
|
434
|
-
end
|
435
|
-
end
|
436
|
-
|
437
422
|
# Run a shell Ruby command with command line options (using the
|
438
|
-
# default test options). Output is captured in @out
|
439
|
-
# @status.
|
423
|
+
# default test options). Output is captured in @out and @err
|
440
424
|
def ruby(*option_list)
|
441
425
|
run_ruby(@ruby_options + option_list)
|
442
426
|
end
|
443
427
|
|
444
428
|
# Run a command line rake with the give rake options. Default
|
445
429
|
# command line ruby options are included. Output is captured in
|
446
|
-
# @out
|
430
|
+
# @out and @err
|
447
431
|
def rake(*rake_options)
|
448
432
|
run_ruby @ruby_options + [@rake_path] + rake_options
|
449
433
|
end
|
450
434
|
|
451
435
|
# Low level ruby command runner ...
|
452
436
|
def run_ruby(option_list)
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
437
|
+
puts "COMMAND: [#{RUBY} #{option_list.join ' '}]" if @verbose
|
438
|
+
|
439
|
+
inn, out, err = Open3.popen3(Gem.ruby, *option_list)
|
440
|
+
inn.close
|
441
|
+
|
442
|
+
@out = out.read
|
443
|
+
@err = err.read
|
444
|
+
|
459
445
|
puts "OUTPUT: [#{@out}]" if @verbose
|
460
446
|
puts "ERROR: [#{@err}]" if @verbose
|
461
447
|
puts "PWD: [#{Dir.pwd}]" if @verbose
|
462
|
-
shell.close
|
463
448
|
end
|
464
449
|
|
465
|
-
|
466
|
-
assert_equal expected_status, @status
|
467
|
-
end
|
468
|
-
end if defined?(Session)
|
450
|
+
end
|