rake 0.7.3 → 0.8.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. data/CHANGES +126 -1
  2. data/README +86 -132
  3. data/Rakefile +111 -64
  4. data/TODO +1 -0
  5. data/bin/rake +24 -0
  6. data/doc/command_line_usage.rdoc +102 -0
  7. data/doc/rakefile.rdoc +126 -3
  8. data/doc/release_notes/rake-0.7.3.rdoc +0 -0
  9. data/doc/release_notes/rake-0.8.0.rdoc +114 -0
  10. data/doc/release_notes/rake-0.8.2.rdoc +165 -0
  11. data/doc/release_notes/rake-0.8.3.rdoc +112 -0
  12. data/doc/release_notes/rake-0.8.4.rdoc +147 -0
  13. data/doc/release_notes/rake-0.8.5.rdoc +53 -0
  14. data/doc/release_notes/rake-0.8.6.rdoc +55 -0
  15. data/doc/release_notes/rake-0.8.7.rdoc +55 -0
  16. data/lib/rake/alt_system.rb +108 -0
  17. data/lib/rake/contrib/ftptools.rb +24 -10
  18. data/lib/rake/contrib/publisher.rb +1 -1
  19. data/lib/rake/contrib/sys.rb +5 -2
  20. data/lib/rake/gempackagetask.rb +2 -6
  21. data/lib/rake/loaders/makefile.rb +17 -15
  22. data/lib/rake/rdoctask.rb +83 -21
  23. data/lib/rake/ruby182_test_unit_fix.rb +0 -0
  24. data/lib/rake/tasklib.rb +8 -3
  25. data/lib/rake/testtask.rb +1 -1
  26. data/lib/rake/win32.rb +55 -0
  27. data/lib/rake.rb +861 -386
  28. data/test/check_expansion.rb +5 -0
  29. data/test/check_no_expansion.rb +5 -0
  30. data/test/data/file_creation_task/Rakefile +4 -1
  31. data/test/data/multidesc/Rakefile +3 -0
  32. data/test/data/sample.mf +6 -1
  33. data/test/data/statusreturn/Rakefile +8 -0
  34. data/test/filecreation.rb +0 -2
  35. data/test/functional.rb +3 -1
  36. data/test/in_environment.rb +30 -0
  37. data/test/rake_test_setup.rb +24 -0
  38. data/test/session_functional.rb +145 -24
  39. data/test/shellcommand.rb +0 -0
  40. data/test/test_application.rb +345 -95
  41. data/test/test_definitions.rb +4 -1
  42. data/test/test_earlytime.rb +2 -2
  43. data/test/test_extension.rb +63 -0
  44. data/test/test_file_task.rb +20 -16
  45. data/test/test_filelist.rb +59 -10
  46. data/test/test_fileutils.rb +59 -38
  47. data/test/test_ftp.rb +5 -1
  48. data/test/test_invocation_chain.rb +81 -0
  49. data/test/test_makefile_loader.rb +5 -2
  50. data/test/test_namespace.rb +37 -14
  51. data/test/test_package_task.rb +3 -15
  52. data/test/test_pathmap.rb +24 -2
  53. data/test/test_pseudo_status.rb +26 -0
  54. data/test/test_rake.rb +9 -2
  55. data/test/test_rdoc_task.rb +88 -0
  56. data/test/test_require.rb +3 -1
  57. data/test/test_rules.rb +56 -12
  58. data/test/test_task_arguments.rb +89 -0
  59. data/test/test_task_manager.rb +27 -2
  60. data/test/test_tasklib.rb +12 -0
  61. data/test/test_tasks.rb +248 -20
  62. data/test/test_test_task.rb +3 -2
  63. data/test/test_top_level_functions.rb +10 -3
  64. data/test/test_win32.rb +72 -0
  65. metadata +105 -69
  66. /data/test/contrib/{testsys.rb → test_sys.rb} +0 -0
@@ -0,0 +1,5 @@
1
+ if ARGV[0] != ARGV[1]
2
+ exit 1
3
+ else
4
+ exit 0
5
+ end
@@ -0,0 +1,5 @@
1
+ if ARGV[0] != ARGV[1]
2
+ exit 0
3
+ else
4
+ exit 1
5
+ end
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
1
3
  N = 2
2
4
 
3
5
  task :default => :run
@@ -17,7 +19,7 @@ FileList['src/*'].each do |src|
17
19
  target = File.join TARGET_DIR, File.basename(src)
18
20
  file target => [src, TARGET_DIR] do
19
21
  cp src, target
20
- sleep 3 if src !~ /foo#{N-1}$/
22
+ # sleep 3 if src !~ /foo#{N-1}$/ # I'm commenting out this sleep, it doesn't seem to do anything.
21
23
  end
22
24
  task :run => target
23
25
  end
@@ -25,6 +27,7 @@ end
25
27
  task :prep => :clean do
26
28
  mkdir_p 'src'
27
29
  N.times do |n|
30
+ puts "DBG: Touching src/foo#{n}"
28
31
  touch "src/foo#{n}"
29
32
  end
30
33
  end
@@ -12,3 +12,6 @@ desc "A2"
12
12
  task :a
13
13
 
14
14
  task :c
15
+
16
+ desc "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
17
+ task :d
data/test/data/sample.mf CHANGED
@@ -4,6 +4,11 @@ b: b1 b2 b3 \
4
4
  b4 b5 b6\
5
5
  # Mid: Comment
6
6
  b7
7
- a: a5 a6 a7
7
+
8
+ a : a5 a6 a7
8
9
  c: c1
9
10
  d: d1 d2 \
11
+
12
+ e f : e1 f1
13
+
14
+ g\ 0: g1 g\ 2 g\ 3 g4
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ task :exit5 do
4
+ exit(5)
5
+ end
6
+
7
+ task :normal do
8
+ end
data/test/filecreation.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'ftools'
4
-
5
3
  module FileCreation
6
4
  OLDFILE = "testdata/old"
7
5
  NEWFILE = "testdata/new"
data/test/functional.rb CHANGED
@@ -3,11 +3,13 @@
3
3
  begin
4
4
  require 'rubygems'
5
5
  gem 'session'
6
+ require 'session'
6
7
  rescue LoadError
7
8
  puts "UNABLE TO RUN FUNCTIONAL TESTS"
8
- puts "No Session Found"
9
+ puts "No Session Found (gem install session)"
9
10
  end
10
11
 
11
12
  if defined?(Session)
13
+ puts "RUNNING WITH SESSIONS"
12
14
  require 'test/session_functional'
13
15
  end
@@ -0,0 +1,30 @@
1
+ module InEnvironment
2
+ private
3
+
4
+ # Create an environment for a test. At the completion of the yielded
5
+ # block, the environment is restored to its original conditions.
6
+ def in_environment(settings)
7
+ original_settings = set_env(settings)
8
+ yield
9
+ ensure
10
+ set_env(original_settings)
11
+ end
12
+
13
+ # Set the environment according to the settings hash.
14
+ def set_env(settings) # :nodoc:
15
+ result = {}
16
+ settings.each do |k, v|
17
+ result[k] = ENV[k]
18
+ if k == 'PWD'
19
+ result[k] = Dir.pwd
20
+ Dir.chdir(v)
21
+ elsif v.nil?
22
+ ENV.delete(k)
23
+ else
24
+ ENV[k] = v
25
+ end
26
+ end
27
+ result
28
+ end
29
+
30
+ end
@@ -0,0 +1,24 @@
1
+ # Common setup for all test files.
2
+
3
+ begin
4
+ require 'rubygems'
5
+ gem 'flexmock'
6
+ rescue LoadError
7
+ # got no gems
8
+ end
9
+
10
+ require 'flexmock/test_unit'
11
+
12
+ if RUBY_VERSION >= "1.9.0"
13
+ class Test::Unit::TestCase
14
+ # def passed?
15
+ # true
16
+ # end
17
+ end
18
+ end
19
+
20
+ module TestMethods
21
+ def assert_exception(ex, msg=nil, &block)
22
+ assert_raise(ex, msg, &block)
23
+ end
24
+ end
@@ -1,7 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ begin
4
+ require 'rubygems'
5
+ rescue LoadError => ex
6
+ end
3
7
  require 'test/unit'
4
8
  require 'fileutils'
9
+ require 'session'
10
+ require 'test/in_environment'
11
+ require 'test/rake_test_setup'
5
12
 
6
13
  # Version 2.1.9 of session has a bug where the @debug instance
7
14
  # variable is not initialized, causing warning messages. This snippet
@@ -17,6 +24,11 @@ module Session
17
24
  end
18
25
 
19
26
  class FunctionalTest < Test::Unit::TestCase
27
+ include InEnvironment
28
+ include TestMethods
29
+
30
+ RUBY_COMMAND = 'ruby'
31
+
20
32
  def setup
21
33
  @rake_path = File.expand_path("bin/rake")
22
34
  lib_path = File.expand_path("lib")
@@ -56,24 +68,96 @@ class FunctionalTest < Test::Unit::TestCase
56
68
  end
57
69
 
58
70
  def test_multi_desc
59
- Dir.chdir("test/data/multidesc") do rake "-T" end
71
+ in_environment(
72
+ 'RAKE_COLUMNS' => "80",
73
+ "PWD" => "test/data/multidesc"
74
+ ) do
75
+ rake "-T"
76
+ end
60
77
  assert_match %r{^rake a *# A / A2 *$}, @out
61
78
  assert_match %r{^rake b *# B *$}, @out
62
79
  assert_no_match %r{^rake c}, @out
80
+ assert_match %r{^rake d *# x{65}\.\.\.$}, @out
81
+ end
82
+
83
+ def test_long_description
84
+ in_environment("PWD" => "test/data/multidesc") do
85
+ rake "--describe"
86
+ end
87
+ assert_match %r{^rake a\n *A / A2 *$}m, @out
88
+ assert_match %r{^rake b\n *B *$}m, @out
89
+ assert_match %r{^rake d\n *x{80}}m, @out
90
+ assert_no_match %r{^rake c\n}m, @out
63
91
  end
64
92
 
65
93
  def test_rbext
66
- Dir.chdir("test/data/rbext") do rake "-N" end
94
+ in_environment("PWD" => "test/data/rbext") do
95
+ rake "-N"
96
+ end
67
97
  assert_match %r{^OK$}, @out
68
98
  end
69
99
 
70
- def test_nosearch
71
- Dir.chdir("test/data/nosearch") do rake "-N" end
100
+ def test_system
101
+ in_environment('RAKE_SYSTEM' => 'test/data/sys') do
102
+ rake '-g', "sys1"
103
+ end
104
+ assert_match %r{^SYS1}, @out
105
+ end
106
+
107
+ def test_system_excludes_rakelib_files_too
108
+ in_environment('RAKE_SYSTEM' => 'test/data/sys') do
109
+ rake '-g', "sys1", '-T', 'extra'
110
+ end
111
+ assert_no_match %r{extra:extra}, @out
112
+ end
113
+
114
+ def test_by_default_rakelib_files_are_include
115
+ in_environment('RAKE_SYSTEM' => 'test/data/sys') do
116
+ rake '-T', 'extra'
117
+ end
118
+ assert_match %r{extra:extra}, @out
119
+ end
120
+
121
+ def test_implicit_system
122
+ in_environment('RAKE_SYSTEM' => File.expand_path('test/data/sys'), "PWD" => "/") do
123
+ rake "sys1", "--trace"
124
+ end
125
+ assert_match %r{^SYS1}, @out
126
+ end
127
+
128
+ def test_no_system
129
+ in_environment('RAKE_SYSTEM' => 'test/data/sys') do
130
+ rake '-G', "sys1"
131
+ end
132
+ assert_match %r{^Don't know how to build task}, @err # emacs wart: '
133
+ end
134
+
135
+ def test_nosearch_with_rakefile_uses_local_rakefile
136
+ in_environment("PWD" => "test/data/default") do
137
+ rake "--nosearch"
138
+ end
139
+ assert_match %r{^DEFAULT}, @out
140
+ end
141
+
142
+ def test_nosearch_without_rakefile_finds_system
143
+ in_environment(
144
+ "PWD" => "test/data/nosearch",
145
+ "RAKE_SYSTEM" => File.expand_path("test/data/sys")
146
+ ) do
147
+ rake "--nosearch", "sys1"
148
+ end
149
+ assert_match %r{^SYS1}, @out
150
+ end
151
+
152
+ def test_nosearch_without_rakefile_and_no_system_fails
153
+ in_environment("PWD" => "test/data/nosearch", "RAKE_SYSTEM" => "not_exist") do
154
+ rake "--nosearch"
155
+ end
72
156
  assert_match %r{^No Rakefile found}, @err
73
157
  end
74
158
 
75
159
  def test_dry_run
76
- Dir.chdir("test/data/default") do rake "-n", "other" end
160
+ in_environment("PWD" => "test/data/default") do rake "-n", "other" end
77
161
  assert_match %r{Execute \(dry run\) default}, @out
78
162
  assert_match %r{Execute \(dry run\) other}, @out
79
163
  assert_no_match %r{DEFAULT}, @out
@@ -82,18 +166,26 @@ class FunctionalTest < Test::Unit::TestCase
82
166
 
83
167
  # Test for the trace/dry_run bug found by Brian Chandler
84
168
  def test_dry_run_bug
85
- Dir.chdir("test/data/dryrun") do rake end
169
+ in_environment("PWD" => "test/data/dryrun") do
170
+ rake
171
+ end
86
172
  FileUtils.rm_f "test/data/dryrun/temp_one"
87
- Dir.chdir("test/data/dryrun") do rake "--dry-run" end
173
+ in_environment("PWD" => "test/data/dryrun") do
174
+ rake "--dry-run"
175
+ end
88
176
  assert_no_match(/No such file/, @out)
89
177
  assert_status
90
178
  end
91
179
 
92
180
  # Test for the trace/dry_run bug found by Brian Chandler
93
181
  def test_trace_bug
94
- Dir.chdir("test/data/dryrun") do rake end
182
+ in_environment("PWD" => "test/data/dryrun") do
183
+ rake
184
+ end
95
185
  FileUtils.rm_f "test/data/dryrun/temp_one"
96
- Dir.chdir("test/data/dryrun") do rake "--trace" end
186
+ in_environment("PWD" => "test/data/dryrun") do
187
+ rake "--trace"
188
+ end
97
189
  assert_no_match(/No such file/, @out)
98
190
  assert_status
99
191
  end
@@ -103,7 +195,9 @@ class FunctionalTest < Test::Unit::TestCase
103
195
  f.puts 'puts "STATIC"'
104
196
  end
105
197
  FileUtils.rm_f "test/data/imports/dynamic_deps"
106
- Dir.chdir("test/data/imports") do rake end
198
+ in_environment("PWD" => "test/data/imports") do
199
+ rake
200
+ end
107
201
  assert File.exist?("test/data/imports/dynamic_deps"),
108
202
  "'dynamic_deps' file should exist"
109
203
  assert_match(/^FIRST$\s+^DYNAMIC$\s+^STATIC$\s+^OTHER$/, @out)
@@ -114,7 +208,9 @@ class FunctionalTest < Test::Unit::TestCase
114
208
 
115
209
  def test_rules_chaining_to_file_task
116
210
  remove_chaining_files
117
- Dir.chdir("test/data/chains") do rake end
211
+ in_environment("PWD" => "test/data/chains") do
212
+ rake
213
+ end
118
214
  assert File.exist?("test/data/chains/play.app"),
119
215
  "'play.app' file should exist"
120
216
  assert_status
@@ -122,12 +218,12 @@ class FunctionalTest < Test::Unit::TestCase
122
218
  end
123
219
 
124
220
  def test_file_creation_task
125
- Dir.chdir("test/data/file_creation_task") do
221
+ in_environment("PWD" => "test/data/file_creation_task") do
126
222
  rake "prep"
127
223
  rake "run"
128
224
  rake "run"
129
- assert(@err !~ /^cp src/, "Should not recopy data")
130
225
  end
226
+ assert(@err !~ /^cp src/, "Should not recopy data")
131
227
  end
132
228
 
133
229
  def test_dash_f_with_no_arg_foils_rakefile_lookup
@@ -135,59 +231,73 @@ class FunctionalTest < Test::Unit::TestCase
135
231
  assert_match(/^TEST1$/, @out)
136
232
  end
137
233
 
138
- def test_dot_rake_files_can_be_laoded_with_dash_r
234
+ def test_dot_rake_files_can_be_loaded_with_dash_r
139
235
  rake "-I test/data/rakelib -rtest2 -f"
140
236
  assert_match(/^TEST2$/, @out)
141
237
  end
142
238
 
143
239
  def test_can_invoke_task_in_toplevel_namespace
144
- Dir.chdir("test/data/namespace") do
240
+ in_environment("PWD" => "test/data/namespace") do
145
241
  rake "copy"
146
- assert_match(/^COPY$/, @out)
147
242
  end
243
+ assert_match(/^COPY$/, @out)
148
244
  end
149
245
 
150
246
  def test_can_invoke_task_in_nested_namespace
151
- Dir.chdir("test/data/namespace") do
247
+ in_environment("PWD" => "test/data/namespace") do
152
248
  rake "nest:copy"
153
249
  assert_match(/^NEST COPY$/, @out)
154
250
  end
155
251
  end
156
252
 
157
253
  def test_tasks_can_reference_task_in_same_namespace
158
- Dir.chdir("test/data/namespace") do
254
+ in_environment("PWD" => "test/data/namespace") do
159
255
  rake "nest:xx"
160
256
  assert_match(/^NEST COPY$/m, @out)
161
257
  end
162
258
  end
163
259
 
164
260
  def test_tasks_can_reference_task_in_other_namespaces
165
- Dir.chdir("test/data/namespace") do
261
+ in_environment("PWD" => "test/data/namespace") do
166
262
  rake "b:run"
167
263
  assert_match(/^IN A\nIN B$/m, @out)
168
264
  end
169
265
  end
170
266
 
171
267
  def test_anonymous_tasks_can_be_invoked_indirectly
172
- Dir.chdir("test/data/namespace") do
268
+ in_environment("PWD" => "test/data/namespace") do
173
269
  rake "anon"
174
270
  assert_match(/^ANON COPY$/m, @out)
175
271
  end
176
272
  end
177
273
 
178
274
  def test_rake_namespace_refers_to_toplevel
179
- Dir.chdir("test/data/namespace") do
275
+ in_environment("PWD" => "test/data/namespace") do
180
276
  rake "very:nested:run"
181
277
  assert_match(/^COPY$/m, @out)
182
278
  end
183
279
  end
184
280
 
185
281
  def test_file_task_are_not_scoped_by_namespaces
186
- Dir.chdir("test/data/namespace") do
282
+ in_environment("PWD" => "test/data/namespace") do
187
283
  rake "xyz.rb"
188
284
  assert_match(/^XYZ1\nXYZ2$/m, @out)
189
285
  end
190
286
  end
287
+
288
+ def test_rake_returns_status_error_values
289
+ in_environment("PWD" => "test/data/statusreturn") do
290
+ rake "exit5"
291
+ assert_status(5)
292
+ end
293
+ end
294
+
295
+ def test_rake_returns_no_status_error_on_normal_exit
296
+ in_environment("PWD" => "test/data/statusreturn") do
297
+ rake "normal"
298
+ assert_status(0)
299
+ end
300
+ end
191
301
 
192
302
  private
193
303
 
@@ -197,10 +307,22 @@ class FunctionalTest < Test::Unit::TestCase
197
307
  end
198
308
  end
199
309
 
310
+ class << self
311
+ def format_command
312
+ @format_command ||= lambda { |ruby_options, rake_path, options|
313
+ "ruby #{ruby_options} #{rake_path} #{options}"
314
+ }
315
+ end
316
+
317
+ def format_command=(fmt_command)
318
+ @format_command = fmt_command
319
+ end
320
+ end
321
+
200
322
  def rake(*option_list)
201
323
  options = option_list.join(' ')
202
324
  shell = Session::Shell.new
203
- command = "ruby #{@ruby_options} #{@rake_path} #{options}"
325
+ command = self.class.format_command[@ruby_options, @rake_path, options]
204
326
  puts "COMMAND: [#{command}]" if @verbose
205
327
  @out, @err = shell.execute command
206
328
  @status = shell.exit_status
@@ -214,5 +336,4 @@ class FunctionalTest < Test::Unit::TestCase
214
336
  def assert_status(expected_status=0)
215
337
  assert_equal expected_status, @status
216
338
  end
217
-
218
339
  end
data/test/shellcommand.rb CHANGED
File without changes