drake 0.9.0.0.3.0 → 0.9.1.0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/CHANGES +9 -8
  2. data/CHANGES-drake +4 -0
  3. data/Rakefile +14 -49
  4. data/Rakefile-drake +2 -1
  5. data/bin/drake +4 -3
  6. data/doc/release_notes/rake-0.9.1.rdoc +52 -0
  7. data/lib/rake/dsl_definition.rb +19 -0
  8. data/lib/rake/version.rb +1 -1
  9. data/test/data/access/Rakefile +3 -1
  10. data/test/data/default/Rakefile +0 -2
  11. data/test/data/file_creation_task/Rakefile +0 -2
  12. data/test/data/multidesc/Rakefile +0 -2
  13. data/test/data/namespace/Rakefile +0 -2
  14. data/test/data/statusreturn/Rakefile +0 -2
  15. data/test/file_creation.rb +0 -2
  16. data/test/helper.rb +63 -0
  17. data/test/in_environment.rb +4 -1
  18. data/test/{parallel_setup.rb → setup_parallel.rb} +0 -0
  19. data/test/{serial_setup.rb → setup_serial.rb} +0 -0
  20. data/test/{lib/parallel_test.rb → test_parallel.rb} +3 -1
  21. data/test/{lib/rake_test.rb → test_rake.rb} +2 -5
  22. data/test/test_rake_application.rb +365 -0
  23. data/test/test_rake_application_options.rb +383 -0
  24. data/test/test_rake_clean.rb +14 -0
  25. data/test/{lib/definitions_test.rb → test_rake_definitions.rb} +5 -10
  26. data/test/test_rake_directory_task.rb +55 -0
  27. data/test/test_rake_dsl.rb +53 -0
  28. data/test/{lib/earlytime_test.rb → test_rake_early_time.rb} +2 -5
  29. data/test/{lib/extension_test.rb → test_rake_extension.rb} +2 -6
  30. data/test/{lib/file_creation_task_test.rb → test_rake_file_creation_task.rb} +7 -7
  31. data/test/{lib/filelist_test.rb → test_rake_file_list.rb} +18 -22
  32. data/test/test_rake_file_list_path_map.rb +8 -0
  33. data/test/{lib/file_task_test.rb → test_rake_file_task.rb} +22 -61
  34. data/test/{lib/fileutils_test.rb → test_rake_file_utils.rb} +11 -15
  35. data/test/{lib/ftp_test.rb → test_rake_ftp_file.rb} +5 -5
  36. data/test/{functional/session_based_tests.rb → test_rake_functional.rb} +35 -24
  37. data/test/test_rake_invocation_chain.rb +52 -0
  38. data/test/{lib/makefile_loader_test.rb → test_rake_makefile_loader.rb} +2 -5
  39. data/test/{lib/multitask_test.rb → test_rake_multi_task.rb} +5 -7
  40. data/test/{lib/namespace_test.rb → test_rake_name_space.rb} +4 -16
  41. data/test/{lib/package_task_test.rb → test_rake_package_task.rb} +2 -6
  42. data/test/{lib/pathmap_test.rb → test_rake_path_map.rb} +4 -58
  43. data/test/test_rake_path_map_explode.rb +31 -0
  44. data/test/test_rake_path_map_partial.rb +18 -0
  45. data/test/{lib/pseudo_status_test.rb → test_rake_pseudo_status.rb} +2 -8
  46. data/test/{lib/rdoc_task_test.rb → test_rake_rdoc_task.rb} +4 -7
  47. data/test/{lib/require_test.rb → test_rake_require.rb} +3 -9
  48. data/test/{lib/rules_test.rb → test_rake_rules.rb} +11 -13
  49. data/test/{lib/task_test.rb → test_rake_task.rb} +16 -183
  50. data/test/test_rake_task_argument_parsing.rb +126 -0
  51. data/test/{lib/task_arguments_test.rb → test_rake_task_arguments.rb} +2 -5
  52. data/test/{lib/tasklib_test.rb → test_rake_task_lib.rb} +2 -5
  53. data/test/{lib/task_manager_test.rb → test_rake_task_manager.rb} +7 -45
  54. data/test/test_rake_task_manager_argument_resolution.rb +36 -0
  55. data/test/test_rake_task_with_arguments.rb +162 -0
  56. data/test/{lib/test_task_test.rb → test_rake_test_task.rb} +52 -7
  57. data/test/{lib/top_level_functions_test.rb → test_rake_top_level_functions.rb} +8 -20
  58. data/test/{lib/win32_test.rb → test_rake_win32.rb} +5 -12
  59. data/test/{contrib/test_sys.rb → test_sys.rb} +2 -6
  60. metadata +62 -47
  61. data/lib/rake/dsl.rb +0 -2
  62. data/test/capture_stdout.rb +0 -26
  63. data/test/functional/functional_test.rb +0 -25
  64. data/test/lib/application_test.rb +0 -871
  65. data/test/lib/clean_test.rb +0 -15
  66. data/test/lib/dsl_test.rb +0 -52
  67. data/test/lib/invocation_chain_test.rb +0 -81
  68. data/test/lib/testtask_test.rb +0 -49
  69. data/test/rake_test_setup.rb +0 -41
  70. data/test/ruby_version_test.rb +0 -3
  71. data/test/test_helper.rb +0 -19
@@ -0,0 +1,383 @@
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(/\Adrake/, 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 "drake, 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
+ @app.options.threads = Rake.application.options.threads
372
+ def @app.exit(*args)
373
+ throw :system_exit, :exit
374
+ end
375
+ @app.instance_eval do
376
+ handle_options
377
+ collect_tasks
378
+ end
379
+ @tasks = @app.top_level_tasks
380
+ @app.options
381
+ end
382
+ end
383
+
@@ -0,0 +1,14 @@
1
+ require File.expand_path('../helper', __FILE__)
2
+
3
+ class TestRakeClean < Rake::TestCase
4
+ include Rake
5
+ def test_clean
6
+ # since other tests call Task.clear, this only works once
7
+ if require('rake/clean')
8
+ assert Task['clean'], "Should define clean"
9
+ assert Task['clobber'], "Should define clobber"
10
+ assert Task['clobber'].prerequisites.include?("clean"),
11
+ "Clobber should require clean"
12
+ end
13
+ end
14
+ end
@@ -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
 
@@ -65,7 +60,7 @@ class TestDefinitions < Test::Unit::TestCase
65
60
 
66
61
  def test_missing_dependencies
67
62
  task :x => ["testdata/missing"]
68
- assert_exception(RuntimeError) { Task[:x].invoke }
63
+ assert_raises(RuntimeError) { Task[:x].invoke }
69
64
  end
70
65
 
71
66
  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