rant 0.5.0 → 0.5.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.
@@ -1,14 +1,20 @@
1
1
 
2
2
  require 'test/unit'
3
3
  require 'tutil'
4
+ require 'rant/import/filelist/std'
5
+ require 'rant/import/sys/more'
4
6
 
5
7
  $testDir ||= File.expand_path(File.dirname(__FILE__))
6
8
 
7
9
  class TestFileList < Test::Unit::TestCase
8
10
  include Rant::TestUtil
9
11
 
12
+ def assert_entries(entry_ary, fl)
13
+ assert_equal entry_ary.size, fl.size
14
+ entry_ary.each { |entry| assert fl.include?(entry) }
15
+ end
10
16
  def fl(*args, &block)
11
- Rant::FileList.new(*args, &block)
17
+ Rant::FileList.glob(*args, &block)
12
18
  end
13
19
  def touch_temp(*args)
14
20
  files = args.flatten
@@ -22,9 +28,76 @@ class TestFileList < Test::Unit::TestCase
22
28
  def setup
23
29
  # Ensure we run in test directory.
24
30
  Dir.chdir($testDir) unless Dir.pwd == $testDir
31
+ @rant = Rant::RantApp.new
32
+ @cx = @rant.cx
33
+ @sys = @cx.sys
25
34
  end
26
35
  def teardown
27
36
  end
37
+ def test_create_new
38
+ @sys.ignore %r{_}
39
+ fl = @sys.filelist
40
+ assert fl.kind_of?(Rant::FileList)
41
+ assert fl.empty?
42
+ fl.concat ["ab", "c_d"]
43
+ assert_equal ["ab"], fl.entries
44
+ end
45
+ def test_create_bracket_op
46
+ in_local_temp_dir do
47
+ Rant::Sys.touch ["a.t", ".a.t"]
48
+ fl = @sys["*.t"]
49
+ assert_entries(["a.t"], fl)
50
+ end
51
+ end
52
+ def test_create_glob
53
+ in_local_temp_dir do
54
+ Rant::Sys.touch ["a.t", ".a.t"]
55
+ fl = @sys.glob("*.t")
56
+ assert_entries(["a.t"], fl)
57
+ fl = @sys.glob(".*.t")
58
+ # note: no "." and ".." entries
59
+ assert_entries([".a.t"], fl)
60
+ fl = @sys.glob("*.t") do |fl|
61
+ fl.glob ".*.t"
62
+ end
63
+ assert_equal ["a.t", ".a.t"], fl.entries
64
+ end
65
+ end
66
+ def test_create_glob_all
67
+ in_local_temp_dir do
68
+ Rant::Sys.touch ["a.t", ".a.t"]
69
+ fl = @sys.glob_all("*.t")
70
+ assert_entries(["a.t", ".a.t"], fl)
71
+ fl = @sys.glob_all(".*.t")
72
+ # note: no "." and ".." entries
73
+ assert_entries([".a.t"], fl)
74
+ fl = @sys.glob_all("*.t") do |fl|
75
+ fl.keep(".")
76
+ end
77
+ assert_entries ["a.t", ".a.t", "."], fl
78
+ end
79
+ end
80
+ def test_conversion_from_filelist
81
+ fl1 = @sys.filelist
82
+ fl2 = @sys.filelist(fl1)
83
+ assert fl1.equal?(fl2) # same object
84
+ end
85
+ def test_conversion_from_ary
86
+ @sys.ignore "foo"
87
+ fl = @sys.filelist(["foo", "bar"])
88
+ assert fl.kind_of?(Rant::FileList)
89
+ assert_equal ["bar"], fl.entries
90
+ end
91
+ def test_conversion_type_error
92
+ assert_raise_kind_of(TypeError) do
93
+ fl = @sys.filelist(Object.new)
94
+ end
95
+ end
96
+ def test_conversion_type_error_nil
97
+ assert_raise_kind_of(TypeError) do
98
+ fl = @sys.filelist(nil)
99
+ end
100
+ end
28
101
  def test_in_flatten
29
102
  touch_temp %w(1.t 2.t) do
30
103
  assert(test(?f, "1.t")) # test touch_temp...
@@ -35,7 +108,7 @@ class TestFileList < Test::Unit::TestCase
35
108
  assert_equal(2, [fl("*.t")].flatten.size)
36
109
  end
37
110
  end
38
- def test_exclude_all
111
+ def test_exclude_name
39
112
  l = fl
40
113
  inc_list = %w(
41
114
  CVS_ a/b a
@@ -44,7 +117,7 @@ class TestFileList < Test::Unit::TestCase
44
117
  CVS a/CVS a/CVS/b CVS/CVS //CVS /CVS/ /a/b/CVS/c
45
118
  ).map! { |f| f.tr "/", File::SEPARATOR }
46
119
  l.concat(not_inc_list + inc_list)
47
- l.exclude_all "CVS"
120
+ l.exclude_name "CVS"
48
121
  inc_list.each { |f|
49
122
  assert(l.include?(f))
50
123
  }
@@ -92,9 +165,9 @@ class TestFileList < Test::Unit::TestCase
92
165
  assert(l.include?("2.tt"))
93
166
  end
94
167
  end
95
- def test_initialize_with_yield
168
+ def test_glob_with_yield
96
169
  touch_temp %w(a.t b.t a.tt b.tt) do
97
- list = fl { |l|
170
+ list = Rant::FileList.glob { |l|
98
171
  l.include "*.t", "*.tt"
99
172
  l.exclude "a*"
100
173
  }
@@ -110,7 +183,7 @@ class TestFileList < Test::Unit::TestCase
110
183
  touch_temp %w(a.t b.t c.t d.t) do
111
184
  list = fl "a*"
112
185
  list.exclude("a*", "b*").include(*%w(b* c* d*))
113
- assert(list.exclude_all("d.t").equal?(list))
186
+ assert(list.exclude_name("d.t").equal?(list))
114
187
  assert(list.include?("b.t"))
115
188
  assert(list.include?("c.t"))
116
189
  assert(!list.include?("a.t"))
@@ -169,7 +242,7 @@ class TestFileList < Test::Unit::TestCase
169
242
  %w(a.t1 a.t2 b.t2).each { |fn|
170
243
  assert(l3.include(fn), "#{fn} missing")
171
244
  }
172
- l3.lazy_uniq!
245
+ l3.uniq!
173
246
  assert_equal(3, l3.size)
174
247
  end
175
248
  end
@@ -181,7 +254,7 @@ class TestFileList < Test::Unit::TestCase
181
254
  assert_equal(2, l1.size)
182
255
  assert_equal(3, l2.size)
183
256
  assert(l2.include?("x"))
184
- assert_equal("x", l2.last)
257
+ assert_equal("x", l2.to_a.last)
185
258
  end
186
259
  end
187
260
  def test_2add_array
@@ -252,11 +325,16 @@ class TestFileList < Test::Unit::TestCase
252
325
  assert(!l.include?("fl.t/a~"))
253
326
  assert(!l.include?("fl.t/CVS"))
254
327
  end
255
- l[0] = "CVS"
328
+
329
+ # change in Rant 0.5.1
330
+ # l[0] = "CVS"
331
+ l.unshift "CVS"
332
+
256
333
  assert(!l.include?("CVS"))
257
334
  ensure
258
335
  FileUtils.rm_rf "fl.t"
259
336
  end
337
+ =begin Makes no sense since Rant 0.5.1
260
338
  def test_return_from_array_method
261
339
  touch_temp "a.t" do
262
340
  l = fl("a.t", "a.t")
@@ -265,13 +343,14 @@ class TestFileList < Test::Unit::TestCase
265
343
  assert_equal(1, ul.size)
266
344
  end
267
345
  end
346
+ =end
268
347
  def test_return_self_from_array_method
269
348
  touch_temp "a.t", "b.t" do
270
349
  l = fl("*.t")
271
350
  sl = l.sort!
272
351
  assert_same(l, sl)
273
- assert_equal("a.t", l.first)
274
- assert_equal("b.t", l[1])
352
+ assert_equal("a.t", l.to_a.first)
353
+ assert_equal("b.t", l.to_a[1])
275
354
  end
276
355
  end
277
356
  def test_sys_with_cd
@@ -331,8 +410,13 @@ class TestFileList < Test::Unit::TestCase
331
410
  def test_sys_glob_flags
332
411
  cx = Rant::RantApp.new.cx
333
412
  touch_temp %w(a.t .a.t b.t .b.t) do
334
- l1 = cx.sys["*.t"]
335
- l1.glob_flags |= File::FNM_DOTMATCH
413
+ l1 = cx.sys.glob
414
+
415
+ # change in Rant 0.5.1
416
+ #l1.glob_flags |= File::FNM_DOTMATCH
417
+ l1.glob_dotfiles
418
+ l1.include("*.t")
419
+
336
420
  l2 = cx.sys["*.t"]
337
421
  assert_equal(4, l1.size)
338
422
  assert_equal(2, l2.size)
@@ -484,4 +568,42 @@ end
484
568
  assert_equal 2, files.size
485
569
  end
486
570
  end
571
+ def test_rantfile_std
572
+ in_local_temp_dir do
573
+ Rant::Sys.mkdir ["d1", "d2"]
574
+ Rant::Sys.touch ["a.1", "d1/a.2", "d2/b.2"]
575
+ Rant::Sys.write_to_file "Rantfile", <<-EOF
576
+ import "filelist/std"
577
+ task :default do
578
+ fl = sys["**/*"]
579
+ puts fl.dirs.join
580
+ puts fl.files.join
581
+ fl.no_dir
582
+ puts fl.join
583
+ end
584
+ EOF
585
+ # Run in subprocess to check if #dirs, #files and #no_dir
586
+ # is defined by import "filelist/std".
587
+ out, err = assert_rant(:x)
588
+ lines = out.split(/\n/)
589
+ assert_entries ["d1", "d2"], lines[0].split
590
+ assert_entries ["a.1", "d1/a.2", "d2/b.2", "Rantfile"], lines[1].split
591
+ assert_entries ["a.1", "d1/a.2", "d2/b.2", "Rantfile"], lines[2].split
592
+ end
593
+ end
594
+ def test_rantfile_object_inspect
595
+ in_local_temp_dir do
596
+ Rant::Sys.write_to_file "Rantfile", <<-EOF
597
+ task :default do |t|
598
+ fl = sys["**/*"]
599
+ fl.object_inspect.kind_of?(String) or t.fail
600
+ puts fl.object_inspect
601
+ end
602
+ EOF
603
+ # Run in subprocess to check if #dirs, #files and #no_dir
604
+ # is defined by import "filelist/std".
605
+ out, err = assert_rant(:x)
606
+ assert !out.strip.empty?
607
+ end
608
+ end
487
609
  end
@@ -63,6 +63,10 @@ class TestSys < Test::Unit::TestCase
63
63
  assert_equal(pl.size, 1,
64
64
  '../ should be "split" into one element')
65
65
  assert_equal(pl[0], "..")
66
+ assert_equal ["."], Rant::Sys.split_all("./")
67
+ assert_equal ["."], Rant::Sys.split_all(".")
68
+ assert_equal [".", "foo"], Rant::Sys.split_all("./foo")
69
+ assert_equal [], Rant::Sys.split_all("")
66
70
  end
67
71
  def test_expand_path
68
72
  in_local_temp_dir do
@@ -555,4 +555,13 @@ class TestSysMethods < Test::Unit::TestCase
555
555
  end
556
556
  assert_file_content "a.t", "hello\n"
557
557
  end
558
+ def test_regular_filename
559
+ if Rant::Env.on_windows?
560
+ assert_equal "a/b", Rant::Sys.regular_filename('a\b')
561
+ assert_equal "a/b", @sys.regular_filename('a\\\\b')
562
+ else
563
+ assert_equal "a/b", Rant::Sys.regular_filename("a/b")
564
+ assert_equal "a/b", @sys.regular_filename("a//b")
565
+ end
566
+ end
558
567
  end
@@ -11,6 +11,28 @@ require 'fileutils'
11
11
  module Test
12
12
  module Unit
13
13
  class TestCase
14
+ def ext_rb_test(script, opts = {})
15
+ out = nil
16
+ Rant::TestUtil.in_local_temp_dir do
17
+ script_fn = opts[:fn] || "fl.rb"
18
+ dirs = (opts[:dirs] || []).dup
19
+ touch = (opts[:touch] || []).dup
20
+ touch.each { |fn| dirs << File.dirname(fn) }
21
+ dirs.each { |dir|
22
+ next if [".", "..", "/"].include?(dir)
23
+ Rant::Sys.mkdir_p dir
24
+ }
25
+ touch.each { |fn| Rant::Sys.touch fn }
26
+ Rant::Sys.write_to_file script_fn, script
27
+ if opts[:return] == :stdout
28
+ out = `#{Rant::Sys.sp Rant::Env::RUBY_EXE} -w -I#{Rant::Sys.sp ENV['RANT_DEV_LIB_DIR']} #{Rant::Sys.sp script_fn}`
29
+ else
30
+ Rant::Sys.ruby "-w", "-I", ENV["RANT_DEV_LIB_DIR"], script_fn
31
+ end
32
+ assert_exit(0, opts[:msg])
33
+ end
34
+ out
35
+ end
14
36
  def assert_rant(*args)
15
37
  res = 0
16
38
  capture = true
@@ -34,19 +56,18 @@ module Test
34
56
  false
35
57
  end
36
58
  }
37
- if newproc
38
- if capture
39
- # TODO: stderr
40
- `#{Rant::Sys.sp(Rant::Env::RUBY_EXE)} #{Rant::Sys.sp(RANT_BIN)} #{args.flatten.join(' ')}`
41
- else
42
- system("#{Rant::Sys.sp(Rant::Env::RUBY_EXE)} " +
43
- "#{Rant::Sys.sp(RANT_BIN)} " +
44
- "#{args.flatten.join(' ')}")
45
- end
46
- assert_equal(res, $?.exitstatus)
47
- end
48
59
  action = lambda {
49
- if capture
60
+ if newproc
61
+ if capture
62
+ # TODO: stderr
63
+ out = `#{Rant::Sys.sp(Rant::Env::RUBY_EXE)} #{Rant::Sys.sp(RANT_BIN)} #{args.flatten.join(' ')}`
64
+ else
65
+ system("#{Rant::Sys.sp(Rant::Env::RUBY_EXE)} " +
66
+ "#{Rant::Sys.sp(RANT_BIN)} " +
67
+ "#{args.flatten.join(' ')}")
68
+ end
69
+ assert_equal(res, $?.exitstatus)
70
+ elsif capture
50
71
  out, err = capture_std do
51
72
  assert_equal(res, ::Rant::RantApp.new.run(*args))
52
73
  end
@@ -66,9 +87,10 @@ module Test
66
87
  end
67
88
  return out, err
68
89
  end
69
- def assert_exit(status = 0)
70
- assert_equal(status, $?.exitstatus,
71
- "exit status expected to be #{status} but is #{$?.exitstatus}")
90
+ def assert_exit(status = 0, msg = nil)
91
+ msg ||= "exit status expected to be " +
92
+ "#{status} but is #{$?.exitstatus}"
93
+ assert_equal(status, $?.exitstatus, msg)
72
94
  end
73
95
  def assert_file_content(fn, content, *opts)
74
96
  assert(test(?f, fn), "`#{fn}' doesn't exist")
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.0
7
- date: 2005-11-22 00:00:00 +01:00
6
+ version: 0.5.2
7
+ date: 2005-12-12 00:00:00 +01:00
8
8
  summary: Rant is a Ruby based build tool.
9
9
  require_paths:
10
10
  - lib
@@ -33,19 +33,19 @@ authors:
33
33
  files:
34
34
  - NEWS
35
35
  - README
36
+ - INSTALL
37
+ - COPYING
36
38
  - Rantfile
37
39
  - install.rb
40
+ - setup.rb
38
41
  - run_rant
39
42
  - run_import
40
- - setup.rb
41
- - INSTALL
42
- - COPYING
43
43
  - bin/rant
44
44
  - bin/rant-import
45
45
  - lib/rant
46
46
  - lib/rant.rb
47
47
  - lib/rant/c
48
- - lib/rant/rantenv.rb
48
+ - lib/rant/filelist.rb
49
49
  - lib/rant/cs_compiler.rb
50
50
  - lib/rant/rantlib.rb
51
51
  - lib/rant/progress.rb
@@ -60,6 +60,7 @@ files:
60
60
  - lib/rant/archive
61
61
  - lib/rant/metautils.rb
62
62
  - lib/rant/import.rb
63
+ - lib/rant/init.rb
63
64
  - lib/rant/c/include.rb
64
65
  - lib/rant/import/c
65
66
  - lib/rant/import/sys
@@ -94,7 +95,10 @@ files:
94
95
  - lib/rant/import/nodes/default.rb
95
96
  - lib/rant/import/nodes/signed.rb
96
97
  - lib/rant/import/win32/rubycmdwrapper.rb
98
+ - lib/rant/import/filelist/core.rb
97
99
  - lib/rant/import/filelist/more.rb
100
+ - lib/rant/import/filelist/std.rb
101
+ - lib/rant/import/filelist/inspect.rb
98
102
  - lib/rant/import/package/tgz.rb
99
103
  - lib/rant/import/package/zip.rb
100
104
  - lib/rant/import/archive/tgz.rb
@@ -110,6 +114,7 @@ files:
110
114
  - lib/rant/archive/rubyzip/ioextras.rb
111
115
  - lib/rant/archive/rubyzip/tempfile_bugfixed.rb
112
116
  - test/c
117
+ - test/lib
113
118
  - test/test_dyn_dependencies.rb
114
119
  - test/test_filetask.rb
115
120
  - test/test_examples.rb
@@ -150,6 +155,7 @@ files:
150
155
  - test/standalone.rf
151
156
  - test/c/source.c
152
157
  - test/c/test_parse_includes.rb
158
+ - test/lib/test_filelist.rb
153
159
  - test/project_rb1/bin
154
160
  - test/project_rb1/lib
155
161
  - test/project_rb1/test
@@ -280,7 +286,6 @@ files:
280
286
  - test/subdirs2/sub1/sub.rant
281
287
  - test/subdirs2/sub00/sub.rant
282
288
  - test/deprecated/README
283
- - test/deprecated/test_0_5_2.rb
284
289
  - test/deprecated/test_0_5_4.rb
285
290
  - test/deprecated/test_0_6_0.rb
286
291
  - doc/rantfile.rdoc
@@ -289,7 +294,9 @@ files:
289
294
  - doc/advanced.rdoc
290
295
  - doc/subdirs.rdoc
291
296
  - doc/rubyproject.rdoc
297
+ - doc/filelist.rdoc
292
298
  - doc/c.rdoc
299
+ - doc/rubylib.rdoc
293
300
  - doc/homepage
294
301
  - doc/sys.rdoc
295
302
  - doc/rant.rdoc
@@ -297,6 +304,7 @@ files:
297
304
  - doc/rant_vs_rake.rdoc
298
305
  - doc/rant.1
299
306
  - doc/csharp.rdoc
307
+ - doc/sys_filelist.rdoc
300
308
  - doc/rant-import.rdoc
301
309
  - doc/examples
302
310
  - doc/package.rdoc
@@ -387,11 +395,14 @@ extra_rdoc_files:
387
395
  - doc/advanced.rdoc
388
396
  - doc/subdirs.rdoc
389
397
  - doc/rubyproject.rdoc
398
+ - doc/filelist.rdoc
390
399
  - doc/c.rdoc
400
+ - doc/rubylib.rdoc
391
401
  - doc/sys.rdoc
392
402
  - doc/rant.rdoc
393
403
  - doc/rant_vs_rake.rdoc
394
404
  - doc/csharp.rdoc
405
+ - doc/sys_filelist.rdoc
395
406
  - doc/rant-import.rdoc
396
407
  - doc/package.rdoc
397
408
  - doc/command.rdoc