rant 0.4.4 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. data/NEWS +38 -0
  2. data/README +4 -2
  3. data/Rantfile +50 -12
  4. data/doc/examples/c_cpp/c++/problem_1_1/another_test.cpp +6 -0
  5. data/doc/examples/c_cpp/c++/problem_1_1/another_test.h +5 -0
  6. data/doc/examples/c_cpp/c++/problem_1_1/main.cpp +12 -0
  7. data/doc/examples/c_cpp/c++/problem_1_1/test.cpp +6 -0
  8. data/doc/examples/c_cpp/c++/problem_1_1/test.h +5 -0
  9. data/doc/examples/c_cpp/c++/template.rf +15 -0
  10. data/doc/examples/c_cpp/c/problem_1_1/another_test.c +6 -0
  11. data/doc/examples/c_cpp/c/problem_1_1/another_test.h +7 -0
  12. data/doc/examples/c_cpp/c/problem_1_1/main.c +12 -0
  13. data/doc/examples/c_cpp/c/problem_1_1/test.c +6 -0
  14. data/doc/examples/c_cpp/c/problem_1_1/test.h +7 -0
  15. data/doc/examples/c_cpp/c/template.rf +15 -0
  16. data/doc/examples/c_cpp/root.rant +46 -0
  17. data/doc/homepage/index.html +115 -0
  18. data/doc/homepage/rant_home.css +98 -0
  19. data/doc/rant.1 +129 -0
  20. data/doc/rant.rdoc +5 -6
  21. data/doc/rantfile.rdoc +55 -32
  22. data/doc/subdirs.rdoc +147 -0
  23. data/lib/rant.rb +47 -49
  24. data/lib/rant/coregen.rb +20 -20
  25. data/lib/rant/import.rb +63 -11
  26. data/lib/rant/import/archive.rb +47 -15
  27. data/lib/rant/import/archive/tgz.rb +1 -1
  28. data/lib/rant/import/autoclean.rb +28 -26
  29. data/lib/rant/import/c/dependencies.rb +1 -1
  30. data/lib/rant/import/directedrule.rb +1 -4
  31. data/lib/rant/import/metadata.rb +30 -7
  32. data/lib/rant/import/nodes/default.rb +67 -13
  33. data/lib/rant/import/rubypackage.rb +1 -1
  34. data/lib/rant/import/rubytest.rb +25 -19
  35. data/lib/rant/import/signedfile.rb +14 -8
  36. data/lib/rant/import/sys/more.rb +22 -0
  37. data/lib/rant/import/sys/tgz.rb +43 -0
  38. data/lib/rant/import/sys/zip.rb +42 -0
  39. data/lib/rant/node.rb +19 -13
  40. data/lib/rant/plugin/configure.rb +1 -1
  41. data/lib/rant/progress.rb +33 -0
  42. data/lib/rant/rantenv.rb +7 -7
  43. data/lib/rant/rantlib.rb +246 -256
  44. data/lib/rant/rantsys.rb +61 -22
  45. data/lib/rant/rantvar.rb +7 -9
  46. data/misc/TODO +18 -0
  47. data/misc/devel-notes +4 -1
  48. data/test/Rantfile +17 -3
  49. data/test/deprecated/README +6 -0
  50. data/test/deprecated/test_0_4_8.rb +41 -0
  51. data/test/deprecated/test_0_5_2.rb +33 -0
  52. data/test/import/md5/root.rant +9 -0
  53. data/test/import/md5/test_md5.rb +45 -0
  54. data/test/import/metadata/Rantfile +2 -2
  55. data/test/import/metadata/test_metadata.rb +2 -2
  56. data/test/import/package/test_package.rb +40 -1
  57. data/test/import/signedfile/sub1/Rantfile +1 -1
  58. data/test/import/sys/data/pkg.tgz +0 -0
  59. data/test/import/sys/data/pkg.zip +0 -0
  60. data/test/import/sys/data/pkg/bin/test +0 -0
  61. data/test/import/sys/data/pkg/bin/test.o +0 -0
  62. data/test/import/sys/data/pkg/test.c +6 -0
  63. data/test/import/sys/data/pkg/test.h +7 -0
  64. data/test/import/sys/data/pkg2.zip +0 -0
  65. data/test/import/sys/test_tgz.rb +38 -0
  66. data/test/import/sys/test_zip.rb +68 -0
  67. data/test/import/sys/tgz.rf +6 -0
  68. data/test/import/sys/zip.rf +15 -0
  69. data/test/project2/{rantfile.rb → root.rant} +0 -0
  70. data/test/project2/test_project.rb +3 -8
  71. data/test/project_rb1/{rantfile.rb → rantfile} +1 -1
  72. data/test/project_rb1/test_project_rb1.rb +3 -5
  73. data/test/rant-import/test_rant-import.rb +22 -10
  74. data/test/subdirs/sub1/Rantfile +1 -1
  75. data/test/subdirs/sub2/{rantfile.rb → rantfile} +0 -0
  76. data/test/subdirs/sub2/sub/rantfile +1 -1
  77. data/test/subdirs2/root.rant +36 -0
  78. data/test/subdirs2/sub00/sub.rant +8 -0
  79. data/test/subdirs2/sub1/sub.rant +13 -0
  80. data/test/subdirs2/test_subdirs2.rb +239 -0
  81. data/test/test_examples.rb +91 -0
  82. data/test/test_filetask.rb +51 -11
  83. data/test/test_rant_interface.rb +24 -0
  84. data/test/test_rantfile_api.rb +54 -2
  85. data/test/test_sourcenode.rb +30 -0
  86. data/test/test_sys.rb +143 -15
  87. data/test/test_task.rb +16 -22
  88. data/test/tutil.rb +22 -38
  89. metadata +67 -9
@@ -24,7 +24,7 @@ class TestMetaData < Test::Unit::TestCase
24
24
  def test_subdir
25
25
  out, err = assert_rant("subdir=true", "sub/b")
26
26
  assert(err.empty?)
27
- assert_equal("nil\nnil\ntouch b\n", out)
27
+ assert_equal("nil\nnil\n(in sub)\ntouch b\n", out)
28
28
  assert(test(?f, ".rant.meta"))
29
29
  assert(test(?f, "sub/.rant.meta"))
30
30
  out, err = assert_rant("subdir=true", "sub/b")
@@ -37,7 +37,7 @@ class TestMetaData < Test::Unit::TestCase
37
37
  FileUtils.rm ".rant.meta"
38
38
  out = run_ruby("make.t", "subdir=true", "sub/b")
39
39
  assert_exit
40
- assert_equal("nil\nnil\ntouch b\n", out)
40
+ assert_equal("nil\nnil\n(in sub)\ntouch b\n", out)
41
41
  assert(test(?f, ".rant.meta"))
42
42
  assert(test(?f, "sub/.rant.meta"))
43
43
  out = run_ruby("make.t", "subdir=true", "sub/b")
@@ -1,10 +1,12 @@
1
1
 
2
2
  require 'test/unit'
3
3
  require 'tutil'
4
+ require 'rant/import/sys/tgz'
4
5
 
5
6
  $testIPackageDir ||= File.expand_path(File.dirname(__FILE__))
6
7
 
7
8
  class TestImportPackage < Test::Unit::TestCase
9
+ include Rant::TestUtil
8
10
  def setup
9
11
  # Ensure we run in test directory.
10
12
  Dir.chdir $testIPackageDir
@@ -23,7 +25,12 @@ class TestImportPackage < Test::Unit::TestCase
23
25
  FileUtils.cp archive, "u.t"
24
26
  FileUtils.cd "u.t"
25
27
  archive = File.basename archive
26
- unpack_archive atype, archive
28
+ case atype
29
+ when :tgz: Rant::Sys.unpack_tgz(archive)
30
+ when :zip: Rant::Sys.unpack_zip(archive)
31
+ else
32
+ raise "unknown archive type -- #{atype}"
33
+ end
27
34
  if @pkg_dir
28
35
  assert(test(?d, @pkg_dir))
29
36
  FileUtils.cd @pkg_dir
@@ -558,4 +565,36 @@ class TestImportPackage < Test::Unit::TestCase
558
565
  ensure
559
566
  FileUtils.rm_f %w(make.t empty.rf empty.t.tgz)
560
567
  end
568
+ def test_package_tgz_flag_manifest_opt_files
569
+ in_local_temp_dir do
570
+ write_to_file "root.rant", <<-EOF
571
+ import "md5", "package/tgz", "autoclean"
572
+ gen Package::Tgz, "a-b", :manifest, :files => sys["*"].exclude("u")
573
+ gen AutoClean
574
+ EOF
575
+ write_to_file "a", "a\n"
576
+ out, err = assert_rant "a-b.tgz"
577
+ assert err.empty?
578
+ assert !out.empty?
579
+ assert(test(?f, "a-b.tgz"))
580
+ assert(test(?f, "MANIFEST"))
581
+ Rant::Sys.unpack_tgz "a-b.tgz", :in => "u"
582
+ assert_nothing_raised do
583
+ assert Rant::Sys.compare_file("root.rant", "u/a-b/root.rant")
584
+ assert_equal "a\n", File.read("u/a-b/a")
585
+ entries = File.read("u/a-b/MANIFEST").split(/\n/)
586
+ assert_equal 3, entries.size
587
+ assert entries.include?("MANIFEST")
588
+ assert entries.include?("a")
589
+ assert entries.include?("root.rant")
590
+ end
591
+ out, err = assert_rant "a-b.tgz"
592
+ assert err.empty?
593
+ assert out.empty?
594
+ assert_rant "autoclean"
595
+ assert !test(?e, "a-b.tgz")
596
+ assert !test(?e, "a-b")
597
+ assert !test(?e, ".rant.meta")
598
+ end
599
+ end
561
600
  end
@@ -1,4 +1,4 @@
1
1
 
2
- gen SignedFile, "s1.t" => "#f2.t" do |t|
2
+ gen SignedFile, "s1.t" => "@f2.t" do |t|
3
3
  write_content(t.name)
4
4
  end
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,6 @@
1
+
2
+ #include "test.h"
3
+
4
+ void test()
5
+ {
6
+ }
@@ -0,0 +1,7 @@
1
+
2
+ #ifndef TEST_H
3
+ #define TEST_H
4
+
5
+ void test(void);
6
+
7
+ #endif
Binary file
@@ -0,0 +1,38 @@
1
+
2
+ require 'test/unit'
3
+ require 'tutil'
4
+
5
+ $test_import_sys_dir ||= File.expand_path(File.dirname(__FILE__))
6
+
7
+ class TestImportSysTgz < Test::Unit::TestCase
8
+ include Rant::TestUtil
9
+
10
+ def setup
11
+ # Ensure we run in test directory.
12
+ Dir.chdir($test_import_sys_dir)
13
+ end
14
+ def test_unpack_tgz
15
+ assert !test(?e, "pkg")
16
+ begin
17
+ out, err = assert_rant "-ftgz.rf"
18
+ assert err.empty?
19
+ assert !out.empty?
20
+ assert out.split(/\n/).size < 3
21
+ dirs = %w(pkg pkg/bin)
22
+ files = %w(pkg/test.c pkg/test.h pkg/bin/test pkg/bin/test.o)
23
+ dirs.each { |dir|
24
+ assert test(?d, dir), "dir `#{dir}' missing"
25
+ }
26
+ files.each { |fn|
27
+ src_fn = File.join "data", fn
28
+ assert test(?f, fn), "file `#{fn}' missing"
29
+ assert Rant::Sys.compare_file(fn, src_fn), "#{fn} corrupted"
30
+ }
31
+ actual = Rant::FileList["pkg", "pkg/**/*", "pkg/**/.*"]
32
+ actual.shun ".", ".."
33
+ assert_equal((files + dirs).sort, actual.sort)
34
+ ensure
35
+ Rant::Sys.rm_rf "pkg"
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,68 @@
1
+
2
+ require 'test/unit'
3
+ require 'tutil'
4
+
5
+ $test_import_sys_dir ||= File.expand_path(File.dirname(__FILE__))
6
+
7
+ class TestImportSysZip < Test::Unit::TestCase
8
+ include Rant::TestUtil
9
+
10
+ def setup
11
+ # Ensure we run in test directory.
12
+ Dir.chdir($test_import_sys_dir)
13
+ end
14
+ def test_unpack_zip_in_dir
15
+ assert !test(?e, "dir.t")
16
+ out, err = assert_rant "-fzip.rf"
17
+ assert err.empty?
18
+ assert !out.empty?
19
+ assert test(?f, "t.zip")
20
+ assert out.split(/\n/).size < 6
21
+ dirs = %w(pkg pkg/bin)
22
+ files = %w(pkg/test.c pkg/test.h pkg/bin/test pkg/bin/test.o)
23
+ dirs.each { |dir|
24
+ dir = File.join("dir.t", dir)
25
+ assert test(?d, dir), "dir `#{dir}' missing"
26
+ }
27
+ files.each { |fn|
28
+ src_fn = File.join "data", fn
29
+ fn = File.join("dir.t", fn)
30
+ assert test(?f, fn), "file `#{fn}' missing"
31
+ assert Rant::Sys.compare_file(fn, src_fn), "#{fn} corrupted"
32
+ }
33
+ actual = Rant::FileList["dir.t/**/*", "dir.t/**/.*"]
34
+ actual.shun ".", ".."
35
+ actual.map! { |e| e.sub(/^dir\.t\//, '') }
36
+ assert_equal((files + dirs).sort, actual.sort)
37
+ out, err = assert_rant "-fzip.rf"
38
+ assert err.empty?
39
+ assert out.empty?
40
+ out, err = assert_rant "-fzip.rf", "src=data/pkg2.zip"
41
+ assert err.empty?
42
+ assert !out.empty?
43
+ assert out.split(/\n/).size < 6
44
+ dirs = %w(pkg pkg/bin)
45
+ files = %w(pkg/test.c pkg/test.h pkg/bin/test)
46
+ dirs.each { |dir|
47
+ dir = File.join("dir.t", dir)
48
+ assert test(?d, dir), "dir `#{dir}' missing"
49
+ }
50
+ files.each { |fn|
51
+ src_fn = File.join "data", fn
52
+ fn = File.join("dir.t", fn)
53
+ assert test(?f, fn), "file `#{fn}' missing"
54
+ assert Rant::Sys.compare_file(fn, src_fn), "#{fn} corrupted"
55
+ }
56
+ actual = Rant::FileList["dir.t/**/*", "dir.t/**/.*"]
57
+ actual.shun ".", ".."
58
+ actual.map! { |e| e.sub(/^dir\.t\//, '') }
59
+ assert_equal((files + dirs).sort, actual.sort)
60
+ out, err = assert_rant "-fzip.rf", "src=data/pkg2.zip"
61
+ assert err.empty?
62
+ assert out.empty?
63
+ assert_rant "-fzip.rf", "autoclean"
64
+ assert !test(?e, "dir.t")
65
+ assert !test(?e, "t.zip")
66
+ assert Dir["**/*.rant.meta"].empty?
67
+ end
68
+ end
@@ -0,0 +1,6 @@
1
+
2
+ import "sys/tgz"
3
+
4
+ task :unpack do
5
+ sys.unpack_tgz "data/pkg.tgz"
6
+ end
@@ -0,0 +1,15 @@
1
+
2
+ import "md5", "sys/zip", "autoclean"
3
+
4
+ var :src => "data/pkg.zip"
5
+
6
+ gen Directory, "dir.t" => "t.zip" do
7
+ sys.rm_rf "dir.t/pkg"
8
+ sys.unpack_zip "t.zip", :in => "dir.t"
9
+ end
10
+
11
+ file "t.zip" => var[:src] do |t|
12
+ sys.cp t.source, t.name
13
+ end
14
+
15
+ gen AutoClean
File without changes
@@ -23,9 +23,7 @@ class TestProject2 < Test::Unit::TestCase
23
23
  Dir.chdir($testProject2Dir) unless Dir.pwd == $testProject2Dir
24
24
  end
25
25
  def teardown
26
- capture_std do
27
- assert_equal(app(%w(-f rantfile.rb -f buildfile clean sub1/clean)).run, 0)
28
- end
26
+ assert_rant(%w(-f root.rant -f buildfile clean sub1/clean))
29
27
  assert(Dir["r_f*"].empty?,
30
28
  "r_f* files should have been removed by `clean'")
31
29
  assert(Dir["b_f*"].empty?,
@@ -51,8 +49,7 @@ class TestProject2 < Test::Unit::TestCase
51
49
  end
52
50
  def test_load_rantfile
53
51
  capture_std do
54
- app("b_f2")
55
- @app.rootdir = $testProject2Dir
52
+ app("b_f2", "-C", $testProject2Dir)
56
53
  assert_equal(:return_val, @app.source("buildfile"),
57
54
  "source should return value of last expression in Rantfile")
58
55
  assert_equal(@app.run, 0)
@@ -77,11 +74,9 @@ class TestProject2 < Test::Unit::TestCase
77
74
  end
78
75
  def test_opth_directory
79
76
  app %w(insub1_s1f1)
80
- #Rant[:directory] = "sub1"
81
77
  @app[:verbose] = 2
82
- @app[:directory] = "sub1"
83
78
  capture_std do
84
- assert_equal(@app.run, 0)
79
+ assert_equal(@app.run("-Csub1"), 0)
85
80
  end
86
81
  assert(Dir.pwd !~ /sub1$/,
87
82
  "rant should cd to original dir before returning from `run'")
@@ -1,7 +1,7 @@
1
1
  import %w(rubytest rubydoc rubypackage clean)
2
2
 
3
3
  lib_files = Dir["lib/**/*.rb"]
4
- dist_files = lib_files + %w(rantfile.rb README test_project_rb1.rb) + Dir["{test,bin}/*"]
4
+ dist_files = lib_files + %w(rantfile README test_project_rb1.rb) + Dir["{test,bin}/*"]
5
5
 
6
6
  desc "Run unit tests."
7
7
  gen RubyTest do |t|
@@ -8,7 +8,7 @@ class TestProjectRb1 < Test::Unit::TestCase
8
8
  def setup
9
9
  @manifest = %w(bin lib test bin/wgrep lib/wgrep.rb
10
10
  test/text test/tc_wgrep.rb README test_project_rb1.rb
11
- rantfile.rb)
11
+ rantfile)
12
12
  # Ensure we run in test directory.
13
13
  Dir.chdir($testProjectRb1Dir)
14
14
  end
@@ -94,8 +94,7 @@ class TestProjectRb1 < Test::Unit::TestCase
94
94
  FileUtils.mkdir tmp_dir
95
95
  FileUtils.cp tar_fn, tmp_dir
96
96
  FileUtils.cd tmp_dir do
97
- #`tar xzf #{tar_fn}`
98
- unpack_archive :tgz, tar_fn
97
+ Rant::Sys.unpack_tgz tar_fn
99
98
  assert(test(?d, pkg_base),
100
99
  "`#{pkg_base}' should be root directory of all files in tar")
101
100
  FileUtils.cd pkg_base do
@@ -115,8 +114,7 @@ class TestProjectRb1 < Test::Unit::TestCase
115
114
  FileUtils.mkdir tmp_dir
116
115
  FileUtils.cp zip_fn, tmp_dir
117
116
  FileUtils.cd tmp_dir do
118
- #`unzip -q #{zip_fn}`
119
- unpack_archive :zip, zip_fn
117
+ Rant::Sys.unpack_zip zip_fn
120
118
  assert(test(?d, pkg_base),
121
119
  "`#{pkg_base}' should be root directory of all files in zip")
122
120
  FileUtils.cd pkg_base do
@@ -1,12 +1,13 @@
1
1
 
2
2
  require 'test/unit'
3
- require 'rant/rantlib'
4
3
  require 'tutil'
5
- require 'fileutils'
4
+ require 'rant/import'
6
5
 
7
6
  $testRantImportDir ||= File.expand_path(File.dirname(__FILE__))
8
7
 
9
8
  class TestRantImport < Test::Unit::TestCase
9
+ include Rant::TestUtil
10
+
10
11
  def setup
11
12
  # Ensure we run in test directory.
12
13
  Dir.chdir($testRantImportDir)
@@ -17,12 +18,27 @@ class TestRantImport < Test::Unit::TestCase
17
18
  FileUtils.rm_f Dir["make*"]
18
19
  FileUtils.rm_rf Dir["*.t"]
19
20
  end
21
+ def test_option_help
22
+ out, err = capture_std do
23
+ assert_equal(0, Rant::RantImport.new("--help").run)
24
+ end
25
+ assert err.empty?
26
+ assert out.include?("rant-import")
27
+ assert out.include?("Options are")
28
+ assert out.include?("--help")
29
+ end
20
30
  def test_no_import
21
31
  run_import("--quiet", "make.rb")
22
32
  assert(test(?f, "make.rb"))
33
+ content = File.read("make.rb")
23
34
  assert(!test(?f, "action.t"))
24
35
  assert_equal(run_rant("hello"), run_ruby("make.rb", "hello"))
25
36
  assert(test(?f, "action.t"))
37
+ out, err = capture_std do
38
+ assert_equal(1, Rant::RantImport.new("-iclean", "make.rb").run)
39
+ end
40
+ assert_equal(content, File.read("make.rb"))
41
+ assert_match(/\[ERROR\].*\bmake\.rb\b.*\bexists\b.*--force/m, err)
26
42
  end
27
43
  def test_import_from_custom_lib
28
44
  FileUtils.mkpath "mylib.t/rant/import"
@@ -85,13 +101,11 @@ class TestRantImport < Test::Unit::TestCase
85
101
  end
86
102
  EOF
87
103
  }
88
- open("Rantfile.rb", "w") { |f|
89
- f << <<-EOF
104
+ write_to_file "rantfile", <<-EOF
90
105
  $:.unshift "lib.t"
91
106
  import "sub/t"
92
107
  gen Sub::T, "hello", "test" do end
93
- EOF
94
- }
108
+ EOF
95
109
  out, err = assert_rant
96
110
  assert_match(/.*hello.*\n.*test.*\n.*block_given/, out)
97
111
  run_import("--quiet", "--auto", "ant")
@@ -132,13 +146,11 @@ class TestRantImport < Test::Unit::TestCase
132
146
  end
133
147
  EOF
134
148
  }
135
- open("rantfile.rb", "w") { |f|
136
- f << <<-EOF
149
+ write_to_file "root.rant", <<-EOF
137
150
  $:.unshift "lib.t"
138
151
  import "sub2/t"
139
152
  gen Sub2::T, "hello", "test" do end
140
- EOF
141
- }
153
+ EOF
142
154
  out, err = assert_rant
143
155
  assert_match(/hellotest/, out)
144
156
  run_import("--quiet", "--auto", "ant.rb")
@@ -3,7 +3,7 @@ file "t" do |t|
3
3
  sys.touch t.name
4
4
  end
5
5
 
6
- file "rootdep.t" => "#subdep.t" do |t|
6
+ file "rootdep.t" => "@subdep.t" do |t|
7
7
  test(?f, "../subdep.t") || t.fail
8
8
  sys.touch t.name
9
9
  end
File without changes
@@ -3,7 +3,7 @@ file "rootdep.t" do |t|
3
3
  sys.touch t.name
4
4
  end
5
5
 
6
- file "rootref.t" => "#t" do |t|
6
+ file "rootref.t" => "@t" do |t|
7
7
  test(?f, "../../t") || t.fail
8
8
  sys.touch t.name
9
9
  end
@@ -0,0 +1,36 @@
1
+
2
+ import "autoclean", "subfile"
3
+
4
+ def define_print_task(name)
5
+ task name do |t|
6
+ puts t.full_name
7
+ end
8
+ end
9
+
10
+ desc "show full task name"
11
+ task :a do |t|
12
+ puts t.full_name
13
+ end
14
+
15
+ file "a.t" do |t|
16
+ write t.name
17
+ end
18
+
19
+ file "b.t" do |t|
20
+ write t.name
21
+ end
22
+
23
+ gen SubFile, "t/t", "a.t" => "b.t" do |t|
24
+ write(t.name, "abc")
25
+ end
26
+
27
+ gen AutoClean
28
+
29
+ subdirs sys["sub?"] # doesn't cover sub00, per intent
30
+
31
+ def self.write(fn, content=nil)
32
+ puts "writing to #{fn}"
33
+ open fn, "w" do |f|
34
+ f.write(content || "#{fn}\n")
35
+ end
36
+ end