rake 0.8.7 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gemtest +0 -0
- data/CHANGES +78 -9
- data/{README → README.rdoc} +14 -10
- data/RRR +9 -0
- data/Rakefile +100 -125
- data/TODO +1 -1
- data/bin/rake +4 -3
- data/doc/command_line_usage.rdoc +18 -6
- data/doc/glossary.rdoc +2 -2
- data/doc/jamis.rb +2 -2
- data/doc/proto_rake.rdoc +22 -22
- data/doc/rake.1.gz +0 -0
- data/doc/rakefile.rdoc +56 -33
- data/doc/rational.rdoc +6 -6
- data/doc/release_notes/rake-0.4.15.rdoc +1 -1
- data/doc/release_notes/rake-0.5.0.rdoc +1 -1
- data/doc/release_notes/rake-0.7.0.rdoc +1 -1
- data/doc/release_notes/rake-0.7.2.rdoc +3 -3
- data/doc/release_notes/rake-0.7.3.rdoc +2 -2
- data/doc/release_notes/rake-0.8.0.rdoc +1 -1
- data/doc/release_notes/rake-0.8.2.rdoc +3 -3
- data/doc/release_notes/rake-0.8.3.rdoc +2 -2
- data/doc/release_notes/rake-0.8.4.rdoc +1 -1
- data/doc/release_notes/rake-0.8.5.rdoc +1 -1
- data/doc/release_notes/rake-0.8.6.rdoc +1 -1
- data/doc/release_notes/rake-0.8.7.rdoc +1 -1
- data/doc/release_notes/rake-0.9.0.rdoc +112 -0
- data/doc/release_notes/rake-0.9.1.rdoc +52 -0
- data/doc/release_notes/rake-0.9.2.rdoc +49 -0
- data/install.rb +14 -12
- data/lib/rake/alt_system.rb +7 -6
- data/lib/rake/application.rb +589 -0
- data/lib/rake/classic_namespace.rb +1 -0
- data/lib/rake/clean.rb +2 -4
- data/lib/rake/cloneable.rb +25 -0
- data/lib/rake/contrib/compositepublisher.rb +2 -5
- data/lib/rake/contrib/ftptools.rb +5 -8
- data/lib/rake/contrib/publisher.rb +2 -8
- data/lib/rake/contrib/rubyforgepublisher.rb +2 -4
- data/lib/rake/contrib/sshpublisher.rb +4 -6
- data/lib/rake/contrib/sys.rb +7 -25
- data/lib/rake/default_loader.rb +10 -0
- data/lib/rake/dsl_definition.rb +167 -0
- data/lib/rake/early_time.rb +18 -0
- data/lib/rake/ext/core.rb +27 -0
- data/lib/rake/ext/module.rb +39 -0
- data/lib/rake/ext/string.rb +167 -0
- data/lib/rake/ext/time.rb +14 -0
- data/lib/rake/file_creation_task.rb +24 -0
- data/lib/rake/file_list.rb +403 -0
- data/lib/rake/file_task.rb +47 -0
- data/lib/rake/file_utils.rb +112 -0
- data/lib/rake/file_utils_ext.rb +142 -0
- data/lib/rake/gempackagetask.rb +6 -90
- data/lib/rake/invocation_chain.rb +51 -0
- data/lib/rake/invocation_exception_mixin.rb +16 -0
- data/lib/rake/loaders/makefile.rb +13 -15
- data/lib/rake/multi_task.rb +16 -0
- data/lib/rake/name_space.rb +25 -0
- data/lib/rake/packagetask.rb +13 -12
- data/lib/rake/pathmap.rb +1 -0
- data/lib/rake/pseudo_status.rb +24 -0
- data/lib/rake/rake_module.rb +29 -0
- data/lib/rake/rake_test_loader.rb +10 -2
- data/lib/rake/rdoctask.rb +211 -190
- data/lib/rake/ruby182_test_unit_fix.rb +9 -7
- data/lib/rake/rule_recursion_overflow_error.rb +20 -0
- data/lib/rake/runtest.rb +4 -6
- data/lib/rake/task.rb +327 -0
- data/lib/rake/task_argument_error.rb +7 -0
- data/lib/rake/task_arguments.rb +74 -0
- data/lib/rake/task_manager.rb +307 -0
- data/lib/rake/tasklib.rb +1 -2
- data/lib/rake/testtask.rb +57 -27
- data/lib/rake/version.rb +10 -0
- data/lib/rake/win32.rb +4 -4
- data/lib/rake.rb +29 -2470
- data/test/data/access/Rakefile +35 -0
- data/test/data/comments/Rakefile +18 -0
- data/test/data/default/Rakefile +1 -3
- data/test/data/deprecated_import/Rakefile +1 -0
- data/test/data/dryrun/Rakefile +1 -1
- data/test/data/extra/Rakefile +1 -0
- data/test/data/file_creation_task/Rakefile +1 -3
- data/test/data/multidesc/Rakefile +0 -2
- data/test/data/namespace/Rakefile +9 -2
- data/test/data/rakelib/test1.rb +1 -0
- data/test/data/statusreturn/Rakefile +0 -2
- data/test/data/verbose/Rakefile +34 -0
- data/test/{filecreation.rb → file_creation.rb} +11 -9
- data/test/helper.rb +44 -0
- data/test/in_environment.rb +11 -6
- data/test/test_rake.rb +3 -6
- data/test/test_rake_application.rb +364 -0
- data/test/test_rake_application_options.rb +382 -0
- data/test/{test_clean.rb → test_rake_clean.rb} +2 -4
- data/test/{test_definitions.rb → test_rake_definitions.rb} +7 -12
- data/test/test_rake_directory_task.rb +55 -0
- data/test/test_rake_dsl.rb +73 -0
- data/test/{test_earlytime.rb → test_rake_early_time.rb} +3 -7
- data/test/{test_extension.rb → test_rake_extension.rb} +4 -8
- data/test/{test_file_creation_task.rb → test_rake_file_creation_task.rb} +7 -7
- data/test/{test_filelist.rb → test_rake_file_list.rb} +45 -35
- data/test/test_rake_file_list_path_map.rb +8 -0
- data/test/{test_file_task.rb → test_rake_file_task.rb} +23 -62
- data/test/{test_fileutils.rb → test_rake_file_utils.rb} +34 -33
- data/test/{test_ftp.rb → test_rake_ftp_file.rb} +5 -5
- data/test/{session_functional.rb → test_rake_functional.rb} +173 -44
- data/test/test_rake_invocation_chain.rb +52 -0
- data/test/{test_makefile_loader.rb → test_rake_makefile_loader.rb} +2 -5
- data/test/{test_multitask.rb → test_rake_multi_task.rb} +18 -12
- data/test/{test_namespace.rb → test_rake_name_space.rb} +4 -16
- data/test/test_rake_package_task.rb +78 -0
- data/test/{test_pathmap.rb → test_rake_path_map.rb} +5 -58
- data/test/test_rake_path_map_explode.rb +31 -0
- data/test/test_rake_path_map_partial.rb +18 -0
- data/test/{test_pseudo_status.rb → test_rake_pseudo_status.rb} +2 -8
- data/test/{test_rdoc_task.rb → test_rake_rdoc_task.rb} +22 -29
- data/test/{test_require.rb → test_rake_require.rb} +11 -11
- data/test/{test_rules.rb → test_rake_rules.rb} +12 -15
- data/test/{test_tasks.rb → test_rake_task.rb} +75 -178
- data/test/test_rake_task_argument_parsing.rb +116 -0
- data/test/{test_task_arguments.rb → test_rake_task_arguments.rb} +7 -10
- data/test/{test_tasklib.rb → test_rake_task_lib.rb} +2 -5
- data/test/{test_task_manager.rb → test_rake_task_manager.rb} +12 -40
- data/test/test_rake_task_manager_argument_resolution.rb +36 -0
- data/test/test_rake_task_with_arguments.rb +162 -0
- data/test/test_rake_test_task.rb +122 -0
- data/test/{test_top_level_functions.rb → test_rake_top_level_functions.rb} +12 -22
- data/test/{test_win32.rb → test_rake_win32.rb} +21 -10
- data/test/test_sys.rb +20 -0
- metadata +129 -51
- data/test/capture_stdout.rb +0 -26
- data/test/contrib/test_sys.rb +0 -47
- data/test/functional.rb +0 -15
- data/test/rake_test_setup.rb +0 -24
- data/test/test_application.rb +0 -675
- data/test/test_invocation_chain.rb +0 -81
- data/test/test_package_task.rb +0 -118
- data/test/test_test_task.rb +0 -77
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
require 'rake'
|
|
5
|
-
|
|
6
|
-
require 'test/capture_stdout'
|
|
7
|
-
require 'test/rake_test_setup'
|
|
8
|
-
|
|
9
|
-
class TestFileList < Test::Unit::TestCase
|
|
3
|
+
class TestRakeFileList < Rake::TestCase
|
|
10
4
|
FileList = Rake::FileList
|
|
11
|
-
include CaptureStdout
|
|
12
|
-
include TestMethods
|
|
13
5
|
|
|
14
6
|
def setup
|
|
7
|
+
super
|
|
8
|
+
|
|
15
9
|
create_test_data
|
|
16
10
|
end
|
|
17
11
|
|
|
18
12
|
def teardown
|
|
19
13
|
# FileList.select_default_ignore_patterns
|
|
20
14
|
FileUtils.rm_rf("testdata")
|
|
15
|
+
|
|
16
|
+
super
|
|
21
17
|
end
|
|
22
18
|
|
|
23
|
-
def
|
|
19
|
+
def test_delegating_methods_do_not_include_to_a_or_to_ary
|
|
24
20
|
assert ! FileList::DELEGATING_METHODS.include?("to_a"), "should not include to_a"
|
|
25
21
|
assert ! FileList::DELEGATING_METHODS.include?(:to_a), "should not include to_a"
|
|
26
22
|
assert ! FileList::DELEGATING_METHODS.include?("to_ary"), "should not include to_ary"
|
|
@@ -87,11 +83,11 @@ class TestFileList < Test::Unit::TestCase
|
|
|
87
83
|
h = f.include("y")
|
|
88
84
|
assert_equal f.object_id, h.object_id
|
|
89
85
|
end
|
|
90
|
-
|
|
86
|
+
|
|
91
87
|
def test_match
|
|
92
88
|
fl = FileList.new
|
|
93
|
-
fl.include('test/
|
|
94
|
-
assert fl.include?("test/
|
|
89
|
+
fl.include('test/test_*.rb')
|
|
90
|
+
assert fl.include?("test/test_rake_file_list.rb")
|
|
95
91
|
assert fl.size > 3
|
|
96
92
|
fl.each { |fn| assert_match(/\.rb$/, fn) }
|
|
97
93
|
end
|
|
@@ -102,7 +98,7 @@ class TestFileList < Test::Unit::TestCase
|
|
|
102
98
|
fl.include("test/*.rb")
|
|
103
99
|
assert_equal "a.java", fl[0]
|
|
104
100
|
assert fl.size > 2
|
|
105
|
-
assert fl.include?("test/
|
|
101
|
+
assert fl.include?("test/test_rake_file_list.rb")
|
|
106
102
|
end
|
|
107
103
|
|
|
108
104
|
def test_multiple_patterns
|
|
@@ -153,7 +149,7 @@ class TestFileList < Test::Unit::TestCase
|
|
|
153
149
|
fl.exclude('testdata/existing')
|
|
154
150
|
assert_equal [], fl
|
|
155
151
|
end
|
|
156
|
-
|
|
152
|
+
|
|
157
153
|
def test_excluding_via_block
|
|
158
154
|
fl = FileList['testdata/a.c', 'testdata/b.c', 'testdata/xyz.c']
|
|
159
155
|
fl.exclude { |fn| fn.pathmap('%n') == 'xyz' }
|
|
@@ -233,24 +229,24 @@ class TestFileList < Test::Unit::TestCase
|
|
|
233
229
|
assert_equal ["testdata/abc.o", "testdata/x.o", "testdata/xyz.o"].sort,
|
|
234
230
|
f3.sort
|
|
235
231
|
end
|
|
236
|
-
|
|
232
|
+
|
|
237
233
|
def test_claim_to_be_a_kind_of_array
|
|
238
234
|
fl = FileList['testdata/*.c']
|
|
239
235
|
assert fl.is_a?(Array)
|
|
240
236
|
assert fl.kind_of?(Array)
|
|
241
237
|
end
|
|
242
|
-
|
|
238
|
+
|
|
243
239
|
def test_claim_to_be_a_kind_of_filelist
|
|
244
240
|
fl = FileList['testdata/*.c']
|
|
245
241
|
assert fl.is_a?(FileList)
|
|
246
242
|
assert fl.kind_of?(FileList)
|
|
247
243
|
end
|
|
248
|
-
|
|
244
|
+
|
|
249
245
|
def test_claim_to_be_a_filelist_instance
|
|
250
246
|
fl = FileList['testdata/*.c']
|
|
251
247
|
assert fl.instance_of?(FileList)
|
|
252
248
|
end
|
|
253
|
-
|
|
249
|
+
|
|
254
250
|
def test_dont_claim_to_be_an_array_instance
|
|
255
251
|
fl = FileList['testdata/*.c']
|
|
256
252
|
assert ! fl.instance_of?(Array)
|
|
@@ -323,24 +319,38 @@ class TestFileList < Test::Unit::TestCase
|
|
|
323
319
|
f.sort
|
|
324
320
|
end
|
|
325
321
|
|
|
322
|
+
def test_egrep_returns_0_if_no_matches
|
|
323
|
+
files = FileList['test/lib/*_test.rb'].exclude("test/lib/filelist_test.rb")
|
|
324
|
+
assert_equal 0, files.egrep(/XYZZY/) { }
|
|
325
|
+
end
|
|
326
|
+
|
|
326
327
|
def test_egrep_with_output
|
|
327
|
-
files = FileList['test/
|
|
328
|
+
files = FileList['test/test_*.rb']
|
|
328
329
|
the_line_number = __LINE__ + 1
|
|
329
|
-
out =
|
|
330
|
+
out, = capture_io do files.egrep(/PUGH/) end
|
|
330
331
|
assert_match(/:#{the_line_number}:/, out)
|
|
331
332
|
end
|
|
332
333
|
|
|
333
334
|
def test_egrep_with_block
|
|
334
|
-
files = FileList['test/
|
|
335
|
-
found =
|
|
335
|
+
files = FileList['test/test_*.rb']
|
|
336
|
+
found = nil
|
|
336
337
|
the_line_number = __LINE__ + 1
|
|
337
338
|
files.egrep(/XYZZY/) do |fn, ln, line |
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
339
|
+
found = [fn, ln, line]
|
|
340
|
+
end
|
|
341
|
+
assert_equal 'test/test_rake_file_list.rb', found[0]
|
|
342
|
+
assert_equal the_line_number, found[1]
|
|
343
|
+
assert_match(/files\.egrep/, found[2])
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
def test_egrep_with_error
|
|
347
|
+
files = FileList['test/test_*.rb']
|
|
348
|
+
_, err = capture_io do
|
|
349
|
+
files.egrep(/ANYTHING/) do |fn, ln, line |
|
|
350
|
+
fail "_EGREP_FAILURE_"
|
|
351
|
+
end
|
|
342
352
|
end
|
|
343
|
-
|
|
353
|
+
assert_match(/_EGREP_FAILURE_/, err)
|
|
344
354
|
end
|
|
345
355
|
|
|
346
356
|
def test_existing
|
|
@@ -447,7 +457,7 @@ class TestFileList < Test::Unit::TestCase
|
|
|
447
457
|
a = FileList['a', 'b', 'c']
|
|
448
458
|
a.freeze
|
|
449
459
|
c = a.clone
|
|
450
|
-
|
|
460
|
+
assert_raises(TypeError, RuntimeError) do
|
|
451
461
|
c << 'more'
|
|
452
462
|
end
|
|
453
463
|
end
|
|
@@ -588,12 +598,12 @@ class TestFileList < Test::Unit::TestCase
|
|
|
588
598
|
assert_equal ['b', 'd'], r
|
|
589
599
|
assert_equal FileList, r.class
|
|
590
600
|
end
|
|
591
|
-
|
|
601
|
+
|
|
592
602
|
def test_file_utils_can_use_filelists
|
|
593
603
|
cfiles = FileList['testdata/*.c']
|
|
594
|
-
|
|
604
|
+
|
|
595
605
|
cp cfiles, @cdir, :verbose => false
|
|
596
|
-
|
|
606
|
+
|
|
597
607
|
assert File.exist?(File.join(@cdir, 'abc.c'))
|
|
598
608
|
assert File.exist?(File.join(@cdir, 'xyz.c'))
|
|
599
609
|
assert File.exist?(File.join(@cdir, 'x.c'))
|
|
@@ -601,7 +611,7 @@ class TestFileList < Test::Unit::TestCase
|
|
|
601
611
|
|
|
602
612
|
def create_test_data
|
|
603
613
|
verbose(false) do
|
|
604
|
-
|
|
614
|
+
|
|
605
615
|
mkdir "testdata" unless File.exist? "testdata"
|
|
606
616
|
mkdir "testdata/CVS" rescue nil
|
|
607
617
|
mkdir "testdata/.svn" rescue nil
|
|
@@ -619,5 +629,5 @@ class TestFileList < Test::Unit::TestCase
|
|
|
619
629
|
touch "testdata/existing"
|
|
620
630
|
end
|
|
621
631
|
end
|
|
622
|
-
|
|
632
|
+
|
|
623
633
|
end
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
require 'test/unit'
|
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
|
4
2
|
require 'fileutils'
|
|
5
|
-
require 'rake'
|
|
6
|
-
require 'test/filecreation'
|
|
7
|
-
require 'test/rake_test_setup'
|
|
8
3
|
|
|
9
|
-
|
|
10
|
-
class TestFileTask < Test::Unit::TestCase
|
|
4
|
+
class TestRakeFileTask < Rake::TestCase
|
|
11
5
|
include Rake
|
|
12
|
-
include FileCreation
|
|
13
|
-
include TestMethods
|
|
14
6
|
|
|
15
7
|
def setup
|
|
8
|
+
super
|
|
9
|
+
|
|
16
10
|
Task.clear
|
|
17
11
|
@runs = Array.new
|
|
18
12
|
FileUtils.rm_f NEWFILE
|
|
@@ -20,15 +14,23 @@ class TestFileTask < Test::Unit::TestCase
|
|
|
20
14
|
end
|
|
21
15
|
|
|
22
16
|
def test_file_need
|
|
17
|
+
FileUtils.mkdir_p 'testdata' # HACK use tmpdir
|
|
18
|
+
|
|
23
19
|
name = "testdata/dummy"
|
|
24
20
|
file name
|
|
21
|
+
|
|
25
22
|
ftask = Task[name]
|
|
23
|
+
|
|
26
24
|
assert_equal name.to_s, ftask.name
|
|
27
25
|
File.delete(ftask.name) rescue nil
|
|
26
|
+
|
|
28
27
|
assert ftask.needed?, "file should be needed"
|
|
28
|
+
|
|
29
29
|
open(ftask.name, "w") { |f| f.puts "HI" }
|
|
30
|
+
|
|
30
31
|
assert_equal nil, ftask.prerequisites.collect{|n| Task[n].timestamp}.max
|
|
31
32
|
assert ! ftask.needed?, "file should not be needed"
|
|
33
|
+
ensure
|
|
32
34
|
File.delete(ftask.name) rescue nil
|
|
33
35
|
end
|
|
34
36
|
|
|
@@ -66,18 +68,26 @@ class TestFileTask < Test::Unit::TestCase
|
|
|
66
68
|
end
|
|
67
69
|
|
|
68
70
|
def test_existing_file_depends_on_non_existing_file
|
|
71
|
+
@ran = false
|
|
72
|
+
|
|
69
73
|
create_file(OLDFILE)
|
|
70
74
|
delete_file(NEWFILE)
|
|
71
|
-
file NEWFILE
|
|
75
|
+
file NEWFILE do
|
|
76
|
+
@ran = true
|
|
77
|
+
end
|
|
78
|
+
|
|
72
79
|
file OLDFILE => NEWFILE
|
|
73
|
-
|
|
80
|
+
|
|
81
|
+
Task[OLDFILE].invoke
|
|
82
|
+
|
|
83
|
+
assert @ran
|
|
74
84
|
end
|
|
75
85
|
|
|
76
86
|
# I have currently disabled this test. I'm not convinced that
|
|
77
87
|
# deleting the file target on failure is always the proper thing to
|
|
78
88
|
# do. I'm willing to hear input on this topic.
|
|
79
89
|
def ztest_file_deletes_on_failure
|
|
80
|
-
task :obj
|
|
90
|
+
task :obj
|
|
81
91
|
file NEWFILE => [:obj] do |t|
|
|
82
92
|
FileUtils.touch NEWFILE
|
|
83
93
|
fail "Ooops"
|
|
@@ -92,52 +102,3 @@ class TestFileTask < Test::Unit::TestCase
|
|
|
92
102
|
|
|
93
103
|
end
|
|
94
104
|
|
|
95
|
-
######################################################################
|
|
96
|
-
class TestDirectoryTask < Test::Unit::TestCase
|
|
97
|
-
include Rake
|
|
98
|
-
|
|
99
|
-
def setup
|
|
100
|
-
rm_rf "testdata", :verbose=>false
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
def teardown
|
|
104
|
-
rm_rf "testdata", :verbose=>false
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
def test_directory
|
|
108
|
-
desc "DESC"
|
|
109
|
-
directory "testdata/a/b/c"
|
|
110
|
-
assert_equal FileCreationTask, Task["testdata"].class
|
|
111
|
-
assert_equal FileCreationTask, Task["testdata/a"].class
|
|
112
|
-
assert_equal FileCreationTask, Task["testdata/a/b/c"].class
|
|
113
|
-
assert_nil Task["testdata"].comment
|
|
114
|
-
assert_equal "DESC", Task["testdata/a/b/c"].comment
|
|
115
|
-
assert_nil Task["testdata/a/b"].comment
|
|
116
|
-
verbose(false) {
|
|
117
|
-
Task['testdata/a/b'].invoke
|
|
118
|
-
}
|
|
119
|
-
assert File.exist?("testdata/a/b")
|
|
120
|
-
assert ! File.exist?("testdata/a/b/c")
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
if Rake::Win32.windows?
|
|
124
|
-
def test_directory_win32
|
|
125
|
-
desc "WIN32 DESC"
|
|
126
|
-
FileUtils.mkdir_p("testdata")
|
|
127
|
-
Dir.chdir("testdata") do
|
|
128
|
-
directory 'c:/testdata/a/b/c'
|
|
129
|
-
assert_equal FileCreationTask, Task['c:/testdata'].class
|
|
130
|
-
assert_equal FileCreationTask, Task['c:/testdata/a'].class
|
|
131
|
-
assert_equal FileCreationTask, Task['c:/testdata/a/b/c'].class
|
|
132
|
-
assert_nil Task['c:/testdata'].comment
|
|
133
|
-
assert_equal "WIN32 DESC", Task['c:/testdata/a/b/c'].comment
|
|
134
|
-
assert_nil Task['c:/testdata/a/b'].comment
|
|
135
|
-
verbose(false) {
|
|
136
|
-
Task['c:/testdata/a/b'].invoke
|
|
137
|
-
}
|
|
138
|
-
assert File.exist?('c:/testdata/a/b')
|
|
139
|
-
assert ! File.exist?('c:/testdata/a/b/c')
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
end
|
|
@@ -1,25 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
require 'rake'
|
|
4
|
-
require 'test/unit'
|
|
5
|
-
require 'test/filecreation'
|
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
|
6
2
|
require 'fileutils'
|
|
7
3
|
require 'stringio'
|
|
8
|
-
require 'test/rake_test_setup'
|
|
9
4
|
|
|
10
|
-
class
|
|
11
|
-
include FileCreation
|
|
12
|
-
include TestMethods
|
|
5
|
+
class TestRakeFileUtils < Rake::TestCase
|
|
13
6
|
|
|
14
7
|
def setup
|
|
15
|
-
|
|
8
|
+
super
|
|
9
|
+
|
|
10
|
+
File.chmod(0750, "test/shellcommand.rb")
|
|
16
11
|
end
|
|
17
|
-
|
|
12
|
+
|
|
18
13
|
def teardown
|
|
14
|
+
File.chmod(0755, "test/shellcommand.rb")
|
|
19
15
|
FileUtils.rm_rf("testdata")
|
|
20
16
|
FileUtils::LN_SUPPORTED[0] = true
|
|
17
|
+
|
|
18
|
+
super
|
|
21
19
|
end
|
|
22
|
-
|
|
20
|
+
|
|
23
21
|
def test_rm_one_file
|
|
24
22
|
create_file("testdata/a")
|
|
25
23
|
FileUtils.rm_rf "testdata/a"
|
|
@@ -45,12 +43,12 @@ class TestFileUtils < Test::Unit::TestCase
|
|
|
45
43
|
def test_ln
|
|
46
44
|
create_dir("testdata")
|
|
47
45
|
open("testdata/a", "w") { |f| f.puts "TEST_LN" }
|
|
48
|
-
|
|
46
|
+
Rake::FileUtilsExt.safe_ln("testdata/a", "testdata/b", :verbose => false)
|
|
49
47
|
assert_equal "TEST_LN\n", open("testdata/b") { |f| f.read }
|
|
50
48
|
end
|
|
51
49
|
|
|
52
50
|
class BadLink
|
|
53
|
-
include
|
|
51
|
+
include Rake::FileUtilsExt
|
|
54
52
|
attr_reader :cp_args
|
|
55
53
|
def initialize(klass)
|
|
56
54
|
@failure_class = klass
|
|
@@ -83,7 +81,7 @@ class TestFileUtils < Test::Unit::TestCase
|
|
|
83
81
|
def test_safe_ln_fails_on_script_error
|
|
84
82
|
FileUtils::LN_SUPPORTED[0] = true
|
|
85
83
|
c = BadLink.new(ScriptError)
|
|
86
|
-
|
|
84
|
+
assert_raises(ScriptError) do c.safe_ln "a", "b" end
|
|
87
85
|
end
|
|
88
86
|
|
|
89
87
|
def test_verbose
|
|
@@ -116,12 +114,12 @@ class TestFileUtils < Test::Unit::TestCase
|
|
|
116
114
|
|
|
117
115
|
def test_fileutils_methods_dont_leak
|
|
118
116
|
obj = Object.new
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
assert_raises(NoMethodError) { obj.copy } # from FileUtils
|
|
118
|
+
assert_raises(NoMethodError) { obj.ruby "-v" } # from RubyFileUtils
|
|
121
119
|
end
|
|
122
120
|
|
|
123
121
|
def test_sh
|
|
124
|
-
verbose(false) { sh %{
|
|
122
|
+
verbose(false) { sh %{#{FileUtils::RUBY} test/shellcommand.rb} }
|
|
125
123
|
assert true, "should not fail"
|
|
126
124
|
end
|
|
127
125
|
|
|
@@ -137,37 +135,40 @@ class TestFileUtils < Test::Unit::TestCase
|
|
|
137
135
|
def self.run(*args)
|
|
138
136
|
new.run(*args)
|
|
139
137
|
end
|
|
138
|
+
def self.ruby(*args)
|
|
139
|
+
Sh.run(RUBY, *args)
|
|
140
|
+
end
|
|
140
141
|
end
|
|
141
142
|
|
|
142
143
|
def test_sh_with_a_single_string_argument
|
|
143
144
|
ENV['RAKE_TEST_SH'] = 'someval'
|
|
144
145
|
verbose(false) {
|
|
145
|
-
sh %{
|
|
146
|
+
sh %{#{FileUtils::RUBY} test/check_expansion.rb #{env_var} someval}
|
|
146
147
|
}
|
|
147
148
|
end
|
|
148
149
|
|
|
149
150
|
def test_sh_with_multiple_arguments
|
|
150
151
|
ENV['RAKE_TEST_SH'] = 'someval'
|
|
151
152
|
verbose(false) {
|
|
152
|
-
Sh.
|
|
153
|
+
Sh.ruby 'test/check_no_expansion.rb', env_var, 'someval'
|
|
153
154
|
}
|
|
154
155
|
end
|
|
155
156
|
|
|
156
157
|
def test_sh_failure
|
|
157
|
-
|
|
158
|
-
verbose(false) { Sh.run %{
|
|
158
|
+
assert_raises(RuntimeError) {
|
|
159
|
+
verbose(false) { Sh.run %{#{FileUtils::RUBY} test/shellcommand.rb 1} }
|
|
159
160
|
}
|
|
160
161
|
end
|
|
161
162
|
|
|
162
163
|
def test_sh_special_handling
|
|
163
164
|
count = 0
|
|
164
165
|
verbose(false) {
|
|
165
|
-
sh(%{
|
|
166
|
+
sh(%{#{FileUtils::RUBY} test/shellcommand.rb}) do |ok, res|
|
|
166
167
|
assert(ok)
|
|
167
168
|
assert_equal 0, res.exitstatus
|
|
168
169
|
count += 1
|
|
169
170
|
end
|
|
170
|
-
sh(%{
|
|
171
|
+
sh(%{#{FileUtils::RUBY} test/shellcommand.rb 1}) do |ok, res|
|
|
171
172
|
assert(!ok)
|
|
172
173
|
assert_equal 1, res.exitstatus
|
|
173
174
|
count += 1
|
|
@@ -182,7 +183,7 @@ class TestFileUtils < Test::Unit::TestCase
|
|
|
182
183
|
end
|
|
183
184
|
|
|
184
185
|
def test_sh_bad_option
|
|
185
|
-
ex =
|
|
186
|
+
ex = assert_raises(ArgumentError) {
|
|
186
187
|
verbose(false) { sh %{test/shellcommand.rb}, :bad_option=>true }
|
|
187
188
|
}
|
|
188
189
|
assert_match(/bad_option/, ex.message)
|
|
@@ -221,16 +222,16 @@ class TestFileUtils < Test::Unit::TestCase
|
|
|
221
222
|
end
|
|
222
223
|
|
|
223
224
|
def test_split_all
|
|
224
|
-
assert_equal ['a'],
|
|
225
|
-
assert_equal ['..'],
|
|
226
|
-
assert_equal ['/'],
|
|
227
|
-
assert_equal ['a', 'b'],
|
|
228
|
-
assert_equal ['/', 'a', 'b'],
|
|
229
|
-
assert_equal ['..', 'a', 'b'],
|
|
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')
|
|
230
231
|
end
|
|
231
232
|
|
|
232
233
|
private
|
|
233
|
-
|
|
234
|
+
|
|
234
235
|
def redirect_stderr
|
|
235
236
|
old_err = $stderr
|
|
236
237
|
$stderr = StringIO.new
|
|
@@ -247,5 +248,5 @@ class TestFileUtils < Test::Unit::TestCase
|
|
|
247
248
|
def env_var
|
|
248
249
|
windows? ? '%RAKE_TEST_SH%' : '$RAKE_TEST_SH'
|
|
249
250
|
end
|
|
250
|
-
|
|
251
|
+
|
|
251
252
|
end
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
require File.expand_path('../helper', __FILE__)
|
|
3
2
|
require 'date'
|
|
4
3
|
require 'time'
|
|
5
|
-
require 'test/unit'
|
|
6
4
|
require 'rake/contrib/ftptools'
|
|
7
5
|
|
|
8
6
|
class FakeDate
|
|
@@ -14,10 +12,11 @@ class FakeDate
|
|
|
14
12
|
end
|
|
15
13
|
end
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
class TestFtpFile < Test::Unit::TestCase
|
|
15
|
+
class TestRakeFtpFile < Rake::TestCase
|
|
19
16
|
|
|
20
17
|
def setup
|
|
18
|
+
super
|
|
19
|
+
|
|
21
20
|
Rake::FtpFile.class_eval { @date_class = FakeDate; @time_class = FakeDate }
|
|
22
21
|
end
|
|
23
22
|
|
|
@@ -57,3 +56,4 @@ class TestFtpFile < Test::Unit::TestCase
|
|
|
57
56
|
assert !file.directory?
|
|
58
57
|
end
|
|
59
58
|
end
|
|
59
|
+
|