rake 0.5.0 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rake might be problematic. Click here for more details.

@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ module Rake
4
+
5
+ # Makefile loader to be used with the import file loader.
6
+ class MakefileLoader
7
+
8
+ # Load the makefile dependencies in +fn+.
9
+ def load(fn)
10
+ buffer = ''
11
+ open(fn) do |mf|
12
+ mf.each do |line|
13
+ next if line =~ /^\s*#/
14
+ buffer << line
15
+ if buffer =~ /\\$/
16
+ buffer.sub!(/\\\n/, ' ')
17
+ state = :append
18
+ else
19
+ process_line(buffer)
20
+ buffer = ''
21
+ end
22
+ end
23
+ end
24
+ process_line(buffer) if buffer != ''
25
+ end
26
+
27
+ private
28
+
29
+ # Process one logical line of makefile data.
30
+ def process_line(line)
31
+ file_task, args = line.split(':')
32
+ return if args.nil?
33
+ dependents = args.split
34
+ file file_task => dependents
35
+ end
36
+ end
37
+
38
+ # Install the handler
39
+ Rake.application.add_loader('mf', MakefileLoader.new)
40
+
41
+ end
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Load the test files from the command line.
4
+
5
+ ARGV.each { |f| load f }
@@ -1,19 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'rake'
4
+
3
5
  module Rake
4
6
 
5
7
  # Base class for Task Libraries.
6
8
  class TaskLib
7
9
 
8
- # Make a copy of a task.
9
- def clone
10
- sibling = self.class.new
11
- instance_variables.each do |ivar|
12
- value = self.instance_variable_get(ivar)
13
- sibling.instance_variable_set(ivar, value.dup) if value
14
- end
15
- sibling
16
- end
10
+ include Cloneable
17
11
 
18
12
  # Make a symbol by pasting two strings together.
19
13
  def paste(a,b)
@@ -58,6 +58,14 @@ module Rake
58
58
  # Glob pattern to match test files. (default is 'test/test*.rb')
59
59
  attr_accessor :pattern
60
60
 
61
+ # Style of test loader to use. Options are:
62
+ #
63
+ # * :rake -- Rake provided test loading script (default).
64
+ # * :testrb -- Ruby provided test loading script.
65
+ # * :direct -- Load tests using command line loader.
66
+ #
67
+ attr_accessor :loader
68
+
61
69
  # Explicitly define the list of test files to be included in a
62
70
  # test. +list+ is expected to be an array of file names (a
63
71
  # FileList is acceptable). If both +pattern+ and +test_files+ are
@@ -75,6 +83,7 @@ module Rake
75
83
  @test_files = nil
76
84
  @verbose = false
77
85
  @warning = false
86
+ @loader = :rake
78
87
  yield self if block_given?
79
88
  @pattern = 'test/test*.rb' if @pattern.nil? && @test_files.nil?
80
89
  define
@@ -86,8 +95,20 @@ module Rake
86
95
  warning_flag = (@warning ? "-w " : "")
87
96
  desc "Run tests" + (@name==:test ? "" : " for #{@name}")
88
97
  task @name do
98
+ run_code = ''
89
99
  RakeFileUtils.verbose(@verbose) do
90
- ruby %{-I#{lib_path} #{warning_flag}-S testrb #{fix} #{file_list.join(' ')} #{option_list}}
100
+ run_code =
101
+ case @loader
102
+ when :direct
103
+ "-e 'ARGV.each{|f| load f}'"
104
+ when :testrb
105
+ "-S testrb #{fix}"
106
+ when :rake
107
+ rake_loader
108
+ end
109
+ ruby "-I#{lib_path} #{warning_flag}#{run_code} " +
110
+ file_list.join(' ') +
111
+ " #{option_list}"
91
112
  end
92
113
  end
93
114
  self
@@ -108,16 +129,21 @@ module Rake
108
129
  end
109
130
  end
110
131
 
111
- def fix
132
+ def fix # :nodoc:
112
133
  case RUBY_VERSION
113
134
  when '1.8.2'
114
- find_fix_file 'rake/ruby182_test_unit_fix'
135
+ find_file 'rake/ruby182_test_unit_fix'
115
136
  else
116
137
  nil
117
138
  end || ''
118
139
  end
119
140
 
120
- def find_fix_file(fn)
141
+ def rake_loader # :nodoc:
142
+ find_file('rake/rake_test_loader') or
143
+ fail "unable to find rake test loader"
144
+ end
145
+
146
+ def find_file(fn) # :nodoc:
121
147
  $LOAD_PATH.each do |path|
122
148
  file_path = File.join(path, "#{fn}.rb")
123
149
  return file_path if File.exist? file_path
@@ -99,6 +99,25 @@ class FunctionalTest < Test::Unit::TestCase
99
99
  assert_status
100
100
  end
101
101
 
102
+ def test_imports
103
+ FileUtils.rm_f "test/data/imports/dynamic_deps"
104
+ Dir.chdir("test/data/imports") do rake end
105
+ assert File.exist?("test/data/imports/dynamic_deps"),
106
+ "'dynamic_deps' file should exist"
107
+ assert_match(/^FIRST$\s+^DYNAMIC$\s+^STATIC$\s+^OTHER$/, @out)
108
+ assert_status
109
+ end
110
+
111
+ def test_rules_chaining_to_file_task
112
+ %w(play.scpt play.app).each do |fn|
113
+ FileUtils.rm_f File.join("test/data/chains", fn)
114
+ end
115
+ Dir.chdir("test/data/chains") do rake end
116
+ assert File.exist?("test/data/chains/play.app"),
117
+ "'play.app' file should exist"
118
+ assert_status
119
+ end
120
+
102
121
  private
103
122
 
104
123
  def rake(*option_list)
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test/unit'
4
+ require 'rake'
5
+ require 'rake/loaders/makefile'
6
+
7
+ class TestMakefileLoader < Test::Unit::TestCase
8
+ def test_create
9
+ Task.clear
10
+ loader = Rake::MakefileLoader.new
11
+ loader.load("test/data/sample.mf")
12
+ %w(a b c d).each do |t|
13
+ assert Task.task_defined?(t), "#{t} should be a defined task"
14
+ end
15
+ assert_equal %w(a1 a2 a3 a4 a5 a6 a7).sort, Task['a'].prerequisites.sort
16
+ assert_equal %w(b1 b2 b3 b4 b5 b6 b7).sort, Task['b'].prerequisites.sort
17
+ assert_equal %w(c1).sort, Task['c'].prerequisites.sort
18
+ assert_equal %w(d1 d2).sort, Task['d'].prerequisites.sort
19
+ assert_equal 4, Task.tasks.size
20
+ end
21
+ end
@@ -44,8 +44,9 @@ class TestFileList < Test::Unit::TestCase
44
44
 
45
45
  def test_add_many
46
46
  fl = FileList.new
47
- fl.include %w(a d c )
47
+ fl.include %w(a d c)
48
48
  fl.include('x', 'y')
49
+ assert_equal ['a', 'd', 'c', 'x', 'y'], fl
49
50
  assert_equal ['a', 'd', 'c', 'x', 'y'], fl.resolve
50
51
  end
51
52
 
@@ -137,6 +138,14 @@ class TestFileList < Test::Unit::TestCase
137
138
  assert_equal "a.java b.java", "#{fl}"
138
139
  end
139
140
 
141
+ def test_to_array
142
+ fl = FileList['a.java', 'b.java']
143
+ assert_equal ['a.java', 'b.java'], fl.to_a
144
+ assert_equal Array, fl.to_a.class
145
+ assert_equal ['a.java', 'b.java'], fl.to_ary
146
+ assert_equal Array, fl.to_ary.class
147
+ end
148
+
140
149
  def test_to_s_pending
141
150
  fl = FileList['testdata/abc.*']
142
151
  assert_equal %{testdata/abc.c}, fl.to_s
@@ -180,6 +189,33 @@ class TestFileList < Test::Unit::TestCase
180
189
  f2.sort
181
190
  end
182
191
 
192
+ def test_string_ext
193
+ assert_equal "one.net", "one.two".ext("net")
194
+ assert_equal "one.net", "one.two".ext(".net")
195
+ assert_equal "one.net", "one".ext("net")
196
+ assert_equal "one.net", "one".ext(".net")
197
+ assert_equal "one.two.net", "one.two.c".ext(".net")
198
+ assert_equal "one/two.net", "one/two.c".ext(".net")
199
+ assert_equal "one.x/two.net", "one.x/two.c".ext(".net")
200
+ assert_equal "one.x\\two.net", "one.x\\two.c".ext(".net")
201
+ assert_equal "one.x/two.net", "one.x/two".ext(".net")
202
+ assert_equal "one.x\\two.net", "one.x\\two".ext(".net")
203
+ assert_equal ".onerc.net", ".onerc.dot".ext("net")
204
+ assert_equal ".onerc.net", ".onerc".ext("net")
205
+ assert_equal ".a/.onerc.net", ".a/.onerc".ext("net")
206
+ assert_equal "one", "one.two".ext('')
207
+ assert_equal "one", "one.two".ext
208
+ assert_equal ".one", ".one.two".ext
209
+ assert_equal ".one", ".one".ext
210
+ assert_equal ".", ".".ext("c")
211
+ assert_equal "..", "..".ext("c")
212
+ end
213
+
214
+ def test_filelist_ext
215
+ assert_equal FileList['one.c', '.one.c'],
216
+ FileList['one.net', '.one'].ext('c')
217
+ end
218
+
183
219
  def test_gsub
184
220
  create_test_data
185
221
  fl = FileList["testdata/*.c"]
@@ -237,6 +273,156 @@ class TestFileList < Test::Unit::TestCase
237
273
  assert_equal ['a', 'b', 'c'], f
238
274
  end
239
275
 
276
+ def test_flatten
277
+ assert_equal ['a', 'testdata/x.c', 'testdata/xyz.c', 'testdata/abc.c'].sort,
278
+ ['a', FileList['testdata/*.c']].flatten.sort
279
+ end
280
+
281
+ def test_clone
282
+ a = FileList['a', 'b', 'c']
283
+ b = a.clone
284
+ a << 'd'
285
+ assert_equal ['a', 'b', 'c', 'd'], a
286
+ assert_equal ['a', 'b', 'c'], b
287
+ end
288
+
289
+ def test_array_comparisons
290
+ fl = FileList['b', 'b']
291
+ a = ['b', 'a']
292
+ b = ['b', 'b']
293
+ c = ['b', 'c']
294
+ assert_equal( 1, fl <=> a )
295
+ assert_equal( 0, fl <=> b )
296
+ assert_equal( -1, fl <=> c )
297
+ assert_equal( -1, a <=> fl )
298
+ assert_equal( 0, b <=> fl )
299
+ assert_equal( 1, c <=> fl )
300
+ end
301
+
302
+ def test_array_equality
303
+ a = FileList['a', 'b']
304
+ b = ['a', 'b']
305
+ assert a == b
306
+ assert b == a
307
+ # assert a.eql?(b)
308
+ # assert b.eql?(a)
309
+ assert ! a.equal?(b)
310
+ assert ! b.equal?(a)
311
+ end
312
+
313
+ def test_enumeration_methods
314
+ a = FileList['a', 'b']
315
+ b = a.collect { |it| it.upcase }
316
+ assert_equal ['A', 'B'], b
317
+ assert_equal FileList, b.class
318
+
319
+ b = a.map { |it| it.upcase }
320
+ assert_equal ['A', 'B'], b
321
+ assert_equal FileList, b.class
322
+
323
+ b = a.sort
324
+ assert_equal ['a', 'b'], b
325
+ assert_equal FileList, b.class
326
+
327
+ b = a.sort_by { |it| it }
328
+ assert_equal ['a', 'b'], b
329
+ assert_equal FileList, b.class
330
+
331
+ b = a.find_all { |it| it == 'b'}
332
+ assert_equal ['b'], b
333
+ assert_equal FileList, b.class
334
+
335
+ b = a.select { |it| it.size == 1 }
336
+ assert_equal ['a', 'b'], b
337
+ assert_equal FileList, b.class
338
+
339
+ b = a.reject { |it| it == 'b' }
340
+ assert_equal ['a'], b
341
+ assert_equal FileList, b.class
342
+
343
+ b = a.grep(/./)
344
+ assert_equal ['a', 'b'], b
345
+ assert_equal FileList, b.class
346
+
347
+ b = a.partition { |it| it == 'b' }
348
+ assert_equal [['b'], ['a']], b
349
+ assert_equal Array, b.class
350
+ assert_equal FileList, b[0].class
351
+ assert_equal FileList, b[1].class
352
+
353
+ b = a.zip(['x', 'y'])
354
+ assert_equal [['a', 'x'], ['b', 'y']], b
355
+ assert_equal Array, b.class
356
+ assert_equal Array, b[0].class
357
+ assert_equal Array, b[1].class
358
+ end
359
+
360
+ def test_array_operators
361
+ a = ['a', 'b']
362
+ b = ['c', 'd']
363
+ f = FileList['x', 'y']
364
+ g = FileList['w', 'z']
365
+
366
+ r = f + g
367
+ assert_equal ['x', 'y', 'w', 'z'], r
368
+ assert_equal FileList, r.class
369
+
370
+ r = a + g
371
+ assert_equal ['a', 'b', 'w', 'z'], r
372
+ assert_equal Array, r.class
373
+
374
+ r = f + b
375
+ assert_equal ['x', 'y', 'c', 'd'], r
376
+ assert_equal FileList, r.class
377
+
378
+ r = FileList['w', 'x', 'y', 'z'] - f
379
+ assert_equal ['w', 'z'], r
380
+ assert_equal FileList, r.class
381
+
382
+ r = FileList['w', 'x', 'y', 'z'] & f
383
+ assert_equal ['x', 'y'], r
384
+ assert_equal FileList, r.class
385
+
386
+ r = f * 2
387
+ assert_equal ['x', 'y', 'x', 'y'], r
388
+ assert_equal FileList, r.class
389
+
390
+ r = f * ','
391
+ assert_equal 'x,y', r
392
+ assert_equal String, r.class
393
+
394
+ r = f | ['a', 'x']
395
+ assert_equal ['a', 'x', 'y'].sort, r.sort
396
+ assert_equal FileList, r.class
397
+ end
398
+
399
+ def test_other_array_returning_methods
400
+ f = FileList['a', nil, 'b']
401
+ r = f.compact
402
+ assert_equal ['a', 'b'], r
403
+ assert_equal FileList, r.class
404
+
405
+ f = FileList['a', 'b']
406
+ r = f.concat(['x', 'y'])
407
+ assert_equal ['a', 'b', 'x', 'y'], r
408
+ assert_equal FileList, r.class
409
+
410
+ f = FileList['a', ['b', 'c'], FileList['d', 'e']]
411
+ r = f.flatten
412
+ assert_equal ['a', 'b', 'c', 'd', 'e'], r
413
+ assert_equal FileList, r.class
414
+
415
+ f = FileList['a', 'b', 'a']
416
+ r = f.uniq
417
+ assert_equal ['a', 'b'], r
418
+ assert_equal FileList, r.class
419
+
420
+ f = FileList['a', 'b', 'c', 'd']
421
+ r = f.values_at(1,3)
422
+ assert_equal ['b', 'd'], r
423
+ assert_equal FileList, r.class
424
+ end
425
+
240
426
  def create_test_data
241
427
  verbose(false) do
242
428
  mkdir "testdata" unless File.exist? "testdata"
@@ -15,7 +15,8 @@ class TestTask < Test::Unit::TestCase
15
15
  arg = nil
16
16
  t = Task.lookup(:name).enhance { |task| arg = task; 1234 }
17
17
  assert_equal "name", t.name
18
- assert [], t.prerequisites
18
+ assert_equal [], t.prerequisites
19
+ assert t.prerequisites.is_a?(FileList)
19
20
  assert t.needed?
20
21
  t.execute
21
22
  assert_equal t, arg
@@ -211,7 +212,7 @@ class TestDefinitions < Test::Unit::TestCase
211
212
  assert_equal [n2.to_s], t.prerequisites.collect{|n| n.to_s}
212
213
  t.invoke
213
214
  t2 = Task[n2]
214
- assert_equal [], t2.prerequisites
215
+ assert_equal FileList[], t2.prerequisites
215
216
  t3 = Task[n3]
216
217
  assert_equal [n1.to_s, n2.to_s], t3.prerequisites.collect{|n|n.to_s}
217
218
  end
@@ -244,9 +245,10 @@ class TestDefinitions < Test::Unit::TestCase
244
245
  private # ----------------------------------------------------------
245
246
 
246
247
  def create_existing_file
247
- if ! File.exist?(EXISTINGFILE)
248
- open(EXISTINGFILE, "w") do |f| f.puts "HI" end
249
- end
248
+ Dir.mkdir File.dirname(EXISTINGFILE) unless
249
+ File.exist?(File.dirname(EXISTINGFILE))
250
+ open(EXISTINGFILE, "w") do |f| f.puts "HI" end unless
251
+ File.exist?(EXISTINGFILE)
250
252
  end
251
253
 
252
254
  end
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.10
2
+ rubygems_version: 0.8.10.1
3
3
  specification_version: 1
4
4
  name: rake
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.5.0
7
- date: 2005-03-25
6
+ version: 0.5.3
7
+ date: 2005-04-09
8
8
  summary: Ruby based make-like utility.
9
9
  require_paths:
10
10
  - lib
@@ -43,12 +43,14 @@ files:
43
43
  - lib/rake/testtask.rb
44
44
  - lib/rake/gempackagetask.rb
45
45
  - lib/rake/ruby182_test_unit_fix.rb
46
+ - lib/rake/rake_test_loader.rb
46
47
  - lib/rake/contrib/ftptools.rb
47
48
  - lib/rake/contrib/sys.rb
48
49
  - lib/rake/contrib/compositepublisher.rb
49
50
  - lib/rake/contrib/publisher.rb
50
51
  - lib/rake/contrib/rubyforgepublisher.rb
51
52
  - lib/rake/contrib/sshpublisher.rb
53
+ - lib/rake/loaders/makefile.rb
52
54
  - test/filecreation.rb
53
55
  - test/testclean.rb
54
56
  - test/testfilelist.rb
@@ -59,6 +61,7 @@ files:
59
61
  - test/testpackagetask.rb
60
62
  - test/functional.rb
61
63
  - test/testtesttask.rb
64
+ - test/test_makefile_loader.rb
62
65
  - test/contrib/testsys.rb
63
66
  - test/data/rbext/rakefile.rb
64
67
  - doc/example