rake 10.5.0 → 13.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +5 -5
  2. data/History.rdoc +2032 -288
  3. data/README.rdoc +40 -24
  4. data/doc/jamis.rb +1 -0
  5. data/doc/rake.1 +139 -124
  6. data/doc/rakefile.rdoc +2 -4
  7. data/{bin → exe}/rake +1 -7
  8. data/lib/rake/application.rb +131 -90
  9. data/lib/rake/backtrace.rb +3 -2
  10. data/lib/rake/clean.rb +7 -5
  11. data/lib/rake/cloneable.rb +1 -0
  12. data/lib/rake/cpu_counter.rb +10 -28
  13. data/lib/rake/default_loader.rb +1 -0
  14. data/lib/rake/dsl_definition.rb +5 -11
  15. data/lib/rake/early_time.rb +1 -0
  16. data/lib/rake/ext/core.rb +1 -0
  17. data/lib/rake/ext/string.rb +22 -21
  18. data/lib/rake/file_creation_task.rb +4 -3
  19. data/lib/rake/file_list.rb +34 -27
  20. data/lib/rake/file_task.rb +12 -4
  21. data/lib/rake/file_utils.rb +38 -32
  22. data/lib/rake/file_utils_ext.rb +8 -18
  23. data/lib/rake/invocation_chain.rb +1 -0
  24. data/lib/rake/invocation_exception_mixin.rb +1 -0
  25. data/lib/rake/late_time.rb +2 -1
  26. data/lib/rake/linked_list.rb +24 -15
  27. data/lib/rake/loaders/makefile.rb +5 -4
  28. data/lib/rake/multi_task.rb +2 -1
  29. data/lib/rake/name_space.rb +1 -1
  30. data/lib/rake/packagetask.rb +40 -17
  31. data/lib/rake/phony.rb +2 -1
  32. data/lib/rake/private_reader.rb +1 -0
  33. data/lib/rake/promise.rb +13 -12
  34. data/lib/rake/pseudo_status.rb +1 -0
  35. data/lib/rake/rake_module.rb +30 -1
  36. data/lib/rake/rake_test_loader.rb +9 -4
  37. data/lib/rake/rule_recursion_overflow_error.rb +2 -2
  38. data/lib/rake/scope.rb +3 -2
  39. data/lib/rake/task.rb +82 -31
  40. data/lib/rake/task_argument_error.rb +1 -0
  41. data/lib/rake/task_arguments.rb +15 -4
  42. data/lib/rake/task_manager.rb +56 -32
  43. data/lib/rake/tasklib.rb +2 -14
  44. data/lib/rake/testtask.rb +37 -61
  45. data/lib/rake/thread_history_display.rb +4 -3
  46. data/lib/rake/thread_pool.rb +16 -17
  47. data/lib/rake/trace_output.rb +2 -1
  48. data/lib/rake/version.rb +4 -1
  49. data/lib/rake/win32.rb +10 -15
  50. data/lib/rake.rb +35 -43
  51. data/rake.gemspec +100 -0
  52. metadata +27 -223
  53. data/.autotest +0 -7
  54. data/.rubocop.yml +0 -27
  55. data/.togglerc +0 -7
  56. data/CONTRIBUTING.rdoc +0 -38
  57. data/Manifest.txt +0 -166
  58. data/Rakefile +0 -81
  59. data/doc/release_notes/rake-0.4.14.rdoc +0 -23
  60. data/doc/release_notes/rake-0.4.15.rdoc +0 -35
  61. data/doc/release_notes/rake-0.5.0.rdoc +0 -53
  62. data/doc/release_notes/rake-0.5.3.rdoc +0 -78
  63. data/doc/release_notes/rake-0.5.4.rdoc +0 -46
  64. data/doc/release_notes/rake-0.6.0.rdoc +0 -141
  65. data/doc/release_notes/rake-0.7.0.rdoc +0 -119
  66. data/doc/release_notes/rake-0.7.1.rdoc +0 -59
  67. data/doc/release_notes/rake-0.7.2.rdoc +0 -121
  68. data/doc/release_notes/rake-0.7.3.rdoc +0 -47
  69. data/doc/release_notes/rake-0.8.0.rdoc +0 -114
  70. data/doc/release_notes/rake-0.8.2.rdoc +0 -165
  71. data/doc/release_notes/rake-0.8.3.rdoc +0 -112
  72. data/doc/release_notes/rake-0.8.4.rdoc +0 -147
  73. data/doc/release_notes/rake-0.8.5.rdoc +0 -53
  74. data/doc/release_notes/rake-0.8.6.rdoc +0 -37
  75. data/doc/release_notes/rake-0.8.7.rdoc +0 -55
  76. data/doc/release_notes/rake-0.9.0.rdoc +0 -112
  77. data/doc/release_notes/rake-0.9.1.rdoc +0 -52
  78. data/doc/release_notes/rake-0.9.2.2.rdoc +0 -55
  79. data/doc/release_notes/rake-0.9.2.rdoc +0 -49
  80. data/doc/release_notes/rake-0.9.3.rdoc +0 -102
  81. data/doc/release_notes/rake-0.9.4.rdoc +0 -60
  82. data/doc/release_notes/rake-0.9.5.rdoc +0 -55
  83. data/doc/release_notes/rake-0.9.6.rdoc +0 -64
  84. data/doc/release_notes/rake-10.0.0.rdoc +0 -178
  85. data/doc/release_notes/rake-10.0.1.rdoc +0 -58
  86. data/doc/release_notes/rake-10.0.2.rdoc +0 -53
  87. data/doc/release_notes/rake-10.0.3.rdoc +0 -191
  88. data/doc/release_notes/rake-10.1.0.rdoc +0 -61
  89. data/lib/rake/alt_system.rb +0 -110
  90. data/lib/rake/contrib/.document +0 -1
  91. data/lib/rake/contrib/compositepublisher.rb +0 -21
  92. data/lib/rake/contrib/ftptools.rb +0 -137
  93. data/lib/rake/contrib/publisher.rb +0 -81
  94. data/lib/rake/contrib/rubyforgepublisher.rb +0 -18
  95. data/lib/rake/contrib/sshpublisher.rb +0 -61
  96. data/lib/rake/contrib/sys.rb +0 -4
  97. data/lib/rake/ext/module.rb +0 -2
  98. data/lib/rake/ext/pathname.rb +0 -25
  99. data/lib/rake/ext/time.rb +0 -18
  100. data/lib/rake/gempackagetask.rb +0 -4
  101. data/lib/rake/pathmap.rb +0 -3
  102. data/lib/rake/rdoctask.rb +0 -4
  103. data/lib/rake/ruby182_test_unit_fix.rb +0 -29
  104. data/lib/rake/runtest.rb +0 -27
  105. data/rakelib/publish.rake +0 -20
  106. data/rakelib/test_times.rake +0 -25
  107. data/test/file_creation.rb +0 -34
  108. data/test/helper.rb +0 -129
  109. data/test/support/rakefile_definitions.rb +0 -478
  110. data/test/support/ruby_runner.rb +0 -34
  111. data/test/test_private_reader.rb +0 -42
  112. data/test/test_rake.rb +0 -40
  113. data/test/test_rake_application.rb +0 -643
  114. data/test/test_rake_application_options.rb +0 -468
  115. data/test/test_rake_backtrace.rb +0 -119
  116. data/test/test_rake_clean.rb +0 -61
  117. data/test/test_rake_cpu_counter.rb +0 -68
  118. data/test/test_rake_definitions.rb +0 -84
  119. data/test/test_rake_directory_task.rb +0 -76
  120. data/test/test_rake_dsl.rb +0 -40
  121. data/test/test_rake_early_time.rb +0 -31
  122. data/test/test_rake_extension.rb +0 -59
  123. data/test/test_rake_file_creation_task.rb +0 -56
  124. data/test/test_rake_file_list.rb +0 -670
  125. data/test/test_rake_file_list_path_map.rb +0 -8
  126. data/test/test_rake_file_task.rb +0 -197
  127. data/test/test_rake_file_utils.rb +0 -314
  128. data/test/test_rake_ftp_file.rb +0 -74
  129. data/test/test_rake_functional.rb +0 -482
  130. data/test/test_rake_invocation_chain.rb +0 -64
  131. data/test/test_rake_late_time.rb +0 -18
  132. data/test/test_rake_linked_list.rb +0 -84
  133. data/test/test_rake_makefile_loader.rb +0 -46
  134. data/test/test_rake_multi_task.rb +0 -64
  135. data/test/test_rake_name_space.rb +0 -57
  136. data/test/test_rake_package_task.rb +0 -79
  137. data/test/test_rake_path_map.rb +0 -168
  138. data/test/test_rake_path_map_explode.rb +0 -34
  139. data/test/test_rake_path_map_partial.rb +0 -18
  140. data/test/test_rake_pathname_extensions.rb +0 -15
  141. data/test/test_rake_pseudo_status.rb +0 -21
  142. data/test/test_rake_rake_test_loader.rb +0 -20
  143. data/test/test_rake_reduce_compat.rb +0 -26
  144. data/test/test_rake_require.rb +0 -40
  145. data/test/test_rake_rules.rb +0 -388
  146. data/test/test_rake_scope.rb +0 -44
  147. data/test/test_rake_task.rb +0 -393
  148. data/test/test_rake_task_argument_parsing.rb +0 -119
  149. data/test/test_rake_task_arguments.rb +0 -127
  150. data/test/test_rake_task_lib.rb +0 -9
  151. data/test/test_rake_task_manager.rb +0 -178
  152. data/test/test_rake_task_manager_argument_resolution.rb +0 -19
  153. data/test/test_rake_task_with_arguments.rb +0 -172
  154. data/test/test_rake_test_task.rb +0 -146
  155. data/test/test_rake_thread_pool.rb +0 -145
  156. data/test/test_rake_top_level_functions.rb +0 -71
  157. data/test/test_rake_win32.rb +0 -72
  158. data/test/test_thread_history_display.rb +0 -101
  159. data/test/test_trace_output.rb +0 -52
@@ -1,197 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
- require 'fileutils'
3
- require 'pathname'
4
-
5
- class TestRakeFileTask < Rake::TestCase
6
- include Rake
7
-
8
- def setup
9
- super
10
-
11
- Task.clear
12
- @runs = Array.new
13
- FileUtils.rm_f NEWFILE
14
- FileUtils.rm_f OLDFILE
15
- end
16
-
17
- def test_file_need
18
- name = "dummy"
19
- file name
20
-
21
- ftask = Task[name]
22
-
23
- assert_equal name.to_s, ftask.name
24
- File.delete(ftask.name) rescue nil
25
-
26
- assert ftask.needed?, "file should be needed"
27
- assert_equal Rake::LATE, ftask.timestamp
28
-
29
- open(ftask.name, "w") { |f| f.puts "HI" }
30
-
31
- assert_equal nil, ftask.prerequisites.map { |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_new_depend_on_regular_task_timestamps
47
- load_phony
48
-
49
- name = "dummy"
50
- task name
51
-
52
- create_timed_files(NEWFILE)
53
-
54
- t1 = Rake.application.intern(FileTask, NEWFILE).enhance([name])
55
-
56
- assert t1.needed?, "depending on non-file task uses Time.now"
57
-
58
- task(name => :phony)
59
-
60
- assert t1.needed?, "unless the non-file task has a timestamp"
61
- end
62
-
63
- def test_file_times_old_depends_on_new
64
- create_timed_files(OLDFILE, NEWFILE)
65
-
66
- t1 = Rake.application.intern(FileTask, OLDFILE).enhance([NEWFILE])
67
- t2 = Rake.application.intern(FileTask, NEWFILE)
68
- assert ! t2.needed?, "Should not need to build new file"
69
- preq_stamp = t1.prerequisites.map { |t| Task[t].timestamp }.max
70
- assert_equal t2.timestamp, preq_stamp
71
- assert t1.timestamp < preq_stamp, "T1 should be older"
72
- assert t1.needed?, "Should need to rebuild old file because of new"
73
- end
74
-
75
- def test_file_depends_on_task_depend_on_file
76
- create_timed_files(OLDFILE, NEWFILE)
77
-
78
- file NEWFILE => [:obj] do |t| @runs << t.name end
79
- task :obj => [OLDFILE] do |t| @runs << t.name end
80
- file OLDFILE do |t| @runs << t.name end
81
-
82
- Task[:obj].invoke
83
- Task[NEWFILE].invoke
84
- assert @runs.include?(NEWFILE)
85
- end
86
-
87
- def test_existing_file_depends_on_non_existing_file
88
- create_file(OLDFILE)
89
- delete_file(NEWFILE)
90
- file NEWFILE do |t| @runs << t.name end
91
- file OLDFILE => NEWFILE do |t| @runs << t.name end
92
-
93
- Task[OLDFILE].invoke
94
-
95
- assert_equal [NEWFILE, OLDFILE], @runs
96
- end
97
-
98
- def test_needed_eh_build_all
99
- create_file 'a'
100
-
101
- file 'a'
102
-
103
- a_task = Task['a']
104
-
105
- refute a_task.needed?
106
-
107
- Rake.application.options.build_all = true
108
-
109
- assert a_task.needed?
110
- ensure
111
- delete_file 'a'
112
- end
113
-
114
- def test_needed_eh_dependency
115
- create_file 'a', Time.now
116
- create_file 'b', Time.now - 60
117
-
118
- create_file 'c', Time.now
119
- create_file 'd', Time.now - 60
120
-
121
- file 'b' => 'a'
122
-
123
- b_task = Task['b']
124
-
125
- assert b_task.needed?
126
-
127
- file 'c' => 'd'
128
-
129
- c_task = Task['c']
130
-
131
- refute c_task.needed?
132
- ensure
133
- delete_file 'old'
134
- delete_file 'new'
135
- end
136
-
137
- def test_needed_eh_exists
138
- name = "dummy"
139
- file name
140
-
141
- ftask = Task[name]
142
-
143
- assert ftask.needed?
144
-
145
- create_file name
146
-
147
- refute ftask.needed?
148
- ensure
149
- delete_file name
150
- end
151
-
152
- def test_source_is_first_prerequisite
153
- t = file :f => ["preqA", "preqB"]
154
- assert_equal "preqA", t.source
155
- end
156
-
157
- def test_sources_is_all_prerequisites
158
- t = file :f => ["preqA", "preqB"]
159
- assert_equal ["preqA", "preqB"], t.sources
160
- end
161
-
162
- def test_task_can_be_pathname
163
- name = "dummy"
164
- file Pathname.new name
165
-
166
- ftask = Task[name]
167
-
168
- assert_equal name.to_s, ftask.name
169
- end
170
-
171
- def test_prerequisite_can_be_pathname
172
- t = file :f => Pathname.new("preq")
173
- assert_equal "preq", t.source
174
- end
175
-
176
- # I have currently disabled this test. I'm not convinced that
177
- # deleting the file target on failure is always the proper thing to
178
- # do. I'm willing to hear input on this topic.
179
- def ztest_file_deletes_on_failure
180
- task :obj
181
- file NEWFILE => [:obj] do |t|
182
- FileUtils.touch NEWFILE
183
- fail "Ooops"
184
- end
185
- assert Task[NEWFILE]
186
- begin
187
- Task[NEWFILE].invoke
188
- rescue Exception
189
- end
190
- assert(! File.exist?(NEWFILE), "NEWFILE should be deleted")
191
- end
192
-
193
- def load_phony
194
- load File.join(@rake_lib, "rake/phony.rb")
195
- end
196
-
197
- end
@@ -1,314 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
- require 'fileutils'
3
- require 'stringio'
4
-
5
- class TestRakeFileUtils < Rake::TestCase
6
- def setup
7
- super
8
- @rake_test_sh = ENV['RAKE_TEST_SH']
9
- end
10
-
11
- def teardown
12
- FileUtils::LN_SUPPORTED[0] = true
13
- RakeFileUtils.verbose_flag = Rake::FileUtilsExt::DEFAULT
14
- ENV['RAKE_TEST_SH'] = @rake_test_sh
15
-
16
- super
17
- end
18
-
19
- def test_rm_one_file
20
- create_file("a")
21
- FileUtils.rm_rf "a"
22
- refute File.exist?("a")
23
- end
24
-
25
- def test_rm_two_files
26
- create_file("a")
27
- create_file("b")
28
- FileUtils.rm_rf ["a", "b"]
29
- refute File.exist?("a")
30
- refute File.exist?("b")
31
- end
32
-
33
- def test_rm_filelist
34
- list = Rake::FileList.new << "a" << "b"
35
- list.each { |fn| create_file(fn) }
36
- FileUtils.rm_r list
37
- refute File.exist?("a")
38
- refute File.exist?("b")
39
- end
40
-
41
- def test_ln
42
- open("a", "w") { |f| f.puts "TEST_LN" }
43
-
44
- Rake::FileUtilsExt.safe_ln("a", "b", :verbose => false)
45
-
46
- assert_equal "TEST_LN\n", File.read('b')
47
- end
48
-
49
- class BadLink
50
- include Rake::FileUtilsExt
51
- attr_reader :cp_args
52
-
53
- def initialize(klass)
54
- @failure_class = klass
55
- end
56
-
57
- def cp(*args)
58
- @cp_args = args
59
- end
60
-
61
- def ln(*args)
62
- fail @failure_class, "ln not supported"
63
- end
64
-
65
- public :safe_ln
66
- end
67
-
68
- def test_safe_ln_failover_to_cp_on_standard_error
69
- FileUtils::LN_SUPPORTED[0] = true
70
- c = BadLink.new(StandardError)
71
- c.safe_ln "a", "b"
72
- assert_equal ['a', 'b'], c.cp_args
73
- c.safe_ln "x", "y"
74
- assert_equal ['x', 'y'], c.cp_args
75
- end
76
-
77
- def test_safe_ln_failover_to_cp_on_not_implemented_error
78
- FileUtils::LN_SUPPORTED[0] = true
79
- c = BadLink.new(NotImplementedError)
80
- c.safe_ln "a", "b"
81
- assert_equal ['a', 'b'], c.cp_args
82
- end
83
-
84
- def test_safe_ln_fails_on_script_error
85
- FileUtils::LN_SUPPORTED[0] = true
86
- c = BadLink.new(ScriptError)
87
- assert_raises(ScriptError) do c.safe_ln "a", "b" end
88
- end
89
-
90
- def test_verbose
91
- verbose true
92
- assert_equal true, verbose
93
- verbose false
94
- assert_equal false, verbose
95
- verbose(true) {
96
- assert_equal true, verbose
97
- }
98
- assert_equal false, verbose
99
- end
100
-
101
- def test_nowrite
102
- nowrite true
103
- assert_equal true, nowrite
104
- nowrite false
105
- assert_equal false, nowrite
106
- nowrite(true) {
107
- assert_equal true, nowrite
108
- }
109
- assert_equal false, nowrite
110
- end
111
-
112
- def test_file_utils_methods_are_available_at_top_level
113
- create_file("a")
114
-
115
- capture_io do
116
- rm_rf "a"
117
- end
118
-
119
- refute File.exist?("a")
120
- end
121
-
122
- def test_fileutils_methods_dont_leak
123
- obj = Object.new
124
- assert_raises(NoMethodError) { obj.copy } # from FileUtils
125
- assert_raises(NoMethodError) { obj.ruby "-v" } # from RubyFileUtils
126
- end
127
-
128
- def test_sh
129
- shellcommand
130
-
131
- verbose(false) { sh %{#{Rake::TestCase::RUBY} shellcommand.rb} }
132
- assert true, "should not fail"
133
- end
134
-
135
- def test_sh_with_a_single_string_argument
136
- check_expansion
137
-
138
- ENV['RAKE_TEST_SH'] = 'someval'
139
- verbose(false) {
140
- sh %{#{RUBY} check_expansion.rb #{env_var} someval}
141
- }
142
- end
143
-
144
- def test_sh_with_multiple_arguments
145
- check_no_expansion
146
- ENV['RAKE_TEST_SH'] = 'someval'
147
-
148
- verbose(false) {
149
- sh RUBY, 'check_no_expansion.rb', env_var, 'someval'
150
- }
151
- end
152
-
153
- def test_sh_failure
154
- shellcommand
155
-
156
- assert_raises(RuntimeError) {
157
- verbose(false) { sh %{#{RUBY} shellcommand.rb 1} }
158
- }
159
- end
160
-
161
- def test_sh_special_handling
162
- shellcommand
163
-
164
- count = 0
165
- verbose(false) {
166
- sh(%{#{RUBY} shellcommand.rb}) do |ok, res|
167
- assert(ok)
168
- assert_equal 0, res.exitstatus
169
- count += 1
170
- end
171
- sh(%{#{RUBY} 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
- shellcommand
182
-
183
- verbose(false) { sh %{shellcommand.rb 1}, :noop=>true }
184
- assert true, "should not fail"
185
- end
186
-
187
- def test_sh_bad_option
188
- shellcommand
189
-
190
- ex = assert_raises(ArgumentError) {
191
- verbose(false) { sh %{shellcommand.rb}, :bad_option=>true }
192
- }
193
- assert_match(/bad_option/, ex.message)
194
- end
195
-
196
- def test_sh_verbose
197
- shellcommand
198
-
199
- _, err = capture_io do
200
- verbose(true) {
201
- sh %{shellcommand.rb}, :noop=>true
202
- }
203
- end
204
-
205
- assert_equal "shellcommand.rb\n", err
206
- end
207
-
208
- def test_sh_verbose_false
209
- shellcommand
210
-
211
- _, err = capture_io do
212
- verbose(false) {
213
- sh %{shellcommand.rb}, :noop=>true
214
- }
215
- end
216
-
217
- assert_equal '', err
218
- end
219
-
220
- def test_sh_verbose_flag_nil
221
- shellcommand
222
-
223
- RakeFileUtils.verbose_flag = nil
224
-
225
- assert_silent do
226
- sh %{shellcommand.rb}, :noop=>true
227
- end
228
- end
229
-
230
- def test_ruby_with_a_single_string_argument
231
- check_expansion
232
-
233
- ENV['RAKE_TEST_SH'] = 'someval'
234
-
235
- verbose(false) {
236
- replace_ruby {
237
- ruby %{check_expansion.rb #{env_var} someval}
238
- }
239
- }
240
- end
241
-
242
- def test_ruby_with_multiple_arguments
243
- check_no_expansion
244
-
245
- ENV['RAKE_TEST_SH'] = 'someval'
246
- verbose(false) {
247
- replace_ruby {
248
- ruby 'check_no_expansion.rb', env_var, 'someval'
249
- }
250
- }
251
- end
252
-
253
- def test_split_all
254
- assert_equal ['a'], Rake::FileUtilsExt.split_all('a')
255
- assert_equal ['..'], Rake::FileUtilsExt.split_all('..')
256
- assert_equal ['/'], Rake::FileUtilsExt.split_all('/')
257
- assert_equal ['a', 'b'], Rake::FileUtilsExt.split_all('a/b')
258
- assert_equal ['/', 'a', 'b'], Rake::FileUtilsExt.split_all('/a/b')
259
- assert_equal ['..', 'a', 'b'], Rake::FileUtilsExt.split_all('../a/b')
260
- end
261
-
262
- def command(name, text)
263
- open name, 'w', 0750 do |io|
264
- io << text
265
- end
266
- end
267
-
268
- def check_no_expansion
269
- command 'check_no_expansion.rb', <<-CHECK_EXPANSION
270
- if ARGV[0] != ARGV[1]
271
- exit 0
272
- else
273
- exit 1
274
- end
275
- CHECK_EXPANSION
276
- end
277
-
278
- def check_expansion
279
- command 'check_expansion.rb', <<-CHECK_EXPANSION
280
- if ARGV[0] != ARGV[1]
281
- exit 1
282
- else
283
- exit 0
284
- end
285
- CHECK_EXPANSION
286
- end
287
-
288
- def replace_ruby
289
- ruby = FileUtils::RUBY
290
- FileUtils.send :remove_const, :RUBY
291
- FileUtils.const_set :RUBY, RUBY
292
- yield
293
- ensure
294
- FileUtils.send :remove_const, :RUBY
295
- FileUtils.const_set:RUBY, ruby
296
- end
297
-
298
- def shellcommand
299
- command 'shellcommand.rb', <<-SHELLCOMMAND
300
- #!/usr/bin/env ruby
301
-
302
- exit((ARGV[0] || "0").to_i)
303
- SHELLCOMMAND
304
- end
305
-
306
- def env_var
307
- windows? ? '%RAKE_TEST_SH%' : '$RAKE_TEST_SH'
308
- end
309
-
310
- def windows?
311
- ! File::ALT_SEPARATOR.nil?
312
- end
313
-
314
- end
@@ -1,74 +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
-
11
- def self.now
12
- Time.local(2003, 10, 3, 12, 00, 00)
13
- end
14
- end
15
-
16
- class TestRakeFtpFile < Rake::TestCase
17
-
18
- def setup
19
- super
20
-
21
- Rake::FtpFile.class_eval {
22
- @date_class = FakeDate
23
- @time_class = FakeDate
24
- }
25
- end
26
-
27
- def test_general
28
- file = Rake::FtpFile.new(
29
- "here",
30
- "-rw-r--r-- 1 a279376 develop 121770 Mar 6 14:50 wiki.pl")
31
- assert_equal "wiki.pl", file.name
32
- assert_equal "here/wiki.pl", file.path
33
- assert_equal "a279376", file.owner
34
- assert_equal "develop", file.group
35
- assert_equal 0644, file.mode
36
- assert_equal 121_770, file.size
37
- assert_equal Time.mktime(2003, 3, 6, 14, 50, 0, 0), file.time
38
- assert ! file.directory?
39
- assert ! file.symlink?
40
- end
41
-
42
- def test_far_date
43
- file = Rake::FtpFile.new(
44
- ".",
45
- "drwxr-xr-x 3 a279376 develop 4096 Nov 26 2001 vss")
46
- assert_equal Time.mktime(2001, 11, 26, 0, 0, 0, 0), file.time
47
- end
48
-
49
- def test_close_date
50
- file = Rake::FtpFile.new(
51
- ".",
52
- "drwxr-xr-x 3 a279376 develop 4096 Nov 26 15:35 vss")
53
- assert_equal Time.mktime(2002, 11, 26, 15, 35, 0, 0), file.time
54
- end
55
-
56
- def test_directory
57
- file = Rake::FtpFile.new(
58
- ".",
59
- "drwxrwxr-x 9 a279376 develop 4096 Mar 13 14:32 working")
60
- assert file.directory?
61
- assert !file.symlink?
62
- end
63
-
64
- def test_symlink
65
- file = Rake::FtpFile.new(
66
- ".",
67
- "lrwxrwxrwx 1 a279376 develop 64 Mar 26 2002 " +
68
- "xtrac -> /home/a279376/working/ics/development/java/" +
69
- "com/fmr/fwp/ics/xtrac")
70
- assert_equal 'xtrac', file.name
71
- assert file.symlink?
72
- assert !file.directory?
73
- end
74
- end