rake 0.9.2 → 13.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. checksums.yaml +7 -0
  2. data/CONTRIBUTING.rdoc +43 -0
  3. data/Gemfile +10 -0
  4. data/History.rdoc +2386 -0
  5. data/MIT-LICENSE +1 -1
  6. data/README.rdoc +64 -109
  7. data/Rakefile +22 -386
  8. data/bin/bundle +105 -0
  9. data/bin/console +7 -0
  10. data/bin/rake +20 -23
  11. data/bin/rdoc +29 -0
  12. data/bin/rubocop +29 -0
  13. data/bin/setup +6 -0
  14. data/doc/command_line_usage.rdoc +65 -21
  15. data/doc/glossary.rdoc +40 -49
  16. data/doc/jamis.rb +1 -0
  17. data/doc/rake.1 +156 -0
  18. data/doc/rakefile.rdoc +127 -62
  19. data/exe/rake +27 -0
  20. data/lib/rake.rb +37 -31
  21. data/lib/rake/application.rb +507 -272
  22. data/lib/rake/backtrace.rb +24 -0
  23. data/lib/rake/clean.rb +55 -8
  24. data/lib/rake/cloneable.rb +11 -19
  25. data/lib/rake/cpu_counter.rb +107 -0
  26. data/lib/rake/default_loader.rb +5 -0
  27. data/lib/rake/dsl_definition.rb +74 -46
  28. data/lib/rake/early_time.rb +5 -1
  29. data/lib/rake/ext/core.rb +5 -6
  30. data/lib/rake/ext/string.rb +61 -52
  31. data/lib/rake/file_creation_task.rb +4 -3
  32. data/lib/rake/file_list.rb +81 -49
  33. data/lib/rake/file_task.rb +15 -8
  34. data/lib/rake/file_utils.rb +69 -47
  35. data/lib/rake/file_utils_ext.rb +18 -26
  36. data/lib/rake/invocation_chain.rb +25 -19
  37. data/lib/rake/invocation_exception_mixin.rb +1 -0
  38. data/lib/rake/late_time.rb +18 -0
  39. data/lib/rake/linked_list.rb +112 -0
  40. data/lib/rake/loaders/makefile.rb +23 -9
  41. data/lib/rake/multi_task.rb +4 -6
  42. data/lib/rake/name_space.rb +36 -23
  43. data/lib/rake/packagetask.rb +71 -34
  44. data/lib/rake/phony.rb +16 -0
  45. data/lib/rake/private_reader.rb +21 -0
  46. data/lib/rake/promise.rb +100 -0
  47. data/lib/rake/pseudo_status.rb +8 -2
  48. data/lib/rake/rake_module.rb +41 -3
  49. data/lib/rake/rake_test_loader.rb +21 -7
  50. data/lib/rake/rule_recursion_overflow_error.rb +2 -2
  51. data/lib/rake/scope.rb +43 -0
  52. data/lib/rake/task.rb +186 -79
  53. data/lib/rake/task_argument_error.rb +1 -0
  54. data/lib/rake/task_arguments.rb +50 -15
  55. data/lib/rake/task_manager.rb +89 -65
  56. data/lib/rake/tasklib.rb +2 -12
  57. data/lib/rake/testtask.rb +61 -63
  58. data/lib/rake/thread_history_display.rb +49 -0
  59. data/lib/rake/thread_pool.rb +163 -0
  60. data/lib/rake/trace_output.rb +23 -0
  61. data/lib/rake/version.rb +7 -7
  62. data/lib/rake/win32.rb +14 -18
  63. data/rake.gemspec +43 -0
  64. metadata +82 -221
  65. data/.gemtest +0 -0
  66. data/CHANGES +0 -509
  67. data/RRR +0 -9
  68. data/TODO +0 -20
  69. data/doc/rake.1.gz +0 -0
  70. data/doc/release_notes/rake-0.4.14.rdoc +0 -23
  71. data/doc/release_notes/rake-0.4.15.rdoc +0 -35
  72. data/doc/release_notes/rake-0.5.0.rdoc +0 -53
  73. data/doc/release_notes/rake-0.5.3.rdoc +0 -78
  74. data/doc/release_notes/rake-0.5.4.rdoc +0 -46
  75. data/doc/release_notes/rake-0.6.0.rdoc +0 -141
  76. data/doc/release_notes/rake-0.7.0.rdoc +0 -119
  77. data/doc/release_notes/rake-0.7.1.rdoc +0 -59
  78. data/doc/release_notes/rake-0.7.2.rdoc +0 -121
  79. data/doc/release_notes/rake-0.7.3.rdoc +0 -47
  80. data/doc/release_notes/rake-0.8.0.rdoc +0 -114
  81. data/doc/release_notes/rake-0.8.2.rdoc +0 -165
  82. data/doc/release_notes/rake-0.8.3.rdoc +0 -112
  83. data/doc/release_notes/rake-0.8.4.rdoc +0 -147
  84. data/doc/release_notes/rake-0.8.5.rdoc +0 -53
  85. data/doc/release_notes/rake-0.8.6.rdoc +0 -55
  86. data/doc/release_notes/rake-0.8.7.rdoc +0 -55
  87. data/doc/release_notes/rake-0.9.0.rdoc +0 -112
  88. data/doc/release_notes/rake-0.9.1.rdoc +0 -52
  89. data/doc/release_notes/rake-0.9.2.rdoc +0 -49
  90. data/install.rb +0 -90
  91. data/lib/rake/alt_system.rb +0 -109
  92. data/lib/rake/classic_namespace.rb +0 -9
  93. data/lib/rake/contrib/compositepublisher.rb +0 -21
  94. data/lib/rake/contrib/ftptools.rb +0 -150
  95. data/lib/rake/contrib/publisher.rb +0 -69
  96. data/lib/rake/contrib/rubyforgepublisher.rb +0 -16
  97. data/lib/rake/contrib/sshpublisher.rb +0 -45
  98. data/lib/rake/contrib/sys.rb +0 -191
  99. data/lib/rake/ext/module.rb +0 -39
  100. data/lib/rake/ext/time.rb +0 -14
  101. data/lib/rake/gempackagetask.rb +0 -13
  102. data/lib/rake/pathmap.rb +0 -1
  103. data/lib/rake/rdoctask.rb +0 -230
  104. data/lib/rake/ruby182_test_unit_fix.rb +0 -25
  105. data/lib/rake/runtest.rb +0 -21
  106. data/test/check_expansion.rb +0 -5
  107. data/test/check_no_expansion.rb +0 -5
  108. data/test/data/access/Rakefile +0 -35
  109. data/test/data/chains/Rakefile +0 -15
  110. data/test/data/comments/Rakefile +0 -18
  111. data/test/data/default/Rakefile +0 -17
  112. data/test/data/deprecated_import/Rakefile +0 -1
  113. data/test/data/dryrun/Rakefile +0 -22
  114. data/test/data/extra/Rakefile +0 -1
  115. data/test/data/file_creation_task/Rakefile +0 -31
  116. data/test/data/imports/Rakefile +0 -19
  117. data/test/data/imports/deps.mf +0 -1
  118. data/test/data/multidesc/Rakefile +0 -15
  119. data/test/data/namespace/Rakefile +0 -64
  120. data/test/data/rakelib/test1.rb +0 -4
  121. data/test/data/rbext/rakefile.rb +0 -3
  122. data/test/data/sample.mf +0 -14
  123. data/test/data/statusreturn/Rakefile +0 -6
  124. data/test/data/unittest/Rakefile +0 -1
  125. data/test/data/verbose/Rakefile +0 -34
  126. data/test/file_creation.rb +0 -34
  127. data/test/helper.rb +0 -44
  128. data/test/in_environment.rb +0 -35
  129. data/test/reqfile.rb +0 -3
  130. data/test/reqfile2.rb +0 -3
  131. data/test/shellcommand.rb +0 -3
  132. data/test/test_rake.rb +0 -38
  133. data/test/test_rake_application.rb +0 -364
  134. data/test/test_rake_application_options.rb +0 -382
  135. data/test/test_rake_clean.rb +0 -12
  136. data/test/test_rake_definitions.rb +0 -80
  137. data/test/test_rake_directory_task.rb +0 -55
  138. data/test/test_rake_dsl.rb +0 -73
  139. data/test/test_rake_early_time.rb +0 -31
  140. data/test/test_rake_extension.rb +0 -59
  141. data/test/test_rake_file_creation_task.rb +0 -62
  142. data/test/test_rake_file_list.rb +0 -633
  143. data/test/test_rake_file_list_path_map.rb +0 -8
  144. data/test/test_rake_file_task.rb +0 -104
  145. data/test/test_rake_file_utils.rb +0 -252
  146. data/test/test_rake_ftp_file.rb +0 -59
  147. data/test/test_rake_functional.rb +0 -468
  148. data/test/test_rake_invocation_chain.rb +0 -52
  149. data/test/test_rake_makefile_loader.rb +0 -23
  150. data/test/test_rake_multi_task.rb +0 -51
  151. data/test/test_rake_name_space.rb +0 -43
  152. data/test/test_rake_package_task.rb +0 -78
  153. data/test/test_rake_path_map.rb +0 -157
  154. data/test/test_rake_path_map_explode.rb +0 -31
  155. data/test/test_rake_path_map_partial.rb +0 -18
  156. data/test/test_rake_pseudo_status.rb +0 -20
  157. data/test/test_rake_rdoc_task.rb +0 -81
  158. data/test/test_rake_require.rb +0 -35
  159. data/test/test_rake_rules.rb +0 -346
  160. data/test/test_rake_task.rb +0 -271
  161. data/test/test_rake_task_argument_parsing.rb +0 -116
  162. data/test/test_rake_task_arguments.rb +0 -86
  163. data/test/test_rake_task_lib.rb +0 -9
  164. data/test/test_rake_task_manager.rb +0 -145
  165. data/test/test_rake_task_manager_argument_resolution.rb +0 -36
  166. data/test/test_rake_task_with_arguments.rb +0 -162
  167. data/test/test_rake_test_task.rb +0 -122
  168. data/test/test_rake_top_level_functions.rb +0 -76
  169. data/test/test_rake_win32.rb +0 -83
  170. data/test/test_sys.rb +0 -20
@@ -1,8 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
-
3
- class TestRakeFileListPathMap < Rake::TestCase
4
- def test_file_list_supports_pathmap
5
- assert_equal ['a', 'b'], FileList['dir/a.rb', 'dir/b.rb'].pathmap("%n")
6
- end
7
- end
8
-
@@ -1,104 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
- require 'fileutils'
3
-
4
- class TestRakeFileTask < Rake::TestCase
5
- include Rake
6
-
7
- def setup
8
- super
9
-
10
- Task.clear
11
- @runs = Array.new
12
- FileUtils.rm_f NEWFILE
13
- FileUtils.rm_f OLDFILE
14
- end
15
-
16
- def test_file_need
17
- FileUtils.mkdir_p 'testdata' # HACK use tmpdir
18
-
19
- name = "testdata/dummy"
20
- file name
21
-
22
- ftask = Task[name]
23
-
24
- assert_equal name.to_s, ftask.name
25
- File.delete(ftask.name) rescue nil
26
-
27
- assert ftask.needed?, "file should be needed"
28
-
29
- open(ftask.name, "w") { |f| f.puts "HI" }
30
-
31
- assert_equal nil, ftask.prerequisites.collect{|n| Task[n].timestamp}.max
32
- assert ! ftask.needed?, "file should not be needed"
33
- ensure
34
- File.delete(ftask.name) rescue nil
35
- end
36
-
37
- def test_file_times_new_depends_on_old
38
- create_timed_files(OLDFILE, NEWFILE)
39
-
40
- t1 = Rake.application.intern(FileTask, NEWFILE).enhance([OLDFILE])
41
- t2 = Rake.application.intern(FileTask, OLDFILE)
42
- assert ! t2.needed?, "Should not need to build old file"
43
- assert ! t1.needed?, "Should not need to rebuild new file because of old"
44
- end
45
-
46
- def test_file_times_old_depends_on_new
47
- create_timed_files(OLDFILE, NEWFILE)
48
-
49
- t1 = Rake.application.intern(FileTask,OLDFILE).enhance([NEWFILE])
50
- t2 = Rake.application.intern(FileTask, NEWFILE)
51
- assert ! t2.needed?, "Should not need to build new file"
52
- preq_stamp = t1.prerequisites.collect{|t| Task[t].timestamp}.max
53
- assert_equal t2.timestamp, preq_stamp
54
- assert t1.timestamp < preq_stamp, "T1 should be older"
55
- assert t1.needed?, "Should need to rebuild old file because of new"
56
- end
57
-
58
- def test_file_depends_on_task_depend_on_file
59
- create_timed_files(OLDFILE, NEWFILE)
60
-
61
- file NEWFILE => [:obj] do |t| @runs << t.name end
62
- task :obj => [OLDFILE] do |t| @runs << t.name end
63
- file OLDFILE do |t| @runs << t.name end
64
-
65
- Task[:obj].invoke
66
- Task[NEWFILE].invoke
67
- assert ! @runs.include?(NEWFILE)
68
- end
69
-
70
- def test_existing_file_depends_on_non_existing_file
71
- @ran = false
72
-
73
- create_file(OLDFILE)
74
- delete_file(NEWFILE)
75
- file NEWFILE do
76
- @ran = true
77
- end
78
-
79
- file OLDFILE => NEWFILE
80
-
81
- Task[OLDFILE].invoke
82
-
83
- assert @ran
84
- end
85
-
86
- # I have currently disabled this test. I'm not convinced that
87
- # deleting the file target on failure is always the proper thing to
88
- # do. I'm willing to hear input on this topic.
89
- def ztest_file_deletes_on_failure
90
- task :obj
91
- file NEWFILE => [:obj] do |t|
92
- FileUtils.touch NEWFILE
93
- fail "Ooops"
94
- end
95
- assert Task[NEWFILE]
96
- begin
97
- Task[NEWFILE].invoke
98
- rescue Exception
99
- end
100
- assert( ! File.exist?(NEWFILE), "NEWFILE should be deleted")
101
- end
102
-
103
- end
104
-
@@ -1,252 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
- require 'fileutils'
3
- require 'stringio'
4
-
5
- class TestRakeFileUtils < Rake::TestCase
6
-
7
- def setup
8
- super
9
-
10
- File.chmod(0750, "test/shellcommand.rb")
11
- end
12
-
13
- def teardown
14
- File.chmod(0755, "test/shellcommand.rb")
15
- FileUtils.rm_rf("testdata")
16
- FileUtils::LN_SUPPORTED[0] = true
17
-
18
- super
19
- end
20
-
21
- def test_rm_one_file
22
- create_file("testdata/a")
23
- FileUtils.rm_rf "testdata/a"
24
- assert ! File.exist?("testdata/a")
25
- end
26
-
27
- def test_rm_two_files
28
- create_file("testdata/a")
29
- create_file("testdata/b")
30
- FileUtils.rm_rf ["testdata/a", "testdata/b"]
31
- assert ! File.exist?("testdata/a")
32
- assert ! File.exist?("testdata/b")
33
- end
34
-
35
- def test_rm_filelist
36
- list = Rake::FileList.new << "testdata/a" << "testdata/b"
37
- list.each { |fn| create_file(fn) }
38
- FileUtils.rm_r list
39
- assert ! File.exist?("testdata/a")
40
- assert ! File.exist?("testdata/b")
41
- end
42
-
43
- def test_ln
44
- create_dir("testdata")
45
- open("testdata/a", "w") { |f| f.puts "TEST_LN" }
46
- Rake::FileUtilsExt.safe_ln("testdata/a", "testdata/b", :verbose => false)
47
- assert_equal "TEST_LN\n", open("testdata/b") { |f| f.read }
48
- end
49
-
50
- class BadLink
51
- include Rake::FileUtilsExt
52
- attr_reader :cp_args
53
- def initialize(klass)
54
- @failure_class = klass
55
- end
56
- def cp(*args)
57
- @cp_args = args
58
- end
59
- def ln(*args)
60
- fail @failure_class, "ln not supported"
61
- end
62
- public :safe_ln
63
- end
64
-
65
- def test_safe_ln_failover_to_cp_on_standard_error
66
- FileUtils::LN_SUPPORTED[0] = true
67
- c = BadLink.new(StandardError)
68
- c.safe_ln "a", "b"
69
- assert_equal ['a', 'b'], c.cp_args
70
- c.safe_ln "x", "y"
71
- assert_equal ['x', 'y'], c.cp_args
72
- end
73
-
74
- def test_safe_ln_failover_to_cp_on_not_implemented_error
75
- FileUtils::LN_SUPPORTED[0] = true
76
- c = BadLink.new(NotImplementedError)
77
- c.safe_ln "a", "b"
78
- assert_equal ['a', 'b'], c.cp_args
79
- end
80
-
81
- def test_safe_ln_fails_on_script_error
82
- FileUtils::LN_SUPPORTED[0] = true
83
- c = BadLink.new(ScriptError)
84
- assert_raises(ScriptError) do c.safe_ln "a", "b" end
85
- end
86
-
87
- def test_verbose
88
- verbose true
89
- assert_equal true, verbose
90
- verbose false
91
- assert_equal false, verbose
92
- verbose(true) {
93
- assert_equal true, verbose
94
- }
95
- assert_equal false, verbose
96
- end
97
-
98
- def test_nowrite
99
- nowrite true
100
- assert_equal true, nowrite
101
- nowrite false
102
- assert_equal false, nowrite
103
- nowrite(true){
104
- assert_equal true, nowrite
105
- }
106
- assert_equal false, nowrite
107
- end
108
-
109
- def test_file_utils_methods_are_available_at_top_level
110
- create_file("testdata/a")
111
- rm_rf "testdata/a"
112
- assert ! File.exist?("testdata/a")
113
- end
114
-
115
- def test_fileutils_methods_dont_leak
116
- obj = Object.new
117
- assert_raises(NoMethodError) { obj.copy } # from FileUtils
118
- assert_raises(NoMethodError) { obj.ruby "-v" } # from RubyFileUtils
119
- end
120
-
121
- def test_sh
122
- verbose(false) { sh %{#{FileUtils::RUBY} test/shellcommand.rb} }
123
- assert true, "should not fail"
124
- end
125
-
126
- # If the :sh method is invoked directly from a test unit instance
127
- # (under mini/test), the mini/test version of fail is invoked rather
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
141
- end
142
-
143
- def test_sh_with_a_single_string_argument
144
- ENV['RAKE_TEST_SH'] = 'someval'
145
- verbose(false) {
146
- sh %{#{FileUtils::RUBY} test/check_expansion.rb #{env_var} someval}
147
- }
148
- end
149
-
150
- def test_sh_with_multiple_arguments
151
- ENV['RAKE_TEST_SH'] = 'someval'
152
- verbose(false) {
153
- Sh.ruby 'test/check_no_expansion.rb', env_var, 'someval'
154
- }
155
- end
156
-
157
- def test_sh_failure
158
- assert_raises(RuntimeError) {
159
- verbose(false) { Sh.run %{#{FileUtils::RUBY} test/shellcommand.rb 1} }
160
- }
161
- end
162
-
163
- def test_sh_special_handling
164
- count = 0
165
- verbose(false) {
166
- sh(%{#{FileUtils::RUBY} test/shellcommand.rb}) do |ok, res|
167
- assert(ok)
168
- assert_equal 0, res.exitstatus
169
- count += 1
170
- end
171
- sh(%{#{FileUtils::RUBY} test/shellcommand.rb 1}) do |ok, res|
172
- assert(!ok)
173
- assert_equal 1, res.exitstatus
174
- count += 1
175
- end
176
- }
177
- assert_equal 2, count, "Block count should be 2"
178
- end
179
-
180
- def test_sh_noop
181
- verbose(false) { sh %{test/shellcommand.rb 1}, :noop=>true }
182
- assert true, "should not fail"
183
- end
184
-
185
- def test_sh_bad_option
186
- ex = assert_raises(ArgumentError) {
187
- verbose(false) { sh %{test/shellcommand.rb}, :bad_option=>true }
188
- }
189
- assert_match(/bad_option/, ex.message)
190
- end
191
-
192
- def test_sh_verbose
193
- out = redirect_stderr {
194
- verbose(true) {
195
- sh %{test/shellcommand.rb}, :noop=>true
196
- }
197
- }
198
- assert_match(/^test\/shellcommand\.rb$/, out)
199
- end
200
-
201
- def test_sh_no_verbose
202
- out = redirect_stderr {
203
- verbose(false) {
204
- sh %{test/shellcommand.rb}, :noop=>true
205
- }
206
- }
207
- assert_equal '', out
208
- end
209
-
210
- def test_ruby_with_a_single_string_argument
211
- ENV['RAKE_TEST_SH'] = 'someval'
212
- verbose(false) {
213
- ruby %{test/check_expansion.rb #{env_var} someval}
214
- }
215
- end
216
-
217
- def test_ruby_with_multiple_arguments
218
- ENV['RAKE_TEST_SH'] = 'someval'
219
- verbose(false) {
220
- ruby 'test/check_no_expansion.rb', env_var, 'someval'
221
- }
222
- end
223
-
224
- def test_split_all
225
- assert_equal ['a'], Rake::FileUtilsExt.split_all('a')
226
- assert_equal ['..'], Rake::FileUtilsExt.split_all('..')
227
- assert_equal ['/'], Rake::FileUtilsExt.split_all('/')
228
- assert_equal ['a', 'b'], Rake::FileUtilsExt.split_all('a/b')
229
- assert_equal ['/', 'a', 'b'], Rake::FileUtilsExt.split_all('/a/b')
230
- assert_equal ['..', 'a', 'b'], Rake::FileUtilsExt.split_all('../a/b')
231
- end
232
-
233
- private
234
-
235
- def redirect_stderr
236
- old_err = $stderr
237
- $stderr = StringIO.new
238
- yield
239
- $stderr.string
240
- ensure
241
- $stderr = old_err
242
- end
243
-
244
- def windows?
245
- ! File::ALT_SEPARATOR.nil?
246
- end
247
-
248
- def env_var
249
- windows? ? '%RAKE_TEST_SH%' : '$RAKE_TEST_SH'
250
- end
251
-
252
- end
@@ -1,59 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
- require 'date'
3
- require 'time'
4
- require 'rake/contrib/ftptools'
5
-
6
- class FakeDate
7
- def self.today
8
- Date.new(2003,10,3)
9
- end
10
- def self.now
11
- Time.local(2003,10,3,12,00,00)
12
- end
13
- end
14
-
15
- class TestRakeFtpFile < Rake::TestCase
16
-
17
- def setup
18
- super
19
-
20
- Rake::FtpFile.class_eval { @date_class = FakeDate; @time_class = FakeDate }
21
- end
22
-
23
- def test_general
24
- file = Rake::FtpFile.new("here", "-rw-r--r-- 1 a279376 develop 121770 Mar 6 14:50 wiki.pl")
25
- assert_equal "wiki.pl", file.name
26
- assert_equal "here/wiki.pl", file.path
27
- assert_equal "a279376", file.owner
28
- assert_equal "develop", file.group
29
- assert_equal 0644, file.mode
30
- assert_equal 121770, file.size
31
- assert_equal Time.mktime(2003,3,6,14,50,0,0), file.time
32
- assert ! file.directory?
33
- assert ! file.symlink?
34
- end
35
-
36
- def test_far_date
37
- file = Rake::FtpFile.new(".", "drwxr-xr-x 3 a279376 develop 4096 Nov 26 2001 vss")
38
- assert_equal Time.mktime(2001,11,26,0,0,0,0), file.time
39
- end
40
-
41
- def test_close_date
42
- file = Rake::FtpFile.new(".", "drwxr-xr-x 3 a279376 develop 4096 Nov 26 15:35 vss")
43
- assert_equal Time.mktime(2002,11,26,15,35,0,0), file.time
44
- end
45
-
46
- def test_directory
47
- file = Rake::FtpFile.new(".", "drwxrwxr-x 9 a279376 develop 4096 Mar 13 14:32 working")
48
- assert file.directory?
49
- assert !file.symlink?
50
- end
51
-
52
- def test_symlink
53
- file = Rake::FtpFile.new(".", "lrwxrwxrwx 1 a279376 develop 64 Mar 26 2002 xtrac -> /home/a279376/working/ics/development/java/com/fmr/fwp/ics/xtrac")
54
- assert_equal 'xtrac', file.name
55
- assert file.symlink?
56
- assert !file.directory?
57
- end
58
- end
59
-
@@ -1,468 +0,0 @@
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
- require File.expand_path('../helper', __FILE__)
22
- 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
36
-
37
- class TestRakeFunctional < Rake::TestCase
38
-
39
- RUBY_COMMAND = 'ruby'
40
-
41
- def setup
42
- super
43
-
44
- @rake_path = File.expand_path("bin/rake")
45
- lib_path = File.expand_path("lib")
46
- @ruby_options = ["-I#{lib_path}", "-I."]
47
- @verbose = ! ENV['VERBOSE'].nil?
48
-
49
- if @verbose
50
- puts
51
- puts
52
- puts "--------------------------------------------------------------------"
53
- puts name
54
- puts "--------------------------------------------------------------------"
55
- end
56
- end
57
-
58
- def test_rake_default
59
- Dir.chdir("test/data/default") do rake end
60
- assert_match(/^DEFAULT$/, @out)
61
- assert_status
62
- end
63
-
64
- def test_rake_error_on_bad_task
65
- Dir.chdir("test/data/default") do rake "xyz" end
66
- assert_match(/rake aborted/, @err)
67
- assert_status(1)
68
- end
69
-
70
- def test_env_available_at_top_scope
71
- Dir.chdir("test/data/default") do rake "TESTTOPSCOPE=1" end
72
- assert_match(/^TOPSCOPE$/, @out)
73
- assert_status
74
- end
75
-
76
- def test_env_available_at_task_scope
77
- Dir.chdir("test/data/default") do rake "TESTTASKSCOPE=1 task_scope" end
78
- assert_match(/^TASKSCOPE$/, @out)
79
- assert_status
80
- end
81
-
82
- def test_multi_desc
83
- in_environment(
84
- 'RAKE_COLUMNS' => "80",
85
- "PWD" => "test/data/multidesc"
86
- ) do
87
- rake "-T"
88
- end
89
- assert_match %r{^rake a *# A / A2 *$}, @out
90
- assert_match %r{^rake b *# B *$}, @out
91
- refute_match %r{^rake c}, @out
92
- assert_match %r{^rake d *# x{65}\.\.\.$}, @out
93
- end
94
-
95
- def test_long_description
96
- in_environment("PWD" => "test/data/multidesc") do
97
- rake "--describe"
98
- end
99
- assert_match %r{^rake a\n *A / A2 *$}m, @out
100
- assert_match %r{^rake b\n *B *$}m, @out
101
- assert_match %r{^rake d\n *x{80}}m, @out
102
- refute_match %r{^rake c\n}m, @out
103
- end
104
-
105
- def test_proper_namespace_access
106
- in_environment("PWD" => "test/data/access") do
107
- rake
108
- end
109
- assert_not_match %r{^BAD:}, @out
110
- end
111
-
112
- def test_rbext
113
- in_environment("PWD" => "test/data/rbext") do
114
- rake "-N"
115
- end
116
- assert_match %r{^OK$}, @out
117
- end
118
-
119
- def test_system
120
- in_environment('RAKE_SYSTEM' => 'test/data/sys') do
121
- rake '-g', "sys1"
122
- end
123
- assert_match %r{^SYS1}, @out
124
- end
125
-
126
- def test_system_excludes_rakelib_files_too
127
- in_environment('RAKE_SYSTEM' => 'test/data/sys') do
128
- rake '-g', "sys1", '-T', 'extra'
129
- end
130
- refute_match %r{extra:extra}, @out
131
- end
132
-
133
- def test_by_default_rakelib_files_are_included
134
- in_environment('RAKE_SYSTEM' => 'test/data/sys', "PWD" => 'test/data/extra') do
135
- rake '-T', 'extra', '--trace'
136
- end
137
- assert_match %r{extra:extra}, @out
138
- end
139
-
140
- def test_implicit_system
141
- in_environment('RAKE_SYSTEM' => File.expand_path('test/data/sys'), "PWD" => "/") do
142
- rake "sys1", "--trace"
143
- end
144
- assert_match %r{^SYS1}, @out
145
- end
146
-
147
- def test_no_system
148
- in_environment('RAKE_SYSTEM' => 'test/data/sys', "PWD" => "test/data/extra") do
149
- rake '-G', "sys1"
150
- end
151
- assert_match %r{^Don't know how to build task}, @err # emacs wart: '
152
- end
153
-
154
- def test_nosearch_with_rakefile_uses_local_rakefile
155
- in_environment("PWD" => "test/data/default") do
156
- rake "--nosearch"
157
- end
158
- assert_match %r{^DEFAULT}, @out
159
- end
160
-
161
- def test_nosearch_without_rakefile_finds_system
162
- in_environment(
163
- "PWD" => "test/data/nosearch",
164
- "RAKE_SYSTEM" => File.expand_path("test/data/sys")
165
- ) do
166
- rake "--nosearch", "sys1"
167
- end
168
- assert_match %r{^SYS1}, @out
169
- end
170
-
171
- def test_nosearch_without_rakefile_and_no_system_fails
172
- in_environment("PWD" => "test/data/nosearch", "RAKE_SYSTEM" => "not_exist") do
173
- rake "--nosearch"
174
- end
175
- assert_match %r{^No Rakefile found}, @err
176
- end
177
-
178
- def test_invalid_command_line_options
179
- in_environment("PWD" => "test/data/default") do
180
- rake "--bad-options"
181
- end
182
- assert_match %r{invalid +option}i, @err
183
- end
184
-
185
- def test_inline_verbose_default_should_show_command
186
- in_environment("PWD" => "test/data/verbose") do
187
- rake "inline_verbose_default"
188
- end
189
- assert_match(/ruby -e/, @err)
190
- end
191
-
192
- def test_inline_verbose_true_should_show_command
193
- in_environment("PWD" => "test/data/verbose") do
194
- rake "inline_verbose_true"
195
- end
196
- assert_match(/ruby -e/, @err)
197
- end
198
-
199
- def test_inline_verbose_false_should_not_show_command
200
- in_environment("PWD" => "test/data/verbose") do
201
- rake "inline_verbose_false"
202
- end
203
- refute_match(/ruby -e/, @err)
204
- end
205
-
206
- def test_block_verbose_false_should_not_show_command
207
- in_environment("PWD" => "test/data/verbose") do
208
- rake "block_verbose_false"
209
- end
210
- refute_match(/ruby -e/, @err)
211
- end
212
-
213
- def test_block_verbose_true_should_show_command
214
- in_environment("PWD" => "test/data/verbose") do
215
- rake "block_verbose_true"
216
- end
217
- assert_match(/ruby -e/, @err)
218
- end
219
-
220
- def test_standalone_verbose_true_should_show_command
221
- in_environment("PWD" => "test/data/verbose") do
222
- rake "standalone_verbose_true"
223
- end
224
- assert_match(/ruby -e/, @err)
225
- end
226
-
227
- def test_standalone_verbose_false_should_not_show_command
228
- in_environment("PWD" => "test/data/verbose") do
229
- rake "standalone_verbose_false"
230
- end
231
- refute_match(/ruby -e/, @err)
232
- end
233
-
234
- def test_dry_run
235
- in_environment("PWD" => "test/data/default") do rake "-n", "other" end
236
- assert_match %r{Execute \(dry run\) default}, @err
237
- assert_match %r{Execute \(dry run\) other}, @err
238
- refute_match %r{DEFAULT}, @out
239
- refute_match %r{OTHER}, @out
240
- end
241
-
242
- # Test for the trace/dry_run bug found by Brian Chandler
243
- def test_dry_run_bug
244
- in_environment("PWD" => "test/data/dryrun") do
245
- rake
246
- end
247
- FileUtils.rm_f "test/data/dryrun/temp_one"
248
- in_environment("PWD" => "test/data/dryrun") do
249
- rake "--dry-run"
250
- end
251
- refute_match(/No such file/, @out)
252
- assert_status
253
- end
254
-
255
- # Test for the trace/dry_run bug found by Brian Chandler
256
- def test_trace_bug
257
- in_environment("PWD" => "test/data/dryrun") do
258
- rake
259
- end
260
- FileUtils.rm_f "test/data/dryrun/temp_one"
261
- in_environment("PWD" => "test/data/dryrun") do
262
- rake "--trace"
263
- end
264
- refute_match(/No such file/, @out)
265
- assert_status
266
- end
267
-
268
- def test_imports
269
- open("test/data/imports/static_deps", "w") do |f|
270
- f.puts 'puts "STATIC"'
271
- end
272
- FileUtils.rm_f "test/data/imports/dynamic_deps"
273
- in_environment("PWD" => "test/data/imports") do
274
- rake
275
- end
276
- assert File.exist?("test/data/imports/dynamic_deps"),
277
- "'dynamic_deps' file should exist"
278
- 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
- end
283
-
284
- def test_rules_chaining_to_file_task
285
- remove_chaining_files
286
- in_environment("PWD" => "test/data/chains") do
287
- rake
288
- end
289
- assert File.exist?("test/data/chains/play.app"),
290
- "'play.app' file should exist"
291
- assert_status
292
- remove_chaining_files
293
- end
294
-
295
- def test_file_creation_task
296
- in_environment("PWD" => "test/data/file_creation_task") do
297
- rake "prep"
298
- rake "run"
299
- rake "run"
300
- end
301
- assert(@err !~ /^cp src/, "Should not recopy data")
302
- end
303
-
304
- def test_dash_f_with_no_arg_foils_rakefile_lookup
305
- rake "-I test/data/rakelib -rtest1 -f"
306
- assert_match(/^TEST1$/, @out)
307
- end
308
-
309
- def test_dot_rake_files_can_be_loaded_with_dash_r
310
- rake "-I test/data/rakelib -rtest2 -f"
311
- assert_match(/^TEST2$/, @out)
312
- end
313
-
314
- def test_can_invoke_task_in_toplevel_namespace
315
- in_environment("PWD" => "test/data/namespace") do
316
- rake "copy"
317
- end
318
- assert_match(/^COPY$/, @out)
319
- end
320
-
321
- def test_can_invoke_task_in_nested_namespace
322
- in_environment("PWD" => "test/data/namespace") do
323
- rake "nest:copy"
324
- assert_match(/^NEST COPY$/, @out)
325
- end
326
- end
327
-
328
- def test_tasks_can_reference_task_in_same_namespace
329
- in_environment("PWD" => "test/data/namespace") do
330
- rake "nest:xx"
331
- assert_match(/^NEST COPY$/m, @out)
332
- end
333
- end
334
-
335
- def test_tasks_can_reference_task_in_other_namespaces
336
- in_environment("PWD" => "test/data/namespace") do
337
- rake "b:run"
338
- assert_match(/^IN A\nIN B$/m, @out)
339
- end
340
- end
341
-
342
- def test_anonymous_tasks_can_be_invoked_indirectly
343
- in_environment("PWD" => "test/data/namespace") do
344
- rake "anon"
345
- assert_match(/^ANON COPY$/m, @out)
346
- end
347
- end
348
-
349
- def test_rake_namespace_refers_to_toplevel
350
- in_environment("PWD" => "test/data/namespace") do
351
- rake "very:nested:run"
352
- assert_match(/^COPY$/m, @out)
353
- end
354
- end
355
-
356
- def test_file_task_are_not_scoped_by_namespaces
357
- in_environment("PWD" => "test/data/namespace") do
358
- rake "xyz.rb"
359
- assert_match(/^XYZ1\nXYZ2$/m, @out)
360
- end
361
- end
362
-
363
- def test_file_task_dependencies_scoped_by_namespaces
364
- in_environment("PWD" => "test/data/namespace") do
365
- rake "scopedep.rb"
366
- assert_match(/^PREPARE\nSCOPEDEP$/m, @out)
367
- end
368
- ensure
369
- remove_namespace_files
370
- end
371
-
372
- def test_rake_returns_status_error_values
373
- in_environment("PWD" => "test/data/statusreturn") do
374
- rake "exit5"
375
- assert_status(5)
376
- end
377
- end
378
-
379
- def test_rake_returns_no_status_error_on_normal_exit
380
- in_environment("PWD" => "test/data/statusreturn") do
381
- rake "normal"
382
- assert_status(0)
383
- end
384
- end
385
-
386
- def test_comment_before_task_acts_like_desc
387
- in_environment("PWD" => "test/data/comments") do
388
- rake "-T"
389
- end
390
- refute_match(/comment for t1/, @out)
391
- end
392
-
393
- def test_comment_separated_from_task_by_blank_line_is_not_picked_up
394
- Dir.chdir("test/data/comments") { rake("-T")}
395
- assert_not_match("t2", @out)
396
- end
397
-
398
- def test_comment_after_desc_is_ignored
399
- Dir.chdir("test/data/comments") { rake("-T")}
400
- assert_match("override comment for t3", @out)
401
- end
402
-
403
- def test_comment_before_desc_is_ignored
404
- Dir.chdir("test/data/comments") { rake("-T")}
405
- assert_match("override comment for t4", @out)
406
- end
407
-
408
- def test_correct_number_of_tasks_reported
409
- Dir.chdir("test/data/comments") { rake("-T")}
410
- assert_equal(2, @out.split(/\n/).grep(/t\d/).size)
411
- end
412
-
413
- def test_file_list_is_requirable_separately
414
- ruby "-rrake/file_list", "-e 'puts Rake::FileList[\"a\"].size'"
415
- assert_equal "1\n", @out
416
- assert_equal 0, @status
417
- end
418
-
419
- private
420
-
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
- # Run a shell Ruby command with command line options (using the
438
- # default test options). Output is captured in @out, @err and
439
- # @status.
440
- def ruby(*option_list)
441
- run_ruby(@ruby_options + option_list)
442
- end
443
-
444
- # Run a command line rake with the give rake options. Default
445
- # command line ruby options are included. Output is captured in
446
- # @out, @err and @status.
447
- def rake(*rake_options)
448
- run_ruby @ruby_options + [@rake_path] + rake_options
449
- end
450
-
451
- # Low level ruby command runner ...
452
- def run_ruby(option_list)
453
- shell = Session::Shell.new
454
- command = "#{RUBY_COMMAND} " + option_list.join(' ')
455
- puts "COMMAND: [#{command}]" if @verbose
456
- @out, @err = shell.execute command
457
- @status = shell.exit_status
458
- puts "STATUS: [#{@status}]" if @verbose
459
- puts "OUTPUT: [#{@out}]" if @verbose
460
- puts "ERROR: [#{@err}]" if @verbose
461
- puts "PWD: [#{Dir.pwd}]" if @verbose
462
- shell.close
463
- end
464
-
465
- def assert_status(expected_status=0)
466
- assert_equal expected_status, @status
467
- end
468
- end if defined?(Session)