drake 0.8.7.0.2.4 → 0.9.0.0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. data/.gemtest +0 -0
  2. data/CHANGES +77 -9
  3. data/{CHANGES.drake → CHANGES-drake} +6 -2
  4. data/MIT-LICENSE +2 -0
  5. data/{README → README.rdoc} +30 -18
  6. data/Rakefile +144 -130
  7. data/Rakefile-drake +67 -0
  8. data/TODO +1 -1
  9. data/bin/drake +2 -0
  10. data/doc/command_line_usage.rdoc +25 -11
  11. data/doc/glossary.rdoc +2 -2
  12. data/doc/jamis.rb +2 -2
  13. data/doc/parallel.rdoc +37 -29
  14. data/doc/proto_rake.rdoc +22 -22
  15. data/doc/rake.1.gz +0 -0
  16. data/doc/rakefile.rdoc +56 -33
  17. data/doc/rational.rdoc +6 -6
  18. data/doc/release_notes/rake-0.4.15.rdoc +1 -1
  19. data/doc/release_notes/rake-0.5.0.rdoc +1 -1
  20. data/doc/release_notes/rake-0.7.0.rdoc +1 -1
  21. data/doc/release_notes/rake-0.7.2.rdoc +3 -3
  22. data/doc/release_notes/rake-0.7.3.rdoc +2 -2
  23. data/doc/release_notes/rake-0.8.0.rdoc +1 -1
  24. data/doc/release_notes/rake-0.8.2.rdoc +3 -3
  25. data/doc/release_notes/rake-0.8.3.rdoc +2 -2
  26. data/doc/release_notes/rake-0.8.4.rdoc +1 -1
  27. data/doc/release_notes/rake-0.8.5.rdoc +1 -1
  28. data/doc/release_notes/rake-0.8.6.rdoc +1 -1
  29. data/doc/release_notes/rake-0.8.7.rdoc +1 -1
  30. data/doc/release_notes/rake-0.9.0.rdoc +112 -0
  31. data/install.rb +14 -12
  32. data/lib/rake.rb +31 -2527
  33. data/lib/rake/alt_system.rb +7 -6
  34. data/lib/rake/application.rb +626 -0
  35. data/lib/rake/classic_namespace.rb +1 -0
  36. data/lib/rake/clean.rb +2 -4
  37. data/lib/rake/cloneable.rb +25 -0
  38. data/lib/rake/contrib/compositepublisher.rb +2 -5
  39. data/lib/rake/contrib/ftptools.rb +5 -8
  40. data/lib/rake/contrib/publisher.rb +2 -8
  41. data/lib/rake/contrib/rubyforgepublisher.rb +2 -4
  42. data/lib/rake/contrib/sshpublisher.rb +4 -6
  43. data/lib/rake/contrib/sys.rb +7 -25
  44. data/lib/rake/default_loader.rb +10 -0
  45. data/lib/rake/dsl.rb +2 -0
  46. data/lib/rake/dsl_definition.rb +143 -0
  47. data/lib/rake/early_time.rb +18 -0
  48. data/lib/rake/ext/core.rb +27 -0
  49. data/lib/rake/ext/module.rb +39 -0
  50. data/lib/rake/ext/string.rb +167 -0
  51. data/lib/rake/ext/time.rb +14 -0
  52. data/lib/rake/file_creation_task.rb +24 -0
  53. data/lib/rake/file_list.rb +403 -0
  54. data/lib/rake/file_task.rb +47 -0
  55. data/lib/rake/file_utils.rb +112 -0
  56. data/lib/rake/file_utils_ext.rb +142 -0
  57. data/lib/rake/gempackagetask.rb +6 -90
  58. data/lib/rake/invocation_chain.rb +51 -0
  59. data/lib/rake/invocation_exception_mixin.rb +16 -0
  60. data/lib/rake/loaders/makefile.rb +13 -15
  61. data/lib/rake/multi_task.rb +16 -0
  62. data/lib/rake/name_space.rb +25 -0
  63. data/lib/rake/packagetask.rb +13 -12
  64. data/lib/rake/parallel.rb +17 -28
  65. data/lib/rake/pathmap.rb +1 -0
  66. data/lib/rake/pseudo_status.rb +24 -0
  67. data/lib/rake/rake_module.rb +29 -0
  68. data/lib/rake/rake_test_loader.rb +10 -2
  69. data/lib/rake/rdoctask.rb +211 -190
  70. data/lib/rake/ruby182_test_unit_fix.rb +9 -7
  71. data/lib/rake/rule_recursion_overflow_error.rb +20 -0
  72. data/lib/rake/runtest.rb +4 -6
  73. data/lib/rake/task.rb +351 -0
  74. data/lib/rake/task_argument_error.rb +7 -0
  75. data/lib/rake/task_arguments.rb +74 -0
  76. data/lib/rake/task_manager.rb +307 -0
  77. data/lib/rake/tasklib.rb +1 -2
  78. data/lib/rake/testtask.rb +57 -27
  79. data/lib/rake/version.rb +13 -0
  80. data/lib/rake/win32.rb +4 -4
  81. data/test/contrib/test_sys.rb +8 -31
  82. data/test/data/access/Rakefile +33 -0
  83. data/test/data/comments/Rakefile +18 -0
  84. data/test/data/default/Rakefile +1 -1
  85. data/test/data/deprecated_import/Rakefile +1 -0
  86. data/test/data/dryrun/Rakefile +1 -1
  87. data/test/data/file_creation_task/Rakefile +1 -1
  88. data/test/data/namespace/Rakefile +9 -0
  89. data/test/data/rakelib/test1.rb +1 -0
  90. data/test/data/verbose/Rakefile +34 -0
  91. data/test/{filecreation.rb → file_creation.rb} +11 -7
  92. data/test/functional/functional_test.rb +25 -0
  93. data/test/{session_functional.rb → functional/session_based_tests.rb} +141 -23
  94. data/test/in_environment.rb +7 -5
  95. data/test/{test_application.rb → lib/application_test.rb} +331 -143
  96. data/test/{test_clean.rb → lib/clean_test.rb} +1 -0
  97. data/test/{test_definitions.rb → lib/definitions_test.rb} +4 -4
  98. data/test/lib/dsl_test.rb +52 -0
  99. data/test/{test_earlytime.rb → lib/earlytime_test.rb} +1 -2
  100. data/test/{test_extension.rb → lib/extension_test.rb} +2 -2
  101. data/test/{test_file_creation_task.rb → lib/file_creation_task_test.rb} +1 -1
  102. data/test/{test_file_task.rb → lib/file_task_test.rb} +9 -5
  103. data/test/{test_filelist.rb → lib/filelist_test.rb} +38 -24
  104. data/test/{test_fileutils.rb → lib/fileutils_test.rb} +27 -22
  105. data/test/{test_ftp.rb → lib/ftp_test.rb} +0 -0
  106. data/test/{test_invocation_chain.rb → lib/invocation_chain_test.rb} +0 -0
  107. data/test/{test_makefile_loader.rb → lib/makefile_loader_test.rb} +0 -0
  108. data/test/{test_multitask.rb → lib/multitask_test.rb} +3 -2
  109. data/test/{test_namespace.rb → lib/namespace_test.rb} +0 -0
  110. data/test/lib/package_task_test.rb +82 -0
  111. data/test/{test_parallel.rb → lib/parallel_test.rb} +5 -5
  112. data/test/{test_pathmap.rb → lib/pathmap_test.rb} +3 -2
  113. data/test/{test_pseudo_status.rb → lib/pseudo_status_test.rb} +0 -0
  114. data/test/{test_rake.rb → lib/rake_test.rb} +1 -1
  115. data/test/{test_rdoc_task.rb → lib/rdoc_task_test.rb} +19 -23
  116. data/test/{test_require.rb → lib/require_test.rb} +8 -2
  117. data/test/{test_rules.rb → lib/rules_test.rb} +4 -5
  118. data/test/{test_task_arguments.rb → lib/task_arguments_test.rb} +5 -5
  119. data/test/{test_task_manager.rb → lib/task_manager_test.rb} +15 -5
  120. data/test/{test_tasks.rb → lib/task_test.rb} +91 -28
  121. data/test/{test_tasklib.rb → lib/tasklib_test.rb} +0 -0
  122. data/test/{test_test_task.rb → lib/test_task_test.rb} +3 -3
  123. data/test/lib/testtask_test.rb +49 -0
  124. data/test/{test_top_level_functions.rb → lib/top_level_functions_test.rb} +5 -3
  125. data/test/{test_win32.rb → lib/win32_test.rb} +19 -0
  126. data/test/rake_test_setup.rb +6 -10
  127. data/test/ruby_version_test.rb +3 -0
  128. data/test/test_helper.rb +19 -0
  129. metadata +108 -66
  130. data/Rakefile.drake +0 -73
  131. data/test/functional.rb +0 -15
  132. data/test/test_package_task.rb +0 -118
@@ -0,0 +1,13 @@
1
+ module Rake
2
+ module Version
3
+ NUMBERS = [
4
+ MAJOR = 0,
5
+ MINOR = 9,
6
+ BUILD = 0,
7
+ DRAKE_MAJOR = 0,
8
+ DRAKE_MINOR = 3,
9
+ DRAKE_BUILD = 0,
10
+ ]
11
+ end
12
+ VERSION = Version::NUMBERS.join('.')
13
+ end
data/lib/rake/win32.rb CHANGED
@@ -5,12 +5,12 @@ module Rake
5
5
  # Win 32 interface methods for Rake. Windows specific functionality
6
6
  # will be placed here to collect that knowledge in one spot.
7
7
  module Win32
8
-
8
+
9
9
  # Error indicating a problem in locating the home directory on a
10
10
  # Win32 system.
11
11
  class Win32HomeError < RuntimeError
12
12
  end
13
-
13
+
14
14
  class << self
15
15
  # True if running on a windows system.
16
16
  def windows?
@@ -21,7 +21,7 @@ module Rake
21
21
  def rake_system(*cmd)
22
22
  AltSystem.system(*cmd)
23
23
  end
24
-
24
+
25
25
  # The standard directory containing system wide rake files on
26
26
  # Win 32 systems. Try the following environment variables (in
27
27
  # order):
@@ -49,7 +49,7 @@ module Rake
49
49
  def normalize(path)
50
50
  path.gsub(/\\/, '/')
51
51
  end
52
-
52
+
53
53
  end
54
54
  end
55
55
  end
@@ -1,41 +1,18 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'test/unit'
4
- require 'test/filecreation'
5
- require 'rake/contrib/sys'
4
+ require 'test/file_creation'
5
+ begin
6
+ old_verbose = $VERBOSE
7
+ $VERBOSE = nil
8
+ require 'rake/contrib/sys'
9
+ ensure
10
+ $VERBOSE = old_verbose
11
+ end
6
12
 
7
13
  class TestSys < Test::Unit::TestCase
8
14
  include FileCreation
9
15
 
10
- # def test_delete
11
- # create_file("testdata/a")
12
- # Sys.delete_all("testdata/a")
13
- # assert ! File.exist?("testdata/a")
14
- # end
15
-
16
- # def test_copy
17
- # create_file("testdata/a")
18
- # Sys.copy("testdata/a", "testdata/b")
19
- # assert File.exist?("testdata/b")
20
- # end
21
-
22
- # def test_for_files
23
- # test_files = ["testdata/a.pl", "testdata/c.pl", "testdata/b.rb"]
24
- # test_files.each { |fn| create_file(fn) }
25
- # list = []
26
- # Sys.for_files("testdata/*.pl", "testdata/*.rb") { |fn|
27
- # list << fn
28
- # }
29
- # assert_equal test_files.sort, list.sort
30
- # end
31
-
32
- # def test_indir
33
- # here = Dir.pwd
34
- # Sys.makedirs("testdata/dir")
35
- # assert_equal "#{here}/testdata/dir", Sys.indir("testdata/dir") { Dir.pwd }
36
- # assert_equal here, Dir.pwd
37
- # end
38
-
39
16
  def test_split_all
40
17
  assert_equal ['a'], Sys.split_all('a')
41
18
  assert_equal ['..'], Sys.split_all('..')
@@ -0,0 +1,33 @@
1
+ TOP_LEVEL_CONSTANT = 0
2
+
3
+ def a_top_level_function
4
+ end
5
+
6
+ task :default => [:work, :obj, :const]
7
+
8
+ task :work do
9
+ begin
10
+ a_top_level_function
11
+ puts "GOOD:M Top level methods can be called in tasks"
12
+ rescue NameError => ex
13
+ puts "BAD:M Top level methods can not be called in tasks"
14
+ end
15
+ end
16
+
17
+ task :obj do
18
+ begin
19
+ Object.new.instance_eval { task :xyzzy }
20
+ puts "BAD:D Rake DSL are polluting objects"
21
+ rescue StandardError => ex
22
+ puts "GOOD:D Rake DSL are not polluting objects"
23
+ end
24
+ end
25
+
26
+ task :const do
27
+ begin
28
+ TOP_LEVEL_CONSTANT
29
+ puts "GOOD:C Top level constants are available in tasks"
30
+ rescue StandardError => ex
31
+ puts "BAD:C Top level constants are NOT available in tasks"
32
+ end
33
+ end
@@ -0,0 +1,18 @@
1
+ # comment for t1
2
+ task :t1 do
3
+ end
4
+
5
+ # no comment or task because there's a blank line
6
+
7
+ task :t2 do
8
+ end
9
+
10
+ desc "override comment for t3"
11
+ # this is not the description
12
+ multitask :t3 do
13
+ end
14
+
15
+ # this is not the description
16
+ desc "override comment for t4"
17
+ file :t4 do
18
+ end
@@ -16,4 +16,4 @@ task :task_scope do
16
16
  if ENV['TESTTASKSCOPE']
17
17
  puts "TASKSCOPE"
18
18
  end
19
- end
19
+ end
@@ -0,0 +1 @@
1
+ import "a"
@@ -1,4 +1,4 @@
1
- #
1
+ #
2
2
 
3
3
  task :default => ["temp_main"]
4
4
 
@@ -5,7 +5,7 @@ N = 2
5
5
  task :default => :run
6
6
 
7
7
  BUILD_DIR = 'build'
8
- task :clean do
8
+ task :clean do
9
9
  rm_rf 'build'
10
10
  rm_rf 'src'
11
11
  end
@@ -55,3 +55,12 @@ namespace "file2" do
55
55
  end
56
56
  end
57
57
 
58
+ namespace "scopedep" do
59
+ task :prepare do
60
+ touch "scopedep.rb"
61
+ puts "PREPARE"
62
+ end
63
+ file "scopedep.rb" => [:prepare] do
64
+ puts "SCOPEDEP"
65
+ end
66
+ end
@@ -1,3 +1,4 @@
1
+
1
2
  task :default do
2
3
  puts "TEST1"
3
4
  end
@@ -0,0 +1,34 @@
1
+
2
+ task :standalone_verbose_true do
3
+ verbose true
4
+ sh "ruby -e '0'"
5
+ end
6
+
7
+ task :standalone_verbose_false do
8
+ verbose false
9
+ sh "ruby -e '0'"
10
+ end
11
+
12
+ task :inline_verbose_default do
13
+ sh "ruby -e '0'"
14
+ end
15
+
16
+ task :inline_verbose_false do
17
+ sh "ruby -e '0'", :verbose => false
18
+ end
19
+
20
+ task :inline_verbose_true do
21
+ sh "ruby -e '0'", :verbose => true
22
+ end
23
+
24
+ task :block_verbose_true do
25
+ verbose(true) do
26
+ sh "ruby -e '0'"
27
+ end
28
+ end
29
+
30
+ task :block_verbose_false do
31
+ verbose(false) do
32
+ sh "ruby -e '0'"
33
+ end
34
+ end
@@ -7,13 +7,16 @@ module FileCreation
7
7
  NEWFILE = "testdata/new"
8
8
 
9
9
  def create_timed_files(oldfile, *newfiles)
10
- return if File.exist?(oldfile) && newfiles.all? { |newfile| File.exist?(newfile) }
11
- old_time = create_file(oldfile)
10
+ return if (File.exist?(oldfile) &&
11
+ newfiles.all? { |newfile|
12
+ File.exist?(newfile) && File.stat(newfile).mtime > File.stat(oldfile).mtime
13
+ })
14
+ now = Time.now
15
+
16
+ create_file(oldfile, now - 60)
17
+
12
18
  newfiles.each do |newfile|
13
- while create_file(newfile) <= old_time
14
- sleep(0.1)
15
- File.delete(newfile) rescue nil
16
- end
19
+ create_file(newfile, now)
17
20
  end
18
21
  end
19
22
 
@@ -32,9 +35,10 @@ module FileCreation
32
35
  File.stat(dirname).mtime
33
36
  end
34
37
 
35
- def create_file(name)
38
+ def create_file(name, file_time=nil)
36
39
  create_dir(File.dirname(name))
37
40
  FileUtils.touch(name) unless File.exist?(name)
41
+ File.utime(file_time, file_time, name) unless file_time.nil?
38
42
  File.stat(name).mtime
39
43
  end
40
44
 
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ begin
4
+ old_verbose = $VERBOSE
5
+ require 'rubygems'
6
+ $VERBOSE = nil
7
+ gem 'session'
8
+ require 'session'
9
+ rescue LoadError
10
+ if File::ALT_SEPARATOR
11
+ puts "Unable to run functional tests on MS Windows. Skipping."
12
+ else
13
+ puts "Unable to run functional tests -- please run \"gem install session\""
14
+ end
15
+ ensure
16
+ $VERBOSE = old_verbose
17
+ end
18
+
19
+ if defined?(Session)
20
+ if File::ALT_SEPARATOR
21
+ puts "Unable to run functional tests on MS Windows. Skipping."
22
+ else
23
+ require 'test/functional/session_based_tests.rb'
24
+ end
25
+ end
@@ -2,13 +2,14 @@
2
2
 
3
3
  begin
4
4
  require 'rubygems'
5
- rescue LoadError => ex
5
+ rescue LoadError
6
6
  end
7
7
  require 'test/unit'
8
8
  require 'fileutils'
9
9
  require 'session'
10
10
  require 'test/in_environment'
11
11
  require 'test/rake_test_setup'
12
+ require 'rake'
12
13
 
13
14
  # Version 2.1.9 of session has a bug where the @debug instance
14
15
  # variable is not initialized, causing warning messages. This snippet
@@ -23,7 +24,7 @@ module Session
23
24
  end
24
25
  end
25
26
 
26
- class FunctionalTest < Test::Unit::TestCase
27
+ class SessionBasedTests < Test::Unit::TestCase
27
28
  include InEnvironment
28
29
  include TestMethods
29
30
 
@@ -32,7 +33,7 @@ class FunctionalTest < Test::Unit::TestCase
32
33
  def setup
33
34
  @rake_path = File.expand_path("bin/rake")
34
35
  lib_path = File.expand_path("lib")
35
- @ruby_options = "-I#{lib_path} -I."
36
+ @ruby_options = ["-I#{lib_path}", "-I."]
36
37
  @verbose = ! ENV['VERBOSE'].nil?
37
38
  if @verbose
38
39
  puts
@@ -55,13 +56,13 @@ class FunctionalTest < Test::Unit::TestCase
55
56
  assert_status(1)
56
57
  end
57
58
 
58
- def test_env_availabe_at_top_scope
59
+ def test_env_available_at_top_scope
59
60
  Dir.chdir("test/data/default") do rake "TESTTOPSCOPE=1" end
60
61
  assert_match(/^TOPSCOPE$/, @out)
61
62
  assert_status
62
63
  end
63
64
 
64
- def test_env_availabe_at_task_scope
65
+ def test_env_available_at_task_scope
65
66
  Dir.chdir("test/data/default") do rake "TESTTASKSCOPE=1 task_scope" end
66
67
  assert_match(/^TASKSCOPE$/, @out)
67
68
  assert_status
@@ -79,7 +80,7 @@ class FunctionalTest < Test::Unit::TestCase
79
80
  assert_no_match %r{^rake c}, @out
80
81
  assert_match %r{^rake d *# x{65}\.\.\.$}, @out
81
82
  end
82
-
83
+
83
84
  def test_long_description
84
85
  in_environment("PWD" => "test/data/multidesc") do
85
86
  rake "--describe"
@@ -90,6 +91,13 @@ class FunctionalTest < Test::Unit::TestCase
90
91
  assert_no_match %r{^rake c\n}m, @out
91
92
  end
92
93
 
94
+ def test_proper_namespace_access
95
+ in_environment("PWD" => "test/data/access") do
96
+ rake
97
+ end
98
+ assert_not_match %r{^BAD:}, @out
99
+ end
100
+
93
101
  def test_rbext
94
102
  in_environment("PWD" => "test/data/rbext") do
95
103
  rake "-N"
@@ -111,7 +119,7 @@ class FunctionalTest < Test::Unit::TestCase
111
119
  assert_no_match %r{extra:extra}, @out
112
120
  end
113
121
 
114
- def test_by_default_rakelib_files_are_include
122
+ def test_by_default_rakelib_files_are_included
115
123
  in_environment('RAKE_SYSTEM' => 'test/data/sys') do
116
124
  rake '-T', 'extra'
117
125
  end
@@ -156,10 +164,66 @@ class FunctionalTest < Test::Unit::TestCase
156
164
  assert_match %r{^No Rakefile found}, @err
157
165
  end
158
166
 
167
+ def test_invalid_command_line_options
168
+ in_environment("PWD" => "test/data/default") do
169
+ rake "--bad-options"
170
+ end
171
+ assert_match %r{invalid +option}i, @err
172
+ end
173
+
174
+ def test_inline_verbose_default_should_show_command
175
+ in_environment("PWD" => "test/data/verbose") do
176
+ rake "inline_verbose_default"
177
+ end
178
+ assert_match(/ruby -e/, @err)
179
+ end
180
+
181
+ def test_inline_verbose_true_should_show_command
182
+ in_environment("PWD" => "test/data/verbose") do
183
+ rake "inline_verbose_true"
184
+ end
185
+ assert_match(/ruby -e/, @err)
186
+ end
187
+
188
+ def test_inline_verbose_false_should_not_show_command
189
+ in_environment("PWD" => "test/data/verbose") do
190
+ rake "inline_verbose_false"
191
+ end
192
+ assert_no_match(/ruby -e/, @err)
193
+ end
194
+
195
+ def test_block_verbose_false_should_not_show_command
196
+ in_environment("PWD" => "test/data/verbose") do
197
+ rake "block_verbose_false"
198
+ end
199
+ assert_no_match(/ruby -e/, @err)
200
+ end
201
+
202
+ def test_block_verbose_true_should_show_command
203
+ in_environment("PWD" => "test/data/verbose") do
204
+ rake "block_verbose_true"
205
+ end
206
+ assert_match(/ruby -e/, @err)
207
+ end
208
+
209
+ def test_standalone_verbose_true_should_show_command
210
+ in_environment("PWD" => "test/data/verbose") do
211
+ rake "standalone_verbose_true"
212
+ end
213
+ assert_match(/ruby -e/, @err)
214
+ end
215
+
216
+ def test_standalone_verbose_false_should_not_show_command
217
+ in_environment("PWD" => "test/data/verbose") do
218
+ rake "standalone_verbose_false"
219
+ end
220
+ assert_no_match(/ruby -e/, @err)
221
+ end
222
+
159
223
  def test_dry_run
160
224
  in_environment("PWD" => "test/data/default") do rake "-n", "other" end
161
- assert_match %r{Execute \(dry run\) default}, @out
162
- assert_match %r{Execute \(dry run\) other}, @out
225
+ assert_match %r{Execute \(dry run\) default}, @err
226
+ assert_match %r{Execute \(dry run\) other}, @err
163
227
  assert_no_match %r{DEFAULT}, @out
164
228
  assert_no_match %r{OTHER}, @out
165
229
  end
@@ -284,7 +348,16 @@ class FunctionalTest < Test::Unit::TestCase
284
348
  assert_match(/^XYZ1\nXYZ2$/m, @out)
285
349
  end
286
350
  end
287
-
351
+
352
+ def test_file_task_dependencies_scoped_by_namespaces
353
+ in_environment("PWD" => "test/data/namespace") do
354
+ rake "scopedep.rb"
355
+ assert_match(/^PREPARE\nSCOPEDEP$/m, @out)
356
+ end
357
+ ensure
358
+ remove_namespace_files
359
+ end
360
+
288
361
  def test_rake_returns_status_error_values
289
362
  in_environment("PWD" => "test/data/statusreturn") do
290
363
  rake "exit5"
@@ -299,30 +372,75 @@ class FunctionalTest < Test::Unit::TestCase
299
372
  end
300
373
  end
301
374
 
375
+ def test_comment_before_task_acts_like_desc
376
+ in_environment("PWD" => "test/data/comments") do
377
+ rake "-T"
378
+ end
379
+ assert_no_match(/comment for t1/, @out)
380
+ end
381
+
382
+ def test_comment_separated_from_task_by_blank_line_is_not_picked_up
383
+ Dir.chdir("test/data/comments") { rake("-T")}
384
+ assert_not_match("t2", @out)
385
+ end
386
+
387
+ def test_comment_after_desc_is_ignored
388
+ Dir.chdir("test/data/comments") { rake("-T")}
389
+ assert_match("override comment for t3", @out)
390
+ end
391
+
392
+ def test_comment_before_desc_is_ignored
393
+ Dir.chdir("test/data/comments") { rake("-T")}
394
+ assert_match("override comment for t4", @out)
395
+ end
396
+
397
+ def test_correct_number_of_tasks_reported
398
+ Dir.chdir("test/data/comments") { rake("-T")}
399
+ assert_equal(2, @out.split(/\n/).grep(/t\d/).size)
400
+ end
401
+
402
+ def test_file_list_is_requirable_separately
403
+ ruby "-rrake/file_list", "-e 'puts Rake::FileList[\"a\"].size'"
404
+ assert_equal "1\n", @out
405
+ assert_equal 0, @status
406
+ end
407
+
302
408
  private
303
409
 
410
+ def assert_not_match(pattern, string, comment="'#{pattern}' was found (incorrectly) in '#{string}.inspect")
411
+ assert_nil Regexp.new(pattern).match(string), comment
412
+ end
413
+
304
414
  def remove_chaining_files
305
415
  %w(play.scpt play.app base).each do |fn|
306
416
  FileUtils.rm_f File.join("test/data/chains", fn)
307
417
  end
308
418
  end
309
419
 
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
420
+ def remove_namespace_files
421
+ %w(scopedep.rb).each do |fn|
422
+ FileUtils.rm_f File.join("test/data/namespace", fn)
319
423
  end
320
424
  end
321
-
322
- def rake(*option_list)
323
- options = option_list.join(' ')
425
+
426
+ # Run a shell Ruby command with command line options (using the
427
+ # default test options). Output is captured in @out, @err and
428
+ # @status.
429
+ def ruby(*option_list)
430
+ run_ruby(@ruby_options + option_list)
431
+ end
432
+
433
+ # Run a command line rake with the give rake options. Default
434
+ # command line ruby options are included. Output is captured in
435
+ # @out, @err and @status.
436
+ def rake(*rake_options)
437
+ run_ruby @ruby_options + [@rake_path] + rake_options
438
+ end
439
+
440
+ # Low level ruby command runner ...
441
+ def run_ruby(option_list)
324
442
  shell = Session::Shell.new
325
- command = self.class.format_command[@ruby_options, @rake_path, options]
443
+ command = "#{RUBY_COMMAND} " + option_list.join(' ')
326
444
  puts "COMMAND: [#{command}]" if @verbose
327
445
  @out, @err = shell.execute command
328
446
  @status = shell.exit_status