rant 0.3.4 → 0.3.6
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 +1 -1
- data/Rantfile +24 -16
- data/doc/advanced.rdoc +188 -0
- data/doc/examples/directedrule/Rantfile +23 -0
- data/doc/examples/directedrule/src_a/a_1.c +0 -0
- data/doc/examples/directedrule/src_a/a_2.c +5 -0
- data/doc/examples/directedrule/src_b/b_1.c +0 -0
- data/doc/jamis.rb +590 -0
- data/doc/rantfile.rdoc +29 -9
- data/lib/rant/import.rb +19 -9
- data/lib/rant/import/autoclean.rb +65 -0
- data/lib/rant/import/clean.rb +45 -0
- data/lib/rant/import/directedrule.rb +122 -0
- data/lib/rant/import/package.rb +258 -0
- data/lib/rant/import/rubydoc.rb +5 -0
- data/lib/rant/import/rubypackage.rb +1 -1
- data/lib/rant/import/truth.rb +24 -0
- data/lib/rant/plugin/configure.rb +1 -0
- data/lib/rant/rantfile.rb +77 -26
- data/lib/rant/rantlib.rb +116 -21
- data/lib/rant/rantsys.rb +92 -4
- data/lib/rant/rantvar.rb +252 -11
- data/rantmethods.rb +2 -2
- data/test/Rantfile +35 -1
- data/test/import/directedrule/Rantfile +27 -0
- data/test/import/directedrule/test_directedrule.rb +31 -0
- data/test/import/truth/Rantfile +16 -0
- data/test/import/truth/test_truth.rb +23 -0
- data/test/rant-import/Rantfile +15 -0
- data/test/rant-import/test_rant-import.rb +65 -0
- data/test/test_clean.rb +134 -0
- data/test/test_examples.rb +47 -0
- data/test/test_filelist.rb +58 -0
- data/test/test_rac.rb +59 -0
- data/test/test_rantfile_api.rb +47 -0
- data/test/test_var.rb +176 -0
- data/test/tutil.rb +18 -2
- data/test/var.rf +23 -0
- metadata +29 -2
data/rantmethods.rb
CHANGED
@@ -28,7 +28,7 @@ task :gem_attrs do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
file "bench-rant" do |t|
|
31
|
-
c =
|
31
|
+
c = 2000
|
32
32
|
if var["TC"]
|
33
33
|
c = Integer(var["TC"])
|
34
34
|
end
|
@@ -53,7 +53,7 @@ file "bench-rant" do |t|
|
|
53
53
|
end
|
54
54
|
|
55
55
|
file "bench-depsearch" do |t|
|
56
|
-
c =
|
56
|
+
c = 2000
|
57
57
|
if var["TC"]
|
58
58
|
c = Integer var["TC"]
|
59
59
|
end
|
data/test/Rantfile
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
|
2
|
+
gen Action do
|
3
|
+
puts "running action" if var[:act_verbose]
|
4
|
+
end
|
5
|
+
|
2
6
|
task :do_nothing
|
3
7
|
|
4
8
|
file "auto.rf" do |t|
|
@@ -11,8 +15,38 @@ file "auto.rf" do |t|
|
|
11
15
|
}
|
12
16
|
end
|
13
17
|
|
18
|
+
file "version.t" do |t|
|
19
|
+
open(t.name, "w") { |f| f.puts "1.0" }
|
20
|
+
end
|
21
|
+
|
22
|
+
gen Action do
|
23
|
+
rac.build "version.t"
|
24
|
+
end
|
25
|
+
|
14
26
|
source "auto.rf"
|
15
27
|
|
16
28
|
task :clean do
|
17
|
-
sys.rm_f %w(auto.t auto.rf)
|
29
|
+
sys.rm_f %w(auto.t auto.rf version.t)
|
18
30
|
end
|
31
|
+
|
32
|
+
gen Directory, "tmp.t"
|
33
|
+
task "tmp.t/Rantfile" => "tmp.t" do |t|
|
34
|
+
open(t.name, "w") { |f|
|
35
|
+
f << <<-EOF
|
36
|
+
file "test.t" do |t| sys.touch t.name end
|
37
|
+
EOF
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
task :subdir_tmp do
|
42
|
+
subdirs %w(tmp.t)
|
43
|
+
end
|
44
|
+
|
45
|
+
task :build_test_t do |t|
|
46
|
+
rac.build "tmp.t/test.t"
|
47
|
+
# just ensure we're NOT in the tmp.t directory
|
48
|
+
#STDERR.puts Dir.pwd
|
49
|
+
test(?d, "tmp.t") or t.fail
|
50
|
+
end
|
51
|
+
|
52
|
+
# vim: ft=ruby
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
import %w(directedrule autoclean)
|
3
|
+
|
4
|
+
task :mk_src => %w(src.t/1.b src.t/2.b src.t/3.b)
|
5
|
+
gen Directory, "src.t"
|
6
|
+
%w(src.t/1.b src.t/2.b src.t/3.b).each { |f|
|
7
|
+
file f => "src.t" do |t| sys.touch t.name end
|
8
|
+
}
|
9
|
+
|
10
|
+
file "foo.t" => %w(build.t/1.a build.t/2.a) do |t|
|
11
|
+
t.fail unless test(?f, "build.t/1.a") && test(?f, "build.t/2.a")
|
12
|
+
sys.touch t.name
|
13
|
+
end
|
14
|
+
|
15
|
+
gen Directory, "build.t"
|
16
|
+
|
17
|
+
gen Action do
|
18
|
+
rac.build "build.t"
|
19
|
+
end
|
20
|
+
|
21
|
+
ro_tt = gen DirectedRule, "build.t" => ["src.t"], :a => :b do |t|
|
22
|
+
sys.touch t.name
|
23
|
+
end
|
24
|
+
|
25
|
+
gen AutoClean
|
26
|
+
|
27
|
+
# vim:ft=ruby
|
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
require 'test/unit'
|
3
|
+
require 'tutil'
|
4
|
+
|
5
|
+
$testImportDrDir ||= File.expand_path(File.dirname(__FILE__))
|
6
|
+
|
7
|
+
class TestDirectedRule < Test::Unit::TestCase
|
8
|
+
def setup
|
9
|
+
# Ensure we run in test directory.
|
10
|
+
Dir.chdir($testImportDrDir) unless Dir.pwd == $testImportDrDir
|
11
|
+
end
|
12
|
+
def teardown
|
13
|
+
assert_rant("autoclean")
|
14
|
+
assert_equal(0, Dir["**/*.t"].size)
|
15
|
+
end
|
16
|
+
def rant(*args)
|
17
|
+
Rant::RantApp.new(*args).run
|
18
|
+
end
|
19
|
+
def test_cmd_target
|
20
|
+
assert_rant
|
21
|
+
assert_rant("build.t/3.a")
|
22
|
+
assert(test(?d, "build.t"))
|
23
|
+
assert(test(?f, "build.t/3.a"))
|
24
|
+
assert(!test(?e, "build.t/1.a"))
|
25
|
+
end
|
26
|
+
def test_dependencies
|
27
|
+
assert_rant
|
28
|
+
assert_rant("foo.t")
|
29
|
+
assert(test(?f, "foo.t"))
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
require 'test/unit'
|
3
|
+
require 'tutil'
|
4
|
+
|
5
|
+
$testImportTruthDir ||= File.expand_path(File.dirname(__FILE__))
|
6
|
+
|
7
|
+
class TestTruth < Test::Unit::TestCase
|
8
|
+
def setup
|
9
|
+
# Ensure we run in test directory.
|
10
|
+
Dir.chdir($testImportTruthDir) unless Dir.pwd == $testImportTruthDir
|
11
|
+
end
|
12
|
+
def test_opt_tasks
|
13
|
+
out, err = assert_rant("--tasks")
|
14
|
+
assert_match(
|
15
|
+
/print hello.*\n.*touch rm\.t.*\n.*this file is useless/, out)
|
16
|
+
end
|
17
|
+
def test_drag
|
18
|
+
assert_rant("rm.t")
|
19
|
+
assert(test(?f, "rm.t"))
|
20
|
+
assert_rant("clean")
|
21
|
+
assert(!test(?e, "rm.t"))
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rant/rantlib'
|
4
|
+
require 'tutil'
|
5
|
+
require 'fileutils'
|
6
|
+
|
7
|
+
$testRantImportDir ||= File.expand_path(File.dirname(__FILE__))
|
8
|
+
|
9
|
+
class TestRantImport < Test::Unit::TestCase
|
10
|
+
def setup
|
11
|
+
# Ensure we run in test directory.
|
12
|
+
Dir.chdir($testRantImportDir) unless Dir.pwd == $testRantImportDir
|
13
|
+
end
|
14
|
+
def teardown
|
15
|
+
FileUtils.rm_f Dir["ant*"]
|
16
|
+
FileUtils.rm_f Dir["make*"]
|
17
|
+
FileUtils.rm_rf Dir["*.t"]
|
18
|
+
end
|
19
|
+
def test_no_import
|
20
|
+
run_import("--quiet", "make.rb")
|
21
|
+
assert(test(?f, "make.rb"))
|
22
|
+
assert(!test(?f, "action.t"))
|
23
|
+
assert_equal(run_rant("hello"), run_ruby("make.rb", "hello"))
|
24
|
+
assert(test(?f, "action.t"))
|
25
|
+
end
|
26
|
+
def test_import_from_custom_lib
|
27
|
+
FileUtils.mkpath "mylib.t/rant/import"
|
28
|
+
open("mylib.t/rant/import/mygen.rb", "w") { |f|
|
29
|
+
f << <<-EOF
|
30
|
+
mygen = Object.new
|
31
|
+
def mygen.rant_generate(rac, ch, args, &block)
|
32
|
+
tn = args.first || "mygen"
|
33
|
+
rac.task(:__caller__ => ch, tn => []) do |t|
|
34
|
+
puts "Greetings from `" + t.name + "', generated by MyGen."
|
35
|
+
rac.cx.sys.touch t.name
|
36
|
+
end
|
37
|
+
end
|
38
|
+
Rant::Generators::MyGen = mygen
|
39
|
+
EOF
|
40
|
+
}
|
41
|
+
open("mygen.rf.t", "w") { |f|
|
42
|
+
f << <<-EOF
|
43
|
+
$:.unshift "mylib.t"
|
44
|
+
import "mygen"
|
45
|
+
desc "task created by mygen"
|
46
|
+
gen MyGen
|
47
|
+
EOF
|
48
|
+
}
|
49
|
+
out, err = capture_std do
|
50
|
+
assert_equal(0, Rant::RantApp.new("-fmygen.rf.t").run)
|
51
|
+
end
|
52
|
+
assert_match(/Greetings.*mygen/, out)
|
53
|
+
assert(test(?f, "mygen"))
|
54
|
+
FileUtils.rm_f "mygen"
|
55
|
+
assert(!test(?e, "mygen"))
|
56
|
+
run_import("--quiet", "-fmygen.rf.t", "ant")
|
57
|
+
assert(test(?f, "ant"))
|
58
|
+
FileUtils.rm_r "mylib.t"
|
59
|
+
out = run_ruby("ant", "-fmygen.rf.t")
|
60
|
+
assert_match(/Greetings.*mygen/, out)
|
61
|
+
assert(test(?f, "mygen"))
|
62
|
+
ensure
|
63
|
+
FileUtils.rm_f "mygen"
|
64
|
+
end
|
65
|
+
end
|
data/test/test_clean.rb
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rant/rantlib'
|
4
|
+
require 'tutil'
|
5
|
+
require 'fileutils'
|
6
|
+
|
7
|
+
$testDir ||= File.expand_path(File.dirname(__FILE__))
|
8
|
+
|
9
|
+
class TestClean < Test::Unit::TestCase
|
10
|
+
def setup
|
11
|
+
# Ensure we run in test directory.
|
12
|
+
Dir.chdir($testDir) unless Dir.pwd == $testDir
|
13
|
+
end
|
14
|
+
def teardown
|
15
|
+
end
|
16
|
+
def layout_project1
|
17
|
+
FileUtils.mkdir "p1.t"
|
18
|
+
Dir.chdir "p1.t" do
|
19
|
+
open("Rantfile", "w") { |f|
|
20
|
+
f << <<-EOF
|
21
|
+
import "clean"
|
22
|
+
task :mk_junk => "sub1.t/mk_junk" do
|
23
|
+
sys.touch %w(a1.t a2.t b1.t b2.t)
|
24
|
+
sys.mkdir %w(sa.t sb.t)
|
25
|
+
sys.touch %w(sa.t/1 sb.t/1)
|
26
|
+
end
|
27
|
+
gen Clean
|
28
|
+
var[:clean].include "*a*.t"
|
29
|
+
subdirs "sub1.t"
|
30
|
+
EOF
|
31
|
+
}
|
32
|
+
end
|
33
|
+
FileUtils.mkdir "p1.t/sub1.t"
|
34
|
+
Dir.chdir "p1.t/sub1.t" do
|
35
|
+
open("Rantfile", "w") { |f|
|
36
|
+
f << <<-EOF
|
37
|
+
import "clean"
|
38
|
+
task :mk_junk do
|
39
|
+
sys.touch %w(a1.t a2.t b1.t b2.t)
|
40
|
+
sys.mkdir %w(sa.t sb.t)
|
41
|
+
end
|
42
|
+
gen Clean
|
43
|
+
var[:clean].include "*b*.t"
|
44
|
+
EOF
|
45
|
+
}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
def cleanup_project1
|
49
|
+
FileUtils.rm_rf "p1.t"
|
50
|
+
end
|
51
|
+
def test_project1
|
52
|
+
layout_project1
|
53
|
+
assert(test(?d, "p1.t"))
|
54
|
+
Dir.chdir "p1.t"
|
55
|
+
assert(test(?f, "Rantfile"))
|
56
|
+
assert(test(?d, "sub1.t"))
|
57
|
+
assert(test(?f, "sub1.t/Rantfile"))
|
58
|
+
|
59
|
+
capture_std do
|
60
|
+
assert_equal(0, Rant::RantApp.new.run)
|
61
|
+
end
|
62
|
+
files = %w(a1.t a2.t b1.t b2.t sub1.t/a1.t
|
63
|
+
sub1.t/a2.t sub1.t/b1.t sub1.t/b2.t)
|
64
|
+
dirs = %w(sa.t sb.t)
|
65
|
+
files.each { |f| assert(test(?f, f)) }
|
66
|
+
dirs.each { |f| assert(test(?d, f)) }
|
67
|
+
capture_std do
|
68
|
+
assert_equal(0, Rant::RantApp.new("clean").run)
|
69
|
+
end
|
70
|
+
%w(sa.t a1.t a2.t sub1.t/b1.t sub1.t/b2.t).each { |f|
|
71
|
+
assert(!test(?e, f))
|
72
|
+
}
|
73
|
+
%w(sb.t b1.t b2.t sub1.t/a1.t sub1.t/a2.t).each { |f|
|
74
|
+
assert(test(?e, f))
|
75
|
+
}
|
76
|
+
Dir.chdir "sub1.t"
|
77
|
+
FileUtils.rm_rf %w(sa.t sb.t)
|
78
|
+
capture_std do
|
79
|
+
assert_equal(0, Rant::RantApp.new.run)
|
80
|
+
end
|
81
|
+
%w(a1.t a2.t b1.t b2.t).each { |f| assert(test(?f, f)) }
|
82
|
+
%w(sa.t sb.t).each { |f| assert(test(?d, f)) }
|
83
|
+
capture_std do
|
84
|
+
assert_equal(0, Rant::RantApp.new("clean").run)
|
85
|
+
end
|
86
|
+
%w(b1.t b2.t sb.t).each { |f| assert(!test(?e, f)) }
|
87
|
+
%w(a1.t a2.t sa.t).each { |f| assert(test(?e, f)) }
|
88
|
+
|
89
|
+
ensure
|
90
|
+
Dir.chdir $testDir
|
91
|
+
cleanup_project1
|
92
|
+
end
|
93
|
+
def layout_project2
|
94
|
+
FileUtils.mkdir "p2.t"
|
95
|
+
Dir.chdir "p2.t"
|
96
|
+
open("Rantfile", "w") { |f|
|
97
|
+
f << <<-EOF
|
98
|
+
import "autoclean"
|
99
|
+
task :mk_junk => %w(a.t b.t/c.t/d.t) do
|
100
|
+
sys.touch "mk_junk.t"
|
101
|
+
end
|
102
|
+
gen AutoClean
|
103
|
+
file "a.t" do |t|
|
104
|
+
sys.touch t.name
|
105
|
+
end
|
106
|
+
gen Directory, "b.t/c.t"
|
107
|
+
file "b.t/c.t/d.t" => "b.t/c.t" do |t|
|
108
|
+
sys.touch t.name
|
109
|
+
end
|
110
|
+
var[:autoclean].include "mk_junk.t"
|
111
|
+
var[:autoclean].include "nix.t"
|
112
|
+
EOF
|
113
|
+
}
|
114
|
+
end
|
115
|
+
def cleanup_project2
|
116
|
+
FileUtils.rm_rf "p2.t"
|
117
|
+
end
|
118
|
+
def test_project2_autoclean
|
119
|
+
layout_project2
|
120
|
+
capture_std do
|
121
|
+
assert_equal(0, Rant::RantApp.new.run)
|
122
|
+
end
|
123
|
+
%w(a.t b.t/c.t/d.t mk_junk.t).each { |f| assert(test(?e, f)) }
|
124
|
+
capture_std do
|
125
|
+
assert_equal(0, Rant::RantApp.new("autoclean").run)
|
126
|
+
end
|
127
|
+
%w(a.t b.t/c.t/d.t mk_junk.t).each { |f| assert(!test(?e, f)) }
|
128
|
+
capture_std do
|
129
|
+
assert_equal(1, Rant::RantApp.new("clean").run)
|
130
|
+
end
|
131
|
+
ensure
|
132
|
+
cleanup_project2
|
133
|
+
end
|
134
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rant/rantlib'
|
4
|
+
require 'tutil'
|
5
|
+
|
6
|
+
$examplesDir ||= File.expand_path(
|
7
|
+
File.join(File.dirname(File.dirname(__FILE__)), "doc", "examples"))
|
8
|
+
|
9
|
+
$cc_is_gcc ||= Rant::Env.find_bin("cc") && Rant::Env.find_bin("gcc")
|
10
|
+
class TestExamples < Test::Unit::TestCase
|
11
|
+
def setup
|
12
|
+
# Ensure we run in test directory.
|
13
|
+
Dir.chdir($examplesDir) unless Dir.pwd == $examplesDir
|
14
|
+
end
|
15
|
+
def teardown
|
16
|
+
end
|
17
|
+
def test_myprog
|
18
|
+
Dir.chdir "myprog"
|
19
|
+
assert_match(/Build myprog.*\n.*Remove compiler products/,
|
20
|
+
run_rant("--tasks"))
|
21
|
+
assert(!test(?f, "myprog"))
|
22
|
+
if $cc_is_gcc
|
23
|
+
# Warning: we're assuming cc is actually gcc
|
24
|
+
run_rant
|
25
|
+
assert(test(?f, "myprog"))
|
26
|
+
else
|
27
|
+
$stderr.puts "*** cc isn't gcc, less example testing ***"
|
28
|
+
# less myprog testing
|
29
|
+
end
|
30
|
+
run_rant("clean")
|
31
|
+
assert(!test(?e, "myprog"))
|
32
|
+
assert(!test(?e, "src/myprog"))
|
33
|
+
assert(!test(?e, "src/lib.o"))
|
34
|
+
assert(!test(?e, "src/main.o"))
|
35
|
+
end
|
36
|
+
def test_directedrule
|
37
|
+
Dir.chdir "directedrule"
|
38
|
+
assert_match(/Build foo/, run_rant("-T"))
|
39
|
+
assert(!test(?f, "foo"))
|
40
|
+
if $cc_is_gcc
|
41
|
+
run_rant
|
42
|
+
assert(test(?f, "foo"))
|
43
|
+
end
|
44
|
+
run_rant("clean")
|
45
|
+
Dir["**/*.o"].each { |f| assert(!test(?e, f)) }
|
46
|
+
end
|
47
|
+
end
|
data/test/test_filelist.rb
CHANGED
@@ -221,4 +221,62 @@ class TestFileList < Test::Unit::TestCase
|
|
221
221
|
ensure
|
222
222
|
FileUtils.rm_rf "fl.t"
|
223
223
|
end
|
224
|
+
def test_return_from_array_method
|
225
|
+
touch_temp "a.t" do
|
226
|
+
l = fl("a.t", "a.t")
|
227
|
+
ul = l.uniq
|
228
|
+
assert(Array === ul)
|
229
|
+
assert_equal(1, ul.size)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
def test_return_self_from_array_method
|
233
|
+
touch_temp "a.t", "b.t" do
|
234
|
+
l = fl("*.t")
|
235
|
+
sl = l.sort!
|
236
|
+
assert_same(l, sl)
|
237
|
+
assert_equal("a.t", l.first)
|
238
|
+
assert_equal("b.t", l[1])
|
239
|
+
end
|
240
|
+
end
|
241
|
+
def test_sys_with_cd
|
242
|
+
FileUtils.mkdir "sub.t"
|
243
|
+
open("sys_cd.rf.t", "w") { |f|
|
244
|
+
f << <<-EOF
|
245
|
+
file "sub.t/a.t" => "sub.t/b.t" do |t|
|
246
|
+
sys.touch t.name
|
247
|
+
end
|
248
|
+
file "sub.t/b.t" do |t|
|
249
|
+
sys.touch t.name
|
250
|
+
end
|
251
|
+
task :clean do
|
252
|
+
sys.cd "sub.t"
|
253
|
+
sys.rm_f sys["*.t"]
|
254
|
+
end
|
255
|
+
EOF
|
256
|
+
}
|
257
|
+
capture_std do
|
258
|
+
Rant::RantApp.new("-fsys_cd.rf.t", "sub.t/a.t").run
|
259
|
+
end
|
260
|
+
assert(test(?f, "sub.t/a.t"))
|
261
|
+
assert(test(?f, "sub.t/b.t"))
|
262
|
+
capture_std do
|
263
|
+
Rant::RantApp.new("-fsys_cd.rf.t", "clean").run
|
264
|
+
end
|
265
|
+
assert(!test(?e, "sub.t/a.t"))
|
266
|
+
assert(!test(?e, "sub.t/b.t"))
|
267
|
+
ensure
|
268
|
+
FileUtils.rm_rf %w(sub.t sys_cd.rf.t)
|
269
|
+
end
|
270
|
+
def test_sys_select
|
271
|
+
cx = Rant::RantApp.new.cx
|
272
|
+
touch_temp %w(a.t b.t) do
|
273
|
+
l1 = cx.sys["*.t"]
|
274
|
+
l2 = l1.select { |f| f =~ /^b/ }
|
275
|
+
assert_equal(2, l1.size)
|
276
|
+
assert(l1.include("a.t"))
|
277
|
+
assert(l1.include("b.t"))
|
278
|
+
assert_equal(1, l2.size)
|
279
|
+
assert(l1.include("b.t"))
|
280
|
+
end
|
281
|
+
end
|
224
282
|
end
|