rant 0.3.6 → 0.3.8
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/NEWS +13 -0
- data/README +7 -1
- data/Rantfile +10 -14
- data/TODO +3 -0
- data/devel-notes +5 -0
- data/doc/advanced.rdoc +46 -0
- data/doc/c.rdoc +64 -0
- data/doc/examples/c_dependencies/Rantfile +27 -0
- data/doc/examples/c_dependencies/include/hello.h +7 -0
- data/doc/examples/c_dependencies/include/util.h +7 -0
- data/doc/examples/c_dependencies/src/main.c +9 -0
- data/doc/examples/c_dependencies/src/util.c +9 -0
- data/doc/examples/directedrule/Rantfile +0 -1
- data/doc/rantfile.rdoc +12 -9
- data/doc/rubyproject.rdoc +26 -0
- data/lib/rant/c/include.rb +51 -0
- data/lib/rant/import/autoclean.rb +16 -9
- data/lib/rant/import/c/dependencies.rb +127 -0
- data/lib/rant/import/directedrule.rb +8 -4
- data/lib/rant/import/rubypackage.rb +2 -1
- data/lib/rant/import/subfile.rb +41 -0
- data/lib/rant/import/truth.rb +6 -1
- data/lib/rant/import/win32/rubycmdwrapper.rb +37 -0
- data/lib/rant/import.rb +26 -3
- data/lib/rant/rantenv.rb +0 -32
- data/lib/rant/rantfile.rb +207 -194
- data/lib/rant/rantlib.rb +83 -150
- data/lib/rant/rantsys.rb +7 -10
- data/lib/rant/rantvar.rb +4 -6
- data/lib/rant.rb +57 -0
- data/rantmethods.rb +1 -47
- data/setup.rb +2 -2
- data/test/Rantfile +6 -1
- data/test/c/source.c +23 -0
- data/test/c/test_parse_includes.rb +41 -0
- data/test/import/c/dependencies/Rantfile +34 -0
- data/test/import/c/dependencies/bar.h +2 -0
- data/test/import/c/dependencies/foo.h +5 -0
- data/test/import/c/dependencies/hello.c +7 -0
- data/test/import/c/dependencies/include/foo.h +0 -0
- data/test/import/c/dependencies/include/sub/sub.h +8 -0
- data/test/import/c/dependencies/include/with space.h +7 -0
- data/test/import/c/dependencies/src/abc +5 -0
- data/test/import/c/dependencies/src/abc.c +5 -0
- data/test/import/c/dependencies/src/bar.c +11 -0
- data/test/import/c/dependencies/test_c_dependencies.rb +92 -0
- data/test/import/c/dependencies/test_on_the_fly.rb +44 -0
- data/test/import/directedrule/Rantfile +7 -2
- data/test/import/directedrule/test_directedrule.rb +6 -0
- data/test/import/subfile/Rantfile +28 -0
- data/test/import/subfile/autoclean.rf +16 -0
- data/test/import/subfile/test_subfile.rb +91 -0
- data/test/import/truth/Rantfile +7 -0
- data/test/import/truth/test_truth.rb +3 -0
- data/test/project2/buildfile +2 -0
- data/test/project2/test_project.rb +5 -3
- data/test/rant-import/Rantfile +4 -0
- data/test/rant-import/test_rant-import.rb +104 -1
- data/test/rule.rf +6 -0
- data/test/test_autosubfiletask.rb +59 -0
- data/test/test_clean.rb +48 -5
- data/test/test_dirtask.rb +45 -1
- data/test/test_examples.rb +25 -3
- data/test/test_filelist.rb +14 -2
- data/test/test_lighttask.rb +4 -6
- data/test/test_rant_interface.rb +8 -8
- data/test/test_rantfile_api.rb +37 -1
- data/test/test_rule.rb +6 -3
- data/test/test_source.rb +28 -1
- data/test/test_sourcenode.rb +163 -0
- data/test/test_task.rb +2 -2
- data/test/test_var.rb +3 -3
- data/test/tutil.rb +23 -2
- metadata +45 -3
- data/test/test_metatask.rb +0 -29
@@ -12,6 +12,7 @@ class TestRantImport < Test::Unit::TestCase
|
|
12
12
|
Dir.chdir($testRantImportDir) unless Dir.pwd == $testRantImportDir
|
13
13
|
end
|
14
14
|
def teardown
|
15
|
+
Dir.chdir($testRantImportDir)
|
15
16
|
FileUtils.rm_f Dir["ant*"]
|
16
17
|
FileUtils.rm_f Dir["make*"]
|
17
18
|
FileUtils.rm_rf Dir["*.t"]
|
@@ -47,7 +48,7 @@ class TestRantImport < Test::Unit::TestCase
|
|
47
48
|
EOF
|
48
49
|
}
|
49
50
|
out, err = capture_std do
|
50
|
-
assert_equal(0, Rant::RantApp.new("-fmygen.rf.t")
|
51
|
+
assert_equal(0, Rant::RantApp.new.run("-fmygen.rf.t"))
|
51
52
|
end
|
52
53
|
assert_match(/Greetings.*mygen/, out)
|
53
54
|
assert(test(?f, "mygen"))
|
@@ -62,4 +63,106 @@ class TestRantImport < Test::Unit::TestCase
|
|
62
63
|
ensure
|
63
64
|
FileUtils.rm_f "mygen"
|
64
65
|
end
|
66
|
+
def test_import_subdir
|
67
|
+
old_pwd = Dir.pwd
|
68
|
+
FileUtils.mkdir "sub.t"
|
69
|
+
Dir.chdir "sub.t"
|
70
|
+
FileUtils.mkpath "lib.t/rant/import/sub"
|
71
|
+
open("lib.t/rant/import/sub/t.rb", "w") { |f|
|
72
|
+
f << <<-EOF
|
73
|
+
module Rant::Generators
|
74
|
+
module Sub
|
75
|
+
class T
|
76
|
+
def self.rant_generate(rac, ch, args, &blk)
|
77
|
+
raise "no ch" unless Hash === ch
|
78
|
+
rac.cx.task args.first do |t|
|
79
|
+
puts args
|
80
|
+
puts "block_given" if block_given?
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
EOF
|
87
|
+
}
|
88
|
+
open("Rantfile.rb", "w") { |f|
|
89
|
+
f << <<-EOF
|
90
|
+
$:.unshift "lib.t"
|
91
|
+
import "sub/t"
|
92
|
+
gen Sub::T, "hello", "test" do end
|
93
|
+
EOF
|
94
|
+
}
|
95
|
+
out, err = assert_rant
|
96
|
+
assert_match(/.*hello.*\n.*test.*\n.*block_given/, out)
|
97
|
+
run_import("--quiet", "--auto", "ant")
|
98
|
+
assert(test(?f, "ant"))
|
99
|
+
FileUtils.rm_r "lib.t"
|
100
|
+
out = run_ruby("ant")
|
101
|
+
assert_match(/.*hello.*\n.*test.*\n.*block_given/, out)
|
102
|
+
ensure
|
103
|
+
Dir.chdir old_pwd
|
104
|
+
FileUtils.rm_rf "sub.t"
|
105
|
+
end
|
106
|
+
def test_import_marked_require
|
107
|
+
old_pwd = Dir.pwd
|
108
|
+
FileUtils.mkdir "sub2.t"
|
109
|
+
Dir.chdir "sub2.t"
|
110
|
+
FileUtils.mkpath "lib.t/rant/import/sub2"
|
111
|
+
FileUtils.mkdir "lib.t/misc"
|
112
|
+
open("lib.t/misc/printer.rb", "w") { |f|
|
113
|
+
f << <<-EOF
|
114
|
+
def misc_print(*args)
|
115
|
+
puts args.flatten.join('')
|
116
|
+
end
|
117
|
+
EOF
|
118
|
+
}
|
119
|
+
open("lib.t/rant/import/sub2/t.rb", "w") { |f|
|
120
|
+
f << <<-EOF
|
121
|
+
require 'misc/printer' # rant-import
|
122
|
+
module Rant::Generators
|
123
|
+
module Sub2
|
124
|
+
class T
|
125
|
+
def self.rant_generate(rac, ch, args, &blk)
|
126
|
+
rac.cx.task args.first do |t|
|
127
|
+
misc_print(args)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
EOF
|
134
|
+
}
|
135
|
+
open("rantfile.rb", "w") { |f|
|
136
|
+
f << <<-EOF
|
137
|
+
$:.unshift "lib.t"
|
138
|
+
import "sub2/t"
|
139
|
+
gen Sub2::T, "hello", "test" do end
|
140
|
+
EOF
|
141
|
+
}
|
142
|
+
out, err = assert_rant
|
143
|
+
assert_match(/hellotest/, out)
|
144
|
+
run_import("--quiet", "--auto", "ant.rb")
|
145
|
+
assert(test(?f, "ant.rb"))
|
146
|
+
FileUtils.rm_r "lib.t"
|
147
|
+
out = run_ruby("ant.rb")
|
148
|
+
assert_match(/hellotest/, out)
|
149
|
+
ensure
|
150
|
+
Dir.chdir old_pwd
|
151
|
+
FileUtils.rm_rf "sub2.t"
|
152
|
+
end
|
153
|
+
def test_sys_shun
|
154
|
+
FileUtils.mkdir "a.t"
|
155
|
+
FileUtils.mkdir "b.t"
|
156
|
+
FileUtils.touch %w(a.t/1.s.t a.t/2.s.t a.t/xy.s.t b.t/b.s.t)
|
157
|
+
out = run_rant("-q", "sys_shun_demo")
|
158
|
+
files = out.strip.split "\n"
|
159
|
+
assert_equal(1, files.size)
|
160
|
+
assert(files.include?("b.t/b.s.t"))
|
161
|
+
run_import("-q", "--auto", "ant")
|
162
|
+
assert(test(?f, "ant"))
|
163
|
+
out = run_ruby("ant", "-q", "sys_shun_demo")
|
164
|
+
files = out.strip.split "\n"
|
165
|
+
assert_equal(1, files.size)
|
166
|
+
assert(files.include?("b.t/b.s.t"))
|
167
|
+
end
|
65
168
|
end
|
data/test/rule.rf
CHANGED
@@ -0,0 +1,59 @@
|
|
1
|
+
|
2
|
+
require 'test/unit'
|
3
|
+
require 'tutil'
|
4
|
+
|
5
|
+
$testDir ||= File.expand_path(File.dirname(__FILE__))
|
6
|
+
|
7
|
+
class TestAutoSubFileTask < Test::Unit::TestCase
|
8
|
+
RG = Rant::Generators
|
9
|
+
def setup
|
10
|
+
# Ensure we run in test directory.
|
11
|
+
Dir.chdir($testDir) unless Dir.pwd == $testDir
|
12
|
+
@rac = Rant::RantApp.new
|
13
|
+
end
|
14
|
+
def teardown
|
15
|
+
FileUtils.rm_rf Dir["*.t"]
|
16
|
+
end
|
17
|
+
def test_create_dir
|
18
|
+
@rac.gen RG::Directory, "dir.t"
|
19
|
+
blk = lambda { |t| FileUtils.touch t.name }
|
20
|
+
@rac.prepare_task("dir.t/file", blk) { |name,pre,blk|
|
21
|
+
Rant::AutoSubFileTask.new(@rac, name, pre, &blk)
|
22
|
+
}
|
23
|
+
tl = @rac.resolve("dir.t/file")
|
24
|
+
assert_equal(1, tl.size)
|
25
|
+
ft = tl.first
|
26
|
+
assert(ft.prerequisites.empty?)
|
27
|
+
@rac.args.replace %w(dir.t/file)
|
28
|
+
capture_std do
|
29
|
+
assert_equal(0, @rac.run)
|
30
|
+
end
|
31
|
+
assert(test(?d, "dir.t"))
|
32
|
+
assert(test(?f, "dir.t/file"))
|
33
|
+
end
|
34
|
+
def test_fail_no_dir
|
35
|
+
blk = lambda { |t| FileUtils.touch t.name }
|
36
|
+
@rac.prepare_task("dir.t/file", blk) { |name,pre,blk|
|
37
|
+
Rant::AutoSubFileTask.new(@rac, name, pre, &blk)
|
38
|
+
}
|
39
|
+
@rac.args.replace %w(dir.t/file)
|
40
|
+
capture_std do
|
41
|
+
assert_equal(1, @rac.run)
|
42
|
+
end
|
43
|
+
assert(!test(?e, "dir.t"))
|
44
|
+
assert(!test(?e, "dir.t/file"))
|
45
|
+
end
|
46
|
+
def test_dir_exists
|
47
|
+
FileUtils.mkdir "dir.t"
|
48
|
+
blk = lambda { |t| FileUtils.touch t.name }
|
49
|
+
@rac.prepare_task("dir.t/file", blk) { |name,pre,blk|
|
50
|
+
Rant::AutoSubFileTask.new(@rac, name, pre, &blk)
|
51
|
+
}
|
52
|
+
@rac.args.replace %w(dir.t/file)
|
53
|
+
capture_std do
|
54
|
+
assert_equal(0, @rac.run)
|
55
|
+
end
|
56
|
+
assert(test(?d, "dir.t"))
|
57
|
+
assert(test(?f, "dir.t/file"))
|
58
|
+
end
|
59
|
+
end
|
data/test/test_clean.rb
CHANGED
@@ -65,7 +65,7 @@ class TestClean < Test::Unit::TestCase
|
|
65
65
|
files.each { |f| assert(test(?f, f)) }
|
66
66
|
dirs.each { |f| assert(test(?d, f)) }
|
67
67
|
capture_std do
|
68
|
-
assert_equal(0, Rant::RantApp.new("clean")
|
68
|
+
assert_equal(0, Rant::RantApp.new.run("clean"))
|
69
69
|
end
|
70
70
|
%w(sa.t a1.t a2.t sub1.t/b1.t sub1.t/b2.t).each { |f|
|
71
71
|
assert(!test(?e, f))
|
@@ -81,7 +81,7 @@ class TestClean < Test::Unit::TestCase
|
|
81
81
|
%w(a1.t a2.t b1.t b2.t).each { |f| assert(test(?f, f)) }
|
82
82
|
%w(sa.t sb.t).each { |f| assert(test(?d, f)) }
|
83
83
|
capture_std do
|
84
|
-
assert_equal(0, Rant::RantApp.new("clean")
|
84
|
+
assert_equal(0, Rant::RantApp.new.run("clean"))
|
85
85
|
end
|
86
86
|
%w(b1.t b2.t sb.t).each { |f| assert(!test(?e, f)) }
|
87
87
|
%w(a1.t a2.t sa.t).each { |f| assert(test(?e, f)) }
|
@@ -92,6 +92,8 @@ class TestClean < Test::Unit::TestCase
|
|
92
92
|
end
|
93
93
|
def layout_project2
|
94
94
|
FileUtils.mkdir "p2.t"
|
95
|
+
FileUtils.mkdir "p2.t/c.t"
|
96
|
+
FileUtils.touch "p2.t/c.t/data"
|
95
97
|
Dir.chdir "p2.t"
|
96
98
|
open("Rantfile", "w") { |f|
|
97
99
|
f << <<-EOF
|
@@ -104,6 +106,10 @@ class TestClean < Test::Unit::TestCase
|
|
104
106
|
sys.touch t.name
|
105
107
|
end
|
106
108
|
gen Directory, "b.t/c.t"
|
109
|
+
gen Directory, "c.t", "a"
|
110
|
+
file "c.t/a/b" => "c.t/a" do
|
111
|
+
sys.touch t.name
|
112
|
+
end
|
107
113
|
file "b.t/c.t/d.t" => "b.t/c.t" do |t|
|
108
114
|
sys.touch t.name
|
109
115
|
end
|
@@ -122,13 +128,50 @@ class TestClean < Test::Unit::TestCase
|
|
122
128
|
end
|
123
129
|
%w(a.t b.t/c.t/d.t mk_junk.t).each { |f| assert(test(?e, f)) }
|
124
130
|
capture_std do
|
125
|
-
assert_equal(0, Rant::RantApp.new("autoclean")
|
131
|
+
assert_equal(0, Rant::RantApp.new.run("autoclean"))
|
126
132
|
end
|
127
|
-
%w(a.t b.t/c.t/d.t mk_junk.t).each { |f| assert(!test(?e, f)) }
|
133
|
+
%w(a.t b.t/c.t/d.t c.t/a mk_junk.t).each { |f| assert(!test(?e, f)) }
|
134
|
+
assert(test(?d, "c.t"))
|
135
|
+
assert(test(?f, "c.t/data"))
|
128
136
|
capture_std do
|
129
|
-
assert_equal(1, Rant::RantApp.new("clean")
|
137
|
+
assert_equal(1, Rant::RantApp.new.run("clean"))
|
130
138
|
end
|
131
139
|
ensure
|
132
140
|
cleanup_project2
|
133
141
|
end
|
142
|
+
def test_clean_rule_target_rx
|
143
|
+
FileUtils.mkdir "t"
|
144
|
+
Dir.chdir "t"
|
145
|
+
FileUtils.mkdir "sub"
|
146
|
+
FileUtils.mkdir "sub/sub"
|
147
|
+
FileUtils.touch "sub/sub/a.t"
|
148
|
+
FileUtils.touch "sub/a.t"
|
149
|
+
FileUtils.touch "a.t"
|
150
|
+
open "Rantfile", "w" do |f|
|
151
|
+
f << <<-EOF
|
152
|
+
gen Rule, :tt => :t do |t|
|
153
|
+
sys.touch t.name
|
154
|
+
end
|
155
|
+
import "autoclean"
|
156
|
+
gen AutoClean
|
157
|
+
EOF
|
158
|
+
end
|
159
|
+
assert_rant("sub/sub/a.tt")
|
160
|
+
assert(test(?f, "sub/sub/a.tt"))
|
161
|
+
assert_rant("sub/a.tt")
|
162
|
+
assert(test(?f, "sub/a.tt"))
|
163
|
+
assert_rant("a.tt")
|
164
|
+
assert(test(?f, "a.tt"))
|
165
|
+
assert_rant("autoclean")
|
166
|
+
%w(a.tt sub/a.tt sub/sub/a.tt).each { |f|
|
167
|
+
assert(!test(?e, f),
|
168
|
+
"#{f} should get unlinked by AutoClean")
|
169
|
+
}
|
170
|
+
%w(a.t sub/a.t sub/sub/a.t).each { |f|
|
171
|
+
assert(test(?e, f))
|
172
|
+
}
|
173
|
+
ensure
|
174
|
+
Dir.chdir $testDir
|
175
|
+
FileUtils.rm_rf "t"
|
176
|
+
end
|
134
177
|
end
|
data/test/test_dirtask.rb
CHANGED
@@ -22,7 +22,7 @@ class TestDirTask < Test::Unit::TestCase
|
|
22
22
|
end
|
23
23
|
def test_return
|
24
24
|
dt = @cx.gen Directory, "a.t/b.t"
|
25
|
-
assert(Rant::
|
25
|
+
assert(Rant::Node === dt)
|
26
26
|
assert_equal("a.t/b.t", dt.name,
|
27
27
|
"`gen Directory' should return task for last directory")
|
28
28
|
args "--quiet", "a.t/b.t"
|
@@ -30,4 +30,48 @@ class TestDirTask < Test::Unit::TestCase
|
|
30
30
|
assert(test(?d, "a.t"))
|
31
31
|
assert(test(?d, "a.t/b.t"))
|
32
32
|
end
|
33
|
+
def test_4_levels
|
34
|
+
@cx.gen Directory, "1.t/2/3/4"
|
35
|
+
args "-q", "1.t/2/3/4"
|
36
|
+
assert_equal(0, @rac.run)
|
37
|
+
assert(test(?d, "1.t/2/3/4"))
|
38
|
+
end
|
39
|
+
def test_basedir_no_create
|
40
|
+
out, err = capture_std do
|
41
|
+
assert_equal(1, Rant::RantApp.new.run("basedir.t"))
|
42
|
+
end
|
43
|
+
assert_match(/\[ERROR\].*basedir\.t/, err)
|
44
|
+
assert(!test(?e, "basedir.t"))
|
45
|
+
end
|
46
|
+
def test_basedir_fail_no_basedir
|
47
|
+
out, err = capture_std do
|
48
|
+
assert_equal(1, Rant::RantApp.new.run("basedir.t/a"))
|
49
|
+
end
|
50
|
+
assert(!test(?e, "basedir.t"))
|
51
|
+
assert(!test(?e, "a"))
|
52
|
+
end
|
53
|
+
def test_basedir_a
|
54
|
+
FileUtils.mkdir "basedir.t"
|
55
|
+
assert_rant("basedir.t/a")
|
56
|
+
assert(test(?d, "basedir.t/a"))
|
57
|
+
assert_rant("clean")
|
58
|
+
assert(!test(?e, "basedir.t"))
|
59
|
+
end
|
60
|
+
def test_basedir_a_b
|
61
|
+
FileUtils.mkdir "basedir.t"
|
62
|
+
assert_rant("basedir.t/a/b")
|
63
|
+
assert(test(?d, "basedir.t/a/b"))
|
64
|
+
assert_rant("clean")
|
65
|
+
end
|
66
|
+
def test_basdir_no_b
|
67
|
+
FileUtils.mkdir "basedir.t"
|
68
|
+
assert_rant(:fail, "basedir.t/b")
|
69
|
+
assert_rant("clean")
|
70
|
+
end
|
71
|
+
def test_description
|
72
|
+
FileUtils.mkdir "basedir.t"
|
73
|
+
out, err = assert_rant("--tasks")
|
74
|
+
assert_match(%r{basedir.t/a/b\s*#.*Make some path}, out)
|
75
|
+
assert_rant("clean")
|
76
|
+
end
|
33
77
|
end
|
data/test/test_examples.rb
CHANGED
@@ -10,9 +10,7 @@ $cc_is_gcc ||= Rant::Env.find_bin("cc") && Rant::Env.find_bin("gcc")
|
|
10
10
|
class TestExamples < Test::Unit::TestCase
|
11
11
|
def setup
|
12
12
|
# Ensure we run in test directory.
|
13
|
-
Dir.chdir
|
14
|
-
end
|
15
|
-
def teardown
|
13
|
+
Dir.chdir $examplesDir
|
16
14
|
end
|
17
15
|
def test_myprog
|
18
16
|
Dir.chdir "myprog"
|
@@ -44,4 +42,28 @@ class TestExamples < Test::Unit::TestCase
|
|
44
42
|
run_rant("clean")
|
45
43
|
Dir["**/*.o"].each { |f| assert(!test(?e, f)) }
|
46
44
|
end
|
45
|
+
def test_c_dependencies
|
46
|
+
Dir.chdir "c_dependencies"
|
47
|
+
assert_match( /\bhello\b.*\n.*\bclean\b.*\n.*\bdistclean\b/,
|
48
|
+
run_rant("-T"))
|
49
|
+
assert(!test(?f, "hello"))
|
50
|
+
if $cc_is_gcc
|
51
|
+
run_rant
|
52
|
+
assert(test(?f, "hello"))
|
53
|
+
else
|
54
|
+
run_rant("c_dependencies")
|
55
|
+
end
|
56
|
+
run_rant("clean")
|
57
|
+
assert(Dir["**/*.o"].empty?)
|
58
|
+
assert(!test(?f, "hello"))
|
59
|
+
assert(test(?f, "c_dependencies"))
|
60
|
+
if $cc_is_gcc
|
61
|
+
run_rant
|
62
|
+
assert(test(?f, "hello"))
|
63
|
+
end
|
64
|
+
run_rant("distclean")
|
65
|
+
assert(Dir["**/*.o"].empty?)
|
66
|
+
assert(!test(?f, "c_dependencies"))
|
67
|
+
assert(!test(?f, "hello"))
|
68
|
+
end
|
47
69
|
end
|
data/test/test_filelist.rb
CHANGED
@@ -255,12 +255,12 @@ class TestFileList < Test::Unit::TestCase
|
|
255
255
|
EOF
|
256
256
|
}
|
257
257
|
capture_std do
|
258
|
-
Rant::RantApp.new("-fsys_cd.rf.t", "sub.t/a.t")
|
258
|
+
Rant::RantApp.new.run("-fsys_cd.rf.t", "sub.t/a.t")
|
259
259
|
end
|
260
260
|
assert(test(?f, "sub.t/a.t"))
|
261
261
|
assert(test(?f, "sub.t/b.t"))
|
262
262
|
capture_std do
|
263
|
-
Rant::RantApp.new("-fsys_cd.rf.t", "clean")
|
263
|
+
Rant::RantApp.new.run("-fsys_cd.rf.t", "clean")
|
264
264
|
end
|
265
265
|
assert(!test(?e, "sub.t/a.t"))
|
266
266
|
assert(!test(?e, "sub.t/b.t"))
|
@@ -279,4 +279,16 @@ class TestFileList < Test::Unit::TestCase
|
|
279
279
|
assert(l1.include("b.t"))
|
280
280
|
end
|
281
281
|
end
|
282
|
+
def test_sys_glob_flags
|
283
|
+
cx = Rant::RantApp.new.cx
|
284
|
+
touch_temp %w(a.t .a.t b.t .b.t) do
|
285
|
+
l1 = cx.sys["*.t"]
|
286
|
+
l1.glob_flags |= File::FNM_DOTMATCH
|
287
|
+
l2 = cx.sys["*.t"]
|
288
|
+
assert_equal(4, l1.size)
|
289
|
+
assert_equal(2, l2.size)
|
290
|
+
%w(a.t .a.t b.t .b.t).each { |f| l1.include? f }
|
291
|
+
%w(a.t b.t ).each { |f| l2.include? f }
|
292
|
+
end
|
293
|
+
end
|
282
294
|
end
|
data/test/test_lighttask.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
|
2
2
|
require 'test/unit'
|
3
|
-
require '
|
4
|
-
|
3
|
+
require 'tutil'
|
5
4
|
|
6
5
|
class TestLightTask < Test::Unit::TestCase
|
7
6
|
def setup
|
8
|
-
@app = Rant::RantApp.new
|
7
|
+
@app = Rant::RantApp.new
|
9
8
|
end
|
10
9
|
def teardown
|
11
10
|
end
|
@@ -14,13 +13,12 @@ class TestLightTask < Test::Unit::TestCase
|
|
14
13
|
Rant::LightTask.new(*[@app, args].flatten, &block)
|
15
14
|
end
|
16
15
|
def test_init
|
17
|
-
t = lt
|
16
|
+
t = lt "tinit"
|
18
17
|
assert(t.needed?,
|
19
18
|
"needed? should be true after creation without " +
|
20
19
|
"`needed' block")
|
21
20
|
assert(!t.done?)
|
22
|
-
assert_equal(t.name, "tinit"
|
23
|
-
"task name should always be a string, despite creation with symbol")
|
21
|
+
assert_equal(t.name, "tinit")
|
24
22
|
end
|
25
23
|
def test_with_blocks
|
26
24
|
run = false
|
data/test/test_rant_interface.rb
CHANGED
@@ -13,9 +13,9 @@ class TestRantInterface < Test::Unit::TestCase
|
|
13
13
|
def teardown
|
14
14
|
end
|
15
15
|
def test_cmd_targets
|
16
|
-
@app = Rant::RantApp.new
|
16
|
+
@app = Rant::RantApp.new
|
17
17
|
op = capture_stderr {
|
18
|
-
assert_equal(@app.run, 1,
|
18
|
+
assert_equal(@app.run("-f non_existent", "target", "-aforced_target"), 1,
|
19
19
|
"Rant should fail because there is no such Rantfile.")
|
20
20
|
}
|
21
21
|
assert(op =~ /\[ERROR\]/,
|
@@ -28,25 +28,25 @@ class TestRantInterface < Test::Unit::TestCase
|
|
28
28
|
"forced_target should run first")
|
29
29
|
end
|
30
30
|
def test_envvar_on_cmdline
|
31
|
-
@app = Rant::RantApp.new
|
31
|
+
@app = Rant::RantApp.new
|
32
32
|
@app.context.var.env "VAR"
|
33
|
-
assert_equal(@app.run, 0)
|
33
|
+
assert_equal(@app.run("VAR=VAL"), 0)
|
34
34
|
assert_equal(ENV["VAR"], "VAL",
|
35
35
|
"rant should set arguments of form VAR=VAL in var")
|
36
36
|
end
|
37
37
|
def test_envvar_on_cmdline_lc
|
38
|
-
@app = Rant::RantApp.new
|
39
|
-
assert_equal(@app.run, 0)
|
38
|
+
@app = Rant::RantApp.new
|
39
|
+
assert_equal(@app.run("var2=val2"), 0)
|
40
40
|
assert_equal(@app.context.var["var2"], "val2",
|
41
41
|
"rant should set arguments of form var2=val2 in var")
|
42
42
|
end
|
43
43
|
def test_opt_targets
|
44
|
-
@app = Rant::RantApp.new
|
44
|
+
@app = Rant::RantApp.new
|
45
45
|
@app.desc 'This is a "public" target.'
|
46
46
|
@app.task :public_task
|
47
47
|
@app.task :private_task
|
48
48
|
op = capture_stdout {
|
49
|
-
assert_equal(@app.run, 0)
|
49
|
+
assert_equal(@app.run("--tasks"), 0)
|
50
50
|
}
|
51
51
|
assert(op =~ /\bpublic_task\b/,
|
52
52
|
"rant -T output should contain name of described task")
|
data/test/test_rantfile_api.rb
CHANGED
@@ -9,10 +9,11 @@ $testDir ||= File.expand_path(File.dirname(__FILE__))
|
|
9
9
|
class TestRantfileAPI < Test::Unit::TestCase
|
10
10
|
def setup
|
11
11
|
# Ensure we run in test directory.
|
12
|
-
Dir.chdir
|
12
|
+
Dir.chdir $testDir
|
13
13
|
@app = Rant::RantApp.new
|
14
14
|
end
|
15
15
|
def teardown
|
16
|
+
Dir.chdir $testDir
|
16
17
|
FileUtils.rm_rf Dir["*.t"]
|
17
18
|
end
|
18
19
|
def test_action
|
@@ -44,4 +45,39 @@ class TestRantfileAPI < Test::Unit::TestCase
|
|
44
45
|
def test_rac_build_cd
|
45
46
|
assert_rant("tmp.t/Rantfile", "subdir_tmp", "build_test_t")
|
46
47
|
end
|
48
|
+
def test_string_sub_ext
|
49
|
+
assert_equal("hello.txt", "hello.sxw".sub_ext(".sxw", ".txt"))
|
50
|
+
end
|
51
|
+
def test_string_sub_ext_2
|
52
|
+
assert_equal("hello.txt", "hello.sxw".sub_ext("sxw", "txt"))
|
53
|
+
end
|
54
|
+
def test_string_sub_ext_one_arg
|
55
|
+
assert_equal("hello.txt", "hello.sxw".sub_ext("txt"))
|
56
|
+
end
|
57
|
+
def test_string_sub_ext_new_ext
|
58
|
+
assert_equal("hello.txt", "hello".sub_ext("txt"))
|
59
|
+
end
|
60
|
+
def test_string_sub_ext_dot
|
61
|
+
assert_equal("hello.txt", "hello.".sub_ext("txt"))
|
62
|
+
end
|
63
|
+
def test_string_sub_ext_empty_str
|
64
|
+
assert_equal("hello.", "hello.txt".sub_ext(""))
|
65
|
+
end
|
66
|
+
def test_string_sub_ext_nil
|
67
|
+
assert_equal("hello.", "hello.txt".sub_ext(nil))
|
68
|
+
end
|
69
|
+
def test_name_error_in_task
|
70
|
+
open "rf.t", "w" do |f|
|
71
|
+
f << <<-EOF
|
72
|
+
task :a do
|
73
|
+
n_i_x
|
74
|
+
end
|
75
|
+
EOF
|
76
|
+
end
|
77
|
+
out, err = assert_rant(:fail, "-frf.t")
|
78
|
+
assert(out.strip.empty?)
|
79
|
+
assert_match(/rf\.t/, err)
|
80
|
+
assert_match(/2/, err)
|
81
|
+
assert_match(/n_i_x/, err)
|
82
|
+
end
|
47
83
|
end
|
data/test/test_rule.rb
CHANGED
@@ -49,6 +49,12 @@ class TestRule < Test::Unit::TestCase
|
|
49
49
|
assert(test(?f, "r.tt"))
|
50
50
|
assert(test(?f, "r.lt"))
|
51
51
|
end
|
52
|
+
def test_enhance_rule_task
|
53
|
+
out, err = assert_rant("-frule.rf", "enhance_t=1", "eh.t")
|
54
|
+
assert(test(?f, "eh.t"))
|
55
|
+
assert_match(/eh\.t created/, out)
|
56
|
+
assert(err !~ /\[WARNING\]|\[ERROR\]/)
|
57
|
+
end
|
52
58
|
if Rant::Env.find_bin("cc") && Rant::Env.find_bin("gcc")
|
53
59
|
# Note: we are assuming that "cc" invokes "gcc"!
|
54
60
|
def test_cc
|
@@ -60,8 +66,5 @@ if Rant::Env.find_bin("cc") && Rant::Env.find_bin("gcc")
|
|
60
66
|
end
|
61
67
|
else
|
62
68
|
$stderr.puts "*** cc/gcc not available, less rule tests ***"
|
63
|
-
def test_dummy
|
64
|
-
assert(true)
|
65
|
-
end
|
66
69
|
end
|
67
70
|
end
|
data/test/test_source.rb
CHANGED
@@ -9,7 +9,7 @@ $testDir ||= File.expand_path(File.dirname(__FILE__))
|
|
9
9
|
|
10
10
|
class TestSource < Test::Unit::TestCase
|
11
11
|
def setup
|
12
|
-
Dir.chdir
|
12
|
+
Dir.chdir $testDir
|
13
13
|
end
|
14
14
|
def teardown
|
15
15
|
capture_std do
|
@@ -23,4 +23,31 @@ class TestSource < Test::Unit::TestCase
|
|
23
23
|
assert(test(?f, "auto.rf"))
|
24
24
|
assert(test(?f, "auto.t"))
|
25
25
|
end
|
26
|
+
def test_source_now
|
27
|
+
open "rf.t", "w" do |f|
|
28
|
+
f << <<-EOF
|
29
|
+
file "source.rf.t" do |t|
|
30
|
+
sys.touch t.name
|
31
|
+
end
|
32
|
+
task :source_now do
|
33
|
+
source :n, "source.rf.t"
|
34
|
+
end
|
35
|
+
task :source_now2 do
|
36
|
+
sys.touch "source.rf.t"
|
37
|
+
source :n, "source.rf.t"
|
38
|
+
end
|
39
|
+
task :mk_source do
|
40
|
+
source "source.rf.t"
|
41
|
+
end
|
42
|
+
EOF
|
43
|
+
end
|
44
|
+
assert_rant("-frf.t", "mk_source")
|
45
|
+
assert(test(?f, "source.rf.t"))
|
46
|
+
FileUtils.rm "source.rf.t"
|
47
|
+
out, err = assert_rant(:fail, "-frf.t", "source_now")
|
48
|
+
assert(!test(?f, "source.rf.t"))
|
49
|
+
assert_match(/\[ERROR\].*source.*No such file.*source\.rf\.t/im, err)
|
50
|
+
assert_rant("-frf.t", "source_now2")
|
51
|
+
assert(test(?f, "source.rf.t"))
|
52
|
+
end
|
26
53
|
end
|