rant 0.4.0 → 0.4.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 +16 -0
- data/README +3 -2
- data/Rantfile +3 -4
- data/doc/advanced.rdoc +18 -13
- data/doc/examples/c_cpp_examples/Rantfile +37 -0
- data/doc/examples/c_cpp_examples/c/problem_1_1/another_test.c +6 -0
- data/doc/examples/c_cpp_examples/c/problem_1_1/another_test.h +7 -0
- data/doc/examples/c_cpp_examples/c/problem_1_1/main.c +12 -0
- data/doc/examples/c_cpp_examples/c/problem_1_1/test.c +6 -0
- data/doc/examples/c_cpp_examples/c/problem_1_1/test.h +7 -0
- data/doc/examples/c_cpp_examples/c/template.rf +21 -0
- data/doc/examples/c_cpp_examples/c++/problem_1_1/another_test.cpp +6 -0
- data/doc/examples/c_cpp_examples/c++/problem_1_1/another_test.h +5 -0
- data/doc/examples/c_cpp_examples/c++/problem_1_1/main.cpp +12 -0
- data/doc/examples/c_cpp_examples/c++/problem_1_1/test.cpp +6 -0
- data/doc/examples/c_cpp_examples/c++/problem_1_1/test.h +5 -0
- data/doc/examples/c_cpp_examples/c++/template.rf +21 -0
- data/doc/examples/c_cpp_examples/rule.rf +7 -0
- data/doc/rantfile.rdoc +1 -0
- data/lib/rant/archive/rubyzip/tempfile_bugfixed.rb +10 -8
- data/lib/rant/archive/rubyzip.rb +3 -8
- data/lib/rant/import/archive.rb +8 -4
- data/lib/rant/import/rubydoc.rb +1 -1
- data/lib/rant/import/rubytest.rb +12 -17
- data/lib/rant/import.rb +3 -2
- data/lib/rant/rantenv.rb +7 -4
- data/lib/rant/rantfile.rb +41 -21
- data/lib/rant/rantlib.rb +166 -113
- data/lib/rant/rantsys.rb +32 -17
- data/lib/rant/rantvar.rb +15 -15
- data/lib/rant/tempfile.rb +12 -0
- data/test/Rantfile +33 -0
- data/test/import/directedrule/test_directedrule.rb +29 -0
- data/test/import/package/Rantfile +2 -0
- data/test/import/package/test_package.rb +10 -0
- data/test/import/subfile/test_subfile.rb +21 -0
- data/test/project1/test_project.rb +10 -30
- data/test/project2/test_project.rb +1 -1
- data/test/project_rb1/test_project_rb1.rb +2 -1
- data/test/rant-import/test_rant-import.rb +35 -1
- data/test/subdirs/test_subdirs.rb +1 -2
- data/test/test_dirtask.rb +42 -0
- data/test/test_examples.rb +67 -0
- data/test/test_filelist.rb +52 -0
- data/test/test_rantfile_api.rb +59 -0
- data/test/ts_all.rb +1 -0
- metadata +25 -3
data/lib/rant/rantsys.rb
CHANGED
@@ -51,7 +51,7 @@ module Rant
|
|
51
51
|
public
|
52
52
|
### Methods having an equivalent in the Array class. #########
|
53
53
|
|
54
|
-
def each
|
54
|
+
def each(&block)
|
55
55
|
resolve if @pending
|
56
56
|
@files.each(&block)
|
57
57
|
end
|
@@ -217,17 +217,31 @@ module Rant
|
|
217
217
|
end
|
218
218
|
private :mk_all_rx
|
219
219
|
|
220
|
-
def select
|
220
|
+
def select(&block)
|
221
221
|
d = dup
|
222
|
-
|
222
|
+
d.actions << [:apply_select, block]
|
223
|
+
d.pending = true
|
223
224
|
d
|
224
225
|
end
|
226
|
+
alias find_all select
|
225
227
|
|
226
228
|
def apply_select blk
|
227
229
|
@files = @files.select(&blk)
|
228
230
|
end
|
229
231
|
private :apply_select
|
230
232
|
|
233
|
+
def map(&block)
|
234
|
+
d = dup
|
235
|
+
d.actions << [:apply_ary_method, :map!, block]
|
236
|
+
d.pending = true
|
237
|
+
d
|
238
|
+
end
|
239
|
+
alias collect map
|
240
|
+
|
241
|
+
def sub_ext(ext, new_ext=nil)
|
242
|
+
map { |f| f.sub_ext ext, new_ext }
|
243
|
+
end
|
244
|
+
|
231
245
|
# Remove all entries which contain a directory with the
|
232
246
|
# given name.
|
233
247
|
# If no argument or +nil+ given, remove all directories.
|
@@ -268,18 +282,12 @@ module Rant
|
|
268
282
|
|
269
283
|
# Remove all files which have the given name.
|
270
284
|
def no_file(name)
|
271
|
-
|
285
|
+
@actions << [:apply_ary_method, :reject!,
|
286
|
+
lambda { |entry| entry == name and test(?f, entry) }]
|
272
287
|
@pending = true
|
273
288
|
self
|
274
289
|
end
|
275
290
|
|
276
|
-
def apply_no_file(name)
|
277
|
-
@files.reject! { |entry|
|
278
|
-
entry == name and test(?f, entry)
|
279
|
-
}
|
280
|
-
end
|
281
|
-
private :apply_no_file
|
282
|
-
|
283
291
|
# Remove all entries which contain an element
|
284
292
|
# with the given suffix.
|
285
293
|
def no_suffix(suffix)
|
@@ -330,6 +338,7 @@ module Rant
|
|
330
338
|
def arglist
|
331
339
|
to_ary.arglist
|
332
340
|
end
|
341
|
+
alias to_s arglist
|
333
342
|
|
334
343
|
# Same as #uniq! but evaluation is delayed until the next read
|
335
344
|
# access (e.g. by calling #each). Always returns self.
|
@@ -347,12 +356,18 @@ module Rant
|
|
347
356
|
self
|
348
357
|
end
|
349
358
|
|
359
|
+
def lazy_map!(&block)
|
360
|
+
@actions << [:apply_ary_method, :map!, block]
|
361
|
+
@pending = true
|
362
|
+
self
|
363
|
+
end
|
364
|
+
|
350
365
|
private
|
351
|
-
def apply_ary_method(meth)
|
352
|
-
@files.send meth
|
366
|
+
def apply_ary_method(meth, block=nil)
|
367
|
+
@files.send meth, &block
|
353
368
|
end
|
354
|
-
def apply_ary_method_1(meth, arg1)
|
355
|
-
@files.send meth, arg1
|
369
|
+
def apply_ary_method_1(meth, arg1, block=nil)
|
370
|
+
@files.send meth, arg1, &block
|
356
371
|
end
|
357
372
|
end # class FileList
|
358
373
|
|
@@ -395,7 +410,7 @@ module Rant
|
|
395
410
|
Dir.chdir(@basedir) { filelist_resolve }
|
396
411
|
end
|
397
412
|
|
398
|
-
def each
|
413
|
+
def each(&block)
|
399
414
|
old_pwd = Dir.pwd
|
400
415
|
resolve if @pending
|
401
416
|
Dir.chdir(@basedir)
|
@@ -427,7 +442,7 @@ module Rant
|
|
427
442
|
@lists = [@cur_list]
|
428
443
|
end
|
429
444
|
|
430
|
-
def each_entry
|
445
|
+
def each_entry(&block)
|
431
446
|
@lists.each { |list|
|
432
447
|
list.each(&block)
|
433
448
|
}
|
data/lib/rant/rantvar.rb
CHANGED
@@ -16,7 +16,7 @@
|
|
16
16
|
# If you're looking for general info about Rant, read the
|
17
17
|
# README[link:files/README.html].
|
18
18
|
module Rant
|
19
|
-
VERSION = '0.4.
|
19
|
+
VERSION = '0.4.2'
|
20
20
|
|
21
21
|
# Those are the filenames for rantfiles.
|
22
22
|
# Case matters!
|
@@ -259,7 +259,7 @@ module Rant
|
|
259
259
|
|
260
260
|
# Use ENV instead of internal store for given vars.
|
261
261
|
# Probably useful for vars like CC, CFLAGS, etc.
|
262
|
-
def env
|
262
|
+
def env(*vars)
|
263
263
|
vars.flatten.each { |var|
|
264
264
|
vid = RantVar.valid_vid(var)
|
265
265
|
cur_val = @store[vid]
|
@@ -360,19 +360,6 @@ module Rant
|
|
360
360
|
end
|
361
361
|
end
|
362
362
|
|
363
|
-
class ::Range
|
364
|
-
def rant_constraint
|
365
|
-
case first
|
366
|
-
when ::Integer
|
367
|
-
IntegerInRange.new(self)
|
368
|
-
when ::Float
|
369
|
-
FloatInRange.new(self)
|
370
|
-
else
|
371
|
-
raise NotAConstraintFactoryError.new(self)
|
372
|
-
end
|
373
|
-
end
|
374
|
-
end
|
375
|
-
|
376
363
|
class Integer
|
377
364
|
include Constraint
|
378
365
|
|
@@ -599,3 +586,16 @@ module Rant
|
|
599
586
|
module_function :valid_constraint?, :valid_vid
|
600
587
|
end # module RantVar
|
601
588
|
end # module Rant
|
589
|
+
|
590
|
+
class Range
|
591
|
+
def rant_constraint
|
592
|
+
case first
|
593
|
+
when ::Integer
|
594
|
+
Rant::RantVar::Constraints::IntegerInRange.new(self)
|
595
|
+
when ::Float
|
596
|
+
Rant::RantVar::Constraints::FloatInRange.new(self)
|
597
|
+
else
|
598
|
+
raise NotAConstraintFactoryError.new(self)
|
599
|
+
end
|
600
|
+
end
|
601
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
|
2
|
+
# tempfile.rb
|
3
|
+
#
|
4
|
+
# Copyright (C) 2005 Stefan Lang <langstefan@gmx.at>
|
5
|
+
|
6
|
+
require 'tempfile'
|
7
|
+
if Tempfile.superclass == SimpleDelegator
|
8
|
+
require 'rant/archive/rubyzip/tempfile_bugfixed'
|
9
|
+
Rant::Tempfile = Rant::BugFix::Tempfile
|
10
|
+
else
|
11
|
+
Rant::Tempfile = Tempfile
|
12
|
+
end
|
data/test/Rantfile
CHANGED
@@ -54,4 +54,37 @@ end
|
|
54
54
|
desc "Make some path (basedir.t/a/b)."
|
55
55
|
gen Directory, "basedir.t", "a/b"
|
56
56
|
|
57
|
+
gen Action do
|
58
|
+
if var[:make_path]
|
59
|
+
make Directory, "basedir.t"
|
60
|
+
make "basedir.t/a/b"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
task :make_file do |t|
|
65
|
+
make "make_file.t" do |t|
|
66
|
+
sys.touch t.name
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
file "make_files_dep.t" do |t|
|
71
|
+
sys.touch t.name
|
72
|
+
end
|
73
|
+
|
74
|
+
gen Action do
|
75
|
+
if var[:make_files]
|
76
|
+
make "make_files.t" => "make_files_dep.t" do |t|
|
77
|
+
sys.touch t.name
|
78
|
+
end
|
79
|
+
end
|
80
|
+
if var[:make_gen_with_block]
|
81
|
+
import "subfile"
|
82
|
+
make SubFile, "a.t/a.t" do |t|
|
83
|
+
sys.touch t.name
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
task :dep_on_make_files => ["make_files.t"]
|
89
|
+
|
57
90
|
# vim: ft=ruby
|
@@ -34,4 +34,33 @@ class TestDirectedRule < Test::Unit::TestCase
|
|
34
34
|
assert(test(?d, "build2.t"))
|
35
35
|
assert(test(?f, "build2.t/1.2a"))
|
36
36
|
end
|
37
|
+
=begin
|
38
|
+
# This would currently be to complex to implement cleanly.
|
39
|
+
def test_invoke_rule_in_subdir
|
40
|
+
FileUtils.mkdir "sub.t"
|
41
|
+
Dir.chdir "sub.t"
|
42
|
+
FileUtils.mkdir "sub.t"
|
43
|
+
open "Rantfile", "w" do |f|
|
44
|
+
f << <<-EOF
|
45
|
+
import "directedrule", "autoclean"
|
46
|
+
gen Directory, "build.t"
|
47
|
+
gen DirectedRule, "build.t" => ["src.t"], :a => :b do |t|
|
48
|
+
sys.touch t.name
|
49
|
+
end
|
50
|
+
gen AutoClean
|
51
|
+
subdirs "sub.t"
|
52
|
+
EOF
|
53
|
+
end
|
54
|
+
open "sub.t/Rantfile", "w" do |f|
|
55
|
+
f << <<-EOF
|
56
|
+
task :a => "build.t/file.a"
|
57
|
+
EOF
|
58
|
+
end
|
59
|
+
assert_rant(:v, "sub.t/a")
|
60
|
+
assert(test(?f, "sub.t/build.t/file.a"))
|
61
|
+
ensure
|
62
|
+
Dir.chdir $testImportDrDir
|
63
|
+
FileUtils.rm_rf "sub.t"
|
64
|
+
end
|
65
|
+
=end
|
37
66
|
end
|
@@ -274,6 +274,16 @@ class TestImportPackage < Test::Unit::TestCase
|
|
274
274
|
ensure
|
275
275
|
FileUtils.rm_rf %w(subs.t sub6.t)
|
276
276
|
end
|
277
|
+
def test_tgz_package_double
|
278
|
+
assert_rant("pkg.t/double.tgz")
|
279
|
+
out, err = assert_rant("pkg.t/double.tgz")
|
280
|
+
assert(out.empty?)
|
281
|
+
assert(err.empty?)
|
282
|
+
mf = %w(Rantfile)
|
283
|
+
dirs = %w()
|
284
|
+
@pkg_dir = "double"
|
285
|
+
check_contents(:tgz, "pkg.t/double.tgz", mf, dirs)
|
286
|
+
end
|
277
287
|
def test_zip_follow_symlink
|
278
288
|
have_symlinks = true
|
279
289
|
FileUtils.mkdir "subs.t"
|
@@ -100,4 +100,25 @@ class TestSubFile < Test::Unit::TestCase
|
|
100
100
|
"#{f} should have been unlinked by AutoClean")
|
101
101
|
}
|
102
102
|
end
|
103
|
+
def test_with_slash
|
104
|
+
open "with_slash.t", "w" do |f|
|
105
|
+
f << <<-EOF
|
106
|
+
import "subfile", "autoclean"
|
107
|
+
gen SubFile, "base.t/", "a" do |t|
|
108
|
+
sys.touch t.name
|
109
|
+
end
|
110
|
+
gen AutoClean
|
111
|
+
EOF
|
112
|
+
end
|
113
|
+
assert_rant(:fail, "-fwith_slash.t")
|
114
|
+
FileUtils.mkdir "base.t"
|
115
|
+
assert_rant("-fwith_slash.t")
|
116
|
+
assert(test(?f, "base.t/a"))
|
117
|
+
out, err = assert_rant("-fwith_slash.t")
|
118
|
+
assert(out.empty?)
|
119
|
+
assert(err.empty?)
|
120
|
+
assert_rant("-fwith_slash.t", "autoclean")
|
121
|
+
assert(test(?d, "base.t"))
|
122
|
+
assert(!test(?e, "base.t/a"))
|
123
|
+
end
|
103
124
|
end
|
@@ -8,63 +8,43 @@ $testProject1Dir = File.expand_path(File.dirname(__FILE__))
|
|
8
8
|
|
9
9
|
class TestProject1 < Test::Unit::TestCase
|
10
10
|
def setup
|
11
|
-
Dir.chdir($testProject1Dir)
|
12
|
-
Rant.reset
|
11
|
+
Dir.chdir($testProject1Dir)
|
13
12
|
end
|
14
13
|
def teardown
|
15
|
-
|
16
|
-
assert_equal(Rant.run("force_clean"), 0)
|
17
|
-
end
|
14
|
+
assert_rant("force_clean")
|
18
15
|
end
|
19
16
|
def test_run
|
20
|
-
out, err =
|
21
|
-
|
22
|
-
"Exit code of rant should be 0.")
|
23
|
-
end
|
17
|
+
out, err = assert_rant("test_touch")
|
18
|
+
#"Exit code of rant should be 0.")
|
24
19
|
assert(err =~ /\[WARNING\]/,
|
25
20
|
"rant should print a warning because of enhance on non-existing task")
|
26
|
-
Rant.reset
|
27
21
|
assert(File.exist?("test_touch"),
|
28
22
|
"file test_touch should have been created")
|
29
|
-
|
30
|
-
assert_equal(Rant.run("clean"), 0)
|
31
|
-
end
|
23
|
+
assert_rant("clean")
|
32
24
|
assert(!File.exist?("test_touch"))
|
33
25
|
end
|
34
26
|
def test_timedep
|
35
|
-
|
36
|
-
assert_equal(Rant.run("create_target"), 0)
|
37
|
-
end
|
27
|
+
assert_rant("create_target")
|
38
28
|
assert(File.exist?("target"))
|
39
|
-
Rant.reset
|
40
29
|
timeout
|
41
|
-
|
42
|
-
assert_equal(Rant.run("create_dep"), 0)
|
43
|
-
end
|
30
|
+
assert_rant("create_dep")
|
44
31
|
assert(File.exist?("dep"))
|
45
32
|
assert(Rant::Sys.uptodate?("dep", "target"),
|
46
33
|
"`create_target' was run before `create_dep'")
|
47
34
|
timeout
|
48
|
-
|
49
|
-
assert_equal(Rant.run("target"), 0)
|
50
|
-
end
|
35
|
+
assert_rant("target")
|
51
36
|
assert(File.exist?("target"))
|
52
37
|
assert(File.exist?("dep"))
|
53
38
|
assert(Rant::Sys.uptodate?("target", "dep"),
|
54
39
|
"`target' should be newer than `dep'")
|
55
40
|
t1 = File.mtime "target"
|
56
|
-
Rant.reset
|
57
41
|
timeout
|
58
|
-
|
59
|
-
assert_equal(Rant.run("target"), 0)
|
60
|
-
end
|
42
|
+
assert_rant("target")
|
61
43
|
assert_equal(t1, File.mtime("target"),
|
62
44
|
"`target' was already up to date")
|
63
45
|
end
|
64
46
|
def test_two_deps
|
65
|
-
|
66
|
-
assert_equal(Rant.run("t2"), 0)
|
67
|
-
end
|
47
|
+
assert_rant("t2")
|
68
48
|
assert(File.exist?("t2"),
|
69
49
|
"file `t2' should have been built")
|
70
50
|
assert(File.exist?("dep1"),
|
@@ -19,7 +19,8 @@ class TestProjectRb1 < Test::Unit::TestCase
|
|
19
19
|
end
|
20
20
|
def check_manifest(msg_prefix = "")
|
21
21
|
manifest = @manifest.dup
|
22
|
-
|
22
|
+
#Dir["**/*"].each { |e|
|
23
|
+
Rant::FileList["**/*"].shun(".svn").each { |e|
|
23
24
|
assert(manifest.reject! { |mf| mf == e } ,
|
24
25
|
"#{msg_prefix}#{e} shouldn't exist according to manifest")
|
25
26
|
}
|
@@ -9,7 +9,7 @@ $testRantImportDir ||= File.expand_path(File.dirname(__FILE__))
|
|
9
9
|
class TestRantImport < Test::Unit::TestCase
|
10
10
|
def setup
|
11
11
|
# Ensure we run in test directory.
|
12
|
-
Dir.chdir($testRantImportDir)
|
12
|
+
Dir.chdir($testRantImportDir)
|
13
13
|
end
|
14
14
|
def teardown
|
15
15
|
Dir.chdir($testRantImportDir)
|
@@ -165,4 +165,38 @@ class TestRantImport < Test::Unit::TestCase
|
|
165
165
|
assert_equal(1, files.size)
|
166
166
|
assert(files.include?("b.t/b.s.t"))
|
167
167
|
end
|
168
|
+
def test_loaded_features
|
169
|
+
FileUtils.mkdir "features.t"
|
170
|
+
Dir.chdir "features.t"
|
171
|
+
FileUtils.mkpath "rant/import"
|
172
|
+
open "rant/import/foo.rb", "w" do |f|
|
173
|
+
f << <<-EOF
|
174
|
+
def foo
|
175
|
+
puts "foo"
|
176
|
+
end
|
177
|
+
EOF
|
178
|
+
end
|
179
|
+
open "Rantfile", "w" do |f|
|
180
|
+
f << <<-EOF
|
181
|
+
import "foo"
|
182
|
+
require 'rant/import/foo'
|
183
|
+
task :default do
|
184
|
+
foo
|
185
|
+
end
|
186
|
+
EOF
|
187
|
+
end
|
188
|
+
out, err = assert_rant
|
189
|
+
assert_match(/foo/, out)
|
190
|
+
assert(err.empty?)
|
191
|
+
run_import("-q", "--auto", "make.rb")
|
192
|
+
assert_exit
|
193
|
+
assert(test(?f, "make.rb"))
|
194
|
+
out = run_ruby("make.rb")
|
195
|
+
assert_exit
|
196
|
+
assert_match(/foo/, out)
|
197
|
+
FileUtils.rm_rf "rant"
|
198
|
+
out = run_ruby("make.rb")
|
199
|
+
assert_exit
|
200
|
+
assert_match(/foo/, out)
|
201
|
+
end
|
168
202
|
end
|
@@ -9,13 +9,12 @@ $testSubdirsDir = File.expand_path(File.dirname(__FILE__))
|
|
9
9
|
class TestSubdirs < Test::Unit::TestCase
|
10
10
|
def setup
|
11
11
|
Dir.chdir($testSubdirsDir) unless Dir.pwd == $testSubdirsDir
|
12
|
-
Rant.reset
|
13
12
|
end
|
14
13
|
def teardown
|
15
14
|
capture_std do
|
16
15
|
assert_equal(0, Rant.run("clean"))
|
17
16
|
end
|
18
|
-
created = Dir["**/*t"]
|
17
|
+
created = Rant::FileList["**/*t"].shun(".svn")#Dir["**/*t"]
|
19
18
|
assert(created.empty?)
|
20
19
|
end
|
21
20
|
def test_load
|
data/test/test_dirtask.rb
CHANGED
@@ -74,4 +74,46 @@ class TestDirTask < Test::Unit::TestCase
|
|
74
74
|
assert_match(%r{basedir.t/a/b\s*#.*Make some path}, out)
|
75
75
|
assert_rant("clean")
|
76
76
|
end
|
77
|
+
def test_basedir_with_slash
|
78
|
+
open "dir_with_slash.t", "w" do |f|
|
79
|
+
f << <<-EOF
|
80
|
+
import "autoclean"
|
81
|
+
file "a.t/b/c" => "a.t/b" do |t|
|
82
|
+
sys.touch t.name
|
83
|
+
end
|
84
|
+
gen Directory, "a.t/", "b"
|
85
|
+
gen AutoClean
|
86
|
+
EOF
|
87
|
+
end
|
88
|
+
assert_rant(:fail, "-fdir_with_slash.t")
|
89
|
+
assert(!test(?e, "a.t"))
|
90
|
+
FileUtils.mkdir "a.t"
|
91
|
+
assert_rant("-fdir_with_slash.t")
|
92
|
+
assert(test(?f, "a.t/b/c"))
|
93
|
+
out, err = assert_rant("-fdir_with_slash.t")
|
94
|
+
assert(out.empty?)
|
95
|
+
assert(err.empty?)
|
96
|
+
assert_rant("-fdir_with_slash.t", "autoclean")
|
97
|
+
assert(test(?d, "a.t"))
|
98
|
+
assert(!test(?e, "a.t/b"))
|
99
|
+
end
|
100
|
+
def test_with_slash
|
101
|
+
open "dir_with_slash.t", "w" do |f|
|
102
|
+
f << <<-EOF
|
103
|
+
import "autoclean"
|
104
|
+
file "a.t/b" => "a.t" do |t|
|
105
|
+
sys.touch t.name
|
106
|
+
end
|
107
|
+
gen Directory, "a.t/"
|
108
|
+
gen AutoClean
|
109
|
+
EOF
|
110
|
+
end
|
111
|
+
assert_rant("-fdir_with_slash.t")
|
112
|
+
assert(test(?f, "a.t/b"))
|
113
|
+
out, err = assert_rant("-fdir_with_slash.t")
|
114
|
+
assert(out.empty?)
|
115
|
+
assert(err.empty?)
|
116
|
+
assert_rant("-fdir_with_slash.t", "autoclean")
|
117
|
+
assert(!test(?e, "a.t"))
|
118
|
+
end
|
77
119
|
end
|
data/test/test_examples.rb
CHANGED
@@ -66,4 +66,71 @@ class TestExamples < Test::Unit::TestCase
|
|
66
66
|
assert(!test(?f, "c_dependencies"))
|
67
67
|
assert(!test(?f, "hello"))
|
68
68
|
end
|
69
|
+
def test_c_cpp_examples
|
70
|
+
Dir.chdir "c_cpp_examples"
|
71
|
+
proj_pwd = Dir.pwd
|
72
|
+
out, err = assert_rant("--tasks")
|
73
|
+
# TODO: replace with a not-so-strict regex
|
74
|
+
op = <<EOF
|
75
|
+
rant run # Run all C and C++ tests.
|
76
|
+
rant build # Build all.
|
77
|
+
rant autoclean # Remove all autogenerated files.
|
78
|
+
rant pkg/c_cpp_exercises.tgz # Create source package.
|
79
|
+
EOF
|
80
|
+
assert_equal(op, out)
|
81
|
+
assert(err.empty?)
|
82
|
+
gen_files = %w(
|
83
|
+
c/problem_1_1/Rantfile
|
84
|
+
c++/problem_1_1/Rantfile
|
85
|
+
c/problem_1_1/c_dependencies
|
86
|
+
c++/problem_1_1/c_dependencies
|
87
|
+
c/problem_1_1/test
|
88
|
+
c++/problem_1_1/test
|
89
|
+
c/problem_1_1/main.o
|
90
|
+
c++/problem_1_1/main.o
|
91
|
+
c/problem_1_1/test.o
|
92
|
+
c++/problem_1_1/test.o
|
93
|
+
c/problem_1_1/another_test.o
|
94
|
+
c++/problem_1_1/another_test.o
|
95
|
+
pkg
|
96
|
+
)
|
97
|
+
if Rant::Env.find_bin("gcc") && Rant::Env.find_bin("g++")
|
98
|
+
out = run_rant
|
99
|
+
assert_exit
|
100
|
+
assert_equal(2, out.scan("Hello, world!").size)
|
101
|
+
out, err = assert_rant("build")
|
102
|
+
assert(out.empty?)
|
103
|
+
assert(err.empty?)
|
104
|
+
else
|
105
|
+
STDERR.puts "*** gcc and/or g++ not available, less example testing ***"
|
106
|
+
end
|
107
|
+
assert_rant("pkg/c_cpp_exercises.tgz")
|
108
|
+
# TODO: check archive contents
|
109
|
+
assert(test(?f, "pkg/c_cpp_exercises.tgz"))
|
110
|
+
out, err = assert_rant("pkg/c_cpp_exercises.tgz")
|
111
|
+
assert(out.empty?)
|
112
|
+
assert(err.empty?)
|
113
|
+
assert_rant("autoclean")
|
114
|
+
gen_files.each { |f|
|
115
|
+
assert(!test(?e, f),
|
116
|
+
"#{f} should have been removed by autoclean")
|
117
|
+
}
|
118
|
+
if Rant::Env.find_bin("gcc")
|
119
|
+
FileUtils.cp "c/template.rf", "c/problem_1_1/Rantfile"
|
120
|
+
Dir.chdir "c/problem_1_1"
|
121
|
+
out = run_rant
|
122
|
+
assert(out.include?("Hello, world!"))
|
123
|
+
assert_rant("autoclean")
|
124
|
+
FileUtils.rm_f "Rantfile"
|
125
|
+
Dir.chdir proj_pwd
|
126
|
+
gen_files.each { |f|
|
127
|
+
assert(!test(?e, f),
|
128
|
+
"#{f} should have been removed by autoclean")
|
129
|
+
}
|
130
|
+
end
|
131
|
+
ensure
|
132
|
+
Dir.chdir proj_pwd
|
133
|
+
FileUtils.rm_f "c/problem_1_1/Rantfile"
|
134
|
+
FileUtils.rm_f "c++/problem_1_1/Rantfile"
|
135
|
+
end
|
69
136
|
end
|
data/test/test_filelist.rb
CHANGED
@@ -288,6 +288,19 @@ class TestFileList < Test::Unit::TestCase
|
|
288
288
|
assert(l1.include("b.t"))
|
289
289
|
end
|
290
290
|
end
|
291
|
+
def test_sys_find_all_resolve
|
292
|
+
cx = Rant::RantApp.new.cx
|
293
|
+
touch_temp %w(a.t b.t) do
|
294
|
+
l1 = cx.sys["*.t"]
|
295
|
+
l1.resolve
|
296
|
+
l2 = l1.find_all { |f| f =~ /^b/ }
|
297
|
+
assert_equal(2, l1.size)
|
298
|
+
assert(l1.include("a.t"))
|
299
|
+
assert(l1.include("b.t"))
|
300
|
+
assert_equal(1, l2.size)
|
301
|
+
assert(l1.include("b.t"))
|
302
|
+
end
|
303
|
+
end
|
291
304
|
def test_sys_glob_flags
|
292
305
|
cx = Rant::RantApp.new.cx
|
293
306
|
touch_temp %w(a.t .a.t b.t .b.t) do
|
@@ -328,4 +341,43 @@ class TestFileList < Test::Unit::TestCase
|
|
328
341
|
assert(fl.include?("a.t"))
|
329
342
|
end
|
330
343
|
end
|
344
|
+
def test_map
|
345
|
+
cx = Rant::RantApp.new.cx
|
346
|
+
touch_temp %w(a.t b.t) do
|
347
|
+
fl = cx.sys["*.t"]
|
348
|
+
l2 = fl.map { |f| f + "t" }
|
349
|
+
assert(Rant::FileList === l2)
|
350
|
+
assert_equal(2, l2.size)
|
351
|
+
assert(l2.include?("a.tt"))
|
352
|
+
assert(l2.include?("b.tt"))
|
353
|
+
assert_equal(2, fl.size)
|
354
|
+
assert(fl.include?("a.t"))
|
355
|
+
assert(fl.include?("b.t"))
|
356
|
+
end
|
357
|
+
end
|
358
|
+
def test_no_file
|
359
|
+
cx = Rant::RantApp.new.cx
|
360
|
+
touch_temp %w(a.t b.t) do
|
361
|
+
fl = cx.sys["*.t"]
|
362
|
+
fl.no_file "a.t"
|
363
|
+
assert_equal(1, fl.size)
|
364
|
+
assert(fl.include?("b.t"))
|
365
|
+
end
|
366
|
+
end
|
367
|
+
def test_to_s
|
368
|
+
cx = Rant::RantApp.new.cx
|
369
|
+
assert_equal("a b", cx.sys[].concat(%w(a b)).to_s)
|
370
|
+
assert_equal("", "#{cx.sys[]}")
|
371
|
+
end
|
372
|
+
if Rant::Env.on_windows?
|
373
|
+
def test_to_s_quoting_spaces_win
|
374
|
+
cx = Rant::RantApp.new.cx
|
375
|
+
assert_equal('"a a" b', "#{cx.sys[].concat(["a a", "b"])}")
|
376
|
+
end
|
377
|
+
else
|
378
|
+
def test_to_s_quoting_spaces
|
379
|
+
cx = Rant::RantApp.new.cx
|
380
|
+
assert_equal("'a a' b", "#{cx.sys[].concat(["a a", "b"])}")
|
381
|
+
end
|
382
|
+
end
|
331
383
|
end
|