rant 0.4.2 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/NEWS +14 -0
  2. data/README +13 -7
  3. data/Rantfile +11 -0
  4. data/doc/md5.rdoc +49 -0
  5. data/doc/rantfile.rdoc +1 -1
  6. data/lib/rant/coregen.rb +193 -0
  7. data/lib/rant/import/archive/zip.rb +2 -0
  8. data/lib/rant/import/archive.rb +10 -2
  9. data/lib/rant/import/autoclean.rb +16 -7
  10. data/lib/rant/import/c/dependencies.rb +1 -1
  11. data/lib/rant/import/directedrule.rb +2 -2
  12. data/lib/rant/import/md5.rb +16 -0
  13. data/lib/rant/import/metadata.rb +162 -0
  14. data/lib/rant/import/nodes/default.rb +490 -0
  15. data/lib/rant/import/nodes/signed.rb +84 -0
  16. data/lib/rant/import/package/zip.rb +2 -0
  17. data/lib/rant/import/rubydoc.rb +5 -1
  18. data/lib/rant/import/rubypackage.rb +2 -1
  19. data/lib/rant/import/signature/md5.rb +38 -0
  20. data/lib/rant/import/signedfile.rb +235 -0
  21. data/lib/rant/import/subfile.rb +1 -1
  22. data/lib/rant/import.rb +5 -1
  23. data/lib/rant/node.rb +165 -0
  24. data/lib/rant/plugin/csharp.rb +2 -0
  25. data/lib/rant/rantlib.rb +64 -9
  26. data/lib/rant/rantsys.rb +39 -27
  27. data/lib/rant/rantvar.rb +32 -2
  28. data/misc/TODO +66 -0
  29. data/test/import/c/dependencies/test_on_the_fly.rb +52 -0
  30. data/test/import/metadata/Rantfile +16 -0
  31. data/test/import/metadata/sub/Rantfile +17 -0
  32. data/test/import/metadata/test_metadata.rb +126 -0
  33. data/test/import/nodes/signed/Rantfile +89 -0
  34. data/test/import/nodes/signed/sub1/Rantfile +6 -0
  35. data/test/import/nodes/signed/test_signed.rb +455 -0
  36. data/test/import/package/md5.rf +10 -0
  37. data/test/import/package/test_package.rb +127 -1
  38. data/test/import/signeddirectory/Rantfile +15 -0
  39. data/test/import/signeddirectory/test_signeddirectory.rb +84 -0
  40. data/test/import/signedfile/Rantfile +90 -0
  41. data/test/import/signedfile/sub1/Rantfile +4 -0
  42. data/test/import/signedfile/test_signedfile.rb +338 -0
  43. data/test/project1/Rantfile +0 -9
  44. data/test/project1/test_project.rb +2 -0
  45. data/test/project_rb1/test_project_rb1.rb +27 -10
  46. data/test/rant-import/test_rant-import.rb +46 -9
  47. data/test/subdirs/sub2/sub/rantfile +0 -5
  48. data/test/subdirs/test_subdirs.rb +0 -9
  49. data/test/test_examples.rb +131 -3
  50. data/test/test_filelist.rb +44 -0
  51. data/test/test_sys.rb +19 -1
  52. data/test/test_task.rb +2 -2
  53. data/test/tutil.rb +9 -3
  54. metadata +34 -4
  55. data/lib/rant/rantfile.rb +0 -897
  56. data/test/test_lighttask.rb +0 -68
@@ -102,15 +102,6 @@ class TestSubdirs < Test::Unit::TestCase
102
102
  assert_equal(0, Rant.run("sub2/sub/dt/dt"))
103
103
  end
104
104
  end
105
- def test_lighttask
106
- capture_std do
107
- assert_equal(0, Rant.run("sub2/sub/lt"))
108
- end
109
- assert(test(?f, "sub2/sub/lt"))
110
- capture_std do
111
- assert_equal(0, Rant.run("sub2/sub/lt"))
112
- end
113
- end
114
105
  def test_gen_task
115
106
  capture_std do
116
107
  assert_equal(0, Rant.run("sub2/sub/gt"))
@@ -3,8 +3,9 @@ require 'test/unit'
3
3
  require 'rant/rantlib'
4
4
  require 'tutil'
5
5
 
6
- $examplesDir ||= File.expand_path(
7
- File.join(File.dirname(File.dirname(__FILE__)), "doc", "examples"))
6
+ $examplesDir ||= File.join(
7
+ File.dirname(File.dirname(File.expand_path(__FILE__))),
8
+ "doc", "examples")
8
9
 
9
10
  $cc_is_gcc ||= Rant::Env.find_bin("cc") && Rant::Env.find_bin("gcc")
10
11
  class TestExamples < Test::Unit::TestCase
@@ -31,6 +32,27 @@ class TestExamples < Test::Unit::TestCase
31
32
  assert(!test(?e, "src/lib.o"))
32
33
  assert(!test(?e, "src/main.o"))
33
34
  end
35
+ def test_myprog_md5
36
+ Dir.chdir "myprog"
37
+ assert_match(/Build myprog.*\n.*Remove compiler products/,
38
+ run_rant("-imd5", "--tasks"))
39
+ assert(!test(?f, "myprog"))
40
+ if $cc_is_gcc
41
+ # Warning: we're assuming cc is actually gcc
42
+ run_rant("-imd5")
43
+ assert(test(?f, "myprog"))
44
+ else
45
+ $stderr.puts "*** cc isn't gcc, less example testing ***"
46
+ # less myprog testing
47
+ end
48
+ run_rant("-imd5", "clean")
49
+ assert(!test(?e, "myprog"))
50
+ assert(!test(?e, "src/myprog"))
51
+ assert(!test(?e, "src/lib.o"))
52
+ assert(!test(?e, "src/main.o"))
53
+ ensure
54
+ FileUtils.rm_f Dir["**/.rant.meta"]
55
+ end
34
56
  def test_directedrule
35
57
  Dir.chdir "directedrule"
36
58
  assert_match(/Build foo/, run_rant("-T"))
@@ -42,6 +64,18 @@ class TestExamples < Test::Unit::TestCase
42
64
  run_rant("clean")
43
65
  Dir["**/*.o"].each { |f| assert(!test(?e, f)) }
44
66
  end
67
+ def test_directedrule_md5
68
+ Dir.chdir "directedrule"
69
+ assert_match(/Build foo/, run_rant("-imd5", "-T"))
70
+ assert(!test(?f, "foo"))
71
+ if $cc_is_gcc
72
+ run_rant("-imd5")
73
+ assert(test(?f, "foo"))
74
+ end
75
+ run_rant("-imd5", "clean")
76
+ assert(!test(?e, ".rant.meta"))
77
+ Dir["**/*.o"].each { |f| assert(!test(?e, f)) }
78
+ end
45
79
  def test_c_dependencies
46
80
  Dir.chdir "c_dependencies"
47
81
  assert_match( /\bhello\b.*\n.*\bclean\b.*\n.*\bdistclean\b/,
@@ -66,6 +100,31 @@ class TestExamples < Test::Unit::TestCase
66
100
  assert(!test(?f, "c_dependencies"))
67
101
  assert(!test(?f, "hello"))
68
102
  end
103
+ def test_c_dependencies_md5
104
+ Dir.chdir "c_dependencies"
105
+ assert_match( /\bhello\b.*\n.*\bclean\b.*\n.*\bdistclean\b/,
106
+ run_rant("-imd5", "-T"))
107
+ assert(!test(?f, "hello"))
108
+ if $cc_is_gcc
109
+ run_rant("-imd5")
110
+ assert(test(?f, "hello"))
111
+ else
112
+ run_rant("-imd5", "c_dependencies")
113
+ end
114
+ run_rant("-imd5", "clean")
115
+ assert(Dir["**/*.o"].empty?)
116
+ assert(!test(?f, "hello"))
117
+ assert(test(?f, "c_dependencies"))
118
+ if $cc_is_gcc
119
+ run_rant("-imd5")
120
+ assert(test(?f, "hello"))
121
+ end
122
+ run_rant("-imd5", "distclean")
123
+ assert(!test(?e, ".rant.meta"))
124
+ assert(Dir["**/*.o"].empty?)
125
+ assert(!test(?f, "c_dependencies"))
126
+ assert(!test(?f, "hello"))
127
+ end
69
128
  def test_c_cpp_examples
70
129
  Dir.chdir "c_cpp_examples"
71
130
  proj_pwd = Dir.pwd
@@ -97,7 +156,7 @@ EOF
97
156
  if Rant::Env.find_bin("gcc") && Rant::Env.find_bin("g++")
98
157
  out = run_rant
99
158
  assert_exit
100
- assert_equal(2, out.scan("Hello, world!").size)
159
+ assert_equal(2, out.scan(/Hello\, world\!/).size)
101
160
  out, err = assert_rant("build")
102
161
  assert(out.empty?)
103
162
  assert(err.empty?)
@@ -133,4 +192,73 @@ EOF
133
192
  FileUtils.rm_f "c/problem_1_1/Rantfile"
134
193
  FileUtils.rm_f "c++/problem_1_1/Rantfile"
135
194
  end
195
+ def test_c_cpp_examples_md5
196
+ Dir.chdir "c_cpp_examples"
197
+ proj_pwd = Dir.pwd
198
+ out, err = assert_rant("-imd5", "--tasks")
199
+ # TODO: replace with a not-so-strict regex
200
+ op = <<EOF
201
+ rant run # Run all C and C++ tests.
202
+ rant build # Build all.
203
+ rant autoclean # Remove all autogenerated files.
204
+ rant pkg/c_cpp_exercises.tgz # Create source package.
205
+ EOF
206
+ assert_equal(op, out)
207
+ assert(err.empty?)
208
+ gen_files = %w(
209
+ c/problem_1_1/Rantfile
210
+ c++/problem_1_1/Rantfile
211
+ c/problem_1_1/c_dependencies
212
+ c++/problem_1_1/c_dependencies
213
+ c/problem_1_1/test
214
+ c++/problem_1_1/test
215
+ c/problem_1_1/main.o
216
+ c++/problem_1_1/main.o
217
+ c/problem_1_1/test.o
218
+ c++/problem_1_1/test.o
219
+ c/problem_1_1/another_test.o
220
+ c++/problem_1_1/another_test.o
221
+ pkg
222
+ )
223
+ if Rant::Env.find_bin("gcc") && Rant::Env.find_bin("g++")
224
+ out = run_rant("-imd5")
225
+ assert_exit
226
+ assert_equal(2, out.scan(/Hello\, world\!/).size)
227
+ out, err = assert_rant("-imd5", "build")
228
+ assert(out.empty?)
229
+ assert(err.empty?)
230
+ else
231
+ STDERR.puts "*** gcc and/or g++ not available, less example testing ***"
232
+ end
233
+ assert_rant("-imd5", "pkg/c_cpp_exercises.tgz")
234
+ # TODO: check archive contents
235
+ assert(test(?f, "pkg/c_cpp_exercises.tgz"))
236
+ out, err = assert_rant("-imd5", "pkg/c_cpp_exercises.tgz")
237
+ assert(out.empty?)
238
+ assert(err.empty?)
239
+ assert_rant("-imd5", "autoclean")
240
+ gen_files.each { |f|
241
+ assert(!test(?e, f),
242
+ "#{f} should have been removed by autoclean")
243
+ }
244
+ assert(Dir["**/.rant.meta"].empty?)
245
+ if Rant::Env.find_bin("gcc")
246
+ FileUtils.cp "c/template.rf", "c/problem_1_1/Rantfile"
247
+ Dir.chdir "c/problem_1_1"
248
+ out = run_rant("-imd5")
249
+ assert(out.include?("Hello, world!"))
250
+ assert_rant("-imd5", "autoclean")
251
+ FileUtils.rm_f "Rantfile"
252
+ Dir.chdir proj_pwd
253
+ gen_files.each { |f|
254
+ assert(!test(?e, f),
255
+ "#{f} should have been removed by autoclean")
256
+ }
257
+ assert(Dir["**/.rant.meta"].empty?)
258
+ end
259
+ ensure
260
+ Dir.chdir proj_pwd
261
+ FileUtils.rm_f "c/problem_1_1/Rantfile"
262
+ FileUtils.rm_f "c++/problem_1_1/Rantfile"
263
+ end
136
264
  end
@@ -158,6 +158,20 @@ class TestFileList < Test::Unit::TestCase
158
158
  assert_equal(1, l2.size)
159
159
  end
160
160
  end
161
+ def test_3addition
162
+ cx = Rant::RantApp.new.cx
163
+ touch_temp %w(a.t1 a.t2 b.t2) do
164
+ l1 = cx.sys["a*"]
165
+ l1.exclude "*.t2"
166
+ l2 = cx.sys["*.t2"]
167
+ l3 = l1 + l2
168
+ %w(a.t1 a.t2 b.t2).each { |fn|
169
+ assert(l3.include(fn), "#{fn} missing")
170
+ }
171
+ l3.lazy_uniq!
172
+ assert_equal(3, l3.size)
173
+ end
174
+ end
161
175
  def test_add_array
162
176
  touch_temp %w(1.t 2.t) do
163
177
  l1 = fl "*.t"
@@ -165,8 +179,19 @@ class TestFileList < Test::Unit::TestCase
165
179
  assert_equal(2, l1.size)
166
180
  assert_equal(3, l2.size)
167
181
  assert(l2.include?("x"))
182
+ assert_equal("x", l2.last)
168
183
  end
169
184
  end
185
+ def test_2add_array
186
+ touch_temp %w(a.t) do
187
+ l1 = fl("*.t")
188
+ l1.resolve
189
+ a = %w(x)
190
+ l2 = l1 + a
191
+ a << "y"
192
+ assert_equal(%w(a.t x), l2.to_ary)
193
+ end
194
+ end
170
195
  def test_glob
171
196
  touch_temp %w(t.t1 t.t2) do
172
197
  l = fl "*.t1"
@@ -341,6 +366,15 @@ class TestFileList < Test::Unit::TestCase
341
366
  assert(fl.include?("a.t"))
342
367
  end
343
368
  end
369
+ def test_ignore_and_shift_op
370
+ cx = Rant::RantApp.new.cx
371
+ cx.var[:ignore] << /CVS/
372
+ touch_temp %w(CVS.t a.t a.tt) do
373
+ fl = cx.sys["*.t"] << "CVS"
374
+ fl.include "*.tt"
375
+ assert_equal(%w(a.t CVS a.tt), fl.to_a)
376
+ end
377
+ end
344
378
  def test_map
345
379
  cx = Rant::RantApp.new.cx
346
380
  touch_temp %w(a.t b.t) do
@@ -369,6 +403,16 @@ class TestFileList < Test::Unit::TestCase
369
403
  assert_equal("a b", cx.sys[].concat(%w(a b)).to_s)
370
404
  assert_equal("", "#{cx.sys[]}")
371
405
  end
406
+ def test_var_ignore_and_dup
407
+ cx = Rant::RantApp.new.cx
408
+ cx.var[:ignore] << "a.t"
409
+ touch_temp %w(a.t b.t a.tt) do
410
+ fl = cx.sys["*.t"] + cx.sys["*.tt"]
411
+ assert_equal(2, fl.size)
412
+ assert(fl.include?("b.t"))
413
+ assert(fl.include?("a.tt"))
414
+ end
415
+ end
372
416
  if Rant::Env.on_windows?
373
417
  def test_to_s_quoting_spaces_win
374
418
  cx = Rant::RantApp.new.cx
data/test/test_sys.rb CHANGED
@@ -61,7 +61,25 @@ class TestSys < Test::Unit::TestCase
61
61
  # ...
62
62
  def test_standalone
63
63
  out = `#{Rant::Sys.sp(Rant::Env::RUBY)} -I#{Rant::Sys.sp(RANT_DEV_LIB_DIR)} standalone.rf`
64
- assert(0, $?)
64
+ assert_exit
65
65
  assert_match(/^t_standalone/, out)
66
66
  end
67
+ def test_cp_with_filelist
68
+ rac = Rant::RantApp.new
69
+ rac[:quiet] = true
70
+ open "a.t", "w" do |f|
71
+ f.puts "a"
72
+ end
73
+ open "b.t", "w" do |f|
74
+ f.puts "b"
75
+ end
76
+ FileUtils.mkdir "cp.t"
77
+ assert_nothing_raised {
78
+ rac.cx.sys.cp rac.cx.sys["a.t","b.t"], "cp.t"
79
+ assert_equal("a\n", File.read("cp.t/a.t"))
80
+ assert_equal("b\n", File.read("cp.t/b.t"))
81
+ }
82
+ ensure
83
+ FileUtils.rm_rf %w(cp.t a.t b.t)
84
+ end
67
85
  end
data/test/test_task.rb CHANGED
@@ -138,7 +138,7 @@ class TestTask < Test::Unit::TestCase
138
138
  enhance_run = false
139
139
  t_run = false
140
140
  t2_run = false
141
- app.gen Rant::Task, :t do |t|
141
+ app.gen Rant::Generators::Task, :t do |t|
142
142
  t.needed { true }
143
143
  t.act {
144
144
  assert(t2_run,
@@ -146,7 +146,7 @@ class TestTask < Test::Unit::TestCase
146
146
  t_run = true
147
147
  }
148
148
  end
149
- app.gen Rant::Task, :t2 do |t|
149
+ app.gen Rant::Generators::Task, :t2 do |t|
150
150
  t.needed { true }
151
151
  t.act { t2_run = true }
152
152
  end
data/test/tutil.rb CHANGED
@@ -49,9 +49,14 @@ module Test
49
49
  def assert_exit(status = 0)
50
50
  assert_equal(status, $?.exitstatus)
51
51
  end
52
- end
53
- end
54
- end
52
+ if RUBY_VERSION < "1.8.1"
53
+ def assert_raise(*args, &block)
54
+ assert_raises(*args, &block)
55
+ end
56
+ end
57
+ end # class TestCase
58
+ end # module Unit
59
+ end # module Test
55
60
 
56
61
  RANT_BIN = File.expand_path(
57
62
  File.join(File.dirname(__FILE__), "..", "run_rant"))
@@ -193,6 +198,7 @@ def unpack_archive(atype, archive)
193
198
  end
194
199
  end
195
200
  def minitar_unpack(archive)
201
+ require 'zlib'
196
202
  require 'rant/archive/minitar'
197
203
  tgz = Zlib::GzipReader.new(File.open(archive, 'rb'))
198
204
  # unpack closes tgz
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.4.2
7
- date: 2005-07-18 00:00:00 +02:00
6
+ version: 0.4.4
7
+ date: 2005-07-29 00:00:00 +02:00
8
8
  summary: Rant is a Ruby based build tool.
9
9
  require_paths:
10
10
  - lib
@@ -44,7 +44,6 @@ files:
44
44
  - lib/rant
45
45
  - lib/rant.rb
46
46
  - lib/rant/c
47
- - lib/rant/rantfile.rb
48
47
  - lib/rant/rantenv.rb
49
48
  - lib/rant/cs_compiler.rb
50
49
  - lib/rant/rantlib.rb
@@ -52,30 +51,40 @@ files:
52
51
  - lib/rant/rantvar.rb
53
52
  - lib/rant/import
54
53
  - lib/rant/plugin_methods.rb
54
+ - lib/rant/node.rb
55
55
  - lib/rant/plugin
56
56
  - lib/rant/tempfile.rb
57
+ - lib/rant/coregen.rb
57
58
  - lib/rant/archive
58
59
  - lib/rant/import.rb
59
60
  - lib/rant/c/include.rb
60
61
  - lib/rant/import/c
62
+ - lib/rant/import/signedfile.rb
61
63
  - lib/rant/import/directedrule.rb
64
+ - lib/rant/import/nodes
62
65
  - lib/rant/import/win32
66
+ - lib/rant/import/metadata.rb
63
67
  - lib/rant/import/truth.rb
64
68
  - lib/rant/import/rubydoc.rb
65
69
  - lib/rant/import/rubytest.rb
66
70
  - lib/rant/import/rubypackage.rb
67
71
  - lib/rant/import/archive.rb
72
+ - lib/rant/import/md5.rb
68
73
  - lib/rant/import/package
69
74
  - lib/rant/import/archive
70
75
  - lib/rant/import/subfile.rb
76
+ - lib/rant/import/signature
71
77
  - lib/rant/import/clean.rb
72
78
  - lib/rant/import/autoclean.rb
73
79
  - lib/rant/import/c/dependencies.rb
80
+ - lib/rant/import/nodes/default.rb
81
+ - lib/rant/import/nodes/signed.rb
74
82
  - lib/rant/import/win32/rubycmdwrapper.rb
75
83
  - lib/rant/import/package/tgz.rb
76
84
  - lib/rant/import/package/zip.rb
77
85
  - lib/rant/import/archive/tgz.rb
78
86
  - lib/rant/import/archive/zip.rb
87
+ - lib/rant/import/signature/md5.rb
79
88
  - lib/rant/plugin/README
80
89
  - lib/rant/plugin/configure.rb
81
90
  - lib/rant/plugin/csharp.rb
@@ -87,7 +96,6 @@ files:
87
96
  - lib/rant/archive/rubyzip/tempfile_bugfixed.rb
88
97
  - test/c
89
98
  - test/test_filetask.rb
90
- - test/test_lighttask.rb
91
99
  - test/test_examples.rb
92
100
  - test/Rantfile
93
101
  - test/ts_all.rb
@@ -138,10 +146,14 @@ files:
138
146
  - test/subdirs/sub2/rantfile.rb
139
147
  - test/subdirs/sub2/sub/rantfile
140
148
  - test/import/c
149
+ - test/import/metadata
150
+ - test/import/nodes
141
151
  - test/import/truth
152
+ - test/import/signeddirectory
142
153
  - test/import/subfile
143
154
  - test/import/directedrule
144
155
  - test/import/package
156
+ - test/import/signedfile
145
157
  - test/import/c/dependencies
146
158
  - test/import/c/dependencies/src
147
159
  - test/import/c/dependencies/bar.h
@@ -158,8 +170,19 @@ files:
158
170
  - test/import/c/dependencies/include/foo.h
159
171
  - test/import/c/dependencies/include/with space.h
160
172
  - test/import/c/dependencies/include/sub/sub.h
173
+ - test/import/metadata/sub
174
+ - test/import/metadata/test_metadata.rb
175
+ - test/import/metadata/Rantfile
176
+ - test/import/metadata/sub/Rantfile
177
+ - test/import/nodes/signed
178
+ - test/import/nodes/signed/sub1
179
+ - test/import/nodes/signed/Rantfile
180
+ - test/import/nodes/signed/test_signed.rb
181
+ - test/import/nodes/signed/sub1/Rantfile
161
182
  - test/import/truth/Rantfile
162
183
  - test/import/truth/test_truth.rb
184
+ - test/import/signeddirectory/Rantfile
185
+ - test/import/signeddirectory/test_signeddirectory.rb
163
186
  - test/import/subfile/Rantfile
164
187
  - test/import/subfile/test_subfile.rb
165
188
  - test/import/subfile/autoclean.rf
@@ -169,6 +192,7 @@ files:
169
192
  - test/import/package/deep
170
193
  - test/import/package/sub2
171
194
  - test/import/package/Rantfile
195
+ - test/import/package/md5.rf
172
196
  - test/import/package/test_package.rb
173
197
  - test/import/package/MANIFEST
174
198
  - test/import/package/sub/f1
@@ -176,6 +200,10 @@ files:
176
200
  - test/import/package/deep/sub/sub
177
201
  - test/import/package/deep/sub/sub/f1
178
202
  - test/import/package/sub2/f1
203
+ - test/import/signedfile/sub1
204
+ - test/import/signedfile/Rantfile
205
+ - test/import/signedfile/test_signedfile.rb
206
+ - test/import/signedfile/sub1/Rantfile
179
207
  - test/plugin/configure
180
208
  - test/plugin/csharp
181
209
  - test/plugin/rantfile
@@ -199,6 +227,7 @@ files:
199
227
  - test/rant-import/Rantfile
200
228
  - test/rant-import/test_rant-import.rb
201
229
  - doc/rantfile.rdoc
230
+ - doc/md5.rdoc
202
231
  - doc/configure.rdoc
203
232
  - doc/advanced.rdoc
204
233
  - doc/rubyproject.rdoc
@@ -267,6 +296,7 @@ rdoc_options:
267
296
  - README
268
297
  extra_rdoc_files:
269
298
  - doc/rantfile.rdoc
299
+ - doc/md5.rdoc
270
300
  - doc/configure.rdoc
271
301
  - doc/advanced.rdoc
272
302
  - doc/rubyproject.rdoc