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.

Files changed (66) hide show
  1. data/CHANGES +9 -8
  2. data/RRR +10 -0
  3. data/Rakefile +9 -45
  4. data/bin/rake +4 -3
  5. data/doc/release_notes/rake-0.9.1.rdoc +52 -0
  6. data/lib/rake/dsl_definition.rb +19 -0
  7. data/lib/rake/version.rb +1 -1
  8. data/test/data/access/Rakefile +3 -1
  9. data/test/data/default/Rakefile +0 -2
  10. data/test/data/file_creation_task/Rakefile +0 -2
  11. data/test/data/multidesc/Rakefile +0 -2
  12. data/test/data/namespace/Rakefile +0 -2
  13. data/test/data/statusreturn/Rakefile +0 -2
  14. data/test/file_creation.rb +0 -2
  15. data/test/helper.rb +44 -0
  16. data/test/in_environment.rb +4 -1
  17. data/test/{lib/rake_test.rb → test_rake.rb} +2 -5
  18. data/test/test_rake_application.rb +364 -0
  19. data/test/test_rake_application_options.rb +382 -0
  20. data/test/{lib/clean_test.rb → test_rake_clean.rb} +2 -5
  21. data/test/{lib/definitions_test.rb → test_rake_definitions.rb} +5 -10
  22. data/test/test_rake_directory_task.rb +55 -0
  23. data/test/test_rake_dsl.rb +53 -0
  24. data/test/{lib/earlytime_test.rb → test_rake_early_time.rb} +2 -5
  25. data/test/{lib/extension_test.rb → test_rake_extension.rb} +2 -6
  26. data/test/{lib/file_creation_task_test.rb → test_rake_file_creation_task.rb} +7 -7
  27. data/test/{lib/filelist_test.rb → test_rake_file_list.rb} +18 -22
  28. data/test/test_rake_file_list_path_map.rb +8 -0
  29. data/test/{lib/file_task_test.rb → test_rake_file_task.rb} +22 -61
  30. data/test/{lib/fileutils_test.rb → test_rake_file_utils.rb} +11 -15
  31. data/test/{lib/ftp_test.rb → test_rake_ftp_file.rb} +5 -5
  32. data/test/{functional/session_based_tests.rb → test_rake_functional.rb} +35 -24
  33. data/test/test_rake_invocation_chain.rb +52 -0
  34. data/test/{lib/makefile_loader_test.rb → test_rake_makefile_loader.rb} +2 -5
  35. data/test/{lib/multitask_test.rb → test_rake_multi_task.rb} +5 -7
  36. data/test/{lib/namespace_test.rb → test_rake_name_space.rb} +4 -16
  37. data/test/{lib/package_task_test.rb → test_rake_package_task.rb} +2 -6
  38. data/test/{lib/pathmap_test.rb → test_rake_path_map.rb} +4 -58
  39. data/test/test_rake_path_map_explode.rb +31 -0
  40. data/test/test_rake_path_map_partial.rb +18 -0
  41. data/test/{lib/pseudo_status_test.rb → test_rake_pseudo_status.rb} +2 -8
  42. data/test/{lib/rdoc_task_test.rb → test_rake_rdoc_task.rb} +4 -7
  43. data/test/{lib/require_test.rb → test_rake_require.rb} +3 -9
  44. data/test/{lib/rules_test.rb → test_rake_rules.rb} +11 -13
  45. data/test/{lib/task_test.rb → test_rake_task.rb} +16 -182
  46. data/test/test_rake_task_argument_parsing.rb +116 -0
  47. data/test/{lib/task_arguments_test.rb → test_rake_task_arguments.rb} +2 -5
  48. data/test/{lib/tasklib_test.rb → test_rake_task_lib.rb} +2 -5
  49. data/test/{lib/task_manager_test.rb → test_rake_task_manager.rb} +7 -45
  50. data/test/test_rake_task_manager_argument_resolution.rb +36 -0
  51. data/test/test_rake_task_with_arguments.rb +162 -0
  52. data/test/{lib/test_task_test.rb → test_rake_test_task.rb} +52 -7
  53. data/test/{lib/top_level_functions_test.rb → test_rake_top_level_functions.rb} +8 -20
  54. data/test/{lib/win32_test.rb → test_rake_win32.rb} +4 -12
  55. data/test/{contrib/test_sys.rb → test_sys.rb} +2 -6
  56. metadata +60 -44
  57. data/lib/rake/dsl.rb +0 -2
  58. data/test/capture_stdout.rb +0 -26
  59. data/test/functional/functional_test.rb +0 -25
  60. data/test/lib/application_test.rb +0 -863
  61. data/test/lib/dsl_test.rb +0 -52
  62. data/test/lib/invocation_chain_test.rb +0 -81
  63. data/test/lib/testtask_test.rb +0 -49
  64. data/test/rake_test_setup.rb +0 -20
  65. data/test/ruby_version_test.rb +0 -3
  66. data/test/test_helper.rb +0 -19
@@ -0,0 +1,382 @@
1
+ require File.expand_path('../helper', __FILE__)
2
+
3
+ TESTING_REQUIRE = [ ]
4
+
5
+ class TestRakeApplicationOptions < Rake::TestCase
6
+
7
+ def setup
8
+ super
9
+
10
+ clear_argv
11
+ Rake::FileUtilsExt.verbose_flag = false
12
+ Rake::FileUtilsExt.nowrite_flag = false
13
+ TESTING_REQUIRE.clear
14
+ end
15
+
16
+ def teardown
17
+ clear_argv
18
+ Rake::FileUtilsExt.verbose_flag = false
19
+ Rake::FileUtilsExt.nowrite_flag = false
20
+
21
+ super
22
+ end
23
+
24
+ def clear_argv
25
+ while ! ARGV.empty?
26
+ ARGV.pop
27
+ end
28
+ end
29
+
30
+ def test_default_options
31
+ in_environment("RAKEOPT" => nil) do
32
+ opts = command_line
33
+ assert_nil opts.classic_namespace
34
+ assert_nil opts.dryrun
35
+ assert_nil opts.ignore_system
36
+ assert_nil opts.load_system
37
+ assert_nil opts.nosearch
38
+ assert_equal ['rakelib'], opts.rakelib
39
+ assert_nil opts.show_prereqs
40
+ assert_nil opts.show_task_pattern
41
+ assert_nil opts.show_tasks
42
+ assert_nil opts.silent
43
+ assert_nil opts.trace
44
+ assert_equal ['rakelib'], opts.rakelib
45
+ assert ! Rake::FileUtilsExt.verbose_flag
46
+ assert ! Rake::FileUtilsExt.nowrite_flag
47
+ end
48
+ end
49
+
50
+ def test_dry_run
51
+ in_environment do
52
+ flags('--dry-run', '-n') do |opts|
53
+ assert opts.dryrun
54
+ assert opts.trace
55
+ assert Rake::FileUtilsExt.verbose_flag
56
+ assert Rake::FileUtilsExt.nowrite_flag
57
+ end
58
+ end
59
+ end
60
+
61
+ def test_describe
62
+ in_environment do
63
+ flags('--describe') do |opts|
64
+ assert_equal :describe, opts.show_tasks
65
+ assert_equal(//.to_s, opts.show_task_pattern.to_s)
66
+ end
67
+ end
68
+ end
69
+
70
+ def test_describe_with_pattern
71
+ in_environment do
72
+ flags('--describe=X') do |opts|
73
+ assert_equal :describe, opts.show_tasks
74
+ assert_equal(/X/.to_s, opts.show_task_pattern.to_s)
75
+ end
76
+ end
77
+ end
78
+
79
+ def test_execute
80
+ in_environment do
81
+ $xyzzy = 0
82
+ flags('--execute=$xyzzy=1', '-e $xyzzy=1') do |opts|
83
+ assert_equal 1, $xyzzy
84
+ assert_equal :exit, @exit
85
+ $xyzzy = 0
86
+ end
87
+ end
88
+ end
89
+
90
+ def test_execute_and_continue
91
+ in_environment do
92
+ $xyzzy = 0
93
+ flags('--execute-continue=$xyzzy=1', '-E $xyzzy=1') do |opts|
94
+ assert_equal 1, $xyzzy
95
+ refute_equal :exit, @exit
96
+ $xyzzy = 0
97
+ end
98
+ end
99
+ end
100
+
101
+ def test_execute_and_print
102
+ in_environment do
103
+ $xyzzy = 0
104
+ out, = capture_io do
105
+ flags('--execute-print=$xyzzy="pugh"', '-p $xyzzy="pugh"') do |opts|
106
+ assert_equal 'pugh', $xyzzy
107
+ assert_equal :exit, @exit
108
+ $xyzzy = 0
109
+ end
110
+ end
111
+
112
+ assert_match(/^pugh$/, out)
113
+ end
114
+ end
115
+
116
+ def test_help
117
+ in_environment do
118
+ out, = capture_io do
119
+ flags '--help', '-H', '-h'
120
+ end
121
+
122
+ assert_match(/\Arake/, out)
123
+ assert_match(/\boptions\b/, out)
124
+ assert_match(/\btargets\b/, out)
125
+ assert_equal :exit, @exit
126
+ end
127
+ end
128
+
129
+ def test_libdir
130
+ in_environment do
131
+ flags(['--libdir', 'xx'], ['-I', 'xx'], ['-Ixx']) do |opts|
132
+ $:.include?('xx')
133
+ end
134
+ end
135
+ ensure
136
+ $:.delete('xx')
137
+ end
138
+
139
+ def test_rakefile
140
+ in_environment do
141
+ flags(['--rakefile', 'RF'], ['--rakefile=RF'], ['-f', 'RF'], ['-fRF']) do |opts|
142
+ assert_equal ['RF'], @app.instance_eval { @rakefiles }
143
+ end
144
+ end
145
+ end
146
+
147
+ def test_rakelib
148
+ in_environment do
149
+ flags(['--rakelibdir', 'A:B:C'], ['--rakelibdir=A:B:C'], ['-R', 'A:B:C'], ['-RA:B:C']) do |opts|
150
+ assert_equal ['A', 'B', 'C'], opts.rakelib
151
+ end
152
+ end
153
+ end
154
+
155
+ def test_require
156
+ in_environment do
157
+ flags(['--require', 'test/reqfile'], '-rtest/reqfile2', '-rtest/reqfile3') do |opts|
158
+ end
159
+ assert TESTING_REQUIRE.include?(1)
160
+ assert TESTING_REQUIRE.include?(2)
161
+ assert TESTING_REQUIRE.include?(3)
162
+ assert_equal 3, TESTING_REQUIRE.size
163
+ end
164
+ end
165
+
166
+ def test_missing_require
167
+ in_environment do
168
+ ex = assert_raises(LoadError) do
169
+ flags(['--require', 'test/missing']) do |opts|
170
+ end
171
+ end
172
+ assert_match(/such file/, ex.message)
173
+ assert_match(/test\/missing/, ex.message)
174
+ end
175
+ end
176
+
177
+ def test_prereqs
178
+ in_environment do
179
+ flags('--prereqs', '-P') do |opts|
180
+ assert opts.show_prereqs
181
+ end
182
+ end
183
+ end
184
+
185
+ def test_quiet
186
+ in_environment do
187
+ flags('--quiet', '-q') do |opts|
188
+ assert ! Rake::FileUtilsExt.verbose_flag
189
+ assert ! opts.silent
190
+ end
191
+ end
192
+ end
193
+
194
+ def test_no_search
195
+ in_environment do
196
+ flags('--nosearch', '--no-search', '-N') do |opts|
197
+ assert opts.nosearch
198
+ end
199
+ end
200
+ end
201
+
202
+ def test_silent
203
+ in_environment do
204
+ flags('--silent', '-s') do |opts|
205
+ assert ! Rake::FileUtilsExt.verbose_flag
206
+ assert opts.silent
207
+ end
208
+ end
209
+ end
210
+
211
+ def test_system
212
+ in_environment do
213
+ flags('--system', '-g') do |opts|
214
+ assert opts.load_system
215
+ end
216
+ end
217
+ end
218
+
219
+ def test_no_system
220
+ in_environment do
221
+ flags('--no-system', '-G') do |opts|
222
+ assert opts.ignore_system
223
+ end
224
+ end
225
+ end
226
+
227
+ def test_trace
228
+ in_environment do
229
+ flags('--trace', '-t') do |opts|
230
+ assert opts.trace
231
+ assert Rake::FileUtilsExt.verbose_flag
232
+ assert ! Rake::FileUtilsExt.nowrite_flag
233
+ end
234
+ end
235
+ end
236
+
237
+ def test_trace_rules
238
+ in_environment do
239
+ flags('--rules') do |opts|
240
+ assert opts.trace_rules
241
+ end
242
+ end
243
+ end
244
+
245
+ def test_tasks
246
+ in_environment do
247
+ flags('--tasks', '-T') do |opts|
248
+ assert_equal :tasks, opts.show_tasks
249
+ assert_equal(//.to_s, opts.show_task_pattern.to_s)
250
+ end
251
+ flags(['--tasks', 'xyz'], ['-Txyz']) do |opts|
252
+ assert_equal :tasks, opts.show_tasks
253
+ assert_equal(/xyz/.to_s, opts.show_task_pattern.to_s)
254
+ end
255
+ end
256
+ end
257
+
258
+ def test_where
259
+ in_environment do
260
+ flags('--where', '-W') do |opts|
261
+ assert_equal :lines, opts.show_tasks
262
+ assert_equal(//.to_s, opts.show_task_pattern.to_s)
263
+ end
264
+ flags(['--where', 'xyz'], ['-Wxyz']) do |opts|
265
+ assert_equal :lines, opts.show_tasks
266
+ assert_equal(/xyz/.to_s, opts.show_task_pattern.to_s)
267
+ end
268
+ end
269
+ end
270
+
271
+ def test_no_deprecated_messages
272
+ in_environment do
273
+ flags('--no-deprecation-warnings', '-X') do |opts|
274
+ assert opts.ignore_deprecate
275
+ end
276
+ end
277
+ end
278
+
279
+ def test_verbose
280
+ in_environment do
281
+ out, = capture_io do
282
+ flags('--verbose', '-V') do |opts|
283
+ assert Rake::FileUtilsExt.verbose_flag
284
+ assert ! opts.silent
285
+ end
286
+ end
287
+
288
+ assert_equal "rake, version #{Rake::VERSION}\n", out
289
+ end
290
+ end
291
+
292
+ def test_version
293
+ in_environment do
294
+ out, = capture_io do
295
+ flags '--version', '-V'
296
+ end
297
+
298
+ assert_match(/\bversion\b/, out)
299
+ assert_match(/\b#{RAKEVERSION}\b/, out)
300
+ assert_equal :exit, @exit
301
+ end
302
+ end
303
+
304
+ def test_classic_namespace
305
+ in_environment do
306
+ _, err = capture_io do
307
+ flags(['--classic-namespace'],
308
+ ['-C', '-T', '-P', '-n', '-s', '-t']) do |opts|
309
+ assert opts.classic_namespace
310
+ assert_equal opts.show_tasks, $show_tasks
311
+ assert_equal opts.show_prereqs, $show_prereqs
312
+ assert_equal opts.trace, $trace
313
+ assert_equal opts.dryrun, $dryrun
314
+ assert_equal opts.silent, $silent
315
+ end
316
+ end
317
+
318
+ assert_match(/deprecated/, err)
319
+ end
320
+ end
321
+
322
+ def test_bad_option
323
+ in_environment do
324
+ _, err = capture_io do
325
+ ex = assert_raises(OptionParser::InvalidOption) do
326
+ flags('--bad-option')
327
+ end
328
+ if ex.message =~ /^While/ # Ruby 1.9 error message
329
+ assert_match(/while parsing/i, ex.message)
330
+ else # Ruby 1.8 error message
331
+ assert_match(/(invalid|unrecognized) option/i, ex.message)
332
+ assert_match(/--bad-option/, ex.message)
333
+ end
334
+ end
335
+ assert_equal '', err
336
+ end
337
+ end
338
+
339
+ def test_task_collection
340
+ command_line("a", "b")
341
+ assert_equal ["a", "b"], @tasks.sort
342
+ end
343
+
344
+ def test_default_task_collection
345
+ command_line()
346
+ assert_equal ["default"], @tasks
347
+ end
348
+
349
+ def test_environment_definition
350
+ ENV.delete('TESTKEY')
351
+ command_line("a", "TESTKEY=12")
352
+ assert_equal ["a"], @tasks.sort
353
+ assert '12', ENV['TESTKEY']
354
+ end
355
+
356
+ private
357
+
358
+ def flags(*sets)
359
+ sets.each do |set|
360
+ ARGV.clear
361
+
362
+ @exit = catch(:system_exit) { command_line(*set) }
363
+
364
+ yield(@app.options) if block_given?
365
+ end
366
+ end
367
+
368
+ def command_line(*options)
369
+ options.each do |opt| ARGV << opt end
370
+ @app = Rake::Application.new
371
+ def @app.exit(*args)
372
+ throw :system_exit, :exit
373
+ end
374
+ @app.instance_eval do
375
+ handle_options
376
+ collect_tasks
377
+ end
378
+ @tasks = @app.top_level_tasks
379
+ @app.options
380
+ end
381
+ end
382
+
@@ -1,10 +1,7 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'test/unit'
4
- require 'rake'
1
+ require File.expand_path('../helper', __FILE__)
5
2
  require 'rake/clean'
6
3
 
7
- class TestClean < Test::Unit::TestCase
4
+ class TestRakeClean < Rake::TestCase
8
5
  include Rake
9
6
  def test_clean
10
7
  assert Task['clean'], "Should define clean"
@@ -1,19 +1,14 @@
1
- #!/usr/bin/env ruby
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
- ######################################################################
10
- class TestDefinitions < Test::Unit::TestCase
4
+ class TestRakeDefinitions < Rake::TestCase
11
5
  include Rake
12
- include TestMethods
13
6
 
14
7
  EXISTINGFILE = "testdata/existing"
15
8
 
16
9
  def setup
10
+ super
11
+
17
12
  Task.clear
18
13
  end
19
14
 
@@ -61,7 +56,7 @@ class TestDefinitions < Test::Unit::TestCase
61
56
 
62
57
  def test_missing_dependencies
63
58
  task :x => ["testdata/missing"]
64
- assert_exception(RuntimeError) { Task[:x].invoke }
59
+ assert_raises(RuntimeError) { Task[:x].invoke }
65
60
  end
66
61
 
67
62
  def test_implicit_file_dependencies
@@ -0,0 +1,55 @@
1
+ require File.expand_path('../helper', __FILE__)
2
+ require 'fileutils'
3
+
4
+ class TestRakeDirectoryTask < Rake::TestCase
5
+ include Rake
6
+
7
+ def setup
8
+ super
9
+
10
+ Rake.rm_rf "testdata", :verbose=>false
11
+ end
12
+
13
+ def teardown
14
+ Rake.rm_rf "testdata", :verbose=>false
15
+
16
+ super
17
+ end
18
+
19
+ def test_directory
20
+ desc "DESC"
21
+ directory "testdata/a/b/c"
22
+ assert_equal FileCreationTask, Task["testdata"].class
23
+ assert_equal FileCreationTask, Task["testdata/a"].class
24
+ assert_equal FileCreationTask, Task["testdata/a/b/c"].class
25
+ assert_nil Task["testdata"].comment
26
+ assert_equal "DESC", Task["testdata/a/b/c"].comment
27
+ assert_nil Task["testdata/a/b"].comment
28
+ verbose(false) {
29
+ Task['testdata/a/b'].invoke
30
+ }
31
+ assert File.exist?("testdata/a/b")
32
+ assert ! File.exist?("testdata/a/b/c")
33
+ end
34
+
35
+ if Rake::Win32.windows?
36
+ def test_directory_win32
37
+ desc "WIN32 DESC"
38
+ FileUtils.mkdir_p("testdata")
39
+ Dir.chdir("testdata") do
40
+ directory 'c:/testdata/a/b/c'
41
+ assert_equal FileCreationTask, Task['c:/testdata'].class
42
+ assert_equal FileCreationTask, Task['c:/testdata/a'].class
43
+ assert_equal FileCreationTask, Task['c:/testdata/a/b/c'].class
44
+ assert_nil Task['c:/testdata'].comment
45
+ assert_equal "WIN32 DESC", Task['c:/testdata/a/b/c'].comment
46
+ assert_nil Task['c:/testdata/a/b'].comment
47
+ verbose(false) {
48
+ Task['c:/testdata/a/b'].invoke
49
+ }
50
+ assert File.exist?('c:/testdata/a/b')
51
+ assert ! File.exist?('c:/testdata/a/b/c')
52
+ end
53
+ end
54
+ end
55
+ end