rake 10.1.0.beta.1 → 10.1.0.beta.2

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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6f3ce12012d73dcdfd6cfec09c9c7d22d8d84600
4
- data.tar.gz: deb2ee15747c685e35e5b29e244ee7a2a9ca55e6
3
+ metadata.gz: 3ff5ebacea4245cd96c888f824a9163986e69fdc
4
+ data.tar.gz: 70037bb8d8e6983e39fcea75475ccf96cf2a8223
5
5
  SHA512:
6
- metadata.gz: 7e1fdf44fc33efa1018d1b936044c6eca8144ae03c7a9a2354f1a1731268ff0f9589c4bf3bd70f2fff41e5813aba982c0ab157514dab3ab0f913550f5ba12d52
7
- data.tar.gz: 0a102b012351cf09af99924d9e78e48c3f07c091a39ab063304fc4c83a1dcb8490ebfed724efe77f86d7873ec90244cc1beb685534aa4d4c1e678c06fed3758f
6
+ metadata.gz: 0574f0908a532f8d382c5f4bb70182c55812e9866314e6c332cf22a577e3a63c4edde103eb47afee2703da689af8b39e3a78695b6fabfc5177f03b99f92e8917
7
+ data.tar.gz: cef1c1ec7ae6fd72e762baf4e9c27baea8fd4cac8bc68fbbf0e1ebb3238472071811c6d121da26d444766db3cd01e70ad4b16df60fe5d247470951f72761386b
data/Rakefile CHANGED
@@ -364,7 +364,7 @@ end
364
364
 
365
365
  load 'xforge.rf' if File.exist?('xforge.rf')
366
366
 
367
- desc "Where is the current directory. This task displays\nthe current rake directory"
367
+ desc "Where is the current directory. This task displays the current rake directory"
368
368
  task :where_am_i do
369
369
  puts Rake.original_dir
370
370
  end
@@ -40,6 +40,8 @@ require 'rake/ext/time'
40
40
 
41
41
  require 'rake/win32'
42
42
 
43
+ require 'rake/linked_list'
44
+ require 'rake/scope'
43
45
  require 'rake/task_argument_error'
44
46
  require 'rake/rule_recursion_overflow_error'
45
47
  require 'rake/rake_module'
@@ -116,6 +116,7 @@ module Rake
116
116
  end
117
117
 
118
118
  # Describe the next rake task.
119
+ # Duplicate descriptions are discarded.
119
120
  #
120
121
  # Example:
121
122
  # desc "Run the Unit Tests"
@@ -219,7 +219,7 @@ module Rake
219
219
  private :resolve_add
220
220
 
221
221
  def resolve_exclude
222
- reject! { |fn| exclude?(fn) }
222
+ reject! { |fn| excluded_from_list?(fn) }
223
223
  self
224
224
  end
225
225
  private :resolve_exclude
@@ -341,13 +341,19 @@ module Rake
341
341
  # Add matching glob patterns.
342
342
  def add_matching(pattern)
343
343
  FileList.glob(pattern).each do |fn|
344
- self << fn unless exclude?(fn)
344
+ self << fn unless excluded_from_list?(fn)
345
345
  end
346
346
  end
347
347
  private :add_matching
348
348
 
349
- # Should the given file name be excluded?
350
- def exclude?(fn)
349
+ # Should the given file name be excluded from the list?
350
+ #
351
+ # NOTE: This method was formally named "exclude?", but Rails
352
+ # introduced an exclude? method as an array method and setup a
353
+ # conflict with file list. We renamed the method to avoid
354
+ # confusion. If you were using "FileList#exclude?" in your user
355
+ # code, you will need to update.
356
+ def excluded_from_list?(fn)
351
357
  return true if @exclude_patterns.any? do |pat|
352
358
  case pat
353
359
  when Regexp
@@ -3,44 +3,48 @@ module Rake
3
3
  ####################################################################
4
4
  # InvocationChain tracks the chain of task invocations to detect
5
5
  # circular dependencies.
6
- class InvocationChain
7
- def initialize(value, tail)
8
- @value = value
9
- @tail = tail
10
- end
6
+ class InvocationChain < LinkedList
11
7
 
12
- def member?(obj)
13
- @value == obj || @tail.member?(obj)
8
+ # Is the invocation already in the chain?
9
+ def member?(invocation)
10
+ head == invocation || tail.member?(invocation)
14
11
  end
15
12
 
16
- def append(value)
17
- if member?(value)
18
- fail RuntimeError, "Circular dependency detected: #{to_s} => #{value}"
13
+ # Append an invocation to the chain of invocations. It is an error
14
+ # if the invocation already listed.
15
+ def append(invocation)
16
+ if member?(invocation)
17
+ fail RuntimeError, "Circular dependency detected: #{to_s} => #{invocation}"
19
18
  end
20
- self.class.new(value, self)
19
+ conj(invocation)
21
20
  end
22
21
 
22
+ # Convert to string, ie: TOP => invocation => invocation
23
23
  def to_s
24
- "#{prefix}#{@value}"
24
+ "#{prefix}#{head}"
25
25
  end
26
26
 
27
- def self.append(value, chain)
28
- chain.append(value)
27
+ # Class level append.
28
+ def self.append(invocation, chain)
29
+ chain.append(invocation)
29
30
  end
30
31
 
31
32
  private
32
33
 
33
34
  def prefix
34
- "#{@tail.to_s} => "
35
+ "#{tail.to_s} => "
35
36
  end
36
37
 
37
- class EmptyInvocationChain
38
+ # Null object for an empty chain.
39
+ class EmptyInvocationChain < LinkedList::EmptyLinkedList
40
+ @parent = InvocationChain
41
+
38
42
  def member?(obj)
39
43
  false
40
44
  end
41
45
 
42
- def append(value)
43
- InvocationChain.new(value, self)
46
+ def append(invocation)
47
+ conj(invocation)
44
48
  end
45
49
 
46
50
  def to_s
@@ -0,0 +1,103 @@
1
+ module Rake
2
+
3
+ # Polylithic linked list structure used to implement several data
4
+ # structures in Rake.
5
+ class LinkedList
6
+ include Enumerable
7
+
8
+ attr_reader :head, :tail
9
+
10
+ def initialize(head, tail=EMPTY)
11
+ @head = head
12
+ @tail = tail
13
+ end
14
+
15
+ # Polymorphically add a new element to the head of a list. The
16
+ # type of head node will be the same list type has the tail.
17
+ def conj(item)
18
+ self.class.cons(item, self)
19
+ end
20
+
21
+ # Is the list empty?
22
+ def empty?
23
+ false
24
+ end
25
+
26
+ # Lists are structurally equivalent.
27
+ def ==(other)
28
+ current = self
29
+ while ! current.empty? && ! other.empty?
30
+ return false if current.head != other.head
31
+ current = current.tail
32
+ other = other.tail
33
+ end
34
+ current.empty? && other.empty?
35
+ end
36
+
37
+ # Convert to string: LL(item, item...)
38
+ def to_s
39
+ items = map { |item| item.to_s }.join(", ")
40
+ "LL(#{items})"
41
+ end
42
+
43
+ # Same as +to_s+, but with inspected items.
44
+ def inspect
45
+ items = map { |item| item.inspect }.join(", ")
46
+ "LL(#{items})"
47
+ end
48
+
49
+ # For each item in the list.
50
+ def each
51
+ current = self
52
+ while ! current.empty?
53
+ yield(current.head)
54
+ current = current.tail
55
+ end
56
+ self
57
+ end
58
+
59
+ # Make a list out of the given arguments. This method is
60
+ # polymorphic
61
+ def self.make(*args)
62
+ result = empty
63
+ args.reverse_each do |item|
64
+ result = cons(item, result)
65
+ end
66
+ result
67
+ end
68
+
69
+ # Cons a new head onto the tail list.
70
+ def self.cons(head, tail)
71
+ new(head, tail)
72
+ end
73
+
74
+ # The standard empty list class for the given LinkedList class.
75
+ def self.empty
76
+ self::EMPTY
77
+ end
78
+
79
+ # Represent an empty list, using the Null Object Pattern.
80
+ #
81
+ # When inheriting from the LinkedList class, you should implement
82
+ # a type specific Empty class as well. Make sure you set the class
83
+ # instance variable @parent to the assocated list class (this
84
+ # allows conj, cons and make to work polymorphically).
85
+ class EmptyLinkedList < LinkedList
86
+ @parent = LinkedList
87
+
88
+ def initialize
89
+ end
90
+
91
+ def empty?
92
+ true
93
+ end
94
+
95
+ def self.cons(head, tail)
96
+ @parent.cons(head, tail)
97
+ end
98
+ end
99
+
100
+ EMPTY = EmptyLinkedList.new
101
+ end
102
+
103
+ end
@@ -0,0 +1,42 @@
1
+ module Rake
2
+ class Scope < LinkedList
3
+
4
+ # Path for the scope.
5
+ def path
6
+ map { |item| item.to_s }.reverse.join(":")
7
+ end
8
+
9
+ # Path for the scope + the named path.
10
+ def path_with_task_name(task_name)
11
+ "#{path}:#{task_name}"
12
+ end
13
+
14
+ # Trim +n+ innermost scope levels from the scope. In no case will
15
+ # this trim beyond the toplevel scope.
16
+ def trim(n)
17
+ result = self
18
+ while n > 0 && ! result.empty?
19
+ result = result.tail
20
+ n -= 1
21
+ end
22
+ result
23
+ end
24
+
25
+ # Scope lists always end with an EmptyScope object. See Null
26
+ # Object Pattern)
27
+ class EmptyScope < EmptyLinkedList
28
+ @parent = Scope
29
+
30
+ def path
31
+ ""
32
+ end
33
+
34
+ def path_with_task_name(task_name)
35
+ task_name
36
+ end
37
+ end
38
+
39
+ # Singleton null object for an empty scope.
40
+ EMPTY = EmptyScope.new
41
+ end
42
+ end
@@ -21,13 +21,6 @@ module Rake
21
21
  # Application owning this task.
22
22
  attr_accessor :application
23
23
 
24
- # Comment for this task. Restricted to a single line of no more than 50
25
- # characters.
26
- attr_reader :comment
27
-
28
- # Full text of the (possibly multi-line) comment.
29
- attr_reader :full_comment
30
-
31
24
  # Array of nested namespaces names used for task lookup by this task.
32
25
  attr_reader :scope
33
26
 
@@ -91,8 +84,7 @@ module Rake
91
84
  @prerequisites = []
92
85
  @actions = []
93
86
  @already_invoked = false
94
- @full_comment = nil
95
- @comment = nil
87
+ @comments = []
96
88
  @lock = Monitor.new
97
89
  @application = app
98
90
  @scope = app.current_scope
@@ -159,8 +151,7 @@ module Rake
159
151
 
160
152
  # Clear the existing comments on a rake task.
161
153
  def clear_comments
162
- @full_comment = nil
163
- @comment = nil
154
+ @comments = []
164
155
  self
165
156
  end
166
157
 
@@ -266,27 +257,42 @@ module Rake
266
257
  add_comment(comment) if comment && ! comment.empty?
267
258
  end
268
259
 
269
- # Writing to the comment attribute is the same as adding a description.
270
- def comment=(description)
271
- add_description(description)
260
+ def add_comment(comment)
261
+ @comments << comment unless @comments.include?(comment)
272
262
  end
263
+ private :add_comment
273
264
 
274
- # Add a comment to the task. If a comment already exists, separate
275
- # the new comment with " / ".
276
- def add_comment(comment)
277
- if @full_comment
278
- @full_comment << " / "
279
- else
280
- @full_comment = ''
281
- end
282
- @full_comment << comment
283
- if @full_comment =~ /\A([^.]+?\.)( |$)/
284
- @comment = $1
265
+ # Full collection of comments. Multiple comments are separated by
266
+ # newlines.
267
+ def full_comment
268
+ transform_comments("\n")
269
+ end
270
+
271
+ # First line (or sentence) of all comments. Multiple comments are
272
+ # separated by a "/".
273
+ def comment
274
+ transform_comments(" / ") { |c| first_sentence(c) }
275
+ end
276
+
277
+ # Transform the list of comments as specified by the block and
278
+ # join with the separator.
279
+ def transform_comments(separator, &block)
280
+ if @comments.empty?
281
+ nil
285
282
  else
286
- @comment = @full_comment
283
+ block ||= lambda { |c| c }
284
+ @comments.map(&block).join(separator)
287
285
  end
288
286
  end
289
- private :add_comment
287
+ private :transform_comments
288
+
289
+ # Get the first sentence in a string. The sentence is terminated
290
+ # by the first period or the end of the line. Decimal points do
291
+ # not count as periods.
292
+ def first_sentence(string)
293
+ string.split(/\.[ \t]|\.$|\n/).first
294
+ end
295
+ private :first_sentence
290
296
 
291
297
  # Set the names of the arguments for this task. +args+ should be
292
298
  # an array of symbols, one for each argument name.
@@ -359,7 +365,8 @@ module Rake
359
365
  # this kind of task. Generic tasks will accept the scope as
360
366
  # part of the name.
361
367
  def scope_name(scope, task_name)
362
- (scope + [task_name]).join(':')
368
+ # (scope + [task_name]).join(':')
369
+ scope.path_with_task_name(task_name)
363
370
  end
364
371
 
365
372
  end # class << Rake::Task
@@ -10,14 +10,14 @@ module Rake
10
10
  super
11
11
  @tasks = Hash.new
12
12
  @rules = Array.new
13
- @scope = Array.new
13
+ @scope = Scope.make
14
14
  @last_description = nil
15
15
  end
16
16
 
17
17
  def create_rule(*args, &block)
18
- pattern, _, deps = resolve_args(args)
18
+ pattern, args, deps = resolve_args(args)
19
19
  pattern = Regexp.new(Regexp.quote(pattern) + '$') if String === pattern
20
- @rules << [pattern, deps, block]
20
+ @rules << [pattern, args, deps, block]
21
21
  end
22
22
 
23
23
  def define_task(task_class, *args, &block)
@@ -116,9 +116,9 @@ module Rake
116
116
  def enhance_with_matching_rule(task_name, level=0)
117
117
  fail Rake::RuleRecursionOverflowError,
118
118
  "Rule Recursion Too Deep" if level >= 16
119
- @rules.each do |pattern, extensions, block|
119
+ @rules.each do |pattern, args, extensions, block|
120
120
  if pattern.match(task_name)
121
- task = attempt_rule(task_name, extensions, block, level)
121
+ task = attempt_rule(task_name, args, extensions, block, level)
122
122
  return task if task
123
123
  end
124
124
  end
@@ -136,7 +136,7 @@ module Rake
136
136
  # List of all the tasks defined in the given scope (and its
137
137
  # sub-scopes).
138
138
  def tasks_in_scope(scope)
139
- prefix = scope.join(":")
139
+ prefix = scope.path
140
140
  tasks.select { |t|
141
141
  /^#{prefix}:/ =~ t.name
142
142
  }
@@ -157,10 +157,10 @@ module Rake
157
157
  initial_scope ||= @scope
158
158
  task_name = task_name.to_s
159
159
  if task_name =~ /^rake:/
160
- scopes = []
160
+ scopes = Scope.make
161
161
  task_name = task_name.sub(/^rake:/, '')
162
162
  elsif task_name =~ /^(\^+)/
163
- scopes = initial_scope[0, initial_scope.size - $1.size]
163
+ scopes = initial_scope.trim($1.size)
164
164
  task_name = task_name.sub(/^(\^+)/, '')
165
165
  else
166
166
  scopes = initial_scope
@@ -170,12 +170,12 @@ module Rake
170
170
 
171
171
  # Lookup the task name
172
172
  def lookup_in_scope(name, scope)
173
- n = scope.size
174
- while n >= 0
175
- tn = (scope[0, n] + [name]).join(':')
173
+ loop do
174
+ tn = scope.path_with_task_name(name)
176
175
  task = @tasks[tn]
177
176
  return task if task
178
- n -= 1
177
+ break if scope.empty?
178
+ scope = scope.tail
179
179
  end
180
180
  nil
181
181
  end
@@ -184,19 +184,19 @@ module Rake
184
184
  # Return the list of scope names currently active in the task
185
185
  # manager.
186
186
  def current_scope
187
- @scope.dup
187
+ @scope
188
188
  end
189
189
 
190
190
  # Evaluate the block in a nested namespace named +name+. Create
191
191
  # an anonymous namespace if +name+ is nil.
192
192
  def in_namespace(name)
193
193
  name ||= generate_name
194
- @scope.push(name)
194
+ @scope = Scope.new(name, @scope)
195
195
  ns = NameSpace.new(self, @scope)
196
196
  yield(ns)
197
197
  ns
198
198
  ensure
199
- @scope.pop
199
+ @scope = @scope.tail
200
200
  end
201
201
 
202
202
  private
@@ -232,7 +232,7 @@ module Rake
232
232
  end
233
233
 
234
234
  # Attempt to create a rule given the list of prerequisites.
235
- def attempt_rule(task_name, extensions, block, level)
235
+ def attempt_rule(task_name, args, extensions, block, level)
236
236
  sources = make_sources(task_name, extensions)
237
237
  prereqs = sources.map { |source|
238
238
  trace_rule level, "Attempting Rule #{task_name} => #{source}"
@@ -247,7 +247,7 @@ module Rake
247
247
  return nil
248
248
  end
249
249
  }
250
- task = FileTask.define_task({task_name => prereqs}, &block)
250
+ task = FileTask.define_task(task_name, {args => prereqs}, &block)
251
251
  task.sources = prereqs
252
252
  task
253
253
  end
@@ -1,5 +1,5 @@
1
1
  module Rake
2
- VERSION = '10.1.0.beta.1'
2
+ VERSION = '10.1.0.beta.2'
3
3
 
4
4
  module Version # :nodoc: all
5
5
  MAJOR, MINOR, BUILD, *OTHER = Rake::VERSION.split '.'
@@ -166,7 +166,7 @@ class TestRakeFileList < Rake::TestCase
166
166
  def test_excluding_via_block
167
167
  fl = FileList['a.c', 'b.c', 'xyz.c']
168
168
  fl.exclude { |fn| fn.pathmap('%n') == 'xyz' }
169
- assert fl.exclude?("xyz.c"), "Should exclude xyz.c"
169
+ assert fl.excluded_from_list?("xyz.c"), "Should exclude xyz.c"
170
170
  assert_equal ['a.c', 'b.c'], fl
171
171
  end
172
172
 
@@ -404,24 +404,24 @@ class TestRakeFileList < Rake::TestCase
404
404
 
405
405
  def test_exclude_with_alternate_file_seps
406
406
  fl = FileList.new
407
- assert fl.exclude?("x/CVS/y")
408
- assert fl.exclude?("x\\CVS\\y")
409
- assert fl.exclude?("x/.svn/y")
410
- assert fl.exclude?("x\\.svn\\y")
411
- assert fl.exclude?("x/core")
412
- assert fl.exclude?("x\\core")
407
+ assert fl.excluded_from_list?("x/CVS/y")
408
+ assert fl.excluded_from_list?("x\\CVS\\y")
409
+ assert fl.excluded_from_list?("x/.svn/y")
410
+ assert fl.excluded_from_list?("x\\.svn\\y")
411
+ assert fl.excluded_from_list?("x/core")
412
+ assert fl.excluded_from_list?("x\\core")
413
413
  end
414
414
 
415
415
  def test_add_default_exclude_list
416
416
  fl = FileList.new
417
417
  fl.exclude(/~\d+$/)
418
- assert fl.exclude?("x/CVS/y")
419
- assert fl.exclude?("x\\CVS\\y")
420
- assert fl.exclude?("x/.svn/y")
421
- assert fl.exclude?("x\\.svn\\y")
422
- assert fl.exclude?("x/core")
423
- assert fl.exclude?("x\\core")
424
- assert fl.exclude?("x/abc~1")
418
+ assert fl.excluded_from_list?("x/CVS/y")
419
+ assert fl.excluded_from_list?("x\\CVS\\y")
420
+ assert fl.excluded_from_list?("x/.svn/y")
421
+ assert fl.excluded_from_list?("x\\.svn\\y")
422
+ assert fl.excluded_from_list?("x/core")
423
+ assert fl.excluded_from_list?("x\\core")
424
+ assert fl.excluded_from_list?("x/abc~1")
425
425
  end
426
426
 
427
427
  def test_basic_array_functions
@@ -68,7 +68,7 @@ class TestRakeFunctional < Rake::TestCase
68
68
 
69
69
  rake "--describe"
70
70
 
71
- assert_match %r{^rake a\n *A / A2 *$}m, @out
71
+ assert_match %r{^rake a\n *A\n *A2 *$}m, @out
72
72
  assert_match %r{^rake b\n *B *$}m, @out
73
73
  assert_match %r{^rake d\n *x{80}}m, @out
74
74
  refute_match %r{^rake c\n}m, @out
@@ -1,11 +1,12 @@
1
1
  require File.expand_path('../helper', __FILE__)
2
2
 
3
3
  class TestRakeInvocationChain < Rake::TestCase
4
+ include Rake
4
5
 
5
6
  def setup
6
7
  super
7
8
 
8
- @empty = Rake::InvocationChain::EMPTY
9
+ @empty = InvocationChain.empty
9
10
 
10
11
  @first_member = "A"
11
12
  @second_member = "B"
@@ -13,7 +14,19 @@ class TestRakeInvocationChain < Rake::TestCase
13
14
  @two = @one.append(@second_member)
14
15
  end
15
16
 
16
- def test_append
17
+ def test_conj_on_invocation_chains
18
+ list = InvocationChain.empty.conj("B").conj("A")
19
+ assert_equal InvocationChain.make("A", "B"), list
20
+ assert_equal InvocationChain, list.class
21
+ end
22
+
23
+ def test_make_on_invocation_chains
24
+ assert_equal @empty, InvocationChain.make()
25
+ assert_equal @one, InvocationChain.make(@first_member)
26
+ assert_equal @two, InvocationChain.make(@second_member, @first_member)
27
+ end
28
+
29
+ def test_append_with_one_argument
17
30
  chain = @empty.append("A")
18
31
 
19
32
  assert_equal 'TOP => A', chain.to_s # HACK
@@ -49,4 +62,3 @@ class TestRakeInvocationChain < Rake::TestCase
49
62
  end
50
63
 
51
64
  end
52
-
@@ -0,0 +1,84 @@
1
+ require File.expand_path('../helper', __FILE__)
2
+
3
+ class TestLinkedList < Rake::TestCase
4
+ include Rake
5
+
6
+ def test_empty_list
7
+ empty = LinkedList::EMPTY
8
+ assert empty.empty?, "should be empty"
9
+ end
10
+
11
+ def test_list_with_one_item
12
+ list = LinkedList.make(:one)
13
+ assert ! list.empty?, "should not be empty"
14
+ assert_equal :one, list.head
15
+ assert_equal LinkedList::EMPTY, list.tail
16
+ end
17
+
18
+ def test_make_with_no_arguments
19
+ empty = LinkedList.make()
20
+ assert_equal LinkedList::EMPTY, empty
21
+ end
22
+
23
+ def test_make_with_one_argument
24
+ list = LinkedList.make(:one)
25
+ assert ! list.empty?
26
+ assert_equal :one, list.head
27
+ assert_equal LinkedList::EMPTY, list.tail
28
+ end
29
+
30
+ def test_make_with_two_arguments
31
+ list = LinkedList.make(:one, :two)
32
+ assert ! list.empty?
33
+ assert_equal :one, list.head
34
+ assert_equal :two, list.tail.head
35
+ assert_equal LinkedList::EMPTY, list.tail.tail
36
+ end
37
+
38
+ def test_list_with_several_items
39
+ list = LinkedList.make(:one, :two, :three)
40
+
41
+ assert ! list.empty?, "should not be empty"
42
+ assert_equal :one, list.head
43
+ assert_equal :two, list.tail.head
44
+ assert_equal :three, list.tail.tail.head
45
+ assert_equal LinkedList::EMPTY, list.tail.tail.tail
46
+ end
47
+
48
+ def test_lists_are_structurally_equivalent
49
+ list = LinkedList.make(1, 2, 3)
50
+ same = LinkedList.make(1, 2, 3)
51
+ diff = LinkedList.make(1, 2, 4)
52
+ short = LinkedList.make(1, 2)
53
+
54
+ assert_equal list, same
55
+ refute_equal list, diff
56
+ refute_equal list, short
57
+ refute_equal short, list
58
+ end
59
+
60
+ def test_converstion_to_string
61
+ list = LinkedList.make(:one, :two, :three)
62
+ assert_equal "LL(one, two, three)", list.to_s
63
+ assert_equal "LL()", LinkedList.make().to_s
64
+ end
65
+
66
+ def test_converstion_with_inspect
67
+ list = LinkedList.make(:one, :two, :three)
68
+ assert_equal "LL(:one, :two, :three)", list.inspect
69
+ assert_equal "LL()", LinkedList.make().inspect
70
+ end
71
+
72
+ def test_lists_are_enumerable
73
+ list = LinkedList.make(1, 2, 3)
74
+ new_list = list.map { |item| item + 10 }
75
+ expected = [11, 12, 13]
76
+ assert_equal expected, new_list
77
+ end
78
+
79
+ def test_conjunction
80
+ list = LinkedList.make.conj("C").conj("B").conj("A")
81
+ assert_equal LinkedList.make("A", "B", "C"), list
82
+ end
83
+
84
+ end
@@ -323,4 +323,40 @@ class TestRakeRules < Rake::TestCase
323
323
  assert_raises(RuntimeError) do Task['a'].invoke end
324
324
  end
325
325
 
326
+ def test_string_rule_with_args
327
+ delete_file(OBJFILE)
328
+ create_file(SRCFILE)
329
+ rule '.o', [:a] => SRCFILE do |t, args|
330
+ assert_equal 'arg', args.a
331
+ end
332
+ Task[OBJFILE].invoke('arg')
333
+ end
334
+
335
+ def test_regex_rule_with_args
336
+ delete_file(OBJFILE)
337
+ create_file(SRCFILE)
338
+ rule(/.o$/, [:a] => SRCFILE) do |t, args|
339
+ assert_equal 'arg', args.a
340
+ end
341
+ Task[OBJFILE].invoke('arg')
342
+ end
343
+
344
+ def test_string_rule_with_args_and_lambda_prereq
345
+ delete_file(OBJFILE)
346
+ create_file(SRCFILE)
347
+ rule '.o', [:a] => [lambda{SRCFILE}]do |t, args|
348
+ assert_equal 'arg', args.a
349
+ end
350
+ Task[OBJFILE].invoke('arg')
351
+ end
352
+
353
+ def test_regex_rule_with_args_and_lambda_prereq
354
+ delete_file(OBJFILE)
355
+ create_file(SRCFILE)
356
+ rule(/.o$/, [:a] => [lambda{SRCFILE}]) do |t, args|
357
+ assert_equal 'arg', args.a
358
+ end
359
+ Task[OBJFILE].invoke('arg')
360
+ end
361
+
326
362
  end
@@ -0,0 +1,44 @@
1
+ require File.expand_path('../helper', __FILE__)
2
+
3
+ class TestRakeScope < Rake::TestCase
4
+ include Rake
5
+
6
+ def test_path_against_empty_scope
7
+ scope = Scope.make
8
+ assert_equal scope, Scope::EMPTY
9
+ assert_equal scope.path, ""
10
+ end
11
+
12
+ def test_path_against_one_element
13
+ scope = Scope.make(:one)
14
+ assert_equal "one", scope.path
15
+ end
16
+
17
+ def test_path_against_two_elements
18
+ scope = Scope.make(:inner, :outer)
19
+ assert_equal "outer:inner", scope.path
20
+ end
21
+
22
+ def test_path_with_task_name
23
+ scope = Scope.make(:inner, :outer)
24
+ assert_equal "outer:inner:task", scope.path_with_task_name("task")
25
+ end
26
+
27
+ def test_path_with_task_name_against_empty_scope
28
+ scope = Scope.make
29
+ assert_equal "task", scope.path_with_task_name("task")
30
+ end
31
+
32
+ def test_conj_against_two_elements
33
+ scope = Scope.make.conj("B").conj("A")
34
+ assert_equal Scope.make("A", "B"), scope
35
+ end
36
+
37
+ def test_trim
38
+ scope = Scope.make("A", "B")
39
+ assert_equal scope, scope.trim(0)
40
+ assert_equal scope.tail, scope.trim(1)
41
+ assert_equal scope.tail.tail, scope.trim(2)
42
+ assert_equal scope.tail.tail, scope.trim(3)
43
+ end
44
+ end
@@ -308,6 +308,24 @@ class TestRakeTask < Rake::TestCase
308
308
  end
309
309
 
310
310
 
311
+ def test_comments_with_sentences
312
+ desc "Comment 1. Comment 2."
313
+ t = task(:t, :name, :rev)
314
+ assert_equal "Comment 1", t.comment
315
+ end
316
+
317
+ def test_comments_with_tabbed_sentences
318
+ desc "Comment 1.\tComment 2."
319
+ t = task(:t, :name, :rev)
320
+ assert_equal "Comment 1", t.comment
321
+ end
322
+
323
+ def test_comments_with_decimal_points
324
+ desc "Revision 1.2.3."
325
+ t = task(:t, :name, :rev)
326
+ assert_equal "Revision 1.2.3", t.comment
327
+ end
328
+
311
329
  def test_extended_comments
312
330
  desc %{
313
331
  This is a comment.
@@ -318,7 +336,7 @@ class TestRakeTask < Rake::TestCase
318
336
  }
319
337
  t = task(:t, :name, :rev)
320
338
  assert_equal "[name,rev]", t.arg_description
321
- assert_equal "This is a comment.", t.comment
339
+ assert_equal "This is a comment", t.comment
322
340
  assert_match(/^\s*name -- Name/, t.full_comment)
323
341
  assert_match(/^\s*rev -- Software/, t.full_comment)
324
342
  assert_match(/\A\s*This is a comment\.$/, t.full_comment)
@@ -332,9 +350,21 @@ class TestRakeTask < Rake::TestCase
332
350
  assert_equal "line one / line two", t.comment
333
351
  end
334
352
 
335
- def test_settable_comments
353
+ def test_duplicate_comments
354
+ desc "line one"
336
355
  t = task(:t)
337
- t.comment = "HI"
338
- assert_equal "HI", t.comment
356
+ desc "line one"
357
+ task(:t)
358
+ assert_equal "line one", t.comment
359
+ end
360
+
361
+ def test_interspersed_duplicate_comments
362
+ desc "line one"
363
+ t = task(:t)
364
+ desc "line two"
365
+ task(:t)
366
+ desc "line one"
367
+ task(:t)
368
+ assert_equal "line one / line two", t.comment
339
369
  end
340
370
  end
@@ -93,7 +93,7 @@ class TestRakeTaskManager < Rake::TestCase
93
93
  bb = @tm.define_task(Rake::Task, :bb)
94
94
  bot_z = @tm.define_task(Rake::Task, :z)
95
95
 
96
- assert_equal ["a", "b"], @tm.current_scope
96
+ assert_equal Rake::Scope.make("b", "a"), @tm.current_scope
97
97
 
98
98
  assert_equal bb, @tm["a:b:bb"]
99
99
  assert_equal aa, @tm["a:aa"]
@@ -101,10 +101,11 @@ class TestRakeTaskManager < Rake::TestCase
101
101
  assert_equal bot_z, @tm["z"]
102
102
  assert_equal mid_z, @tm["^z"]
103
103
  assert_equal top_z, @tm["^^z"]
104
+ assert_equal top_z, @tm["^^^z"] # Over the top
104
105
  assert_equal top_z, @tm["rake:z"]
105
106
  end
106
107
 
107
- assert_equal ["a"], @tm.current_scope
108
+ assert_equal Rake::Scope.make("a"), @tm.current_scope
108
109
 
109
110
  assert_equal bb, @tm["a:b:bb"]
110
111
  assert_equal aa, @tm["a:aa"]
@@ -113,14 +114,15 @@ class TestRakeTaskManager < Rake::TestCase
113
114
  assert_equal aa, @tm["aa"]
114
115
  assert_equal mid_z, @tm["z"]
115
116
  assert_equal top_z, @tm["^z"]
117
+ assert_equal top_z, @tm["^^z"] # Over the top
116
118
  assert_equal top_z, @tm["rake:z"]
117
119
  end
118
120
 
119
- assert_equal [], @tm.current_scope
121
+ assert_equal Rake::Scope.make, @tm.current_scope
120
122
 
121
- assert_equal [], xx.scope
122
- assert_equal ['a'], aa.scope
123
- assert_equal ['a', 'b'], bb.scope
123
+ assert_equal Rake::Scope.make, xx.scope
124
+ assert_equal Rake::Scope.make('a'), aa.scope
125
+ assert_equal Rake::Scope.make('b', 'a'), bb.scope
124
126
  end
125
127
 
126
128
  def test_lookup_with_explicit_scopes
@@ -133,11 +135,11 @@ class TestRakeTaskManager < Rake::TestCase
133
135
  t3 = @tm.define_task(Rake::Task, :t)
134
136
  end
135
137
  end
136
- assert_equal t1, @tm[:t, []]
137
- assert_equal t2, @tm[:t, ["a"]]
138
- assert_equal t3, @tm[:t, ["a", "b"]]
139
- assert_equal s, @tm[:s, ["a", "b"]]
140
- assert_equal s, @tm[:s, ["a"]]
138
+ assert_equal t1, @tm[:t, Rake::Scope.make]
139
+ assert_equal t2, @tm[:t, Rake::Scope.make("a")]
140
+ assert_equal t3, @tm[:t, Rake::Scope.make("b", "a")]
141
+ assert_equal s, @tm[:s, Rake::Scope.make("b", "a")]
142
+ assert_equal s, @tm[:s, Rake::Scope.make("a")]
141
143
  end
142
144
 
143
145
  def test_correctly_scoped_prerequisites_are_invoked
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.1.0.beta.1
4
+ version: 10.1.0.beta.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Weirich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-26 00:00:00.000000000 Z
11
+ date: 2013-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -105,6 +105,7 @@ files:
105
105
  - lib/rake/gempackagetask.rb
106
106
  - lib/rake/invocation_chain.rb
107
107
  - lib/rake/invocation_exception_mixin.rb
108
+ - lib/rake/linked_list.rb
108
109
  - lib/rake/loaders/makefile.rb
109
110
  - lib/rake/multi_task.rb
110
111
  - lib/rake/name_space.rb
@@ -120,6 +121,7 @@ files:
120
121
  - lib/rake/ruby182_test_unit_fix.rb
121
122
  - lib/rake/rule_recursion_overflow_error.rb
122
123
  - lib/rake/runtest.rb
124
+ - lib/rake/scope.rb
123
125
  - lib/rake/task.rb
124
126
  - lib/rake/task_argument_error.rb
125
127
  - lib/rake/task_arguments.rb
@@ -152,6 +154,7 @@ files:
152
154
  - test/test_rake_ftp_file.rb
153
155
  - test/test_rake_functional.rb
154
156
  - test/test_rake_invocation_chain.rb
157
+ - test/test_rake_linked_list.rb
155
158
  - test/test_rake_makefile_loader.rb
156
159
  - test/test_rake_multi_task.rb
157
160
  - test/test_rake_name_space.rb
@@ -164,6 +167,7 @@ files:
164
167
  - test/test_rake_reduce_compat.rb
165
168
  - test/test_rake_require.rb
166
169
  - test/test_rake_rules.rb
170
+ - test/test_rake_scope.rb
167
171
  - test/test_rake_task.rb
168
172
  - test/test_rake_task_argument_parsing.rb
169
173
  - test/test_rake_task_arguments.rb