craigmarksmith-rake 0.8.3.100
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +427 -0
- data/MIT-LICENSE +21 -0
- data/README +196 -0
- data/Rakefile +416 -0
- data/TODO +20 -0
- data/bin/rake +31 -0
- data/doc/command_line_usage.rdoc +102 -0
- data/doc/example/Rakefile1 +38 -0
- data/doc/example/Rakefile2 +35 -0
- data/doc/example/a.c +6 -0
- data/doc/example/b.c +6 -0
- data/doc/example/main.c +11 -0
- data/doc/glossary.rdoc +51 -0
- data/doc/jamis.rb +591 -0
- data/doc/proto_rake.rdoc +127 -0
- data/doc/rake.1.gz +0 -0
- data/doc/rakefile.rdoc +534 -0
- data/doc/rational.rdoc +151 -0
- data/doc/release_notes/rake-0.4.14.rdoc +23 -0
- data/doc/release_notes/rake-0.4.15.rdoc +35 -0
- data/doc/release_notes/rake-0.5.0.rdoc +53 -0
- data/doc/release_notes/rake-0.5.3.rdoc +78 -0
- data/doc/release_notes/rake-0.5.4.rdoc +46 -0
- data/doc/release_notes/rake-0.6.0.rdoc +141 -0
- data/doc/release_notes/rake-0.7.0.rdoc +119 -0
- data/doc/release_notes/rake-0.7.1.rdoc +59 -0
- data/doc/release_notes/rake-0.7.2.rdoc +121 -0
- data/doc/release_notes/rake-0.7.3.rdoc +47 -0
- data/doc/release_notes/rake-0.8.0.rdoc +114 -0
- data/doc/release_notes/rake-0.8.2.rdoc +165 -0
- data/doc/release_notes/rake-0.8.3.rdoc +112 -0
- data/doc/release_notes/rake-0.8.4.rdoc +147 -0
- data/install.rb +88 -0
- data/lib/rake/classic_namespace.rb +8 -0
- data/lib/rake/clean.rb +33 -0
- data/lib/rake/contrib/compositepublisher.rb +24 -0
- data/lib/rake/contrib/ftptools.rb +153 -0
- data/lib/rake/contrib/publisher.rb +75 -0
- data/lib/rake/contrib/rubyforgepublisher.rb +18 -0
- data/lib/rake/contrib/sshpublisher.rb +47 -0
- data/lib/rake/contrib/sys.rb +209 -0
- data/lib/rake/gempackagetask.rb +97 -0
- data/lib/rake/loaders/makefile.rb +42 -0
- data/lib/rake/packagetask.rb +184 -0
- data/lib/rake/rake_test_loader.rb +5 -0
- data/lib/rake/rdoctask.rb +209 -0
- data/lib/rake/ruby182_test_unit_fix.rb +23 -0
- data/lib/rake/runtest.rb +23 -0
- data/lib/rake/tasklib.rb +23 -0
- data/lib/rake/testtask.rb +161 -0
- data/lib/rake/win32.rb +55 -0
- data/lib/rake.rb +2519 -0
- data/test/capture_stdout.rb +26 -0
- data/test/check_expansion.rb +5 -0
- data/test/contrib/test_sys.rb +47 -0
- 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 +33 -0
- data/test/data/imports/Rakefile +19 -0
- data/test/data/imports/deps.mf +1 -0
- data/test/data/multidesc/Rakefile +17 -0
- data/test/data/namespace/Rakefile +57 -0
- data/test/data/rakelib/test1.rb +3 -0
- data/test/data/rbext/rakefile.rb +3 -0
- data/test/data/sample.mf +14 -0
- data/test/data/statusreturn/Rakefile +8 -0
- data/test/data/unittest/Rakefile +1 -0
- data/test/filecreation.rb +32 -0
- data/test/functional.rb +15 -0
- data/test/in_environment.rb +30 -0
- data/test/rake_test_setup.rb +24 -0
- data/test/reqfile.rb +3 -0
- data/test/reqfile2.rb +3 -0
- data/test/session_functional.rb +339 -0
- data/test/shellcommand.rb +3 -0
- data/test/test_application.rb +690 -0
- data/test/test_clean.rb +14 -0
- data/test/test_definitions.rb +85 -0
- data/test/test_earlytime.rb +35 -0
- data/test/test_extension.rb +63 -0
- data/test/test_file_creation_task.rb +62 -0
- data/test/test_file_task.rb +143 -0
- data/test/test_filelist.rb +623 -0
- data/test/test_fileutils.rb +251 -0
- data/test/test_ftp.rb +59 -0
- data/test/test_invocation_chain.rb +81 -0
- data/test/test_makefile_loader.rb +26 -0
- data/test/test_multitask.rb +45 -0
- data/test/test_namespace.rb +55 -0
- data/test/test_package_task.rb +118 -0
- data/test/test_pathmap.rb +210 -0
- data/test/test_rake.rb +41 -0
- data/test/test_rdoc_task.rb +88 -0
- data/test/test_require.rb +35 -0
- data/test/test_rules.rb +349 -0
- data/test/test_task_arguments.rb +89 -0
- data/test/test_task_manager.rb +173 -0
- data/test/test_tasklib.rb +12 -0
- data/test/test_tasks.rb +374 -0
- data/test/test_test_task.rb +77 -0
- data/test/test_top_level_functions.rb +86 -0
- data/test/test_win32.rb +72 -0
- metadata +186 -0
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'rubygems'
|
5
|
+
rescue LoadError
|
6
|
+
# got no gems
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'test/unit'
|
10
|
+
require 'flexmock/test_unit'
|
11
|
+
require 'rake'
|
12
|
+
require 'test/rake_test_setup'
|
13
|
+
|
14
|
+
class TestNameSpace < Test::Unit::TestCase
|
15
|
+
include TestMethods
|
16
|
+
|
17
|
+
class TM
|
18
|
+
include Rake::TaskManager
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_namespace_creation
|
22
|
+
mgr = TM.new
|
23
|
+
ns = Rake::NameSpace.new(mgr, [])
|
24
|
+
assert_not_nil ns
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_namespace_lookup
|
28
|
+
mgr = TM.new
|
29
|
+
ns = mgr.in_namespace("n") do
|
30
|
+
mgr.define_task(Rake::Task, "t")
|
31
|
+
end
|
32
|
+
|
33
|
+
assert_not_nil ns["t"]
|
34
|
+
assert_equal mgr["n:t"], ns["t"]
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_namespace_reports_tasks_it_owns
|
38
|
+
mgr = TM.new
|
39
|
+
nns = nil
|
40
|
+
ns = mgr.in_namespace("n") do
|
41
|
+
mgr.define_task(Rake::Task, :x)
|
42
|
+
mgr.define_task(Rake::Task, :y)
|
43
|
+
nns = mgr.in_namespace("nn") do
|
44
|
+
mgr.define_task(Rake::Task, :z)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
mgr.in_namespace("m") do
|
48
|
+
mgr.define_task(Rake::Task, :x)
|
49
|
+
end
|
50
|
+
|
51
|
+
assert_equal ["n:nn:z", "n:x", "n:y"],
|
52
|
+
ns.tasks.map { |tsk| tsk.name }
|
53
|
+
assert_equal ["n:nn:z"], nns.tasks.map {|t| t.name}
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rake/packagetask'
|
5
|
+
require 'test/rake_test_setup'
|
6
|
+
|
7
|
+
class TestPackageTask < Test::Unit::TestCase
|
8
|
+
include Rake
|
9
|
+
include TestMethods
|
10
|
+
|
11
|
+
def test_create
|
12
|
+
pkg = Rake::PackageTask.new("pkgr", "1.2.3") { |p|
|
13
|
+
p.package_files << "install.rb"
|
14
|
+
p.package_files.include(
|
15
|
+
'[A-Z]*',
|
16
|
+
'bin/**/*',
|
17
|
+
'lib/**/*.rb',
|
18
|
+
'test/**/*.rb',
|
19
|
+
'doc/**/*',
|
20
|
+
'build/rubyapp.rb',
|
21
|
+
'*.blurb')
|
22
|
+
p.package_files.exclude(/\bCVS\b/)
|
23
|
+
p.package_files.exclude(/~$/)
|
24
|
+
p.package_dir = 'pkg'
|
25
|
+
p.need_tar = true
|
26
|
+
p.need_tar_gz = true
|
27
|
+
p.need_tar_bz2 = true
|
28
|
+
p.need_zip = true
|
29
|
+
}
|
30
|
+
assert_equal "pkg", pkg.package_dir
|
31
|
+
assert pkg.package_files.include?("bin/rake")
|
32
|
+
assert "pkgr", pkg.name
|
33
|
+
assert "1.2.3", pkg.version
|
34
|
+
assert Task[:package]
|
35
|
+
assert Task['pkg/pkgr-1.2.3.tgz']
|
36
|
+
assert Task['pkg/pkgr-1.2.3.tar.gz']
|
37
|
+
assert Task['pkg/pkgr-1.2.3.tar.bz2']
|
38
|
+
assert Task['pkg/pkgr-1.2.3.zip']
|
39
|
+
assert Task["pkg/pkgr-1.2.3"]
|
40
|
+
assert Task[:clobber_package]
|
41
|
+
assert Task[:repackage]
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_missing_version
|
45
|
+
assert_exception(RuntimeError) {
|
46
|
+
pkg = Rake::PackageTask.new("pkgr") { |p| }
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_no_version
|
51
|
+
pkg = Rake::PackageTask.new("pkgr", :noversion) { |p| }
|
52
|
+
assert "pkgr", pkg.send(:package_name)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_clone
|
56
|
+
pkg = Rake::PackageTask.new("x", :noversion)
|
57
|
+
p2 = pkg.clone
|
58
|
+
pkg.package_files << "y"
|
59
|
+
p2.package_files << "x"
|
60
|
+
assert_equal ["y"], pkg.package_files
|
61
|
+
assert_equal ["x"], p2.package_files
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
begin
|
67
|
+
require 'rubygems'
|
68
|
+
require 'rake/gempackagetask'
|
69
|
+
rescue Exception
|
70
|
+
puts "WARNING: RubyGems not installed"
|
71
|
+
end
|
72
|
+
|
73
|
+
if ! defined?(Gem)
|
74
|
+
puts "WARNING: Unable to test GemPackaging ... requires RubyGems"
|
75
|
+
else
|
76
|
+
class TestGemPackageTask < Test::Unit::TestCase
|
77
|
+
def test_gem_package
|
78
|
+
gem = Gem::Specification.new do |g|
|
79
|
+
g.name = "pkgr"
|
80
|
+
g.version = "1.2.3"
|
81
|
+
g.files = FileList["x"].resolve
|
82
|
+
end
|
83
|
+
pkg = Rake::GemPackageTask.new(gem) do |p|
|
84
|
+
p.package_files << "y"
|
85
|
+
end
|
86
|
+
assert_equal ["x", "y"], pkg.package_files
|
87
|
+
assert_equal "pkgr-1.2.3.gem", pkg.gem_file
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_gem_package_with_current_platform
|
91
|
+
gem = Gem::Specification.new do |g|
|
92
|
+
g.name = "pkgr"
|
93
|
+
g.version = "1.2.3"
|
94
|
+
g.files = FileList["x"].resolve
|
95
|
+
g.platform = Gem::Platform::CURRENT
|
96
|
+
end
|
97
|
+
pkg = Rake::GemPackageTask.new(gem) do |p|
|
98
|
+
p.package_files << "y"
|
99
|
+
end
|
100
|
+
assert_equal ["x", "y"], pkg.package_files
|
101
|
+
assert_match(/^pkgr-1\.2\.3-(\S+)\.gem$/, pkg.gem_file)
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_gem_package_with_ruby_platform
|
105
|
+
gem = Gem::Specification.new do |g|
|
106
|
+
g.name = "pkgr"
|
107
|
+
g.version = "1.2.3"
|
108
|
+
g.files = FileList["x"].resolve
|
109
|
+
g.platform = Gem::Platform::RUBY
|
110
|
+
end
|
111
|
+
pkg = Rake::GemPackageTask.new(gem) do |p|
|
112
|
+
p.package_files << "y"
|
113
|
+
end
|
114
|
+
assert_equal ["x", "y"], pkg.package_files
|
115
|
+
assert_equal "pkgr-1.2.3.gem", pkg.gem_file
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,210 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rake'
|
5
|
+
|
6
|
+
# ====================================================================
|
7
|
+
class TestPathMap < Test::Unit::TestCase
|
8
|
+
include TestMethods
|
9
|
+
|
10
|
+
def test_returns_self_with_no_args
|
11
|
+
assert_equal "abc.rb", "abc.rb".pathmap
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_s_returns_file_separator
|
15
|
+
sep = File::ALT_SEPARATOR || File::SEPARATOR
|
16
|
+
assert_equal sep, "abc.rb".pathmap("%s")
|
17
|
+
assert_equal sep, "".pathmap("%s")
|
18
|
+
assert_equal "a#{sep}b", "a/b".pathmap("%d%s%f")
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_f_returns_basename
|
22
|
+
assert_equal "abc.rb", "abc.rb".pathmap("%f")
|
23
|
+
assert_equal "abc.rb", "this/is/a/dir/abc.rb".pathmap("%f")
|
24
|
+
assert_equal "abc.rb", "/this/is/a/dir/abc.rb".pathmap("%f")
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_n_returns_basename_without_extension
|
28
|
+
assert_equal "abc", "abc.rb".pathmap("%n")
|
29
|
+
assert_equal "abc", "abc".pathmap("%n")
|
30
|
+
assert_equal "abc", "this/is/a/dir/abc.rb".pathmap("%n")
|
31
|
+
assert_equal "abc", "/this/is/a/dir/abc.rb".pathmap("%n")
|
32
|
+
assert_equal "abc", "/this/is/a/dir/abc".pathmap("%n")
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_d_returns_dirname
|
36
|
+
assert_equal ".", "abc.rb".pathmap("%d")
|
37
|
+
assert_equal "/", "/abc".pathmap("%d")
|
38
|
+
assert_equal "this/is/a/dir", "this/is/a/dir/abc.rb".pathmap("%d")
|
39
|
+
assert_equal "/this/is/a/dir", "/this/is/a/dir/abc.rb".pathmap("%d")
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_9d_returns_partial_dirname
|
43
|
+
assert_equal "this/is", "this/is/a/dir/abc.rb".pathmap("%2d")
|
44
|
+
assert_equal "this", "this/is/a/dir/abc.rb".pathmap("%1d")
|
45
|
+
assert_equal ".", "this/is/a/dir/abc.rb".pathmap("%0d")
|
46
|
+
assert_equal "dir", "this/is/a/dir/abc.rb".pathmap("%-1d")
|
47
|
+
assert_equal "a/dir", "this/is/a/dir/abc.rb".pathmap("%-2d")
|
48
|
+
assert_equal "this/is/a/dir", "this/is/a/dir/abc.rb".pathmap("%100d")
|
49
|
+
assert_equal "this/is/a/dir", "this/is/a/dir/abc.rb".pathmap("%-100d")
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_x_returns_extension
|
53
|
+
assert_equal "", "abc".pathmap("%x")
|
54
|
+
assert_equal ".rb", "abc.rb".pathmap("%x")
|
55
|
+
assert_equal ".rb", "abc.xyz.rb".pathmap("%x")
|
56
|
+
assert_equal "", ".depends".pathmap("%x")
|
57
|
+
assert_equal "", "dir/.depends".pathmap("%x")
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_X_returns_everything_but_extension
|
61
|
+
assert_equal "abc", "abc".pathmap("%X")
|
62
|
+
assert_equal "abc", "abc.rb".pathmap("%X")
|
63
|
+
assert_equal "abc.xyz", "abc.xyz.rb".pathmap("%X")
|
64
|
+
assert_equal "ab.xyz", "ab.xyz.rb".pathmap("%X")
|
65
|
+
assert_equal "a.xyz", "a.xyz.rb".pathmap("%X")
|
66
|
+
assert_equal "abc", "abc.rb".pathmap("%X")
|
67
|
+
assert_equal "ab", "ab.rb".pathmap("%X")
|
68
|
+
assert_equal "a", "a.rb".pathmap("%X")
|
69
|
+
assert_equal ".depends", ".depends".pathmap("%X")
|
70
|
+
assert_equal "a/dir/.depends", "a/dir/.depends".pathmap("%X")
|
71
|
+
assert_equal "/.depends", "/.depends".pathmap("%X")
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_p_returns_entire_pathname
|
75
|
+
assert_equal "abc.rb", "abc.rb".pathmap("%p")
|
76
|
+
assert_equal "this/is/a/dir/abc.rb", "this/is/a/dir/abc.rb".pathmap("%p")
|
77
|
+
assert_equal "/this/is/a/dir/abc.rb", "/this/is/a/dir/abc.rb".pathmap("%p")
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_dash_returns_empty_string
|
81
|
+
assert_equal "", "abc.rb".pathmap("%-")
|
82
|
+
assert_equal "abc.rb", "abc.rb".pathmap("%X%-%x")
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_percent_percent_returns_percent
|
86
|
+
assert_equal "a%b", "".pathmap("a%%b")
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_undefined_percent_causes_error
|
90
|
+
ex = assert_exception(ArgumentError) {
|
91
|
+
"dir/abc.rb".pathmap("%z")
|
92
|
+
}
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_pattern_returns_substitutions
|
96
|
+
assert_equal "bin/org/osb",
|
97
|
+
"src/org/osb/Xyz.java".pathmap("%{src,bin}d")
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_pattern_can_use_backreferences
|
101
|
+
assert_equal "dir/hi/is", "dir/this/is".pathmap("%{t(hi)s,\\1}p")
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_pattern_with_star_replacement_string_uses_block
|
105
|
+
assert_equal "src/ORG/osb",
|
106
|
+
"src/org/osb/Xyz.java".pathmap("%{/org,*}d") { |d| d.upcase }
|
107
|
+
assert_equal "Xyz.java",
|
108
|
+
"src/org/osb/Xyz.java".pathmap("%{.*,*}f") { |f| f.capitalize }
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_pattern_with_no_replacement_nor_block_substitutes_empty_string
|
112
|
+
assert_equal "bc.rb", "abc.rb".pathmap("%{a}f")
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_pattern_works_with_certain_valid_operators
|
116
|
+
assert_equal "dir/xbc.rb", "dir/abc.rb".pathmap("%{a,x}p")
|
117
|
+
assert_equal "d1r", "dir/abc.rb".pathmap("%{i,1}d")
|
118
|
+
assert_equal "xbc.rb", "dir/abc.rb".pathmap("%{a,x}f")
|
119
|
+
assert_equal ".Rb", "dir/abc.rb".pathmap("%{r,R}x")
|
120
|
+
assert_equal "xbc", "dir/abc.rb".pathmap("%{a,x}n")
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_multiple_patterns
|
124
|
+
assert_equal "this/is/b/directory/abc.rb",
|
125
|
+
"this/is/a/dir/abc.rb".pathmap("%{a,b;dir,\\0ectory}p")
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_partial_directory_selection_works_with_patterns
|
129
|
+
assert_equal "this/is/a/long",
|
130
|
+
"this/is/a/really/long/path/ok.rb".pathmap("%{/really/,/}5d")
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_pattern_with_invalid_operator
|
134
|
+
ex = assert_exception(ArgumentError) do
|
135
|
+
"abc.xyz".pathmap("%{src,bin}z")
|
136
|
+
end
|
137
|
+
assert_match(/unknown.*pathmap.*spec.*z/i, ex.message)
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_works_with_windows_separators
|
141
|
+
if File::ALT_SEPARATOR
|
142
|
+
assert_equal "abc", 'dir\abc.rb'.pathmap("%n")
|
143
|
+
assert_equal 'this\is\a\dir',
|
144
|
+
'this\is\a\dir\abc.rb'.pathmap("%d")
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_complex_patterns
|
149
|
+
sep = "".pathmap("%s")
|
150
|
+
assert_equal "dir/abc.rb", "dir/abc.rb".pathmap("%d/%n%x")
|
151
|
+
assert_equal "./abc.rb", "abc.rb".pathmap("%d/%n%x")
|
152
|
+
assert_equal "Your file extension is '.rb'",
|
153
|
+
"dir/abc.rb".pathmap("Your file extension is '%x'")
|
154
|
+
assert_equal "bin/org/onstepback/proj/A.class",
|
155
|
+
"src/org/onstepback/proj/A.java".pathmap("%{src,bin}d/%n.class")
|
156
|
+
assert_equal "src_work/bin/org/onstepback/proj/A.class",
|
157
|
+
"src_work/src/org/onstepback/proj/A.java".pathmap('%{\bsrc\b,bin}X.class')
|
158
|
+
assert_equal ".depends.bak", ".depends".pathmap("%X.bak")
|
159
|
+
assert_equal "d#{sep}a/b/c#{sep}file.txt", "a/b/c/d/file.txt".pathmap("%-1d%s%3d%s%f")
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
class TestPathMapExplode < Test::Unit::TestCase
|
164
|
+
def setup
|
165
|
+
String.class_eval { public :pathmap_explode }
|
166
|
+
end
|
167
|
+
|
168
|
+
def teardown
|
169
|
+
String.class_eval { protected :pathmap_explode }
|
170
|
+
end
|
171
|
+
|
172
|
+
def test_explode
|
173
|
+
assert_equal ['a'], 'a'.pathmap_explode
|
174
|
+
assert_equal ['a', 'b'], 'a/b'.pathmap_explode
|
175
|
+
assert_equal ['a', 'b', 'c'], 'a/b/c'.pathmap_explode
|
176
|
+
assert_equal ['/', 'a'], '/a'.pathmap_explode
|
177
|
+
assert_equal ['/', 'a', 'b'], '/a/b'.pathmap_explode
|
178
|
+
assert_equal ['/', 'a', 'b', 'c'], '/a/b/c'.pathmap_explode
|
179
|
+
if File::ALT_SEPARATOR
|
180
|
+
assert_equal ['c:.', 'a'], 'c:a'.pathmap_explode
|
181
|
+
assert_equal ['c:.', 'a', 'b'], 'c:a/b'.pathmap_explode
|
182
|
+
assert_equal ['c:.', 'a', 'b', 'c'], 'c:a/b/c'.pathmap_explode
|
183
|
+
assert_equal ['c:/', 'a'], 'c:/a'.pathmap_explode
|
184
|
+
assert_equal ['c:/', 'a', 'b'], 'c:/a/b'.pathmap_explode
|
185
|
+
assert_equal ['c:/', 'a', 'b', 'c'], 'c:/a/b/c'.pathmap_explode
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
class TestPathMapPartial < Test::Unit::TestCase
|
191
|
+
def test_pathmap_partial
|
192
|
+
@path = "1/2/file"
|
193
|
+
def @path.call(n)
|
194
|
+
pathmap_partial(n)
|
195
|
+
end
|
196
|
+
assert_equal("1", @path.call(1))
|
197
|
+
assert_equal("1/2", @path.call(2))
|
198
|
+
assert_equal("1/2", @path.call(3))
|
199
|
+
assert_equal(".", @path.call(0))
|
200
|
+
assert_equal("2", @path.call(-1))
|
201
|
+
assert_equal("1/2", @path.call(-2))
|
202
|
+
assert_equal("1/2", @path.call(-3))
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
class TestFileListPathMap < Test::Unit::TestCase
|
207
|
+
def test_file_list_supports_pathmap
|
208
|
+
assert_equal ['a', 'b'], FileList['dir/a.rb', 'dir/b.rb'].pathmap("%n")
|
209
|
+
end
|
210
|
+
end
|
data/test/test_rake.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rake'
|
5
|
+
|
6
|
+
class TestRake < Test::Unit::TestCase
|
7
|
+
def test_each_dir_parent
|
8
|
+
assert_equal ['a'], alldirs('a')
|
9
|
+
assert_equal ['a/b', 'a'], alldirs('a/b')
|
10
|
+
assert_equal ['/a/b', '/a', '/'], alldirs('/a/b')
|
11
|
+
if File.dirname("c:/foo") == "c:"
|
12
|
+
# Under Unix
|
13
|
+
assert_equal ['c:/a/b', 'c:/a', 'c:'], alldirs('c:/a/b')
|
14
|
+
assert_equal ['c:a/b', 'c:a'], alldirs('c:a/b')
|
15
|
+
else
|
16
|
+
# Under Windows
|
17
|
+
assert_equal ['c:/a/b', 'c:/a', 'c:/'], alldirs('c:/a/b')
|
18
|
+
assert_equal ['c:a/b', 'c:a'], alldirs('c:a/b')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def alldirs(fn)
|
23
|
+
result = []
|
24
|
+
Rake.each_dir_parent(fn) { |d| result << d }
|
25
|
+
result
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_can_override_application
|
29
|
+
old_app = Rake.application
|
30
|
+
fake_app = Object.new
|
31
|
+
Rake.application = fake_app
|
32
|
+
assert_equal fake_app, Rake.application
|
33
|
+
ensure
|
34
|
+
Rake.application = old_app
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_original_dir_reports_current_dir
|
38
|
+
assert_equal Dir.pwd, Rake.original_dir
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rake/rdoctask'
|
5
|
+
require 'test/rake_test_setup'
|
6
|
+
|
7
|
+
class TestRDocTask < Test::Unit::TestCase
|
8
|
+
include Rake
|
9
|
+
include TestMethods
|
10
|
+
|
11
|
+
def setup
|
12
|
+
Task.clear
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_tasks_creation
|
16
|
+
Rake::RDocTask.new
|
17
|
+
assert Task[:rdoc]
|
18
|
+
assert Task[:clobber_rdoc]
|
19
|
+
assert Task[:rerdoc]
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_tasks_creation_with_custom_name_symbol
|
23
|
+
rd = Rake::RDocTask.new(:rdoc_dev)
|
24
|
+
assert Task[:rdoc_dev]
|
25
|
+
assert Task[:clobber_rdoc_dev]
|
26
|
+
assert Task[:rerdoc_dev]
|
27
|
+
assert_equal :rdoc_dev, rd.name
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_tasks_creation_with_custom_name_string
|
31
|
+
rd = Rake::RDocTask.new("rdoc_dev")
|
32
|
+
assert Task[:rdoc_dev]
|
33
|
+
assert Task[:clobber_rdoc_dev]
|
34
|
+
assert Task[:rerdoc_dev]
|
35
|
+
assert_equal "rdoc_dev", rd.name
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_tasks_creation_with_custom_name_hash
|
39
|
+
options = { :rdoc => "rdoc", :clobber_rdoc => "rdoc:clean", :rerdoc => "rdoc:force" }
|
40
|
+
rd = Rake::RDocTask.new(options)
|
41
|
+
assert Task[:"rdoc"]
|
42
|
+
assert Task[:"rdoc:clean"]
|
43
|
+
assert Task[:"rdoc:force"]
|
44
|
+
assert_raises(RuntimeError) { Task[:clobber_rdoc] }
|
45
|
+
assert_equal options, rd.name
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_tasks_creation_with_custom_name_hash_will_use_default_if_an_option_isnt_given
|
49
|
+
rd = Rake::RDocTask.new(:clobber_rdoc => "rdoc:clean")
|
50
|
+
assert Task[:rdoc]
|
51
|
+
assert Task[:"rdoc:clean"]
|
52
|
+
assert Task[:rerdoc]
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_tasks_creation_with_custom_name_hash_raises_exception_if_invalid_option_given
|
56
|
+
assert_raises(ArgumentError) do
|
57
|
+
Rake::RDocTask.new(:foo => "bar")
|
58
|
+
end
|
59
|
+
|
60
|
+
begin
|
61
|
+
Rake::RDocTask.new(:foo => "bar")
|
62
|
+
rescue ArgumentError => e
|
63
|
+
assert_match(/foo/, e.message)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_inline_source_is_enabled_by_default
|
68
|
+
rd = Rake::RDocTask.new
|
69
|
+
assert rd.option_list.include?('--inline-source')
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_inline_source_option_is_only_appended_if_option_not_already_given
|
73
|
+
rd = Rake::RDocTask.new
|
74
|
+
rd.options << '--inline-source'
|
75
|
+
assert_equal 1, rd.option_list.grep('--inline-source').size
|
76
|
+
|
77
|
+
rd = Rake::RDocTask.new
|
78
|
+
rd.options << '-S'
|
79
|
+
assert_equal 1, rd.option_list.grep('-S').size
|
80
|
+
assert_equal 0, rd.option_list.grep('--inline-source').size
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_inline_source_option_can_be_disabled
|
84
|
+
rd = Rake::RDocTask.new
|
85
|
+
rd.inline_source = false
|
86
|
+
assert !rd.option_list.include?('--inline-source')
|
87
|
+
end
|
88
|
+
end
|