rant 0.3.0 → 0.3.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/NEWS +21 -0
- data/README +8 -0
- data/Rantfile +30 -16
- data/TODO +3 -4
- data/devel-notes +16 -0
- data/doc/csharp.rdoc +2 -3
- data/doc/examples/myprog/README +2 -0
- data/doc/examples/myprog/Rantfile +13 -0
- data/doc/examples/myprog/src/Rantfile +15 -0
- data/doc/examples/myprog/src/lib.c +6 -0
- data/doc/examples/myprog/src/lib.h +4 -0
- data/doc/examples/myprog/src/main.c +7 -0
- data/doc/rantfile.rdoc +108 -3
- data/lib/rant/cs_compiler.rb +6 -4
- data/lib/rant/import.rb +13 -0
- data/lib/rant/import/rubypackage.rb +43 -20
- data/lib/rant/plugin/configure.rb +21 -7
- data/lib/rant/plugin/csharp.rb +8 -9
- data/lib/rant/rantenv.rb +3 -0
- data/lib/rant/rantfile.rb +66 -33
- data/lib/rant/rantlib.rb +133 -27
- data/lib/rant/rantsys.rb +197 -42
- data/rantmethods.rb +46 -0
- data/setup.rb +18 -4
- data/test/plugin/configure/Rantfile +0 -6
- data/test/plugin/configure/test_configure.rb +2 -2
- data/test/plugin/csharp/test_csharp.rb +7 -2
- data/test/plugin/rantfile +45 -0
- data/test/plugin/test_conf_csharp.rb +53 -0
- data/test/project1/Rantfile +4 -0
- data/test/project1/test_project.rb +33 -8
- data/test/project2/buildfile +3 -3
- data/test/project2/sub1/Rantfile +3 -3
- data/test/project2/test_project.rb +6 -4
- data/test/project_rb1/test_project_rb1.rb +2 -2
- data/test/standalone.rf +10 -0
- data/test/subdirs/Rantfile +26 -0
- data/test/subdirs/sub1/Rantfile +15 -0
- data/test/subdirs/sub2/rantfile.rb +14 -0
- data/test/subdirs/sub2/sub/rantfile +15 -0
- data/test/subdirs/test_subdirs.rb +96 -0
- data/test/test_env.rb +3 -3
- data/test/test_filelist.rb +143 -0
- data/test/test_lighttask.rb +21 -0
- data/test/test_metatask.rb +1 -1
- data/test/test_rant_interface.rb +5 -5
- data/test/test_sys.rb +7 -1
- data/test/test_task.rb +25 -0
- data/test/toplevel.rf +0 -1
- data/test/tutil.rb +26 -1
- metadata +39 -14
data/test/standalone.rf
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
file "t" => "sub1/t" do |t|
|
3
|
+
sys.touch t.name
|
4
|
+
end
|
5
|
+
|
6
|
+
file "2t" => "sub2/t" do |t|
|
7
|
+
sys.touch t.name
|
8
|
+
end
|
9
|
+
|
10
|
+
file "subdep.t" do |t|
|
11
|
+
sys.touch t.name
|
12
|
+
end
|
13
|
+
|
14
|
+
task :sub_sub => "sub2/sub/rootref.t" do |t|
|
15
|
+
test(?f, "sub2/sub/rootref.t") or t.fail
|
16
|
+
sys.touch "sub_sub.t"
|
17
|
+
end
|
18
|
+
|
19
|
+
#task :clean => ["sub1/clean", "sub2/clean"] do
|
20
|
+
task :clean => ["sub2/clean", "sub1/clean", "sub2/sub/clean"] do
|
21
|
+
sys.rm_f Dir["*t"]
|
22
|
+
end
|
23
|
+
|
24
|
+
subdirs FileList["sub*"].exclude("*.*")
|
25
|
+
|
26
|
+
# vim:ft=ruby
|
@@ -0,0 +1,96 @@
|
|
1
|
+
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rant/rantlib'
|
4
|
+
require 'tutil'
|
5
|
+
|
6
|
+
# Ensure we run in testproject directory.
|
7
|
+
$testSubdirsDir = File.expand_path(File.dirname(__FILE__))
|
8
|
+
|
9
|
+
class TestSubdirs < Test::Unit::TestCase
|
10
|
+
def setup
|
11
|
+
Dir.chdir($testSubdirsDir) unless Dir.pwd == $testSubdirsDir
|
12
|
+
Rant.reset
|
13
|
+
end
|
14
|
+
def teardown
|
15
|
+
capture_std do
|
16
|
+
assert_equal(Rant.run("clean"), 0)
|
17
|
+
end
|
18
|
+
created = Dir["**/*t"]
|
19
|
+
assert(created.empty?)
|
20
|
+
end
|
21
|
+
def test_load
|
22
|
+
capture_std do
|
23
|
+
assert_equal(0, Rant.run("-T"))
|
24
|
+
end
|
25
|
+
end
|
26
|
+
def test_sub_dep
|
27
|
+
capture_std do
|
28
|
+
assert_equal(0, Rant.run("t"))
|
29
|
+
end
|
30
|
+
assert(test(?f, "sub1/t"),
|
31
|
+
"t depends on sub1/t")
|
32
|
+
assert(test(?f, "t"))
|
33
|
+
end
|
34
|
+
def test_sub_dep2
|
35
|
+
capture_std do
|
36
|
+
assert_equal(0, Rant.run("2t"))
|
37
|
+
end
|
38
|
+
assert(test(?f, "sub2/t"))
|
39
|
+
assert(test(?f, "2t"))
|
40
|
+
assert(!test(?e, "sub1/t"))
|
41
|
+
end
|
42
|
+
def test_sub_task_from_commandline
|
43
|
+
capture_std do
|
44
|
+
assert_equal(0, Rant.run("sub1/t"))
|
45
|
+
end
|
46
|
+
assert(test(?f, "sub1/t"))
|
47
|
+
assert(!test(?e, "t"))
|
48
|
+
capture_std do
|
49
|
+
assert_equal(0, Rant.run("sub1/clean"))
|
50
|
+
end
|
51
|
+
assert(!test(?f, "sub1/t"))
|
52
|
+
end
|
53
|
+
def test_root_dep
|
54
|
+
capture_std do
|
55
|
+
assert_equal(0, Rant.run("sub1/rootdep.t"))
|
56
|
+
end
|
57
|
+
assert(test(?f, "subdep.t"))
|
58
|
+
assert(test(?f, "sub1/rootdep.t"))
|
59
|
+
end
|
60
|
+
def test_sub_sub_dep
|
61
|
+
capture_std do
|
62
|
+
assert_equal(0, Rant.run("sub2/subdep.t"))
|
63
|
+
end
|
64
|
+
assert(test(?f, "sub2/subdep.t"))
|
65
|
+
assert(test(?f, "sub2/sub/rootdep.t"))
|
66
|
+
end
|
67
|
+
def test_sub_sub_rootref
|
68
|
+
capture_std do
|
69
|
+
assert_equal(0, Rant.run("sub2/sub/rootref.t"))
|
70
|
+
end
|
71
|
+
assert(test(?f, "t"))
|
72
|
+
assert(test(?f, "sub2/sub/rootref.t"))
|
73
|
+
end
|
74
|
+
def test_root_sub_sub_rootref
|
75
|
+
capture_std do
|
76
|
+
assert_equal(0, Rant.run("sub_sub"))
|
77
|
+
end
|
78
|
+
assert(test(?f, "sub_sub.t"))
|
79
|
+
assert(test(?f, "sub2/sub/rootref.t"))
|
80
|
+
assert(test(?f, "t"))
|
81
|
+
end
|
82
|
+
def test_import
|
83
|
+
run_import %w(--auto ant)
|
84
|
+
assert_equal($?, 0)
|
85
|
+
capture_std do
|
86
|
+
assert_nothing_raised {
|
87
|
+
Rant::Sys.ruby("ant", "-q", "sub_sub")
|
88
|
+
}
|
89
|
+
end
|
90
|
+
assert(test(?f, "sub_sub.t"))
|
91
|
+
assert(test(?f, "sub2/sub/rootref.t"))
|
92
|
+
assert(test(?f, "t"))
|
93
|
+
ensure
|
94
|
+
File.delete "ant" if File.exist? "ant"
|
95
|
+
end
|
96
|
+
end
|
data/test/test_env.rb
CHANGED
@@ -30,15 +30,15 @@ class TestRantEnv < Test::Unit::TestCase
|
|
30
30
|
have_echo = `echo hello` =~ /hello/
|
31
31
|
rescue Exception
|
32
32
|
end
|
33
|
-
if have_echo
|
34
|
-
=begin
|
33
|
+
if have_echo
|
34
|
+
=begin
|
35
35
|
# seems to be not so on windows...
|
36
36
|
echo_bin = Rant::Env.find_bin("echo")
|
37
37
|
assert(echo_bin,
|
38
38
|
"echo can be invoked, so find_bin should find it")
|
39
39
|
assert(echo_bin =~ /echo/i)
|
40
40
|
assert(`#{echo_bin} hello` =~ /hello/,
|
41
|
-
"echo should be invokable through `#{echo_bin}'")
|
41
|
+
"echo should be invokable through `#{echo_bin}'")
|
42
42
|
=end
|
43
43
|
else
|
44
44
|
puts "*** echo not available, will not search with find_bin ***"
|
@@ -0,0 +1,143 @@
|
|
1
|
+
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rant/rantlib'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'tutil'
|
6
|
+
|
7
|
+
$testDir ||= File.expand_path(File.dirname(__FILE__))
|
8
|
+
|
9
|
+
class TestFileList < Test::Unit::TestCase
|
10
|
+
def fl(*args, &block)
|
11
|
+
Rant::FileList.new(*args, &block)
|
12
|
+
end
|
13
|
+
def touch_temp(*args)
|
14
|
+
files = args.flatten
|
15
|
+
files.each { |f| FileUtils.touch f }
|
16
|
+
yield if block_given?
|
17
|
+
ensure
|
18
|
+
files.each { |f|
|
19
|
+
File.delete f if File.exist? f
|
20
|
+
}
|
21
|
+
end
|
22
|
+
def setup
|
23
|
+
# Ensure we run in test directory.
|
24
|
+
Dir.chdir($testDir) unless Dir.pwd == $testDir
|
25
|
+
end
|
26
|
+
def teardown
|
27
|
+
end
|
28
|
+
def test_in_flatten
|
29
|
+
touch_temp %w(1.t 2.t) do
|
30
|
+
assert(test(?f, "1.t")) # test touch_temp...
|
31
|
+
assert(test(?f, "2.t"))
|
32
|
+
assert_equal(2, fl("*.t").size)
|
33
|
+
# see comments in FileList implementation to understand
|
34
|
+
# the necessity of this test...
|
35
|
+
assert_equal(2, [fl("*.t")].flatten.size)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
def test_exclude_all
|
39
|
+
l = fl
|
40
|
+
inc_list = %w(
|
41
|
+
CVS_ a/b a
|
42
|
+
).map! { |f| f.tr "/", File::SEPARATOR }
|
43
|
+
not_inc_list = %w(
|
44
|
+
CVS a/CVS a/CVS/b CVS/CVS //CVS /CVS/ /a/b/CVS/c
|
45
|
+
).map! { |f| f.tr "/", File::SEPARATOR }
|
46
|
+
l.concat(not_inc_list + inc_list)
|
47
|
+
l.exclude_all "CVS"
|
48
|
+
inc_list.each { |f|
|
49
|
+
assert(l.include?(f))
|
50
|
+
}
|
51
|
+
not_inc_list.each { |f|
|
52
|
+
assert(!l.include?(f))
|
53
|
+
}
|
54
|
+
end
|
55
|
+
def test_initialize
|
56
|
+
touch_temp %w(1.t 2.tt) do
|
57
|
+
assert(fl("*.t").include?("1.t"),
|
58
|
+
'FileList["*.t"] should include 1.t')
|
59
|
+
l = fl("*.t", "*.tt")
|
60
|
+
assert(l.include?("1.t"))
|
61
|
+
assert(l.include?("2.tt"))
|
62
|
+
end
|
63
|
+
end
|
64
|
+
def test_initialize_with_yield
|
65
|
+
touch_temp %w(a.t b.t a.tt b.tt) do
|
66
|
+
list = fl { |l|
|
67
|
+
l.include "*.t", "*.tt"
|
68
|
+
l.exclude "a*"
|
69
|
+
}
|
70
|
+
%w(b.t b.tt).each { |f|
|
71
|
+
assert(list.include?(f), "`#{f}' should be included")
|
72
|
+
}
|
73
|
+
%w(a.t a.tt).each { |f|
|
74
|
+
assert(!list.include?(f), "`#{f}' shouln't be included")
|
75
|
+
}
|
76
|
+
end
|
77
|
+
end
|
78
|
+
def test_mix_include_exclude
|
79
|
+
touch_temp %w(a.t b.t c.t d.t) do
|
80
|
+
list = fl "a*"
|
81
|
+
list.exclude("a*", "b*").include(*%w(b* c* d*))
|
82
|
+
assert(list.exclude_all("d.t").equal?(list))
|
83
|
+
assert(list.include?("b.t"))
|
84
|
+
assert(list.include?("c.t"))
|
85
|
+
assert(!list.include?("a.t"))
|
86
|
+
assert(!list.include?("d.t"))
|
87
|
+
end
|
88
|
+
end
|
89
|
+
def test_exclude_regexp
|
90
|
+
touch_temp %w(aa.t a.t a+.t) do
|
91
|
+
list = fl "*.t"
|
92
|
+
list.exclude(/a+\.t/)
|
93
|
+
assert(list.include?("a+.t"))
|
94
|
+
assert(!list.include?("a.t"))
|
95
|
+
assert(!list.include?("aa.t"))
|
96
|
+
assert_equal(1, list.size)
|
97
|
+
|
98
|
+
list = fl "*.t"
|
99
|
+
list.exclude("a+.t")
|
100
|
+
assert(!list.include?("a+.t"))
|
101
|
+
assert(list.include?("a.t"))
|
102
|
+
assert(list.include?("aa.t"))
|
103
|
+
assert_equal(2, list.size)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
def test_addition
|
107
|
+
touch_temp %w(t.t1 t.t2 t.t3) do
|
108
|
+
l = (fl("*.t1") << "a") + fl("*.t2", "*.t3")
|
109
|
+
assert_equal(4, l.size)
|
110
|
+
%w(t.t1 t.t2 t.t3 a).each { |f|
|
111
|
+
assert(l.include?(f),
|
112
|
+
"`#{f}' should be included")
|
113
|
+
}
|
114
|
+
end
|
115
|
+
end
|
116
|
+
def test_2addition
|
117
|
+
touch_temp %w(1.ta 1.tb 2.t) do
|
118
|
+
l1 = fl "*.ta", "*.t"
|
119
|
+
l2 = fl "1*"
|
120
|
+
l2.exclude "*.ta"
|
121
|
+
l = l1 + l2
|
122
|
+
assert(l.include?("1.ta"))
|
123
|
+
assert_equal(3, l.size)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
def test_glob
|
127
|
+
touch_temp %w(t.t1 t.t2) do
|
128
|
+
l = fl "*.t1"
|
129
|
+
l.glob "*.t2"
|
130
|
+
assert_equal(2, l.size)
|
131
|
+
assert(l.include?("t.t1"))
|
132
|
+
assert(l.include?("t.t2"))
|
133
|
+
end
|
134
|
+
end
|
135
|
+
def test_shun
|
136
|
+
touch_temp %w(t.t1 t.t2) do
|
137
|
+
l = fl "t.*"
|
138
|
+
l.shun "t.t1"
|
139
|
+
assert_equal(1, l.size)
|
140
|
+
assert(l.include?("t.t2"))
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
data/test/test_lighttask.rb
CHANGED
@@ -46,4 +46,25 @@ class TestLightTask < Test::Unit::TestCase
|
|
46
46
|
assert(!t.needed?,
|
47
47
|
"task shouldn't be needed? after first run")
|
48
48
|
end
|
49
|
+
def test_task_with_lighttask_pre
|
50
|
+
lt_run = false
|
51
|
+
lt_nr = false
|
52
|
+
t_run = false
|
53
|
+
@app.args.replace %w(t)
|
54
|
+
t1 = @app.gen Rant::LightTask, :t1 do |t|
|
55
|
+
t.needed { lt_nr = true }
|
56
|
+
t.act { lt_run = true }
|
57
|
+
end
|
58
|
+
t = @app.task :t => :t1 do
|
59
|
+
assert(lt_run,
|
60
|
+
"LightTask prerequisite should run first.")
|
61
|
+
t_run = true
|
62
|
+
end
|
63
|
+
assert(t.needed?)
|
64
|
+
assert(lt_nr)
|
65
|
+
assert(!lt_run,
|
66
|
+
"LightTask#needed? shouldn't run 'act' block")
|
67
|
+
assert_equal(0, @app.run)
|
68
|
+
assert(t_run)
|
69
|
+
end
|
49
70
|
end
|
data/test/test_metatask.rb
CHANGED
@@ -12,7 +12,7 @@ class TestMetaTask < Test::Unit::TestCase
|
|
12
12
|
def test_with_single_task
|
13
13
|
run = false
|
14
14
|
t = @app.task :t do run = true end
|
15
|
-
mt = MetaTask.for_task t
|
15
|
+
mt = Rant::MetaTask.for_task t
|
16
16
|
assert_equal(t.name, mt.name,
|
17
17
|
"MetaTask should have name of contained task(s).")
|
18
18
|
if t.needed?
|
data/test/test_rant_interface.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
2
|
require 'test/unit'
|
3
|
-
require 'rant'
|
3
|
+
require 'rant/rantlib'
|
4
4
|
require 'tutil'
|
5
5
|
|
6
6
|
$testDir ||= File.expand_path(File.dirname(__FILE__))
|
@@ -13,7 +13,7 @@ class TestRantInterface < Test::Unit::TestCase
|
|
13
13
|
def teardown
|
14
14
|
end
|
15
15
|
def test_cmd_targets
|
16
|
-
@app = RantApp.new("-f non_existent", "target", "-aforced_target")
|
16
|
+
@app = Rant::RantApp.new("-f non_existent", "target", "-aforced_target")
|
17
17
|
op = capture_stderr {
|
18
18
|
assert_equal(@app.run, 1,
|
19
19
|
"Rant should fail because there is no such Rantfile.")
|
@@ -28,19 +28,19 @@ class TestRantInterface < Test::Unit::TestCase
|
|
28
28
|
"forced_target should run first")
|
29
29
|
end
|
30
30
|
def test_envvar_on_cmdline
|
31
|
-
@app = RantApp.new("VAR=VAL")
|
31
|
+
@app = Rant::RantApp.new("VAR=VAL")
|
32
32
|
assert_equal(@app.run, 0)
|
33
33
|
assert_equal(ENV["VAR"], "VAL",
|
34
34
|
"rant should set arguments of form VAR=VAL in ENV")
|
35
35
|
end
|
36
36
|
def test_envvar_on_cmdline_lc
|
37
|
-
@app = RantApp.new("var2=val2")
|
37
|
+
@app = Rant::RantApp.new("var2=val2")
|
38
38
|
assert_equal(@app.run, 0)
|
39
39
|
assert_equal(ENV["var2"], "val2",
|
40
40
|
"rant should set arguments of form var2=val2 in ENV")
|
41
41
|
end
|
42
42
|
def test_opt_targets
|
43
|
-
@app = RantApp.new("--tasks")
|
43
|
+
@app = Rant::RantApp.new("--tasks")
|
44
44
|
@app.desc 'This is a "public" target.'
|
45
45
|
@app.task :public_task
|
46
46
|
@app.task :private_task
|
data/test/test_sys.rb
CHANGED
@@ -5,7 +5,7 @@ require 'tutil'
|
|
5
5
|
|
6
6
|
$testDir ||= File.expand_path(File.dirname(__FILE__))
|
7
7
|
|
8
|
-
class
|
8
|
+
class TestSys < Test::Unit::TestCase
|
9
9
|
include Rant::Sys
|
10
10
|
|
11
11
|
def setup
|
@@ -58,4 +58,10 @@ class TestFileUtils < Test::Unit::TestCase
|
|
58
58
|
ensure
|
59
59
|
File.delete "name_error.rf" if File.exist? "name_error.rf"
|
60
60
|
end
|
61
|
+
# ...
|
62
|
+
def test_standalone
|
63
|
+
out = `#{Rant::Sys.sp(Rant::Env::RUBY)} -I#{Rant::Sys.sp(RANT_DEV_LIB_DIR)} standalone.rf`
|
64
|
+
assert(0, $?)
|
65
|
+
assert_match(/^t_standalone/, out)
|
66
|
+
end
|
61
67
|
end
|
data/test/test_task.rb
CHANGED
@@ -112,4 +112,29 @@ class TestTask < Test::Unit::TestCase
|
|
112
112
|
assert_equal(rl, %w(t1 t2 t3),
|
113
113
|
"t3 was run and depends on [t1, t2] => run order: t1 t2 t3")
|
114
114
|
end
|
115
|
+
def test_enhance_gen_task
|
116
|
+
app = Rant::RantApp.new
|
117
|
+
enhance_run = false
|
118
|
+
t_run = false
|
119
|
+
t2_run = false
|
120
|
+
app.gen Rant::Task, :t do |t|
|
121
|
+
t.needed { true }
|
122
|
+
t.act {
|
123
|
+
assert(t2_run,
|
124
|
+
"enhance added `t2' as prerequisite")
|
125
|
+
t_run = true
|
126
|
+
}
|
127
|
+
end
|
128
|
+
app.gen Rant::Task, :t2 do |t|
|
129
|
+
t.needed { true }
|
130
|
+
t.act { t2_run = true }
|
131
|
+
end
|
132
|
+
assert_nothing_raised("generated Task should be enhanceable") {
|
133
|
+
app.enhance :t => :t2 do
|
134
|
+
enhance_run = true
|
135
|
+
end
|
136
|
+
}
|
137
|
+
assert_equal(0, app.run)
|
138
|
+
assert(t_run)
|
139
|
+
end
|
115
140
|
end
|