rant 0.5.2 → 0.5.4
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 +16 -0
- data/README +1 -1
- data/Rantfile +17 -0
- data/doc/sys.rdoc +16 -0
- data/lib/rant/coregen.rb +14 -12
- data/lib/rant/import/rubypackage.rb +7 -2
- data/lib/rant/import/sys/more.rb +7 -0
- data/lib/rant/init.rb +1 -1
- data/lib/rant/rantlib.rb +6 -0
- data/lib/rant/rantvar.rb +2 -65
- data/test/subdirs2/root.rant +8 -0
- data/test/subdirs2/sub1/sub.rant +2 -0
- data/test/subdirs2/test_subdirs2.rb +10 -0
- data/test/test_sys_methods.rb +18 -0
- data/test/test_var.rb +12 -1
- data/test/var.rf +2 -0
- metadata +2 -3
- data/test/deprecated/test_0_5_4.rb +0 -53
data/NEWS
CHANGED
@@ -1,6 +1,22 @@
|
|
1
1
|
|
2
2
|
= Rant NEWS
|
3
3
|
|
4
|
+
== Rant 0.5.4
|
5
|
+
|
6
|
+
Incompatible changes:
|
7
|
+
* The undocumented method <tt>var.is</tt> which is deprecated since
|
8
|
+
release 0.5.2 is not defined anymore.
|
9
|
+
|
10
|
+
Fixes and minor improvements:
|
11
|
+
* Fix a rule bug where a custom rule task wouldn't find it's
|
12
|
+
prerequisites in subdirectories.
|
13
|
+
* An non-backwards compatible change in the YAML library of Ruby 1.8.3
|
14
|
+
and newer causes gems to be non-backwards compatible. The fix for
|
15
|
+
backwards compatibility of gems created with RubyPackage is enabled
|
16
|
+
for all newer Ruby versions now. (See changes of last Rant release.)
|
17
|
+
* The new method <tt>sys.write_to_binfile</tt>. (Kevin Burge's idea.)
|
18
|
+
Read doc/sys.rdoc[link:files/doc/sys_rdoc.html] for documentation.
|
19
|
+
|
4
20
|
== Rant 0.5.2
|
5
21
|
|
6
22
|
Incompatible changes:
|
data/README
CHANGED
@@ -42,7 +42,7 @@ Running rant in the directory of this file:
|
|
42
42
|
will ensure that the "data" file in the "backup" directory is up to
|
43
43
|
date.
|
44
44
|
|
45
|
-
This document was written for version 0.5.
|
45
|
+
This document was written for version 0.5.4 of Rant. Most things
|
46
46
|
described here will work for older/newer versions of Rant, but look at
|
47
47
|
the README file in the Rant distribution you've installed for exact
|
48
48
|
documentation of your Rant version.
|
data/Rantfile
CHANGED
@@ -41,6 +41,10 @@ gen RubyPackage, "rant#{var :pkg_ext}" do |t|
|
|
41
41
|
t.package_task
|
42
42
|
end
|
43
43
|
|
44
|
+
task "dev-pkg" do
|
45
|
+
make Package::Tgz, "pkg/rant-dev", :files => dist_files
|
46
|
+
end
|
47
|
+
|
44
48
|
task "dist-files" do
|
45
49
|
puts dist_files
|
46
50
|
end
|
@@ -291,4 +295,17 @@ def count_rb_lines(fn)
|
|
291
295
|
[lines, code_lines]
|
292
296
|
end
|
293
297
|
|
298
|
+
@prefix = var[:prefix] || "/usr/local"
|
299
|
+
|
300
|
+
task "uninstall" do
|
301
|
+
print <<-EOF
|
302
|
+
Run task _uninstall_ to uninstall Rant from prefix[#@prefix].
|
303
|
+
EOF
|
304
|
+
end
|
305
|
+
|
306
|
+
task "_uninstall_" do
|
307
|
+
sys.rm_rf FileList["#@prefix/lib/ruby/site_ruby/1.8/rant*"]
|
308
|
+
sys.rm_f FileList["#@prefix/bin/rant*"]
|
309
|
+
end
|
310
|
+
|
294
311
|
# vim:ft=ruby
|
data/doc/sys.rdoc
CHANGED
@@ -400,6 +400,22 @@ The following methods print messages to standard output:
|
|
400
400
|
|
401
401
|
sys.write_to_file "version", "1.2.0\n" # => prints "writing 6 bytes to file `version'"
|
402
402
|
|
403
|
+
* <b>write_to_binfile(fn, data)</b>
|
404
|
+
|
405
|
+
Requires <tt>import "sys/more"</tt>
|
406
|
+
|
407
|
+
Like <tt>write_to_file(fn, data)</tt> but opens the file in binary
|
408
|
+
mode.
|
409
|
+
|
410
|
+
Example:
|
411
|
+
|
412
|
+
import "sys/more"
|
413
|
+
|
414
|
+
require "digest/md5"
|
415
|
+
data = Digest::MD5.digest("some_string")
|
416
|
+
|
417
|
+
sys.write_to_binfile "hash", data # => prints "writing 16 bytes to file `hash'"
|
418
|
+
|
403
419
|
* <b>unpack_tgz(fn, options = {})</b>
|
404
420
|
|
405
421
|
Requires <tt>import "sys/tgz"</tt>
|
data/lib/rant/coregen.rb
CHANGED
@@ -179,9 +179,11 @@ module Rant
|
|
179
179
|
have_src = true
|
180
180
|
src = @src_proc[target]
|
181
181
|
if src.respond_to? :to_ary
|
182
|
-
have_src = src.to_ary.all? { |s|
|
182
|
+
have_src = src.to_ary.all? { |s|
|
183
|
+
have_src?(rel_project_dir, s)
|
184
|
+
}
|
183
185
|
else
|
184
|
-
have_src = have_src?(src)
|
186
|
+
have_src = have_src?(rel_project_dir, src)
|
185
187
|
end
|
186
188
|
if have_src
|
187
189
|
create_nodes(rel_project_dir, target, src)
|
@@ -190,33 +192,33 @@ module Rant
|
|
190
192
|
end
|
191
193
|
alias [] call
|
192
194
|
private
|
193
|
-
def have_src?(name)
|
194
|
-
|
195
|
-
|
195
|
+
def have_src?(rel_project_dir, name)
|
196
|
+
return true unless
|
197
|
+
@rant.rec_save_resolve(name, self, rel_project_dir).empty?
|
198
|
+
test(?e, @rant.abs_path(rel_project_dir, name))
|
196
199
|
end
|
197
200
|
def create_nodes(rel_project_dir, target, deps)
|
201
|
+
@rant.goto_project_dir rel_project_dir
|
198
202
|
case nodes = @block[target, deps]
|
199
203
|
when Array: nodes
|
200
204
|
when Node: [nodes]
|
201
205
|
else
|
202
206
|
@rant.abort_at(@ch, "Block has to " +
|
203
207
|
"return Node or array of Nodes.")
|
204
|
-
end
|
205
|
-
node.project_subdir = @rant.current_subdir
|
206
|
-
}
|
208
|
+
end
|
207
209
|
end
|
208
210
|
end
|
209
211
|
class FileHook < Hook
|
210
212
|
private
|
211
|
-
def have_src?(name)
|
212
|
-
test(?e, name) or
|
213
|
-
@rant.rec_save_resolve(name, self
|
213
|
+
def have_src?(rel_project_dir, name)
|
214
|
+
test(?e, @rant.abs_path(rel_project_dir, name)) or
|
215
|
+
@rant.rec_save_resolve(name, self, rel_project_dir
|
214
216
|
).any? { |t| t.file_target? }
|
215
217
|
end
|
216
218
|
def create_nodes(rel_project_dir, target, deps)
|
219
|
+
@rant.goto_project_dir rel_project_dir
|
217
220
|
t = @rant.file(:__caller__ => @ch,
|
218
221
|
target => deps, &@block)
|
219
|
-
t.project_subdir = @rant.current_subdir
|
220
222
|
[t]
|
221
223
|
end
|
222
224
|
end
|
@@ -246,8 +246,13 @@ class Rant::Generators::RubyPackage
|
|
246
246
|
end
|
247
247
|
|
248
248
|
# fix for YAML bug in Ruby 1.8.3 and 1.8.4 previews
|
249
|
-
|
250
|
-
|
249
|
+
#
|
250
|
+
# Update: That's not a bug in YAML 1.8.3 and later, it's a
|
251
|
+
# non-backwards compatible change, because YAML 1.8.2 and
|
252
|
+
# later is buggy. (My current understanding of this
|
253
|
+
# issue.) Adding the "---" at the start ensures that it
|
254
|
+
# can be read with all Ruby YAML versions.
|
255
|
+
if RUBY_VERSION > "1.8.2"
|
251
256
|
def spec.to_yaml(*args, &block)
|
252
257
|
yaml = super
|
253
258
|
yaml =~ /^---/ ? yaml : "--- #{yaml}"
|
data/lib/rant/import/sys/more.rb
CHANGED
@@ -12,6 +12,13 @@ module Rant
|
|
12
12
|
f.write content
|
13
13
|
end
|
14
14
|
end
|
15
|
+
def write_to_binfile(fn, content)
|
16
|
+
content = content.to_str
|
17
|
+
fu_output_message "writing #{content.size} bytes to file `#{fn}'"
|
18
|
+
File.open fn, "wb" do |f|
|
19
|
+
f.write content
|
20
|
+
end
|
21
|
+
end
|
15
22
|
def clean(entry)
|
16
23
|
if test ?f, entry
|
17
24
|
rm_f entry
|
data/lib/rant/init.rb
CHANGED
data/lib/rant/rantlib.rb
CHANGED
@@ -451,6 +451,12 @@ class Rant::RantApp
|
|
451
451
|
sub = expand_path(@current_subdir, path)
|
452
452
|
sub.empty? ? @rootdir : File.join(@rootdir, sub)
|
453
453
|
end
|
454
|
+
def abs_path(subdir, fn)
|
455
|
+
path = File.join(@rootdir, subdir, fn)
|
456
|
+
path.gsub!(%r{/+}, "/")
|
457
|
+
path.sub!(%r{/$}, "") if path.length > 1
|
458
|
+
path
|
459
|
+
end
|
454
460
|
def goto(dir)
|
455
461
|
goto_project_dir(expand_path(@current_subdir, dir))
|
456
462
|
end
|
data/lib/rant/rantvar.rb
CHANGED
@@ -110,7 +110,6 @@ module Rant
|
|
110
110
|
# holds constraints for values in @store
|
111
111
|
@constraints = {}
|
112
112
|
# set by default query
|
113
|
-
@current_var = nil # this line will go in 0.5.4
|
114
113
|
end
|
115
114
|
|
116
115
|
def query(*args, &block)
|
@@ -123,7 +122,6 @@ module Rant
|
|
123
122
|
if Hash === arg
|
124
123
|
if arg.size == 1
|
125
124
|
arg.each { |k,v|
|
126
|
-
@current_var = k # this line will go in 0.5.4
|
127
125
|
self[k] = v if self[k].nil?
|
128
126
|
}
|
129
127
|
self
|
@@ -135,7 +133,6 @@ module Rant
|
|
135
133
|
end
|
136
134
|
when 2, 3
|
137
135
|
vid, cf, val = *args
|
138
|
-
@current_var = vid # this line will go in 0.5.4
|
139
136
|
constrain vid,
|
140
137
|
get_factory(cf).rant_constraint
|
141
138
|
self[vid] = val if val
|
@@ -144,15 +141,6 @@ module Rant
|
|
144
141
|
end
|
145
142
|
end
|
146
143
|
|
147
|
-
def is ct, *ct_args
|
148
|
-
warn caller[0]
|
149
|
-
warn "method `var.is' is deprecated and will not be " +
|
150
|
-
"in Rant 0.5.4 and later"
|
151
|
-
constrain @current_var,
|
152
|
-
get_factory(ct).rant_constraint(*ct_args)
|
153
|
-
self
|
154
|
-
end
|
155
|
-
|
156
144
|
def restrict vid, ct, *ct_args
|
157
145
|
if vid.respond_to? :to_ary
|
158
146
|
vid.to_ary.each { |v| restrict(v, ct, *ct_args) }
|
@@ -165,54 +153,10 @@ module Rant
|
|
165
153
|
|
166
154
|
def get_factory id
|
167
155
|
if String === id || Symbol === id
|
168
|
-
|
169
|
-
### temporary solution ###
|
170
|
-
raise unless Constraints.const_defined? id
|
171
|
-
##########################
|
172
|
-
id = Constraints.const_get(id)
|
173
|
-
rescue
|
174
|
-
### temporary solution ###
|
175
|
-
id_sym = id.to_sym
|
176
|
-
rl =
|
177
|
-
if [:Integer, :IntegerInRange, :Float,
|
178
|
-
:FloatInRange].include? id_sym
|
179
|
-
'rant/import/var/numbers'
|
180
|
-
elsif [:Bool, :BoolTrue].include? id_sym
|
181
|
-
'rant/import/var/booleans'
|
182
|
-
elsif :List == id_sym
|
183
|
-
'rant/import/var/lists'
|
184
|
-
elsif [:String, :ToString].include? id_sym
|
185
|
-
'rant/import/var/strings'
|
186
|
-
else
|
187
|
-
##########################
|
188
|
-
raise NotAConstraintFactoryError.new(id), caller
|
189
|
-
end
|
190
|
-
warn "Explicitely <code>import " +
|
191
|
-
"'#{rl.sub(/^rant\/import\//, '')}'" +
|
192
|
-
"</code> to use the #{id_sym.inspect} " +
|
193
|
-
"constraint."
|
194
|
-
require rl #rant-import:remove
|
195
|
-
retry
|
196
|
-
end
|
156
|
+
id = Constraints.const_get(id) rescue nil
|
197
157
|
end
|
198
158
|
unless id.respond_to? :rant_constraint
|
199
|
-
|
200
|
-
rl =
|
201
|
-
if id == true || id == false
|
202
|
-
'rant/import/var/booleans'
|
203
|
-
elsif id == String
|
204
|
-
'rant/import/var/strings'
|
205
|
-
elsif id.kind_of? Range
|
206
|
-
'rant/import/var/numbers'
|
207
|
-
else
|
208
|
-
##########################
|
209
|
-
raise NotAConstraintFactoryError.new(id), caller
|
210
|
-
end
|
211
|
-
warn "Explicitely <code>import " +
|
212
|
-
"'#{rl.sub(/^rant\/import\//, '')}'" +
|
213
|
-
"</code> to use the #{id.inspect} " +
|
214
|
-
"constraint."
|
215
|
-
require rl #rant-import:remove
|
159
|
+
raise NotAConstraintFactoryError.new(id), caller
|
216
160
|
end
|
217
161
|
id
|
218
162
|
end
|
@@ -372,10 +316,3 @@ module Rant
|
|
372
316
|
end # module Constraints
|
373
317
|
end # module RantVar
|
374
318
|
end # module Rant
|
375
|
-
|
376
|
-
### temporary solution ###
|
377
|
-
#require 'rant/import/var/numbers' #rant-import:uncomment
|
378
|
-
#require 'rant/import/var/booleans' #rant-import:uncomment
|
379
|
-
#require 'rant/import/var/lists' #rant-import:uncomment
|
380
|
-
#require 'rant/import/var/strings' #rant-import:uncomment
|
381
|
-
##########################
|
data/test/subdirs2/root.rant
CHANGED
@@ -30,6 +30,14 @@ end
|
|
30
30
|
|
31
31
|
gen Command, "c1.t", ["sub1/c1.t"], "$[sh_puts] ${<} > $(>)"
|
32
32
|
|
33
|
+
gen Rule, ".r.t" => ".s.t" do |target, sources|
|
34
|
+
gen Command, target, sources, "$[sh_cat] $(<) > $(>)"
|
35
|
+
end
|
36
|
+
|
37
|
+
gen Action, /\.s\.t$/ do
|
38
|
+
puts ".s.t action"
|
39
|
+
end
|
40
|
+
|
33
41
|
gen SubFile, "t/t", "a.t" => "b.t" do |t|
|
34
42
|
write(t.name, "abc")
|
35
43
|
end
|
data/test/subdirs2/sub1/sub.rant
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
|
2
2
|
require 'test/unit'
|
3
3
|
require 'tutil'
|
4
|
+
require 'rant/import/sys/more'
|
4
5
|
|
5
6
|
$test_subdirs2_dir ||= File.expand_path(File.dirname(__FILE__))
|
6
7
|
|
@@ -255,4 +256,13 @@ EOF
|
|
255
256
|
assert err.empty?
|
256
257
|
assert out.split(/\n/).size < 2
|
257
258
|
end
|
259
|
+
def test_custom_rule_task
|
260
|
+
Rant::Sys.write_to_file "sub1/a.s.t", "foo\n"
|
261
|
+
out, err = assert_rant "sub1/c3.t"
|
262
|
+
assert err.empty?
|
263
|
+
assert_match(/\.s\.t action/, out)
|
264
|
+
assert_file_content "sub1/c3.t", "foo\n"
|
265
|
+
ensure
|
266
|
+
Rant::Sys.rm_f ["sub1/a.s.t"]
|
267
|
+
end
|
258
268
|
end
|
data/test/test_sys_methods.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
require 'test/unit'
|
3
3
|
require 'tutil'
|
4
4
|
require 'rant/import/sys/more'
|
5
|
+
require 'rant/import/filelist/std'
|
5
6
|
|
6
7
|
$testDir ||= File.expand_path(File.dirname(__FILE__))
|
7
8
|
|
@@ -555,6 +556,23 @@ class TestSysMethods < Test::Unit::TestCase
|
|
555
556
|
end
|
556
557
|
assert_file_content "a.t", "hello\n"
|
557
558
|
end
|
559
|
+
def test_write_to_binfile
|
560
|
+
@cx.import "sys/more"
|
561
|
+
capture_std do
|
562
|
+
# TODO: specialize exception class
|
563
|
+
assert_raise_kind_of(StandardError) do
|
564
|
+
@sys.write_to_binfile "a.t", Object.new
|
565
|
+
end
|
566
|
+
end
|
567
|
+
assert !test(?e, "a.t")
|
568
|
+
out, err = capture_std do
|
569
|
+
@sys.write_to_binfile "a.t", "hello\nsepp"
|
570
|
+
end
|
571
|
+
assert test(?f, "a.t")
|
572
|
+
File.open("a.t", "rb") do |f|
|
573
|
+
assert_equal "hello\nsepp", f.read
|
574
|
+
end
|
575
|
+
end
|
558
576
|
def test_regular_filename
|
559
577
|
if Rant::Env.on_windows?
|
560
578
|
assert_equal "a/b", Rant::Sys.regular_filename('a\b')
|
data/test/test_var.rb
CHANGED
@@ -18,6 +18,7 @@ class TestVar < Test::Unit::TestCase
|
|
18
18
|
def teardown
|
19
19
|
end
|
20
20
|
def test_space
|
21
|
+
require "rant/import/var/numbers"
|
21
22
|
s = nil
|
22
23
|
assert_nothing_raised {
|
23
24
|
s = RS.new
|
@@ -41,6 +42,7 @@ class TestVar < Test::Unit::TestCase
|
|
41
42
|
assert_equal(%w(CVS), @cx.var["ignore"])
|
42
43
|
end
|
43
44
|
def test_invalid_for_constraint
|
45
|
+
@cx.import "var/numbers"
|
44
46
|
@cx.var :a, :Integer
|
45
47
|
assert_equal(0, @cx.var[:a])
|
46
48
|
assert_raises(Rant::RantVar::ConstraintError) {
|
@@ -100,6 +102,7 @@ class TestVar < Test::Unit::TestCase
|
|
100
102
|
end
|
101
103
|
end
|
102
104
|
def test_is_string
|
105
|
+
@cx.import "var/strings"
|
103
106
|
@rac.var :s, :String
|
104
107
|
assert_equal("", @rac.var["s"])
|
105
108
|
@rac.var[:s] = "abc"
|
@@ -115,7 +118,9 @@ class TestVar < Test::Unit::TestCase
|
|
115
118
|
}
|
116
119
|
assert_equal("obj", @rac.var[:s])
|
117
120
|
end
|
121
|
+
=begin
|
118
122
|
def test_is_integer
|
123
|
+
@cx.import "var/numbers"
|
119
124
|
@rac.var(:count => 10).is :Integer
|
120
125
|
assert_equal(10, @rac.var[:count])
|
121
126
|
assert_raise(::Rant::RantVar::ConstraintError) {
|
@@ -139,7 +144,9 @@ class TestVar < Test::Unit::TestCase
|
|
139
144
|
@rac.var[:count] = "15"
|
140
145
|
assert_equal(15, @rac.var(:count))
|
141
146
|
end
|
147
|
+
=end
|
142
148
|
def test_restrict
|
149
|
+
@cx.import "var/numbers"
|
143
150
|
assert_equal(nil, @rac.var[:num])
|
144
151
|
@rac.var.restrict :num, :Float, -1.1..2.0
|
145
152
|
assert_equal(-1.1, @rac.var[:num])
|
@@ -189,6 +196,7 @@ class TestVar < Test::Unit::TestCase
|
|
189
196
|
assert_match(/num 1.1/, out)
|
190
197
|
end
|
191
198
|
def test_env_to_string
|
199
|
+
@cx.import "var/strings"
|
192
200
|
@rac.var "RT_TO_S", :ToString
|
193
201
|
@rac.var.env "RT_TO_S"
|
194
202
|
if Rant::Env.on_windows?
|
@@ -210,6 +218,7 @@ class TestVar < Test::Unit::TestCase
|
|
210
218
|
}
|
211
219
|
end
|
212
220
|
def test_bool
|
221
|
+
@cx.import "var/booleans"
|
213
222
|
@rac.var "true?", :Bool
|
214
223
|
assert_equal(false, @rac.var[:true?])
|
215
224
|
assert_nothing_raised {
|
@@ -246,6 +255,7 @@ class TestVar < Test::Unit::TestCase
|
|
246
255
|
assert_equal(false, @rac.var[:true?])
|
247
256
|
end
|
248
257
|
def test_bool_shortcut_true
|
258
|
+
@cx.import "var/booleans"
|
249
259
|
@rac.var :bs, true
|
250
260
|
assert_equal(true, @rac.var[:bs])
|
251
261
|
@rac.var[:bs] = false
|
@@ -256,6 +266,7 @@ class TestVar < Test::Unit::TestCase
|
|
256
266
|
assert_equal(false, @rac.var[:bs])
|
257
267
|
end
|
258
268
|
def test_bool_shortcut_false
|
269
|
+
@cx.import "var/booleans"
|
259
270
|
@rac.var :bs, false
|
260
271
|
assert_equal(false, @rac.var[:bs])
|
261
272
|
@rac.var[:bs] = "1"
|
@@ -277,7 +288,7 @@ class TestVar < Test::Unit::TestCase
|
|
277
288
|
end
|
278
289
|
def test_rant_import
|
279
290
|
@rac.args.replace %w(-fvar.rf show_num)
|
280
|
-
run_import "-q", "ant.t"
|
291
|
+
run_import "-q", "-ivar/numbers", "ant.t"
|
281
292
|
assert_exit
|
282
293
|
out = run_ruby("ant.t", "-fvar.rf", "show_num")
|
283
294
|
assert_exit
|
data/test/var.rf
CHANGED
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rant
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.5.
|
7
|
-
date: 2005-12-
|
6
|
+
version: 0.5.4
|
7
|
+
date: 2005-12-18 00:00:00 +01:00
|
8
8
|
summary: Rant is a Ruby based build tool.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -286,7 +286,6 @@ files:
|
|
286
286
|
- test/subdirs2/sub1/sub.rant
|
287
287
|
- test/subdirs2/sub00/sub.rant
|
288
288
|
- test/deprecated/README
|
289
|
-
- test/deprecated/test_0_5_4.rb
|
290
289
|
- test/deprecated/test_0_6_0.rb
|
291
290
|
- doc/rantfile.rdoc
|
292
291
|
- doc/md5.rdoc
|
@@ -1,53 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'test/unit'
|
3
|
-
require 'tutil'
|
4
|
-
require 'rant/import/sys/more'
|
5
|
-
|
6
|
-
$test_deprecated_dir ||= File.expand_path(File.dirname(__FILE__))
|
7
|
-
|
8
|
-
class TestDeprecated_0_5_4 < Test::Unit::TestCase
|
9
|
-
include Rant::TestUtil
|
10
|
-
|
11
|
-
def setup
|
12
|
-
Dir.chdir $test_deprecated_dir
|
13
|
-
end
|
14
|
-
def test_autoimport_var_constraints
|
15
|
-
Rant::Sys.write_to_file "var.t", <<-EOF
|
16
|
-
var :a, :Integer
|
17
|
-
var :b, :String
|
18
|
-
var :c, :List
|
19
|
-
var :d, :Bool
|
20
|
-
task :default do
|
21
|
-
p var[:a].kind_of?(Integer)
|
22
|
-
p var[:b].kind_of?(String)
|
23
|
-
p var[:c].kind_of?(Array)
|
24
|
-
p(var[:d] == true || var[:d] == false)
|
25
|
-
end
|
26
|
-
EOF
|
27
|
-
out, err = assert_rant "-fvar.t", "a=2", "d=1"
|
28
|
-
assert_match(/import 'var\/numbers'/, err)
|
29
|
-
assert_match(/import 'var\/strings'/, err)
|
30
|
-
assert_match(/import 'var\/lists'/, err)
|
31
|
-
assert_match(/import 'var\/booleans'/, err)
|
32
|
-
lines = out.split(/\n/)
|
33
|
-
assert_equal %w(true true true true), lines
|
34
|
-
ensure
|
35
|
-
Rant::Sys.rm_f "var.t"
|
36
|
-
end
|
37
|
-
def test_var_is
|
38
|
-
Rant::Sys.write_to_file "var.t", <<-EOF
|
39
|
-
import "var/booleans"
|
40
|
-
var(:b => true).is :Bool
|
41
|
-
task :default do
|
42
|
-
p var[:b]
|
43
|
-
var[:b] = "off"
|
44
|
-
p var[:b]
|
45
|
-
end
|
46
|
-
EOF
|
47
|
-
out, err = assert_rant("-fvar.t")
|
48
|
-
assert_match(/\bvar\.t\b.*\b2\b.*var\.is.*deprecated.*0\.5\.4/m, err)
|
49
|
-
assert_equal %w(true false), out.split(/\n/)
|
50
|
-
ensure
|
51
|
-
Rant::Sys.rm_f "var.t"
|
52
|
-
end
|
53
|
-
end
|