rake 0.5.4 → 0.6.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.
- data.tar.gz.sig +0 -0
- data/CHANGES +24 -0
- data/README +28 -11
- data/Rakefile +22 -30
- data/bin/rake +1 -1
- data/doc/jamis.rb +132 -105
- data/doc/release_notes/rake-0.6.0.rdoc +141 -0
- data/lib/rake.rb +661 -455
- data/lib/rake/classic_namespace.rb +8 -0
- data/lib/rake/gempackagetask.rb +5 -3
- data/lib/rake/packagetask.rb +0 -2
- data/lib/rake/rake_test_loader.rb +1 -1
- data/lib/rake/testtask.rb +8 -2
- data/test/data/chains/Rakefile +15 -0
- data/test/data/default/Rakefile +19 -0
- data/test/data/dryrun/Rakefile +22 -0
- data/test/data/file_creation_task/Rakefile +30 -0
- data/test/data/imports/Rakefile +19 -0
- data/test/data/imports/deps.mf +1 -0
- data/test/data/multidesc/Rakefile +14 -0
- data/test/data/sample.mf +9 -0
- data/test/filecreation.rb +18 -9
- data/test/functional.rb +2 -130
- data/test/session_functional.rb +159 -0
- data/test/{testclean.rb → test_clean.rb} +1 -0
- data/test/test_definitions.rb +82 -0
- data/test/test_earlytime.rb +31 -0
- data/test/test_file_creation_task.rb +56 -0
- data/test/test_file_task.rb +140 -0
- data/test/{testfilelist.rb → test_filelist.rb} +17 -2
- data/test/{testfileutils.rb → test_fileutils.rb} +10 -2
- data/test/{testftp.rb → test_ftp.rb} +0 -0
- data/test/test_makefile_loader.rb +2 -0
- data/test/{testpackagetask.rb → test_package_task.rb} +45 -0
- data/test/test_rake.rb +21 -0
- data/test/test_rules.rb +206 -0
- data/test/test_tasks.rb +77 -0
- data/test/{testtesttask.rb → test_test_task.rb} +5 -0
- metadata +72 -12
- metadata.gz.sig +2 -0
- data/TAGS +0 -126
- data/test/testtasks.rb +0 -400
@@ -0,0 +1,82 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'rake'
|
6
|
+
require 'test/filecreation'
|
7
|
+
|
8
|
+
######################################################################
|
9
|
+
class TestDefinitions < Test::Unit::TestCase
|
10
|
+
include Rake
|
11
|
+
EXISTINGFILE = "testdata/existing"
|
12
|
+
|
13
|
+
def setup
|
14
|
+
Task.clear
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_task
|
18
|
+
done = false
|
19
|
+
task :one => [:two] do done = true end
|
20
|
+
task :two
|
21
|
+
task :three => [:one, :two]
|
22
|
+
check_tasks(:one, :two, :three)
|
23
|
+
assert done, "Should be done"
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_file_task
|
27
|
+
done = false
|
28
|
+
file "testdata/one" => "testdata/two" do done = true end
|
29
|
+
file "testdata/two"
|
30
|
+
file "testdata/three" => ["testdata/one", "testdata/two"]
|
31
|
+
check_tasks("testdata/one", "testdata/two", "testdata/three")
|
32
|
+
assert done, "Should be done"
|
33
|
+
end
|
34
|
+
|
35
|
+
def check_tasks(n1, n2, n3)
|
36
|
+
t = Task[n1]
|
37
|
+
assert Task === t, "Should be a Task"
|
38
|
+
assert_equal n1.to_s, t.name
|
39
|
+
assert_equal [n2.to_s], t.prerequisites.collect{|n| n.to_s}
|
40
|
+
t.invoke
|
41
|
+
t2 = Task[n2]
|
42
|
+
assert_equal FileList[], t2.prerequisites
|
43
|
+
t3 = Task[n3]
|
44
|
+
assert_equal [n1.to_s, n2.to_s], t3.prerequisites.collect{|n|n.to_s}
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_incremental_definitions
|
48
|
+
runs = []
|
49
|
+
task :t1 => [:t2] do runs << "A"; 4321 end
|
50
|
+
task :t1 => [:t3] do runs << "B"; 1234 end
|
51
|
+
task :t1 => [:t3]
|
52
|
+
task :t2
|
53
|
+
task :t3
|
54
|
+
Task[:t1].invoke
|
55
|
+
assert_equal ["A", "B"], runs
|
56
|
+
assert_equal ["t2", "t3"], Task[:t1].prerequisites
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_missing_dependencies
|
60
|
+
task :x => ["testdata/missing"]
|
61
|
+
assert_raises(RuntimeError) { Task[:x].invoke }
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_implicit_file_dependencies
|
65
|
+
runs = []
|
66
|
+
create_existing_file
|
67
|
+
task :y => [EXISTINGFILE] do |t| runs << t.name end
|
68
|
+
Task[:y].invoke
|
69
|
+
assert_equal runs, ['y']
|
70
|
+
end
|
71
|
+
|
72
|
+
private # ----------------------------------------------------------
|
73
|
+
|
74
|
+
def create_existing_file
|
75
|
+
Dir.mkdir File.dirname(EXISTINGFILE) unless
|
76
|
+
File.exist?(File.dirname(EXISTINGFILE))
|
77
|
+
open(EXISTINGFILE, "w") do |f| f.puts "HI" end unless
|
78
|
+
File.exist?(EXISTINGFILE)
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rake'
|
5
|
+
|
6
|
+
class TestEarlyTime < Test::Unit::TestCase
|
7
|
+
def test_create
|
8
|
+
early = Rake::EarlyTime.instance
|
9
|
+
time = Time.mktime(1920, 1, 1, 0, 0, 0)
|
10
|
+
assert early <= Time.now
|
11
|
+
assert early < Time.now
|
12
|
+
assert early != Time.now
|
13
|
+
assert Time.now > early
|
14
|
+
assert Time.now >= early
|
15
|
+
assert Time.now != early
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_equality
|
19
|
+
early = Rake::EarlyTime.instance
|
20
|
+
assert_equal early, early, "two early times should be equal"
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_original_time_compare_is_not_messed_up
|
24
|
+
t1 = Time.mktime(1920, 1, 1, 0, 0, 0)
|
25
|
+
t2 = Time.now
|
26
|
+
assert t1 < t2
|
27
|
+
assert t2 > t1
|
28
|
+
assert t1 == t1
|
29
|
+
assert t2 == t2
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'rake'
|
6
|
+
require 'test/filecreation'
|
7
|
+
|
8
|
+
######################################################################
|
9
|
+
class TestFileCreationTask < Test::Unit::TestCase
|
10
|
+
include Rake
|
11
|
+
include FileCreation
|
12
|
+
|
13
|
+
DUMMY_DIR = 'testdata/dummy_dir'
|
14
|
+
|
15
|
+
def setup
|
16
|
+
Task.clear
|
17
|
+
end
|
18
|
+
|
19
|
+
def teardown
|
20
|
+
FileUtils.rm_rf DUMMY_DIR
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_file_needed
|
24
|
+
create_dir DUMMY_DIR
|
25
|
+
fc_task = Task[DUMMY_DIR]
|
26
|
+
assert_equal DUMMY_DIR, fc_task.name
|
27
|
+
FileUtils.rm_rf fc_task.name
|
28
|
+
assert fc_task.needed?, "file should be needed"
|
29
|
+
FileUtils.mkdir fc_task.name
|
30
|
+
assert_equal nil, fc_task.prerequisites.collect{|n| Task[n].timestamp}.max
|
31
|
+
assert ! fc_task.needed?, "file should not be needed"
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_directory
|
35
|
+
directory DUMMY_DIR
|
36
|
+
fc_task = Task[DUMMY_DIR]
|
37
|
+
assert_equal DUMMY_DIR, fc_task.name
|
38
|
+
assert FileCreationTask === fc_task
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_no_retriggers_on_filecreate_task
|
42
|
+
create_timed_files(OLDFILE, NEWFILE)
|
43
|
+
t1 = FileCreationTask.lookup(OLDFILE).enhance([NEWFILE])
|
44
|
+
t2 = FileCreationTask.lookup(NEWFILE)
|
45
|
+
assert ! t2.needed?, "Should not need to build new file"
|
46
|
+
assert ! t1.needed?, "Should not need to rebuild old file because of new"
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_no_retriggers_on_file_task
|
50
|
+
create_timed_files(OLDFILE, NEWFILE)
|
51
|
+
t1 = FileTask.lookup(OLDFILE).enhance([NEWFILE])
|
52
|
+
t2 = FileCreationTask.lookup(NEWFILE)
|
53
|
+
assert ! t2.needed?, "Should not need to build new file"
|
54
|
+
assert ! t1.needed?, "Should not need to rebuild old file because of new"
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'rake'
|
6
|
+
require 'test/filecreation'
|
7
|
+
|
8
|
+
######################################################################
|
9
|
+
class TestFileTask < Test::Unit::TestCase
|
10
|
+
include Rake
|
11
|
+
include FileCreation
|
12
|
+
|
13
|
+
def setup
|
14
|
+
Task.clear
|
15
|
+
@runs = Array.new
|
16
|
+
FileUtils.rm_f NEWFILE
|
17
|
+
FileUtils.rm_f OLDFILE
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_file_need
|
21
|
+
name = "testdata/dummy"
|
22
|
+
file name
|
23
|
+
ftask = Task[name]
|
24
|
+
assert_equal name.to_s, ftask.name
|
25
|
+
File.delete(ftask.name) rescue nil
|
26
|
+
assert ftask.needed?, "file should be needed"
|
27
|
+
open(ftask.name, "w") { |f| f.puts "HI" }
|
28
|
+
assert_equal nil, ftask.prerequisites.collect{|n| Task[n].timestamp}.max
|
29
|
+
assert ! ftask.needed?, "file should not be needed"
|
30
|
+
File.delete(ftask.name) rescue nil
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_file_times_new_depends_on_old
|
34
|
+
create_timed_files(OLDFILE, NEWFILE)
|
35
|
+
|
36
|
+
t1 = FileTask.lookup(NEWFILE).enhance([OLDFILE])
|
37
|
+
t2 = FileTask.lookup(OLDFILE)
|
38
|
+
assert ! t2.needed?, "Should not need to build old file"
|
39
|
+
assert ! t1.needed?, "Should not need to rebuild new file because of old"
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_file_times_old_depends_on_new
|
43
|
+
create_timed_files(OLDFILE, NEWFILE)
|
44
|
+
|
45
|
+
t1 = FileTask.lookup(OLDFILE).enhance([NEWFILE])
|
46
|
+
t2 = FileTask.lookup(NEWFILE)
|
47
|
+
assert ! t2.needed?, "Should not need to build new file"
|
48
|
+
preq_stamp = t1.prerequisites.collect{|t| Task[t].timestamp}.max
|
49
|
+
assert_equal t2.timestamp, preq_stamp
|
50
|
+
assert t1.timestamp < preq_stamp, "T1 should be older"
|
51
|
+
assert t1.needed?, "Should need to rebuild old file because of new"
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_file_depends_on_task_depend_on_file
|
55
|
+
create_timed_files(OLDFILE, NEWFILE)
|
56
|
+
|
57
|
+
file NEWFILE => [:obj] do |t| @runs << t.name end
|
58
|
+
task :obj => [OLDFILE] do |t| @runs << t.name end
|
59
|
+
file OLDFILE do |t| @runs << t.name end
|
60
|
+
|
61
|
+
Task[:obj].invoke
|
62
|
+
Task[NEWFILE].invoke
|
63
|
+
assert ! @runs.include?(NEWFILE)
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_existing_file_depends_on_non_existing_file
|
67
|
+
create_file(OLDFILE)
|
68
|
+
delete_file(NEWFILE)
|
69
|
+
file NEWFILE
|
70
|
+
file OLDFILE => NEWFILE
|
71
|
+
assert_nothing_raised do Task[OLDFILE].invoke end
|
72
|
+
end
|
73
|
+
|
74
|
+
# I have currently disabled this test. I'm not convinced that
|
75
|
+
# deleting the file target on failure is always the proper thing to
|
76
|
+
# do. I'm willing to hear input on this topic.
|
77
|
+
def ztest_file_deletes_on_failure
|
78
|
+
task :obj
|
79
|
+
file NEWFILE => [:obj] do |t|
|
80
|
+
FileUtils.touch NEWFILE
|
81
|
+
fail "Ooops"
|
82
|
+
end
|
83
|
+
assert Task[NEWFILE]
|
84
|
+
begin
|
85
|
+
Task[NEWFILE].invoke
|
86
|
+
rescue Exception
|
87
|
+
end
|
88
|
+
assert( ! File.exist?(NEWFILE), "NEWFILE should be deleted")
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
######################################################################
|
94
|
+
class TestDirectoryTask < Test::Unit::TestCase
|
95
|
+
include Rake
|
96
|
+
|
97
|
+
def setup
|
98
|
+
rm_rf "testdata", :verbose=>false
|
99
|
+
end
|
100
|
+
|
101
|
+
def teardown
|
102
|
+
rm_rf "testdata", :verbose=>false
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_directory
|
106
|
+
desc "DESC"
|
107
|
+
directory "testdata/a/b/c"
|
108
|
+
assert_equal FileCreationTask, Task["testdata"].class
|
109
|
+
assert_equal FileCreationTask, Task["testdata/a"].class
|
110
|
+
assert_equal FileCreationTask, Task["testdata/a/b/c"].class
|
111
|
+
assert_nil Task["testdata"].comment
|
112
|
+
assert_equal "DESC", Task["testdata/a/b/c"].comment
|
113
|
+
assert_nil Task["testdata/a/b"].comment
|
114
|
+
verbose(false) {
|
115
|
+
Task['testdata/a/b'].invoke
|
116
|
+
}
|
117
|
+
assert File.exist?("testdata/a/b")
|
118
|
+
assert ! File.exist?("testdata/a/b/c")
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_directory_win32
|
122
|
+
desc "WIN32 DESC"
|
123
|
+
FileUtils.mkdir_p("testdata")
|
124
|
+
Dir.chdir("testdata") do
|
125
|
+
directory 'c:/testdata/a/b/c'
|
126
|
+
assert_equal FileCreationTask, Task['c:/testdata'].class
|
127
|
+
assert_equal FileCreationTask, Task['c:/testdata/a'].class
|
128
|
+
assert_equal FileCreationTask, Task['c:/testdata/a/b/c'].class
|
129
|
+
assert_nil Task['c:/testdata'].comment
|
130
|
+
assert_equal "WIN32 DESC", Task['c:/testdata/a/b/c'].comment
|
131
|
+
assert_nil Task['c:/testdata/a/b'].comment
|
132
|
+
verbose(false) {
|
133
|
+
Task['c:/testdata/a/b'].invoke
|
134
|
+
}
|
135
|
+
assert File.exist?('c:/testdata/a/b')
|
136
|
+
assert ! File.exist?('c:/testdata/a/b/c')
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
@@ -12,6 +12,7 @@ class TestFileList < Test::Unit::TestCase
|
|
12
12
|
|
13
13
|
def teardown
|
14
14
|
FileList.select_default_ignore_patterns
|
15
|
+
FileUtils.rm_rf("testdata")
|
15
16
|
end
|
16
17
|
|
17
18
|
def test_create
|
@@ -78,7 +79,7 @@ class TestFileList < Test::Unit::TestCase
|
|
78
79
|
def test_match
|
79
80
|
fl = FileList.new
|
80
81
|
fl.include('test/test*.rb')
|
81
|
-
assert fl.include?("test/
|
82
|
+
assert fl.include?("test/test_filelist.rb")
|
82
83
|
assert fl.size > 3
|
83
84
|
fl.each { |fn| assert_match(/\.rb$/, fn) }
|
84
85
|
end
|
@@ -89,7 +90,7 @@ class TestFileList < Test::Unit::TestCase
|
|
89
90
|
fl.include("test/*.rb")
|
90
91
|
assert_equal "a.java", fl[0]
|
91
92
|
assert fl.size > 2
|
92
|
-
assert fl.include?("test/
|
93
|
+
assert fl.include?("test/test_filelist.rb")
|
93
94
|
end
|
94
95
|
|
95
96
|
def test_multiple_patterns
|
@@ -241,6 +242,20 @@ class TestFileList < Test::Unit::TestCase
|
|
241
242
|
f2.sort
|
242
243
|
end
|
243
244
|
|
245
|
+
def test_egrep
|
246
|
+
files = FileList['test/test*.rb']
|
247
|
+
found = false
|
248
|
+
the_line_number = __LINE__ + 1
|
249
|
+
files.egrep(/XYZZY/) do |fn, ln, line |
|
250
|
+
assert_equal 'test/test_filelist.rb', fn
|
251
|
+
assert_equal the_line_number, ln
|
252
|
+
assert_match(/files\.egrep/, line)
|
253
|
+
found = true
|
254
|
+
end
|
255
|
+
assert found, "should have foudn a matching line"
|
256
|
+
end
|
257
|
+
|
258
|
+
|
244
259
|
def test_ignore_special
|
245
260
|
f = FileList['testdata/*']
|
246
261
|
assert ! f.include?("testdata/CVS"), "Should not contain CVS"
|
@@ -8,16 +8,24 @@ require 'fileutils'
|
|
8
8
|
class TestFileUtils < Test::Unit::TestCase
|
9
9
|
include FileCreation
|
10
10
|
|
11
|
+
def setup
|
12
|
+
File.chmod(0750,"test/shellcommand.rb")
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown
|
16
|
+
FileUtils.rm_rf("testdata")
|
17
|
+
end
|
18
|
+
|
11
19
|
def test_rm_one_file
|
12
20
|
create_file("testdata/a")
|
13
|
-
FileUtils.
|
21
|
+
FileUtils.rm_rf "testdata/a"
|
14
22
|
assert ! File.exist?("testdata/a")
|
15
23
|
end
|
16
24
|
|
17
25
|
def test_rm_two_files
|
18
26
|
create_file("testdata/a")
|
19
27
|
create_file("testdata/b")
|
20
|
-
FileUtils.
|
28
|
+
FileUtils.rm_rf ["testdata/a", "testdata/b"]
|
21
29
|
assert ! File.exist?("testdata/a")
|
22
30
|
assert ! File.exist?("testdata/b")
|
23
31
|
end
|
File without changes
|
@@ -4,6 +4,8 @@ require 'test/unit'
|
|
4
4
|
require 'rake/packagetask'
|
5
5
|
|
6
6
|
class TestPackageTask < Test::Unit::TestCase
|
7
|
+
include Rake
|
8
|
+
|
7
9
|
def test_create
|
8
10
|
pkg = Rake::PackageTask.new("pkgr", "1.2.3") { |p|
|
9
11
|
p.package_files << "install.rb"
|
@@ -80,6 +82,49 @@ else
|
|
80
82
|
p.package_files << "y"
|
81
83
|
end
|
82
84
|
assert_equal ["x", "y"], pkg.package_files
|
85
|
+
assert_equal "pkgr-1.2.3.gem", pkg.gem_file
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_gem_package_with_specific_platform
|
89
|
+
gem = Gem::Specification.new do |g|
|
90
|
+
g.name = "pkgr"
|
91
|
+
g.version = "1.2.3"
|
92
|
+
g.files = FileList["x"].resolve
|
93
|
+
g.platform = Gem::Platform::WIN32
|
94
|
+
end
|
95
|
+
pkg = Rake::GemPackageTask.new(gem) do |p|
|
96
|
+
p.package_files << "y"
|
97
|
+
end
|
98
|
+
assert_equal ["x", "y"], pkg.package_files
|
99
|
+
assert_equal "pkgr-1.2.3-mswin32.gem", pkg.gem_file
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_gem_package_with_current_platform
|
103
|
+
gem = Gem::Specification.new do |g|
|
104
|
+
g.name = "pkgr"
|
105
|
+
g.version = "1.2.3"
|
106
|
+
g.files = FileList["x"].resolve
|
107
|
+
g.platform = Gem::Platform::CURRENT
|
108
|
+
end
|
109
|
+
pkg = Rake::GemPackageTask.new(gem) do |p|
|
110
|
+
p.package_files << "y"
|
111
|
+
end
|
112
|
+
assert_equal ["x", "y"], pkg.package_files
|
113
|
+
assert_match(/^pkgr-1\.2\.3-(\S+)\.gem$/, pkg.gem_file)
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_gem_package_with_ruby_platform
|
117
|
+
gem = Gem::Specification.new do |g|
|
118
|
+
g.name = "pkgr"
|
119
|
+
g.version = "1.2.3"
|
120
|
+
g.files = FileList["x"].resolve
|
121
|
+
g.platform = Gem::Platform::RUBY
|
122
|
+
end
|
123
|
+
pkg = Rake::GemPackageTask.new(gem) do |p|
|
124
|
+
p.package_files << "y"
|
125
|
+
end
|
126
|
+
assert_equal ["x", "y"], pkg.package_files
|
127
|
+
assert_equal "pkgr-1.2.3.gem", pkg.gem_file
|
83
128
|
end
|
84
129
|
end
|
85
130
|
end
|