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/test/test_rac.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rant/rantlib'
|
4
|
+
require 'tutil'
|
5
|
+
|
6
|
+
$testDir ||= File.expand_path(File.dirname(__FILE__))
|
7
|
+
|
8
|
+
class TestRac < Test::Unit::TestCase
|
9
|
+
def setup
|
10
|
+
# Ensure we run in test directory.
|
11
|
+
Dir.chdir($testDir) unless Dir.pwd == $testDir
|
12
|
+
end
|
13
|
+
def teardown
|
14
|
+
end
|
15
|
+
def test_parse_caller_elem_nil
|
16
|
+
assert_nothing_raised {
|
17
|
+
ch = Rant::Lib.parse_caller_elem(nil)
|
18
|
+
assert_equal("", ch[:file])
|
19
|
+
assert_equal(0, ch[:ln])
|
20
|
+
}
|
21
|
+
end
|
22
|
+
def test_parse_caller_elem_file_ln
|
23
|
+
assert_nothing_raised {
|
24
|
+
ch = Rant::Lib.parse_caller_elem("C:\\foo\\bar:32")
|
25
|
+
assert_equal("C:\\foo\\bar", ch[:file])
|
26
|
+
assert_equal(32, ch[:ln])
|
27
|
+
}
|
28
|
+
end
|
29
|
+
def test_parse_caller_elem_file_ln_meth
|
30
|
+
assert_nothing_raised {
|
31
|
+
ch = Rant::Lib.parse_caller_elem("C:\\foo abc\\bar de:32:in nix")
|
32
|
+
assert_equal("C:\\foo abc\\bar de", ch[:file])
|
33
|
+
assert_equal(32, ch[:ln])
|
34
|
+
}
|
35
|
+
end
|
36
|
+
def test_parse_caller_elem_eval
|
37
|
+
assert_nothing_raised {
|
38
|
+
ch = Rant::Lib.parse_caller_elem("-e:1")
|
39
|
+
assert_equal("-e", ch[:file])
|
40
|
+
assert_equal(1, ch[:ln])
|
41
|
+
}
|
42
|
+
end
|
43
|
+
def test_parse_caller_elem_file_with_colon_ln_meth
|
44
|
+
assert_nothing_raised {
|
45
|
+
ch = Rant::Lib.parse_caller_elem("abc:de:32:in nix")
|
46
|
+
assert_equal("abc:de", ch[:file])
|
47
|
+
assert_equal(32, ch[:ln])
|
48
|
+
}
|
49
|
+
end
|
50
|
+
def test_parse_caller_elem_no_line_number
|
51
|
+
assert_nothing_raised {
|
52
|
+
out, err = capture_std do
|
53
|
+
ch = Rant::Lib.parse_caller_elem("foo")
|
54
|
+
assert_equal("foo", ch[:file])
|
55
|
+
assert_equal(0, ch[:ln])
|
56
|
+
end
|
57
|
+
}
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,47 @@
|
|
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 TestRantfileAPI < Test::Unit::TestCase
|
10
|
+
def setup
|
11
|
+
# Ensure we run in test directory.
|
12
|
+
Dir.chdir($testDir) unless Dir.pwd == $testDir
|
13
|
+
@app = Rant::RantApp.new
|
14
|
+
end
|
15
|
+
def teardown
|
16
|
+
FileUtils.rm_rf Dir["*.t"]
|
17
|
+
end
|
18
|
+
def test_action
|
19
|
+
@app.args << "act_verbose=1"
|
20
|
+
out, err = capture_std do
|
21
|
+
assert_equal(0, @app.run)
|
22
|
+
end
|
23
|
+
assert_match(/running action/, out)
|
24
|
+
end
|
25
|
+
def test_action_query
|
26
|
+
@app.args << "act_verbose=1" << "--tasks"
|
27
|
+
out, err = capture_std do
|
28
|
+
assert_equal(0, @app.run)
|
29
|
+
end
|
30
|
+
assert(out !~ /running action/)
|
31
|
+
end
|
32
|
+
def test_rac_build
|
33
|
+
capture_std do
|
34
|
+
assert_equal(0, @app.run)
|
35
|
+
end
|
36
|
+
assert(test(?f, "version.t"))
|
37
|
+
old_mtime = File.mtime "version.t"
|
38
|
+
timeout
|
39
|
+
capture_std do
|
40
|
+
assert_equal(0, Rant::RantApp.new.run)
|
41
|
+
end
|
42
|
+
assert_equal(old_mtime, File.mtime("version.t"))
|
43
|
+
end
|
44
|
+
def test_rac_build_cd
|
45
|
+
assert_rant("tmp.t/Rantfile", "subdir_tmp", "build_test_t")
|
46
|
+
end
|
47
|
+
end
|
data/test/test_var.rb
CHANGED
@@ -99,4 +99,180 @@ class TestVar < Test::Unit::TestCase
|
|
99
99
|
assert_equal(0, Rant::RantApp.new(%w(-fvar.rf clean)).run)
|
100
100
|
end
|
101
101
|
end
|
102
|
+
def test_is_string
|
103
|
+
@rac.var :s, :String
|
104
|
+
assert_equal("", @rac.var["s"])
|
105
|
+
@rac.var[:s] = "abc"
|
106
|
+
assert_equal("abc", @rac.var["s"])
|
107
|
+
obj = Object.new
|
108
|
+
def obj.to_str
|
109
|
+
"obj"
|
110
|
+
end
|
111
|
+
assert_nothing_raised { @rac.var[:s] = obj }
|
112
|
+
assert_equal("obj", @rac.var[:s])
|
113
|
+
assert_raise(::Rant::RantVar::ConstraintError) {
|
114
|
+
@rac.var[:s] = 3
|
115
|
+
}
|
116
|
+
assert_equal("obj", @rac.var[:s])
|
117
|
+
end
|
118
|
+
def test_is_integer
|
119
|
+
@rac.var(:count => 10).is :Integer
|
120
|
+
assert_equal(10, @rac.var[:count])
|
121
|
+
assert_raise(::Rant::RantVar::ConstraintError) {
|
122
|
+
@rac.var[:count] = "no_integer"
|
123
|
+
}
|
124
|
+
assert_equal(10, @rac.var[:count])
|
125
|
+
end
|
126
|
+
def test_is_integer_in_range
|
127
|
+
@rac.var(:count => 10).is 0..20
|
128
|
+
assert_equal(10, @rac.var[:count])
|
129
|
+
assert_raise(::Rant::RantVar::ConstraintError) {
|
130
|
+
@rac.var[:count] = "no_integer"
|
131
|
+
}
|
132
|
+
assert_raise(::Rant::RantVar::ConstraintError) {
|
133
|
+
@rac.var[:count] = 21
|
134
|
+
}
|
135
|
+
assert_raise(::Rant::RantVar::ConstraintError) {
|
136
|
+
@rac.var[:count] = -1
|
137
|
+
}
|
138
|
+
assert_equal(10, @rac.var[:count])
|
139
|
+
@rac.var[:count] = "15"
|
140
|
+
assert_equal(15, @rac.var(:count))
|
141
|
+
end
|
142
|
+
def test_restrict
|
143
|
+
assert_equal(nil, @rac.var[:num])
|
144
|
+
@rac.var.restrict :num, :Float, -1.1..2.0
|
145
|
+
assert_equal(-1.1, @rac.var[:num])
|
146
|
+
@rac.var[:num] = "1.5"
|
147
|
+
assert_equal(1.5, @rac.var[:num])
|
148
|
+
assert_raise(::Rant::RantVar::ConstraintError) {
|
149
|
+
@rac.var[:num] = -1.2
|
150
|
+
}
|
151
|
+
assert_equal(1.5, @rac.var[:num])
|
152
|
+
end
|
153
|
+
def test_restrict_cmd
|
154
|
+
@rac.args.replace %w(-fvar.rf show_count)
|
155
|
+
out, err = capture_std { @rac.run }
|
156
|
+
assert_match(/count 1/, out)
|
157
|
+
end
|
158
|
+
def test_restrict_cmd_change
|
159
|
+
@rac.args.replace %w(-fvar.rf count=5 show_count)
|
160
|
+
out, err = capture_std { @rac.run }
|
161
|
+
assert_match(/count 5/, out)
|
162
|
+
end
|
163
|
+
def test_restrict_cmd_error
|
164
|
+
@rac.args.replace %w(-fvar.rf count=0 show_count)
|
165
|
+
out, err = capture_std {
|
166
|
+
assert_equal(1, @rac.run)
|
167
|
+
}
|
168
|
+
assert_match(/[ERROR]/, err)
|
169
|
+
end
|
170
|
+
def test_float_range_cmd
|
171
|
+
@rac.args.replace %w(-fvar.rf num=5.0 show_num)
|
172
|
+
out, err = capture_std do
|
173
|
+
assert_equal(0, @rac.run)
|
174
|
+
end
|
175
|
+
assert_match(/num 5.0/, out)
|
176
|
+
end
|
177
|
+
def test_float_range_cmd_invalid
|
178
|
+
@rac.args.replace %w(-fvar.rf num=0.0 show_num)
|
179
|
+
out, err = capture_std do
|
180
|
+
assert_equal(1, @rac.run)
|
181
|
+
end
|
182
|
+
assert_match(/[ERROR]/, err)
|
183
|
+
end
|
184
|
+
def test_float_range_default
|
185
|
+
@rac.args.replace %w(-fvar.rf show_num)
|
186
|
+
out, err = capture_std do
|
187
|
+
assert_equal(0, @rac.run)
|
188
|
+
end
|
189
|
+
assert_match(/num 1.1/, out)
|
190
|
+
end
|
191
|
+
def test_env_to_string
|
192
|
+
@rac.var "RT_TO_S", :ToString
|
193
|
+
@rac.var.env "RT_TO_S"
|
194
|
+
if Rant::Env.on_windows?
|
195
|
+
# very odd on windows: when setting ENV["ABC"]="" you'll
|
196
|
+
# get out ENV["ABC"] == nil
|
197
|
+
assert(ENV["RT_TO_S"] == "" || ENV["RT_TO_S"] == nil)
|
198
|
+
assert(@rac.var["RT_TO_S"] == "" || @rac.var["RT_TO_S"] == nil)
|
199
|
+
else
|
200
|
+
assert_equal(ENV["RT_TO_S"], "")
|
201
|
+
assert_equal(@rac.var["RT_TO_S"], "")
|
202
|
+
end
|
203
|
+
assert_nothing_raised {
|
204
|
+
@rac.var[:RT_TO_S] = "abc"
|
205
|
+
assert_equal("abc", ENV["RT_TO_S"])
|
206
|
+
obj = Object.new
|
207
|
+
def obj.to_s; "obj"; end
|
208
|
+
@rac.var[:RT_TO_S] = obj
|
209
|
+
assert_equal("obj", ENV["RT_TO_S"])
|
210
|
+
}
|
211
|
+
end
|
212
|
+
def test_bool
|
213
|
+
@rac.var "true?", :Bool
|
214
|
+
assert_equal(false, @rac.var[:true?])
|
215
|
+
assert_nothing_raised {
|
216
|
+
@rac.var[:true?] = true
|
217
|
+
assert_equal(true, @rac.var[:true?])
|
218
|
+
@rac.var[:true?] = false
|
219
|
+
assert_equal(false, @rac.var[:true?])
|
220
|
+
@rac.var[:true?] = 1
|
221
|
+
assert_equal(true, @rac.var[:true?])
|
222
|
+
@rac.var[:true?] = 0
|
223
|
+
assert_equal(false, @rac.var[:true?])
|
224
|
+
@rac.var[:true?] = :on
|
225
|
+
assert_equal(true, @rac.var[:true?])
|
226
|
+
@rac.var[:true?] = :off
|
227
|
+
assert_equal(false, @rac.var[:true?])
|
228
|
+
@rac.var[:true?] = "yes"
|
229
|
+
assert_equal(true, @rac.var[:true?])
|
230
|
+
@rac.var[:true?] = "no"
|
231
|
+
assert_equal(false, @rac.var[:true?])
|
232
|
+
@rac.var[:true?] = "true"
|
233
|
+
assert_equal(true, @rac.var[:true?])
|
234
|
+
@rac.var[:true?] = "false"
|
235
|
+
assert_equal(false, @rac.var[:true?])
|
236
|
+
@rac.var[:true?] = "y"
|
237
|
+
assert_equal(true, @rac.var[:true?])
|
238
|
+
@rac.var[:true?] = "n"
|
239
|
+
assert_equal(false, @rac.var[:true?])
|
240
|
+
@rac.var[:true?] = nil
|
241
|
+
assert_equal(false, @rac.var[:true?])
|
242
|
+
}
|
243
|
+
assert_raise(::Rant::RantVar::ConstraintError) {
|
244
|
+
@rac.var[:true?] = "abc"
|
245
|
+
}
|
246
|
+
assert_equal(false, @rac.var[:true?])
|
247
|
+
end
|
248
|
+
def test_bool_shortcut_true
|
249
|
+
@rac.var :bs, true
|
250
|
+
assert_equal(true, @rac.var[:bs])
|
251
|
+
@rac.var[:bs] = false
|
252
|
+
assert_equal(false, @rac.var[:bs])
|
253
|
+
assert_raise(::Rant::RantVar::ConstraintError) {
|
254
|
+
@rac.var[:bs] = "abc"
|
255
|
+
}
|
256
|
+
assert_equal(false, @rac.var[:bs])
|
257
|
+
end
|
258
|
+
def test_bool_shortcut_false
|
259
|
+
@rac.var :bs, false
|
260
|
+
assert_equal(false, @rac.var[:bs])
|
261
|
+
@rac.var[:bs] = "1"
|
262
|
+
assert_equal(true, @rac.var[:bs])
|
263
|
+
assert_raise(::Rant::RantVar::ConstraintError) {
|
264
|
+
@rac.var[:bs] = "abc"
|
265
|
+
}
|
266
|
+
assert_equal(true, @rac.var[:bs])
|
267
|
+
end
|
268
|
+
def test_violation_message
|
269
|
+
@rac.args.replace %w(-fvar.rf source_err)
|
270
|
+
out, err = capture_std do
|
271
|
+
assert_equal(1, @rac.run)
|
272
|
+
end
|
273
|
+
assert_match(
|
274
|
+
/source_err\.rf\.t.+2.*\n.*11.+constraint.+integer/i, err)
|
275
|
+
ensure
|
276
|
+
assert_equal(0, Rant::RantApp.new("-fvar.rf", "clean", "-q").run)
|
277
|
+
end
|
102
278
|
end
|
data/test/tutil.rb
CHANGED
@@ -1,8 +1,20 @@
|
|
1
1
|
|
2
2
|
# This file contains methods that aid in testing Rant.
|
3
3
|
|
4
|
-
require 'rant/
|
5
|
-
require '
|
4
|
+
require 'rant/rantlib'
|
5
|
+
require 'fileutils'
|
6
|
+
|
7
|
+
module Test
|
8
|
+
module Unit
|
9
|
+
class TestCase
|
10
|
+
def assert_rant(*args)
|
11
|
+
capture_std do
|
12
|
+
assert_equal(0, ::Rant::RantApp.new(*args).run)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
6
18
|
|
7
19
|
RANT_BIN = File.expand_path(
|
8
20
|
File.join(File.dirname(__FILE__), "..", "run_rant"))
|
@@ -118,3 +130,7 @@ end
|
|
118
130
|
def run_import(*args)
|
119
131
|
`#{Rant::Sys.sp(Rant::Env::RUBY)} #{Rant::Sys.sp(RANT_IMPORT_BIN)} #{args.flatten.arglist}`
|
120
132
|
end
|
133
|
+
|
134
|
+
def run_ruby(*args)
|
135
|
+
`#{Rant::Sys.sp(Rant::Env::RUBY)} #{args.flatten.arglist}`
|
136
|
+
end
|
data/test/var.rf
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
|
2
2
|
var "v1" => "default_1.t"
|
3
3
|
var["v2"] = "default_2.t"
|
4
|
+
var.restrict :count, :Integer, 1..10
|
5
|
+
var :num, 1.1 .. 11.11
|
4
6
|
|
5
7
|
task :default => [var[:v1], var[:v2]]
|
6
8
|
|
@@ -12,6 +14,27 @@ file var[:v2] do |t|
|
|
12
14
|
sys.touch t.name
|
13
15
|
end
|
14
16
|
|
17
|
+
task :show_count do |t|
|
18
|
+
puts "count #{var :count}"
|
19
|
+
end
|
20
|
+
|
21
|
+
task :show_num do
|
22
|
+
puts "num #{var :num}"
|
23
|
+
end
|
24
|
+
|
25
|
+
task :source_err do
|
26
|
+
source "source_err.rf.t"
|
27
|
+
end
|
28
|
+
|
29
|
+
file "source_err.rf.t" do |t|
|
30
|
+
open(t.name, "w") { |f|
|
31
|
+
f << <<-EOF
|
32
|
+
|
33
|
+
var[:count] = 11
|
34
|
+
EOF
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
15
38
|
task :clean do
|
16
39
|
sys.rm_f sys["*.t"]
|
17
40
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.10
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rant
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.3.
|
7
|
-
date: 2005-
|
6
|
+
version: 0.3.6
|
7
|
+
date: 2005-05-02
|
8
8
|
summary: Rant is a Ruby based build tool.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -54,14 +54,20 @@ files:
|
|
54
54
|
- lib/rant/plugin_methods.rb
|
55
55
|
- lib/rant/plugin
|
56
56
|
- lib/rant/import.rb
|
57
|
+
- lib/rant/import/directedrule.rb
|
58
|
+
- lib/rant/import/truth.rb
|
57
59
|
- lib/rant/import/rubydoc.rb
|
58
60
|
- lib/rant/import/rubytest.rb
|
59
61
|
- lib/rant/import/rubypackage.rb
|
62
|
+
- lib/rant/import/package.rb
|
63
|
+
- lib/rant/import/clean.rb
|
64
|
+
- lib/rant/import/autoclean.rb
|
60
65
|
- lib/rant/plugin/README
|
61
66
|
- lib/rant/plugin/configure.rb
|
62
67
|
- lib/rant/plugin/csharp.rb
|
63
68
|
- test/test_filetask.rb
|
64
69
|
- test/test_lighttask.rb
|
70
|
+
- test/test_examples.rb
|
65
71
|
- test/Rantfile
|
66
72
|
- test/ts_all.rb
|
67
73
|
- test/test_rule.rb
|
@@ -70,10 +76,13 @@ files:
|
|
70
76
|
- test/rule.rf
|
71
77
|
- test/subdirs
|
72
78
|
- test/test_metatask.rb
|
79
|
+
- test/test_rantfile_api.rb
|
73
80
|
- test/test_env.rb
|
74
81
|
- test/toplevel.rf
|
75
82
|
- test/test_source.rb
|
83
|
+
- test/import
|
76
84
|
- test/plugin
|
85
|
+
- test/test_rac.rb
|
77
86
|
- test/test_rant_interface.rb
|
78
87
|
- test/test_sys.rb
|
79
88
|
- test/test_var.rb
|
@@ -82,6 +91,8 @@ files:
|
|
82
91
|
- test/test_dirtask.rb
|
83
92
|
- test/project1
|
84
93
|
- test/project2
|
94
|
+
- test/rant-import
|
95
|
+
- test/test_clean.rb
|
85
96
|
- test/test_filelist.rb
|
86
97
|
- test/standalone.rf
|
87
98
|
- test/project_rb1/bin
|
@@ -102,6 +113,12 @@ files:
|
|
102
113
|
- test/subdirs/sub2/sub
|
103
114
|
- test/subdirs/sub2/rantfile.rb
|
104
115
|
- test/subdirs/sub2/sub/rantfile
|
116
|
+
- test/import/truth
|
117
|
+
- test/import/directedrule
|
118
|
+
- test/import/truth/Rantfile
|
119
|
+
- test/import/truth/test_truth.rb
|
120
|
+
- test/import/directedrule/Rantfile
|
121
|
+
- test/import/directedrule/test_directedrule.rb
|
105
122
|
- test/plugin/configure
|
106
123
|
- test/plugin/csharp
|
107
124
|
- test/plugin/rantfile
|
@@ -122,15 +139,25 @@ files:
|
|
122
139
|
- test/project2/buildfile
|
123
140
|
- test/project2/test_project.rb
|
124
141
|
- test/project2/sub1/Rantfile
|
142
|
+
- test/rant-import/Rantfile
|
143
|
+
- test/rant-import/test_rant-import.rb
|
125
144
|
- doc/rantfile.rdoc
|
126
145
|
- doc/configure.rdoc
|
127
146
|
- doc/advanced.rdoc
|
128
147
|
- doc/rubyproject.rdoc
|
129
148
|
- doc/rant.rdoc
|
149
|
+
- doc/jamis.rb
|
130
150
|
- doc/csharp.rdoc
|
131
151
|
- doc/rant-import.rdoc
|
132
152
|
- doc/examples
|
153
|
+
- doc/examples/directedrule
|
133
154
|
- doc/examples/myprog
|
155
|
+
- doc/examples/directedrule/src_a
|
156
|
+
- doc/examples/directedrule/src_b
|
157
|
+
- doc/examples/directedrule/Rantfile
|
158
|
+
- doc/examples/directedrule/src_a/a_1.c
|
159
|
+
- doc/examples/directedrule/src_a/a_2.c
|
160
|
+
- doc/examples/directedrule/src_b/b_1.c
|
134
161
|
- doc/examples/myprog/src
|
135
162
|
- doc/examples/myprog/README
|
136
163
|
- doc/examples/myprog/Rantfile
|