rake 11.1.2 → 11.2.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rake might be problematic. Click here for more details.

Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +14 -0
  3. data/.rubocop.yml +0 -9
  4. data/.travis.yml +28 -0
  5. data/CONTRIBUTING.rdoc +3 -5
  6. data/Gemfile +3 -0
  7. data/History.rdoc +1770 -273
  8. data/Rakefile +15 -68
  9. data/appveyor.yml +24 -0
  10. data/bin/console +7 -0
  11. data/bin/setup +6 -0
  12. data/doc/release_notes/README.md +4 -0
  13. data/doc/release_notes/rake-0.7.3.rdoc +0 -0
  14. data/{bin → exe}/rake +0 -6
  15. data/lib/rake.rb +1 -3
  16. data/lib/rake/application.rb +3 -6
  17. data/lib/rake/cpu_counter.rb +3 -17
  18. data/lib/rake/file_utils.rb +22 -6
  19. data/lib/rake/packagetask.rb +12 -1
  20. data/lib/rake/rake_test_loader.rb +0 -1
  21. data/lib/rake/rule_recursion_overflow_error.rb +0 -1
  22. data/lib/rake/task.rb +3 -3
  23. data/lib/rake/task_arguments.rb +2 -1
  24. data/lib/rake/testtask.rb +5 -1
  25. data/lib/rake/thread_pool.rb +0 -1
  26. data/lib/rake/version.rb +2 -0
  27. data/rake.gemspec +30 -0
  28. metadata +21 -110
  29. data/.autotest +0 -7
  30. data/.togglerc +0 -7
  31. data/Manifest.txt +0 -154
  32. data/lib/rake/contrib/.document +0 -1
  33. data/rakelib/test_times.rake +0 -25
  34. data/test/file_creation.rb +0 -34
  35. data/test/helper.rb +0 -134
  36. data/test/support/rakefile_definitions.rb +0 -476
  37. data/test/support/ruby_runner.rb +0 -34
  38. data/test/test_private_reader.rb +0 -42
  39. data/test/test_rake.rb +0 -40
  40. data/test/test_rake_application.rb +0 -659
  41. data/test/test_rake_application_options.rb +0 -468
  42. data/test/test_rake_backtrace.rb +0 -119
  43. data/test/test_rake_clean.rb +0 -61
  44. data/test/test_rake_cpu_counter.rb +0 -68
  45. data/test/test_rake_definitions.rb +0 -84
  46. data/test/test_rake_directory_task.rb +0 -76
  47. data/test/test_rake_dsl.rb +0 -40
  48. data/test/test_rake_early_time.rb +0 -31
  49. data/test/test_rake_extension.rb +0 -59
  50. data/test/test_rake_file_creation_task.rb +0 -56
  51. data/test/test_rake_file_list.rb +0 -687
  52. data/test/test_rake_file_list_path_map.rb +0 -15
  53. data/test/test_rake_file_task.rb +0 -197
  54. data/test/test_rake_file_utils.rb +0 -318
  55. data/test/test_rake_ftp_file.rb +0 -74
  56. data/test/test_rake_functional.rb +0 -484
  57. data/test/test_rake_invocation_chain.rb +0 -64
  58. data/test/test_rake_late_time.rb +0 -18
  59. data/test/test_rake_linked_list.rb +0 -84
  60. data/test/test_rake_makefile_loader.rb +0 -46
  61. data/test/test_rake_multi_task.rb +0 -64
  62. data/test/test_rake_name_space.rb +0 -57
  63. data/test/test_rake_package_task.rb +0 -79
  64. data/test/test_rake_path_map.rb +0 -168
  65. data/test/test_rake_path_map_explode.rb +0 -34
  66. data/test/test_rake_path_map_partial.rb +0 -18
  67. data/test/test_rake_pathname_extensions.rb +0 -15
  68. data/test/test_rake_pseudo_status.rb +0 -21
  69. data/test/test_rake_rake_test_loader.rb +0 -20
  70. data/test/test_rake_reduce_compat.rb +0 -26
  71. data/test/test_rake_require.rb +0 -40
  72. data/test/test_rake_rules.rb +0 -388
  73. data/test/test_rake_scope.rb +0 -44
  74. data/test/test_rake_task.rb +0 -430
  75. data/test/test_rake_task_argument_parsing.rb +0 -119
  76. data/test/test_rake_task_arguments.rb +0 -134
  77. data/test/test_rake_task_manager.rb +0 -178
  78. data/test/test_rake_task_manager_argument_resolution.rb +0 -19
  79. data/test/test_rake_task_with_arguments.rb +0 -172
  80. data/test/test_rake_test_task.rb +0 -130
  81. data/test/test_rake_thread_pool.rb +0 -145
  82. data/test/test_rake_top_level_functions.rb +0 -71
  83. data/test/test_rake_win32.rb +0 -72
  84. data/test/test_thread_history_display.rb +0 -101
  85. data/test/test_trace_output.rb +0 -52
@@ -1,15 +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
-
8
- def test_file_list_supports_pathmap_with_a_block
9
- mapped = FileList['dir/a.rb', 'dir/b.rb'].pathmap("%{.*,*}n") do |name|
10
- name.upcase
11
- end
12
- assert_equal ['A', 'B'], mapped
13
- end
14
- end
15
-
@@ -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,318 +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
- skip if jruby9? # https://github.com/jruby/jruby/issues/3653
146
-
147
- check_no_expansion
148
- ENV['RAKE_TEST_SH'] = 'someval'
149
-
150
- verbose(false) {
151
- sh RUBY, 'check_no_expansion.rb', env_var, 'someval'
152
- }
153
- end
154
-
155
- def test_sh_failure
156
- shellcommand
157
-
158
- assert_raises(RuntimeError) {
159
- verbose(false) { sh %{#{RUBY} shellcommand.rb 1} }
160
- }
161
- end
162
-
163
- def test_sh_special_handling
164
- shellcommand
165
-
166
- count = 0
167
- verbose(false) {
168
- sh(%{#{RUBY} shellcommand.rb}) do |ok, res|
169
- assert(ok)
170
- assert_equal 0, res.exitstatus
171
- count += 1
172
- end
173
- sh(%{#{RUBY} shellcommand.rb 1}) do |ok, res|
174
- assert(!ok)
175
- assert_equal 1, res.exitstatus
176
- count += 1
177
- end
178
- }
179
- assert_equal 2, count, "Block count should be 2"
180
- end
181
-
182
- def test_sh_noop
183
- shellcommand
184
-
185
- verbose(false) { sh %{shellcommand.rb 1}, :noop=>true }
186
- assert true, "should not fail"
187
- end
188
-
189
- def test_sh_bad_option
190
- shellcommand
191
-
192
- ex = assert_raises(ArgumentError) {
193
- verbose(false) { sh %{shellcommand.rb}, :bad_option=>true }
194
- }
195
- assert_match(/bad_option/, ex.message)
196
- end
197
-
198
- def test_sh_verbose
199
- shellcommand
200
-
201
- _, err = capture_io do
202
- verbose(true) {
203
- sh %{shellcommand.rb}, :noop=>true
204
- }
205
- end
206
-
207
- assert_equal "shellcommand.rb\n", err
208
- end
209
-
210
- def test_sh_verbose_false
211
- shellcommand
212
-
213
- _, err = capture_io do
214
- verbose(false) {
215
- sh %{shellcommand.rb}, :noop=>true
216
- }
217
- end
218
-
219
- assert_equal '', err
220
- end
221
-
222
- def test_sh_verbose_flag_nil
223
- shellcommand
224
-
225
- RakeFileUtils.verbose_flag = nil
226
-
227
- assert_silent do
228
- sh %{shellcommand.rb}, :noop=>true
229
- end
230
- end
231
-
232
- def test_ruby_with_a_single_string_argument
233
- check_expansion
234
-
235
- ENV['RAKE_TEST_SH'] = 'someval'
236
-
237
- verbose(false) {
238
- replace_ruby {
239
- ruby %{check_expansion.rb #{env_var} someval}
240
- }
241
- }
242
- end
243
-
244
- def test_ruby_with_multiple_arguments
245
- skip if jruby9? # https://github.com/jruby/jruby/issues/3653
246
-
247
- check_no_expansion
248
-
249
- ENV['RAKE_TEST_SH'] = 'someval'
250
- verbose(false) {
251
- replace_ruby {
252
- ruby 'check_no_expansion.rb', env_var, 'someval'
253
- }
254
- }
255
- end
256
-
257
- def test_split_all
258
- assert_equal ['a'], Rake::FileUtilsExt.split_all('a')
259
- assert_equal ['..'], Rake::FileUtilsExt.split_all('..')
260
- assert_equal ['/'], Rake::FileUtilsExt.split_all('/')
261
- assert_equal ['a', 'b'], Rake::FileUtilsExt.split_all('a/b')
262
- assert_equal ['/', 'a', 'b'], Rake::FileUtilsExt.split_all('/a/b')
263
- assert_equal ['..', 'a', 'b'], Rake::FileUtilsExt.split_all('../a/b')
264
- end
265
-
266
- def command(name, text)
267
- open name, 'w', 0750 do |io|
268
- io << text
269
- end
270
- end
271
-
272
- def check_no_expansion
273
- command 'check_no_expansion.rb', <<-CHECK_EXPANSION
274
- if ARGV[0] != ARGV[1]
275
- exit 0
276
- else
277
- exit 1
278
- end
279
- CHECK_EXPANSION
280
- end
281
-
282
- def check_expansion
283
- command 'check_expansion.rb', <<-CHECK_EXPANSION
284
- if ARGV[0] != ARGV[1]
285
- exit 1
286
- else
287
- exit 0
288
- end
289
- CHECK_EXPANSION
290
- end
291
-
292
- def replace_ruby
293
- ruby = FileUtils::RUBY
294
- FileUtils.send :remove_const, :RUBY
295
- FileUtils.const_set :RUBY, RUBY
296
- yield
297
- ensure
298
- FileUtils.send :remove_const, :RUBY
299
- FileUtils.const_set:RUBY, ruby
300
- end
301
-
302
- def shellcommand
303
- command 'shellcommand.rb', <<-SHELLCOMMAND
304
- #!/usr/bin/env ruby
305
-
306
- exit((ARGV[0] || "0").to_i)
307
- SHELLCOMMAND
308
- end
309
-
310
- def env_var
311
- windows? ? '%RAKE_TEST_SH%' : '$RAKE_TEST_SH'
312
- end
313
-
314
- def windows?
315
- ! File::ALT_SEPARATOR.nil?
316
- end
317
-
318
- end