rant 0.5.6 → 0.5.7

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 +12 -0
  2. data/README +3 -3
  3. data/Rantfile +7 -1
  4. data/doc/Untitled-1~ +7 -0
  5. data/doc/command.rdoc +1 -1
  6. data/doc/csharp.rdoc +49 -72
  7. data/doc/csharp.rdoc~ +37 -0
  8. data/doc/csharp_deprecated.rdoc +73 -0
  9. data/doc/homepage/index.html +5 -8
  10. data/doc/homepage/index.html~ +134 -0
  11. data/doc/sys.rdoc +14 -0
  12. data/lib/rant/coregen.rb~ +262 -0
  13. data/lib/rant/csharp/base_compiler_adapter.rb +125 -0
  14. data/lib/rant/csharp/base_compiler_adapter.rb~ +105 -0
  15. data/lib/rant/csharp/compiler_adapter_factory.rb +40 -0
  16. data/lib/rant/csharp/compiler_adapter_factory.rb~ +39 -0
  17. data/lib/rant/csharp/csc_compiler.rb +15 -0
  18. data/lib/rant/csharp/csc_compiler.rb~ +39 -0
  19. data/lib/rant/csharp/gmcs_compiler.rb +9 -0
  20. data/lib/rant/csharp/gmcs_compiler.rb~ +10 -0
  21. data/lib/rant/csharp/mcs_compiler.rb +13 -0
  22. data/lib/rant/csharp/mcs_compiler.rb~ +40 -0
  23. data/lib/rant/csharp/msc_compiler.rb~ +39 -0
  24. data/lib/rant/import/csharp.rb +48 -0
  25. data/lib/rant/import/csharp.rb~ +58 -0
  26. data/lib/rant/import/nunittest.rb +32 -0
  27. data/lib/rant/import/resgen.rb +21 -0
  28. data/lib/rant/import/resgen.rb~ +20 -0
  29. data/lib/rant/init.rb +1 -1
  30. data/lib/rant/rantlib.rb +1 -0
  31. data/lib/rant/rantlib.rb~ +1376 -0
  32. data/lib/rant/rantsys.rb +6 -0
  33. data/run_import +1 -1
  34. data/run_rant +1 -1
  35. data/test/import/package/test_package.rb~ +628 -0
  36. data/test/rule.rf +4 -0
  37. data/test/test_filetask.rb~ +97 -0
  38. data/test/test_rule.rb +10 -0
  39. data/test/test_sys_methods.rb +22 -0
  40. data/test/units/csharp/test_base_compiler_adapter.rb +107 -0
  41. data/test/units/csharp/test_base_compiler_adapter.rb~ +73 -0
  42. data/test/units/csharp/test_compiler_adapter_factory.rb +66 -0
  43. data/test/units/csharp/test_compiler_adapter_factory.rb~ +66 -0
  44. data/test/units/csharp/test_csc_compiler.rb +23 -0
  45. data/test/units/csharp/test_csc_compiler.rb~ +23 -0
  46. data/test/units/csharp/test_gmsc_compiler.rb +19 -0
  47. data/test/units/csharp/test_gmsc_compiler.rb~ +19 -0
  48. data/test/units/csharp/test_msc_compiler.rb +23 -0
  49. data/test/units/csharp/test_msc_compiler.rb~ +23 -0
  50. data/test/units/csharp_test_helper.rb +6 -0
  51. data/test/units/import/test_csharp.rb +127 -0
  52. data/test/units/import/test_csharp.rb~ +126 -0
  53. data/test/units/import/test_nunittest.rb +122 -0
  54. data/test/units/import/test_resgen.rb +107 -0
  55. data/test/units/import/test_resgen.rb~ +88 -0
  56. metadata +269 -224
@@ -257,10 +257,16 @@ module Rant
257
257
  # how many drive letters are really allowed on
258
258
  # windows?
259
259
  end
260
+ def absolute_path?(path)
261
+ path =~ %r{\A([a-zA-Z]+:)?(/|\\)}
262
+ end
260
263
  else
261
264
  def root_dir?(path)
262
265
  path == "/"
263
266
  end
267
+ def absolute_path?(path)
268
+ path =~ %r{\A/}
269
+ end
264
270
  end
265
271
 
266
272
  extend self
data/run_import CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/local/bin/ruby
1
+ #!/usr/bin/env ruby
2
2
  # Run rant-import from current development directory.
3
3
 
4
4
  $:.unshift File.expand_path(File.join(File.dirname(__FILE__), "lib"))
data/run_rant CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/local/bin/ruby
1
+ #!/usr/bin/env ruby
2
2
  # Run rant in current development directory.
3
3
 
4
4
  $:.unshift File.expand_path(File.join(File.dirname(__FILE__), "lib"))
@@ -0,0 +1,628 @@
1
+
2
+ require 'test/unit'
3
+ require 'tutil'
4
+ require 'rant/import/sys/tgz'
5
+
6
+ $testIPackageDir ||= File.expand_path(File.dirname(__FILE__))
7
+
8
+ class TestImportPackage < Test::Unit::TestCase
9
+ include Rant::TestUtil
10
+ def setup
11
+ # Ensure we run in test directory.
12
+ Dir.chdir $testIPackageDir
13
+ @pkg_dir = nil
14
+ @contents = {}
15
+ end
16
+ def teardown
17
+ assert_rant("autoclean")
18
+ Dir["*.{tgz,zip,t}"].each { |f|
19
+ assert(false, "#{f} should be removed by AutoClean")
20
+ }
21
+ end
22
+ def check_contents(atype, archive, files, dirs = [], manifest_file = nil)
23
+ old_pwd = Dir.pwd
24
+ FileUtils.mkdir "u.t"
25
+ FileUtils.cp archive, "u.t"
26
+ FileUtils.cd "u.t"
27
+ archive = File.basename 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
34
+ if @pkg_dir
35
+ assert(test(?d, @pkg_dir))
36
+ FileUtils.cd @pkg_dir
37
+ end
38
+ files.each { |f|
39
+ assert(test(?f, f), "file #{f} is missing in archive")
40
+ content = @contents[f]
41
+ if content
42
+ assert_equal(content, File.read(f))
43
+ end
44
+ }
45
+ dirs.each { |f|
46
+ assert(test(?d, f), "dir #{f} is missing in archive")
47
+ }
48
+ count = files.size + dirs.size
49
+ # + 1 because of the archive file
50
+ count += 1 unless @pkg_dir
51
+ assert_equal(count, Rant::FileList.glob_all("**/*").size)
52
+ if manifest_file
53
+ check_manifest(manifest_file, files)
54
+ end
55
+ yield if block_given?
56
+ ensure
57
+ FileUtils.cd old_pwd
58
+ FileUtils.rm_r "u.t"
59
+ end
60
+ def check_manifest(file, entries)
61
+ assert(test(?f, file))
62
+ m_entries = IO.read(file).split("\n")
63
+ assert_equal(entries.size, m_entries.size)
64
+ entries.each { |f|
65
+ assert(m_entries.include?(f),
66
+ "#{f} missing in manifest")
67
+ }
68
+ end
69
+ def test_tgz_from_manifest
70
+ assert_rant
71
+ mf = %w(Rantfile sub/f1 sub2/f1 MANIFEST)
72
+ dirs = %w(sub sub2)
73
+ check_contents(:tgz, "t1.tgz", mf, dirs, "MANIFEST")
74
+ end
75
+ def test_tgz_sync_manifest
76
+ assert_rant("t2.tgz")
77
+ mf = %w(sub/f1 sub2/f1 m2.tgz.t)
78
+ dirs = %w(sub sub2)
79
+ check_manifest("m2.tgz.t", mf)
80
+ check_contents(:tgz, "t2.tgz", mf, dirs, "m2.tgz.t")
81
+ out, err = assert_rant("t2.tgz")
82
+ assert(out.strip.empty?)
83
+ #assert(err.strip.empty?)
84
+ FileUtils.touch "sub/f5"
85
+ out, err = assert_rant("t2.tgz")
86
+ assert_match(/writing m2\.tgz\.t.*\n.*tar/m, out)
87
+ check_contents(:tgz, "t2.tgz", mf + %w(sub/f5), dirs, "m2.tgz.t")
88
+ timeout
89
+ FileUtils.rm "sub/f5"
90
+ out, err = assert_rant("t2.tgz")
91
+ assert_match(/writing m2\.tgz\.t.*\n.*tar/m, out)
92
+ check_contents(:tgz, "t2.tgz", mf, dirs, "m2.tgz.t")
93
+ # test autoclean
94
+ assert_rant("autoclean")
95
+ assert(!test(?e, "m2.tgz.t"))
96
+ # hmm.. the tgz will be removed by check_contents anyway...
97
+ assert(!test(?e, "t2.tgz"))
98
+ ensure
99
+ FileUtils.rm_rf "sub/f5"
100
+ end
101
+ def test_tgz_sync_manifest_md5
102
+ assert_rant("-imd5", "t2.tgz")
103
+ mf = %w(sub/f1 sub2/f1 m2.tgz.t)
104
+ dirs = %w(sub sub2)
105
+ check_manifest("m2.tgz.t", mf)
106
+ check_contents(:tgz, "t2.tgz", mf, dirs, "m2.tgz.t")
107
+ out, err = assert_rant("t2.tgz")
108
+ assert(out.strip.empty?)
109
+ assert(err.strip.empty?)
110
+ FileUtils.touch "sub/f5"
111
+ out, err = assert_rant("-imd5", "t2.tgz")
112
+ assert_match(/writing m2\.tgz\.t.*\n.*tar/m, out)
113
+ check_contents(:tgz, "t2.tgz", mf + %w(sub/f5), dirs, "m2.tgz.t")
114
+ FileUtils.rm "sub/f5"
115
+ out, err = assert_rant("-imd5", "t2.tgz")
116
+ assert_match(/writing m2\.tgz\.t.*\n.*tar/m, out)
117
+ check_contents(:tgz, "t2.tgz", mf, dirs, "m2.tgz.t")
118
+ # test autoclean
119
+ assert_rant("-imd5", "autoclean")
120
+ assert(!test(?e, "m2.tgz.t"))
121
+ # hmm.. the tgz will be removed by check_contents anyway...
122
+ assert(!test(?e, "t2.tgz"))
123
+ assert(!test(?e, ".rant.meta"))
124
+ ensure
125
+ FileUtils.rm_rf "sub/f5"
126
+ end
127
+ def test_tgz_files_array
128
+ assert_rant("t3.tgz")
129
+ mf = %w(Rantfile sub/f1)
130
+ dirs = %w(sub)
131
+ check_contents(:tgz, "t3.tgz", mf, dirs)
132
+ end
133
+ def test_tgz_version_and_dir
134
+ assert_rant("pkg.t/t4-1.0.0.tgz")
135
+ assert(test(?d, "pkg.t"))
136
+ mf = %w(Rantfile sub/f1 sub2/f1 MANIFEST)
137
+ dirs = %w(sub sub2)
138
+ check_contents(:tgz, "pkg.t/t4-1.0.0.tgz", mf, dirs, "MANIFEST")
139
+ ensure
140
+ FileUtils.rm_rf "pkg.t"
141
+ end
142
+ def test_tgz_package_manifest
143
+ assert(!test(?e, "pkg2.t"))
144
+ assert_rant("pkg2.t.tgz")
145
+ assert(?d, "pkg2.t")
146
+ mf = %w(Rantfile sub/f1 sub2/f1 MANIFEST)
147
+ dirs = %w(sub sub2)
148
+ @pkg_dir = "pkg2.t"
149
+ check_contents(:tgz, "pkg2.t.tgz", mf, dirs, "MANIFEST")
150
+ assert(test(?d, "pkg2.t"))
151
+ assert_rant("autoclean")
152
+ assert(!test(?e, "pkg2.t"))
153
+ end
154
+ def test_tgz_package_basedir_manifest_extension
155
+ assert_rant("sub/pkg.t/pkg-0.1.tar.gz")
156
+ assert(test(?f, "sub/pkg.t/pkg-0.1.tar.gz"))
157
+ mf = %w(Rantfile sub/f1 sub2/f1 MANIFEST)
158
+ dirs = %w(sub sub2)
159
+ @pkg_dir = "pkg-0.1"
160
+ check_contents(:tgz,
161
+ "sub/pkg.t/pkg-0.1.tar.gz", mf, dirs, "MANIFEST")
162
+ assert(test(?f, "sub/f1"))
163
+ assert_rant("autoclean")
164
+ assert(!test(?e, "sub/pkg.t-0.1"))
165
+ assert(test(?d, "sub"))
166
+ assert(test(?f, "sub/f1"))
167
+ end
168
+ def test_tgz_package_basedir_with_slash
169
+ assert(!test(?d, "sub.t"))
170
+ assert_rant(:fail, "sub.t/pkg.tgz")
171
+ assert(!test(?d, "sub.t"))
172
+ FileUtils.mkdir "sub.t"
173
+ FileUtils.touch "sub.t/a.t"
174
+ out, err = assert_rant("sub.t/pkg.tgz")
175
+ assert(!out.empty?)
176
+ out, err = assert_rant("sub.t/pkg.tgz")
177
+ assert(out.strip.empty?)
178
+ assert(test(?d, "sub.t/pkg"))
179
+ @pkg_dir = "pkg"
180
+ mf = %w(sub/f1)
181
+ dirs = %w(sub)
182
+ check_contents(:tgz, "sub.t/pkg.tgz", mf, dirs)
183
+ assert_rant("autoclean")
184
+ assert(!test(?e, "sub.t/pkg.tgz"))
185
+ assert(!test(?e, "sub.t/pkg"))
186
+ assert(test(?d, "sub.t"))
187
+ assert(test(?f, "sub.t/a.t"))
188
+ ensure
189
+ FileUtils.rm_rf "sub.t"
190
+ end
191
+ def test_tgz_import_archive
192
+ open "rf.t", "w" do |f|
193
+ f << <<-EOF
194
+ import "archive/tgz", "autoclean"
195
+ gen Archive::Tgz, "rf", :files => sys["deep/sub/sub/f1"]
196
+ gen AutoClean
197
+ EOF
198
+ end
199
+ assert_rant("-frf.t")
200
+ mf = %w(deep/sub/sub/f1)
201
+ dirs = %w(deep deep/sub deep/sub/sub)
202
+ check_contents(:tgz, "rf.tgz", mf, dirs)
203
+ assert(test(?f, "rf.tgz"))
204
+ assert_rant("-frf.t", "autoclean")
205
+ assert(!test(?e, "rf.tgz"))
206
+ run_import("-frf.t", "-q", "--auto", "ant.t")
207
+ assert_equal(0, $?.exitstatus)
208
+ out = run_ruby("ant.t", "-frf.t")
209
+ assert(!out.empty?)
210
+ out = run_ruby("ant.t", "-frf.t")
211
+ assert(out.empty?)
212
+ check_contents(:tgz, "rf.tgz", mf, dirs)
213
+ assert(test(?f, "rf.tgz"))
214
+ assert_rant("-frf.t", "autoclean")
215
+ assert(!test(?e, "rf.tgz"))
216
+ ensure
217
+ FileUtils.rm_rf %w(rf.t ant.t)
218
+ end
219
+ def test_tgz_package_empty_dir
220
+ FileUtils.mkdir "sub6.t"
221
+ assert_rant("t6.tgz")
222
+ @pkg_dir = "t6"
223
+ mf = %w()
224
+ dirs = %w(sub6.t)
225
+ check_contents(:tgz, "t6.tgz", mf, dirs)
226
+ ensure
227
+ FileUtils.rm_rf %w(sub6.t)
228
+ end
229
+ def test_tgz_files_manifest_desc
230
+ out, err = assert_rant("--tasks")
231
+ assert_match(/rant\s+t2\.tgz\s+#\s+Create t2\.tgz/, out)
232
+ end
233
+ def test_tgz_package_files_contains_manifest
234
+ assert_rant("t5.tgz")
235
+ @pkg_dir = "t5"
236
+ mf = %w(Rantfile mf5.t)
237
+ dirs = %w()
238
+ check_contents(:tgz, "t5.tgz", mf, dirs, "mf5.t")
239
+ assert_rant("autoclean")
240
+ assert(!test(?e, "t5"))
241
+ end
242
+ def test_tgz_package_non_recursive
243
+ FileUtils.mkdir "sub6.t"
244
+ FileUtils.touch "sub6.t/.t"
245
+ FileUtils.touch "sub6.t/a.t"
246
+ assert_rant("t6.tgz")
247
+ @pkg_dir = "t6"
248
+ mf = %w()
249
+ dirs = %w(sub6.t)
250
+ check_contents(:tgz, "t6.tgz", mf, dirs)
251
+ assert_rant("autoclean")
252
+ assert(!test(?e, "t6"))
253
+ ensure
254
+ FileUtils.rm_rf "sub6.t"
255
+ end
256
+ def test_tgz_non_recursive
257
+ FileUtils.mkdir "sub7.t"
258
+ FileUtils.touch "sub7.t/a"
259
+ assert_rant("t7.tgz")
260
+ mf = %w()
261
+ dirs = %w(sub7.t)
262
+ check_contents(:tgz, "t7.tgz", mf, dirs)
263
+ ensure
264
+ FileUtils.rm_rf "sub7.t"
265
+ end
266
+ def test_tgz_follow_symlink
267
+ have_symlinks = true
268
+ FileUtils.mkdir "subs.t"
269
+ open "target.t", "w" do |f|
270
+ f.print "symlink test target file"
271
+ end
272
+ begin
273
+ File.symlink "../target.t", "subs.t/symlink"
274
+ rescue NotImplementedError
275
+ have_symlinks = false
276
+ end
277
+ if have_symlinks
278
+ assert(File.symlink?("subs.t/symlink"))
279
+ assert(File.exist?("subs.t/symlink"))
280
+ assert_rant("sym.tgz")
281
+ mf = %w(subs.t/symlink)
282
+ dirs = %w(subs.t)
283
+ @contents["subs.t/symlink"] = "symlink test target file"
284
+ check_contents(:tgz, "sym.tgz", mf, dirs)
285
+ else
286
+ STDERR.puts "*** platform doesn't support symbolic links ***"
287
+ end
288
+ ensure
289
+ FileUtils.rm_f %w(target.t sym.tgz)
290
+ FileUtils.rm_rf "subs.t"
291
+ end
292
+ def test_tgz_package_follow_symlink_dir
293
+ have_symlinks = true
294
+ FileUtils.mkdir "subs.t"
295
+ begin
296
+ File.symlink "subs.t", "sub6.t"
297
+ rescue NotImplementedError
298
+ have_symlinks = false
299
+ end
300
+ if have_symlinks
301
+ assert_rant("t6.tgz")
302
+ @pkg_dir = "t6"
303
+ mf = %w()
304
+ dirs = %w(sub6.t)
305
+ check_contents(:tgz, "t6.tgz", mf, dirs)
306
+ end
307
+ ensure
308
+ FileUtils.rm_rf %w(subs.t sub6.t)
309
+ end
310
+ def test_tgz_package_double
311
+ assert_rant("pkg.t/double.tgz")
312
+ out, err = assert_rant("pkg.t/double.tgz")
313
+ assert(out.empty?)
314
+ assert(err.empty?)
315
+ mf = %w(Rantfile)
316
+ dirs = %w()
317
+ @pkg_dir = "double"
318
+ check_contents(:tgz, "pkg.t/double.tgz", mf, dirs)
319
+ end
320
+ def test_zip_follow_symlink
321
+ have_symlinks = true
322
+ FileUtils.mkdir "subs.t"
323
+ open "target.t", "w" do |f|
324
+ f.print "symlink test target file"
325
+ end
326
+ begin
327
+ File.symlink "../target.t", "subs.t/symlink"
328
+ rescue NotImplementedError
329
+ have_symlinks = false
330
+ end
331
+ if have_symlinks
332
+ assert(File.symlink?("subs.t/symlink"))
333
+ assert(File.exist?("subs.t/symlink"))
334
+ assert_rant("sym.zip")
335
+ mf = %w(subs.t/symlink)
336
+ dirs = %w(subs.t)
337
+ @contents["subs.t/symlink"] = "symlink test target file"
338
+ check_contents(:zip, "sym.zip", mf, dirs)
339
+ else
340
+ STDERR.puts "*** platform doesn't support symbolic links ***"
341
+ end
342
+ ensure
343
+ FileUtils.rm_f %w(target.t sym.zip)
344
+ FileUtils.rm_rf "subs.t"
345
+ end
346
+ def test_zip_package_follow_symlink_dir
347
+ have_symlinks = true
348
+ FileUtils.mkdir "subs.t"
349
+ begin
350
+ File.symlink "subs.t", "sub6.t"
351
+ rescue NotImplementedError
352
+ have_symlinks = false
353
+ end
354
+ if have_symlinks
355
+ assert_rant("t6.zip")
356
+ @pkg_dir = "t6"
357
+ mf = %w()
358
+ dirs = %w(sub6.t)
359
+ check_contents(:zip, "t6.zip", mf, dirs)
360
+ end
361
+ ensure
362
+ FileUtils.rm_rf %w(subs.t sub6.t)
363
+ end
364
+ def test_zip_non_recursive
365
+ FileUtils.mkdir "sub7.t"
366
+ FileUtils.touch "sub7.t/a"
367
+ assert_rant("t7.zip")
368
+ mf = %w()
369
+ dirs = %w(sub7.t)
370
+ check_contents(:zip, "t7.zip", mf, dirs)
371
+ ensure
372
+ FileUtils.rm_rf "sub7.t"
373
+ end
374
+ def test_zip_package_non_recursive
375
+ FileUtils.mkdir "sub6.t"
376
+ FileUtils.touch "sub6.t/.t"
377
+ FileUtils.touch "sub6.t/a.t"
378
+ assert_rant("t6.zip")
379
+ @pkg_dir = "t6"
380
+ mf = %w()
381
+ dirs = %w(sub6.t)
382
+ check_contents(:zip, "t6.zip", mf, dirs)
383
+ assert_rant("autoclean")
384
+ assert(!test(?e, "t6"))
385
+ ensure
386
+ FileUtils.rm_rf "sub6.t"
387
+ end
388
+ def test_zip_package_empty_dir
389
+ FileUtils.mkdir "sub6.t"
390
+ assert_rant("t6.zip")
391
+ @pkg_dir = "t6"
392
+ mf = %w()
393
+ dirs = %w(sub6.t)
394
+ check_contents(:zip, "t6.zip", mf, dirs)
395
+ ensure
396
+ FileUtils.rm_rf %w(sub6.t)
397
+ end
398
+ def test_zip_manifest_desc
399
+ out, err = assert_rant("--tasks")
400
+ assert_match(/rant\s+t1\.zip\s+#\s+Create t1\.zip/, out)
401
+ end
402
+ def test_zip_rant_import
403
+ run_import("-q", "--auto", "ant.t")
404
+ assert_equal(0, $?.exitstatus)
405
+ assert(test(?f, "ant.t"))
406
+ out = run_ruby("ant.t", "pkg.t/pkg.zip")
407
+ assert_equal(0, $?.exitstatus)
408
+ assert(!out.empty?)
409
+ out = run_ruby("ant.t", "pkg.t/pkg.zip")
410
+ assert(out.empty?)
411
+ mf = %w(deep/sub/sub/f1 CONTENTS)
412
+ dirs = %w(deep deep/sub deep/sub/sub)
413
+ @pkg_dir = "pkg"
414
+ check_contents(:zip, "pkg.t/pkg.zip", mf, dirs, "CONTENTS")
415
+ assert(test(?f, "CONTENTS"))
416
+ run_ruby("ant.t", "autoclean")
417
+ assert(!test(?f, "CONTENTS"))
418
+ ensure
419
+ FileUtils.rm_f "ant.t"
420
+ end
421
+ def test_zip_package_write_manifest
422
+ assert(!test(?f, "CONTENTS"))
423
+ assert_rant(:x, "pkg.t/pkg.zip")
424
+ assert(test(?f, "CONTENTS"))
425
+ mf = %w(deep/sub/sub/f1 CONTENTS)
426
+ dirs = %w(deep deep/sub deep/sub/sub)
427
+ @pkg_dir = "pkg"
428
+ check_contents(:zip, "pkg.t/pkg.zip", mf, dirs, "CONTENTS")
429
+ assert(test(?f, "CONTENTS"))
430
+ assert_rant("autoclean")
431
+ assert(!test(?f, "CONTENTS"))
432
+ end
433
+ def test_zip_with_basedir
434
+ assert_rant(:fail, "zip.t/t4-1.0.0.zip")
435
+ assert(!test(?d, "zip.t"))
436
+ FileUtils.mkdir "zip.t"
437
+ assert_rant(:x, "zip.t/t4-1.0.0.zip")
438
+ mf = %w(Rantfile sub/f1 sub2/f1 MANIFEST)
439
+ dirs = %w(sub sub2)
440
+ check_contents(:zip, "zip.t/t4-1.0.0.zip", mf, dirs, "MANIFEST")
441
+ assert_rant("autoclean")
442
+ assert(test(?d, "zip.t"))
443
+ assert(!test(?e, "zip.t/t4-1.0.0.zip"))
444
+ ensure
445
+ FileUtils.rm_rf "zip.t"
446
+ end
447
+ def test_zip_with_basedir_md5
448
+ assert_rant(:fail, "-imd5", "zip.t/t4-1.0.0.zip")
449
+ assert(!test(?d, "zip.t"))
450
+ FileUtils.mkdir "zip.t"
451
+ assert_rant(:x, "-imd5", "zip.t/t4-1.0.0.zip")
452
+ mf = %w(Rantfile sub/f1 sub2/f1 MANIFEST)
453
+ dirs = %w(sub sub2)
454
+ check_contents(:zip, "zip.t/t4-1.0.0.zip", mf, dirs, "MANIFEST")
455
+ out, err = assert_rant("-imd5", "zip.t/t4-1.0.0.zip")
456
+ assert(err.empty?)
457
+ assert(out.empty?)
458
+ assert_rant("-imd5", "autoclean")
459
+ assert(test(?d, "zip.t"))
460
+ assert(!test(?e, ".rant.meta"))
461
+ assert(!test(?e, "zip.t/t4-1.0.0.zip"))
462
+ ensure
463
+ FileUtils.rm_rf "zip.t"
464
+ end
465
+ def test_zip_from_manifest
466
+ assert_rant(:x, "t1.zip")
467
+ mf = %w(Rantfile sub/f1 sub2/f1 MANIFEST)
468
+ dirs = %w(sub sub2)
469
+ check_contents(:zip, "t1.zip", mf, dirs, "MANIFEST")
470
+ end
471
+ def test_zip_sync_manifest
472
+ assert_rant(:x, "t2.zip")
473
+ mf = %w(sub/f1 sub2/f1 m2.zip.t)
474
+ dirs = %w(sub sub2)
475
+ check_manifest("m2.zip.t", mf)
476
+ check_contents(:zip, "t2.zip", mf, dirs, "m2.zip.t")
477
+ ensure
478
+ FileUtils.rm_f "m2.zip.t"
479
+ end
480
+ def test_zip_filelist
481
+ assert_rant(:x, "t3.zip")
482
+ mf = %w(Rantfile sub/f1)
483
+ dirs = %w(sub)
484
+ check_contents(:zip, "t3.zip", mf, dirs)
485
+ end
486
+ def write(fn, str)
487
+ open fn, "w" do |f|
488
+ f.write str
489
+ end
490
+ end
491
+ def test_md5_zip_package
492
+ write("sub/pkg.t", "abc\n")
493
+ write("sub2/a.t", "a\n")
494
+ out, err = assert_rant("-fmd5.rf", "pkg.t/m1.zip")
495
+ assert(err.empty?)
496
+ mf = %w(sub/f1 sub2/f1 sub2/a.t)
497
+ dirs = %w(sub sub2)
498
+ @pkg_dir = "m1"
499
+ check_contents(:zip, "pkg.t/m1.zip", mf, dirs)
500
+ FileUtils.rm "sub/pkg.t"
501
+ out, err = assert_rant("-fmd5.rf", "pkg.t/m1.zip")
502
+ assert(err.empty?)
503
+ assert(out.empty?)
504
+ FileUtils.rm "sub2/a.t"
505
+ out, err = assert_rant("-fmd5.rf", "pkg.t/m1.zip")
506
+ assert(err.empty?)
507
+ assert(!out.empty?)
508
+ mf = %w(sub/f1 sub2/f1)
509
+ dirs = %w(sub sub2)
510
+ @pkg_dir = "m1"
511
+ check_contents(:zip, "pkg.t/m1.zip", mf, dirs)
512
+ out, err = assert_rant("-fmd5.rf", "pkg.t/m1.zip")
513
+ assert(err.empty?)
514
+ assert(out.empty?)
515
+ assert_rant("-fmd5.rf", "clean")
516
+ assert(!test(?e, "pkg.t"))
517
+ assert(!test(?e, ".rant.meta"))
518
+ ensure
519
+ FileUtils.rm_f %w(.rant.meta sub1/pkg.t sub2/a.t)
520
+ end
521
+ def test_md5_tgz_package
522
+ write("sub/pkg.t", "abc\n")
523
+ write("sub2/a.t", "a\n")
524
+ out, err = assert_rant("-fmd5.rf", "pkg.t/m1.tgz")
525
+ assert(err.empty?)
526
+ mf = %w(sub/f1 sub2/f1 sub2/a.t)
527
+ dirs = %w(sub sub2)
528
+ @pkg_dir = "m1"
529
+ check_contents(:tgz, "pkg.t/m1.tgz", mf, dirs)
530
+ FileUtils.rm "sub/pkg.t"
531
+ out, err = assert_rant("-fmd5.rf", "pkg.t/m1.tgz")
532
+ assert(err.empty?)
533
+ assert(out.empty?)
534
+ FileUtils.rm "sub2/a.t"
535
+ out, err = assert_rant("-fmd5.rf", "pkg.t/m1.tgz")
536
+ assert(err.empty?)
537
+ assert(!out.empty?)
538
+ mf = %w(sub/f1 sub2/f1)
539
+ dirs = %w(sub sub2)
540
+ @pkg_dir = "m1"
541
+ check_contents(:tgz, "pkg.t/m1.tgz", mf, dirs)
542
+ out, err = assert_rant("-fmd5.rf", "pkg.t/m1.tgz")
543
+ assert(err.empty?)
544
+ assert(out.empty?)
545
+ assert_rant("-fmd5.rf", "clean")
546
+ assert(!test(?e, "pkg.t"))
547
+ assert(!test(?e, ".rant.meta"))
548
+ ensure
549
+ FileUtils.rm_f %w(.rant.meta sub1/pkg.t sub2/a.t)
550
+ end
551
+ def test_rant_import_md5_empty_archive_tgz
552
+ write("empty.rf", <<-EOF)
553
+ import "md5", "archive/tgz"
554
+ gen Archive::Tgz, "empty.t", :files => []
555
+ EOF
556
+ run_import("-q", "-fempty.rf", "--auto", "make.t")
557
+ assert_exit
558
+ out = run_ruby("make.t", "-fempty.rf", "empty.t.tgz")
559
+ assert_exit
560
+ mf = %w()
561
+ dirs = %w()
562
+ check_contents(:tgz, "empty.t.tgz", mf, dirs)
563
+ out = run_ruby("make.t", "-fempty.rf", "empty.t.tgz")
564
+ assert(out.empty?)
565
+ ensure
566
+ FileUtils.rm_f %w(make.t empty.rf empty.t.tgz)
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", "*.tgz")
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
600
+ def test_package_zip_exclude_package_dir
601
+ in_local_temp_dir do
602
+ write_to_file "root.rant", <<-EOF
603
+ import "md5", "package/zip", "autoclean"
604
+ gen Package::Zip, "pkg", :files => sys["**/*.t"]
605
+ gen AutoClean
606
+ EOF
607
+ write_to_file "a.t", "a\n"
608
+ Rant::Sys.mkdir "dir"
609
+ write_to_file "dir/a.t", "dir_a\n"
610
+ write_to_file "pkg.t", "pkg\n"
611
+ out, err = assert_rant "pkg.zip"
612
+ assert err.empty?
613
+ assert !out.empty?
614
+ mf = %w(a.t dir/a.t pkg.t)
615
+ dirs = %w(dir)
616
+ @pkg_dir = "pkg"
617
+ check_contents(:zip, "pkg.zip", mf, dirs)
618
+ out, err = assert_rant "pkg.zip"
619
+ check_contents(:zip, "pkg.zip", mf, dirs)
620
+ assert err.empty?
621
+ assert out.empty?
622
+
623
+ assert_rant "autoclean"
624
+ assert Rant::FileList["**/*.zip"].empty?
625
+ assert !test(?e, ".rant.meta")
626
+ end
627
+ end
628
+ end