rant 0.3.2 → 0.3.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.
@@ -0,0 +1,26 @@
1
+
2
+ require 'test/unit'
3
+ require 'rant/rantlib'
4
+ require 'tutil'
5
+ require 'fileutils'
6
+
7
+ # Ensure we run in testproject directory.
8
+ $testDir ||= File.expand_path(File.dirname(__FILE__))
9
+
10
+ class TestSource < Test::Unit::TestCase
11
+ def setup
12
+ Dir.chdir($testDir) unless Dir.pwd == $testDir
13
+ end
14
+ def teardown
15
+ capture_std do
16
+ assert_equal(0, Rant.run("clean"))
17
+ end
18
+ end
19
+ def test_task_for_source
20
+ capture_std do
21
+ assert_equal(0, Rant.run("auto.t"))
22
+ end
23
+ assert(test(?f, "auto.rf"))
24
+ assert(test(?f, "auto.t"))
25
+ end
26
+ end
data/test/test_task.rb CHANGED
@@ -42,7 +42,7 @@ class TestTask < Test::Unit::TestCase
42
42
  task.invoke
43
43
  }
44
44
  assert(task.fail?)
45
- assert(task.run?, "although task failed, it was ran")
45
+ assert(task.invoked?, "although task failed, it was invoked")
46
46
  end
47
47
 
48
48
  def test_dependant
@@ -75,7 +75,7 @@ class TestTask < Test::Unit::TestCase
75
75
 
76
76
  def test_task
77
77
  run = false
78
- t = Rant.task :t do |t|
78
+ t = Rant.rac.task :t do |t|
79
79
  run = true
80
80
  end
81
81
  t.invoke
@@ -84,7 +84,7 @@ class TestTask < Test::Unit::TestCase
84
84
 
85
85
  def test_dep_on_self
86
86
  run = false
87
- t = Rant.task :t => "t" do |t|
87
+ t = Rant.rac.task :t => "t" do |t|
88
88
  run = true
89
89
  end
90
90
  th = Thread.new { t.invoke }
@@ -94,15 +94,36 @@ class TestTask < Test::Unit::TestCase
94
94
  assert(run,
95
95
  "task should get run despite dependency on itself")
96
96
  end
97
+ def test_circular_dependency
98
+ t1r = false
99
+ t2r = false
100
+ t1 = Rant.rac.task :t1 => :t2 do |t|
101
+ assert(t2r)
102
+ t1r = true
103
+ end
104
+ t2 = Rant.rac.task :t2 => :t1 do |t|
105
+ t2r = true
106
+ end
107
+ out, err = capture_std do
108
+ th = Thread.new { t1.invoke }
109
+ assert_equal(th, th.join(0.5),
110
+ "task should detect circular dependency")
111
+ end
112
+ assert(t1r)
113
+ assert(t2r)
114
+ assert_match(/\[WARNING\]/, err,
115
+ "Rant should print a warning to stderr about circular" +
116
+ "dependency")
117
+ end
97
118
  def test_dep_on_self_in_deplist
98
119
  rl = []
99
- t1 = Rant.task :t1 do |t|
120
+ t1 = Rant.rac.task :t1 do |t|
100
121
  rl << t.name
101
122
  end
102
- t2 = Rant.task :t2 do |t|
123
+ t2 = Rant.rac.task :t2 do |t|
103
124
  rl << t.name
104
125
  end
105
- t3 = Rant.task :t3 => [:t1, :t3, :t2] do |t|
126
+ t3 = Rant.rac.task :t3 => [:t1, :t3, :t2] do |t|
106
127
  rl << t.name
107
128
  end
108
129
  th = Thread.new { t3.invoke }
data/test/test_var.rb ADDED
@@ -0,0 +1,102 @@
1
+
2
+ require 'test/unit'
3
+ require 'rant/rantlib'
4
+ require 'fileutils'
5
+ require 'tutil'
6
+
7
+ $testDir ||= File.expand_path(File.dirname(__FILE__))
8
+
9
+ class TestVar < Test::Unit::TestCase
10
+ RV = Rant::RantVar
11
+ RS = Rant::RantVar::Space
12
+ def setup
13
+ # Ensure we run in test directory.
14
+ Dir.chdir($testDir) unless Dir.pwd == $testDir
15
+ @rac = Rant::RantApp.new
16
+ @cx = @rac.context
17
+ end
18
+ def teardown
19
+ end
20
+ def test_space
21
+ s = nil
22
+ assert_nothing_raised {
23
+ s = RS.new
24
+ assert_nil(s[:a])
25
+ s[:a] = 1
26
+ assert_equal(1, s["a"])
27
+ assert_equal(1, s[:a])
28
+ s[:b] = "b"
29
+ assert_equal("b", s.query(:b))
30
+ assert_same(s[:b], s["b"])
31
+ assert_same(s.query("b"), s["b"])
32
+ s.query :a, :Integer, 2
33
+ assert_equal(2, s[:a])
34
+ s.query :c, :Integer
35
+ assert_equal(0, s[:c])
36
+ }
37
+ end
38
+ def test_rac_var_ignore
39
+ assert_equal([], @cx.var(:ignore))
40
+ @cx.var[:ignore] = "CVS"
41
+ assert_equal(%w(CVS), @cx.var["ignore"])
42
+ end
43
+ def test_invalid_for_constraint
44
+ @cx.var :a, :Integer
45
+ assert_equal(0, @cx.var[:a])
46
+ assert_raises(Rant::RantVar::ConstraintError) {
47
+ @cx.var[:a] = "x"
48
+ }
49
+ assert_equal(0, @cx.var[:a])
50
+ end
51
+ def test_env
52
+ ENV["RANT_TEST_VAL"] = "val"
53
+ @cx.var.env "RANT_TEST_VAL"
54
+ assert_equal("val", @cx.var["RANT_TEST_VAL"])
55
+ assert_equal("val", @cx.var("RANT_TEST_VAL"))
56
+ @cx.var[:RANT_TEST_VAL] = "new"
57
+ assert_equal("new", @cx.var["RANT_TEST_VAL"])
58
+ assert_equal("new", ENV["RANT_TEST_VAL"])
59
+ env_val2 = ENV["RANT_TEST_VAL2"]
60
+ @cx.var["RANT_TEST_VAL2"] = "val2"
61
+ assert_equal(env_val2, ENV["RANT_TEST_VAL2"])
62
+ assert_equal("val2", @cx.var("RANT_TEST_VAL2"))
63
+ end
64
+ def test_late_env
65
+ @cx.var "rtv3" => "val3"
66
+ @cx.var.env "rtv3", "rtv4"
67
+ assert_equal("val3", @cx.var["rtv3"])
68
+ assert_equal("val3", ENV["rtv3"])
69
+ ENV["rtv4"] = "val4"
70
+ assert_equal("val4", @cx.var["rtv4"])
71
+ end
72
+ def test_env_with_array
73
+ @cx.var "rtv6" => "val6"
74
+ @cx.var.env %w(rtv6 rtv7)
75
+ assert_equal("val6", @cx.var["rtv6"])
76
+ assert_equal("val6", ENV["rtv6"])
77
+ ENV["rtv7"] = "val7"
78
+ assert_equal("val7", @cx.var["rtv7"])
79
+ end
80
+ def test_defaults
81
+ @rac.args.replace %w(-fvar.rf)
82
+ capture_std do
83
+ assert_equal(0, @rac.run)
84
+ end
85
+ assert(test(?f, "default_1.t"))
86
+ assert(test(?f, "default_2.t"))
87
+ capture_std do
88
+ assert_equal(0, Rant::RantApp.new(%w(-fvar.rf clean)).run)
89
+ end
90
+ end
91
+ def test_override
92
+ @rac.args.replace %w(v1=val1.t v2=val2.t -fvar.rf)
93
+ capture_std do
94
+ assert_equal(0, @rac.run)
95
+ end
96
+ assert(test(?f, "val1.t"))
97
+ assert(test(?f, "default_2.t"))
98
+ capture_std do
99
+ assert_equal(0, Rant::RantApp.new(%w(-fvar.rf clean)).run)
100
+ end
101
+ end
102
+ end
data/test/toplevel.rf CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- include Sys
2
+ include Rant::Sys
3
3
 
4
4
  def tf fn
5
5
  touch fn
data/test/var.rf ADDED
@@ -0,0 +1,19 @@
1
+
2
+ var "v1" => "default_1.t"
3
+ var["v2"] = "default_2.t"
4
+
5
+ task :default => [var[:v1], var[:v2]]
6
+
7
+ file var[:v1] do |t|
8
+ sys.touch t.name
9
+ end
10
+
11
+ file var[:v2] do |t|
12
+ sys.touch t.name
13
+ end
14
+
15
+ task :clean do
16
+ sys.rm_f sys["*.t"]
17
+ end
18
+
19
+ # vim:ft=ruby
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.2
7
- date: 2005-04-03
6
+ version: 0.3.4
7
+ date: 2005-04-17
8
8
  summary: Rant is a Ruby based build tool.
9
9
  require_paths:
10
10
  - lib
@@ -33,6 +33,7 @@ files:
33
33
  - TODO
34
34
  - README
35
35
  - Rantfile
36
+ - install.rb
36
37
  - run_rant
37
38
  - devel-notes
38
39
  - rantmethods.rb
@@ -63,16 +64,22 @@ files:
63
64
  - test/test_lighttask.rb
64
65
  - test/Rantfile
65
66
  - test/ts_all.rb
67
+ - test/test_rule.rb
66
68
  - test/test_task.rb
67
69
  - test/project_rb1
70
+ - test/rule.rf
68
71
  - test/subdirs
69
72
  - test/test_metatask.rb
70
73
  - test/test_env.rb
71
74
  - test/toplevel.rf
75
+ - test/test_source.rb
72
76
  - test/plugin
73
77
  - test/test_rant_interface.rb
74
78
  - test/test_sys.rb
79
+ - test/test_var.rb
75
80
  - test/tutil.rb
81
+ - test/var.rf
82
+ - test/test_dirtask.rb
76
83
  - test/project1
77
84
  - test/project2
78
85
  - test/test_filelist.rb
@@ -117,6 +124,7 @@ files:
117
124
  - test/project2/sub1/Rantfile
118
125
  - doc/rantfile.rdoc
119
126
  - doc/configure.rdoc
127
+ - doc/advanced.rdoc
120
128
  - doc/rubyproject.rdoc
121
129
  - doc/rant.rdoc
122
130
  - doc/csharp.rdoc
@@ -142,6 +150,7 @@ rdoc_options:
142
150
  extra_rdoc_files:
143
151
  - doc/rantfile.rdoc
144
152
  - doc/configure.rdoc
153
+ - doc/advanced.rdoc
145
154
  - doc/rubyproject.rdoc
146
155
  - doc/rant.rdoc
147
156
  - doc/csharp.rdoc