rake 0.7.0 → 0.7.1

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.

data/CHANGES CHANGED
@@ -1,6 +1,20 @@
1
1
  = Rake Changelog
2
2
 
3
- == Pre-Version 0.7.0
3
+ == Version 0.7.1
4
+
5
+ * Added optional filter parameter to the --tasks command line option.
6
+ * Added flatten to allow rule transform procs to return lists of
7
+ prereqs (Joel VanderWerf provided patch).
8
+ * Added pathmap to String and FileList.
9
+ * The -r option will now load .rake files (but a straight require
10
+ doesn't yet). NOTE: This is experimental ... it may be
11
+ discontinued.
12
+ * The -f option without a value will disable the search for a
13
+ Rakefile. The assumption is that the -r files are adequate.
14
+ * Fixed the safe_ln function to fall back to cp in more error
15
+ scenarios.
16
+
17
+ == Version 0.7.0
4
18
 
5
19
  * Added Rake.original_dir to return the original starting directory of
6
20
  the rake application.
data/README CHANGED
@@ -108,6 +108,8 @@ package.
108
108
  Rake is a late entry in the make replacement field. Here are links to
109
109
  other projects with similar (and not so similar) goals.
110
110
 
111
+ * http://directory.fsf.org/bras.html -- Bras, one of earliest
112
+ implementations of "make in a scripting language".
111
113
  * http://www.a-a-p.org -- Make in Python
112
114
  * http://www.aromatic.com/tools/jam.txt -- JAM, Java Automated Make
113
115
  * http://ant.apache.org -- The Ant project
data/Rakefile CHANGED
@@ -245,7 +245,7 @@ load "publish.rf" if File.exist? "publish.rf"
245
245
 
246
246
  desc "Look for TODO and FIXME tags in the code"
247
247
  task :todo do
248
- FileList['**/*.rb'].egrep /#.*(FIXME|TODO|TBD)/
248
+ FileList['**/*.rb'].exclude('pkg').egrep /#.*(FIXME|TODO|TBD)/
249
249
  end
250
250
 
251
251
  desc "Look for Debugging print lines"
@@ -0,0 +1,59 @@
1
+ = Rake 0.7.1 Released
2
+
3
+ Version 0.7.1 supplies a bug fix and a few minor enhancements.
4
+
5
+ == Changes
6
+
7
+ === Bug Fixes in 0.7.1
8
+
9
+ * Changes in the exception reported for the FileUtils.ln caused
10
+ safe_ln to fail with a NotImplementedError. Rake 0.7.1 will now
11
+ catch that error or any StandardError and properly fall back to
12
+ using +cp+.
13
+
14
+ === New Features in 0.7.1
15
+
16
+ * You can filter the results of the --task option by supplying an
17
+ optional regular expression. This allows the user to easily find a
18
+ particular task name in a long list of possible names.
19
+
20
+ * Transforming procs in a rule may now return a list of prerequisites.
21
+ This allows more flexible rule formation.
22
+
23
+ * FileList and String now support a +pathmap+ melthod that makes the
24
+ transforming paths a bit easier. See the API docs for +pathmap+ for
25
+ details.
26
+
27
+ * The -f option without a value will disable the search for a
28
+ Rakefile. This allows the Rakefile to be defined entirely in a
29
+ library (and loaded with the -r option). The current working
30
+ directory is not changed when this is done.
31
+
32
+ == What is Rake
33
+
34
+ Rake is a build tool similar to the make program in many ways. But
35
+ instead of cryptic make recipes, Rake uses standard Ruby code to
36
+ declare tasks and dependencies. You have the full power of a modern
37
+ scripting language built right into your build tool.
38
+
39
+ == Availability
40
+
41
+ The easiest way to get and install rake is via RubyGems ...
42
+
43
+ gem install rake (you may need root/admin privileges)
44
+
45
+ Otherwise, you can get it from the more traditional places:
46
+
47
+ Home Page:: http://rake.rubyforge.org/
48
+ Download:: http://rubyforge.org/project/showfiles.php?group_id=50
49
+
50
+ == Thanks
51
+
52
+ As usual, it was input from users that drove a alot of these changes.
53
+ The following people either contributed patches, made suggestions or
54
+ made otherwise helpful comments. Thanks to ...
55
+
56
+ * James Britt and Assaph Mehr for reporting and helping to debug the
57
+ safe_ln issue.
58
+
59
+ -- Jim Weirich
@@ -29,7 +29,7 @@
29
29
  # referenced as a library via a require statement, but it can be
30
30
  # distributed independently as an application.
31
31
 
32
- RAKEVERSION = '0.7.0'
32
+ RAKEVERSION = '0.7.1'
33
33
 
34
34
  require 'rbconfig'
35
35
  require 'ftools'
@@ -78,9 +78,164 @@ class String
78
78
  dup.sub!(%r(([^/\\])\.[^./\\]*$)) { $1 + newext } || self + newext
79
79
  end
80
80
  end
81
- end
82
81
 
83
82
 
83
+ unless instance_methods.include? "pathmap"
84
+ # Explode a path into individual components. Used by +pathmap+.
85
+ def pathmap_explode
86
+ head, tail = File.split(self)
87
+ return [self] if head == self
88
+ return [tail] if head == '.' || tail == '/'
89
+ return [head, tail] if head == '/'
90
+ return head.pathmap_explode + [tail]
91
+ end
92
+ protected :pathmap_explode
93
+
94
+ # Extract a partial path from the path. Include +n+ directories
95
+ # from the front end (left hand side) if +n+ is positive. Include
96
+ # |+n+| directories from the back end (right hand side) if +n+ is
97
+ # negative.
98
+ def pathmap_partial(n)
99
+ target = File.dirname(self)
100
+ dirs = target.pathmap_explode
101
+ if n > 0
102
+ File.join(dirs[0...n])
103
+ elsif n < 0
104
+ partial = dirs[n..-1]
105
+ if partial.nil? || partial.empty?
106
+ target
107
+ else
108
+ File.join(partial)
109
+ end
110
+ else
111
+ "."
112
+ end
113
+ end
114
+ protected :pathmap_partial
115
+
116
+ # Preform the pathmap replacement operations on the given path.
117
+ # The patterns take the form 'pat1,rep1;pat2,rep2...'.
118
+ def pathmap_replace(patterns, &block)
119
+ result = self
120
+ patterns.split(';').each do |pair|
121
+ pattern, replacement = pair.split(',')
122
+ pattern = Regexp.new(pattern)
123
+ if replacement == '*' && block_given?
124
+ result = result.sub(pattern, &block)
125
+ elsif replacement
126
+ result = result.sub(pattern, replacement)
127
+ else
128
+ result = result.sub(pattern, '')
129
+ end
130
+ end
131
+ result
132
+ end
133
+ protected :pathmap_replace
134
+
135
+ # Map the path according to the given specification. The
136
+ # specification controls the details of the mapping. The
137
+ # following special patterns are recognized:
138
+ #
139
+ # * <b>%p</b> -- The complete path.
140
+ # * <b>%f</b> -- The base file name of the path, with its file
141
+ # extension, but without any directories.
142
+ # * <b>%n</b> -- The file name of the path without its file
143
+ # extension.
144
+ # * <b>%d</b> -- The directory list of the path.
145
+ # * <b>%x</b> -- The file extension of the path. An empty string
146
+ # if there is no extension.
147
+ # * <b>%X</b> -- Everything *but* the file extension.
148
+ # * <b>%s</b> -- The alternate file separater if defined,
149
+ # otherwise use the standard file separator.
150
+ # # <b>%%</b> -- A percent sign.
151
+ #
152
+ # The %d specifier can also have a numeric prefix (e.g. '%2d').
153
+ # If the number is positive, only return (up to) +n+ directories
154
+ # in the path, starting from the left hand side. If +n+ is
155
+ # negative, return (up to) |+n+| directories from the right hand
156
+ # side of the path.
157
+ #
158
+ # Examples:
159
+ #
160
+ # 'a/b/c/d/file.txt'.pathmap("%2d") => 'a/b'
161
+ # 'a/b/c/d/file.txt'.pathmap("%-2d") => 'c/d'
162
+ #
163
+ # Also the %d, %p, $f, $n, %x, and %X operators can take a
164
+ # pattern/replacement argument to perform simple string
165
+ # substititions on a particular part of the path. The pattern and
166
+ # replacement are speparated by a comma and are enclosed by curly
167
+ # braces. The replacement spec comes after the % character but
168
+ # before the operator letter. (e.g. "%{old,new}d"). Muliple
169
+ # replacement specs should be separated by semi-colons
170
+ # (e.g. "%{old,new;src,bin}d").
171
+ #
172
+ # Regular expressions may be used for the pattern, and back refs
173
+ # may be used in the replacement text. Curly braces, commas and
174
+ # semi-colons are excluded from both the pattern and replacement
175
+ # text (let's keep parsing reasonable).
176
+ #
177
+ # For example:
178
+ #
179
+ # "src/org/onestepback/proj/A.java".pathmap("%{^src,bin}X.class")
180
+ #
181
+ # returns:
182
+ #
183
+ # "bin/org/onestepback/proj/A.class"
184
+ #
185
+ # If the replacement text is '*', then a block may be provided to
186
+ # perform some arbitrary calculation for the replacement.
187
+ #
188
+ # For example:
189
+ #
190
+ # "/path/to/file.TXT".pathmap("%X%{.*,*}x") { |ext|
191
+ # ext.downcase
192
+ # }
193
+ #
194
+ # Returns:
195
+ #
196
+ # "/path/to/file.txt"
197
+ #
198
+ def pathmap(spec=nil, &block)
199
+ return self if spec.nil?
200
+ result = ''
201
+ spec.scan(/%\{[^}]*\}-?\d*[sdpfnxX%]|%-?\d+d|%.|[^%]+/) do |frag|
202
+ case frag
203
+ when '%f'
204
+ result << File.basename(self)
205
+ when '%n'
206
+ result << File.basename(self).ext
207
+ when '%d'
208
+ result << File.dirname(self)
209
+ when '%x'
210
+ result << $1 if self =~ /[^\/](\.[^.]+)$/
211
+ when '%X'
212
+ if self =~ /^(.+[^\/])(\.[^.]+)$/
213
+ result << $1
214
+ else
215
+ result << self
216
+ end
217
+ when '%p'
218
+ result << self
219
+ when '%s'
220
+ result << (File::ALT_SEPARATOR || File::SEPARATOR)
221
+ when '%%'
222
+ result << "%"
223
+ when /%(-?\d+)d/
224
+ result << pathmap_partial($1.to_i)
225
+ when /^%\{([^}]*)\}(\d*[dpfnxX])/
226
+ patterns, operator = $1, $2
227
+ result << pathmap('%' + operator).pathmap_replace(patterns, &block)
228
+ when /^%/
229
+ fail ArgumentError, "Unknown pathmap specifier #{frag} in '#{spec}'"
230
+ else
231
+ result << frag
232
+ end
233
+ end
234
+ result
235
+ end
236
+ end
237
+ end
238
+
84
239
  ######################################################################
85
240
  module Rake
86
241
 
@@ -603,7 +758,7 @@ module FileUtils
603
758
  else
604
759
  begin
605
760
  ln(*args)
606
- rescue Errno::EOPNOTSUPP, Errno::EXDEV
761
+ rescue StandardError, NotImplementedError
607
762
  LN_SUPPORTED[0] = false
608
763
  cp(*args)
609
764
  end
@@ -1045,6 +1200,13 @@ module Rake
1045
1200
  self
1046
1201
  end
1047
1202
 
1203
+ # Apply the pathmap spec to each of the included file names,
1204
+ # returning a new file list with the modified paths. (See
1205
+ # String#pathmap for details.)
1206
+ def pathmap(spec=nil)
1207
+ collect { |fn| fn.pathmap(spec) }
1208
+ end
1209
+
1048
1210
  # Return a new array with <tt>String#ext</tt> method applied to
1049
1211
  # each member of the array.
1050
1212
  #
@@ -1421,13 +1583,13 @@ module Rake
1421
1583
  extensions.collect { |ext|
1422
1584
  case ext
1423
1585
  when String
1424
- source = task_name.sub(/\.[^.]*$/, ext)
1586
+ task_name.sub(/\.[^.]*$/, ext)
1425
1587
  when Proc
1426
- source = ext.call(task_name)
1588
+ ext.call(task_name)
1427
1589
  else
1428
1590
  fail "Don't know how to handle rule dependent: #{ext.inspect}"
1429
1591
  end
1430
- }
1592
+ }.flatten
1431
1593
  end
1432
1594
 
1433
1595
  end
@@ -1459,14 +1621,14 @@ module Rake
1459
1621
  "Display the tasks and dependencies, then exit."],
1460
1622
  ['--quiet', '-q', GetoptLong::NO_ARGUMENT,
1461
1623
  "Do not log messages to standard output."],
1462
- ['--rakefile', '-f', GetoptLong::REQUIRED_ARGUMENT,
1624
+ ['--rakefile', '-f', GetoptLong::OPTIONAL_ARGUMENT,
1463
1625
  "Use FILE as the rakefile."],
1464
1626
  ['--require', '-r', GetoptLong::REQUIRED_ARGUMENT,
1465
1627
  "Require MODULE before executing rakefile."],
1466
1628
  ['--silent', '-s', GetoptLong::NO_ARGUMENT,
1467
1629
  "Like --quiet, but also suppresses the 'in directory' announcement."],
1468
- ['--tasks', '-T', GetoptLong::NO_ARGUMENT,
1469
- "Display the tasks and dependencies, then exit."],
1630
+ ['--tasks', '-T', GetoptLong::OPTIONAL_ARGUMENT,
1631
+ "Display the tasks (matching optional PATTERN) with descriptions, then exit."],
1470
1632
  ['--trace', '-t', GetoptLong::NO_ARGUMENT,
1471
1633
  "Turn on invoke/execute tracing, enable full backtrace."],
1472
1634
  ['--usage', '-h', GetoptLong::NO_ARGUMENT,
@@ -1501,7 +1663,7 @@ module Rake
1501
1663
  # If a match is found, it is copied into @rakefile.
1502
1664
  def have_rakefile
1503
1665
  RAKEFILES.each do |fn|
1504
- if File.exist?(fn)
1666
+ if File.exist?(fn) || fn == ''
1505
1667
  @rakefile = fn
1506
1668
  return true
1507
1669
  end
@@ -1533,15 +1695,14 @@ module Rake
1533
1695
 
1534
1696
  # Display the tasks and dependencies.
1535
1697
  def display_tasks_and_comments
1536
- width = Rake::Task.tasks.select { |t|
1537
- t.comment
1538
- }.collect { |t|
1698
+ displayable_tasks = Rake::Task.tasks.select { |t|
1699
+ t.comment && t.name =~ options.show_task_pattern
1700
+ }
1701
+ width = displayable_tasks.collect { |t|
1539
1702
  t.name.length
1540
1703
  }.max
1541
- Rake::Task.tasks.each do |t|
1542
- if t.comment
1543
- printf "rake %-#{width}s # %s\n", t.name, t.comment
1544
- end
1704
+ displayable_tasks.each do |t|
1705
+ printf "rake %-#{width}s # %s\n", t.name, t.comment
1545
1706
  end
1546
1707
  end
1547
1708
 
@@ -1584,12 +1745,21 @@ module Rake
1584
1745
  when '--rakelibdir'
1585
1746
  options.rakelib = value.split(':')
1586
1747
  when '--require'
1587
- require value
1748
+ begin
1749
+ require value
1750
+ rescue LoadError => ex
1751
+ begin
1752
+ rake_require value
1753
+ rescue LoadError => ex2
1754
+ raise ex
1755
+ end
1756
+ end
1588
1757
  when '--silent'
1589
1758
  verbose(false)
1590
1759
  options.silent = true
1591
1760
  when '--tasks'
1592
1761
  options.show_tasks = true
1762
+ options.show_task_pattern = Regexp.new(value || '.')
1593
1763
  when '--trace'
1594
1764
  options.trace = true
1595
1765
  verbose(true)
@@ -1627,6 +1797,23 @@ module Rake
1627
1797
  end
1628
1798
  end
1629
1799
 
1800
+ # Similar to the regular Ruby +require+ command, but will check
1801
+ # for .rake files in addition to .rb files.
1802
+ def rake_require(file_name, paths=$LOAD_PATH, loaded=$")
1803
+ return false if loaded.include?(file_name)
1804
+ paths.each do |path|
1805
+ fn = file_name + ".rake"
1806
+ full_path = File.join(path, fn)
1807
+ if File.exist?(full_path)
1808
+ load full_path
1809
+ loaded << fn
1810
+ return true
1811
+ end
1812
+ end
1813
+ fail LoadError, "Can't find #{file_name}"
1814
+ end
1815
+
1816
+ # Find the rakefile and then load it and any pending imports.
1630
1817
  def load_rakefile
1631
1818
  here = Dir.pwd
1632
1819
  while ! have_rakefile
@@ -1638,7 +1825,7 @@ module Rake
1638
1825
  end
1639
1826
  puts "(in #{Dir.pwd})" unless options.silent
1640
1827
  $rakefile = @rakefile
1641
- load File.expand_path(@rakefile)
1828
+ load File.expand_path(@rakefile) if @rakefile != ''
1642
1829
  options.rakelib.each do |rlib|
1643
1830
  Dir["#{rlib}/*.rake"].each do |name| add_import name end
1644
1831
  end
@@ -0,0 +1,3 @@
1
+ task :default do
2
+ puts "TEST1"
3
+ end
@@ -130,6 +130,16 @@ class FunctionalTest < Test::Unit::TestCase
130
130
  end
131
131
  end
132
132
 
133
+ def test_dash_f_with_no_arg_foils_rakefile_lookup
134
+ rake "-I test/data/rakelib -rtest1 -f"
135
+ assert_match(/^TEST1$/, @out)
136
+ end
137
+
138
+ def test_dot_rake_files_can_be_laoded_with_dash_r
139
+ rake "-I test/data/rakelib -rtest2 -f"
140
+ assert_match(/^TEST2$/, @out)
141
+ end
142
+
133
143
  def test_can_invoke_task_in_toplevel_namespace
134
144
  Dir.chdir("test/data/namespace") do
135
145
  rake "copy"
@@ -252,7 +252,7 @@ class TestFileList < Test::Unit::TestCase
252
252
  assert_match(/files\.egrep/, line)
253
253
  found = true
254
254
  end
255
- assert found, "should have foudn a matching line"
255
+ assert found, "should have found a matching line"
256
256
  end
257
257
 
258
258
 
@@ -38,6 +38,13 @@ class TestFileUtils < Test::Unit::TestCase
38
38
  assert ! File.exist?("testdata/b")
39
39
  end
40
40
 
41
+ def test_ln
42
+ create_dir("testdata")
43
+ open("testdata/a", "w") { |f| f.puts "TEST_LN" }
44
+ RakeFileUtils.safe_ln("testdata/a", "testdata/b", :verbose => false)
45
+ assert_equal "TEST_LN\n", open("testdata/b") { |f| f.read }
46
+ end
47
+
41
48
  def test_verbose
42
49
  verbose true
43
50
  assert_equal true, verbose
@@ -0,0 +1,182 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test/unit'
4
+ require 'rake'
5
+
6
+ # ====================================================================
7
+ class TestPathMap < Test::Unit::TestCase
8
+
9
+ def test_returns_self_with_no_args
10
+ assert_equal "abc.rb", "abc.rb".pathmap
11
+ end
12
+
13
+ def test_s_returns_file_separator
14
+ sep = File::ALT_SEPARATOR || File::SEPARATOR
15
+ assert_equal sep, "abc.rb".pathmap("%s")
16
+ assert_equal "a#{sep}b", "a/b".pathmap("%d%s%f")
17
+ end
18
+
19
+ def test_b_returns_basename
20
+ assert_equal "abc.rb", "abc.rb".pathmap("%f")
21
+ assert_equal "abc.rb", "this/is/a/dir/abc.rb".pathmap("%f")
22
+ assert_equal "abc.rb", "/this/is/a/dir/abc.rb".pathmap("%f")
23
+ end
24
+
25
+ def test_B_returns_basename_without_extension
26
+ assert_equal "abc", "abc.rb".pathmap("%n")
27
+ assert_equal "abc", "abc".pathmap("%n")
28
+ assert_equal "abc", "this/is/a/dir/abc.rb".pathmap("%n")
29
+ assert_equal "abc", "/this/is/a/dir/abc.rb".pathmap("%n")
30
+ assert_equal "abc", "/this/is/a/dir/abc".pathmap("%n")
31
+ end
32
+
33
+ def test_d_returns_dirname
34
+ assert_equal ".", "abc.rb".pathmap("%d")
35
+ assert_equal "/", "/abc".pathmap("%d")
36
+ assert_equal "this/is/a/dir", "this/is/a/dir/abc.rb".pathmap("%d")
37
+ assert_equal "/this/is/a/dir", "/this/is/a/dir/abc.rb".pathmap("%d")
38
+ end
39
+
40
+ def test_nnnd_returns_partial_dirname
41
+ assert_equal "this/is", "this/is/a/dir/abc.rb".pathmap("%2d")
42
+ assert_equal "this", "this/is/a/dir/abc.rb".pathmap("%1d")
43
+ assert_equal ".", "this/is/a/dir/abc.rb".pathmap("%0d")
44
+ assert_equal "dir", "this/is/a/dir/abc.rb".pathmap("%-1d")
45
+ assert_equal "a/dir", "this/is/a/dir/abc.rb".pathmap("%-2d")
46
+ assert_equal "this/is/a/dir", "this/is/a/dir/abc.rb".pathmap("%100d")
47
+ assert_equal "this/is/a/dir", "this/is/a/dir/abc.rb".pathmap("%-100d")
48
+ end
49
+
50
+ def test_pattern_returns_substitutions
51
+ assert_equal "bin/org/osb",
52
+ "src/org/osb/Xyz.java".pathmap("%{src,bin}d")
53
+ end
54
+
55
+ def test_pattern_can_use_backreferences
56
+ assert_equal "dir/hi/is", "dir/this/is".pathmap("%{t(hi)s,\\1}p")
57
+ end
58
+
59
+ def test_pattern_with_star_replacement_string_uses_block
60
+ assert_equal "src/ORG/osb",
61
+ "src/org/osb/Xyz.java".pathmap("%{/org,*}d") { |d| d.upcase }
62
+ assert_equal "Xyz.java",
63
+ "src/org/osb/Xyz.java".pathmap("%{.*,*}f") { |f| f.capitalize }
64
+ end
65
+
66
+ def test_pattern_with_no_replacement_nor_block_substitutes_empty_string
67
+ assert_equal "bc.rb", "abc.rb".pathmap("%{a}f")
68
+ end
69
+
70
+ def test_pattern_works_with_certain_valid_operators
71
+ assert_equal "dir/xbc.rb", "dir/abc.rb".pathmap("%{a,x}p")
72
+ assert_equal "d1r", "dir/abc.rb".pathmap("%{i,1}d")
73
+ assert_equal "xbc.rb", "dir/abc.rb".pathmap("%{a,x}f")
74
+ assert_equal ".Rb", "dir/abc.rb".pathmap("%{r,R}x")
75
+ assert_equal "xbc", "dir/abc.rb".pathmap("%{a,x}n")
76
+ end
77
+
78
+ def test_multiple_patterns
79
+ assert_equal "this/is/b/directory/abc.rb",
80
+ "this/is/a/dir/abc.rb".pathmap("%{a,b;dir,\\0ectory}p")
81
+ end
82
+
83
+ def test_partial_directory_selection_works_with_patterns
84
+ assert_equal "this/is/a/long",
85
+ "this/is/a/really/long/path/ok.rb".pathmap("%{/really/,/}5d")
86
+ end
87
+
88
+ def test_pattern_with_invalid_operator
89
+ ex = assert_raise(ArgumentError) do
90
+ "abc.xyz".pathmap("%{src,bin}z")
91
+ end
92
+ assert_match(/unknown.*pathmap.*spec.*z/i, ex.message)
93
+ end
94
+
95
+ def test_x_returns_extension
96
+ assert_equal "", "abc".pathmap("%x")
97
+ assert_equal ".rb", "abc.rb".pathmap("%x")
98
+ assert_equal ".rb", "abc.xyz.rb".pathmap("%x")
99
+ assert_equal "", ".depends".pathmap("%x")
100
+ assert_equal "", "dir/.depends".pathmap("%x")
101
+ end
102
+
103
+ def test_X_returns_everything_but_extension
104
+ assert_equal "abc", "abc".pathmap("%X")
105
+ assert_equal "abc", "abc.rb".pathmap("%X")
106
+ assert_equal "abc.xyz", "abc.xyz.rb".pathmap("%X")
107
+ assert_equal ".depends", ".depends".pathmap("%X")
108
+ assert_equal "a/dir/.depends", "a/dir/.depends".pathmap("%X")
109
+ assert_equal "/.depends", "/.depends".pathmap("%X")
110
+ end
111
+
112
+ def test_p_returns_entire_pathname
113
+ assert_equal "abc.rb", "abc.rb".pathmap("%p")
114
+ assert_equal "this/is/a/dir/abc.rb", "this/is/a/dir/abc.rb".pathmap("%p")
115
+ assert_equal "/this/is/a/dir/abc.rb", "/this/is/a/dir/abc.rb".pathmap("%p")
116
+ end
117
+
118
+ def test_percent_percent_returns_percent
119
+ assert_equal "a%b", "".pathmap("a%%b")
120
+ end
121
+
122
+ def test_undefined_percent_causes_error
123
+ ex = assert_raise(ArgumentError) {
124
+ "dir/abc.rb".pathmap("%z")
125
+ }
126
+ end
127
+
128
+ def test_works_with_windows_separators
129
+ if File::ALT_SEPARATOR
130
+ assert_equal "abc", 'dir\abc.rb'.pathmap("%n")
131
+ assert_equal 'this\is\a\dir',
132
+ 'this\is\a\dir\abc.rb'.pathmap("%d")
133
+ end
134
+ end
135
+
136
+ def test_complex_patterns
137
+ sep = "".pathmap("%s")
138
+ assert_equal "dir/abc.rb", "dir/abc.rb".pathmap("%d/%n%x")
139
+ assert_equal "./abc.rb", "abc.rb".pathmap("%d/%n%x")
140
+ assert_equal "Your file extension is '.rb'",
141
+ "dir/abc.rb".pathmap("Your file extension is '%x'")
142
+ assert_equal "bin/org/onstepback/proj/A.class",
143
+ "src/org/onstepback/proj/A.java".pathmap("%{src,bin}d/%n.class")
144
+ assert_equal "src_work/bin/org/onstepback/proj/A.class",
145
+ "src_work/src/org/onstepback/proj/A.java".pathmap('%{\bsrc\b,bin}X.class')
146
+ assert_equal ".depends.bak", ".depends".pathmap("%X.bak")
147
+ assert_equal "d#{sep}a/b/c#{sep}file.txt", "a/b/c/d/file.txt".pathmap("%-1d%s%3d%s%f")
148
+ end
149
+ end
150
+
151
+ class TestPathMapExplode < Test::Unit::TestCase
152
+ def setup
153
+ String.class_eval { public :pathmap_explode }
154
+ end
155
+
156
+ def teardown
157
+ String.class_eval { protected :pathmap_explode }
158
+ end
159
+
160
+ def test_explode
161
+ assert_equal ['a'], 'a'.pathmap_explode
162
+ assert_equal ['a', 'b'], 'a/b'.pathmap_explode
163
+ assert_equal ['a', 'b', 'c'], 'a/b/c'.pathmap_explode
164
+ assert_equal ['/', 'a'], '/a'.pathmap_explode
165
+ assert_equal ['/', 'a', 'b'], '/a/b'.pathmap_explode
166
+ assert_equal ['/', 'a', 'b', 'c'], '/a/b/c'.pathmap_explode
167
+ if File::ALT_SEPARATOR
168
+ assert_equal ['c:.', 'a'], 'c:a'.pathmap_explode
169
+ assert_equal ['c:.', 'a', 'b'], 'c:a/b'.pathmap_explode
170
+ assert_equal ['c:.', 'a', 'b', 'c'], 'c:a/b/c'.pathmap_explode
171
+ assert_equal ['c:/', 'a'], 'c:/a'.pathmap_explode
172
+ assert_equal ['c:/', 'a', 'b'], 'c:/a/b'.pathmap_explode
173
+ assert_equal ['c:/', 'a', 'b', 'c'], 'c:/a/b/c'.pathmap_explode
174
+ end
175
+ end
176
+ end
177
+
178
+ class TestFileListPathMap < Test::Unit::TestCase
179
+ def test_file_list_supports_pathmap
180
+ assert_equal ['a', 'b'], FileList['dir/a.rb', 'dir/b.rb'].pathmap("%n")
181
+ end
182
+ end
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test/unit'
4
+ require 'rake'
5
+
6
+ # ====================================================================
7
+ class TestRequire < Test::Unit::TestCase
8
+
9
+ def test_can_load_rake_library
10
+ app = Rake::Application.new
11
+ assert app.rake_require("test2", ['test/data/rakelib'], [])
12
+ end
13
+
14
+ def test_wont_reload_rake_library
15
+ app = Rake::Application.new
16
+ assert ! app.rake_require("test2", ['test/data/rakelib'], ['test2'])
17
+ end
18
+
19
+ def test_throws_error_if_library_not_found
20
+ app = Rake::Application.new
21
+ ex = assert_raise(LoadError) {
22
+ assert app.rake_require("testx", ['test/data/rakelib'], [])
23
+ }
24
+ assert_match(/x/, ex.message)
25
+ end
26
+ end
27
+
@@ -178,6 +178,28 @@ class TestRules < Test::Unit::TestCase
178
178
  rm_r("testdata/src", :verbose=>false) rescue nil
179
179
  end
180
180
 
181
+ def test_proc_returning_lists_are_flattened_into_prereqs
182
+ ran = false
183
+ File.makedirs("testdata/flatten")
184
+ create_file("testdata/flatten/a.txt")
185
+ task 'testdata/flatten/b.data' do |t|
186
+ ran = true
187
+ touch t.name, :verbose => false
188
+ end
189
+ rule '.html' =>
190
+ proc { |fn|
191
+ [
192
+ fn.ext("txt"),
193
+ "testdata/flatten/b.data"
194
+ ]
195
+ } do |task|
196
+ end
197
+ Task['testdata/flatten/a.html'].invoke
198
+ assert ran, "Should have triggered flattened dependency"
199
+ ensure
200
+ rm_r("testdata/flatten", :verbose=>false) rescue nil
201
+ end
202
+
181
203
  def test_recursive_rules
182
204
  actions = []
183
205
  create_file("testdata/abc.xml")
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
2
+ rubygems_version: 0.8.11.8
3
3
  specification_version: 1
4
4
  name: rake
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.7.0
7
- date: 2006-01-19 00:00:00 -05:00
6
+ version: 0.7.1
7
+ date: 2006-04-03 00:00:00 -04:00
8
8
  summary: Ruby based make-like utility.
9
9
  require_paths:
10
10
  - lib
@@ -25,6 +25,7 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
25
25
  platform: ruby
26
26
  signing_key:
27
27
  cert_chain:
28
+ post_install_message:
28
29
  authors:
29
30
  - Jim Weirich
30
31
  files:
@@ -62,7 +63,9 @@ files:
62
63
  - test/shellcommand.rb
63
64
  - test/test_tasks.rb
64
65
  - test/functional.rb
66
+ - test/test_pathmap.rb
65
67
  - test/test_rake.rb
68
+ - test/test_require.rb
66
69
  - test/test_makefile_loader.rb
67
70
  - test/test_test_task.rb
68
71
  - test/session_functional.rb
@@ -76,6 +79,7 @@ files:
76
79
  - test/test_namespace.rb
77
80
  - test/contrib/testsys.rb
78
81
  - test/data/rbext/rakefile.rb
82
+ - test/data/rakelib/test1.rb
79
83
  - test/data/sample.mf
80
84
  - test/data/imports/deps.mf
81
85
  - test/data/default/Rakefile
@@ -102,6 +106,7 @@ files:
102
106
  - doc/release_notes/rake-0.5.3.rdoc
103
107
  - doc/release_notes/rake-0.4.15.rdoc
104
108
  - doc/release_notes/rake-0.6.0.rdoc
109
+ - doc/release_notes/rake-0.7.1.rdoc
105
110
  - doc/release_notes/rake-0.5.0.rdoc
106
111
  - doc/release_notes/rake-0.5.4.rdoc
107
112
  - doc/release_notes/rake-0.7.0.rdoc
@@ -126,6 +131,7 @@ extra_rdoc_files:
126
131
  - doc/release_notes/rake-0.5.3.rdoc
127
132
  - doc/release_notes/rake-0.4.15.rdoc
128
133
  - doc/release_notes/rake-0.6.0.rdoc
134
+ - doc/release_notes/rake-0.7.1.rdoc
129
135
  - doc/release_notes/rake-0.5.0.rdoc
130
136
  - doc/release_notes/rake-0.5.4.rdoc
131
137
  - doc/release_notes/rake-0.7.0.rdoc