rant 0.3.8 → 0.4.0

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.
Files changed (55) hide show
  1. data/NEWS +19 -0
  2. data/README +51 -24
  3. data/Rantfile +7 -8
  4. data/doc/advanced.rdoc +3 -1
  5. data/doc/package.rdoc +280 -0
  6. data/doc/rantfile.rdoc +9 -19
  7. data/doc/rubyproject.rdoc +24 -16
  8. data/lib/rant/archive/minitar.rb +983 -0
  9. data/lib/rant/archive/rubyzip/ioextras.rb +122 -0
  10. data/lib/rant/archive/rubyzip/stdrubyext.rb +114 -0
  11. data/lib/rant/archive/rubyzip/tempfile_bugfixed.rb +195 -0
  12. data/lib/rant/archive/rubyzip.rb +1575 -0
  13. data/lib/rant/import/archive/tgz.rb +49 -0
  14. data/lib/rant/import/archive/zip.rb +67 -0
  15. data/lib/rant/import/archive.rb +312 -0
  16. data/lib/rant/import/autoclean.rb +2 -2
  17. data/lib/rant/import/c/dependencies.rb +3 -3
  18. data/lib/rant/import/clean.rb +1 -1
  19. data/lib/rant/import/directedrule.rb +1 -1
  20. data/lib/rant/import/package/tgz.rb +35 -0
  21. data/lib/rant/import/package/zip.rb +36 -0
  22. data/lib/rant/import/rubydoc.rb +1 -1
  23. data/lib/rant/import/rubypackage.rb +19 -77
  24. data/lib/rant/import/rubytest.rb +1 -1
  25. data/lib/rant/import/subfile.rb +28 -14
  26. data/lib/rant/import/win32/rubycmdwrapper.rb +1 -1
  27. data/lib/rant/import.rb +36 -16
  28. data/lib/rant/plugin/csharp.rb +1 -1
  29. data/lib/rant/rantenv.rb +2 -13
  30. data/lib/rant/rantfile.rb +11 -11
  31. data/lib/rant/rantlib.rb +7 -3
  32. data/lib/rant/rantsys.rb +53 -2
  33. data/lib/rant/rantvar.rb +62 -1
  34. data/misc/TODO +41 -0
  35. data/{devel-notes → misc/devel-notes} +6 -0
  36. data/misc/mt.rb +3 -0
  37. data/misc/t.rb +18 -0
  38. data/test/import/c/dependencies/test_c_dependencies.rb +18 -0
  39. data/test/import/package/MANIFEST +4 -0
  40. data/test/import/package/Rantfile +49 -0
  41. data/test/import/package/deep/sub/sub/f1 +1 -0
  42. data/test/import/package/sub/f1 +1 -0
  43. data/test/import/package/sub2/f1 +1 -0
  44. data/test/import/package/test_package.rb +425 -0
  45. data/test/import/subfile/Rantfile +8 -0
  46. data/test/import/subfile/test_subfile.rb +12 -0
  47. data/test/project_rb1/rantfile.rb +3 -4
  48. data/test/project_rb1/test_project_rb1.rb +16 -40
  49. data/test/rant-import/test_rant-import.rb +3 -3
  50. data/test/test_filelist.rb +39 -2
  51. data/test/tutil.rb +89 -3
  52. metadata +35 -6
  53. data/TODO +0 -21
  54. data/lib/rant/import/package.rb +0 -258
  55. /data/{rantmethods.rb → misc/rantmethods.rb} +0 -0
data/misc/TODO ADDED
@@ -0,0 +1,41 @@
1
+
2
+ = TODO
3
+
4
+ == Solve archiving dependency problem
5
+ Because of timed depdencies, the archiving tasks don't recognize if
6
+ the only change is that a file was removed. The only exception is a
7
+ primitive +Archive+ task whith manifest synchronization. The problem
8
+ can be solved by writing a list of files parallel to archive creation
9
+ or to write a signature of the filelist.
10
+
11
+ == Dependency alternation
12
+ Allow at least two tasks as one dependency where the first available
13
+ will actually used to satisfy the dependency, pseudo code:
14
+ task :a => :b | :c
15
+ Rant should first try :b and if the task :b exists and succeds
16
+ :c won't be considered, if task :b doesn't exist, rant should try
17
+ to make :c.
18
+
19
+ == GET RID OF CLASS Rant::Path
20
+ Done (0.3.7).
21
+
22
+ == Packaging
23
+ Try minitar if tar is not available.
24
+ Done (0.3.9).
25
+
26
+ == C# plugin
27
+ Define the method +assembly+ for building a file with the C# compiler?
28
+ Done.
29
+
30
+ == Predefined tasks
31
+
32
+ Add a 'distclean' task that removes all files and directories
33
+ generatet by any file task.
34
+ Done (AutoClean generator).
35
+
36
+ == Java plugin
37
+
38
+ At least for the 1.0.0 release.
39
+
40
+ #--
41
+ # vim:tw=70
@@ -1,4 +1,10 @@
1
1
 
2
+ == Task alias
3
+ Since +alias+ is a Ruby keyword, we could use +nick+ to create task
4
+ alises.
5
+ Other choices: short, cut, name, label, syn, synonym, ident, term,
6
+ shortcut, abbreviation
7
+
2
8
  == Here docs
3
9
  Don't use here documents in the Rant sources, imports and plugins.
4
10
  They'll get messed up by the rant-import command.
data/misc/mt.rb ADDED
@@ -0,0 +1,3 @@
1
+
2
+ module Task
3
+ end
data/misc/t.rb ADDED
@@ -0,0 +1,18 @@
1
+
2
+ =begin
3
+ Run this with `rant -f t.rb', it should print the following 3 lines:
4
+ Task
5
+ Rant::Task
6
+ a
7
+ =end
8
+ require 'rubygems'
9
+ #require 'rake'
10
+ require 'mt'
11
+
12
+ gen Task, "a" do |t|
13
+ t.needed { true }
14
+ t.act { puts t.name }
15
+ end
16
+
17
+ p ::Task
18
+ p Task
@@ -89,4 +89,22 @@ class TestImportCDependencies < Test::Unit::TestCase
89
89
  assert(!test(?e, f), "#{f} should get unlinked by AutoClean")
90
90
  }
91
91
  end
92
+ def test_rant_import_hello_c
93
+ run_import("-q", "--auto", "ant.t")
94
+ assert_exit
95
+ assert(test(?f, "ant.t"))
96
+ run_ruby("ant.t", "hello.t")
97
+ assert_exit
98
+ assert(test(?f, "hello.t"))
99
+ assert(test(?f, "c_dependencies"))
100
+ out = run_ruby("ant.t", "hello.t")
101
+ assert(out.strip.empty?)
102
+ open "ant.t" do |f|
103
+ requires = extract_requires(f)
104
+ requires.each { |fn|
105
+ assert_no_match(/^rant\//, fn,
106
+ "#{fn} should be inlined by rant-import")
107
+ }
108
+ end
109
+ end
92
110
  end
@@ -0,0 +1,4 @@
1
+ Rantfile
2
+ sub/f1
3
+ sub2/f1
4
+ MANIFEST
@@ -0,0 +1,49 @@
1
+
2
+ import %w(package/tgz package/zip autoclean)
3
+
4
+ gen Archive::Tgz, "t1", :manifest => "MANIFEST"
5
+ desc "Create t1.zip"
6
+ gen Archive::Zip, "t1", :manifest => "MANIFEST"
7
+
8
+ desc "Create t2.tgz"
9
+ gen Archive::Tgz, "t2",
10
+ :files => sys["sub*/f?"],
11
+ :manifest => "m2.tgz.t"
12
+
13
+ gen Archive::Zip, "t2",
14
+ :files => sys["sub*/f?"],
15
+ :manifest => "m2.zip.t"
16
+
17
+ gen Archive::Tgz, "t3", :files => %w(Rantfile sub/f1)
18
+ gen Archive::Zip, "t3", :files => sys["Rantfile", "sub/f1"]
19
+
20
+ gen Archive::Tgz, "pkg.t/t4", :manifest, :version => "1.0.0"
21
+
22
+ gen Archive::Zip, "zip.t", "t4", :manifest, :version => "1.0.0"
23
+
24
+ gen Package::Tgz, "pkg2.t", :manifest
25
+
26
+ gen Package::Zip, "pkg.t/pkg",
27
+ :manifest => "CONTENTS",
28
+ :files => %w(deep/sub/sub/f1)
29
+
30
+ gen Package::Tgz, "sub", "pkg.t/pkg", :manifest,
31
+ :version => "0.1",
32
+ :extension => ".tar.gz"
33
+
34
+ gen Package::Tgz, "sub.t/", "pkg", :files => %w(sub/f1)
35
+
36
+ gen Package::Tgz, "t5",
37
+ :manifest => "mf5.t",
38
+ :files => %w(Rantfile mf5.t)
39
+
40
+ gen Package::Tgz, "t6", :files => %w(sub6.t)
41
+ gen Package::Zip, "t6", :files => %w(sub6.t)
42
+
43
+ gen Archive::Tgz, "t7", :files => %w(sub7.t)
44
+ gen Archive::Zip, "t7", :files => %w(sub7.t)
45
+
46
+ gen Archive::Tgz, "sym", :files => sys["subs.t/**/*"]
47
+ gen Archive::Zip, "sym", :files => sys["subs.t/**/*"]
48
+
49
+ gen AutoClean
@@ -0,0 +1 @@
1
+ deep/sub/sub/f1
@@ -0,0 +1 @@
1
+ sub/f1
@@ -0,0 +1 @@
1
+ sub2/f1
@@ -0,0 +1,425 @@
1
+
2
+ require 'test/unit'
3
+ require 'tutil'
4
+
5
+ $testIPackageDir ||= File.expand_path(File.dirname(__FILE__))
6
+
7
+ class TestImportPackage < Test::Unit::TestCase
8
+ def setup
9
+ # Ensure we run in test directory.
10
+ Dir.chdir $testIPackageDir
11
+ @pkg_dir = nil
12
+ @contents = {}
13
+ end
14
+ def teardown
15
+ assert_rant("autoclean")
16
+ Dir["*.{tgz,zip,t}"].each { |f|
17
+ assert(false, "#{f} should be removed by AutoClean")
18
+ }
19
+ end
20
+ def check_contents(atype, archive, files, dirs = [], manifest_file = nil)
21
+ old_pwd = Dir.pwd
22
+ FileUtils.mkdir "u.t"
23
+ FileUtils.cp archive, "u.t"
24
+ FileUtils.cd "u.t"
25
+ archive = File.basename archive
26
+ unpack_archive atype, archive
27
+ if @pkg_dir
28
+ assert(test(?d, @pkg_dir))
29
+ FileUtils.cd @pkg_dir
30
+ end
31
+ files.each { |f|
32
+ assert(test(?f, f), "file #{f} is missing in archive")
33
+ content = @contents[f]
34
+ if content
35
+ assert_equal(content, File.read(f))
36
+ end
37
+ }
38
+ dirs.each { |f|
39
+ assert(test(?d, f), "dir #{f} is missing in archive")
40
+ }
41
+ count = files.size + dirs.size
42
+ # + 1 because of the archive file
43
+ count += 1 unless @pkg_dir
44
+ assert_equal(count, Dir["**/*"].size)
45
+ if manifest_file
46
+ check_manifest(manifest_file, files)
47
+ end
48
+ yield if block_given?
49
+ ensure
50
+ FileUtils.cd old_pwd
51
+ FileUtils.rm_r "u.t"
52
+ end
53
+ def check_manifest(file, entries)
54
+ assert(test(?f, file))
55
+ m_entries = IO.read(file).split("\n")
56
+ assert_equal(entries.size, m_entries.size)
57
+ entries.each { |f|
58
+ assert(m_entries.include?(f),
59
+ "#{f} missing in manifest")
60
+ }
61
+ end
62
+ def test_tgz_from_manifest
63
+ assert_rant
64
+ mf = %w(Rantfile sub/f1 sub2/f1 MANIFEST)
65
+ dirs = %w(sub sub2)
66
+ check_contents(:tgz, "t1.tgz", mf, dirs, "MANIFEST")
67
+ end
68
+ def test_tgz_sync_manifest
69
+ assert_rant("t2.tgz")
70
+ mf = %w(sub/f1 sub2/f1 m2.tgz.t)
71
+ dirs = %w(sub sub2)
72
+ check_manifest("m2.tgz.t", mf)
73
+ check_contents(:tgz, "t2.tgz", mf, dirs, "m2.tgz.t")
74
+ out, err = assert_rant("t2.tgz")
75
+ assert(out.strip.empty?)
76
+ #assert(err.strip.empty?)
77
+ FileUtils.touch "sub/f5"
78
+ out, err = assert_rant("t2.tgz")
79
+ assert_match(/writing m2\.tgz\.t.*\n.*tar/m, out)
80
+ check_contents(:tgz, "t2.tgz", mf + %w(sub/f5), dirs, "m2.tgz.t")
81
+ timeout
82
+ FileUtils.rm "sub/f5"
83
+ out, err = assert_rant("t2.tgz")
84
+ assert_match(/writing m2\.tgz\.t.*\n.*tar/m, out)
85
+ check_contents(:tgz, "t2.tgz", mf, dirs, "m2.tgz.t")
86
+ # test autoclean
87
+ assert_rant("autoclean")
88
+ assert(!test(?e, "m2.tgz.t"))
89
+ # hmm.. the tgz will be removed by check_contents anyway...
90
+ assert(!test(?e, "t2.tgz"))
91
+ ensure
92
+ FileUtils.rm_rf "sub/f5"
93
+ end
94
+ def test_tgz_files_array
95
+ assert_rant("t3.tgz")
96
+ mf = %w(Rantfile sub/f1)
97
+ dirs = %w(sub)
98
+ check_contents(:tgz, "t3.tgz", mf, dirs)
99
+ end
100
+ def test_tgz_version_and_dir
101
+ assert_rant("pkg.t/t4-1.0.0.tgz")
102
+ assert(test(?d, "pkg.t"))
103
+ mf = %w(Rantfile sub/f1 sub2/f1 MANIFEST)
104
+ dirs = %w(sub sub2)
105
+ check_contents(:tgz, "pkg.t/t4-1.0.0.tgz", mf, dirs, "MANIFEST")
106
+ ensure
107
+ FileUtils.rm_rf "pkg.t"
108
+ end
109
+ def test_tgz_package_manifest
110
+ assert(!test(?e, "pkg2.t"))
111
+ assert_rant("pkg2.t.tgz")
112
+ assert(?d, "pkg2.t")
113
+ mf = %w(Rantfile sub/f1 sub2/f1 MANIFEST)
114
+ dirs = %w(sub sub2)
115
+ @pkg_dir = "pkg2.t"
116
+ check_contents(:tgz, "pkg2.t.tgz", mf, dirs, "MANIFEST")
117
+ assert(test(?d, "pkg2.t"))
118
+ assert_rant("autoclean")
119
+ assert(!test(?e, "pkg2.t"))
120
+ end
121
+ def test_tgz_package_basedir_manifest_extension
122
+ assert_rant("sub/pkg.t/pkg-0.1.tar.gz")
123
+ assert(test(?f, "sub/pkg.t/pkg-0.1.tar.gz"))
124
+ mf = %w(Rantfile sub/f1 sub2/f1 MANIFEST)
125
+ dirs = %w(sub sub2)
126
+ @pkg_dir = "pkg-0.1"
127
+ check_contents(:tgz,
128
+ "sub/pkg.t/pkg-0.1.tar.gz", mf, dirs, "MANIFEST")
129
+ assert(test(?f, "sub/f1"))
130
+ assert_rant("autoclean")
131
+ assert(!test(?e, "sub/pkg.t-0.1"))
132
+ assert(test(?d, "sub"))
133
+ assert(test(?f, "sub/f1"))
134
+ end
135
+ def test_tgz_package_basedir_with_slash
136
+ assert(!test(?d, "sub.t"))
137
+ assert_rant(:fail, "sub.t/pkg.tgz")
138
+ assert(!test(?d, "sub.t"))
139
+ FileUtils.mkdir "sub.t"
140
+ FileUtils.touch "sub.t/a.t"
141
+ out, err = assert_rant("sub.t/pkg.tgz")
142
+ assert(!out.empty?)
143
+ out, err = assert_rant("sub.t/pkg.tgz")
144
+ assert(out.empty?)
145
+ assert(test(?d, "sub.t/pkg"))
146
+ @pkg_dir = "pkg"
147
+ mf = %w(sub/f1)
148
+ dirs = %w(sub)
149
+ check_contents(:tgz, "sub.t/pkg.tgz", mf, dirs)
150
+ assert_rant("autoclean")
151
+ assert(!test(?e, "sub.t/pkg.tgz"))
152
+ assert(!test(?e, "sub.t/pkg"))
153
+ assert(test(?d, "sub.t"))
154
+ assert(test(?f, "sub.t/a.t"))
155
+ ensure
156
+ FileUtils.rm_rf "sub.t"
157
+ end
158
+ def test_tgz_import_archive
159
+ open "rf.t", "w" do |f|
160
+ f << <<-EOF
161
+ import "archive/tgz", "autoclean"
162
+ gen Archive::Tgz, "rf", :files => sys["deep/sub/sub/f1"]
163
+ gen AutoClean
164
+ EOF
165
+ end
166
+ assert_rant("-frf.t")
167
+ mf = %w(deep/sub/sub/f1)
168
+ dirs = %w(deep deep/sub deep/sub/sub)
169
+ check_contents(:tgz, "rf.tgz", mf, dirs)
170
+ assert(test(?f, "rf.tgz"))
171
+ assert_rant("-frf.t", "autoclean")
172
+ assert(!test(?e, "rf.tgz"))
173
+ run_import("-frf.t", "-q", "--auto", "ant.t")
174
+ assert_equal(0, $?.exitstatus)
175
+ out = run_ruby("ant.t", "-frf.t")
176
+ assert(!out.empty?)
177
+ out = run_ruby("ant.t", "-frf.t")
178
+ assert(out.empty?)
179
+ check_contents(:tgz, "rf.tgz", mf, dirs)
180
+ assert(test(?f, "rf.tgz"))
181
+ assert_rant("-frf.t", "autoclean")
182
+ assert(!test(?e, "rf.tgz"))
183
+ ensure
184
+ FileUtils.rm_rf %w(rf.t ant.t)
185
+ end
186
+ def test_tgz_package_empty_dir
187
+ FileUtils.mkdir "sub6.t"
188
+ assert_rant("t6.tgz")
189
+ @pkg_dir = "t6"
190
+ mf = %w()
191
+ dirs = %w(sub6.t)
192
+ check_contents(:tgz, "t6.tgz", mf, dirs)
193
+ ensure
194
+ FileUtils.rm_rf %w(sub6.t)
195
+ end
196
+ def test_tgz_files_manifest_desc
197
+ out, err = assert_rant("--tasks")
198
+ assert_match(/rant\s+t2\.tgz\s+#\s+Create t2\.tgz/, out)
199
+ end
200
+ def test_tgz_package_files_contains_manifest
201
+ assert_rant("t5.tgz")
202
+ @pkg_dir = "t5"
203
+ mf = %w(Rantfile mf5.t)
204
+ dirs = %w()
205
+ check_contents(:tgz, "t5.tgz", mf, dirs, "mf5.t")
206
+ assert_rant("autoclean")
207
+ assert(!test(?e, "t5"))
208
+ end
209
+ def test_tgz_package_non_recursive
210
+ FileUtils.mkdir "sub6.t"
211
+ FileUtils.touch "sub6.t/.t"
212
+ FileUtils.touch "sub6.t/a.t"
213
+ assert_rant("t6.tgz")
214
+ @pkg_dir = "t6"
215
+ mf = %w()
216
+ dirs = %w(sub6.t)
217
+ check_contents(:tgz, "t6.tgz", mf, dirs)
218
+ assert_rant("autoclean")
219
+ assert(!test(?e, "t6"))
220
+ ensure
221
+ FileUtils.rm_rf "sub6.t"
222
+ end
223
+ def test_tgz_non_recursive
224
+ FileUtils.mkdir "sub7.t"
225
+ FileUtils.touch "sub7.t/a"
226
+ assert_rant("t7.tgz")
227
+ mf = %w()
228
+ dirs = %w(sub7.t)
229
+ check_contents(:tgz, "t7.tgz", mf, dirs)
230
+ ensure
231
+ FileUtils.rm_rf "sub7.t"
232
+ end
233
+ def test_tgz_follow_symlink
234
+ have_symlinks = true
235
+ FileUtils.mkdir "subs.t"
236
+ open "target.t", "w" do |f|
237
+ f.print "symlink test target file"
238
+ end
239
+ begin
240
+ File.symlink "../target.t", "subs.t/symlink"
241
+ rescue NotImplementedError
242
+ have_symlinks = false
243
+ end
244
+ if have_symlinks
245
+ assert(File.symlink?("subs.t/symlink"))
246
+ assert(File.exist?("subs.t/symlink"))
247
+ assert_rant("sym.tgz")
248
+ mf = %w(subs.t/symlink)
249
+ dirs = %w(subs.t)
250
+ @contents["subs.t/symlink"] = "symlink test target file"
251
+ check_contents(:tgz, "sym.tgz", mf, dirs)
252
+ else
253
+ STDERR.puts "*** platform doesn't support symbolic links ***"
254
+ end
255
+ ensure
256
+ FileUtils.rm_f %w(target.t sym.tgz)
257
+ FileUtils.rm_rf "subs.t"
258
+ end
259
+ def test_tgz_package_follow_symlink_dir
260
+ have_symlinks = true
261
+ FileUtils.mkdir "subs.t"
262
+ begin
263
+ File.symlink "subs.t", "sub6.t"
264
+ rescue NotImplementedError
265
+ have_symlinks = false
266
+ end
267
+ if have_symlinks
268
+ assert_rant("t6.tgz")
269
+ @pkg_dir = "t6"
270
+ mf = %w()
271
+ dirs = %w(sub6.t)
272
+ check_contents(:tgz, "t6.tgz", mf, dirs)
273
+ end
274
+ ensure
275
+ FileUtils.rm_rf %w(subs.t sub6.t)
276
+ end
277
+ def test_zip_follow_symlink
278
+ have_symlinks = true
279
+ FileUtils.mkdir "subs.t"
280
+ open "target.t", "w" do |f|
281
+ f.print "symlink test target file"
282
+ end
283
+ begin
284
+ File.symlink "../target.t", "subs.t/symlink"
285
+ rescue NotImplementedError
286
+ have_symlinks = false
287
+ end
288
+ if have_symlinks
289
+ assert(File.symlink?("subs.t/symlink"))
290
+ assert(File.exist?("subs.t/symlink"))
291
+ assert_rant("sym.zip")
292
+ mf = %w(subs.t/symlink)
293
+ dirs = %w(subs.t)
294
+ @contents["subs.t/symlink"] = "symlink test target file"
295
+ check_contents(:zip, "sym.zip", mf, dirs)
296
+ else
297
+ STDERR.puts "*** platform doesn't support symbolic links ***"
298
+ end
299
+ ensure
300
+ FileUtils.rm_f %w(target.t sym.zip)
301
+ FileUtils.rm_rf "subs.t"
302
+ end
303
+ def test_zip_package_follow_symlink_dir
304
+ have_symlinks = true
305
+ FileUtils.mkdir "subs.t"
306
+ begin
307
+ File.symlink "subs.t", "sub6.t"
308
+ rescue NotImplementedError
309
+ have_symlinks = false
310
+ end
311
+ if have_symlinks
312
+ assert_rant("t6.zip")
313
+ @pkg_dir = "t6"
314
+ mf = %w()
315
+ dirs = %w(sub6.t)
316
+ check_contents(:zip, "t6.zip", mf, dirs)
317
+ end
318
+ ensure
319
+ FileUtils.rm_rf %w(subs.t sub6.t)
320
+ end
321
+ def test_zip_non_recursive
322
+ FileUtils.mkdir "sub7.t"
323
+ FileUtils.touch "sub7.t/a"
324
+ assert_rant("t7.zip")
325
+ mf = %w()
326
+ dirs = %w(sub7.t)
327
+ check_contents(:zip, "t7.zip", mf, dirs)
328
+ ensure
329
+ FileUtils.rm_rf "sub7.t"
330
+ end
331
+ def test_zip_package_non_recursive
332
+ FileUtils.mkdir "sub6.t"
333
+ FileUtils.touch "sub6.t/.t"
334
+ FileUtils.touch "sub6.t/a.t"
335
+ assert_rant("t6.zip")
336
+ @pkg_dir = "t6"
337
+ mf = %w()
338
+ dirs = %w(sub6.t)
339
+ check_contents(:zip, "t6.zip", mf, dirs)
340
+ assert_rant("autoclean")
341
+ assert(!test(?e, "t6"))
342
+ ensure
343
+ FileUtils.rm_rf "sub6.t"
344
+ end
345
+ def test_zip_package_empty_dir
346
+ FileUtils.mkdir "sub6.t"
347
+ assert_rant("t6.zip")
348
+ @pkg_dir = "t6"
349
+ mf = %w()
350
+ dirs = %w(sub6.t)
351
+ check_contents(:zip, "t6.zip", mf, dirs)
352
+ ensure
353
+ FileUtils.rm_rf %w(sub6.t)
354
+ end
355
+ def test_zip_manifest_desc
356
+ out, err = assert_rant("--tasks")
357
+ assert_match(/rant\s+t1\.zip\s+#\s+Create t1\.zip/, out)
358
+ end
359
+ def test_zip_rant_import
360
+ run_import("-q", "--auto", "ant.t")
361
+ assert_equal(0, $?.exitstatus)
362
+ assert(test(?f, "ant.t"))
363
+ out = run_ruby("ant.t", "pkg.t/pkg.zip")
364
+ assert_equal(0, $?.exitstatus)
365
+ assert(!out.empty?)
366
+ out = run_ruby("ant.t", "pkg.t/pkg.zip")
367
+ assert(out.empty?)
368
+ mf = %w(deep/sub/sub/f1 CONTENTS)
369
+ dirs = %w(deep deep/sub deep/sub/sub)
370
+ @pkg_dir = "pkg"
371
+ check_contents(:zip, "pkg.t/pkg.zip", mf, dirs, "CONTENTS")
372
+ assert(test(?f, "CONTENTS"))
373
+ run_ruby("ant.t", "autoclean")
374
+ assert(!test(?f, "CONTENTS"))
375
+ ensure
376
+ FileUtils.rm_f "ant.t"
377
+ end
378
+ def test_zip_package_write_manifest
379
+ assert(!test(?f, "CONTENTS"))
380
+ assert_rant(:x, "pkg.t/pkg.zip")
381
+ assert(test(?f, "CONTENTS"))
382
+ mf = %w(deep/sub/sub/f1 CONTENTS)
383
+ dirs = %w(deep deep/sub deep/sub/sub)
384
+ @pkg_dir = "pkg"
385
+ check_contents(:zip, "pkg.t/pkg.zip", mf, dirs, "CONTENTS")
386
+ assert(test(?f, "CONTENTS"))
387
+ assert_rant("autoclean")
388
+ assert(!test(?f, "CONTENTS"))
389
+ end
390
+ def test_zip_with_basedir
391
+ assert_rant(:fail, "zip.t/t4-1.0.0.zip")
392
+ assert(!test(?d, "zip.t"))
393
+ FileUtils.mkdir "zip.t"
394
+ assert_rant(:x, "zip.t/t4-1.0.0.zip")
395
+ mf = %w(Rantfile sub/f1 sub2/f1 MANIFEST)
396
+ dirs = %w(sub sub2)
397
+ check_contents(:zip, "zip.t/t4-1.0.0.zip", mf, dirs, "MANIFEST")
398
+ assert_rant("autoclean")
399
+ assert(test(?d, "zip.t"))
400
+ assert(!test(?e, "zip.t/t4-1.0.0.zip"))
401
+ ensure
402
+ FileUtils.rm_rf "zip.t"
403
+ end
404
+ def test_zip_from_manifest
405
+ assert_rant(:x, "t1.zip")
406
+ mf = %w(Rantfile sub/f1 sub2/f1 MANIFEST)
407
+ dirs = %w(sub sub2)
408
+ check_contents(:zip, "t1.zip", mf, dirs, "MANIFEST")
409
+ end
410
+ def test_zip_sync_manifest
411
+ assert_rant(:x, "t2.zip")
412
+ mf = %w(sub/f1 sub2/f1 m2.zip.t)
413
+ dirs = %w(sub sub2)
414
+ check_manifest("m2.zip.t", mf)
415
+ check_contents(:zip, "t2.zip", mf, dirs, "m2.zip.t")
416
+ ensure
417
+ FileUtils.rm_f "m2.zip.t"
418
+ end
419
+ def test_zip_filelist
420
+ assert_rant(:x, "t3.zip")
421
+ mf = %w(Rantfile sub/f1)
422
+ dirs = %w(sub)
423
+ check_contents(:zip, "t3.zip", mf, dirs)
424
+ end
425
+ end
@@ -26,3 +26,11 @@ end
26
26
  gen SubFile, "file.t" do |t|
27
27
  sys.touch t.name
28
28
  end
29
+
30
+ gen SubFile, "sub.t", "sub/file" => "file.t" do |t|
31
+ sys.touch t.name
32
+ end
33
+
34
+ gen SubFile, "a.t" => %w(file.t sub.t/file2) do |t|
35
+ sys.touch t.name
36
+ end
@@ -71,6 +71,18 @@ class TestSubFile < Test::Unit::TestCase
71
71
  out, err = assert_rant("file.t")
72
72
  assert(out.strip.empty?)
73
73
  end
74
+ def test_dependency
75
+ FileUtils.mkdir "sub.t"
76
+ assert_rant("sub.t/sub/file")
77
+ assert(test(?f, "file.t"))
78
+ assert(test(?f, "sub.t/sub/file"))
79
+ end
80
+ def test_dependencies
81
+ assert_rant("a.t")
82
+ assert(test(?f, "file.t"))
83
+ assert(test(?f, "sub.t/file2"))
84
+ assert(test(?f, "a.t"))
85
+ end
74
86
  def test_autoclean
75
87
  assert_rant("-fautoclean.rf", "sub.t/file")
76
88
  assert(test(?f, "sub.t/file"))
@@ -1,4 +1,4 @@
1
- import %w(rubytest rubydoc rubypackage)
1
+ import %w(rubytest rubydoc rubypackage clean)
2
2
 
3
3
  lib_files = Dir["lib/**/*.rb"]
4
4
  dist_files = lib_files + %w(rantfile.rb README test_project_rb1.rb) + Dir["{test,bin}/*"]
@@ -25,6 +25,5 @@ gen RubyPackage, :wgrep do |t|
25
25
  t.package_task "pkg"
26
26
  end
27
27
 
28
- task :clean do
29
- sys.rm_rf %w(doc packages)
30
- end
28
+ gen Clean
29
+ var[:clean].include "doc", "packages", "*~"