From 70c3032ae5387cc57a2256bc22233d5f06efa2c3 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Fri, 15 May 2009 17:39:29 -0400 Subject: [PATCH 0001/1389] Updated CHANGES file. --- CHANGES | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 3b1a02b81..8dc3f1ace 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,12 @@ - = Rake Changelog +== Pre-Version 0.9.x + +* Allow single line comments immediately prior to a task to be used in + place of +desc+. + +* Split rake.rb into individual files. + == Version 0.8.7 * Fixed EXEEXT for JRuby on windows. From 8f198546213eb01061ba368d0ada70e64ff51e52 Mon Sep 17 00:00:00 2001 From: Dave Thomas Date: Thu, 26 Mar 2009 16:17:13 +0000 Subject: [PATCH 0002/1389] Allow single line comments immediately prior to a task to be used in place of +desc+. A single line comment on the line prior to any task, file, etc definition will be used to populate that task's description (but only if no prior +desc+ was seen). # here is the description tasl :dave do ... --- doc/rakefile.rdoc | 26 +++++++++++++++++------ lib/rake.rb | 42 +++++++++++++++++++++++++++++++++++-- test/data/comments/Rakefile | 18 ++++++++++++++++ test/session_functional.rb | 29 +++++++++++++++++++++++++ 4 files changed, 107 insertions(+), 8 deletions(-) create mode 100644 test/data/comments/Rakefile diff --git a/doc/rakefile.rdoc b/doc/rakefile.rdoc index f8ae72c32..ddaccd9ac 100644 --- a/doc/rakefile.rdoc +++ b/doc/rakefile.rdoc @@ -365,18 +365,32 @@ loading. Standard Ruby comments (beginning with "#") can be used anywhere it is legal in Ruby source code, including comments for tasks and rules. -However, if you wish a task to be described using the "-T" switch, -then you need to use the +desc+ command to describe the task. +A single-line comment immediately before a task (with no blank line +between it and the task) will be used as that task's description, and +the task and description will appear in the list displayed +using the "-T" switch. === Example: - desc "Create a distribution package" + # Create a distribution package task :package => [ ... ] do ... end +You can also use the +desc+ command before a task to set the +description for the task. In this case, intervening blank lines +are allowed + +=== Example: + + desc 'Create a distribution package' + + task :package => [ ... ] do ... end + +The +desc+ comment takes priority over the comment for of description. + The "-T" switch (or "--tasks" if you like to spell things out) will -display a list of tasks that have a defined comment. If you use -+desc+ to describe your major tasks, you have a semi-automatic way of -generating a summary of your Rake file. +display a list of tasks that have a description. If you use +comments or +desc+ to describe your major tasks, you have a +semi-automatic way of generating a summary of your Rake file. traken$ rake -T (in /home/.../rake) diff --git a/lib/rake.rb b/lib/rake.rb index 12928308f..ba74fbaa0 100755 --- a/lib/rake.rb +++ b/lib/rake.rb @@ -1707,8 +1707,7 @@ def define_task(task_class, *args, &block) deps = deps.collect {|d| d.to_s } task = intern(task_class, task_name) task.set_arg_names(arg_names) unless arg_names.empty? - task.add_description(@last_description) - @last_description = nil + task.add_description(get_description) task.enhance(deps, &block) task end @@ -1944,6 +1943,45 @@ def make_sources(task_name, extensions) }.flatten end + + private + + # Return the current description. If there isn't one, try to find it + # by reading in the source file and looking for a comment immediately + # prior to the task definition + def get_description + desc = @last_description || find_preceding_comment_for_task + @last_description = nil + desc + end + + def find_preceding_comment_for_task + stack = caller + begin + where = stack.shift + end until stack.empty? || where =~ /in `task'/ + return nil if stack.empty? + file_name, line = parse_stack_line(stack.shift) + return nil unless file_name + comment_from_file(file_name, line) + end + + def parse_stack_line(where) + if where =~ /^(.*):(\d)/ + [ $1, Integer($2) ] + else + nil + end + end + + def comment_from_file(file_name, line) + @file_cache ||= {} + content = (@file_cache[file_name] ||= File.readlines(file_name)) + line -= 2 +# line -= 1 while line >= 0 && content[line] =~ /^\s*$/ + return nil unless content[line] =~ /^\s*#\s*(.*)/ + $1 + end end # TaskManager ###################################################################### diff --git a/test/data/comments/Rakefile b/test/data/comments/Rakefile new file mode 100644 index 000000000..a281d7311 --- /dev/null +++ b/test/data/comments/Rakefile @@ -0,0 +1,18 @@ +# comment for t1 +task :t1 do +end + +# no comment or task because there's a blank line + +task :t2 do +end + +desc "override comment for t3" +# this is not the description +multitask :t3 do +end + +# this is not the description +desc "override comment for t4" +file :t4 do +end \ No newline at end of file diff --git a/test/session_functional.rb b/test/session_functional.rb index 730e2d5d2..54f515e3c 100644 --- a/test/session_functional.rb +++ b/test/session_functional.rb @@ -299,8 +299,37 @@ def test_rake_returns_no_status_error_on_normal_exit end end + def test_comment_before_task_acts_like_desc + Dir.chdir("test/data/comments") { rake("-T")} + assert_match("comment for t1", @out) + end + + def test_comment_separated_from_task_by_blank_line_is_not_picked_up + Dir.chdir("test/data/comments") { rake("-T")} + assert_not_match("t2", @out) + end + + def test_comment_after_desc_is_ignored + Dir.chdir("test/data/comments") { rake("-T")} + assert_match("override comment for t3", @out) + end + + def test_comment_before_desc_is_ignored + Dir.chdir("test/data/comments") { rake("-T")} + assert_match("override comment for t4", @out) + end + + def test_correct_number_of_tasks_reported + Dir.chdir("test/data/comments") { rake("-T")} + assert_equal(3, @out.grep(/t\d/).size) + end + private + def assert_not_match(pattern, string, comment="'#{pattern}' was found (incorrectly) in '#{string}.inspect") + assert_nil Regexp.new(pattern).match(string), comment + end + def remove_chaining_files %w(play.scpt play.app base).each do |fn| FileUtils.rm_f File.join("test/data/chains", fn) From 0d539c3525601e2509cd274043160da6338e9df7 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Sat, 28 Mar 2009 11:21:10 +0000 Subject: [PATCH 0003/1389] Fixed # task comment bug. --- lib/rake.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/rake.rb b/lib/rake.rb index ba74fbaa0..7e0a20953 100755 --- a/lib/rake.rb +++ b/lib/rake.rb @@ -1967,7 +1967,7 @@ def find_preceding_comment_for_task end def parse_stack_line(where) - if where =~ /^(.*):(\d)/ + if where =~ /^(.*):(\d+)/ [ $1, Integer($2) ] else nil @@ -1978,7 +1978,6 @@ def comment_from_file(file_name, line) @file_cache ||= {} content = (@file_cache[file_name] ||= File.readlines(file_name)) line -= 2 -# line -= 1 while line >= 0 && content[line] =~ /^\s*$/ return nil unless content[line] =~ /^\s*#\s*(.*)/ $1 end From 3f5ee0a06bb8253aa6a9c445211d4ce0302b3749 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Sat, 28 Mar 2009 12:39:10 +0000 Subject: [PATCH 0004/1389] added daves comment patch to CHANGES --- CHANGES | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES b/CHANGES index 8dc3f1ace..54af6b679 100644 --- a/CHANGES +++ b/CHANGES @@ -16,6 +16,10 @@ * Minor fixes to the RDoc generation (removed dependency on darkfish and removed inline source option). +== PreVersion 0.8.6 + +* Now allow # comments to comment a task definition. + == Version 0.8.5 * Better support for the system command on Windows. From 0d4416efd91808320323936f21f58fc64c695187 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Sat, 28 Mar 2009 12:42:01 +0000 Subject: [PATCH 0005/1389] Moved FileList to a separate file. --- lib/rake.rb | 689 +----------------------------------- lib/rake/cloneable.rb | 25 ++ lib/rake/file_list.rb | 410 +++++++++++++++++++++ lib/rake/file_utils.rb | 103 ++++++ lib/rake/rake_file_utils.rb | 142 ++++++++ test/test_fileutils.rb | 2 +- 6 files changed, 687 insertions(+), 684 deletions(-) create mode 100644 lib/rake/cloneable.rb create mode 100644 lib/rake/file_list.rb create mode 100644 lib/rake/file_utils.rb create mode 100644 lib/rake/rake_file_utils.rb diff --git a/lib/rake.rb b/lib/rake.rb index 7e0a20953..961e64c5b 100755 --- a/lib/rake.rb +++ b/lib/rake.rb @@ -39,6 +39,11 @@ require 'ostruct' require 'rake/win32' +require 'rake/file_list' + + +# Alias FileList to be available at the top level. +FileList = Rake::FileList $trace = false @@ -283,29 +288,6 @@ def original_dir end #################################################################### - # Mixin for creating easily cloned objects. - # - module Cloneable - # Clone an object by making a new object and setting all the instance - # variables to the same values. - def dup - sibling = self.class.new - instance_variables.each do |ivar| - value = self.instance_variable_get(ivar) - new_value = value.clone rescue value - sibling.instance_variable_set(ivar, new_value) - end - sibling.taint if tainted? - sibling - end - - def clone - sibling = dup - sibling.freeze if frozen? - sibling - end - end - #################################################################### # Exit status class for times the system just gives us a nil. class PseudoStatus @@ -952,666 +934,7 @@ def import(*fns) end end -############################################################################# -# This a FileUtils extension that defines several additional commands to be -# added to the FileUtils utility functions. -# -module FileUtils - RUBY_EXT = ((Config::CONFIG['ruby_install_name'] =~ /\.(com|cmd|exe|bat|rb|sh)$/) ? - "" : - Config::CONFIG['EXEEXT']) - - RUBY = File.join( - Config::CONFIG['bindir'], - Config::CONFIG['ruby_install_name'] + RUBY_EXT). - sub(/.*\s.*/m, '"\&"') - - OPT_TABLE['sh'] = %w(noop verbose) - OPT_TABLE['ruby'] = %w(noop verbose) - - # Run the system command +cmd+. If multiple arguments are given the command - # is not run with the shell (same semantics as Kernel::exec and - # Kernel::system). - # - # Example: - # sh %{ls -ltr} - # - # sh 'ls', 'file with spaces' - # - # # check exit status after command runs - # sh %{grep pattern file} do |ok, res| - # if ! ok - # puts "pattern not found (status = #{res.exitstatus})" - # end - # end - # - def sh(*cmd, &block) - options = (Hash === cmd.last) ? cmd.pop : {} - unless block_given? - show_command = cmd.join(" ") - show_command = show_command[0,42] + "..." unless $trace - # TODO code application logic heref show_command.length > 45 - block = lambda { |ok, status| - ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]" - } - end - if RakeFileUtils.verbose_flag == :default - options[:verbose] = true - else - options[:verbose] ||= RakeFileUtils.verbose_flag - end - options[:noop] ||= RakeFileUtils.nowrite_flag - rake_check_options options, :noop, :verbose - rake_output_message cmd.join(" ") if options[:verbose] - unless options[:noop] - res = rake_system(*cmd) - status = $? - status = PseudoStatus.new(1) if !res && status.nil? - block.call(res, status) - end - end - - def rake_system(*cmd) - Rake::AltSystem.system(*cmd) - end - private :rake_system - - # Run a Ruby interpreter with the given arguments. - # - # Example: - # ruby %{-pe '$_.upcase!' 1 then - sh(*([RUBY] + args + [options]), &block) - else - sh("#{RUBY} #{args.first}", options, &block) - end - end - - LN_SUPPORTED = [true] - - # Attempt to do a normal file link, but fall back to a copy if the link - # fails. - def safe_ln(*args) - unless LN_SUPPORTED[0] - cp(*args) - else - begin - ln(*args) - rescue StandardError, NotImplementedError => ex - LN_SUPPORTED[0] = false - cp(*args) - end - end - end - - # Split a file path into individual directory names. - # - # Example: - # split_all("a/b/c") => ['a', 'b', 'c'] - # - def split_all(path) - head, tail = File.split(path) - return [tail] if head == '.' || tail == '/' - return [head, tail] if head == '/' - return split_all(head) + [tail] - end -end - -############################################################################# -# RakeFileUtils provides a custom version of the FileUtils methods that -# respond to the verbose and nowrite commands. -# -module RakeFileUtils - include FileUtils - - class << self - attr_accessor :verbose_flag, :nowrite_flag - end - RakeFileUtils.verbose_flag = :default - RakeFileUtils.nowrite_flag = false - - $fileutils_verbose = true - $fileutils_nowrite = false - - FileUtils::OPT_TABLE.each do |name, opts| - default_options = [] - if opts.include?(:verbose) || opts.include?("verbose") - default_options << ':verbose => RakeFileUtils.verbose_flag' - end - if opts.include?(:noop) || opts.include?("noop") - default_options << ':noop => RakeFileUtils.nowrite_flag' - end - - next if default_options.empty? - module_eval(<<-EOS, __FILE__, __LINE__ + 1) - def #{name}( *args, &block ) - super( - *rake_merge_option(args, - #{default_options.join(', ')} - ), &block) - end - EOS - end - - # Get/set the verbose flag controlling output from the FileUtils utilities. - # If verbose is true, then the utility method is echoed to standard output. - # - # Examples: - # verbose # return the current value of the verbose flag - # verbose(v) # set the verbose flag to _v_. - # verbose(v) { code } # Execute code with the verbose flag set temporarily to _v_. - # # Return to the original value when code is done. - def verbose(value=nil) - oldvalue = RakeFileUtils.verbose_flag - RakeFileUtils.verbose_flag = value unless value.nil? - if block_given? - begin - yield - ensure - RakeFileUtils.verbose_flag = oldvalue - end - end - RakeFileUtils.verbose_flag - end - - # Get/set the nowrite flag controlling output from the FileUtils utilities. - # If verbose is true, then the utility method is echoed to standard output. - # - # Examples: - # nowrite # return the current value of the nowrite flag - # nowrite(v) # set the nowrite flag to _v_. - # nowrite(v) { code } # Execute code with the nowrite flag set temporarily to _v_. - # # Return to the original value when code is done. - def nowrite(value=nil) - oldvalue = RakeFileUtils.nowrite_flag - RakeFileUtils.nowrite_flag = value unless value.nil? - if block_given? - begin - yield - ensure - RakeFileUtils.nowrite_flag = oldvalue - end - end - oldvalue - end - - # Use this function to prevent protentially destructive ruby code from - # running when the :nowrite flag is set. - # - # Example: - # - # when_writing("Building Project") do - # project.build - # end - # - # The following code will build the project under normal conditions. If the - # nowrite(true) flag is set, then the example will print: - # DRYRUN: Building Project - # instead of actually building the project. - # - def when_writing(msg=nil) - if RakeFileUtils.nowrite_flag - puts "DRYRUN: #{msg}" if msg - else - yield - end - end - - # Merge the given options with the default values. - def rake_merge_option(args, defaults) - if Hash === args.last - defaults.update(args.last) - args.pop - end - args.push defaults - args - end - private :rake_merge_option - - # Send the message to the default rake output (which is $stderr). - def rake_output_message(message) - $stderr.puts(message) - end - private :rake_output_message - - # Check that the options do not contain options not listed in +optdecl+. An - # ArgumentError exception is thrown if non-declared options are found. - def rake_check_options(options, *optdecl) - h = options.dup - optdecl.each do |name| - h.delete name - end - raise ArgumentError, "no such option: #{h.keys.join(' ')}" unless h.empty? - end - private :rake_check_options - - extend self -end - -############################################################################# -# Include the FileUtils file manipulation functions in the top level module, -# but mark them private so that they don't unintentionally define methods on -# other objects. - -include RakeFileUtils -private(*FileUtils.instance_methods(false)) -private(*RakeFileUtils.instance_methods(false)) - -###################################################################### -module Rake - - ########################################################################### - # A FileList is essentially an array with a few helper methods defined to - # make file manipulation a bit easier. - # - # FileLists are lazy. When given a list of glob patterns for possible files - # to be included in the file list, instead of searching the file structures - # to find the files, a FileList holds the pattern for latter use. - # - # This allows us to define a number of FileList to match any number of - # files, but only search out the actual files when then FileList itself is - # actually used. The key is that the first time an element of the - # FileList/Array is requested, the pending patterns are resolved into a real - # list of file names. - # - class FileList - - include Cloneable - - # == Method Delegation - # - # The lazy evaluation magic of FileLists happens by implementing all the - # array specific methods to call +resolve+ before delegating the heavy - # lifting to an embedded array object (@items). - # - # In addition, there are two kinds of delegation calls. The regular kind - # delegates to the @items array and returns the result directly. Well, - # almost directly. It checks if the returned value is the @items object - # itself, and if so will return the FileList object instead. - # - # The second kind of delegation call is used in methods that normally - # return a new Array object. We want to capture the return value of these - # methods and wrap them in a new FileList object. We enumerate these - # methods in the +SPECIAL_RETURN+ list below. - - # List of array methods (that are not in +Object+) that need to be - # delegated. - ARRAY_METHODS = (Array.instance_methods - Object.instance_methods).map { |n| n.to_s } - - # List of additional methods that must be delegated. - MUST_DEFINE = %w[to_a inspect] - - # List of methods that should not be delegated here (we define special - # versions of them explicitly below). - MUST_NOT_DEFINE = %w[to_a to_ary partition *] - - # List of delegated methods that return new array values which need - # wrapping. - SPECIAL_RETURN = %w[ - map collect sort sort_by select find_all reject grep - compact flatten uniq values_at - + - & | - ] - - DELEGATING_METHODS = (ARRAY_METHODS + MUST_DEFINE - MUST_NOT_DEFINE).collect{ |s| s.to_s }.sort.uniq - - # Now do the delegation. - DELEGATING_METHODS.each_with_index do |sym, i| - if SPECIAL_RETURN.include?(sym) - ln = __LINE__+1 - class_eval %{ - def #{sym}(*args, &block) - resolve - result = @items.send(:#{sym}, *args, &block) - FileList.new.import(result) - end - }, __FILE__, ln - else - ln = __LINE__+1 - class_eval %{ - def #{sym}(*args, &block) - resolve - result = @items.send(:#{sym}, *args, &block) - result.object_id == @items.object_id ? self : result - end - }, __FILE__, ln - end - end - - # Create a file list from the globbable patterns given. If you wish to - # perform multiple includes or excludes at object build time, use the - # "yield self" pattern. - # - # Example: - # file_list = FileList.new('lib/**/*.rb', 'test/test*.rb') - # - # pkg_files = FileList.new('lib/**/*') do |fl| - # fl.exclude(/\bCVS\b/) - # end - # - def initialize(*patterns) - @pending_add = [] - @pending = false - @exclude_patterns = DEFAULT_IGNORE_PATTERNS.dup - @exclude_procs = DEFAULT_IGNORE_PROCS.dup - @exclude_re = nil - @items = [] - patterns.each { |pattern| include(pattern) } - yield self if block_given? - end - - # Add file names defined by glob patterns to the file list. If an array - # is given, add each element of the array. - # - # Example: - # file_list.include("*.java", "*.cfg") - # file_list.include %w( math.c lib.h *.o ) - # - def include(*filenames) - # TODO: check for pending - filenames.each do |fn| - if fn.respond_to? :to_ary - include(*fn.to_ary) - else - @pending_add << fn - end - end - @pending = true - self - end - alias :add :include - - # Register a list of file name patterns that should be excluded from the - # list. Patterns may be regular expressions, glob patterns or regular - # strings. In addition, a block given to exclude will remove entries that - # return true when given to the block. - # - # Note that glob patterns are expanded against the file system. If a file - # is explicitly added to a file list, but does not exist in the file - # system, then an glob pattern in the exclude list will not exclude the - # file. - # - # Examples: - # FileList['a.c', 'b.c'].exclude("a.c") => ['b.c'] - # FileList['a.c', 'b.c'].exclude(/^a/) => ['b.c'] - # - # If "a.c" is a file, then ... - # FileList['a.c', 'b.c'].exclude("a.*") => ['b.c'] - # - # If "a.c" is not a file, then ... - # FileList['a.c', 'b.c'].exclude("a.*") => ['a.c', 'b.c'] - # - def exclude(*patterns, &block) - patterns.each do |pat| - @exclude_patterns << pat - end - if block_given? - @exclude_procs << block - end - resolve_exclude if ! @pending - self - end - - - # Clear all the exclude patterns so that we exclude nothing. - def clear_exclude - @exclude_patterns = [] - @exclude_procs = [] - calculate_exclude_regexp if ! @pending - self - end - - # Define equality. - def ==(array) - to_ary == array - end - - # Return the internal array object. - def to_a - resolve - @items - end - - # Return the internal array object. - def to_ary - to_a - end - - # Lie about our class. - def is_a?(klass) - klass == Array || super(klass) - end - alias kind_of? is_a? - - # Redefine * to return either a string or a new file list. - def *(other) - result = @items * other - case result - when Array - FileList.new.import(result) - else - result - end - end - - # Resolve all the pending adds now. - def resolve - if @pending - @pending = false - @pending_add.each do |fn| resolve_add(fn) end - @pending_add = [] - resolve_exclude - end - self - end - - def calculate_exclude_regexp - ignores = [] - @exclude_patterns.each do |pat| - case pat - when Regexp - ignores << pat - when /[*?]/ - Dir[pat].each do |p| ignores << p end - else - ignores << Regexp.quote(pat) - end - end - if ignores.empty? - @exclude_re = /^$/ - else - re_str = ignores.collect { |p| "(" + p.to_s + ")" }.join("|") - @exclude_re = Regexp.new(re_str) - end - end - - def resolve_add(fn) - case fn - when %r{[*?\[\{]} - add_matching(fn) - else - self << fn - end - end - private :resolve_add - - def resolve_exclude - calculate_exclude_regexp - reject! { |fn| exclude?(fn) } - self - end - private :resolve_exclude - - # Return a new FileList with the results of running +sub+ against each - # element of the oringal list. - # - # Example: - # FileList['a.c', 'b.c'].sub(/\.c$/, '.o') => ['a.o', 'b.o'] - # - def sub(pat, rep) - inject(FileList.new) { |res, fn| res << fn.sub(pat,rep) } - end - - # Return a new FileList with the results of running +gsub+ against each - # element of the original list. - # - # Example: - # FileList['lib/test/file', 'x/y'].gsub(/\//, "\\") - # => ['lib\\test\\file', 'x\\y'] - # - def gsub(pat, rep) - inject(FileList.new) { |res, fn| res << fn.gsub(pat,rep) } - end - - # Same as +sub+ except that the oringal file list is modified. - def sub!(pat, rep) - each_with_index { |fn, i| self[i] = fn.sub(pat,rep) } - self - end - - # Same as +gsub+ except that the original file list is modified. - def gsub!(pat, rep) - each_with_index { |fn, i| self[i] = fn.gsub(pat,rep) } - self - end - - # Apply the pathmap spec to each of the included file names, returning a - # new file list with the modified paths. (See String#pathmap for - # details.) - def pathmap(spec=nil) - collect { |fn| fn.pathmap(spec) } - end - - # Return a new FileList with String#ext method applied - # to each member of the array. - # - # This method is a shortcut for: - # - # array.collect { |item| item.ext(newext) } - # - # +ext+ is a user added method for the Array class. - def ext(newext='') - collect { |fn| fn.ext(newext) } - end - - - # Grep each of the files in the filelist using the given pattern. If a - # block is given, call the block on each matching line, passing the file - # name, line number, and the matching line of text. If no block is given, - # a standard emac style file:linenumber:line message will be printed to - # standard out. - def egrep(pattern, *options) - each do |fn| - open(fn, "rb", *options) do |inf| - count = 0 - inf.each do |line| - count += 1 - if pattern.match(line) - if block_given? - yield fn, count, line - else - puts "#{fn}:#{count}:#{line}" - end - end - end - end - end - end - - # Return a new file list that only contains file names from the current - # file list that exist on the file system. - def existing - select { |fn| File.exist?(fn) } - end - - # Modify the current file list so that it contains only file name that - # exist on the file system. - def existing! - resolve - @items = @items.select { |fn| File.exist?(fn) } - self - end - - # FileList version of partition. Needed because the nested arrays should - # be FileLists in this version. - def partition(&block) # :nodoc: - resolve - result = @items.partition(&block) - [ - FileList.new.import(result[0]), - FileList.new.import(result[1]), - ] - end - - # Convert a FileList to a string by joining all elements with a space. - def to_s - resolve - self.join(' ') - end - - # Add matching glob patterns. - def add_matching(pattern) - Dir[pattern].each do |fn| - self << fn unless exclude?(fn) - end - end - private :add_matching - - # Should the given file name be excluded? - def exclude?(fn) - calculate_exclude_regexp unless @exclude_re - fn =~ @exclude_re || @exclude_procs.any? { |p| p.call(fn) } - end - - DEFAULT_IGNORE_PATTERNS = [ - /(^|[\/\\])CVS([\/\\]|$)/, - /(^|[\/\\])\.svn([\/\\]|$)/, - /\.bak$/, - /~$/ - ] - DEFAULT_IGNORE_PROCS = [ - proc { |fn| fn =~ /(^|[\/\\])core$/ && ! File.directory?(fn) } - ] -# @exclude_patterns = DEFAULT_IGNORE_PATTERNS.dup - - def import(array) - @items = array - self - end - - class << self - # Create a new file list including the files listed. Similar to: - # - # FileList.new(*args) - def [](*args) - new(*args) - end - end - end # FileList -end - -module Rake - class << self - - # Yield each file or directory component. - def each_dir_parent(dir) # :nodoc: - old_length = nil - while dir != '.' && dir.length != old_length - yield(dir) - old_length = dir.length - dir = File.dirname(dir) - end - end - end -end # module Rake - -# Alias FileList to be available at the top level. -FileList = Rake::FileList - -############################################################################# +# ########################################################################### module Rake # Default Rakefile loader used by +import+. diff --git a/lib/rake/cloneable.rb b/lib/rake/cloneable.rb new file mode 100644 index 000000000..19c780bff --- /dev/null +++ b/lib/rake/cloneable.rb @@ -0,0 +1,25 @@ +module Rake + # ########################################################################## + # Mixin for creating easily cloned objects. + # + module Cloneable + # Clone an object by making a new object and setting all the instance + # variables to the same values. + def dup + sibling = self.class.new + instance_variables.each do |ivar| + value = self.instance_variable_get(ivar) + new_value = value.clone rescue value + sibling.instance_variable_set(ivar, new_value) + end + sibling.taint if tainted? + sibling + end + + def clone + sibling = dup + sibling.freeze if frozen? + sibling + end + end +end diff --git a/lib/rake/file_list.rb b/lib/rake/file_list.rb new file mode 100644 index 000000000..51dfc1c84 --- /dev/null +++ b/lib/rake/file_list.rb @@ -0,0 +1,410 @@ +require 'rake/cloneable' +require 'rake/rake_file_utils' + +###################################################################### +module Rake + + # ######################################################################### + # A FileList is essentially an array with a few helper methods defined to + # make file manipulation a bit easier. + # + # FileLists are lazy. When given a list of glob patterns for possible files + # to be included in the file list, instead of searching the file structures + # to find the files, a FileList holds the pattern for latter use. + # + # This allows us to define a number of FileList to match any number of + # files, but only search out the actual files when then FileList itself is + # actually used. The key is that the first time an element of the + # FileList/Array is requested, the pending patterns are resolved into a real + # list of file names. + # + class FileList + + include Cloneable + + # == Method Delegation + # + # The lazy evaluation magic of FileLists happens by implementing all the + # array specific methods to call +resolve+ before delegating the heavy + # lifting to an embedded array object (@items). + # + # In addition, there are two kinds of delegation calls. The regular kind + # delegates to the @items array and returns the result directly. Well, + # almost directly. It checks if the returned value is the @items object + # itself, and if so will return the FileList object instead. + # + # The second kind of delegation call is used in methods that normally + # return a new Array object. We want to capture the return value of these + # methods and wrap them in a new FileList object. We enumerate these + # methods in the +SPECIAL_RETURN+ list below. + + # List of array methods (that are not in +Object+) that need to be + # delegated. + ARRAY_METHODS = (Array.instance_methods - Object.instance_methods).map { |n| n.to_s } + + # List of additional methods that must be delegated. + MUST_DEFINE = %w[to_a inspect] + + # List of methods that should not be delegated here (we define special + # versions of them explicitly below). + MUST_NOT_DEFINE = %w[to_a to_ary partition *] + + # List of delegated methods that return new array values which need + # wrapping. + SPECIAL_RETURN = %w[ + map collect sort sort_by select find_all reject grep + compact flatten uniq values_at + + - & | + ] + + DELEGATING_METHODS = (ARRAY_METHODS + MUST_DEFINE - MUST_NOT_DEFINE).collect{ |s| s.to_s }.sort.uniq + + # Now do the delegation. + DELEGATING_METHODS.each_with_index do |sym, i| + if SPECIAL_RETURN.include?(sym) + ln = __LINE__+1 + class_eval %{ + def #{sym}(*args, &block) + resolve + result = @items.send(:#{sym}, *args, &block) + FileList.new.import(result) + end + }, __FILE__, ln + else + ln = __LINE__+1 + class_eval %{ + def #{sym}(*args, &block) + resolve + result = @items.send(:#{sym}, *args, &block) + result.object_id == @items.object_id ? self : result + end + }, __FILE__, ln + end + end + + # Create a file list from the globbable patterns given. If you wish to + # perform multiple includes or excludes at object build time, use the + # "yield self" pattern. + # + # Example: + # file_list = FileList.new('lib/**/*.rb', 'test/test*.rb') + # + # pkg_files = FileList.new('lib/**/*') do |fl| + # fl.exclude(/\bCVS\b/) + # end + # + def initialize(*patterns) + @pending_add = [] + @pending = false + @exclude_patterns = DEFAULT_IGNORE_PATTERNS.dup + @exclude_procs = DEFAULT_IGNORE_PROCS.dup + @exclude_re = nil + @items = [] + patterns.each { |pattern| include(pattern) } + yield self if block_given? + end + + # Add file names defined by glob patterns to the file list. If an array + # is given, add each element of the array. + # + # Example: + # file_list.include("*.java", "*.cfg") + # file_list.include %w( math.c lib.h *.o ) + # + def include(*filenames) + # TODO: check for pending + filenames.each do |fn| + if fn.respond_to? :to_ary + include(*fn.to_ary) + else + @pending_add << fn + end + end + @pending = true + self + end + alias :add :include + + # Register a list of file name patterns that should be excluded from the + # list. Patterns may be regular expressions, glob patterns or regular + # strings. In addition, a block given to exclude will remove entries that + # return true when given to the block. + # + # Note that glob patterns are expanded against the file system. If a file + # is explicitly added to a file list, but does not exist in the file + # system, then an glob pattern in the exclude list will not exclude the + # file. + # + # Examples: + # FileList['a.c', 'b.c'].exclude("a.c") => ['b.c'] + # FileList['a.c', 'b.c'].exclude(/^a/) => ['b.c'] + # + # If "a.c" is a file, then ... + # FileList['a.c', 'b.c'].exclude("a.*") => ['b.c'] + # + # If "a.c" is not a file, then ... + # FileList['a.c', 'b.c'].exclude("a.*") => ['a.c', 'b.c'] + # + def exclude(*patterns, &block) + patterns.each do |pat| + @exclude_patterns << pat + end + if block_given? + @exclude_procs << block + end + resolve_exclude if ! @pending + self + end + + + # Clear all the exclude patterns so that we exclude nothing. + def clear_exclude + @exclude_patterns = [] + @exclude_procs = [] + calculate_exclude_regexp if ! @pending + self + end + + # Define equality. + def ==(array) + to_ary == array + end + + # Return the internal array object. + def to_a + resolve + @items + end + + # Return the internal array object. + def to_ary + to_a + end + + # Lie about our class. + def is_a?(klass) + klass == Array || super(klass) + end + alias kind_of? is_a? + + # Redefine * to return either a string or a new file list. + def *(other) + result = @items * other + case result + when Array + FileList.new.import(result) + else + result + end + end + + # Resolve all the pending adds now. + def resolve + if @pending + @pending = false + @pending_add.each do |fn| resolve_add(fn) end + @pending_add = [] + resolve_exclude + end + self + end + + def calculate_exclude_regexp + ignores = [] + @exclude_patterns.each do |pat| + case pat + when Regexp + ignores << pat + when /[*?]/ + Dir[pat].each do |p| ignores << p end + else + ignores << Regexp.quote(pat) + end + end + if ignores.empty? + @exclude_re = /^$/ + else + re_str = ignores.collect { |p| "(" + p.to_s + ")" }.join("|") + @exclude_re = Regexp.new(re_str) + end + end + + def resolve_add(fn) + case fn + when %r{[*?\[\{]} + add_matching(fn) + else + self << fn + end + end + private :resolve_add + + def resolve_exclude + calculate_exclude_regexp + reject! { |fn| exclude?(fn) } + self + end + private :resolve_exclude + + # Return a new FileList with the results of running +sub+ against each + # element of the oringal list. + # + # Example: + # FileList['a.c', 'b.c'].sub(/\.c$/, '.o') => ['a.o', 'b.o'] + # + def sub(pat, rep) + inject(FileList.new) { |res, fn| res << fn.sub(pat,rep) } + end + + # Return a new FileList with the results of running +gsub+ against each + # element of the original list. + # + # Example: + # FileList['lib/test/file', 'x/y'].gsub(/\//, "\\") + # => ['lib\\test\\file', 'x\\y'] + # + def gsub(pat, rep) + inject(FileList.new) { |res, fn| res << fn.gsub(pat,rep) } + end + + # Same as +sub+ except that the oringal file list is modified. + def sub!(pat, rep) + each_with_index { |fn, i| self[i] = fn.sub(pat,rep) } + self + end + + # Same as +gsub+ except that the original file list is modified. + def gsub!(pat, rep) + each_with_index { |fn, i| self[i] = fn.gsub(pat,rep) } + self + end + + # Apply the pathmap spec to each of the included file names, returning a + # new file list with the modified paths. (See String#pathmap for + # details.) + def pathmap(spec=nil) + collect { |fn| fn.pathmap(spec) } + end + + # Return a new FileList with String#ext method applied + # to each member of the array. + # + # This method is a shortcut for: + # + # array.collect { |item| item.ext(newext) } + # + # +ext+ is a user added method for the Array class. + def ext(newext='') + collect { |fn| fn.ext(newext) } + end + + + # Grep each of the files in the filelist using the given pattern. If a + # block is given, call the block on each matching line, passing the file + # name, line number, and the matching line of text. If no block is given, + # a standard emac style file:linenumber:line message will be printed to + # standard out. + def egrep(pattern, *options) + each do |fn| + open(fn, "rb", *options) do |inf| + count = 0 + inf.each do |line| + count += 1 + if pattern.match(line) + if block_given? + yield fn, count, line + else + puts "#{fn}:#{count}:#{line}" + end + end + end + end + end + end + + # Return a new file list that only contains file names from the current + # file list that exist on the file system. + def existing + select { |fn| File.exist?(fn) } + end + + # Modify the current file list so that it contains only file name that + # exist on the file system. + def existing! + resolve + @items = @items.select { |fn| File.exist?(fn) } + self + end + + # FileList version of partition. Needed because the nested arrays should + # be FileLists in this version. + def partition(&block) # :nodoc: + resolve + result = @items.partition(&block) + [ + FileList.new.import(result[0]), + FileList.new.import(result[1]), + ] + end + + # Convert a FileList to a string by joining all elements with a space. + def to_s + resolve + self.join(' ') + end + + # Add matching glob patterns. + def add_matching(pattern) + Dir[pattern].each do |fn| + self << fn unless exclude?(fn) + end + end + private :add_matching + + # Should the given file name be excluded? + def exclude?(fn) + calculate_exclude_regexp unless @exclude_re + fn =~ @exclude_re || @exclude_procs.any? { |p| p.call(fn) } + end + + DEFAULT_IGNORE_PATTERNS = [ + /(^|[\/\\])CVS([\/\\]|$)/, + /(^|[\/\\])\.svn([\/\\]|$)/, + /\.bak$/, + /~$/ + ] + DEFAULT_IGNORE_PROCS = [ + proc { |fn| fn =~ /(^|[\/\\])core$/ && ! File.directory?(fn) } + ] +# @exclude_patterns = DEFAULT_IGNORE_PATTERNS.dup + + def import(array) + @items = array + self + end + + class << self + # Create a new file list including the files listed. Similar to: + # + # FileList.new(*args) + def [](*args) + new(*args) + end + end + end # FileList +end + +module Rake + class << self + + # Yield each file or directory component. + def each_dir_parent(dir) # :nodoc: + old_length = nil + while dir != '.' && dir.length != old_length + yield(dir) + old_length = dir.length + dir = File.dirname(dir) + end + end + end +end # module Rake diff --git a/lib/rake/file_utils.rb b/lib/rake/file_utils.rb new file mode 100644 index 000000000..4454f7806 --- /dev/null +++ b/lib/rake/file_utils.rb @@ -0,0 +1,103 @@ +# ########################################################################### +# This a FileUtils extension that defines several additional commands to be +# added to the FileUtils utility functions. +# +module FileUtils + RUBY = File.join( + Config::CONFIG['bindir'], + Config::CONFIG['ruby_install_name'] + Config::CONFIG['EXEEXT']). + sub(/.*\s.*/m, '"\&"') + + OPT_TABLE['sh'] = %w(noop verbose) + OPT_TABLE['ruby'] = %w(noop verbose) + + # Run the system command +cmd+. If multiple arguments are given the command + # is not run with the shell (same semantics as Kernel::exec and + # Kernel::system). + # + # Example: + # sh %{ls -ltr} + # + # sh 'ls', 'file with spaces' + # + # # check exit status after command runs + # sh %{grep pattern file} do |ok, res| + # if ! ok + # puts "pattern not found (status = #{res.exitstatus})" + # end + # end + # + def sh(*cmd, &block) + options = (Hash === cmd.last) ? cmd.pop : {} + unless block_given? + show_command = cmd.join(" ") + show_command = show_command[0,42] + "..." unless $trace + # TODO code application logic heref show_command.length > 45 + block = lambda { |ok, status| + ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]" + } + end + if RakeFileUtils.verbose_flag == :default + options[:verbose] = true + else + options[:verbose] ||= RakeFileUtils.verbose_flag + end + options[:noop] ||= RakeFileUtils.nowrite_flag + rake_check_options options, :noop, :verbose + rake_output_message cmd.join(" ") if options[:verbose] + unless options[:noop] + res = rake_system(*cmd) + status = $? + status = PseudoStatus.new(1) if !res && status.nil? + block.call(res, status) + end + end + + def rake_system(*cmd) + Rake::AltSystem.system(*cmd) + end + private :rake_system + + # Run a Ruby interpreter with the given arguments. + # + # Example: + # ruby %{-pe '$_.upcase!' 1 then + sh(*([RUBY] + args + [options]), &block) + else + sh("#{RUBY} #{args.first}", options, &block) + end + end + + LN_SUPPORTED = [true] + + # Attempt to do a normal file link, but fall back to a copy if the link + # fails. + def safe_ln(*args) + unless LN_SUPPORTED[0] + cp(*args) + else + begin + ln(*args) + rescue StandardError, NotImplementedError => ex + LN_SUPPORTED[0] = false + cp(*args) + end + end + end + + # Split a file path into individual directory names. + # + # Example: + # split_all("a/b/c") => ['a', 'b', 'c'] + # + def split_all(path) + head, tail = File.split(path) + return [tail] if head == '.' || tail == '/' + return [head, tail] if head == '/' + return split_all(head) + [tail] + end +end diff --git a/lib/rake/rake_file_utils.rb b/lib/rake/rake_file_utils.rb new file mode 100644 index 000000000..7ddd5b33b --- /dev/null +++ b/lib/rake/rake_file_utils.rb @@ -0,0 +1,142 @@ +require 'rake/file_utils' + +# ########################################################################### +# RakeFileUtils provides a custom version of the FileUtils methods that +# respond to the verbose and nowrite commands. +# +module RakeFileUtils + include FileUtils + + class << self + attr_accessor :verbose_flag, :nowrite_flag + end + RakeFileUtils.verbose_flag = :default + RakeFileUtils.nowrite_flag = false + + $fileutils_verbose = true + $fileutils_nowrite = false + + FileUtils::OPT_TABLE.each do |name, opts| + default_options = [] + if opts.include?(:verbose) || opts.include?("verbose") + default_options << ':verbose => RakeFileUtils.verbose_flag' + end + if opts.include?(:noop) || opts.include?("noop") + default_options << ':noop => RakeFileUtils.nowrite_flag' + end + + next if default_options.empty? + module_eval(<<-EOS, __FILE__, __LINE__ + 1) + def #{name}( *args, &block ) + super( + *rake_merge_option(args, + #{default_options.join(', ')} + ), &block) + end + EOS + end + + # Get/set the verbose flag controlling output from the FileUtils utilities. + # If verbose is true, then the utility method is echoed to standard output. + # + # Examples: + # verbose # return the current value of the verbose flag + # verbose(v) # set the verbose flag to _v_. + # verbose(v) { code } # Execute code with the verbose flag set temporarily to _v_. + # # Return to the original value when code is done. + def verbose(value=nil) + oldvalue = RakeFileUtils.verbose_flag + RakeFileUtils.verbose_flag = value unless value.nil? + if block_given? + begin + yield + ensure + RakeFileUtils.verbose_flag = oldvalue + end + end + RakeFileUtils.verbose_flag + end + + # Get/set the nowrite flag controlling output from the FileUtils utilities. + # If verbose is true, then the utility method is echoed to standard output. + # + # Examples: + # nowrite # return the current value of the nowrite flag + # nowrite(v) # set the nowrite flag to _v_. + # nowrite(v) { code } # Execute code with the nowrite flag set temporarily to _v_. + # # Return to the original value when code is done. + def nowrite(value=nil) + oldvalue = RakeFileUtils.nowrite_flag + RakeFileUtils.nowrite_flag = value unless value.nil? + if block_given? + begin + yield + ensure + RakeFileUtils.nowrite_flag = oldvalue + end + end + oldvalue + end + + # Use this function to prevent protentially destructive ruby code from + # running when the :nowrite flag is set. + # + # Example: + # + # when_writing("Building Project") do + # project.build + # end + # + # The following code will build the project under normal conditions. If the + # nowrite(true) flag is set, then the example will print: + # DRYRUN: Building Project + # instead of actually building the project. + # + def when_writing(msg=nil) + if RakeFileUtils.nowrite_flag + puts "DRYRUN: #{msg}" if msg + else + yield + end + end + + # Merge the given options with the default values. + def rake_merge_option(args, defaults) + if Hash === args.last + defaults.update(args.last) + args.pop + end + args.push defaults + args + end + private :rake_merge_option + + # Send the message to the default rake output (which is $stderr). + def rake_output_message(message) + $stderr.puts(message) + end + private :rake_output_message + + # Check that the options do not contain options not listed in +optdecl+. An + # ArgumentError exception is thrown if non-declared options are found. + def rake_check_options(options, *optdecl) + h = options.dup + optdecl.each do |name| + h.delete name + end + raise ArgumentError, "no such option: #{h.keys.join(' ')}" unless h.empty? + end + private :rake_check_options + + extend self +end + +# ########################################################################### +# Include the FileUtils file manipulation functions in the top level module, +# but mark them private so that they don't unintentionally define methods on +# other objects. + +include RakeFileUtils +private(*FileUtils.instance_methods(false)) +private(*RakeFileUtils.instance_methods(false)) + diff --git a/test/test_fileutils.rb b/test/test_fileutils.rb index 20d965079..083b2cc5d 100644 --- a/test/test_fileutils.rb +++ b/test/test_fileutils.rb @@ -117,7 +117,7 @@ def test_file_utils_methods_are_available_at_top_level def test_fileutils_methods_dont_leak obj = Object.new assert_exception(NoMethodError) { obj.copy } # from FileUtils - assert_exception(NoMethodError) { obj.ruby } # from RubyFileUtils + assert_exception(NoMethodError) { obj.ruby "-v" } # from RubyFileUtils end def test_sh From 2de58bc9e1b1ab89564f160c58f768cefa736e70 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Sat, 28 Mar 2009 16:49:10 +0000 Subject: [PATCH 0006/1389] Broken into separate files. --- lib/rake.rb | 1821 +-------------------- lib/rake/application.rb | 532 ++++++ lib/rake/default_loader.rb | 10 + lib/rake/dsl.rb | 117 ++ lib/rake/early_time.rb | 18 + lib/rake/ext/module.rb | 54 + lib/rake/ext/string.rb | 165 ++ lib/rake/ext/time.rb | 14 + lib/rake/file_creation_task.rb | 24 + lib/rake/file_task.rb | 47 + lib/rake/invocation_chain.rb | 51 + lib/rake/multi_task.rb | 16 + lib/rake/name_space.rb | 25 + lib/rake/psuedo_status.rb | 24 + lib/rake/rake_module.rb | 23 + lib/rake/rule_recursion_overflow_error.rb | 20 + lib/rake/task.rb | 301 ++++ lib/rake/task_argument_error.rb | 7 + lib/rake/task_arguments.rb | 78 + lib/rake/task_manager.rb | 306 ++++ 20 files changed, 1833 insertions(+), 1820 deletions(-) create mode 100644 lib/rake/application.rb create mode 100644 lib/rake/default_loader.rb create mode 100644 lib/rake/dsl.rb create mode 100644 lib/rake/early_time.rb create mode 100644 lib/rake/ext/module.rb create mode 100644 lib/rake/ext/string.rb create mode 100644 lib/rake/ext/time.rb create mode 100644 lib/rake/file_creation_task.rb create mode 100644 lib/rake/file_task.rb create mode 100644 lib/rake/invocation_chain.rb create mode 100644 lib/rake/multi_task.rb create mode 100644 lib/rake/name_space.rb create mode 100644 lib/rake/psuedo_status.rb create mode 100644 lib/rake/rake_module.rb create mode 100644 lib/rake/rule_recursion_overflow_error.rb create mode 100644 lib/rake/task.rb create mode 100644 lib/rake/task_argument_error.rb create mode 100644 lib/rake/task_arguments.rb create mode 100644 lib/rake/task_manager.rb diff --git a/lib/rake.rb b/lib/rake.rb index 961e64c5b..87d9e7ed6 100755 --- a/lib/rake.rb +++ b/lib/rake.rb @@ -29,7 +29,7 @@ # as a library via a require statement, but it can be distributed # independently as an application. -RAKEVERSION = '0.8.7' +RAKEVERSION = '0.8.5' require 'rbconfig' require 'fileutils' @@ -41,1826 +41,7 @@ require 'rake/win32' require 'rake/file_list' - # Alias FileList to be available at the top level. FileList = Rake::FileList $trace = false - -###################################################################### -# Rake extensions to Module. -# -class Module - # Check for an existing method in the current class before extending. IF - # the method already exists, then a warning is printed and the extension is - # not added. Otherwise the block is yielded and any definitions in the - # block will take effect. - # - # Usage: - # - # class String - # rake_extension("xyz") do - # def xyz - # ... - # end - # end - # end - # - def rake_extension(method) - if method_defined?(method) - $stderr.puts "WARNING: Possible conflict with Rake extension: #{self}##{method} already exists" - else - yield - end - end -end # module Module - - -###################################################################### -# User defined methods to be added to String. -# -class String - rake_extension("ext") do - # Replace the file extension with +newext+. If there is no extension on - # the string, append the new extension to the end. If the new extension - # is not given, or is the empty string, remove any existing extension. - # - # +ext+ is a user added method for the String class. - def ext(newext='') - return self.dup if ['.', '..'].include? self - if newext != '' - newext = (newext =~ /^\./) ? newext : ("." + newext) - end - self.chomp(File.extname(self)) << newext - end - end - - rake_extension("pathmap") do - # Explode a path into individual components. Used by +pathmap+. - def pathmap_explode - head, tail = File.split(self) - return [self] if head == self - return [tail] if head == '.' || tail == '/' - return [head, tail] if head == '/' - return head.pathmap_explode + [tail] - end - protected :pathmap_explode - - # Extract a partial path from the path. Include +n+ directories from the - # front end (left hand side) if +n+ is positive. Include |+n+| - # directories from the back end (right hand side) if +n+ is negative. - def pathmap_partial(n) - dirs = File.dirname(self).pathmap_explode - partial_dirs = - if n > 0 - dirs[0...n] - elsif n < 0 - dirs.reverse[0...-n].reverse - else - "." - end - File.join(partial_dirs) - end - protected :pathmap_partial - - # Preform the pathmap replacement operations on the given path. The - # patterns take the form 'pat1,rep1;pat2,rep2...'. - def pathmap_replace(patterns, &block) - result = self - patterns.split(';').each do |pair| - pattern, replacement = pair.split(',') - pattern = Regexp.new(pattern) - if replacement == '*' && block_given? - result = result.sub(pattern, &block) - elsif replacement - result = result.sub(pattern, replacement) - else - result = result.sub(pattern, '') - end - end - result - end - protected :pathmap_replace - - # Map the path according to the given specification. The specification - # controls the details of the mapping. The following special patterns are - # recognized: - # - # * %p -- The complete path. - # * %f -- The base file name of the path, with its file extension, - # but without any directories. - # * %n -- The file name of the path without its file extension. - # * %d -- The directory list of the path. - # * %x -- The file extension of the path. An empty string if there - # is no extension. - # * %X -- Everything *but* the file extension. - # * %s -- The alternate file separater if defined, otherwise use - # the standard file separator. - # * %% -- A percent sign. - # - # The %d specifier can also have a numeric prefix (e.g. '%2d'). If the - # number is positive, only return (up to) +n+ directories in the path, - # starting from the left hand side. If +n+ is negative, return (up to) - # |+n+| directories from the right hand side of the path. - # - # Examples: - # - # 'a/b/c/d/file.txt'.pathmap("%2d") => 'a/b' - # 'a/b/c/d/file.txt'.pathmap("%-2d") => 'c/d' - # - # Also the %d, %p, %f, %n, %x, and %X operators can take a - # pattern/replacement argument to perform simple string substititions on a - # particular part of the path. The pattern and replacement are speparated - # by a comma and are enclosed by curly braces. The replacement spec comes - # after the % character but before the operator letter. (e.g. - # "%{old,new}d"). Muliple replacement specs should be separated by - # semi-colons (e.g. "%{old,new;src,bin}d"). - # - # Regular expressions may be used for the pattern, and back refs may be - # used in the replacement text. Curly braces, commas and semi-colons are - # excluded from both the pattern and replacement text (let's keep parsing - # reasonable). - # - # For example: - # - # "src/org/onestepback/proj/A.java".pathmap("%{^src,bin}X.class") - # - # returns: - # - # "bin/org/onestepback/proj/A.class" - # - # If the replacement text is '*', then a block may be provided to perform - # some arbitrary calculation for the replacement. - # - # For example: - # - # "/path/to/file.TXT".pathmap("%X%{.*,*}x") { |ext| - # ext.downcase - # } - # - # Returns: - # - # "/path/to/file.txt" - # - def pathmap(spec=nil, &block) - return self if spec.nil? - result = '' - spec.scan(/%\{[^}]*\}-?\d*[sdpfnxX%]|%-?\d+d|%.|[^%]+/) do |frag| - case frag - when '%f' - result << File.basename(self) - when '%n' - result << File.basename(self).ext - when '%d' - result << File.dirname(self) - when '%x' - result << File.extname(self) - when '%X' - result << self.ext - when '%p' - result << self - when '%s' - result << (File::ALT_SEPARATOR || File::SEPARATOR) - when '%-' - # do nothing - when '%%' - result << "%" - when /%(-?\d+)d/ - result << pathmap_partial($1.to_i) - when /^%\{([^}]*)\}(\d*[dpfnxX])/ - patterns, operator = $1, $2 - result << pathmap('%' + operator).pathmap_replace(patterns, &block) - when /^%/ - fail ArgumentError, "Unknown pathmap specifier #{frag} in '#{spec}'" - else - result << frag - end - end - result - end - end -end # class String - -############################################################################## -module Rake - - # Errors ----------------------------------------------------------- - - # Error indicating an ill-formed task declaration. - class TaskArgumentError < ArgumentError - end - - # Error indicating a recursion overflow error in task selection. - class RuleRecursionOverflowError < StandardError - def initialize(*args) - super - @targets = [] - end - - def add_target(target) - @targets << target - end - - def message - super + ": [" + @targets.reverse.join(' => ') + "]" - end - end - - # -------------------------------------------------------------------------- - # Rake module singleton methods. - # - class << self - # Current Rake Application - def application - @application ||= Rake::Application.new - end - - # Set the current Rake application object. - def application=(app) - @application = app - end - - # Return the original directory where the Rake application was started. - def original_dir - application.original_dir - end - - end - - #################################################################### - #################################################################### - # Exit status class for times the system just gives us a nil. - class PseudoStatus - attr_reader :exitstatus - def initialize(code=0) - @exitstatus = code - end - def to_i - @exitstatus << 8 - end - def >>(n) - to_i >> n - end - def stopped? - false - end - def exited? - true - end - end - - #################################################################### - # TaskAguments manage the arguments passed to a task. - # - class TaskArguments - include Enumerable - - attr_reader :names - - # Create a TaskArgument object with a list of named arguments - # (given by :names) and a set of associated values (given by - # :values). :parent is the parent argument object. - def initialize(names, values, parent=nil) - @names = names - @parent = parent - @hash = {} - names.each_with_index { |name, i| - @hash[name.to_sym] = values[i] unless values[i].nil? - } - end - - # Create a new argument scope using the prerequisite argument - # names. - def new_scope(names) - values = names.collect { |n| self[n] } - self.class.new(names, values, self) - end - - # Find an argument value by name or index. - def [](index) - lookup(index.to_sym) - end - - # Specify a hash of default values for task arguments. Use the - # defaults only if there is no specific value for the given - # argument. - def with_defaults(defaults) - @hash = defaults.merge(@hash) - end - - def each(&block) - @hash.each(&block) - end - - def method_missing(sym, *args, &block) - lookup(sym.to_sym) - end - - def to_hash - @hash - end - - def to_s - @hash.inspect - end - - def inspect - to_s - end - - protected - - def lookup(name) - if @hash.has_key?(name) - @hash[name] - elsif ENV.has_key?(name.to_s) - ENV[name.to_s] - elsif ENV.has_key?(name.to_s.upcase) - ENV[name.to_s.upcase] - elsif @parent - @parent.lookup(name) - end - end - end - - EMPTY_TASK_ARGS = TaskArguments.new([], []) - - #################################################################### - # InvocationChain tracks the chain of task invocations to detect - # circular dependencies. - class InvocationChain - def initialize(value, tail) - @value = value - @tail = tail - end - - def member?(obj) - @value == obj || @tail.member?(obj) - end - - def append(value) - if member?(value) - fail RuntimeError, "Circular dependency detected: #{to_s} => #{value}" - end - self.class.new(value, self) - end - - def to_s - "#{prefix}#{@value}" - end - - def self.append(value, chain) - chain.append(value) - end - - private - - def prefix - "#{@tail.to_s} => " - end - - class EmptyInvocationChain - def member?(obj) - false - end - def append(value) - InvocationChain.new(value, self) - end - def to_s - "TOP" - end - end - - EMPTY = EmptyInvocationChain.new - - end # class InvocationChain - -end # module Rake - -module Rake - - ########################################################################### - # A Task is the basic unit of work in a Rakefile. Tasks have associated - # actions (possibly more than one) and a list of prerequisites. When - # invoked, a task will first ensure that all of its prerequisites have an - # opportunity to run and then it will execute its own actions. - # - # Tasks are not usually created directly using the new method, but rather - # use the +file+ and +task+ convenience methods. - # - class Task - # List of prerequisites for a task. - attr_reader :prerequisites - - # List of actions attached to a task. - attr_reader :actions - - # Application owning this task. - attr_accessor :application - - # Comment for this task. Restricted to a single line of no more than 50 - # characters. - attr_reader :comment - - # Full text of the (possibly multi-line) comment. - attr_reader :full_comment - - # Array of nested namespaces names used for task lookup by this task. - attr_reader :scope - - # Return task name - def to_s - name - end - - def inspect - "<#{self.class} #{name} => [#{prerequisites.join(', ')}]>" - end - - # List of sources for task. - attr_writer :sources - def sources - @sources ||= [] - end - - # First source from a rule (nil if no sources) - def source - @sources.first if defined?(@sources) - end - - # Create a task named +task_name+ with no actions or prerequisites. Use - # +enhance+ to add actions and prerequisites. - def initialize(task_name, app) - @name = task_name.to_s - @prerequisites = [] - @actions = [] - @already_invoked = false - @full_comment = nil - @comment = nil - @lock = Monitor.new - @application = app - @scope = app.current_scope - @arg_names = nil - end - - # Enhance a task with prerequisites or actions. Returns self. - def enhance(deps=nil, &block) - @prerequisites |= deps if deps - @actions << block if block_given? - self - end - - # Name of the task, including any namespace qualifiers. - def name - @name.to_s - end - - # Name of task with argument list description. - def name_with_args # :nodoc: - if arg_description - "#{name}#{arg_description}" - else - name - end - end - - # Argument description (nil if none). - def arg_description # :nodoc: - @arg_names ? "[#{(arg_names || []).join(',')}]" : nil - end - - # Name of arguments for this task. - def arg_names - @arg_names || [] - end - - # Reenable the task, allowing its tasks to be executed if the task - # is invoked again. - def reenable - @already_invoked = false - end - - # Clear the existing prerequisites and actions of a rake task. - def clear - clear_prerequisites - clear_actions - self - end - - # Clear the existing prerequisites of a rake task. - def clear_prerequisites - prerequisites.clear - self - end - - # Clear the existing actions on a rake task. - def clear_actions - actions.clear - self - end - - # Invoke the task if it is needed. Prerequites are invoked first. - def invoke(*args) - task_args = TaskArguments.new(arg_names, args) - invoke_with_call_chain(task_args, InvocationChain::EMPTY) - end - - # Same as invoke, but explicitly pass a call chain to detect - # circular dependencies. - def invoke_with_call_chain(task_args, invocation_chain) # :nodoc: - new_chain = InvocationChain.append(self, invocation_chain) - @lock.synchronize do - if application.options.trace - puts "** Invoke #{name} #{format_trace_flags}" - end - return if @already_invoked - @already_invoked = true - invoke_prerequisites(task_args, new_chain) - execute(task_args) if needed? - end - end - protected :invoke_with_call_chain - - # Invoke all the prerequisites of a task. - def invoke_prerequisites(task_args, invocation_chain) # :nodoc: - @prerequisites.each { |n| - prereq = application[n, @scope] - prereq_args = task_args.new_scope(prereq.arg_names) - prereq.invoke_with_call_chain(prereq_args, invocation_chain) - } - end - - # Format the trace flags for display. - def format_trace_flags - flags = [] - flags << "first_time" unless @already_invoked - flags << "not_needed" unless needed? - flags.empty? ? "" : "(" + flags.join(", ") + ")" - end - private :format_trace_flags - - # Execute the actions associated with this task. - def execute(args=nil) - args ||= EMPTY_TASK_ARGS - if application.options.dryrun - puts "** Execute (dry run) #{name}" - return - end - if application.options.trace - puts "** Execute #{name}" - end - application.enhance_with_matching_rule(name) if @actions.empty? - @actions.each do |act| - case act.arity - when 1 - act.call(self) - else - act.call(self, args) - end - end - end - - # Is this task needed? - def needed? - true - end - - # Timestamp for this task. Basic tasks return the current time for their - # time stamp. Other tasks can be more sophisticated. - def timestamp - @prerequisites.collect { |p| application[p].timestamp }.max || Time.now - end - - # Add a description to the task. The description can consist of an option - # argument list (enclosed brackets) and an optional comment. - def add_description(description) - return if ! description - comment = description.strip - add_comment(comment) if comment && ! comment.empty? - end - - # Writing to the comment attribute is the same as adding a description. - def comment=(description) - add_description(description) - end - - # Add a comment to the task. If a comment alread exists, separate - # the new comment with " / ". - def add_comment(comment) - if @full_comment - @full_comment << " / " - else - @full_comment = '' - end - @full_comment << comment - if @full_comment =~ /\A([^.]+?\.)( |$)/ - @comment = $1 - else - @comment = @full_comment - end - end - private :add_comment - - # Set the names of the arguments for this task. +args+ should be - # an array of symbols, one for each argument name. - def set_arg_names(args) - @arg_names = args.map { |a| a.to_sym } - end - - # Return a string describing the internal state of a task. Useful for - # debugging. - def investigation - result = "------------------------------\n" - result << "Investigating #{name}\n" - result << "class: #{self.class}\n" - result << "task needed: #{needed?}\n" - result << "timestamp: #{timestamp}\n" - result << "pre-requisites: \n" - prereqs = @prerequisites.collect {|name| application[name]} - prereqs.sort! {|a,b| a.timestamp <=> b.timestamp} - prereqs.each do |p| - result << "--#{p.name} (#{p.timestamp})\n" - end - latest_prereq = @prerequisites.collect{|n| application[n].timestamp}.max - result << "latest-prerequisite time: #{latest_prereq}\n" - result << "................................\n\n" - return result - end - - # ---------------------------------------------------------------- - # Rake Module Methods - # - class << self - - # Clear the task list. This cause rake to immediately forget all the - # tasks that have been assigned. (Normally used in the unit tests.) - def clear - Rake.application.clear - end - - # List of all defined tasks. - def tasks - Rake.application.tasks - end - - # Return a task with the given name. If the task is not currently - # known, try to synthesize one from the defined rules. If no rules are - # found, but an existing file matches the task name, assume it is a file - # task with no dependencies or actions. - def [](task_name) - Rake.application[task_name] - end - - # TRUE if the task name is already defined. - def task_defined?(task_name) - Rake.application.lookup(task_name) != nil - end - - # Define a task given +args+ and an option block. If a rule with the - # given name already exists, the prerequisites and actions are added to - # the existing task. Returns the defined task. - def define_task(*args, &block) - Rake.application.define_task(self, *args, &block) - end - - # Define a rule for synthesizing tasks. - def create_rule(*args, &block) - Rake.application.create_rule(*args, &block) - end - - # Apply the scope to the task name according to the rules for - # this kind of task. Generic tasks will accept the scope as - # part of the name. - def scope_name(scope, task_name) - (scope + [task_name]).join(':') - end - - end # class << Rake::Task - end # class Rake::Task - - - ########################################################################### - # A FileTask is a task that includes time based dependencies. If any of a - # FileTask's prerequisites have a timestamp that is later than the file - # represented by this task, then the file must be rebuilt (using the - # supplied actions). - # - class FileTask < Task - - # Is this file task needed? Yes if it doesn't exist, or if its time stamp - # is out of date. - def needed? - ! File.exist?(name) || out_of_date?(timestamp) - end - - # Time stamp for file task. - def timestamp - if File.exist?(name) - File.mtime(name.to_s) - else - Rake::EARLY - end - end - - private - - # Are there any prerequisites with a later time than the given time stamp? - def out_of_date?(stamp) - @prerequisites.any? { |n| application[n].timestamp > stamp} - end - - # ---------------------------------------------------------------- - # Task class methods. - # - class << self - # Apply the scope to the task name according to the rules for this kind - # of task. File based tasks ignore the scope when creating the name. - def scope_name(scope, task_name) - task_name - end - end - end # class Rake::FileTask - - ########################################################################### - # A FileCreationTask is a file task that when used as a dependency will be - # needed if and only if the file has not been created. Once created, it is - # not re-triggered if any of its dependencies are newer, nor does trigger - # any rebuilds of tasks that depend on it whenever it is updated. - # - class FileCreationTask < FileTask - # Is this file task needed? Yes if it doesn't exist. - def needed? - ! File.exist?(name) - end - - # Time stamp for file creation task. This time stamp is earlier - # than any other time stamp. - def timestamp - Rake::EARLY - end - end - - ########################################################################### - # Same as a regular task, but the immediate prerequisites are done in - # parallel using Ruby threads. - # - class MultiTask < Task - private - def invoke_prerequisites(args, invocation_chain) - threads = @prerequisites.collect { |p| - Thread.new(p) { |r| application[r].invoke_with_call_chain(args, invocation_chain) } - } - threads.each { |t| t.join } - end - end -end # module Rake - -## ########################################################################### -# Task Definition Functions ... - -# Declare a basic task. -# -# Example: -# task :clobber => [:clean] do -# rm_rf "html" -# end -# -def task(*args, &block) - Rake::Task.define_task(*args, &block) -end - - -# Declare a file task. -# -# Example: -# file "config.cfg" => ["config.template"] do -# open("config.cfg", "w") do |outfile| -# open("config.template") do |infile| -# while line = infile.gets -# outfile.puts line -# end -# end -# end -# end -# -def file(*args, &block) - Rake::FileTask.define_task(*args, &block) -end - -# Declare a file creation task. -# (Mainly used for the directory command). -def file_create(args, &block) - Rake::FileCreationTask.define_task(args, &block) -end - -# Declare a set of files tasks to create the given directories on demand. -# -# Example: -# directory "testdata/doc" -# -def directory(dir) - Rake.each_dir_parent(dir) do |d| - file_create d do |t| - mkdir_p t.name if ! File.exist?(t.name) - end - end -end - -# Declare a task that performs its prerequisites in parallel. Multitasks does -# *not* guarantee that its prerequisites will execute in any given order -# (which is obvious when you think about it) -# -# Example: -# multitask :deploy => [:deploy_gem, :deploy_rdoc] -# -def multitask(args, &block) - Rake::MultiTask.define_task(args, &block) -end - -# Create a new rake namespace and use it for evaluating the given block. -# Returns a NameSpace object that can be used to lookup tasks defined in the -# namespace. -# -# E.g. -# -# ns = namespace "nested" do -# task :run -# end -# task_run = ns[:run] # find :run in the given namespace. -# -def namespace(name=nil, &block) - Rake.application.in_namespace(name, &block) -end - -# Declare a rule for auto-tasks. -# -# Example: -# rule '.o' => '.c' do |t| -# sh %{cc -o #{t.name} #{t.source}} -# end -# -def rule(*args, &block) - Rake::Task.create_rule(*args, &block) -end - -# Describe the next rake task. -# -# Example: -# desc "Run the Unit Tests" -# task :test => [:build] -# runtests -# end -# -def desc(description) - Rake.application.last_description = description -end - -# Import the partial Rakefiles +fn+. Imported files are loaded _after_ the -# current file is completely loaded. This allows the import statement to -# appear anywhere in the importing file, and yet allowing the imported files -# to depend on objects defined in the importing file. -# -# A common use of the import statement is to include files containing -# dependency declarations. -# -# See also the --rakelibdir command line option. -# -# Example: -# import ".depend", "my_rules" -# -def import(*fns) - fns.each do |fn| - Rake.application.add_import(fn) - end -end - -# ########################################################################### -module Rake - - # Default Rakefile loader used by +import+. - class DefaultLoader - def load(fn) - Kernel.load(File.expand_path(fn)) - end - end - - # EarlyTime is a fake timestamp that occurs _before_ any other time value. - class EarlyTime - include Comparable - include Singleton - - def <=>(other) - -1 - end - - def to_s - "" - end - end - - EARLY = EarlyTime.instance -end # module Rake - -############################################################################# -# Extensions to time to allow comparisons with an early time class. -# -class Time - alias rake_original_time_compare :<=> - def <=>(other) - if Rake::EarlyTime === other - - other.<=>(self) - else - rake_original_time_compare(other) - end - end -end # class Time - -module Rake - - #################################################################### - # The NameSpace class will lookup task names in the the scope - # defined by a +namespace+ command. - # - class NameSpace - - # Create a namespace lookup object using the given task manager - # and the list of scopes. - def initialize(task_manager, scope_list) - @task_manager = task_manager - @scope = scope_list.dup - end - - # Lookup a task named +name+ in the namespace. - def [](name) - @task_manager.lookup(name, @scope) - end - - # Return the list of tasks defined in this and nested namespaces. - def tasks - @task_manager.tasks_in_scope(@scope) - end - end # NameSpace - - - #################################################################### - # The TaskManager module is a mixin for managing tasks. - module TaskManager - # Track the last comment made in the Rakefile. - attr_accessor :last_description - alias :last_comment :last_description # Backwards compatibility - - def initialize - super - @tasks = Hash.new - @rules = Array.new - @scope = Array.new - @last_description = nil - end - - def create_rule(*args, &block) - pattern, arg_names, deps = resolve_args(args) - pattern = Regexp.new(Regexp.quote(pattern) + '$') if String === pattern - @rules << [pattern, deps, block] - end - - def define_task(task_class, *args, &block) - task_name, arg_names, deps = resolve_args(args) - task_name = task_class.scope_name(@scope, task_name) - deps = [deps] unless deps.respond_to?(:to_ary) - deps = deps.collect {|d| d.to_s } - task = intern(task_class, task_name) - task.set_arg_names(arg_names) unless arg_names.empty? - task.add_description(get_description) - task.enhance(deps, &block) - task - end - - # Lookup a task. Return an existing task if found, otherwise - # create a task of the current type. - def intern(task_class, task_name) - @tasks[task_name.to_s] ||= task_class.new(task_name, self) - end - - # Find a matching task for +task_name+. - def [](task_name, scopes=nil) - task_name = task_name.to_s - self.lookup(task_name, scopes) or - enhance_with_matching_rule(task_name) or - synthesize_file_task(task_name) or - fail "Don't know how to build task '#{task_name}'" - end - - def synthesize_file_task(task_name) - return nil unless File.exist?(task_name) - define_task(Rake::FileTask, task_name) - end - - # Resolve the arguments for a task/rule. Returns a triplet of - # [task_name, arg_name_list, prerequisites]. - def resolve_args(args) - if args.last.is_a?(Hash) - deps = args.pop - resolve_args_with_dependencies(args, deps) - else - resolve_args_without_dependencies(args) - end - end - - # Resolve task arguments for a task or rule when there are no - # dependencies declared. - # - # The patterns recognized by this argument resolving function are: - # - # task :t - # task :t, [:a] - # task :t, :a (deprecated) - # - def resolve_args_without_dependencies(args) - task_name = args.shift - if args.size == 1 && args.first.respond_to?(:to_ary) - arg_names = args.first.to_ary - else - arg_names = args - end - [task_name, arg_names, []] - end - private :resolve_args_without_dependencies - - # Resolve task arguments for a task or rule when there are - # dependencies declared. - # - # The patterns recognized by this argument resolving function are: - # - # task :t => [:d] - # task :t, [a] => [:d] - # task :t, :needs => [:d] (deprecated) - # task :t, :a, :needs => [:d] (deprecated) - # - def resolve_args_with_dependencies(args, hash) # :nodoc: - fail "Task Argument Error" if hash.size != 1 - key, value = hash.map { |k, v| [k,v] }.first - if args.empty? - task_name = key - arg_names = [] - deps = value - elsif key == :needs - task_name = args.shift - arg_names = args - deps = value - else - task_name = args.shift - arg_names = key - deps = value - end - deps = [deps] unless deps.respond_to?(:to_ary) - [task_name, arg_names, deps] - end - private :resolve_args_with_dependencies - - # If a rule can be found that matches the task name, enhance the - # task with the prerequisites and actions from the rule. Set the - # source attribute of the task appropriately for the rule. Return - # the enhanced task or nil of no rule was found. - def enhance_with_matching_rule(task_name, level=0) - fail Rake::RuleRecursionOverflowError, - "Rule Recursion Too Deep" if level >= 16 - @rules.each do |pattern, extensions, block| - if md = pattern.match(task_name) - task = attempt_rule(task_name, extensions, block, level) - return task if task - end - end - nil - rescue Rake::RuleRecursionOverflowError => ex - ex.add_target(task_name) - fail ex - end - - # List of all defined tasks in this application. - def tasks - @tasks.values.sort_by { |t| t.name } - end - - # List of all the tasks defined in the given scope (and its - # sub-scopes). - def tasks_in_scope(scope) - prefix = scope.join(":") - tasks.select { |t| - /^#{prefix}:/ =~ t.name - } - end - - # Clear all tasks in this application. - def clear - @tasks.clear - @rules.clear - end - - # Lookup a task, using scope and the scope hints in the task name. - # This method performs straight lookups without trying to - # synthesize file tasks or rules. Special scope names (e.g. '^') - # are recognized. If no scope argument is supplied, use the - # current scope. Return nil if the task cannot be found. - def lookup(task_name, initial_scope=nil) - initial_scope ||= @scope - task_name = task_name.to_s - if task_name =~ /^rake:/ - scopes = [] - task_name = task_name.sub(/^rake:/, '') - elsif task_name =~ /^(\^+)/ - scopes = initial_scope[0, initial_scope.size - $1.size] - task_name = task_name.sub(/^(\^+)/, '') - else - scopes = initial_scope - end - lookup_in_scope(task_name, scopes) - end - - # Lookup the task name - def lookup_in_scope(name, scope) - n = scope.size - while n >= 0 - tn = (scope[0,n] + [name]).join(':') - task = @tasks[tn] - return task if task - n -= 1 - end - nil - end - private :lookup_in_scope - - # Return the list of scope names currently active in the task - # manager. - def current_scope - @scope.dup - end - - # Evaluate the block in a nested namespace named +name+. Create - # an anonymous namespace if +name+ is nil. - def in_namespace(name) - name ||= generate_name - @scope.push(name) - ns = NameSpace.new(self, @scope) - yield(ns) - ns - ensure - @scope.pop - end - - private - - # Generate an anonymous namespace name. - def generate_name - @seed ||= 0 - @seed += 1 - "_anon_#{@seed}" - end - - def trace_rule(level, message) - puts "#{" "*level}#{message}" if Rake.application.options.trace_rules - end - - # Attempt to create a rule given the list of prerequisites. - def attempt_rule(task_name, extensions, block, level) - sources = make_sources(task_name, extensions) - prereqs = sources.collect { |source| - trace_rule level, "Attempting Rule #{task_name} => #{source}" - if File.exist?(source) || Rake::Task.task_defined?(source) - trace_rule level, "(#{task_name} => #{source} ... EXIST)" - source - elsif parent = enhance_with_matching_rule(source, level+1) - trace_rule level, "(#{task_name} => #{source} ... ENHANCE)" - parent.name - else - trace_rule level, "(#{task_name} => #{source} ... FAIL)" - return nil - end - } - task = FileTask.define_task({task_name => prereqs}, &block) - task.sources = prereqs - task - end - - # Make a list of sources from the list of file name extensions / - # translation procs. - def make_sources(task_name, extensions) - extensions.collect { |ext| - case ext - when /%/ - task_name.pathmap(ext) - when %r{/} - ext - when /^\./ - task_name.ext(ext) - when String - ext - when Proc - if ext.arity == 1 - ext.call(task_name) - else - ext.call - end - else - fail "Don't know how to handle rule dependent: #{ext.inspect}" - end - }.flatten - end - - - private - - # Return the current description. If there isn't one, try to find it - # by reading in the source file and looking for a comment immediately - # prior to the task definition - def get_description - desc = @last_description || find_preceding_comment_for_task - @last_description = nil - desc - end - - def find_preceding_comment_for_task - stack = caller - begin - where = stack.shift - end until stack.empty? || where =~ /in `task'/ - return nil if stack.empty? - file_name, line = parse_stack_line(stack.shift) - return nil unless file_name - comment_from_file(file_name, line) - end - - def parse_stack_line(where) - if where =~ /^(.*):(\d+)/ - [ $1, Integer($2) ] - else - nil - end - end - - def comment_from_file(file_name, line) - @file_cache ||= {} - content = (@file_cache[file_name] ||= File.readlines(file_name)) - line -= 2 - return nil unless content[line] =~ /^\s*#\s*(.*)/ - $1 - end - end # TaskManager - - ###################################################################### - # Rake main application object. When invoking +rake+ from the - # command line, a Rake::Application object is created and run. - # - class Application - include TaskManager - - # The name of the application (typically 'rake') - attr_reader :name - - # The original directory where rake was invoked. - attr_reader :original_dir - - # Name of the actual rakefile used. - attr_reader :rakefile - - # List of the top level task names (task names from the command line). - attr_reader :top_level_tasks - - DEFAULT_RAKEFILES = ['rakefile', 'Rakefile', 'rakefile.rb', 'Rakefile.rb'].freeze - - # Initialize a Rake::Application object. - def initialize - super - @name = 'rake' - @rakefiles = DEFAULT_RAKEFILES.dup - @rakefile = nil - @pending_imports = [] - @imported = [] - @loaders = {} - @default_loader = Rake::DefaultLoader.new - @original_dir = Dir.pwd - @top_level_tasks = [] - add_loader('rb', DefaultLoader.new) - add_loader('rf', DefaultLoader.new) - add_loader('rake', DefaultLoader.new) - @tty_output = STDOUT.tty? - end - - # Run the Rake application. The run method performs the following three steps: - # - # * Initialize the command line options (+init+). - # * Define the tasks (+load_rakefile+). - # * Run the top level tasks (+run_tasks+). - # - # If you wish to build a custom rake command, you should call +init+ on your - # application. The define any tasks. Finally, call +top_level+ to run your top - # level tasks. - def run - standard_exception_handling do - init - load_rakefile - top_level - end - end - - # Initialize the command line parameters and app name. - def init(app_name='rake') - standard_exception_handling do - @name = app_name - handle_options - collect_tasks - end - end - - # Find the rakefile and then load it and any pending imports. - def load_rakefile - standard_exception_handling do - raw_load_rakefile - end - end - - # Run the top level tasks of a Rake application. - def top_level - standard_exception_handling do - if options.show_tasks - display_tasks_and_comments - elsif options.show_prereqs - display_prerequisites - else - top_level_tasks.each { |task_name| invoke_task(task_name) } - end - end - end - - # Add a loader to handle imported files ending in the extension - # +ext+. - def add_loader(ext, loader) - ext = ".#{ext}" unless ext =~ /^\./ - @loaders[ext] = loader - end - - # Application options from the command line - def options - @options ||= OpenStruct.new - end - - # private ---------------------------------------------------------------- - - def invoke_task(task_string) - name, args = parse_task_string(task_string) - t = self[name] - t.invoke(*args) - end - - def parse_task_string(string) - if string =~ /^([^\[]+)(\[(.*)\])$/ - name = $1 - args = $3.split(/\s*,\s*/) - else - name = string - args = [] - end - [name, args] - end - - # Provide standard execption handling for the given block. - def standard_exception_handling - begin - yield - rescue SystemExit => ex - # Exit silently with current status - raise - rescue OptionParser::InvalidOption => ex - # Exit silently - exit(false) - rescue Exception => ex - # Exit with error message - $stderr.puts "#{name} aborted!" - $stderr.puts ex.message - if options.trace - $stderr.puts ex.backtrace.join("\n") - else - $stderr.puts ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || "" - $stderr.puts "(See full trace by running task with --trace)" - end - exit(false) - end - end - - # True if one of the files in RAKEFILES is in the current directory. - # If a match is found, it is copied into @rakefile. - def have_rakefile - @rakefiles.each do |fn| - if File.exist?(fn) - others = Dir.glob(fn, File::FNM_CASEFOLD) - return others.size == 1 ? others.first : fn - elsif fn == '' - return fn - end - end - return nil - end - - # True if we are outputting to TTY, false otherwise - def tty_output? - @tty_output - end - - # Override the detected TTY output state (mostly for testing) - def tty_output=( tty_output_state ) - @tty_output = tty_output_state - end - - # We will truncate output if we are outputting to a TTY or if we've been - # given an explicit column width to honor - def truncate_output? - tty_output? || ENV['RAKE_COLUMNS'] - end - - # Display the tasks and comments. - def display_tasks_and_comments - displayable_tasks = tasks.select { |t| - t.comment && t.name =~ options.show_task_pattern - } - if options.full_description - displayable_tasks.each do |t| - puts "#{name} #{t.name_with_args}" - t.full_comment.split("\n").each do |line| - puts " #{line}" - end - puts - end - else - width = displayable_tasks.collect { |t| t.name_with_args.length }.max || 10 - max_column = truncate_output? ? terminal_width - name.size - width - 7 : nil - displayable_tasks.each do |t| - printf "#{name} %-#{width}s # %s\n", - t.name_with_args, max_column ? truncate(t.comment, max_column) : t.comment - end - end - end - - def terminal_width - if ENV['RAKE_COLUMNS'] - result = ENV['RAKE_COLUMNS'].to_i - else - result = unix? ? dynamic_width : 80 - end - (result < 10) ? 80 : result - rescue - 80 - end - - # Calculate the dynamic width of the - def dynamic_width - @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput) - end - - def dynamic_width_stty - %x{stty size 2>/dev/null}.split[1].to_i - end - - def dynamic_width_tput - %x{tput cols 2>/dev/null}.to_i - end - - def unix? - RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i - end - - def windows? - Win32.windows? - end - - def truncate(string, width) - if string.length <= width - string - else - ( string[0, width-3] || "" ) + "..." - end - end - - # Display the tasks and prerequisites - def display_prerequisites - tasks.each do |t| - puts "#{name} #{t.name}" - t.prerequisites.each { |pre| puts " #{pre}" } - end - end - - # A list of all the standard options used in rake, suitable for - # passing to OptionParser. - def standard_rake_options - [ - ['--classic-namespace', '-C', "Put Task and FileTask in the top level namespace", - lambda { |value| - require 'rake/classic_namespace' - options.classic_namespace = true - } - ], - ['--describe', '-D [PATTERN]', "Describe the tasks (matching optional PATTERN), then exit.", - lambda { |value| - options.show_tasks = true - options.full_description = true - options.show_task_pattern = Regexp.new(value || '') - } - ], - ['--dry-run', '-n', "Do a dry run without executing actions.", - lambda { |value| - verbose(true) - nowrite(true) - options.dryrun = true - options.trace = true - } - ], - ['--execute', '-e CODE', "Execute some Ruby code and exit.", - lambda { |value| - eval(value) - exit - } - ], - ['--execute-print', '-p CODE', "Execute some Ruby code, print the result, then exit.", - lambda { |value| - puts eval(value) - exit - } - ], - ['--execute-continue', '-E CODE', - "Execute some Ruby code, then continue with normal task processing.", - lambda { |value| eval(value) } - ], - ['--libdir', '-I LIBDIR', "Include LIBDIR in the search path for required modules.", - lambda { |value| $:.push(value) } - ], - ['--prereqs', '-P', "Display the tasks and dependencies, then exit.", - lambda { |value| options.show_prereqs = true } - ], - ['--quiet', '-q', "Do not log messages to standard output.", - lambda { |value| verbose(false) } - ], - ['--rakefile', '-f [FILE]', "Use FILE as the rakefile.", - lambda { |value| - value ||= '' - @rakefiles.clear - @rakefiles << value - } - ], - ['--rakelibdir', '--rakelib', '-R RAKELIBDIR', - "Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib')", - lambda { |value| options.rakelib = value.split(':') } - ], - ['--require', '-r MODULE', "Require MODULE before executing rakefile.", - lambda { |value| - begin - require value - rescue LoadError => ex - begin - rake_require value - rescue LoadError => ex2 - raise ex - end - end - } - ], - ['--rules', "Trace the rules resolution.", - lambda { |value| options.trace_rules = true } - ], - ['--no-search', '--nosearch', '-N', "Do not search parent directories for the Rakefile.", - lambda { |value| options.nosearch = true } - ], - ['--silent', '-s', "Like --quiet, but also suppresses the 'in directory' announcement.", - lambda { |value| - verbose(false) - options.silent = true - } - ], - ['--system', '-g', - "Using system wide (global) rakefiles (usually '~/.rake/*.rake').", - lambda { |value| options.load_system = true } - ], - ['--no-system', '--nosystem', '-G', - "Use standard project Rakefile search paths, ignore system wide rakefiles.", - lambda { |value| options.ignore_system = true } - ], - ['--tasks', '-T [PATTERN]', "Display the tasks (matching optional PATTERN) with descriptions, then exit.", - lambda { |value| - options.show_tasks = true - options.show_task_pattern = Regexp.new(value || '') - options.full_description = false - } - ], - ['--trace', '-t', "Turn on invoke/execute tracing, enable full backtrace.", - lambda { |value| - options.trace = true - verbose(true) - } - ], - ['--verbose', '-v', "Log message to standard output.", - lambda { |value| verbose(true) } - ], - ['--version', '-V', "Display the program version.", - lambda { |value| - puts "rake, version #{RAKEVERSION}" - exit - } - ] - ] - end - - # Read and handle the command line options. - def handle_options - options.rakelib = ['rakelib'] - - OptionParser.new do |opts| - opts.banner = "rake [-f rakefile] {options} targets..." - opts.separator "" - opts.separator "Options are ..." - - opts.on_tail("-h", "--help", "-H", "Display this help message.") do - puts opts - exit - end - - standard_rake_options.each { |args| opts.on(*args) } - end.parse! - - # If class namespaces are requested, set the global options - # according to the values in the options structure. - if options.classic_namespace - $show_tasks = options.show_tasks - $show_prereqs = options.show_prereqs - $trace = options.trace - $dryrun = options.dryrun - $silent = options.silent - end - end - - # Similar to the regular Ruby +require+ command, but will check - # for *.rake files in addition to *.rb files. - def rake_require(file_name, paths=$LOAD_PATH, loaded=$") - return false if loaded.include?(file_name) - paths.each do |path| - fn = file_name + ".rake" - full_path = File.join(path, fn) - if File.exist?(full_path) - load full_path - loaded << fn - return true - end - end - fail LoadError, "Can't find #{file_name}" - end - - def find_rakefile_location - here = Dir.pwd - while ! (fn = have_rakefile) - Dir.chdir("..") - if Dir.pwd == here || options.nosearch - return nil - end - here = Dir.pwd - end - [fn, here] - ensure - Dir.chdir(Rake.original_dir) - end - - def raw_load_rakefile # :nodoc: - rakefile, location = find_rakefile_location - if (! options.ignore_system) && - (options.load_system || rakefile.nil?) && - system_dir && File.directory?(system_dir) - puts "(in #{Dir.pwd})" unless options.silent - glob("#{system_dir}/*.rake") do |name| - add_import name - end - else - fail "No Rakefile found (looking for: #{@rakefiles.join(', ')})" if - rakefile.nil? - @rakefile = rakefile - Dir.chdir(location) - puts "(in #{Dir.pwd})" unless options.silent - $rakefile = @rakefile if options.classic_namespace - load File.expand_path(@rakefile) if @rakefile && @rakefile != '' - options.rakelib.each do |rlib| - glob("#{rlib}/*.rake") do |name| - add_import name - end - end - end - load_imports - end - - def glob(path, &block) - Dir[path.gsub("\\", '/')].each(&block) - end - private :glob - - # The directory path containing the system wide rakefiles. - def system_dir - @system_dir ||= - begin - if ENV['RAKE_SYSTEM'] - ENV['RAKE_SYSTEM'] - else - standard_system_dir - end - end - end - - # The standard directory containing system wide rake files. - if Win32.windows? - def standard_system_dir #:nodoc: - Win32.win32_system_dir - end - else - def standard_system_dir #:nodoc: - File.join(File.expand_path('~'), '.rake') - end - end - private :standard_system_dir - - # Collect the list of tasks on the command line. If no tasks are - # given, return a list containing only the default task. - # Environmental assignments are processed at this time as well. - def collect_tasks - @top_level_tasks = [] - ARGV.each do |arg| - if arg =~ /^(\w+)=(.*)$/ - ENV[$1] = $2 - else - @top_level_tasks << arg unless arg =~ /^-/ - end - end - @top_level_tasks.push("default") if @top_level_tasks.size == 0 - end - - # Add a file to the list of files to be imported. - def add_import(fn) - @pending_imports << fn - end - - # Load the pending list of imported files. - def load_imports - while fn = @pending_imports.shift - next if @imported.member?(fn) - if fn_task = lookup(fn) - fn_task.invoke - end - ext = File.extname(fn) - loader = @loaders[ext] || @default_loader - loader.load(fn) - @imported << fn - end - end - - # Warn about deprecated use of top level constant names. - def const_warning(const_name) - @const_warning ||= false - if ! @const_warning - $stderr.puts %{WARNING: Deprecated reference to top-level constant '#{const_name}' } + - %{found at: #{rakefile_location}} # ' - $stderr.puts %{ Use --classic-namespace on rake command} - $stderr.puts %{ or 'require "rake/classic_namespace"' in Rakefile} - end - @const_warning = true - end - - def rakefile_location - begin - fail - rescue RuntimeError => ex - ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || "" - end - end - end -end - - -class Module - # Rename the original handler to make it available. - alias :rake_original_const_missing :const_missing - - # Check for deprecated uses of top level (i.e. in Object) uses of - # Rake class names. If someone tries to reference the constant - # name, display a warning and return the proper object. Using the - # --classic-namespace command line option will define these - # constants in Object and avoid this handler. - def const_missing(const_name) - case const_name - when :Task - Rake.application.const_warning(const_name) - Rake::Task - when :FileTask - Rake.application.const_warning(const_name) - Rake::FileTask - when :FileCreationTask - Rake.application.const_warning(const_name) - Rake::FileCreationTask - when :RakeApp - Rake.application.const_warning(const_name) - Rake::Application - else - rake_original_const_missing(const_name) - end - end -end diff --git a/lib/rake/application.rb b/lib/rake/application.rb new file mode 100644 index 000000000..aba993af7 --- /dev/null +++ b/lib/rake/application.rb @@ -0,0 +1,532 @@ +require 'rake/task_manager' + +module Rake + + ###################################################################### + # Rake main application object. When invoking +rake+ from the + # command line, a Rake::Application object is created and run. + # + class Application + include TaskManager + + # The name of the application (typically 'rake') + attr_reader :name + + # The original directory where rake was invoked. + attr_reader :original_dir + + # Name of the actual rakefile used. + attr_reader :rakefile + + # List of the top level task names (task names from the command line). + attr_reader :top_level_tasks + + DEFAULT_RAKEFILES = ['rakefile', 'Rakefile', 'rakefile.rb', 'Rakefile.rb'].freeze + + # Initialize a Rake::Application object. + def initialize + super + @name = 'rake' + @rakefiles = DEFAULT_RAKEFILES.dup + @rakefile = nil + @pending_imports = [] + @imported = [] + @loaders = {} + @default_loader = Rake::DefaultLoader.new + @original_dir = Dir.pwd + @top_level_tasks = [] + add_loader('rb', DefaultLoader.new) + add_loader('rf', DefaultLoader.new) + add_loader('rake', DefaultLoader.new) + @tty_output = STDOUT.tty? + end + + # Run the Rake application. The run method performs the following three steps: + # + # * Initialize the command line options (+init+). + # * Define the tasks (+load_rakefile+). + # * Run the top level tasks (+run_tasks+). + # + # If you wish to build a custom rake command, you should call +init+ on your + # application. The define any tasks. Finally, call +top_level+ to run your top + # level tasks. + def run + standard_exception_handling do + init + load_rakefile + top_level + end + end + + # Initialize the command line parameters and app name. + def init(app_name='rake') + standard_exception_handling do + @name = app_name + handle_options + collect_tasks + end + end + + # Find the rakefile and then load it and any pending imports. + def load_rakefile + standard_exception_handling do + raw_load_rakefile + end + end + + # Run the top level tasks of a Rake application. + def top_level + standard_exception_handling do + if options.show_tasks + display_tasks_and_comments + elsif options.show_prereqs + display_prerequisites + else + top_level_tasks.each { |task_name| invoke_task(task_name) } + end + end + end + + # Add a loader to handle imported files ending in the extension + # +ext+. + def add_loader(ext, loader) + ext = ".#{ext}" unless ext =~ /^\./ + @loaders[ext] = loader + end + + # Application options from the command line + def options + @options ||= OpenStruct.new + end + + # private ---------------------------------------------------------------- + + def invoke_task(task_string) + name, args = parse_task_string(task_string) + t = self[name] + t.invoke(*args) + end + + def parse_task_string(string) + if string =~ /^([^\[]+)(\[(.*)\])$/ + name = $1 + args = $3.split(/\s*,\s*/) + else + name = string + args = [] + end + [name, args] + end + + # Provide standard execption handling for the given block. + def standard_exception_handling + begin + yield + rescue SystemExit => ex + # Exit silently with current status + raise + rescue OptionParser::InvalidOption => ex + # Exit silently + exit(false) + rescue Exception => ex + # Exit with error message + $stderr.puts "#{name} aborted!" + $stderr.puts ex.message + if options.trace + $stderr.puts ex.backtrace.join("\n") + else + $stderr.puts ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || "" + $stderr.puts "(See full trace by running task with --trace)" + end + exit(false) + end + end + + # True if one of the files in RAKEFILES is in the current directory. + # If a match is found, it is copied into @rakefile. + def have_rakefile + @rakefiles.each do |fn| + if File.exist?(fn) + others = Dir.glob(fn, File::FNM_CASEFOLD) + return others.size == 1 ? others.first : fn + elsif fn == '' + return fn + end + end + return nil + end + + # True if we are outputting to TTY, false otherwise + def tty_output? + @tty_output + end + + # Override the detected TTY output state (mostly for testing) + def tty_output=( tty_output_state ) + @tty_output = tty_output_state + end + + # We will truncate output if we are outputting to a TTY or if we've been + # given an explicit column width to honor + def truncate_output? + tty_output? || ENV['RAKE_COLUMNS'] + end + + # Display the tasks and comments. + def display_tasks_and_comments + displayable_tasks = tasks.select { |t| + t.comment && t.name =~ options.show_task_pattern + } + if options.full_description + displayable_tasks.each do |t| + puts "#{name} #{t.name_with_args}" + t.full_comment.split("\n").each do |line| + puts " #{line}" + end + puts + end + else + width = displayable_tasks.collect { |t| t.name_with_args.length }.max || 10 + max_column = truncate_output? ? terminal_width - name.size - width - 7 : nil + displayable_tasks.each do |t| + printf "#{name} %-#{width}s # %s\n", + t.name_with_args, max_column ? truncate(t.comment, max_column) : t.comment + end + end + end + + def terminal_width + if ENV['RAKE_COLUMNS'] + result = ENV['RAKE_COLUMNS'].to_i + else + result = unix? ? dynamic_width : 80 + end + (result < 10) ? 80 : result + rescue + 80 + end + + # Calculate the dynamic width of the + def dynamic_width + @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput) + end + + def dynamic_width_stty + %x{stty size 2>/dev/null}.split[1].to_i + end + + def dynamic_width_tput + %x{tput cols 2>/dev/null}.to_i + end + + def unix? + RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i + end + + def windows? + Win32.windows? + end + + def truncate(string, width) + if string.length <= width + string + else + ( string[0, width-3] || "" ) + "..." + end + end + + # Display the tasks and prerequisites + def display_prerequisites + tasks.each do |t| + puts "#{name} #{t.name}" + t.prerequisites.each { |pre| puts " #{pre}" } + end + end + + # A list of all the standard options used in rake, suitable for + # passing to OptionParser. + def standard_rake_options + [ + ['--classic-namespace', '-C', "Put Task and FileTask in the top level namespace", + lambda { |value| + require 'rake/classic_namespace' + options.classic_namespace = true + } + ], + ['--describe', '-D [PATTERN]', "Describe the tasks (matching optional PATTERN), then exit.", + lambda { |value| + options.show_tasks = true + options.full_description = true + options.show_task_pattern = Regexp.new(value || '') + } + ], + ['--dry-run', '-n', "Do a dry run without executing actions.", + lambda { |value| + verbose(true) + nowrite(true) + options.dryrun = true + options.trace = true + } + ], + ['--execute', '-e CODE', "Execute some Ruby code and exit.", + lambda { |value| + eval(value) + exit + } + ], + ['--execute-print', '-p CODE', "Execute some Ruby code, print the result, then exit.", + lambda { |value| + puts eval(value) + exit + } + ], + ['--execute-continue', '-E CODE', + "Execute some Ruby code, then continue with normal task processing.", + lambda { |value| eval(value) } + ], + ['--libdir', '-I LIBDIR', "Include LIBDIR in the search path for required modules.", + lambda { |value| $:.push(value) } + ], + ['--prereqs', '-P', "Display the tasks and dependencies, then exit.", + lambda { |value| options.show_prereqs = true } + ], + ['--quiet', '-q', "Do not log messages to standard output.", + lambda { |value| verbose(false) } + ], + ['--rakefile', '-f [FILE]', "Use FILE as the rakefile.", + lambda { |value| + value ||= '' + @rakefiles.clear + @rakefiles << value + } + ], + ['--rakelibdir', '--rakelib', '-R RAKELIBDIR', + "Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib')", + lambda { |value| options.rakelib = value.split(':') } + ], + ['--require', '-r MODULE', "Require MODULE before executing rakefile.", + lambda { |value| + begin + require value + rescue LoadError => ex + begin + rake_require value + rescue LoadError => ex2 + raise ex + end + end + } + ], + ['--rules', "Trace the rules resolution.", + lambda { |value| options.trace_rules = true } + ], + ['--no-search', '--nosearch', '-N', "Do not search parent directories for the Rakefile.", + lambda { |value| options.nosearch = true } + ], + ['--silent', '-s', "Like --quiet, but also suppresses the 'in directory' announcement.", + lambda { |value| + verbose(false) + options.silent = true + } + ], + ['--system', '-g', + "Using system wide (global) rakefiles (usually '~/.rake/*.rake').", + lambda { |value| options.load_system = true } + ], + ['--no-system', '--nosystem', '-G', + "Use standard project Rakefile search paths, ignore system wide rakefiles.", + lambda { |value| options.ignore_system = true } + ], + ['--tasks', '-T [PATTERN]', "Display the tasks (matching optional PATTERN) with descriptions, then exit.", + lambda { |value| + options.show_tasks = true + options.show_task_pattern = Regexp.new(value || '') + options.full_description = false + } + ], + ['--trace', '-t', "Turn on invoke/execute tracing, enable full backtrace.", + lambda { |value| + options.trace = true + verbose(true) + } + ], + ['--verbose', '-v', "Log message to standard output.", + lambda { |value| verbose(true) } + ], + ['--version', '-V', "Display the program version.", + lambda { |value| + puts "rake, version #{RAKEVERSION}" + exit + } + ] + ] + end + + # Read and handle the command line options. + def handle_options + options.rakelib = ['rakelib'] + + OptionParser.new do |opts| + opts.banner = "rake [-f rakefile] {options} targets..." + opts.separator "" + opts.separator "Options are ..." + + opts.on_tail("-h", "--help", "-H", "Display this help message.") do + puts opts + exit + end + + standard_rake_options.each { |args| opts.on(*args) } + end.parse! + + # If class namespaces are requested, set the global options + # according to the values in the options structure. + if options.classic_namespace + $show_tasks = options.show_tasks + $show_prereqs = options.show_prereqs + $trace = options.trace + $dryrun = options.dryrun + $silent = options.silent + end + end + + # Similar to the regular Ruby +require+ command, but will check + # for *.rake files in addition to *.rb files. + def rake_require(file_name, paths=$LOAD_PATH, loaded=$") + return false if loaded.include?(file_name) + paths.each do |path| + fn = file_name + ".rake" + full_path = File.join(path, fn) + if File.exist?(full_path) + load full_path + loaded << fn + return true + end + end + fail LoadError, "Can't find #{file_name}" + end + + def find_rakefile_location + here = Dir.pwd + while ! (fn = have_rakefile) + Dir.chdir("..") + if Dir.pwd == here || options.nosearch + return nil + end + here = Dir.pwd + end + [fn, here] + ensure + Dir.chdir(Rake.original_dir) + end + + def raw_load_rakefile # :nodoc: + rakefile, location = find_rakefile_location + if (! options.ignore_system) && + (options.load_system || rakefile.nil?) && + system_dir && File.directory?(system_dir) + puts "(in #{Dir.pwd})" unless options.silent + glob("#{system_dir}/*.rake") do |name| + add_import name + end + else + fail "No Rakefile found (looking for: #{@rakefiles.join(', ')})" if + rakefile.nil? + @rakefile = rakefile + Dir.chdir(location) + puts "(in #{Dir.pwd})" unless options.silent + $rakefile = @rakefile if options.classic_namespace + load File.expand_path(@rakefile) if @rakefile && @rakefile != '' + options.rakelib.each do |rlib| + glob("#{rlib}/*.rake") do |name| + add_import name + end + end + end + load_imports + end + + def glob(path, &block) + Dir[path.gsub("\\", '/')].each(&block) + end + private :glob + + # The directory path containing the system wide rakefiles. + def system_dir + @system_dir ||= + begin + if ENV['RAKE_SYSTEM'] + ENV['RAKE_SYSTEM'] + else + standard_system_dir + end + end + end + + # The standard directory containing system wide rake files. + if Win32.windows? + def standard_system_dir #:nodoc: + Win32.win32_system_dir + end + else + def standard_system_dir #:nodoc: + File.join(File.expand_path('~'), '.rake') + end + end + private :standard_system_dir + + # Collect the list of tasks on the command line. If no tasks are + # given, return a list containing only the default task. + # Environmental assignments are processed at this time as well. + def collect_tasks + @top_level_tasks = [] + ARGV.each do |arg| + if arg =~ /^(\w+)=(.*)$/ + ENV[$1] = $2 + else + @top_level_tasks << arg unless arg =~ /^-/ + end + end + @top_level_tasks.push("default") if @top_level_tasks.size == 0 + end + + # Add a file to the list of files to be imported. + def add_import(fn) + @pending_imports << fn + end + + # Load the pending list of imported files. + def load_imports + while fn = @pending_imports.shift + next if @imported.member?(fn) + if fn_task = lookup(fn) + fn_task.invoke + end + ext = File.extname(fn) + loader = @loaders[ext] || @default_loader + loader.load(fn) + @imported << fn + end + end + + # Warn about deprecated use of top level constant names. + def const_warning(const_name) + @const_warning ||= false + if ! @const_warning + $stderr.puts %{WARNING: Deprecated reference to top-level constant '#{const_name}' } + + %{found at: #{rakefile_location}} # ' + $stderr.puts %{ Use --classic-namespace on rake command} + $stderr.puts %{ or 'require "rake/classic_namespace"' in Rakefile} + end + @const_warning = true + end + + def rakefile_location + begin + fail + rescue RuntimeError => ex + ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || "" + end + end + end +end diff --git a/lib/rake/default_loader.rb b/lib/rake/default_loader.rb new file mode 100644 index 000000000..919e321d4 --- /dev/null +++ b/lib/rake/default_loader.rb @@ -0,0 +1,10 @@ +module Rake + + # Default Rakefile loader used by +import+. + class DefaultLoader + def load(fn) + Kernel.load(File.expand_path(fn)) + end + end + +end diff --git a/lib/rake/dsl.rb b/lib/rake/dsl.rb new file mode 100644 index 000000000..59604c94c --- /dev/null +++ b/lib/rake/dsl.rb @@ -0,0 +1,117 @@ +# Rake DSL functions. + +# Declare a basic task. +# +# Example: +# task :clobber => [:clean] do +# rm_rf "html" +# end +# +def task(*args, &block) + Rake::Task.define_task(*args, &block) +end + + +# Declare a file task. +# +# Example: +# file "config.cfg" => ["config.template"] do +# open("config.cfg", "w") do |outfile| +# open("config.template") do |infile| +# while line = infile.gets +# outfile.puts line +# end +# end +# end +# end +# +def file(*args, &block) + Rake::FileTask.define_task(*args, &block) +end + +# Declare a file creation task. +# (Mainly used for the directory command). +def file_create(args, &block) + Rake::FileCreationTask.define_task(args, &block) +end + +# Declare a set of files tasks to create the given directories on demand. +# +# Example: +# directory "testdata/doc" +# +def directory(dir) + Rake.each_dir_parent(dir) do |d| + file_create d do |t| + mkdir_p t.name if ! File.exist?(t.name) + end + end +end + +# Declare a task that performs its prerequisites in parallel. Multitasks does +# *not* guarantee that its prerequisites will execute in any given order +# (which is obvious when you think about it) +# +# Example: +# multitask :deploy => [:deploy_gem, :deploy_rdoc] +# +def multitask(args, &block) + Rake::MultiTask.define_task(args, &block) +end + +# Create a new rake namespace and use it for evaluating the given block. +# Returns a NameSpace object that can be used to lookup tasks defined in the +# namespace. +# +# E.g. +# +# ns = namespace "nested" do +# task :run +# end +# task_run = ns[:run] # find :run in the given namespace. +# +def namespace(name=nil, &block) + Rake.application.in_namespace(name, &block) +end + +# Declare a rule for auto-tasks. +# +# Example: +# rule '.o' => '.c' do |t| +# sh %{cc -o #{t.name} #{t.source}} +# end +# +def rule(*args, &block) + Rake::Task.create_rule(*args, &block) +end + +# Describe the next rake task. +# +# Example: +# desc "Run the Unit Tests" +# task :test => [:build] +# runtests +# end +# +def desc(description) + Rake.application.last_description = description +end + +# Import the partial Rakefiles +fn+. Imported files are loaded _after_ the +# current file is completely loaded. This allows the import statement to +# appear anywhere in the importing file, and yet allowing the imported files +# to depend on objects defined in the importing file. +# +# A common use of the import statement is to include files containing +# dependency declarations. +# +# See also the --rakelibdir command line option. +# +# Example: +# import ".depend", "my_rules" +# +def import(*fns) + fns.each do |fn| + Rake.application.add_import(fn) + end +end diff --git a/lib/rake/early_time.rb b/lib/rake/early_time.rb new file mode 100644 index 000000000..8c0e7d333 --- /dev/null +++ b/lib/rake/early_time.rb @@ -0,0 +1,18 @@ +module Rake + + # EarlyTime is a fake timestamp that occurs _before_ any other time value. + class EarlyTime + include Comparable + include Singleton + + def <=>(other) + -1 + end + + def to_s + "" + end + end + + EARLY = EarlyTime.instance +end diff --git a/lib/rake/ext/module.rb b/lib/rake/ext/module.rb new file mode 100644 index 000000000..4d9a9ab9d --- /dev/null +++ b/lib/rake/ext/module.rb @@ -0,0 +1,54 @@ +###################################################################### +# Rake extensions to Module. +# +class Module + # Check for an existing method in the current class before extending. IF + # the method already exists, then a warning is printed and the extension is + # not added. Otherwise the block is yielded and any definitions in the + # block will take effect. + # + # Usage: + # + # class String + # rake_extension("xyz") do + # def xyz + # ... + # end + # end + # end + # + def rake_extension(method) + if method_defined?(method) + $stderr.puts "WARNING: Possible conflict with Rake extension: #{self}##{method} already exists" + else + yield + end + end + + # Rename the original handler to make it available. + alias :rake_original_const_missing :const_missing + + # Check for deprecated uses of top level (i.e. in Object) uses of + # Rake class names. If someone tries to reference the constant + # name, display a warning and return the proper object. Using the + # --classic-namespace command line option will define these + # constants in Object and avoid this handler. + def const_missing(const_name) + case const_name + when :Task + Rake.application.const_warning(const_name) + Rake::Task + when :FileTask + Rake.application.const_warning(const_name) + Rake::FileTask + when :FileCreationTask + Rake.application.const_warning(const_name) + Rake::FileCreationTask + when :RakeApp + Rake.application.const_warning(const_name) + Rake::Application + else + rake_original_const_missing(const_name) + end + end +end diff --git a/lib/rake/ext/string.rb b/lib/rake/ext/string.rb new file mode 100644 index 000000000..293b7950e --- /dev/null +++ b/lib/rake/ext/string.rb @@ -0,0 +1,165 @@ +###################################################################### +# Rake extension methods for String. +# +class String + rake_extension("ext") do + # Replace the file extension with +newext+. If there is no extension on + # the string, append the new extension to the end. If the new extension + # is not given, or is the empty string, remove any existing extension. + # + # +ext+ is a user added method for the String class. + def ext(newext='') + return self.dup if ['.', '..'].include? self + if newext != '' + newext = (newext =~ /^\./) ? newext : ("." + newext) + end + self.chomp(File.extname(self)) << newext + end + end + + rake_extension("pathmap") do + # Explode a path into individual components. Used by +pathmap+. + def pathmap_explode + head, tail = File.split(self) + return [self] if head == self + return [tail] if head == '.' || tail == '/' + return [head, tail] if head == '/' + return head.pathmap_explode + [tail] + end + protected :pathmap_explode + + # Extract a partial path from the path. Include +n+ directories from the + # front end (left hand side) if +n+ is positive. Include |+n+| + # directories from the back end (right hand side) if +n+ is negative. + def pathmap_partial(n) + dirs = File.dirname(self).pathmap_explode + partial_dirs = + if n > 0 + dirs[0...n] + elsif n < 0 + dirs.reverse[0...-n].reverse + else + "." + end + File.join(partial_dirs) + end + protected :pathmap_partial + + # Preform the pathmap replacement operations on the given path. The + # patterns take the form 'pat1,rep1;pat2,rep2...'. + def pathmap_replace(patterns, &block) + result = self + patterns.split(';').each do |pair| + pattern, replacement = pair.split(',') + pattern = Regexp.new(pattern) + if replacement == '*' && block_given? + result = result.sub(pattern, &block) + elsif replacement + result = result.sub(pattern, replacement) + else + result = result.sub(pattern, '') + end + end + result + end + protected :pathmap_replace + + # Map the path according to the given specification. The specification + # controls the details of the mapping. The following special patterns are + # recognized: + # + # * %p -- The complete path. + # * %f -- The base file name of the path, with its file extension, + # but without any directories. + # * %n -- The file name of the path without its file extension. + # * %d -- The directory list of the path. + # * %x -- The file extension of the path. An empty string if there + # is no extension. + # * %X -- Everything *but* the file extension. + # * %s -- The alternate file separater if defined, otherwise use + # the standard file separator. + # * %% -- A percent sign. + # + # The %d specifier can also have a numeric prefix (e.g. '%2d'). If the + # number is positive, only return (up to) +n+ directories in the path, + # starting from the left hand side. If +n+ is negative, return (up to) + # |+n+| directories from the right hand side of the path. + # + # Examples: + # + # 'a/b/c/d/file.txt'.pathmap("%2d") => 'a/b' + # 'a/b/c/d/file.txt'.pathmap("%-2d") => 'c/d' + # + # Also the %d, %p, %f, %n, %x, and %X operators can take a + # pattern/replacement argument to perform simple string substititions on a + # particular part of the path. The pattern and replacement are speparated + # by a comma and are enclosed by curly braces. The replacement spec comes + # after the % character but before the operator letter. (e.g. + # "%{old,new}d"). Muliple replacement specs should be separated by + # semi-colons (e.g. "%{old,new;src,bin}d"). + # + # Regular expressions may be used for the pattern, and back refs may be + # used in the replacement text. Curly braces, commas and semi-colons are + # excluded from both the pattern and replacement text (let's keep parsing + # reasonable). + # + # For example: + # + # "src/org/onestepback/proj/A.java".pathmap("%{^src,bin}X.class") + # + # returns: + # + # "bin/org/onestepback/proj/A.class" + # + # If the replacement text is '*', then a block may be provided to perform + # some arbitrary calculation for the replacement. + # + # For example: + # + # "/path/to/file.TXT".pathmap("%X%{.*,*}x") { |ext| + # ext.downcase + # } + # + # Returns: + # + # "/path/to/file.txt" + # + def pathmap(spec=nil, &block) + return self if spec.nil? + result = '' + spec.scan(/%\{[^}]*\}-?\d*[sdpfnxX%]|%-?\d+d|%.|[^%]+/) do |frag| + case frag + when '%f' + result << File.basename(self) + when '%n' + result << File.basename(self).ext + when '%d' + result << File.dirname(self) + when '%x' + result << File.extname(self) + when '%X' + result << self.ext + when '%p' + result << self + when '%s' + result << (File::ALT_SEPARATOR || File::SEPARATOR) + when '%-' + # do nothing + when '%%' + result << "%" + when /%(-?\d+)d/ + result << pathmap_partial($1.to_i) + when /^%\{([^}]*)\}(\d*[dpfnxX])/ + patterns, operator = $1, $2 + result << pathmap('%' + operator).pathmap_replace(patterns, &block) + when /^%/ + fail ArgumentError, "Unknown pathmap specifier #{frag} in '#{spec}'" + else + result << frag + end + end + result + end + end +end # class String + diff --git a/lib/rake/ext/time.rb b/lib/rake/ext/time.rb new file mode 100644 index 000000000..ca3ea2a79 --- /dev/null +++ b/lib/rake/ext/time.rb @@ -0,0 +1,14 @@ +# ########################################################################### +# Extensions to time to allow comparisons with an early time class. +# +class Time + alias rake_original_time_compare :<=> + def <=>(other) + if Rake::EarlyTime === other + - other.<=>(self) + else + rake_original_time_compare(other) + end + end +end # class Time + diff --git a/lib/rake/file_creation_task.rb b/lib/rake/file_creation_task.rb new file mode 100644 index 000000000..c87e2192b --- /dev/null +++ b/lib/rake/file_creation_task.rb @@ -0,0 +1,24 @@ +require 'rake/file_task' +require 'rake/early_time' + +module Rake + + # A FileCreationTask is a file task that when used as a dependency will be + # needed if and only if the file has not been created. Once created, it is + # not re-triggered if any of its dependencies are newer, nor does trigger + # any rebuilds of tasks that depend on it whenever it is updated. + # + class FileCreationTask < FileTask + # Is this file task needed? Yes if it doesn't exist. + def needed? + ! File.exist?(name) + end + + # Time stamp for file creation task. This time stamp is earlier + # than any other time stamp. + def timestamp + Rake::EARLY + end + end + +end diff --git a/lib/rake/file_task.rb b/lib/rake/file_task.rb new file mode 100644 index 000000000..60e9b0783 --- /dev/null +++ b/lib/rake/file_task.rb @@ -0,0 +1,47 @@ +require 'rake/task.rb' +require 'rake/early_time' + +module Rake + # ######################################################################### + # A FileTask is a task that includes time based dependencies. If any of a + # FileTask's prerequisites have a timestamp that is later than the file + # represented by this task, then the file must be rebuilt (using the + # supplied actions). + # + class FileTask < Task + + # Is this file task needed? Yes if it doesn't exist, or if its time stamp + # is out of date. + def needed? + ! File.exist?(name) || out_of_date?(timestamp) + end + + # Time stamp for file task. + def timestamp + if File.exist?(name) + File.mtime(name.to_s) + else + Rake::EARLY + end + end + + private + + # Are there any prerequisites with a later time than the given time stamp? + def out_of_date?(stamp) + @prerequisites.any? { |n| application[n].timestamp > stamp} + end + + # ---------------------------------------------------------------- + # Task class methods. + # + class << self + # Apply the scope to the task name according to the rules for this kind + # of task. File based tasks ignore the scope when creating the name. + def scope_name(scope, task_name) + task_name + end + end + end +end + diff --git a/lib/rake/invocation_chain.rb b/lib/rake/invocation_chain.rb new file mode 100644 index 000000000..a2c858589 --- /dev/null +++ b/lib/rake/invocation_chain.rb @@ -0,0 +1,51 @@ +module Rake + + #################################################################### + # InvocationChain tracks the chain of task invocations to detect + # circular dependencies. + class InvocationChain + def initialize(value, tail) + @value = value + @tail = tail + end + + def member?(obj) + @value == obj || @tail.member?(obj) + end + + def append(value) + if member?(value) + fail RuntimeError, "Circular dependency detected: #{to_s} => #{value}" + end + self.class.new(value, self) + end + + def to_s + "#{prefix}#{@value}" + end + + def self.append(value, chain) + chain.append(value) + end + + private + + def prefix + "#{@tail.to_s} => " + end + + class EmptyInvocationChain + def member?(obj) + false + end + def append(value) + InvocationChain.new(value, self) + end + def to_s + "TOP" + end + end + + EMPTY = EmptyInvocationChain.new + end +end diff --git a/lib/rake/multi_task.rb b/lib/rake/multi_task.rb new file mode 100644 index 000000000..176264945 --- /dev/null +++ b/lib/rake/multi_task.rb @@ -0,0 +1,16 @@ +module Rake + + # Same as a regular task, but the immediate prerequisites are done in + # parallel using Ruby threads. + # + class MultiTask < Task + private + def invoke_prerequisites(args, invocation_chain) + threads = @prerequisites.collect { |p| + Thread.new(p) { |r| application[r].invoke_with_call_chain(args, invocation_chain) } + } + threads.each { |t| t.join } + end + end + +end diff --git a/lib/rake/name_space.rb b/lib/rake/name_space.rb new file mode 100644 index 000000000..073285468 --- /dev/null +++ b/lib/rake/name_space.rb @@ -0,0 +1,25 @@ +module Rake + + # The NameSpace class will lookup task names in the the scope + # defined by a +namespace+ command. + # + class NameSpace + + # Create a namespace lookup object using the given task manager + # and the list of scopes. + def initialize(task_manager, scope_list) + @task_manager = task_manager + @scope = scope_list.dup + end + + # Lookup a task named +name+ in the namespace. + def [](name) + @task_manager.lookup(name, @scope) + end + + # Return the list of tasks defined in this and nested namespaces. + def tasks + @task_manager.tasks_in_scope(@scope) + end + end +end diff --git a/lib/rake/psuedo_status.rb b/lib/rake/psuedo_status.rb new file mode 100644 index 000000000..8ce050309 --- /dev/null +++ b/lib/rake/psuedo_status.rb @@ -0,0 +1,24 @@ +module Rake + + #################################################################### + # Exit status class for times the system just gives us a nil. + class PseudoStatus + attr_reader :exitstatus + def initialize(code=0) + @exitstatus = code + end + def to_i + @exitstatus << 8 + end + def >>(n) + to_i >> n + end + def stopped? + false + end + def exited? + true + end + end + +end diff --git a/lib/rake/rake_module.rb b/lib/rake/rake_module.rb new file mode 100644 index 000000000..b606a7b6e --- /dev/null +++ b/lib/rake/rake_module.rb @@ -0,0 +1,23 @@ +module Rake + + # Rake module singleton methods. + # + class << self + # Current Rake Application + def application + @application ||= Rake::Application.new + end + + # Set the current Rake application object. + def application=(app) + @application = app + end + + # Return the original directory where the Rake application was started. + def original_dir + application.original_dir + end + + end + +end diff --git a/lib/rake/rule_recursion_overflow_error.rb b/lib/rake/rule_recursion_overflow_error.rb new file mode 100644 index 000000000..da4318da9 --- /dev/null +++ b/lib/rake/rule_recursion_overflow_error.rb @@ -0,0 +1,20 @@ + +module Rake + + # Error indicating a recursion overflow error in task selection. + class RuleRecursionOverflowError < StandardError + def initialize(*args) + super + @targets = [] + end + + def add_target(target) + @targets << target + end + + def message + super + ": [" + @targets.reverse.join(' => ') + "]" + end + end + +end diff --git a/lib/rake/task.rb b/lib/rake/task.rb new file mode 100644 index 000000000..975421362 --- /dev/null +++ b/lib/rake/task.rb @@ -0,0 +1,301 @@ +module Rake + + # ######################################################################### + # A Task is the basic unit of work in a Rakefile. Tasks have associated + # actions (possibly more than one) and a list of prerequisites. When + # invoked, a task will first ensure that all of its prerequisites have an + # opportunity to run and then it will execute its own actions. + # + # Tasks are not usually created directly using the new method, but rather + # use the +file+ and +task+ convenience methods. + # + class Task + # List of prerequisites for a task. + attr_reader :prerequisites + + # List of actions attached to a task. + attr_reader :actions + + # Application owning this task. + attr_accessor :application + + # Comment for this task. Restricted to a single line of no more than 50 + # characters. + attr_reader :comment + + # Full text of the (possibly multi-line) comment. + attr_reader :full_comment + + # Array of nested namespaces names used for task lookup by this task. + attr_reader :scope + + # Return task name + def to_s + name + end + + def inspect + "<#{self.class} #{name} => [#{prerequisites.join(', ')}]>" + end + + # List of sources for task. + attr_writer :sources + def sources + @sources ||= [] + end + + # First source from a rule (nil if no sources) + def source + @sources.first if defined?(@sources) + end + + # Create a task named +task_name+ with no actions or prerequisites. Use + # +enhance+ to add actions and prerequisites. + def initialize(task_name, app) + @name = task_name.to_s + @prerequisites = [] + @actions = [] + @already_invoked = false + @full_comment = nil + @comment = nil + @lock = Monitor.new + @application = app + @scope = app.current_scope + @arg_names = nil + end + + # Enhance a task with prerequisites or actions. Returns self. + def enhance(deps=nil, &block) + @prerequisites |= deps if deps + @actions << block if block_given? + self + end + + # Name of the task, including any namespace qualifiers. + def name + @name.to_s + end + + # Name of task with argument list description. + def name_with_args # :nodoc: + if arg_description + "#{name}#{arg_description}" + else + name + end + end + + # Argument description (nil if none). + def arg_description # :nodoc: + @arg_names ? "[#{(arg_names || []).join(',')}]" : nil + end + + # Name of arguments for this task. + def arg_names + @arg_names || [] + end + + # Reenable the task, allowing its tasks to be executed if the task + # is invoked again. + def reenable + @already_invoked = false + end + + # Clear the existing prerequisites and actions of a rake task. + def clear + clear_prerequisites + clear_actions + self + end + + # Clear the existing prerequisites of a rake task. + def clear_prerequisites + prerequisites.clear + self + end + + # Clear the existing actions on a rake task. + def clear_actions + actions.clear + self + end + + # Invoke the task if it is needed. Prerequites are invoked first. + def invoke(*args) + task_args = TaskArguments.new(arg_names, args) + invoke_with_call_chain(task_args, InvocationChain::EMPTY) + end + + # Same as invoke, but explicitly pass a call chain to detect + # circular dependencies. + def invoke_with_call_chain(task_args, invocation_chain) # :nodoc: + new_chain = InvocationChain.append(self, invocation_chain) + @lock.synchronize do + if application.options.trace + puts "** Invoke #{name} #{format_trace_flags}" + end + return if @already_invoked + @already_invoked = true + invoke_prerequisites(task_args, new_chain) + execute(task_args) if needed? + end + end + protected :invoke_with_call_chain + + # Invoke all the prerequisites of a task. + def invoke_prerequisites(task_args, invocation_chain) # :nodoc: + @prerequisites.each { |n| + prereq = application[n, @scope] + prereq_args = task_args.new_scope(prereq.arg_names) + prereq.invoke_with_call_chain(prereq_args, invocation_chain) + } + end + + # Format the trace flags for display. + def format_trace_flags + flags = [] + flags << "first_time" unless @already_invoked + flags << "not_needed" unless needed? + flags.empty? ? "" : "(" + flags.join(", ") + ")" + end + private :format_trace_flags + + # Execute the actions associated with this task. + def execute(args=nil) + args ||= EMPTY_TASK_ARGS + if application.options.dryrun + puts "** Execute (dry run) #{name}" + return + end + if application.options.trace + puts "** Execute #{name}" + end + application.enhance_with_matching_rule(name) if @actions.empty? + @actions.each do |act| + case act.arity + when 1 + act.call(self) + else + act.call(self, args) + end + end + end + + # Is this task needed? + def needed? + true + end + + # Timestamp for this task. Basic tasks return the current time for their + # time stamp. Other tasks can be more sophisticated. + def timestamp + @prerequisites.collect { |p| application[p].timestamp }.max || Time.now + end + + # Add a description to the task. The description can consist of an option + # argument list (enclosed brackets) and an optional comment. + def add_description(description) + return if ! description + comment = description.strip + add_comment(comment) if comment && ! comment.empty? + end + + # Writing to the comment attribute is the same as adding a description. + def comment=(description) + add_description(description) + end + + # Add a comment to the task. If a comment alread exists, separate + # the new comment with " / ". + def add_comment(comment) + if @full_comment + @full_comment << " / " + else + @full_comment = '' + end + @full_comment << comment + if @full_comment =~ /\A([^.]+?\.)( |$)/ + @comment = $1 + else + @comment = @full_comment + end + end + private :add_comment + + # Set the names of the arguments for this task. +args+ should be + # an array of symbols, one for each argument name. + def set_arg_names(args) + @arg_names = args.map { |a| a.to_sym } + end + + # Return a string describing the internal state of a task. Useful for + # debugging. + def investigation + result = "------------------------------\n" + result << "Investigating #{name}\n" + result << "class: #{self.class}\n" + result << "task needed: #{needed?}\n" + result << "timestamp: #{timestamp}\n" + result << "pre-requisites: \n" + prereqs = @prerequisites.collect {|name| application[name]} + prereqs.sort! {|a,b| a.timestamp <=> b.timestamp} + prereqs.each do |p| + result << "--#{p.name} (#{p.timestamp})\n" + end + latest_prereq = @prerequisites.collect{|n| application[n].timestamp}.max + result << "latest-prerequisite time: #{latest_prereq}\n" + result << "................................\n\n" + return result + end + + # ---------------------------------------------------------------- + # Rake Module Methods + # + class << self + + # Clear the task list. This cause rake to immediately forget all the + # tasks that have been assigned. (Normally used in the unit tests.) + def clear + Rake.application.clear + end + + # List of all defined tasks. + def tasks + Rake.application.tasks + end + + # Return a task with the given name. If the task is not currently + # known, try to synthesize one from the defined rules. If no rules are + # found, but an existing file matches the task name, assume it is a file + # task with no dependencies or actions. + def [](task_name) + Rake.application[task_name] + end + + # TRUE if the task name is already defined. + def task_defined?(task_name) + Rake.application.lookup(task_name) != nil + end + + # Define a task given +args+ and an option block. If a rule with the + # given name already exists, the prerequisites and actions are added to + # the existing task. Returns the defined task. + def define_task(*args, &block) + Rake.application.define_task(self, *args, &block) + end + + # Define a rule for synthesizing tasks. + def create_rule(*args, &block) + Rake.application.create_rule(*args, &block) + end + + # Apply the scope to the task name according to the rules for + # this kind of task. Generic tasks will accept the scope as + # part of the name. + def scope_name(scope, task_name) + (scope + [task_name]).join(':') + end + + end # class << Rake::Task + end # class Rake::Task +end diff --git a/lib/rake/task_argument_error.rb b/lib/rake/task_argument_error.rb new file mode 100644 index 000000000..3e1dda64d --- /dev/null +++ b/lib/rake/task_argument_error.rb @@ -0,0 +1,7 @@ +module Rake + + # Error indicating an ill-formed task declaration. + class TaskArgumentError < ArgumentError + end + +end diff --git a/lib/rake/task_arguments.rb b/lib/rake/task_arguments.rb new file mode 100644 index 000000000..379cd2fb2 --- /dev/null +++ b/lib/rake/task_arguments.rb @@ -0,0 +1,78 @@ +module Rake + + #################################################################### + # TaskAguments manage the arguments passed to a task. + # + class TaskArguments + include Enumerable + + attr_reader :names + + # Create a TaskArgument object with a list of named arguments + # (given by :names) and a set of associated values (given by + # :values). :parent is the parent argument object. + def initialize(names, values, parent=nil) + @names = names + @parent = parent + @hash = {} + names.each_with_index { |name, i| + @hash[name.to_sym] = values[i] unless values[i].nil? + } + end + + # Create a new argument scope using the prerequisite argument + # names. + def new_scope(names) + values = names.collect { |n| self[n] } + self.class.new(names, values, self) + end + + # Find an argument value by name or index. + def [](index) + lookup(index.to_sym) + end + + # Specify a hash of default values for task arguments. Use the + # defaults only if there is no specific value for the given + # argument. + def with_defaults(defaults) + @hash = defaults.merge(@hash) + end + + def each(&block) + @hash.each(&block) + end + + def method_missing(sym, *args, &block) + lookup(sym.to_sym) + end + + def to_hash + @hash + end + + def to_s + @hash.inspect + end + + def inspect + to_s + end + + protected + + def lookup(name) + if @hash.has_key?(name) + @hash[name] + elsif ENV.has_key?(name.to_s) + ENV[name.to_s] + elsif ENV.has_key?(name.to_s.upcase) + ENV[name.to_s.upcase] + elsif @parent + @parent.lookup(name) + end + end + end + + EMPTY_TASK_ARGS = TaskArguments.new([], []) +end diff --git a/lib/rake/task_manager.rb b/lib/rake/task_manager.rb new file mode 100644 index 000000000..1ee08409d --- /dev/null +++ b/lib/rake/task_manager.rb @@ -0,0 +1,306 @@ +module Rake + + # The TaskManager module is a mixin for managing tasks. + module TaskManager + # Track the last comment made in the Rakefile. + attr_accessor :last_description + alias :last_comment :last_description # Backwards compatibility + + def initialize + super + @tasks = Hash.new + @rules = Array.new + @scope = Array.new + @last_description = nil + end + + def create_rule(*args, &block) + pattern, arg_names, deps = resolve_args(args) + pattern = Regexp.new(Regexp.quote(pattern) + '$') if String === pattern + @rules << [pattern, deps, block] + end + + def define_task(task_class, *args, &block) + task_name, arg_names, deps = resolve_args(args) + task_name = task_class.scope_name(@scope, task_name) + deps = [deps] unless deps.respond_to?(:to_ary) + deps = deps.collect {|d| d.to_s } + task = intern(task_class, task_name) + task.set_arg_names(arg_names) unless arg_names.empty? + task.add_description(get_description) + task.enhance(deps, &block) + task + end + + # Lookup a task. Return an existing task if found, otherwise + # create a task of the current type. + def intern(task_class, task_name) + @tasks[task_name.to_s] ||= task_class.new(task_name, self) + end + + # Find a matching task for +task_name+. + def [](task_name, scopes=nil) + task_name = task_name.to_s + self.lookup(task_name, scopes) or + enhance_with_matching_rule(task_name) or + synthesize_file_task(task_name) or + fail "Don't know how to build task '#{task_name}'" + end + + def synthesize_file_task(task_name) + return nil unless File.exist?(task_name) + define_task(Rake::FileTask, task_name) + end + + # Resolve the arguments for a task/rule. Returns a triplet of + # [task_name, arg_name_list, prerequisites]. + def resolve_args(args) + if args.last.is_a?(Hash) + deps = args.pop + resolve_args_with_dependencies(args, deps) + else + resolve_args_without_dependencies(args) + end + end + + # Resolve task arguments for a task or rule when there are no + # dependencies declared. + # + # The patterns recognized by this argument resolving function are: + # + # task :t + # task :t, [:a] + # task :t, :a (deprecated) + # + def resolve_args_without_dependencies(args) + task_name = args.shift + if args.size == 1 && args.first.respond_to?(:to_ary) + arg_names = args.first.to_ary + else + arg_names = args + end + [task_name, arg_names, []] + end + private :resolve_args_without_dependencies + + # Resolve task arguments for a task or rule when there are + # dependencies declared. + # + # The patterns recognized by this argument resolving function are: + # + # task :t => [:d] + # task :t, [a] => [:d] + # task :t, :needs => [:d] (deprecated) + # task :t, :a, :needs => [:d] (deprecated) + # + def resolve_args_with_dependencies(args, hash) # :nodoc: + fail "Task Argument Error" if hash.size != 1 + key, value = hash.map { |k, v| [k,v] }.first + if args.empty? + task_name = key + arg_names = [] + deps = value + elsif key == :needs + task_name = args.shift + arg_names = args + deps = value + else + task_name = args.shift + arg_names = key + deps = value + end + deps = [deps] unless deps.respond_to?(:to_ary) + [task_name, arg_names, deps] + end + private :resolve_args_with_dependencies + + # If a rule can be found that matches the task name, enhance the + # task with the prerequisites and actions from the rule. Set the + # source attribute of the task appropriately for the rule. Return + # the enhanced task or nil of no rule was found. + def enhance_with_matching_rule(task_name, level=0) + fail Rake::RuleRecursionOverflowError, + "Rule Recursion Too Deep" if level >= 16 + @rules.each do |pattern, extensions, block| + if md = pattern.match(task_name) + task = attempt_rule(task_name, extensions, block, level) + return task if task + end + end + nil + rescue Rake::RuleRecursionOverflowError => ex + ex.add_target(task_name) + fail ex + end + + # List of all defined tasks in this application. + def tasks + @tasks.values.sort_by { |t| t.name } + end + + # List of all the tasks defined in the given scope (and its + # sub-scopes). + def tasks_in_scope(scope) + prefix = scope.join(":") + tasks.select { |t| + /^#{prefix}:/ =~ t.name + } + end + + # Clear all tasks in this application. + def clear + @tasks.clear + @rules.clear + end + + # Lookup a task, using scope and the scope hints in the task name. + # This method performs straight lookups without trying to + # synthesize file tasks or rules. Special scope names (e.g. '^') + # are recognized. If no scope argument is supplied, use the + # current scope. Return nil if the task cannot be found. + def lookup(task_name, initial_scope=nil) + initial_scope ||= @scope + task_name = task_name.to_s + if task_name =~ /^rake:/ + scopes = [] + task_name = task_name.sub(/^rake:/, '') + elsif task_name =~ /^(\^+)/ + scopes = initial_scope[0, initial_scope.size - $1.size] + task_name = task_name.sub(/^(\^+)/, '') + else + scopes = initial_scope + end + lookup_in_scope(task_name, scopes) + end + + # Lookup the task name + def lookup_in_scope(name, scope) + n = scope.size + while n >= 0 + tn = (scope[0,n] + [name]).join(':') + task = @tasks[tn] + return task if task + n -= 1 + end + nil + end + private :lookup_in_scope + + # Return the list of scope names currently active in the task + # manager. + def current_scope + @scope.dup + end + + # Evaluate the block in a nested namespace named +name+. Create + # an anonymous namespace if +name+ is nil. + def in_namespace(name) + name ||= generate_name + @scope.push(name) + ns = NameSpace.new(self, @scope) + yield(ns) + ns + ensure + @scope.pop + end + + private + + # Generate an anonymous namespace name. + def generate_name + @seed ||= 0 + @seed += 1 + "_anon_#{@seed}" + end + + def trace_rule(level, message) + puts "#{" "*level}#{message}" if Rake.application.options.trace_rules + end + + # Attempt to create a rule given the list of prerequisites. + def attempt_rule(task_name, extensions, block, level) + sources = make_sources(task_name, extensions) + prereqs = sources.collect { |source| + trace_rule level, "Attempting Rule #{task_name} => #{source}" + if File.exist?(source) || Rake::Task.task_defined?(source) + trace_rule level, "(#{task_name} => #{source} ... EXIST)" + source + elsif parent = enhance_with_matching_rule(source, level+1) + trace_rule level, "(#{task_name} => #{source} ... ENHANCE)" + parent.name + else + trace_rule level, "(#{task_name} => #{source} ... FAIL)" + return nil + end + } + task = FileTask.define_task({task_name => prereqs}, &block) + task.sources = prereqs + task + end + + # Make a list of sources from the list of file name extensions / + # translation procs. + def make_sources(task_name, extensions) + extensions.collect { |ext| + case ext + when /%/ + task_name.pathmap(ext) + when %r{/} + ext + when /^\./ + task_name.ext(ext) + when String + ext + when Proc + if ext.arity == 1 + ext.call(task_name) + else + ext.call + end + else + fail "Don't know how to handle rule dependent: #{ext.inspect}" + end + }.flatten + end + + + private + + # Return the current description. If there isn't one, try to find it + # by reading in the source file and looking for a comment immediately + # prior to the task definition + def get_description + desc = @last_description || find_preceding_comment_for_task + @last_description = nil + desc + end + + def find_preceding_comment_for_task + stack = caller + begin + where = stack.shift + end until stack.empty? || where =~ /in `task'/ + return nil if stack.empty? + file_name, line = parse_stack_line(stack.shift) + return nil unless file_name + comment_from_file(file_name, line) + end + + def parse_stack_line(where) + if where =~ /^(.*):(\d+)/ + [ $1, Integer($2) ] + else + nil + end + end + + def comment_from_file(file_name, line) + @file_cache ||= {} + content = (@file_cache[file_name] ||= File.readlines(file_name)) + line -= 2 + return nil unless content[line] =~ /^\s*#\s*(.*)/ + $1 + end + end + +end From b1582d4378c08ecb6c66dab351f8a021261fbbf0 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Sat, 28 Mar 2009 16:54:26 +0000 Subject: [PATCH 0007/1389] moved top level manipulators to top level. --- lib/rake.rb | 10 +++++++++- lib/rake/rake_file_utils.rb | 9 --------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/rake.rb b/lib/rake.rb index 87d9e7ed6..c9a35a53e 100755 --- a/lib/rake.rb +++ b/lib/rake.rb @@ -41,7 +41,15 @@ require 'rake/win32' require 'rake/file_list' +$trace = false + # Alias FileList to be available at the top level. FileList = Rake::FileList -$trace = false +# Include the FileUtils file manipulation functions in the top level module, +# but mark them private so that they don't unintentionally define methods on +# other objects. + +include RakeFileUtils +private(*FileUtils.instance_methods(false)) +private(*RakeFileUtils.instance_methods(false)) diff --git a/lib/rake/rake_file_utils.rb b/lib/rake/rake_file_utils.rb index 7ddd5b33b..a4036cc8f 100644 --- a/lib/rake/rake_file_utils.rb +++ b/lib/rake/rake_file_utils.rb @@ -131,12 +131,3 @@ def rake_check_options(options, *optdecl) extend self end -# ########################################################################### -# Include the FileUtils file manipulation functions in the top level module, -# but mark them private so that they don't unintentionally define methods on -# other objects. - -include RakeFileUtils -private(*FileUtils.instance_methods(false)) -private(*RakeFileUtils.instance_methods(false)) - From aaa93d743399d81c04a51aa938a89a648ec8d9d8 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Sat, 28 Mar 2009 16:56:05 +0000 Subject: [PATCH 0008/1389] Updated main copyright --- lib/rake.rb | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/rake.rb b/lib/rake.rb index c9a35a53e..ae9984450 100755 --- a/lib/rake.rb +++ b/lib/rake.rb @@ -2,7 +2,7 @@ #-- -# Copyright 2003, 2004, 2005, 2006, 2007, 2008 by Jim Weirich (jim@weirichhouse.org) +# Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 by Jim Weirich (jim.weirich@gmail.com) # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to @@ -22,12 +22,6 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. #++ -# -# = Rake -- Ruby Make -# -# This is the main file for the Rake application. Normally it is referenced -# as a library via a require statement, but it can be distributed -# independently as an application. RAKEVERSION = '0.8.5' From db5ae92855b5c7243e2e362fe5c5243355898b7c Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Wed, 6 May 2009 14:26:52 -0700 Subject: [PATCH 0009/1389] Added .idea to ignore file. --- .gitignore | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 062a44bd5..5c2982f4c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,13 @@ +*.bak +*.patch +*.rbc +.#* +.idea TAGS +coverage html pkg -coverage -testdata -*.bak +r19.diff temp_* +testdata x -*.patch -.#* -*.rbc -r19.diff From f6d26a57a9ad9e3c3701d76c058e91425f11c54a Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Mon, 11 May 2009 10:35:33 -0400 Subject: [PATCH 0010/1389] Updated rakefile to not generate darkfish in the gemspec. --- Rakefile | 6 +++--- rake.gemspec | 33 ++++++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/Rakefile b/Rakefile index 751ec983f..8493bb5d4 100644 --- a/Rakefile +++ b/Rakefile @@ -136,9 +136,9 @@ rescue LoadError => ex end BASE_RDOC_OPTIONS = [ - '--line-numbers', - '--main', 'README', - '--title', 'Rake -- Ruby Make', + '--line-numbers', '--inline-source', + '--main' , 'README', + '--title', 'Rake -- Ruby Make' ] rd = Rake::RDocTask.new("rdoc") do |rdoc| diff --git a/rake.gemspec b/rake.gemspec index 2da7ea7e8..5b39cd317 100644 --- a/rake.gemspec +++ b/rake.gemspec @@ -1,7 +1,7 @@ --- !ruby/object:Gem::Specification name: rake version: !ruby/object:Gem::Version - version: 0.8.4.99 + version: 0.8.5 platform: ruby authors: - Jim Weirich @@ -9,7 +9,7 @@ autorequire: bindir: bin cert_chain: [] -date: 2009-04-22 00:00:00 -04:00 +date: 2009-05-11 00:00:00 -04:00 default_executable: rake dependencies: [] @@ -43,6 +43,7 @@ extra_rdoc_files: - doc/release_notes/rake-0.8.2.rdoc - doc/release_notes/rake-0.8.3.rdoc - doc/release_notes/rake-0.8.4.rdoc +- doc/release_notes/rake-0.8.5.rdoc files: - install.rb - CHANGES @@ -52,21 +53,44 @@ files: - TODO - bin/rake - lib/rake/alt_system.rb +- lib/rake/application.rb - lib/rake/classic_namespace.rb - lib/rake/clean.rb +- lib/rake/cloneable.rb - lib/rake/contrib/compositepublisher.rb - lib/rake/contrib/ftptools.rb - lib/rake/contrib/publisher.rb - lib/rake/contrib/rubyforgepublisher.rb - lib/rake/contrib/sshpublisher.rb - lib/rake/contrib/sys.rb +- lib/rake/default_loader.rb +- lib/rake/dsl.rb +- lib/rake/early_time.rb +- lib/rake/ext/module.rb +- lib/rake/ext/string.rb +- lib/rake/ext/time.rb +- lib/rake/file_creation_task.rb +- lib/rake/file_list.rb +- lib/rake/file_task.rb +- lib/rake/file_utils.rb - lib/rake/gempackagetask.rb +- lib/rake/invocation_chain.rb - lib/rake/loaders/makefile.rb +- lib/rake/multi_task.rb +- lib/rake/name_space.rb - lib/rake/packagetask.rb +- lib/rake/psuedo_status.rb +- lib/rake/rake_file_utils.rb +- lib/rake/rake_module.rb - lib/rake/rake_test_loader.rb - lib/rake/rdoctask.rb - lib/rake/ruby182_test_unit_fix.rb +- lib/rake/rule_recursion_overflow_error.rb - lib/rake/runtest.rb +- lib/rake/task.rb +- lib/rake/task_argument_error.rb +- lib/rake/task_arguments.rb +- lib/rake/task_manager.rb - lib/rake/tasklib.rb - lib/rake/testtask.rb - lib/rake/win32.rb @@ -116,6 +140,7 @@ files: - test/data/imports/deps.mf - test/data/sample.mf - test/data/chains/Rakefile +- test/data/comments/Rakefile - test/data/default/Rakefile - test/data/dryrun/Rakefile - test/data/file_creation_task/Rakefile @@ -153,6 +178,7 @@ files: - doc/release_notes/rake-0.8.2.rdoc - doc/release_notes/rake-0.8.3.rdoc - doc/release_notes/rake-0.8.4.rdoc +- doc/release_notes/rake-0.8.5.rdoc has_rdoc: true homepage: http://rake.rubyforge.org post_install_message: @@ -163,9 +189,6 @@ rdoc_options: - README - --title - Rake -- Ruby Make -- -SHN -- -f -- darkfish require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement From ee6cb80c5d974652631a59882ff1d0ce074dcc46 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Fri, 15 May 2009 17:35:56 -0400 Subject: [PATCH 0011/1389] Fixes for post 0.8.7 merge. --- lib/rake.rb | 24 +++++++++++++++++++++++- lib/rake/application.rb | 1 + lib/rake/ext/module.rb | 6 ++++++ lib/rake/rake_module.rb | 2 ++ 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/lib/rake.rb b/lib/rake.rb index ae9984450..75b362e0d 100755 --- a/lib/rake.rb +++ b/lib/rake.rb @@ -23,7 +23,7 @@ # IN THE SOFTWARE. #++ -RAKEVERSION = '0.8.5' +RAKEVERSION = '0.8.7.1' require 'rbconfig' require 'fileutils' @@ -32,8 +32,30 @@ require 'optparse' require 'ostruct' +require 'rake/ext/module' +require 'rake/ext/string' +require 'rake/ext/time' + require 'rake/win32' + +require 'rake/task_argument_error' +require 'rake/rule_recursion_overflow_error' +require 'rake/rake_module' +require 'rake/psuedo_status' +require 'rake/task_arguments' +require 'rake/invocation_chain' +require 'rake/task' +require 'rake/file_task' +require 'rake/file_creation_task' +require 'rake/multi_task' +require 'rake/dsl' +require 'rake/rake_file_utils' require 'rake/file_list' +require 'rake/default_loader' +require 'rake/early_time' +require 'rake/name_space' +require 'rake/task_manager' +require 'rake/application' $trace = false diff --git a/lib/rake/application.rb b/lib/rake/application.rb index aba993af7..77329b2dc 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -1,4 +1,5 @@ require 'rake/task_manager' +require 'rake/win32' module Rake diff --git a/lib/rake/ext/module.rb b/lib/rake/ext/module.rb index 4d9a9ab9d..6e30e6cbb 100644 --- a/lib/rake/ext/module.rb +++ b/lib/rake/ext/module.rb @@ -1,3 +1,9 @@ +require 'rake/task' +require 'rake/file_task' +require 'rake/file_creation_task' +require 'rake/application' +require 'rake/task_manager' + ###################################################################### # Rake extensions to Module. # diff --git a/lib/rake/rake_module.rb b/lib/rake/rake_module.rb index b606a7b6e..9aa9c4339 100644 --- a/lib/rake/rake_module.rb +++ b/lib/rake/rake_module.rb @@ -1,3 +1,5 @@ +require 'rake/application' + module Rake # Rake module singleton methods. From 63d419d9487978b4dcbc8704f1a8c50498bf4845 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Fri, 15 May 2009 17:55:12 -0400 Subject: [PATCH 0012/1389] Restructured tests into subdirectories and switched to the *_test.rb convention. --- Rakefile | 10 +++++----- .../functional_test.rb} | 2 +- .../session_based_tests.rb} | 0 .../application_test.rb} | 0 test/{test_clean.rb => lib/clean_test.rb} | 0 .../definitions_test.rb} | 0 test/{test_earlytime.rb => lib/earlytime_test.rb} | 0 test/{test_extension.rb => lib/extension_test.rb} | 0 .../file_creation_task_test.rb} | 0 test/{test_file_task.rb => lib/file_task_test.rb} | 0 test/{test_filelist.rb => lib/filelist_test.rb} | 14 +++++++------- test/{test_fileutils.rb => lib/fileutils_test.rb} | 0 test/{test_ftp.rb => lib/ftp_test.rb} | 0 .../invocation_chain_test.rb} | 0 .../makefile_loader_test.rb} | 0 test/{test_multitask.rb => lib/multitask_test.rb} | 0 test/{test_namespace.rb => lib/namespace_test.rb} | 0 .../package_task_test.rb} | 0 test/{test_pathmap.rb => lib/pathmap_test.rb} | 0 .../pseudo_status_test.rb} | 0 test/{test_rake.rb => lib/rake_test.rb} | 0 test/{test_rdoc_task.rb => lib/rdoc_task_test.rb} | 0 test/{test_require.rb => lib/require_test.rb} | 0 test/{test_rules.rb => lib/rules_test.rb} | 0 .../task_arguments_test.rb} | 0 .../task_manager_test.rb} | 0 test/{test_tasklib.rb => lib/tasklib_test.rb} | 0 test/{test_tasks.rb => lib/tasks_test.rb} | 0 test/{test_test_task.rb => lib/test_task_test.rb} | 0 .../top_level_functions_test.rb} | 0 test/{test_win32.rb => lib/win32_test.rb} | 0 31 files changed, 13 insertions(+), 13 deletions(-) rename test/{functional.rb => functional/functional_test.rb} (83%) rename test/{session_functional.rb => functional/session_based_tests.rb} (100%) rename test/{test_application.rb => lib/application_test.rb} (100%) rename test/{test_clean.rb => lib/clean_test.rb} (100%) rename test/{test_definitions.rb => lib/definitions_test.rb} (100%) rename test/{test_earlytime.rb => lib/earlytime_test.rb} (100%) rename test/{test_extension.rb => lib/extension_test.rb} (100%) rename test/{test_file_creation_task.rb => lib/file_creation_task_test.rb} (100%) rename test/{test_file_task.rb => lib/file_task_test.rb} (100%) rename test/{test_filelist.rb => lib/filelist_test.rb} (98%) rename test/{test_fileutils.rb => lib/fileutils_test.rb} (100%) rename test/{test_ftp.rb => lib/ftp_test.rb} (100%) rename test/{test_invocation_chain.rb => lib/invocation_chain_test.rb} (100%) rename test/{test_makefile_loader.rb => lib/makefile_loader_test.rb} (100%) rename test/{test_multitask.rb => lib/multitask_test.rb} (100%) rename test/{test_namespace.rb => lib/namespace_test.rb} (100%) rename test/{test_package_task.rb => lib/package_task_test.rb} (100%) rename test/{test_pathmap.rb => lib/pathmap_test.rb} (100%) rename test/{test_pseudo_status.rb => lib/pseudo_status_test.rb} (100%) rename test/{test_rake.rb => lib/rake_test.rb} (100%) rename test/{test_rdoc_task.rb => lib/rdoc_task_test.rb} (100%) rename test/{test_require.rb => lib/require_test.rb} (100%) rename test/{test_rules.rb => lib/rules_test.rb} (100%) rename test/{test_task_arguments.rb => lib/task_arguments_test.rb} (100%) rename test/{test_task_manager.rb => lib/task_manager_test.rb} (100%) rename test/{test_tasklib.rb => lib/tasklib_test.rb} (100%) rename test/{test_tasks.rb => lib/tasks_test.rb} (100%) rename test/{test_test_task.rb => lib/test_task_test.rb} (100%) rename test/{test_top_level_functions.rb => lib/top_level_functions_test.rb} (100%) rename test/{test_win32.rb => lib/win32_test.rb} (100%) diff --git a/Rakefile b/Rakefile index 8493bb5d4..fca2e6c4d 100644 --- a/Rakefile +++ b/Rakefile @@ -64,22 +64,22 @@ task :test => :test_units Rake::TestTask.new(:test_all) do |t| t.test_files = FileList[ - 'test/test*.rb', - 'test/contrib/test*.rb', - 'test/fun*.rb' + 'test/lib/*_test.rb', + 'test/contrib/*_test.rb', + 'test/functional/*_test.rb' ] t.warning = true t.verbose = false end Rake::TestTask.new(:test_units) do |t| - t.test_files = FileList['test/test*.rb'] + t.test_files = FileList['test/lib/*_test.rb'] t.warning = true t.verbose = false end Rake::TestTask.new(:test_functional) do |t| - t.test_files = FileList['test/fun*.rb'] + t.test_files = FileList['test/functional/*_test.rb'] t.warning = true t.verbose = false end diff --git a/test/functional.rb b/test/functional/functional_test.rb similarity index 83% rename from test/functional.rb rename to test/functional/functional_test.rb index 6a5c60250..301f78370 100644 --- a/test/functional.rb +++ b/test/functional/functional_test.rb @@ -11,5 +11,5 @@ if defined?(Session) puts "RUNNING WITH SESSIONS" - require 'test/session_functional' + require 'test/functional/session_based_tests.rb' end diff --git a/test/session_functional.rb b/test/functional/session_based_tests.rb similarity index 100% rename from test/session_functional.rb rename to test/functional/session_based_tests.rb diff --git a/test/test_application.rb b/test/lib/application_test.rb similarity index 100% rename from test/test_application.rb rename to test/lib/application_test.rb diff --git a/test/test_clean.rb b/test/lib/clean_test.rb similarity index 100% rename from test/test_clean.rb rename to test/lib/clean_test.rb diff --git a/test/test_definitions.rb b/test/lib/definitions_test.rb similarity index 100% rename from test/test_definitions.rb rename to test/lib/definitions_test.rb diff --git a/test/test_earlytime.rb b/test/lib/earlytime_test.rb similarity index 100% rename from test/test_earlytime.rb rename to test/lib/earlytime_test.rb diff --git a/test/test_extension.rb b/test/lib/extension_test.rb similarity index 100% rename from test/test_extension.rb rename to test/lib/extension_test.rb diff --git a/test/test_file_creation_task.rb b/test/lib/file_creation_task_test.rb similarity index 100% rename from test/test_file_creation_task.rb rename to test/lib/file_creation_task_test.rb diff --git a/test/test_file_task.rb b/test/lib/file_task_test.rb similarity index 100% rename from test/test_file_task.rb rename to test/lib/file_task_test.rb diff --git a/test/test_filelist.rb b/test/lib/filelist_test.rb similarity index 98% rename from test/test_filelist.rb rename to test/lib/filelist_test.rb index 84ee82ccf..26483997d 100644 --- a/test/test_filelist.rb +++ b/test/lib/filelist_test.rb @@ -90,8 +90,8 @@ def test_add_return def test_match fl = FileList.new - fl.include('test/test*.rb') - assert fl.include?("test/test_filelist.rb") + fl.include('test/lib/*_test.rb') + assert fl.include?("test/lib/filelist_test.rb") assert fl.size > 3 fl.each { |fn| assert_match(/\.rb$/, fn) } end @@ -99,10 +99,10 @@ def test_match def test_add_matching fl = FileList.new fl << "a.java" - fl.include("test/*.rb") + fl.include("test/lib/*.rb") assert_equal "a.java", fl[0] assert fl.size > 2 - assert fl.include?("test/test_filelist.rb") + assert fl.include?("test/lib/filelist_test.rb") end def test_multiple_patterns @@ -324,18 +324,18 @@ def test_gsub! end def test_egrep_with_output - files = FileList['test/test*.rb'] + files = FileList['test/lib/*_test.rb'] the_line_number = __LINE__ + 1 out = capture_stdout do files.egrep(/PUGH/) end assert_match(/:#{the_line_number}:/, out) end def test_egrep_with_block - files = FileList['test/test*.rb'] + files = FileList['test/lib/*_test.rb'] found = false the_line_number = __LINE__ + 1 files.egrep(/XYZZY/) do |fn, ln, line | - assert_equal 'test/test_filelist.rb', fn + assert_equal 'test/lib/filelist_test.rb', fn assert_equal the_line_number, ln assert_match(/files\.egrep/, line) found = true diff --git a/test/test_fileutils.rb b/test/lib/fileutils_test.rb similarity index 100% rename from test/test_fileutils.rb rename to test/lib/fileutils_test.rb diff --git a/test/test_ftp.rb b/test/lib/ftp_test.rb similarity index 100% rename from test/test_ftp.rb rename to test/lib/ftp_test.rb diff --git a/test/test_invocation_chain.rb b/test/lib/invocation_chain_test.rb similarity index 100% rename from test/test_invocation_chain.rb rename to test/lib/invocation_chain_test.rb diff --git a/test/test_makefile_loader.rb b/test/lib/makefile_loader_test.rb similarity index 100% rename from test/test_makefile_loader.rb rename to test/lib/makefile_loader_test.rb diff --git a/test/test_multitask.rb b/test/lib/multitask_test.rb similarity index 100% rename from test/test_multitask.rb rename to test/lib/multitask_test.rb diff --git a/test/test_namespace.rb b/test/lib/namespace_test.rb similarity index 100% rename from test/test_namespace.rb rename to test/lib/namespace_test.rb diff --git a/test/test_package_task.rb b/test/lib/package_task_test.rb similarity index 100% rename from test/test_package_task.rb rename to test/lib/package_task_test.rb diff --git a/test/test_pathmap.rb b/test/lib/pathmap_test.rb similarity index 100% rename from test/test_pathmap.rb rename to test/lib/pathmap_test.rb diff --git a/test/test_pseudo_status.rb b/test/lib/pseudo_status_test.rb similarity index 100% rename from test/test_pseudo_status.rb rename to test/lib/pseudo_status_test.rb diff --git a/test/test_rake.rb b/test/lib/rake_test.rb similarity index 100% rename from test/test_rake.rb rename to test/lib/rake_test.rb diff --git a/test/test_rdoc_task.rb b/test/lib/rdoc_task_test.rb similarity index 100% rename from test/test_rdoc_task.rb rename to test/lib/rdoc_task_test.rb diff --git a/test/test_require.rb b/test/lib/require_test.rb similarity index 100% rename from test/test_require.rb rename to test/lib/require_test.rb diff --git a/test/test_rules.rb b/test/lib/rules_test.rb similarity index 100% rename from test/test_rules.rb rename to test/lib/rules_test.rb diff --git a/test/test_task_arguments.rb b/test/lib/task_arguments_test.rb similarity index 100% rename from test/test_task_arguments.rb rename to test/lib/task_arguments_test.rb diff --git a/test/test_task_manager.rb b/test/lib/task_manager_test.rb similarity index 100% rename from test/test_task_manager.rb rename to test/lib/task_manager_test.rb diff --git a/test/test_tasklib.rb b/test/lib/tasklib_test.rb similarity index 100% rename from test/test_tasklib.rb rename to test/lib/tasklib_test.rb diff --git a/test/test_tasks.rb b/test/lib/tasks_test.rb similarity index 100% rename from test/test_tasks.rb rename to test/lib/tasks_test.rb diff --git a/test/test_test_task.rb b/test/lib/test_task_test.rb similarity index 100% rename from test/test_test_task.rb rename to test/lib/test_task_test.rb diff --git a/test/test_top_level_functions.rb b/test/lib/top_level_functions_test.rb similarity index 100% rename from test/test_top_level_functions.rb rename to test/lib/top_level_functions_test.rb diff --git a/test/test_win32.rb b/test/lib/win32_test.rb similarity index 100% rename from test/test_win32.rb rename to test/lib/win32_test.rb From a66153af034e5b0680031dd693f764492a26845c Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Fri, 15 May 2009 18:09:56 -0400 Subject: [PATCH 0013/1389] Fixed up test location for r19 and rbx. --- Rakefile | 10 ++++++---- rakelib/rbx.rake | 6 +++--- rakelib/ruby19.rake | 6 +++--- test/functional/session_based_tests.rb | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Rakefile b/Rakefile index fca2e6c4d..2bba042ac 100644 --- a/Rakefile +++ b/Rakefile @@ -62,7 +62,8 @@ task :tu => :test_units task :tc => :test_contribs task :test => :test_units -Rake::TestTask.new(:test_all) do |t| +namespace :test do + Rake::TestTask.new(:all) do |t| t.test_files = FileList[ 'test/lib/*_test.rb', 'test/contrib/*_test.rb', @@ -72,23 +73,24 @@ Rake::TestTask.new(:test_all) do |t| t.verbose = false end -Rake::TestTask.new(:test_units) do |t| +Rake::TestTask.new(:units) do |t| t.test_files = FileList['test/lib/*_test.rb'] t.warning = true t.verbose = false end -Rake::TestTask.new(:test_functional) do |t| +Rake::TestTask.new(:functional) do |t| t.test_files = FileList['test/functional/*_test.rb'] t.warning = true t.verbose = false end -Rake::TestTask.new(:test_contribs) do |t| +Rake::TestTask.new(:contribs) do |t| t.test_files = FileList['test/contrib/test*.rb'] t.warning = true t.verbose = false end +end begin require 'rcov/rcovtask' diff --git a/rakelib/rbx.rake b/rakelib/rbx.rake index 60ec5e1d4..c5ba10918 100644 --- a/rakelib/rbx.rake +++ b/rakelib/rbx.rake @@ -63,19 +63,19 @@ namespace "rbx" do desc "Run the unit tests in Ruby 1.9" task :units, :opts, :needs => [:env19] do |t, args| - test_files = FileList['test/**/test_*.rb'] + test_files = FileList['test/lib/*_test.rb'] Rbx.run_tests(test_files, args.opts) end desc "Run the functional tests in Ruby 1.9" task :functionals, :opts, :needs => [:env19] do |t, args| - test_files = FileList['test/functional.rb'] + test_files = FileList['test/functional/*_test.rb'] Rbx.run_tests(test_files, args.opts) end desc "Run the all the tests in Ruby 1.9" task :all, :opts, :needs => [:env19] do |t, args| - test_files = FileList['test/functional.rb', 'test/**/test_*.rb'] + test_files = FileList['test/functional/*_test.rb', 'test/lib/*_test.rb'] Rbx.run_tests(test_files, args.opts) end end diff --git a/rakelib/ruby19.rake b/rakelib/ruby19.rake index 7696bb570..075d77429 100644 --- a/rakelib/ruby19.rake +++ b/rakelib/ruby19.rake @@ -69,19 +69,19 @@ namespace "ruby19" do desc "Run the unit tests in Ruby 1.9" task :units, :opts, :needs => [:env19] do |t, args| - test_files = FileList['test/**/test_*.rb'] + test_files = FileList['test/lib/*_test.rb'] Ruby19.run_tests(test_files, args.opts) end desc "Run the functional tests in Ruby 1.9" task :functionals, :opts, :needs => [:env19] do |t, args| - test_files = FileList['test/functional.rb'] + test_files = FileList['test/functional/*_test.rb'] Ruby19.run_tests(test_files, args.opts) end desc "Run the all the tests in Ruby 1.9" task :all, :opts, :needs => [:env19] do |t, args| - test_files = FileList['test/functional.rb', 'test/**/test_*.rb'] + test_files = FileList['test/functional/*_test.rb', 'test/lib/*_test.rb'] Ruby19.run_tests(test_files, args.opts) end end diff --git a/test/functional/session_based_tests.rb b/test/functional/session_based_tests.rb index 54f515e3c..2738a2fff 100644 --- a/test/functional/session_based_tests.rb +++ b/test/functional/session_based_tests.rb @@ -321,7 +321,7 @@ def test_comment_before_desc_is_ignored def test_correct_number_of_tasks_reported Dir.chdir("test/data/comments") { rake("-T")} - assert_equal(3, @out.grep(/t\d/).size) + assert_equal(3, @out.split(/\n/).grep(/t\d/).size) end private From eb6702a95b73531dc7aa2c9e6be1b433c906ccd7 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Fri, 15 May 2009 18:13:15 -0400 Subject: [PATCH 0014/1389] Fixed testing shortcuts. --- Rakefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Rakefile b/Rakefile index 2bba042ac..983b12627 100644 --- a/Rakefile +++ b/Rakefile @@ -56,11 +56,11 @@ end # Common Abbreviations ... -task :ta => :test_all -task :tf => :test_functional -task :tu => :test_units -task :tc => :test_contribs -task :test => :test_units +task :ta => "test:all" +task :tf => "test:functional" +task :tu => "test:units" +task :tc => "test:contribs" +task :test => "test:units" namespace :test do Rake::TestTask.new(:all) do |t| From f8d1b8b441e38ac314e5d70d41b6ca2715c54667 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Sun, 17 May 2009 21:43:57 -0400 Subject: [PATCH 0015/1389] Updated RBC clean extensions. --- README | 2 +- Rakefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README b/README index 41668dd72..ea2860aad 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ = RAKE -- Ruby Make -Supporting Rake version: 0.8.6 +Supporting Rake version: 0.8.7. This package contains Rake, a simple ruby build program with capabilities similar to make. diff --git a/Rakefile b/Rakefile index 983b12627..479e81dfc 100644 --- a/Rakefile +++ b/Rakefile @@ -16,7 +16,7 @@ require 'rake/clean' require 'rake/testtask' require 'rake/rdoctask' -CLEAN.include('**/*.o', '*.dot', '**/.*.rbc') +CLEAN.include('**/*.o', '*.dot', '**/*.rbc') CLOBBER.include('doc/example/main', 'testdata') CLOBBER.include('test/data/**/temp_*') CLOBBER.include('test/data/chains/play.*') From 90cb387d5964521c48ec83b4dfd9013ae91986aa Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Mon, 18 May 2009 07:52:33 -0400 Subject: [PATCH 0016/1389] test_all => test:all --- Rakefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Rakefile b/Rakefile index 479e81dfc..5ded82ac9 100644 --- a/Rakefile +++ b/Rakefile @@ -47,7 +47,7 @@ SRC_RB = FileList['lib/**/*.rb'] # The default task is run if rake is given no explicit arguments. desc "Default Task" -task :default => :test_all +task :default => "test:all" # Test Tasks --------------------------------------------------------- task :dbg do |t| @@ -115,7 +115,7 @@ rescue LoadError end directory 'testdata' -[:test_all, :test_units, :test_contribs, :test_functional].each do |t| +["test:all", :test_units, :test_contribs, :test_functional].each do |t| task t => ['testdata'] end @@ -328,7 +328,7 @@ task :release, :rel, :reuse, :reltest, :needs => [ :prerelease, :clobber, - :test_all, + "test:all", :update_version, :package, :tag From db9dde7b2a8874e3d96fe3b5b4453d0a5412bf90 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Mon, 18 May 2009 07:55:04 -0400 Subject: [PATCH 0017/1389] Added deprecation warning for classic namespaces. --- lib/rake/classic_namespace.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/rake/classic_namespace.rb b/lib/rake/classic_namespace.rb index feb756996..6865cf77d 100644 --- a/lib/rake/classic_namespace.rb +++ b/lib/rake/classic_namespace.rb @@ -2,6 +2,7 @@ # Loading this file enables compatibility with older Rakefile that # referenced Task from the top level. +puts "WARNING: Classic namespaces are deprecated and will be removed from future versions of Rake." Task = Rake::Task FileTask = Rake::FileTask FileCreationTask = Rake::FileCreationTask From 72e5cbb393aac0346fc2f21a998ffd3af7b377a6 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Mon, 18 May 2009 08:12:51 -0400 Subject: [PATCH 0018/1389] better toggle mode --- .togglerc | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .togglerc diff --git a/.togglerc b/.togglerc new file mode 100644 index 000000000..68a3cb8ef --- /dev/null +++ b/.togglerc @@ -0,0 +1,7 @@ +(add-to-list + 'toggle-mapping-styles + '(rake . ( + ("test/lib/\\1_test.rb" . "lib/rake/\\1.rb") + ) )) + +(buffer-toggle-style 'rake) From e98aa212219f18096b1804423696f7a01f92acb8 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Mon, 18 May 2009 08:13:01 -0400 Subject: [PATCH 0019/1389] Changing show tasks. --- lib/rake/application.rb | 8 +++----- test/functional/session_based_tests.rb | 1 + test/lib/application_test.rb | 15 ++++++--------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/lib/rake/application.rb b/lib/rake/application.rb index 77329b2dc..a95d02482 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -178,7 +178,7 @@ def display_tasks_and_comments displayable_tasks = tasks.select { |t| t.comment && t.name =~ options.show_task_pattern } - if options.full_description + if options.show_task == :describe displayable_tasks.each do |t| puts "#{name} #{t.name_with_args}" t.full_comment.split("\n").each do |line| @@ -256,8 +256,7 @@ def standard_rake_options ], ['--describe', '-D [PATTERN]', "Describe the tasks (matching optional PATTERN), then exit.", lambda { |value| - options.show_tasks = true - options.full_description = true + options.show_tasks = :describe options.show_task_pattern = Regexp.new(value || '') } ], @@ -340,9 +339,8 @@ def standard_rake_options ], ['--tasks', '-T [PATTERN]', "Display the tasks (matching optional PATTERN) with descriptions, then exit.", lambda { |value| - options.show_tasks = true + options.show_tasks = :tasks options.show_task_pattern = Regexp.new(value || '') - options.full_description = false } ], ['--trace', '-t', "Turn on invoke/execute tracing, enable full backtrace.", diff --git a/test/functional/session_based_tests.rb b/test/functional/session_based_tests.rb index 2738a2fff..9cf5c27db 100644 --- a/test/functional/session_based_tests.rb +++ b/test/functional/session_based_tests.rb @@ -84,6 +84,7 @@ def test_long_description in_environment("PWD" => "test/data/multidesc") do rake "--describe" end + puts @out assert_match %r{^rake a\n *A / A2 *$}m, @out assert_match %r{^rake b\n *B *$}m, @out assert_match %r{^rake d\n *x{80}}m, @out diff --git a/test/lib/application_test.rb b/test/lib/application_test.rb index c7fadb65e..5d2e50890 100644 --- a/test/lib/application_test.rb +++ b/test/lib/application_test.rb @@ -99,9 +99,9 @@ def test_display_tasks_with_long_comments_to_a_non_tty_with_columns_set_truncate end end - def test_display_tasks_with_full_descriptions + def test_describe_tasks + @app.options.show_task = :describe @app.options.show_task_pattern = // - @app.options.full_description = true @app.last_description = "COMMENT" @app.define_task(Rake::Task, "t") out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end @@ -319,7 +319,6 @@ def test_default_options opts = command_line assert_nil opts.classic_namespace assert_nil opts.dryrun - assert_nil opts.full_description assert_nil opts.ignore_system assert_nil opts.load_system assert_nil opts.nosearch @@ -345,16 +344,14 @@ def test_dry_run def test_describe flags('--describe') do |opts| - assert opts.full_description - assert opts.show_tasks + assert_equal :describe, opts.show_tasks assert_equal(//.to_s, opts.show_task_pattern.to_s) end end def test_describe_with_pattern flags('--describe=X') do |opts| - assert opts.full_description - assert opts.show_tasks + assert_equal :describe, opts.show_tasks assert_equal(/X/.to_s, opts.show_task_pattern.to_s) end end @@ -489,11 +486,11 @@ def test_trace_rules def test_tasks flags('--tasks', '-T') do |opts| - assert opts.show_tasks + assert_equal :tasks, opts.show_tasks assert_equal(//.to_s, opts.show_task_pattern.to_s) end flags(['--tasks', 'xyz'], ['-Txyz']) do |opts| - assert opts.show_tasks + assert_equal :tasks, opts.show_tasks assert_equal(/xyz/, opts.show_task_pattern) end end From d8090fd1c830042ba22d4cfad172fc0ca4e7a152 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Mon, 18 May 2009 08:16:56 -0400 Subject: [PATCH 0020/1389] Fixed tests for show_tasks changes. --- lib/rake/application.rb | 2 +- test/functional/session_based_tests.rb | 1 - test/lib/application_test.rb | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/rake/application.rb b/lib/rake/application.rb index a95d02482..dc12a4ad1 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -178,7 +178,7 @@ def display_tasks_and_comments displayable_tasks = tasks.select { |t| t.comment && t.name =~ options.show_task_pattern } - if options.show_task == :describe + if options.show_tasks == :describe displayable_tasks.each do |t| puts "#{name} #{t.name_with_args}" t.full_comment.split("\n").each do |line| diff --git a/test/functional/session_based_tests.rb b/test/functional/session_based_tests.rb index 9cf5c27db..2738a2fff 100644 --- a/test/functional/session_based_tests.rb +++ b/test/functional/session_based_tests.rb @@ -84,7 +84,6 @@ def test_long_description in_environment("PWD" => "test/data/multidesc") do rake "--describe" end - puts @out assert_match %r{^rake a\n *A / A2 *$}m, @out assert_match %r{^rake b\n *B *$}m, @out assert_match %r{^rake d\n *x{80}}m, @out diff --git a/test/lib/application_test.rb b/test/lib/application_test.rb index 5d2e50890..3cd4b9024 100644 --- a/test/lib/application_test.rb +++ b/test/lib/application_test.rb @@ -100,7 +100,7 @@ def test_display_tasks_with_long_comments_to_a_non_tty_with_columns_set_truncate end def test_describe_tasks - @app.options.show_task = :describe + @app.options.show_tasks = :describe @app.options.show_task_pattern = // @app.last_description = "COMMENT" @app.define_task(Rake::Task, "t") From 6f8b9a0ffce8ea889cb52d11869113ae5a9a6854 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Mon, 18 May 2009 08:23:37 -0400 Subject: [PATCH 0021/1389] Show tasks using :tasks --- lib/rake/application.rb | 7 +++++-- test/lib/application_test.rb | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/rake/application.rb b/lib/rake/application.rb index dc12a4ad1..094e2bbfc 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -178,7 +178,8 @@ def display_tasks_and_comments displayable_tasks = tasks.select { |t| t.comment && t.name =~ options.show_task_pattern } - if options.show_tasks == :describe + case options.show_tasks + when :describe displayable_tasks.each do |t| puts "#{name} #{t.name_with_args}" t.full_comment.split("\n").each do |line| @@ -186,13 +187,15 @@ def display_tasks_and_comments end puts end - else + when :tasks width = displayable_tasks.collect { |t| t.name_with_args.length }.max || 10 max_column = truncate_output? ? terminal_width - name.size - width - 7 : nil displayable_tasks.each do |t| printf "#{name} %-#{width}s # %s\n", t.name_with_args, max_column ? truncate(t.comment, max_column) : t.comment end + else + fail "Unknown show task mode: '#{options.show_tasks}'" end end diff --git a/test/lib/application_test.rb b/test/lib/application_test.rb index 3cd4b9024..b2ff8de3e 100644 --- a/test/lib/application_test.rb +++ b/test/lib/application_test.rb @@ -33,6 +33,7 @@ def test_constant_warning end def test_display_tasks + @app.options.show_tasks = :tasks @app.options.show_task_pattern = // @app.last_description = "COMMENT" @app.define_task(Rake::Task, "t") @@ -43,6 +44,7 @@ def test_display_tasks def test_display_tasks_with_long_comments in_environment('RAKE_COLUMNS' => '80') do + @app.options.show_tasks = :tasks @app.options.show_task_pattern = // @app.last_description = "1234567890" * 8 @app.define_task(Rake::Task, "t") @@ -54,6 +56,7 @@ def test_display_tasks_with_long_comments def test_display_tasks_with_task_name_wider_than_tty_display in_environment('RAKE_COLUMNS' => '80') do + @app.options.show_tasks = :tasks @app.options.show_task_pattern = // description = "something short" task_name = "task name" * 80 @@ -66,6 +69,7 @@ def test_display_tasks_with_task_name_wider_than_tty_display end def test_display_tasks_with_very_long_task_name_to_a_non_tty_shows_name_and_comment + @app.options.show_tasks = :tasks @app.options.show_task_pattern = // @app.tty_output = false description = "something short" @@ -78,6 +82,7 @@ def test_display_tasks_with_very_long_task_name_to_a_non_tty_shows_name_and_comm end def test_display_tasks_with_long_comments_to_a_non_tty_shows_entire_comment + @app.options.show_tasks = :tasks @app.options.show_task_pattern = // @app.tty_output = false @app.last_description = "1234567890" * 8 @@ -89,6 +94,7 @@ def test_display_tasks_with_long_comments_to_a_non_tty_shows_entire_comment def test_display_tasks_with_long_comments_to_a_non_tty_with_columns_set_truncates_comments in_environment("RAKE_COLUMNS" => '80') do + @app.options.show_tasks = :tasks @app.options.show_task_pattern = // @app.tty_output = false @app.last_description = "1234567890" * 8 From 4f6507e56fe0555bd67d690df4ec5c04416aa9ec Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Mon, 18 May 2009 08:28:42 -0400 Subject: [PATCH 0022/1389] Renamed tasks_test.rb to task_test.rb --- test/lib/{tasks_test.rb => task_test.rb} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/lib/{tasks_test.rb => task_test.rb} (100%) diff --git a/test/lib/tasks_test.rb b/test/lib/task_test.rb similarity index 100% rename from test/lib/tasks_test.rb rename to test/lib/task_test.rb From a483460a488b54a667b1ac24f82614ebfe44d963 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Mon, 18 May 2009 11:26:47 -0400 Subject: [PATCH 0023/1389] Added line number stuff (in progress) --- lib/rake/application.rb | 14 +++++++++----- lib/rake/task.rb | 5 +++++ test/lib/application_test.rb | 11 +++++++++++ test/lib/task_test.rb | 1 + 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/lib/rake/application.rb b/lib/rake/application.rb index 094e2bbfc..e599110c1 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -179,6 +179,13 @@ def display_tasks_and_comments t.comment && t.name =~ options.show_task_pattern } case options.show_tasks + when :tasks + width = displayable_tasks.collect { |t| t.name_with_args.length }.max || 10 + max_column = truncate_output? ? terminal_width - name.size - width - 7 : nil + displayable_tasks.each do |t| + printf "#{name} %-#{width}s # %s\n", + t.name_with_args, max_column ? truncate(t.comment, max_column) : t.comment + end when :describe displayable_tasks.each do |t| puts "#{name} #{t.name_with_args}" @@ -187,12 +194,9 @@ def display_tasks_and_comments end puts end - when :tasks - width = displayable_tasks.collect { |t| t.name_with_args.length }.max || 10 - max_column = truncate_output? ? terminal_width - name.size - width - 7 : nil + when :lines displayable_tasks.each do |t| - printf "#{name} %-#{width}s # %s\n", - t.name_with_args, max_column ? truncate(t.comment, max_column) : t.comment + puts "#{name} #{t.name_with_args} #{t.location}" end else fail "Unknown show task mode: '#{options.show_tasks}'" diff --git a/lib/rake/task.rb b/lib/rake/task.rb index 975421362..dd6f4d78d 100644 --- a/lib/rake/task.rb +++ b/lib/rake/task.rb @@ -29,6 +29,10 @@ class Task # Array of nested namespaces names used for task lookup by this task. attr_reader :scope + # File/Line location of the the task definition (only valid if the + # task was defined with the detect location option set). + attr_reader :location + # Return task name def to_s name @@ -62,6 +66,7 @@ def initialize(task_name, app) @application = app @scope = app.current_scope @arg_names = nil + @location = "" end # Enhance a task with prerequisites or actions. Returns self. diff --git a/test/lib/application_test.rb b/test/lib/application_test.rb index b2ff8de3e..7982f6b41 100644 --- a/test/lib/application_test.rb +++ b/test/lib/application_test.rb @@ -115,6 +115,17 @@ def test_describe_tasks assert_match(/^ {4}COMMENT$/, out) end + def test_show_lines + @app.options.show_tasks = :lines + @app.options.show_task_pattern = // + @app.last_description = "COMMENT" + @app.define_task(Rake::Task, "t") + out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end + puts out + assert_match(/^rake t$/, out) + assert_match(/^ {4}COMMENT$/, out) + end + def test_finding_rakefile assert_match(/Rakefile/i, @app.instance_eval { have_rakefile }) end diff --git a/test/lib/task_test.rb b/test/lib/task_test.rb index 8b424c5e9..e55fd0497 100644 --- a/test/lib/task_test.rb +++ b/test/lib/task_test.rb @@ -27,6 +27,7 @@ def test_create assert_equal t, arg assert_nil t.source assert_equal [], t.sources + assert_equal "", t.location end def test_inspect From 89bc2c1e04920bf34f2b6468e67e22538cbb4147 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Mon, 18 May 2009 19:16:31 -0400 Subject: [PATCH 0024/1389] Added line number recording to task definition. --- lib/rake/application.rb | 12 ++++++++++-- lib/rake/task.rb | 4 ++-- lib/rake/task_manager.rb | 29 +++++++++++++++++++++++++++-- test/lib/application_test.rb | 5 ++--- test/lib/task_test.rb | 3 ++- 5 files changed, 43 insertions(+), 10 deletions(-) diff --git a/lib/rake/application.rb b/lib/rake/application.rb index e599110c1..f1a558654 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -196,7 +196,9 @@ def display_tasks_and_comments end when :lines displayable_tasks.each do |t| - puts "#{name} #{t.name_with_args} #{t.location}" + t.locations.each do |loc| + printf "#{name} %-30s %s\n",t.name_with_args, loc + end end else fail "Unknown show task mode: '#{options.show_tasks}'" @@ -364,7 +366,13 @@ def standard_rake_options puts "rake, version #{RAKEVERSION}" exit } - ] + ], + ['--where', '-W [PATTERN]', "Describe the tasks (matching optional PATTERN), then exit.", + lambda { |value| + options.show_tasks = :lines + options.show_task_pattern = Regexp.new(value || '') + } + ], ] end diff --git a/lib/rake/task.rb b/lib/rake/task.rb index dd6f4d78d..cd4e5c9b1 100644 --- a/lib/rake/task.rb +++ b/lib/rake/task.rb @@ -31,7 +31,7 @@ class Task # File/Line location of the the task definition (only valid if the # task was defined with the detect location option set). - attr_reader :location + attr_reader :locations # Return task name def to_s @@ -66,7 +66,7 @@ def initialize(task_name, app) @application = app @scope = app.current_scope @arg_names = nil - @location = "" + @locations = [] end # Enhance a task with prerequisites or actions. Returns self. diff --git a/lib/rake/task_manager.rb b/lib/rake/task_manager.rb index 1ee08409d..adcf355a7 100644 --- a/lib/rake/task_manager.rb +++ b/lib/rake/task_manager.rb @@ -29,7 +29,9 @@ def define_task(task_class, *args, &block) task.set_arg_names(arg_names) unless arg_names.empty? task.add_description(get_description) task.enhance(deps, &block) - task + with_location { + task + } end # Lookup a task. Return an existing task if found, otherwise @@ -205,7 +207,30 @@ def in_namespace(name) end private - + + # Add a location to the locations field of the yield object. + def with_location + result = yield + loc = find_location + result.locations << loc if loc + result + end + + # Find the location that called into the dsl layer. + def find_location + begin + raise StandardError.new + rescue StandardError => ex + locations = ex.backtrace + i = 0 + while locations[i] + return locations[i+1] if locations[i] =~ /rake\/dsl.rb/ + i += 1 + end + end + nil + end + # Generate an anonymous namespace name. def generate_name @seed ||= 0 diff --git a/test/lib/application_test.rb b/test/lib/application_test.rb index 7982f6b41..5a9dd873b 100644 --- a/test/lib/application_test.rb +++ b/test/lib/application_test.rb @@ -120,10 +120,9 @@ def test_show_lines @app.options.show_task_pattern = // @app.last_description = "COMMENT" @app.define_task(Rake::Task, "t") + @app['t'].locations << "HERE:1" out = capture_stdout do @app.instance_eval { display_tasks_and_comments } end - puts out - assert_match(/^rake t$/, out) - assert_match(/^ {4}COMMENT$/, out) + assert_match(/^rake t +[^:]+:\d+ *$/, out) end def test_finding_rakefile diff --git a/test/lib/task_test.rb b/test/lib/task_test.rb index e55fd0497..66a45425b 100644 --- a/test/lib/task_test.rb +++ b/test/lib/task_test.rb @@ -27,7 +27,8 @@ def test_create assert_equal t, arg assert_nil t.source assert_equal [], t.sources - assert_equal "", t.location + assert_equal 1, t.locations.size + assert_match(/#{Regexp.quote(__FILE__)}/, t.locations.first) end def test_inspect From 85421510ea6dd3fff69493822ae3bf6778b49c9f Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Mon, 18 May 2009 23:52:54 -0400 Subject: [PATCH 0025/1389] Updated changes file. --- CHANGES | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES b/CHANGES index 54af6b679..38097a92f 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,8 @@ * Split rake.rb into individual files. +* Support for the --where (-W) flag for showing where a task is defined. + == Version 0.8.7 * Fixed EXEEXT for JRuby on windows. From 62c0ae202b123fd743262c5d37cd900f62441555 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Mon, 18 May 2009 23:56:43 -0400 Subject: [PATCH 0026/1389] Removed unused dbg task --- Rakefile | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Rakefile b/Rakefile index 5ded82ac9..e9335ebea 100644 --- a/Rakefile +++ b/Rakefile @@ -50,9 +50,6 @@ desc "Default Task" task :default => "test:all" # Test Tasks --------------------------------------------------------- -task :dbg do |t| - puts "Arguments are: #{t.args.join(', ')}" -end # Common Abbreviations ... @@ -291,11 +288,6 @@ task :todo do RUBY_FILES.egrep(/#.*(FIXME|TODO|TBD)/) end -desc "Look for Debugging print lines" -task :dbg do - RUBY_FILES.egrep(/\bDBG|\bbreakpoint\b/) -end - desc "List all ruby files" task :rubyfiles do puts RUBY_FILES From 0227ed75c86b1a062016933b6935220da03c754e Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Tue, 19 May 2009 11:28:31 -0400 Subject: [PATCH 0027/1389] Extracted method display_error_message (more readable and make customization easier). --- lib/rake/application.rb | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/rake/application.rb b/lib/rake/application.rb index f1a558654..fa4c3c21a 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -131,18 +131,23 @@ def standard_exception_handling exit(false) rescue Exception => ex # Exit with error message - $stderr.puts "#{name} aborted!" - $stderr.puts ex.message - if options.trace - $stderr.puts ex.backtrace.join("\n") - else - $stderr.puts ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || "" - $stderr.puts "(See full trace by running task with --trace)" - end + display_error_message(ex) exit(false) end end + # Display the error message that caused the exception. + def display_error_message(ex) + $stderr.puts "#{name} aborted!" + $stderr.puts ex.message + if options.trace + $stderr.puts ex.backtrace.join("\n") + else + $stderr.puts ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || "" + $stderr.puts "(See full trace by running task with --trace)" + end + end + # True if one of the files in RAKEFILES is in the current directory. # If a match is found, it is copied into @rakefile. def have_rakefile From 23e98af2e2a387617559a849d9dec4787eca84b5 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Sun, 24 May 2009 17:04:24 -0400 Subject: [PATCH 0028/1389] Added some DSL tests. --- lib/rake/dsl.rb | 5 +++++ test/lib/dsl_test.rb | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 test/lib/dsl_test.rb diff --git a/lib/rake/dsl.rb b/lib/rake/dsl.rb index 59604c94c..fdefdb02a 100644 --- a/lib/rake/dsl.rb +++ b/lib/rake/dsl.rb @@ -71,6 +71,11 @@ def multitask(args, &block) # task_run = ns[:run] # find :run in the given namespace. # def namespace(name=nil, &block) + name = name.to_s if name.kind_of?(Symbol) + name = name.to_str if name.respond_to?(:to_str) + unless name.kind_of?(String) + raise ArgumentError, "Expected a String or Symbol for a namespace name" + end Rake.application.in_namespace(name, &block) end diff --git a/test/lib/dsl_test.rb b/test/lib/dsl_test.rb new file mode 100644 index 000000000..8f3a02215 --- /dev/null +++ b/test/lib/dsl_test.rb @@ -0,0 +1,40 @@ +#!/usr/bin/env ruby + +begin + require 'rubygems' +rescue LoadError + # got no gems +end + +require 'test/unit' +require 'flexmock/test_unit' +require 'rake' +require 'test/rake_test_setup' + +class DslTest < Test::Unit::TestCase + def test_namespace_command + namespace "n" do + task "t" + end + assert_not_nil Rake::Task["n:t"] + end + + def test_namespace_command_with_bad_name + ex = assert_raise(ArgumentError) do + namespace 1 do end + end + assert_match(/string/i, ex.message) + assert_match(/symbol/i, ex.message) + end + + def test_namespace_command_with_a_string_like_object + name = Object.new + def name.to_str + "bob" + end + namespace name do + task "t" + end + assert_not_nil Rake::Task["bob:t"] + end +end From 43ea847a157e487dc418c40d6849429f174a8c97 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Sun, 24 May 2009 17:04:47 -0400 Subject: [PATCH 0029/1389] Moved tags task to a separate file. --- Rakefile | 10 ---------- rakelib/tags.rake | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 rakelib/tags.rake diff --git a/Rakefile b/Rakefile index e9335ebea..53d16029e 100644 --- a/Rakefile +++ b/Rakefile @@ -295,16 +295,6 @@ task :rubyfiles do end task :rf => :rubyfiles -desc "Create a TAGS file" -task :tags => "TAGS" - -TAGS = 'xctags -e' - -file "TAGS" => RUBY_FILES do - puts "Makings TAGS" - sh "#{TAGS} #{RUBY_FILES}", :verbose => false -end - # -------------------------------------------------------------------- # Creating a release diff --git a/rakelib/tags.rake b/rakelib/tags.rake new file mode 100644 index 000000000..b49e31563 --- /dev/null +++ b/rakelib/tags.rake @@ -0,0 +1,18 @@ +#!/usr/bin/env ruby + +module Tags + PROG = ENV['TAGS'] || 'ctags' + RUBY_FILES = FileList['**/*.rb'] + RUBY_FILES.include('**/*.rake') +end + +namespace "tags" do + desc "Generate an Emacs TAGS file" + task :emacs => Tags::RUBY_FILES do + puts "Making Emacs TAGS file" + sh "#{Tags::PROG} -e #{Tags::RUBY_FILES}", :verbose => false + end +end + +desc "Generate the TAGS file" +task :tags => ["tags:emacs"] From 5a9fe7ba4e8147b47b00c282f9f03fb05b2ddfe5 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Sun, 24 May 2009 18:04:51 -0400 Subject: [PATCH 0030/1389] Allow namespaces to be nil. --- lib/rake/dsl.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rake/dsl.rb b/lib/rake/dsl.rb index fdefdb02a..131b42b13 100644 --- a/lib/rake/dsl.rb +++ b/lib/rake/dsl.rb @@ -73,7 +73,7 @@ def multitask(args, &block) def namespace(name=nil, &block) name = name.to_s if name.kind_of?(Symbol) name = name.to_str if name.respond_to?(:to_str) - unless name.kind_of?(String) + unless name.kind_of?(String) || name.nil? raise ArgumentError, "Expected a String or Symbol for a namespace name" end Rake.application.in_namespace(name, &block) From 89f693785e200ce2c369109a54ea3bca38f42b4d Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Sun, 24 May 2009 17:58:09 -0400 Subject: [PATCH 0031/1389] Attempting to fix quotes in test runner. --- lib/rake/testtask.rb | 31 ++++++++++++++++++------------- test/lib/testtask_test.rb | 38 ++++++++++++++++++++++++++++++++++++++ test/test_helper.rb | 9 +++++++++ 3 files changed, 65 insertions(+), 13 deletions(-) create mode 100644 test/lib/testtask_test.rb create mode 100644 test/test_helper.rb diff --git a/lib/rake/testtask.rb b/lib/rake/testtask.rb index 4bc32aacf..64d8ce276 100644 --- a/lib/rake/testtask.rb +++ b/lib/rake/testtask.rb @@ -98,21 +98,11 @@ def define lib_path = @libs.join(File::PATH_SEPARATOR) desc "Run tests" + (@name==:test ? "" : " for #{@name}") task @name do - run_code = '' RakeFileUtils.verbose(@verbose) do - run_code = - case @loader - when :direct - "-e 'ARGV.each{|f| load f}'" - when :testrb - "-S testrb #{fix}" - when :rake - rake_loader - end @ruby_opts.unshift( "-I\"#{lib_path}\"" ) @ruby_opts.unshift( "-w" ) if @warning ruby @ruby_opts.join(" ") + - " \"#{run_code}\" " + + " #{run_code} " + file_list.collect { |fn| "\"#{fn}\"" }.join(' ') + " #{option_list}" end @@ -136,14 +126,29 @@ def file_list # :nodoc: end def fix # :nodoc: - case RUBY_VERSION + case ruby_version when '1.8.2' - find_file 'rake/ruby182_test_unit_fix' + "'#{find_file 'rake/ruby182_test_unit_fix'}'" else nil end || '' end + def ruby_version + RUBY_VERSION + end + + def run_code + case @loader + when :direct + "-e 'ARGV.each{|f| load f}'" + when :testrb + "-S testrb #{fix}" + when :rake + "'#{rake_loader}'" + end + end + def rake_loader # :nodoc: find_file('rake/rake_test_loader') or fail "unable to find rake test loader" diff --git a/test/lib/testtask_test.rb b/test/lib/testtask_test.rb new file mode 100644 index 000000000..582d7bc62 --- /dev/null +++ b/test/lib/testtask_test.rb @@ -0,0 +1,38 @@ +require 'test/test_helper' +require 'rake/testtask' + +class TestTaskTest < Test::Unit::TestCase + def test_create + test_task = Rake::TestTask.new(:tx) + end + + def test_direct_run_has_quoted_paths + test_task = Rake::TestTask.new(:tx) do |t| + t.loader = :direct + end + assert_match(/-e '.*'/, test_task.run_code) + end + + def test_testrb_run_has_quoted_paths_on_ruby_182 + test_task = Rake::TestTask.new(:tx) do |t| + t.loader = :testrb + end + flexmock(test_task).should_receive(:ruby_version).and_return('1.8.2') + assert_match(/^-S testrb +'.*'$/, test_task.run_code) + end + + def test_testrb_run_has_quoted_paths_on_ruby_186 + test_task = Rake::TestTask.new(:tx) do |t| + t.loader = :testrb + end + flexmock(test_task).should_receive(:ruby_version).and_return('1.8.6') + assert_match(/^-S testrb +$/, test_task.run_code) + end + + def test_rake_run_has_quoted_paths + test_task = Rake::TestTask.new(:tx) do |t| + t.loader = :rake + end + assert_match(/'.*'/, test_task.run_code) + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 000000000..55ef8933f --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,9 @@ +begin + require 'rubygems' +rescue LoadError => ex + # No rubygems available +end +require 'test/unit' +require 'flexmock/test_unit' + +require 'rake' From 87e39db55c40cc7e1b005fdddcc3158e17b63513 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Sun, 24 May 2009 18:12:52 -0400 Subject: [PATCH 0032/1389] Updated quoted paths in test task code to use double quotes. --- Rakefile | 52 +++++++++++++++++++-------------------- lib/rake/testtask.rb | 6 ++--- test/lib/testtask_test.rb | 10 +++----- 3 files changed, 32 insertions(+), 36 deletions(-) diff --git a/Rakefile b/Rakefile index 53d16029e..c4fef93c6 100644 --- a/Rakefile +++ b/Rakefile @@ -61,32 +61,32 @@ task :test => "test:units" namespace :test do Rake::TestTask.new(:all) do |t| - t.test_files = FileList[ - 'test/lib/*_test.rb', - 'test/contrib/*_test.rb', - 'test/functional/*_test.rb' - ] - t.warning = true - t.verbose = false -end - -Rake::TestTask.new(:units) do |t| - t.test_files = FileList['test/lib/*_test.rb'] - t.warning = true - t.verbose = false -end - -Rake::TestTask.new(:functional) do |t| - t.test_files = FileList['test/functional/*_test.rb'] - t.warning = true - t.verbose = false -end - -Rake::TestTask.new(:contribs) do |t| - t.test_files = FileList['test/contrib/test*.rb'] - t.warning = true - t.verbose = false -end + t.test_files = FileList[ + 'test/lib/*_test.rb', + 'test/contrib/*_test.rb', + 'test/functional/*_test.rb' + ] + t.warning = true + t.verbose = false + end + + Rake::TestTask.new(:units) do |t| + t.test_files = FileList['test/lib/*_test.rb'] + t.warning = true + t.verbose = false + end + + Rake::TestTask.new(:functional) do |t| + t.test_files = FileList['test/functional/*_test.rb'] + t.warning = true + t.verbose = false + end + + Rake::TestTask.new(:contribs) do |t| + t.test_files = FileList['test/contrib/test*.rb'] + t.warning = true + t.verbose = false + end end begin diff --git a/lib/rake/testtask.rb b/lib/rake/testtask.rb index 64d8ce276..a8c3cbfb5 100644 --- a/lib/rake/testtask.rb +++ b/lib/rake/testtask.rb @@ -128,7 +128,7 @@ def file_list # :nodoc: def fix # :nodoc: case ruby_version when '1.8.2' - "'#{find_file 'rake/ruby182_test_unit_fix'}'" + "\"#{find_file 'rake/ruby182_test_unit_fix'}\"" else nil end || '' @@ -141,11 +141,11 @@ def ruby_version def run_code case @loader when :direct - "-e 'ARGV.each{|f| load f}'" + "-e \"ARGV.each{|f| load f}\"" when :testrb "-S testrb #{fix}" when :rake - "'#{rake_loader}'" + "\"#{rake_loader}\"" end end diff --git a/test/lib/testtask_test.rb b/test/lib/testtask_test.rb index 582d7bc62..d5205bfd6 100644 --- a/test/lib/testtask_test.rb +++ b/test/lib/testtask_test.rb @@ -2,15 +2,11 @@ require 'rake/testtask' class TestTaskTest < Test::Unit::TestCase - def test_create - test_task = Rake::TestTask.new(:tx) - end - def test_direct_run_has_quoted_paths test_task = Rake::TestTask.new(:tx) do |t| t.loader = :direct end - assert_match(/-e '.*'/, test_task.run_code) + assert_match(/-e ".*"/, test_task.run_code) end def test_testrb_run_has_quoted_paths_on_ruby_182 @@ -18,7 +14,7 @@ def test_testrb_run_has_quoted_paths_on_ruby_182 t.loader = :testrb end flexmock(test_task).should_receive(:ruby_version).and_return('1.8.2') - assert_match(/^-S testrb +'.*'$/, test_task.run_code) + assert_match(/^-S testrb +".*"$/, test_task.run_code) end def test_testrb_run_has_quoted_paths_on_ruby_186 @@ -33,6 +29,6 @@ def test_rake_run_has_quoted_paths test_task = Rake::TestTask.new(:tx) do |t| t.loader = :rake end - assert_match(/'.*'/, test_task.run_code) + assert_match(/".*"/, test_task.run_code) end end From 652b3f40d5b07ed82962ea39733e4709d858c0f0 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Sun, 24 May 2009 18:17:32 -0400 Subject: [PATCH 0033/1389] Updated changes (fixed http://onestepback.org/redmine/issues/show/44) --- CHANGES | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES b/CHANGES index 38097a92f..fd5bc6a72 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,9 @@ * Split rake.rb into individual files. +* Fixed quoting in test task + (http://onestepback.org/redmine/issues/show/44) + * Support for the --where (-W) flag for showing where a task is defined. == Version 0.8.7 From c7a92d53e57c585c1f6eea00513b4ad233c5315b Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Sun, 24 May 2009 18:30:07 -0400 Subject: [PATCH 0034/1389] Testing that invalid options errors are printed. --- CHANGES | 4 ++-- lib/rake/application.rb | 2 +- test/functional/session_based_tests.rb | 9 ++++++++- test/lib/application_test.rb | 3 ++- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index fd5bc6a72..d36d4afaa 100644 --- a/CHANGES +++ b/CHANGES @@ -7,11 +7,11 @@ * Split rake.rb into individual files. +* Support for the --where (-W) flag for showing where a task is defined. + * Fixed quoting in test task (http://onestepback.org/redmine/issues/show/44) -* Support for the --where (-W) flag for showing where a task is defined. - == Version 0.8.7 * Fixed EXEEXT for JRuby on windows. diff --git a/lib/rake/application.rb b/lib/rake/application.rb index fa4c3c21a..bc94c35cc 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -127,7 +127,7 @@ def standard_exception_handling # Exit silently with current status raise rescue OptionParser::InvalidOption => ex - # Exit silently + $stderr.puts ex.message exit(false) rescue Exception => ex # Exit with error message diff --git a/test/functional/session_based_tests.rb b/test/functional/session_based_tests.rb index 2738a2fff..070fe9924 100644 --- a/test/functional/session_based_tests.rb +++ b/test/functional/session_based_tests.rb @@ -23,7 +23,7 @@ def initialize(*args) end end -class FunctionalTest < Test::Unit::TestCase +class SessionBasedTests < Test::Unit::TestCase include InEnvironment include TestMethods @@ -156,6 +156,13 @@ def test_nosearch_without_rakefile_and_no_system_fails assert_match %r{^No Rakefile found}, @err end + def test_invalid_command_line_options + in_environment("PWD" => "test/data/default") do + rake "--bad-options" + end + assert_match %r{invalid +option}i, @err + end + def test_dry_run in_environment("PWD" => "test/data/default") do rake "-n", "other" end assert_match %r{Execute \(dry run\) default}, @out diff --git a/test/lib/application_test.rb b/test/lib/application_test.rb index 5a9dd873b..fb3add110 100644 --- a/test/lib/application_test.rb +++ b/test/lib/application_test.rb @@ -538,7 +538,7 @@ def test_classic_namespace end def test_bad_option - capture_stderr do + error_output = capture_stderr do ex = assert_exception(OptionParser::InvalidOption) do flags('--bad-option') end @@ -549,6 +549,7 @@ def test_bad_option assert_match(/--bad-option/, ex.message) end end + assert_equal '', error_output end def test_task_collection From 762e6c5c6d3350c2719b29eb3b4be909b6363492 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Sun, 24 May 2009 18:34:19 -0400 Subject: [PATCH 0035/1389] Updated changes (http://onestepback.org/redmine/issues/show/47) --- CHANGES | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index d36d4afaa..3a192f774 100644 --- a/CHANGES +++ b/CHANGES @@ -9,9 +9,12 @@ * Support for the --where (-W) flag for showing where a task is defined. -* Fixed quoting in test task +* Fixed quoting in test task. (http://onestepback.org/redmine/issues/show/44) +* Fixed the silent option parsing problem. + (http://onestepback.org/redmine/issues/show/47) + == Version 0.8.7 * Fixed EXEEXT for JRuby on windows. From 6afd6faeee1c39868748f2b8f001e6d627919b49 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Sun, 24 May 2009 22:45:48 -0400 Subject: [PATCH 0036/1389] Fixed problem with :verbose=>false in sh and ruby commands (http://onestepback.org/redmine/issues/show/52). Updated tests to cover all scenarios. --- CHANGES | 2 ++ lib/rake/file_utils.rb | 4 +-- rakelib/tags.rake | 2 +- test/data/verbose/Rakefile | 34 ++++++++++++++++++ test/functional/session_based_tests.rb | 49 ++++++++++++++++++++++++++ 5 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 test/data/verbose/Rakefile diff --git a/CHANGES b/CHANGES index 3a192f774..20b34391b 100644 --- a/CHANGES +++ b/CHANGES @@ -15,6 +15,8 @@ * Fixed the silent option parsing problem. (http://onestepback.org/redmine/issues/show/47) +* Fixed :verbose=>false flag on sh and ruby commands. + == Version 0.8.7 * Fixed EXEEXT for JRuby on windows. diff --git a/lib/rake/file_utils.rb b/lib/rake/file_utils.rb index 4454f7806..11b2912bc 100644 --- a/lib/rake/file_utils.rb +++ b/lib/rake/file_utils.rb @@ -37,9 +37,9 @@ def sh(*cmd, &block) ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]" } end - if RakeFileUtils.verbose_flag == :default + if RakeFileUtils.verbose_flag == :default && options[:verbose].nil? options[:verbose] = true - else + elsif options[:verbose].nil? options[:verbose] ||= RakeFileUtils.verbose_flag end options[:noop] ||= RakeFileUtils.nowrite_flag diff --git a/rakelib/tags.rake b/rakelib/tags.rake index b49e31563..d1e11291e 100644 --- a/rakelib/tags.rake +++ b/rakelib/tags.rake @@ -2,7 +2,7 @@ module Tags PROG = ENV['TAGS'] || 'ctags' - RUBY_FILES = FileList['**/*.rb'] + RUBY_FILES = FileList['**/*.rb'].exclude('sys.rb') RUBY_FILES.include('**/*.rake') end diff --git a/test/data/verbose/Rakefile b/test/data/verbose/Rakefile new file mode 100644 index 000000000..08b19b9dd --- /dev/null +++ b/test/data/verbose/Rakefile @@ -0,0 +1,34 @@ + +task :standalone_verbose_true do + verbose true + sh "ruby -e '0'" +end + +task :standalone_verbose_false do + verbose false + sh "ruby -e '0'" +end + +task :inline_verbose_default do + sh "ruby -e '0'" +end + +task :inline_verbose_false do + sh "ruby -e '0'", :verbose => false +end + +task :inline_verbose_true do + sh "ruby -e '0'", :verbose => true +end + +task :block_verbose_true do + verbose(true) do + sh "ruby -e '0'" + end +end + +task :block_verbose_false do + verbose(false) do + sh "ruby -e '0'" + end +end diff --git a/test/functional/session_based_tests.rb b/test/functional/session_based_tests.rb index 070fe9924..1a80dd6e0 100644 --- a/test/functional/session_based_tests.rb +++ b/test/functional/session_based_tests.rb @@ -163,6 +163,55 @@ def test_invalid_command_line_options assert_match %r{invalid +option}i, @err end + def test_inline_verbose_default_should_show_command + in_environment("PWD" => "test/data/verbose") do + rake "inline_verbose_default" + end + assert_match(/ruby -e/, @err) + end + + def test_inline_verbose_true_should_show_command + in_environment("PWD" => "test/data/verbose") do + rake "inline_verbose_true" + end + assert_match(/ruby -e/, @err) + end + + def test_inline_verbose_false_should_not_show_command + in_environment("PWD" => "test/data/verbose") do + rake "inline_verbose_false" + end + assert_no_match(/ruby -e/, @err) + end + + def test_block_verbose_false_should_not_show_command + in_environment("PWD" => "test/data/verbose") do + rake "block_verbose_false" + end + assert_no_match(/ruby -e/, @err) + end + + def test_block_verbose_true_should_show_command + in_environment("PWD" => "test/data/verbose") do + rake "block_verbose_true" + end + assert_match(/ruby -e/, @err) + end + + def test_standalone_verbose_true_should_show_command + in_environment("PWD" => "test/data/verbose") do + rake "standalone_verbose_true" + end + assert_match(/ruby -e/, @err) + end + + def test_standalone_verbose_false_should_not_show_command + in_environment("PWD" => "test/data/verbose") do + rake "standalone_verbose_false" + end + assert_no_match(/ruby -e/, @err) + end + def test_dry_run in_environment("PWD" => "test/data/default") do rake "-n", "other" end assert_match %r{Execute \(dry run\) default}, @out From 34ddd30fa9716202b6e3e02e26038045c458aade Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Sun, 24 May 2009 22:57:29 -0400 Subject: [PATCH 0037/1389] Pulled verbose calculation into its own private method in file_utils. --- lib/rake/file_utils.rb | 15 ++++++++++----- lib/rake/rake_file_utils.rb | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/rake/file_utils.rb b/lib/rake/file_utils.rb index 11b2912bc..09da77c62 100644 --- a/lib/rake/file_utils.rb +++ b/lib/rake/file_utils.rb @@ -37,11 +37,7 @@ def sh(*cmd, &block) ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]" } end - if RakeFileUtils.verbose_flag == :default && options[:verbose].nil? - options[:verbose] = true - elsif options[:verbose].nil? - options[:verbose] ||= RakeFileUtils.verbose_flag - end + set_verbose_option(options) options[:noop] ||= RakeFileUtils.nowrite_flag rake_check_options options, :noop, :verbose rake_output_message cmd.join(" ") if options[:verbose] @@ -53,6 +49,15 @@ def sh(*cmd, &block) end end + def set_verbose_option(options) + if RakeFileUtils.verbose_flag.nil? && options[:verbose].nil? + options[:verbose] = true + elsif options[:verbose].nil? + options[:verbose] ||= RakeFileUtils.verbose_flag + end + end + private :set_verbose_option + def rake_system(*cmd) Rake::AltSystem.system(*cmd) end diff --git a/lib/rake/rake_file_utils.rb b/lib/rake/rake_file_utils.rb index a4036cc8f..c1d88c049 100644 --- a/lib/rake/rake_file_utils.rb +++ b/lib/rake/rake_file_utils.rb @@ -10,7 +10,7 @@ module RakeFileUtils class << self attr_accessor :verbose_flag, :nowrite_flag end - RakeFileUtils.verbose_flag = :default + RakeFileUtils.verbose_flag = nil RakeFileUtils.nowrite_flag = false $fileutils_verbose = true From 5f525246d044c483002cc55930d42a40faca07d5 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Sun, 24 May 2009 23:05:59 -0400 Subject: [PATCH 0038/1389] Refactoring the sh command a bit. --- lib/rake/file_utils.rb | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/rake/file_utils.rb b/lib/rake/file_utils.rb index 09da77c62..e735a2e3b 100644 --- a/lib/rake/file_utils.rb +++ b/lib/rake/file_utils.rb @@ -29,16 +29,9 @@ module FileUtils # def sh(*cmd, &block) options = (Hash === cmd.last) ? cmd.pop : {} - unless block_given? - show_command = cmd.join(" ") - show_command = show_command[0,42] + "..." unless $trace - # TODO code application logic heref show_command.length > 45 - block = lambda { |ok, status| - ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]" - } - end + block = create_shell_command(cmd) unless block_given? set_verbose_option(options) - options[:noop] ||= RakeFileUtils.nowrite_flag + options[:noop] ||= RakeFileUtils.nowrite_flag rake_check_options options, :noop, :verbose rake_output_message cmd.join(" ") if options[:verbose] unless options[:noop] @@ -49,11 +42,17 @@ def sh(*cmd, &block) end end + def create_shell_command(cmd) + show_command = cmd.join(" ") + show_command = show_command[0,42] + "..." unless $trace + block = lambda { |ok, status| + ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]" + } + end + def set_verbose_option(options) - if RakeFileUtils.verbose_flag.nil? && options[:verbose].nil? - options[:verbose] = true - elsif options[:verbose].nil? - options[:verbose] ||= RakeFileUtils.verbose_flag + if options[:verbose].nil? + options[:verbose] = RakeFileUtils.verbose_flag.nil? || RakeFileUtils.verbose_flag end end private :set_verbose_option From 2865311c66078d6b2b334413c7d7f7d99653e5dd Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Sun, 24 May 2009 23:12:32 -0400 Subject: [PATCH 0039/1389] Changed nomenclature from shell_command to shell_runner. --- lib/rake/file_utils.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/rake/file_utils.rb b/lib/rake/file_utils.rb index e735a2e3b..bcf81b00b 100644 --- a/lib/rake/file_utils.rb +++ b/lib/rake/file_utils.rb @@ -29,7 +29,7 @@ module FileUtils # def sh(*cmd, &block) options = (Hash === cmd.last) ? cmd.pop : {} - block = create_shell_command(cmd) unless block_given? + shell_runner = block_given? ? block : create_shell_runner(cmd) set_verbose_option(options) options[:noop] ||= RakeFileUtils.nowrite_flag rake_check_options options, :noop, :verbose @@ -38,17 +38,18 @@ def sh(*cmd, &block) res = rake_system(*cmd) status = $? status = PseudoStatus.new(1) if !res && status.nil? - block.call(res, status) + shell_runner.call(res, status) end end - def create_shell_command(cmd) + def create_shell_runner(cmd) show_command = cmd.join(" ") show_command = show_command[0,42] + "..." unless $trace block = lambda { |ok, status| ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]" } end + private :create_shell_runner def set_verbose_option(options) if options[:verbose].nil? From 9cbc5a6640471f1fa257b6f71430615b72e84040 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Mon, 25 May 2009 07:45:23 -0400 Subject: [PATCH 0040/1389] Documentation update. --- README => README.rdoc | 0 Rakefile | 4 ++-- lib/rake/ruby182_test_unit_fix.rb | 16 +++++++++------- 3 files changed, 11 insertions(+), 9 deletions(-) rename README => README.rdoc (100%) diff --git a/README b/README.rdoc similarity index 100% rename from README rename to README.rdoc diff --git a/Rakefile b/Rakefile index c4fef93c6..5964a4650 100644 --- a/Rakefile +++ b/Rakefile @@ -136,7 +136,7 @@ end BASE_RDOC_OPTIONS = [ '--line-numbers', '--inline-source', - '--main' , 'README', + '--main' , 'README.rdoc', '--title', 'Rake -- Ruby Make' ] @@ -147,7 +147,7 @@ rd = Rake::RDocTask.new("rdoc") do |rdoc| rdoc.options = BASE_RDOC_OPTIONS.dup rdoc.options << '-SHN' << '-f' << 'darkfish' if DARKFISH_ENABLED - rdoc.rdoc_files.include('README', 'MIT-LICENSE', 'TODO', 'CHANGES') + rdoc.rdoc_files.include('README.rdoc', 'MIT-LICENSE', 'TODO', 'CHANGES') rdoc.rdoc_files.include('lib/**/*.rb', 'doc/**/*.rdoc') rdoc.rdoc_files.exclude(/\bcontrib\b/) end diff --git a/lib/rake/ruby182_test_unit_fix.rb b/lib/rake/ruby182_test_unit_fix.rb index f02c7879e..9e411ed51 100755 --- a/lib/rake/ruby182_test_unit_fix.rb +++ b/lib/rake/ruby182_test_unit_fix.rb @@ -1,10 +1,13 @@ -module Test - module Unit - module Collector - class Dir +# Local Rake override to fix bug in Ruby 0.8.2 +module Test # :nodoc: + # Local Rake override to fix bug in Ruby 0.8.2 + module Unit # :nodoc: + # Local Rake override to fix bug in Ruby 0.8.2 + module Collector # :nodoc: + # Local Rake override to fix bug in Ruby 0.8.2 + class Dir # :nodoc: undef collect_file - def collect_file(name, suites, already_gathered) - # loadpath = $:.dup + def collect_file(name, suites, already_gathered) # :nodoc: dir = File.dirname(File.expand_path(name)) $:.unshift(dir) unless $:.first == dir if(@req) @@ -14,7 +17,6 @@ def collect_file(name, suites, already_gathered) end find_test_cases(already_gathered).each{|t| add_suite(suites, t.suite)} ensure - # $:.replace(loadpath) $:.delete_at $:.rindex(dir) end end From 9224cf9b741d585555587d193219d65b634590d0 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Mon, 25 May 2009 07:55:17 -0400 Subject: [PATCH 0041/1389] Updated docs to reflect the task argument / environment variable matchup. --- doc/rakefile.rdoc | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/doc/rakefile.rdoc b/doc/rakefile.rdoc index ddaccd9ac..099858008 100644 --- a/doc/rakefile.rdoc +++ b/doc/rakefile.rdoc @@ -183,6 +183,22 @@ argument string should be quoted. Something like this: (Quoting rules vary between operating systems and shells, so make sure you consult the proper docs for your OS/shell). +=== Tasks Arguments and the Environment + +Task argument values can also be picked up from the environment. For +example, if the "release" task expected a parameter named +"release_version", then either + + rake release[0.8.2] + +or + + RELEASE_VERSION rake release + +will work. Environment variable names must either match the task +parameter exactly, or match an all uppcase version of the task +parameter. + === Tasks that Expect Parameters Parameters are only given to tasks that are setup to expect them. In @@ -210,7 +226,8 @@ The first argument of the block "t" is always bound to the current task object. The second argument "args" is an open-struct like object that allows access to the task arguments. Extra command line arguments to a task are ignored. Missing command line arguments are -given the nil value. +picked up from matching environment variables. If there are no +matching environment variables, they are given the nil value. If you wish to specify default values for the arguments, you can use the with_defaults method in the task body. Here is the above example @@ -239,7 +256,8 @@ for tasks with arguments. For example: There is an older format for declaring task parameters that omitted the task argument array and used the :needs keyword to introduce the dependencies. That format is still supported for compatibility, but -is not recommended for use. +is not recommended for use. The older format may be dropped in future +versions of rake. == Accessing Task Programatically From 1261da8342eb748d2bcae4ee1390548231142d23 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Mon, 25 May 2009 07:56:54 -0400 Subject: [PATCH 0042/1389] Updated rake version in Rakefile documentation. --- doc/rakefile.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/rakefile.rdoc b/doc/rakefile.rdoc index 099858008..61f3d4d73 100644 --- a/doc/rakefile.rdoc +++ b/doc/rakefile.rdoc @@ -1,4 +1,4 @@ -= Rakefile Format (as of version 0.8.3) += Rakefile Format (as of version 0.8.7) First of all, there is no special format for a Rakefile. A Rakefile contains executable Ruby code. Anything legal in a ruby script is From 18ba9053346b827f460c4369959379eeb0c80fba Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Mon, 25 May 2009 08:02:39 -0400 Subject: [PATCH 0043/1389] More document tweaks. --- README.rdoc | 2 -- doc/rakefile.rdoc | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/README.rdoc b/README.rdoc index ea2860aad..ed1e8eb1c 100644 --- a/README.rdoc +++ b/README.rdoc @@ -89,7 +89,6 @@ Type "rake --help" for all available options. * For a glossary of terms, see doc/glossary.rdoc[http://rake.rubyforge.org/files/doc/glossary_rdoc.html]. - == Development === Source Repository @@ -120,7 +119,6 @@ You will need an account to before you can post issues. Register at http://onestepback.org/redmine/account/register. Or you can send me an email (at jim dot weirich at gmail dot com) - == Online Resources === Rake References diff --git a/doc/rakefile.rdoc b/doc/rakefile.rdoc index 61f3d4d73..b84c2ddbe 100644 --- a/doc/rakefile.rdoc +++ b/doc/rakefile.rdoc @@ -563,4 +563,4 @@ This is the proper way to specify the task ... == See -* README -- Main documentation for Rake. +* README.rdoc -- Main documentation for Rake. From dcd95c47fc766ec89cdaabb1644cf122b577cdfe Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Mon, 25 May 2009 08:04:21 -0400 Subject: [PATCH 0044/1389] Update test that reference README. --- test/lib/task_manager_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/lib/task_manager_test.rb b/test/lib/task_manager_test.rb index 2b3731625..37ed85bb5 100644 --- a/test/lib/task_manager_test.rb +++ b/test/lib/task_manager_test.rb @@ -65,8 +65,8 @@ def test_namespace_yields_same_namespace_as_returned end def test_name_lookup_with_implicit_file_tasks - t = @tm["README"] - assert_equal "README", t.name + t = @tm["README.rdoc"] + assert_equal "README.rdoc", t.name assert Rake::FileTask === t end From 6ee9f1ef2e40ee14b7602e8ef0f1d058e1aaf048 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Mon, 25 May 2009 08:38:18 -0400 Subject: [PATCH 0045/1389] Using Config's os_host rather than RUBY_PLATFORM (http://onestepback.org/redmine/issues/show/42) --- lib/rake/application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rake/application.rb b/lib/rake/application.rb index bc94c35cc..b1a23da9c 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -235,7 +235,7 @@ def dynamic_width_tput end def unix? - RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i + Config::CONFIG['host_os'] =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i end def windows? From 8b256a2bbacca936f2a0ae96b34deaefa098025b Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Mon, 25 May 2009 09:11:34 -0400 Subject: [PATCH 0046/1389] Test Task refactoring. --- lib/rake/testtask.rb | 26 +++++++++++++++++++------- test/lib/testtask_test.rb | 14 ++++++++++++++ 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/lib/rake/testtask.rb b/lib/rake/testtask.rb index a8c3cbfb5..63d080a53 100644 --- a/lib/rake/testtask.rb +++ b/lib/rake/testtask.rb @@ -55,6 +55,10 @@ class TestTask < TaskLib # E.g. warning=true implies "ruby -w" used to run the tests. attr_accessor :warning + # Request that the tests be run at the given safe level. + # E.g. safe_level=1 implies "ruby -T1" is used to run the tests. + attr_accessor :safe_level + # Glob pattern to match test files. (default is 'test/test*.rb') attr_accessor :pattern @@ -87,6 +91,7 @@ def initialize(name=:test) @verbose = false @warning = false @loader = :rake + @safe_level = nil @ruby_opts = [] yield self if block_given? @pattern = 'test/test*.rb' if @pattern.nil? && @test_files.nil? @@ -95,16 +100,10 @@ def initialize(name=:test) # Create the tasks defined by this task lib. def define - lib_path = @libs.join(File::PATH_SEPARATOR) desc "Run tests" + (@name==:test ? "" : " for #{@name}") task @name do RakeFileUtils.verbose(@verbose) do - @ruby_opts.unshift( "-I\"#{lib_path}\"" ) - @ruby_opts.unshift( "-w" ) if @warning - ruby @ruby_opts.join(" ") + - " #{run_code} " + - file_list.collect { |fn| "\"#{fn}\"" }.join(' ') + - " #{option_list}" + ruby "#{ruby_opts_string} #{run_code} #{file_list_string} #{option_list}" end end self @@ -114,6 +113,19 @@ def option_list # :nodoc: ENV['TESTOPTS'] || @options || "" end + def ruby_opts_string + lib_path = @libs.join(File::PATH_SEPARATOR) + opts = @ruby_opts.dup + opts.unshift( "-I\"#{lib_path}\"" ) + opts.unshift( "-w" ) if @warning + opts.unshift("-T#{@safe_level}") if @safe_level + opts.join(" ") + end + + def file_list_string + file_list.collect { |fn| "\"#{fn}\"" }.join(' ') + end + def file_list # :nodoc: if ENV['TEST'] FileList[ ENV['TEST'] ] diff --git a/test/lib/testtask_test.rb b/test/lib/testtask_test.rb index d5205bfd6..a8b37da81 100644 --- a/test/lib/testtask_test.rb +++ b/test/lib/testtask_test.rb @@ -31,4 +31,18 @@ def test_rake_run_has_quoted_paths end assert_match(/".*"/, test_task.run_code) end + + def test_safe_mode_defaults + test_task = Rake::TestTask.new(:tx) + assert_nil test_task.safe_level + assert_no_match(/-3/, test_task.ruby_opts_string) + end + + def test_explicit_safe_mode + test_task = Rake::TestTask.new(:tx) do |t| + t.safe_level = 3 + end + assert_equal 3, test_task.safe_level + assert_match(/-T3/, test_task.ruby_opts_string) + end end From 31e849de324eb4ba171c59b5a03009fc575962f2 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Mon, 25 May 2009 09:45:01 -0400 Subject: [PATCH 0047/1389] Removed safe_level from test task. Doesn't work with -I option. --- lib/rake/testtask.rb | 6 ------ test/lib/testtask_test.rb | 14 -------------- 2 files changed, 20 deletions(-) diff --git a/lib/rake/testtask.rb b/lib/rake/testtask.rb index 63d080a53..81ffcce37 100644 --- a/lib/rake/testtask.rb +++ b/lib/rake/testtask.rb @@ -55,10 +55,6 @@ class TestTask < TaskLib # E.g. warning=true implies "ruby -w" used to run the tests. attr_accessor :warning - # Request that the tests be run at the given safe level. - # E.g. safe_level=1 implies "ruby -T1" is used to run the tests. - attr_accessor :safe_level - # Glob pattern to match test files. (default is 'test/test*.rb') attr_accessor :pattern @@ -91,7 +87,6 @@ def initialize(name=:test) @verbose = false @warning = false @loader = :rake - @safe_level = nil @ruby_opts = [] yield self if block_given? @pattern = 'test/test*.rb' if @pattern.nil? && @test_files.nil? @@ -118,7 +113,6 @@ def ruby_opts_string opts = @ruby_opts.dup opts.unshift( "-I\"#{lib_path}\"" ) opts.unshift( "-w" ) if @warning - opts.unshift("-T#{@safe_level}") if @safe_level opts.join(" ") end diff --git a/test/lib/testtask_test.rb b/test/lib/testtask_test.rb index a8b37da81..d5205bfd6 100644 --- a/test/lib/testtask_test.rb +++ b/test/lib/testtask_test.rb @@ -31,18 +31,4 @@ def test_rake_run_has_quoted_paths end assert_match(/".*"/, test_task.run_code) end - - def test_safe_mode_defaults - test_task = Rake::TestTask.new(:tx) - assert_nil test_task.safe_level - assert_no_match(/-3/, test_task.ruby_opts_string) - end - - def test_explicit_safe_mode - test_task = Rake::TestTask.new(:tx) do |t| - t.safe_level = 3 - end - assert_equal 3, test_task.safe_level - assert_match(/-T3/, test_task.ruby_opts_string) - end end From 19e3a40c6f09c3a57bc5070a6bcba98a36de55e6 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Mon, 25 May 2009 12:59:46 -0400 Subject: [PATCH 0048/1389] Added test for flattened test libraries. --- test/lib/testtask_test.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/lib/testtask_test.rb b/test/lib/testtask_test.rb index d5205bfd6..636c1bbb3 100644 --- a/test/lib/testtask_test.rb +++ b/test/lib/testtask_test.rb @@ -31,4 +31,11 @@ def test_rake_run_has_quoted_paths end assert_match(/".*"/, test_task.run_code) end + + def test_nested_libs_will_be_flattened + test_task = Rake::TestTask.new(:tx) do |t| + t.libs << ["A", "B"] + end + assert_match(/lib:A:B/, test_task.ruby_opts_string) + end end From 5725abbfea493a1d4ffc68ee100890de3ef8459f Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Mon, 25 May 2009 13:03:54 -0400 Subject: [PATCH 0049/1389] No -I if there are no test libs. --- lib/rake/testtask.rb | 7 +++++-- test/lib/testtask_test.rb | 7 +++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/rake/testtask.rb b/lib/rake/testtask.rb index 81ffcce37..7d200b7e5 100644 --- a/lib/rake/testtask.rb +++ b/lib/rake/testtask.rb @@ -109,12 +109,15 @@ def option_list # :nodoc: end def ruby_opts_string - lib_path = @libs.join(File::PATH_SEPARATOR) opts = @ruby_opts.dup - opts.unshift( "-I\"#{lib_path}\"" ) + opts.unshift( "-I\"#{lib_path}\"" ) unless @libs.empty? opts.unshift( "-w" ) if @warning opts.join(" ") end + + def lib_path + @libs.join(File::PATH_SEPARATOR) + end def file_list_string file_list.collect { |fn| "\"#{fn}\"" }.join(' ') diff --git a/test/lib/testtask_test.rb b/test/lib/testtask_test.rb index 636c1bbb3..d28d26715 100644 --- a/test/lib/testtask_test.rb +++ b/test/lib/testtask_test.rb @@ -38,4 +38,11 @@ def test_nested_libs_will_be_flattened end assert_match(/lib:A:B/, test_task.ruby_opts_string) end + + def test_empty_lib_path_implies_no_dash_I_option + test_task = Rake::TestTask.new(:tx) do |t| + t.libs = [] + end + assert_no_match(/-I/, test_task.ruby_opts_string) + end end From 74c65b2f8acf466c12f6f680de6454aef76a719c Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Mon, 25 May 2009 12:51:08 -0400 Subject: [PATCH 0050/1389] Changed how exclude on file lists is calculated (http://onestepback.org/redmine/issues/show/37) --- lib/rake/file_list.rb | 39 ++++++++++++--------------------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/lib/rake/file_list.rb b/lib/rake/file_list.rb index 51dfc1c84..cd6749c4b 100644 --- a/lib/rake/file_list.rb +++ b/lib/rake/file_list.rb @@ -98,7 +98,6 @@ def initialize(*patterns) @pending = false @exclude_patterns = DEFAULT_IGNORE_PATTERNS.dup @exclude_procs = DEFAULT_IGNORE_PROCS.dup - @exclude_re = nil @items = [] patterns.each { |pattern| include(pattern) } yield self if block_given? @@ -161,7 +160,6 @@ def exclude(*patterns, &block) def clear_exclude @exclude_patterns = [] @exclude_procs = [] - calculate_exclude_regexp if ! @pending self end @@ -209,26 +207,6 @@ def resolve self end - def calculate_exclude_regexp - ignores = [] - @exclude_patterns.each do |pat| - case pat - when Regexp - ignores << pat - when /[*?]/ - Dir[pat].each do |p| ignores << p end - else - ignores << Regexp.quote(pat) - end - end - if ignores.empty? - @exclude_re = /^$/ - else - re_str = ignores.collect { |p| "(" + p.to_s + ")" }.join("|") - @exclude_re = Regexp.new(re_str) - end - end - def resolve_add(fn) case fn when %r{[*?\[\{]} @@ -240,7 +218,6 @@ def resolve_add(fn) private :resolve_add def resolve_exclude - calculate_exclude_regexp reject! { |fn| exclude?(fn) } self end @@ -363,8 +340,17 @@ def add_matching(pattern) # Should the given file name be excluded? def exclude?(fn) - calculate_exclude_regexp unless @exclude_re - fn =~ @exclude_re || @exclude_procs.any? { |p| p.call(fn) } + return true if @exclude_patterns.any? do |pat| + case pat + when Regexp + fn =~ pat + when /[*?]/ + File.fnmatch?(pat, fn, File::FNM_PATHNAME) + else + fn == pat + end + end + @exclude_procs.any? { |p| p.call(fn) } end DEFAULT_IGNORE_PATTERNS = [ @@ -376,7 +362,6 @@ def exclude?(fn) DEFAULT_IGNORE_PROCS = [ proc { |fn| fn =~ /(^|[\/\\])core$/ && ! File.directory?(fn) } ] -# @exclude_patterns = DEFAULT_IGNORE_PATTERNS.dup def import(array) @items = array @@ -391,7 +376,7 @@ def [](*args) new(*args) end end - end # FileList + end end module Rake From d000a3dc5f5db44ce5dfac1a65cbdaa8a79fd956 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Tue, 26 May 2009 10:53:41 -0400 Subject: [PATCH 0051/1389] Added RAKEOPT environment variable support. --- lib/rake/application.rb | 4 ++++ test/lib/application_test.rb | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/lib/rake/application.rb b/lib/rake/application.rb index b1a23da9c..91294ca46 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -1,3 +1,6 @@ +require 'shellwords' +require 'optparse' + require 'rake/task_manager' require 'rake/win32' @@ -396,6 +399,7 @@ def handle_options end standard_rake_options.each { |args| opts.on(*args) } + opts.environment('RAKEOPT') end.parse! # If class namespaces are requested, set the global options diff --git a/test/lib/application_test.rb b/test/lib/application_test.rb index fb3add110..45d1ffa01 100644 --- a/test/lib/application_test.rb +++ b/test/lib/application_test.rb @@ -686,4 +686,21 @@ def test_terminal_width_with_failure assert_equal 80, app.terminal_width end end + + def test_rakeopt_with_blank_options + in_environment("RAKEOPT" => "") do + ARGV << '--trace' + app = Rake::Application.new + app.init + assert !app.options.silent + end + end + + def test_rakeopt_with_silent_options + in_environment("RAKEOPT" => "-s") do + app = Rake::Application.new + app.init + assert app.options.silent + end + end end From 73d55ffd46d88696a9db44ccd911253ec067cc53 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Tue, 26 May 2009 11:05:09 -0400 Subject: [PATCH 0052/1389] More tests for RAKEOPT. --- test/in_environment.rb | 6 ++++-- test/lib/application_test.rb | 42 +++++++++++++++++++++++------------- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/test/in_environment.rb b/test/in_environment.rb index fb02eba98..51b61343c 100644 --- a/test/in_environment.rb +++ b/test/in_environment.rb @@ -3,8 +3,10 @@ module InEnvironment # Create an environment for a test. At the completion of the yielded # block, the environment is restored to its original conditions. - def in_environment(settings) - original_settings = set_env(settings) + def in_environment(settings=nil) + settings ||= {} + full_settings = {"RAKEOPT" => nil}.merge(settings) + original_settings = set_env(full_settings) yield ensure set_env(original_settings) diff --git a/test/lib/application_test.rb b/test/lib/application_test.rb index 45d1ffa01..f003da685 100644 --- a/test/lib/application_test.rb +++ b/test/lib/application_test.rb @@ -311,6 +311,7 @@ def test_run_with_bad_options class TestApplicationOptions < Test::Unit::TestCase include CaptureStdout include TestMethods + include InEnvironment def setup clear_argv @@ -332,21 +333,23 @@ def clear_argv end def test_default_options - opts = command_line - assert_nil opts.classic_namespace - assert_nil opts.dryrun - assert_nil opts.ignore_system - assert_nil opts.load_system - assert_nil opts.nosearch - assert_equal ['rakelib'], opts.rakelib - assert_nil opts.show_prereqs - assert_nil opts.show_task_pattern - assert_nil opts.show_tasks - assert_nil opts.silent - assert_nil opts.trace - assert_equal ['rakelib'], opts.rakelib - assert ! RakeFileUtils.verbose_flag - assert ! RakeFileUtils.nowrite_flag + in_environment("RAKEOPT" => nil) do + opts = command_line + assert_nil opts.classic_namespace + assert_nil opts.dryrun + assert_nil opts.ignore_system + assert_nil opts.load_system + assert_nil opts.nosearch + assert_equal ['rakelib'], opts.rakelib + assert_nil opts.show_prereqs + assert_nil opts.show_task_pattern + assert_nil opts.show_tasks + assert_nil opts.silent + assert_nil opts.trace + assert_equal ['rakelib'], opts.rakelib + assert ! RakeFileUtils.verbose_flag + assert ! RakeFileUtils.nowrite_flag + end end def test_dry_run @@ -687,6 +690,15 @@ def test_terminal_width_with_failure end end + def test_no_rakeopt + in_environment do + ARGV << '--trace' + app = Rake::Application.new + app.init + assert !app.options.silent + end + end + def test_rakeopt_with_blank_options in_environment("RAKEOPT" => "") do ARGV << '--trace' From de46c07c8a014a55584c72833313e969138ced71 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Tue, 26 May 2009 14:04:59 -0400 Subject: [PATCH 0053/1389] Task invocation chain now printed on errors. --- Rakefile | 5 +++++ lib/rake/application.rb | 3 ++- lib/rake/ext/exception.rb | 5 +++++ lib/rake/invocation_exception_mixin.rb | 16 ++++++++++++++++ lib/rake/task.rb | 7 +++++++ 5 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 lib/rake/ext/exception.rb create mode 100644 lib/rake/invocation_exception_mixin.rb diff --git a/Rakefile b/Rakefile index 5964a4650..f78863bec 100644 --- a/Rakefile +++ b/Rakefile @@ -412,3 +412,8 @@ desc "Where is the current directory. This task displays\nthe current rake dire task :where_am_i do puts Rake.original_dir end + +task :failure => :really_fail +task :really_fail do + fail "oops" +end diff --git a/lib/rake/application.rb b/lib/rake/application.rb index 91294ca46..cd73382f0 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -147,8 +147,9 @@ def display_error_message(ex) $stderr.puts ex.backtrace.join("\n") else $stderr.puts ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || "" - $stderr.puts "(See full trace by running task with --trace)" end + $stderr.puts "Tasks: #{ex.chain}" if ex.chain + $stderr.puts "(See full trace by running task with --trace)" unless options.trace end # True if one of the files in RAKEFILES is in the current directory. diff --git a/lib/rake/ext/exception.rb b/lib/rake/ext/exception.rb new file mode 100644 index 000000000..17ff1560f --- /dev/null +++ b/lib/rake/ext/exception.rb @@ -0,0 +1,5 @@ +require 'rake/invocation_exception_mixin' + +class Exception + include Rake::InvocationExceptionMixin +end diff --git a/lib/rake/invocation_exception_mixin.rb b/lib/rake/invocation_exception_mixin.rb new file mode 100644 index 000000000..4936e9632 --- /dev/null +++ b/lib/rake/invocation_exception_mixin.rb @@ -0,0 +1,16 @@ +module Rake + module InvocationExceptionMixin + # Return the invocation chain (list of Rake tasks) that were in + # effect when this execption was detected by rake. May be null if + # no tasks were active. + def chain + @rake_invocation_chain ||= nil + end + + # Set the invocation chain in effect when this exception was + # detected. + def chain=(value) + @rake_invocation_chain = value + end + end +end diff --git a/lib/rake/task.rb b/lib/rake/task.rb index cd4e5c9b1..decc38df5 100644 --- a/lib/rake/task.rb +++ b/lib/rake/task.rb @@ -1,3 +1,5 @@ +require 'rake/ext/exception' + module Rake # ######################################################################### @@ -144,6 +146,11 @@ def invoke_with_call_chain(task_args, invocation_chain) # :nodoc: invoke_prerequisites(task_args, new_chain) execute(task_args) if needed? end + rescue Exception => ex + if ex.chain.nil? + ex.chain = new_chain + end + raise ex end protected :invoke_with_call_chain From 622c4edba6ddd31dd5d6fcf544dd8c83f44ce331 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Tue, 26 May 2009 14:21:39 -0400 Subject: [PATCH 0054/1389] Only add chain methods to exceptions actually caught in Rake. --- lib/rake/application.rb | 10 ++++++++-- lib/rake/ext/exception.rb | 5 ----- lib/rake/task.rb | 12 ++++++++---- 3 files changed, 16 insertions(+), 11 deletions(-) delete mode 100644 lib/rake/ext/exception.rb diff --git a/lib/rake/application.rb b/lib/rake/application.rb index cd73382f0..5f6823b58 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -148,10 +148,16 @@ def display_error_message(ex) else $stderr.puts ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || "" end - $stderr.puts "Tasks: #{ex.chain}" if ex.chain + $stderr.puts "Tasks: #{ex.chain}" if has_chain?(ex) $stderr.puts "(See full trace by running task with --trace)" unless options.trace end - + + # Does the exception have a task invocation chain? + def has_chain?(exception) + exception.respond_to?(:chain) && exception.chain + end + private :has_chain? + # True if one of the files in RAKEFILES is in the current directory. # If a match is found, it is copied into @rakefile. def have_rakefile diff --git a/lib/rake/ext/exception.rb b/lib/rake/ext/exception.rb deleted file mode 100644 index 17ff1560f..000000000 --- a/lib/rake/ext/exception.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rake/invocation_exception_mixin' - -class Exception - include Rake::InvocationExceptionMixin -end diff --git a/lib/rake/task.rb b/lib/rake/task.rb index decc38df5..b1d18811b 100644 --- a/lib/rake/task.rb +++ b/lib/rake/task.rb @@ -1,4 +1,4 @@ -require 'rake/ext/exception' +require 'rake/invocation_exception_mixin' module Rake @@ -147,13 +147,17 @@ def invoke_with_call_chain(task_args, invocation_chain) # :nodoc: execute(task_args) if needed? end rescue Exception => ex - if ex.chain.nil? - ex.chain = new_chain - end + add_chain_to(ex, new_chain) raise ex end protected :invoke_with_call_chain + def add_chain_to(exception, new_chain) + exception.extend(InvocationExceptionMixin) unless exception.respond_to?(:chain) + exception.chain = new_chain if exception.chain.nil? + end + private :add_chain_to + # Invoke all the prerequisites of a task. def invoke_prerequisites(task_args, invocation_chain) # :nodoc: @prerequisites.each { |n| From db133d365d0549125a131ef33e9e2bbe540e30ff Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Tue, 26 May 2009 14:24:01 -0400 Subject: [PATCH 0055/1389] Added fail change on error (http://onestepback.org/redmine/issues/show/3) Added RAKEOPT support --- CHANGES | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 20b34391b..1ef0066c7 100644 --- a/CHANGES +++ b/CHANGES @@ -15,7 +15,13 @@ * Fixed the silent option parsing problem. (http://onestepback.org/redmine/issues/show/47) -* Fixed :verbose=>false flag on sh and ruby commands. +* Fixed :verbose=>false flag on sh and ruby commands. + +* Rake command line options may be given by default in a RAKEOPT + environment variable. + +* Errors in Rake will now display the task invocation chain in effect + at the time of the error. == Version 0.8.7 From 6fe3f8e2af68233eb90b2c3c8a811cd3b84a0970 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Tue, 26 May 2009 14:52:30 -0400 Subject: [PATCH 0056/1389] Isolated most flag testing in an in_environment call to prevent the RAKEOPT environment variable from interferring with the results. --- test/lib/application_test.rb | 244 +++++++++++++++++++++-------------- 1 file changed, 147 insertions(+), 97 deletions(-) diff --git a/test/lib/application_test.rb b/test/lib/application_test.rb index f003da685..05fdab740 100644 --- a/test/lib/application_test.rb +++ b/test/lib/application_test.rb @@ -353,206 +353,256 @@ def test_default_options end def test_dry_run - flags('--dry-run', '-n') do |opts| - assert opts.dryrun - assert opts.trace - assert RakeFileUtils.verbose_flag - assert RakeFileUtils.nowrite_flag + in_environment do + flags('--dry-run', '-n') do |opts| + assert opts.dryrun + assert opts.trace + assert RakeFileUtils.verbose_flag + assert RakeFileUtils.nowrite_flag + end end end def test_describe - flags('--describe') do |opts| - assert_equal :describe, opts.show_tasks - assert_equal(//.to_s, opts.show_task_pattern.to_s) + in_environment do + flags('--describe') do |opts| + assert_equal :describe, opts.show_tasks + assert_equal(//.to_s, opts.show_task_pattern.to_s) + end end end def test_describe_with_pattern - flags('--describe=X') do |opts| - assert_equal :describe, opts.show_tasks - assert_equal(/X/.to_s, opts.show_task_pattern.to_s) + in_environment do + flags('--describe=X') do |opts| + assert_equal :describe, opts.show_tasks + assert_equal(/X/.to_s, opts.show_task_pattern.to_s) + end end end def test_execute - $xyzzy = 0 - flags('--execute=$xyzzy=1', '-e $xyzzy=1') do |opts| - assert_equal 1, $xyzzy - assert_equal :exit, @exit + in_environment do $xyzzy = 0 + flags('--execute=$xyzzy=1', '-e $xyzzy=1') do |opts| + assert_equal 1, $xyzzy + assert_equal :exit, @exit + $xyzzy = 0 + end end end def test_execute_and_continue - $xyzzy = 0 - flags('--execute-continue=$xyzzy=1', '-E $xyzzy=1') do |opts| - assert_equal 1, $xyzzy - assert_not_equal :exit, @exit + in_environment do $xyzzy = 0 + flags('--execute-continue=$xyzzy=1', '-E $xyzzy=1') do |opts| + assert_equal 1, $xyzzy + assert_not_equal :exit, @exit + $xyzzy = 0 + end end end def test_execute_and_print - $xyzzy = 0 - flags('--execute-print=$xyzzy="pugh"', '-p $xyzzy="pugh"') do |opts| - assert_equal 'pugh', $xyzzy - assert_equal :exit, @exit - assert_match(/^pugh$/, @out) + in_environment do $xyzzy = 0 + flags('--execute-print=$xyzzy="pugh"', '-p $xyzzy="pugh"') do |opts| + assert_equal 'pugh', $xyzzy + assert_equal :exit, @exit + assert_match(/^pugh$/, @out) + $xyzzy = 0 + end end end def test_help - flags('--help', '-H', '-h') do |opts| - assert_match(/\Arake/, @out) - assert_match(/\boptions\b/, @out) - assert_match(/\btargets\b/, @out) - assert_equal :exit, @exit - assert_equal :exit, @exit + in_environment do + flags('--help', '-H', '-h') do |opts| + assert_match(/\Arake/, @out) + assert_match(/\boptions\b/, @out) + assert_match(/\btargets\b/, @out) + assert_equal :exit, @exit + assert_equal :exit, @exit + end end end def test_libdir - flags(['--libdir', 'xx'], ['-I', 'xx'], ['-Ixx']) do |opts| - $:.include?('xx') + in_environment do + flags(['--libdir', 'xx'], ['-I', 'xx'], ['-Ixx']) do |opts| + $:.include?('xx') + end end ensure $:.delete('xx') end def test_rakefile - flags(['--rakefile', 'RF'], ['--rakefile=RF'], ['-f', 'RF'], ['-fRF']) do |opts| - assert_equal ['RF'], @app.instance_eval { @rakefiles } + in_environment do + flags(['--rakefile', 'RF'], ['--rakefile=RF'], ['-f', 'RF'], ['-fRF']) do |opts| + assert_equal ['RF'], @app.instance_eval { @rakefiles } + end end end def test_rakelib - flags(['--rakelibdir', 'A:B:C'], ['--rakelibdir=A:B:C'], ['-R', 'A:B:C'], ['-RA:B:C']) do |opts| - assert_equal ['A', 'B', 'C'], opts.rakelib + in_environment do + flags(['--rakelibdir', 'A:B:C'], ['--rakelibdir=A:B:C'], ['-R', 'A:B:C'], ['-RA:B:C']) do |opts| + assert_equal ['A', 'B', 'C'], opts.rakelib + end end end def test_require - flags(['--require', 'test/reqfile'], '-rtest/reqfile2', '-rtest/reqfile3') do |opts| + in_environment do + flags(['--require', 'test/reqfile'], '-rtest/reqfile2', '-rtest/reqfile3') do |opts| + end + assert TESTING_REQUIRE.include?(1) + assert TESTING_REQUIRE.include?(2) + assert TESTING_REQUIRE.include?(3) + assert_equal 3, TESTING_REQUIRE.size end - assert TESTING_REQUIRE.include?(1) - assert TESTING_REQUIRE.include?(2) - assert TESTING_REQUIRE.include?(3) - assert_equal 3, TESTING_REQUIRE.size end - + def test_missing_require - ex = assert_exception(LoadError) do - flags(['--require', 'test/missing']) do |opts| + in_environment do + ex = assert_exception(LoadError) do + flags(['--require', 'test/missing']) do |opts| + end end + assert_match(/no such file/, ex.message) + assert_match(/test\/missing/, ex.message) end - assert_match(/no such file/, ex.message) - assert_match(/test\/missing/, ex.message) end def test_prereqs - flags('--prereqs', '-P') do |opts| - assert opts.show_prereqs + in_environment do + flags('--prereqs', '-P') do |opts| + assert opts.show_prereqs + end end end def test_quiet - flags('--quiet', '-q') do |opts| - assert ! RakeFileUtils.verbose_flag - assert ! opts.silent + in_environment do + flags('--quiet', '-q') do |opts| + assert ! RakeFileUtils.verbose_flag + assert ! opts.silent + end end end def test_no_search - flags('--nosearch', '--no-search', '-N') do |opts| - assert opts.nosearch + in_environment do + flags('--nosearch', '--no-search', '-N') do |opts| + assert opts.nosearch + end end end def test_silent - flags('--silent', '-s') do |opts| - assert ! RakeFileUtils.verbose_flag - assert opts.silent + in_environment do + flags('--silent', '-s') do |opts| + assert ! RakeFileUtils.verbose_flag + assert opts.silent + end end end def test_system - flags('--system', '-g') do |opts| - assert opts.load_system + in_environment do + flags('--system', '-g') do |opts| + assert opts.load_system + end end end def test_no_system - flags('--no-system', '-G') do |opts| - assert opts.ignore_system + in_environment do + flags('--no-system', '-G') do |opts| + assert opts.ignore_system + end end end def test_trace - flags('--trace', '-t') do |opts| - assert opts.trace - assert RakeFileUtils.verbose_flag - assert ! RakeFileUtils.nowrite_flag + in_environment do + flags('--trace', '-t') do |opts| + assert opts.trace + assert RakeFileUtils.verbose_flag + assert ! RakeFileUtils.nowrite_flag + end end end def test_trace_rules - flags('--rules') do |opts| - assert opts.trace_rules + in_environment do + flags('--rules') do |opts| + assert opts.trace_rules + end end end def test_tasks - flags('--tasks', '-T') do |opts| - assert_equal :tasks, opts.show_tasks - assert_equal(//.to_s, opts.show_task_pattern.to_s) - end - flags(['--tasks', 'xyz'], ['-Txyz']) do |opts| - assert_equal :tasks, opts.show_tasks - assert_equal(/xyz/, opts.show_task_pattern) + in_environment do + flags('--tasks', '-T') do |opts| + assert_equal :tasks, opts.show_tasks + assert_equal(//.to_s, opts.show_task_pattern.to_s) + end + flags(['--tasks', 'xyz'], ['-Txyz']) do |opts| + assert_equal :tasks, opts.show_tasks + assert_equal(/xyz/, opts.show_task_pattern) + end end end def test_verbose - flags('--verbose', '-V') do |opts| - assert RakeFileUtils.verbose_flag - assert ! opts.silent + in_environment do + flags('--verbose', '-V') do |opts| + assert RakeFileUtils.verbose_flag + assert ! opts.silent + end end end def test_version - flags('--version', '-V') do |opts| - assert_match(/\bversion\b/, @out) - assert_match(/\b#{RAKEVERSION}\b/, @out) - assert_equal :exit, @exit + in_environment do + flags('--version', '-V') do |opts| + assert_match(/\bversion\b/, @out) + assert_match(/\b#{RAKEVERSION}\b/, @out) + assert_equal :exit, @exit + end end end def test_classic_namespace - flags(['--classic-namespace'], ['-C', '-T', '-P', '-n', '-s', '-t']) do |opts| - assert opts.classic_namespace - assert_equal opts.show_tasks, $show_tasks - assert_equal opts.show_prereqs, $show_prereqs - assert_equal opts.trace, $trace - assert_equal opts.dryrun, $dryrun - assert_equal opts.silent, $silent + in_environment do + flags(['--classic-namespace'], ['-C', '-T', '-P', '-n', '-s', '-t']) do |opts| + assert opts.classic_namespace + assert_equal opts.show_tasks, $show_tasks + assert_equal opts.show_prereqs, $show_prereqs + assert_equal opts.trace, $trace + assert_equal opts.dryrun, $dryrun + assert_equal opts.silent, $silent + end end end def test_bad_option - error_output = capture_stderr do - ex = assert_exception(OptionParser::InvalidOption) do - flags('--bad-option') - end - if ex.message =~ /^While/ # Ruby 1.9 error message - assert_match(/while parsing/i, ex.message) - else # Ruby 1.8 error message - assert_match(/(invalid|unrecognized) option/i, ex.message) - assert_match(/--bad-option/, ex.message) + in_environment do + error_output = capture_stderr do + ex = assert_exception(OptionParser::InvalidOption) do + flags('--bad-option') + end + if ex.message =~ /^While/ # Ruby 1.9 error message + assert_match(/while parsing/i, ex.message) + else # Ruby 1.8 error message + assert_match(/(invalid|unrecognized) option/i, ex.message) + assert_match(/--bad-option/, ex.message) + end end + assert_equal '', error_output end - assert_equal '', error_output end def test_task_collection From 4dda757c172e89a494057a464974f05211c78376 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Wed, 27 May 2009 09:34:09 -0400 Subject: [PATCH 0057/1389] Fixed race condition in tests. --- Rakefile | 4 +++- test/lib/multitask_test.rb | 18 +++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Rakefile b/Rakefile index f78863bec..1df5bc62a 100644 --- a/Rakefile +++ b/Rakefile @@ -102,7 +102,9 @@ begin '--sort coverage' ] + FileList['rakelib/*.rake'].pathmap("-x%p") t.test_files = FileList[ - 'test/test*.rb', 'test/functional.rb' + 'test/lib/*_test.rb', + 'test/contrib/*_test.rb', + 'test/functional/*_test.rb' ] t.output_dir = 'coverage' t.verbose = true diff --git a/test/lib/multitask_test.rb b/test/lib/multitask_test.rb index ee9be773c..04d9ee31e 100644 --- a/test/lib/multitask_test.rb +++ b/test/lib/multitask_test.rb @@ -1,6 +1,7 @@ #!/usr/bin/env ruby require 'test/unit' +require 'thread' require 'rake' ###################################################################### @@ -10,11 +11,18 @@ class TestMultiTask < Test::Unit::TestCase def setup Task.clear @runs = Array.new + @mutex = Mutex.new + end + + def add_run(obj) + @mutex.synchronize do + @runs << obj + end end def test_running_multitasks - task :a do 3.times do |i| @runs << "A#{i}"; sleep 0.01; end end - task :b do 3.times do |i| @runs << "B#{i}"; sleep 0.01; end end + task :a do 3.times do |i| add_run("A#{i}"); sleep 0.01; end end + task :b do 3.times do |i| add_run("B#{i}"); sleep 0.01; end end multitask :both => [:a, :b] Task[:both].invoke assert_equal 6, @runs.size @@ -25,9 +33,9 @@ def test_running_multitasks end def test_all_multitasks_wait_on_slow_prerequisites - task :slow do 3.times do |i| @runs << "S#{i}"; sleep 0.05 end end - task :a => [:slow] do 3.times do |i| @runs << "A#{i}"; sleep 0.01 end end - task :b => [:slow] do 3.times do |i| @runs << "B#{i}"; sleep 0.01 end end + task :slow do 3.times do |i| add_run("S#{i}"); sleep 0.05 end end + task :a => [:slow] do 3.times do |i| add_run("A#{i}"); sleep 0.01 end end + task :b => [:slow] do 3.times do |i| add_run("B#{i}"); sleep 0.01 end end multitask :both => [:a, :b] Task[:both].invoke assert_equal 9, @runs.size From 967b70ec47ac47ce275d3580d70cd13793c235e7 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Thu, 4 Jun 2009 12:54:25 -0400 Subject: [PATCH 0058/1389] Added an environment module to rake. Eventually this will be where Rakefile are evaluated. --- lib/rake/dsl.rb | 237 ++++++++++++++++++----------------- lib/rake/environment.rb | 15 +++ lib/rake/task_manager.rb | 1 + test/lib/environment_test.rb | 11 ++ 4 files changed, 149 insertions(+), 115 deletions(-) create mode 100644 lib/rake/environment.rb create mode 100644 test/lib/environment_test.rb diff --git a/lib/rake/dsl.rb b/lib/rake/dsl.rb index 131b42b13..10188e836 100644 --- a/lib/rake/dsl.rb +++ b/lib/rake/dsl.rb @@ -1,122 +1,129 @@ # Rake DSL functions. -# Declare a basic task. -# -# Example: -# task :clobber => [:clean] do -# rm_rf "html" -# end -# -def task(*args, &block) - Rake::Task.define_task(*args, &block) -end - - -# Declare a file task. -# -# Example: -# file "config.cfg" => ["config.template"] do -# open("config.cfg", "w") do |outfile| -# open("config.template") do |infile| -# while line = infile.gets -# outfile.puts line -# end -# end -# end -# end -# -def file(*args, &block) - Rake::FileTask.define_task(*args, &block) -end - -# Declare a file creation task. -# (Mainly used for the directory command). -def file_create(args, &block) - Rake::FileCreationTask.define_task(args, &block) -end - -# Declare a set of files tasks to create the given directories on demand. -# -# Example: -# directory "testdata/doc" -# -def directory(dir) - Rake.each_dir_parent(dir) do |d| - file_create d do |t| - mkdir_p t.name if ! File.exist?(t.name) +module Rake::DSL + # Declare a basic task. + # + # Example: + # task :clobber => [:clean] do + # rm_rf "html" + # end + # + def task(*args, &block) + Rake::Task.define_task(*args, &block) + end + + + # Declare a file task. + # + # Example: + # file "config.cfg" => ["config.template"] do + # open("config.cfg", "w") do |outfile| + # open("config.template") do |infile| + # while line = infile.gets + # outfile.puts line + # end + # end + # end + # end + # + def file(*args, &block) + Rake::FileTask.define_task(*args, &block) + end + + # Declare a file creation task. + # (Mainly used for the directory command). + def file_create(args, &block) + Rake::FileCreationTask.define_task(args, &block) + end + + # Declare a set of files tasks to create the given directories on + # demand. + # + # Example: + # directory "testdata/doc" + # + def directory(dir) + Rake.each_dir_parent(dir) do |d| + file_create d do |t| + mkdir_p t.name if ! File.exist?(t.name) + end end end -end - -# Declare a task that performs its prerequisites in parallel. Multitasks does -# *not* guarantee that its prerequisites will execute in any given order -# (which is obvious when you think about it) -# -# Example: -# multitask :deploy => [:deploy_gem, :deploy_rdoc] -# -def multitask(args, &block) - Rake::MultiTask.define_task(args, &block) -end - -# Create a new rake namespace and use it for evaluating the given block. -# Returns a NameSpace object that can be used to lookup tasks defined in the -# namespace. -# -# E.g. -# -# ns = namespace "nested" do -# task :run -# end -# task_run = ns[:run] # find :run in the given namespace. -# -def namespace(name=nil, &block) - name = name.to_s if name.kind_of?(Symbol) - name = name.to_str if name.respond_to?(:to_str) - unless name.kind_of?(String) || name.nil? - raise ArgumentError, "Expected a String or Symbol for a namespace name" + + # Declare a task that performs its prerequisites in + # parallel. Multitasks does *not* guarantee that its prerequisites + # will execute in any given order (which is obvious when you think + # about it) + # + # Example: + # multitask :deploy => [:deploy_gem, :deploy_rdoc] + # + def multitask(args, &block) + Rake::MultiTask.define_task(args, &block) end - Rake.application.in_namespace(name, &block) -end - -# Declare a rule for auto-tasks. -# -# Example: -# rule '.o' => '.c' do |t| -# sh %{cc -o #{t.name} #{t.source}} -# end -# -def rule(*args, &block) - Rake::Task.create_rule(*args, &block) -end - -# Describe the next rake task. -# -# Example: -# desc "Run the Unit Tests" -# task :test => [:build] -# runtests -# end -# -def desc(description) - Rake.application.last_description = description -end - -# Import the partial Rakefiles +fn+. Imported files are loaded _after_ the -# current file is completely loaded. This allows the import statement to -# appear anywhere in the importing file, and yet allowing the imported files -# to depend on objects defined in the importing file. -# -# A common use of the import statement is to include files containing -# dependency declarations. -# -# See also the --rakelibdir command line option. -# -# Example: -# import ".depend", "my_rules" -# -def import(*fns) - fns.each do |fn| - Rake.application.add_import(fn) + + # Create a new rake namespace and use it for evaluating the given + # block. Returns a NameSpace object that can be used to lookup + # tasks defined in the namespace. + # + # E.g. + # + # ns = namespace "nested" do + # task :run + # end + # task_run = ns[:run] # find :run in the given namespace. + # + def namespace(name=nil, &block) + name = name.to_s if name.kind_of?(Symbol) + name = name.to_str if name.respond_to?(:to_str) + unless name.kind_of?(String) || name.nil? + raise ArgumentError, "Expected a String or Symbol for a namespace name" + end + Rake.application.in_namespace(name, &block) + end + + # Declare a rule for auto-tasks. + # + # Example: + # rule '.o' => '.c' do |t| + # sh %{cc -o #{t.name} #{t.source}} + # end + # + def rule(*args, &block) + Rake::Task.create_rule(*args, &block) + end + + # Describe the next rake task. + # + # Example: + # desc "Run the Unit Tests" + # task :test => [:build] + # runtests + # end + # + def desc(description) + Rake.application.last_description = description + end + + # Import the partial Rakefiles +fn+. Imported files are loaded + # _after_ the current file is completely loaded. This allows the + # import statement to appear anywhere in the importing file, and yet + # allowing the imported files to depend on objects defined in the + # importing file. + # + # A common use of the import statement is to include files + # containing dependency declarations. + # + # See also the --rakelibdir command line option. + # + # Example: + # import ".depend", "my_rules" + # + def import(*fns) + fns.each do |fn| + Rake.application.add_import(fn) + end end end + +include Rake::DSL diff --git a/lib/rake/environment.rb b/lib/rake/environment.rb new file mode 100644 index 000000000..17100874f --- /dev/null +++ b/lib/rake/environment.rb @@ -0,0 +1,15 @@ +module Rake + + # Rakefile are evaluated in the Rake::Environment module space. Top + # level rake functions (e.g. :task, :file) are available in this + # environment. + module Environment + extend Rake::DSL + + class << self + def load_string(code) + module_eval(code) + end + end + end +end diff --git a/lib/rake/task_manager.rb b/lib/rake/task_manager.rb index adcf355a7..adb576ef9 100644 --- a/lib/rake/task_manager.rb +++ b/lib/rake/task_manager.rb @@ -320,6 +320,7 @@ def parse_stack_line(where) end def comment_from_file(file_name, line) + return if file_name == '(eval)' @file_cache ||= {} content = (@file_cache[file_name] ||= File.readlines(file_name)) line -= 2 diff --git a/test/lib/environment_test.rb b/test/lib/environment_test.rb new file mode 100644 index 000000000..964ec6fd5 --- /dev/null +++ b/test/lib/environment_test.rb @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby + +require 'test/test_helper' +require 'rake/environment' + +class TestEnvironment < Test::Unit::TestCase + def test_load_string + Rake::Environment.load_string("task :xyz") + assert Rake::Task[:xyz], "should have a task named xyz" + end +end From 0554a901e468c3513417795685e357898b4955e2 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Thu, 4 Jun 2009 13:50:16 -0400 Subject: [PATCH 0059/1389] Rakefile are now loaded using Rake::Environment --- lib/rake.rb | 1 + lib/rake/application.rb | 2 +- lib/rake/default_loader.rb | 2 +- lib/rake/environment.rb | 9 +++++++-- test/functional/session_based_tests.rb | 4 +++- test/lib/environment_test.rb | 7 +++++++ 6 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/rake.rb b/lib/rake.rb index 75b362e0d..4811b08c5 100755 --- a/lib/rake.rb +++ b/lib/rake.rb @@ -56,6 +56,7 @@ require 'rake/name_space' require 'rake/task_manager' require 'rake/application' +require 'rake/environment' $trace = false diff --git a/lib/rake/application.rb b/lib/rake/application.rb index 5f6823b58..f62df52a7 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -466,7 +466,7 @@ def raw_load_rakefile # :nodoc: Dir.chdir(location) puts "(in #{Dir.pwd})" unless options.silent $rakefile = @rakefile if options.classic_namespace - load File.expand_path(@rakefile) if @rakefile && @rakefile != '' + Rake::Environment.load_rakefile(File.expand_path(@rakefile)) if @rakefile && @rakefile != '' options.rakelib.each do |rlib| glob("#{rlib}/*.rake") do |name| add_import name diff --git a/lib/rake/default_loader.rb b/lib/rake/default_loader.rb index 919e321d4..7657e3ff1 100644 --- a/lib/rake/default_loader.rb +++ b/lib/rake/default_loader.rb @@ -3,7 +3,7 @@ module Rake # Default Rakefile loader used by +import+. class DefaultLoader def load(fn) - Kernel.load(File.expand_path(fn)) + Rake::Environment.load_rakefile(File.expand_path(fn)) end end diff --git a/lib/rake/environment.rb b/lib/rake/environment.rb index 17100874f..eec782556 100644 --- a/lib/rake/environment.rb +++ b/lib/rake/environment.rb @@ -7,8 +7,13 @@ module Environment extend Rake::DSL class << self - def load_string(code) - module_eval(code) + def load_rakefile(rakefile_path) + rakefile = open(rakefile_path) { |f| f.read } + load_string(rakefile, rakefile_path) + end + + def load_string(code, file_name=nil) + module_eval(code, file_name || "(eval)") end end end diff --git a/test/functional/session_based_tests.rb b/test/functional/session_based_tests.rb index 1a80dd6e0..560e8d968 100644 --- a/test/functional/session_based_tests.rb +++ b/test/functional/session_based_tests.rb @@ -356,7 +356,9 @@ def test_rake_returns_no_status_error_on_normal_exit end def test_comment_before_task_acts_like_desc - Dir.chdir("test/data/comments") { rake("-T")} + in_environment("PWD" => "test/data/comments") do + rake "-T" + end assert_match("comment for t1", @out) end diff --git a/test/lib/environment_test.rb b/test/lib/environment_test.rb index 964ec6fd5..cc662e15e 100644 --- a/test/lib/environment_test.rb +++ b/test/lib/environment_test.rb @@ -5,7 +5,14 @@ class TestEnvironment < Test::Unit::TestCase def test_load_string + Rake::Task.clear Rake::Environment.load_string("task :xyz") assert Rake::Task[:xyz], "should have a task named xyz" end + + def test_load_rakefile + Rake::Task.clear + Rake::Environment.load_rakefile("test/data/default/Rakefile") + assert Rake::Task[:default], "Should have a default task" + end end From 6a8bac6f78e47875daecd454149b7db3551c73e3 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Thu, 4 Jun 2009 16:29:26 -0400 Subject: [PATCH 0060/1389] Removed Rake's DSL commands from the top level. --- lib/rake/application.rb | 2 +- lib/rake/clean.rb | 32 ++++++++++++++------------ lib/rake/dsl.rb | 2 +- lib/rake/environment.rb | 4 ++++ lib/rake/loaders/makefile.rb | 2 ++ lib/rake/tasklib.rb | 1 + test/data/rakelib/test1.rb | 6 +++-- test/functional/session_based_tests.rb | 2 +- test/lib/clean_test.rb | 1 + test/lib/dsl_test.rb | 1 + test/test_helper.rb | 4 ++++ 11 files changed, 37 insertions(+), 20 deletions(-) diff --git a/lib/rake/application.rb b/lib/rake/application.rb index f62df52a7..271bd26f4 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -428,7 +428,7 @@ def rake_require(file_name, paths=$LOAD_PATH, loaded=$") fn = file_name + ".rake" full_path = File.join(path, fn) if File.exist?(full_path) - load full_path + Rake::Environment.load_rakefile(full_path) loaded << fn return true end diff --git a/lib/rake/clean.rb b/lib/rake/clean.rb index 4ee2c5ac9..ccb26dd0a 100644 --- a/lib/rake/clean.rb +++ b/lib/rake/clean.rb @@ -15,19 +15,21 @@ require 'rake' -CLEAN = Rake::FileList["**/*~", "**/*.bak", "**/core"] -CLEAN.clear_exclude.exclude { |fn| - fn.pathmap("%f") == 'core' && File.directory?(fn) -} - -desc "Remove any temporary products." -task :clean do - CLEAN.each { |fn| rm_r fn rescue nil } -end - -CLOBBER = Rake::FileList.new - -desc "Remove any generated file." -task :clobber => [:clean] do - CLOBBER.each { |fn| rm_r fn rescue nil } +Rake::Environment.run do + CLEAN = Rake::FileList["**/*~", "**/*.bak", "**/core"] + CLEAN.clear_exclude.exclude { |fn| + fn.pathmap("%f") == 'core' && File.directory?(fn) + } + + desc "Remove any temporary products." + task :clean do + CLEAN.each { |fn| rm_r fn rescue nil } + end + + CLOBBER = Rake::FileList.new + + desc "Remove any generated file." + task :clobber => [:clean] do + CLOBBER.each { |fn| rm_r fn rescue nil } + end end diff --git a/lib/rake/dsl.rb b/lib/rake/dsl.rb index 10188e836..3a6584321 100644 --- a/lib/rake/dsl.rb +++ b/lib/rake/dsl.rb @@ -126,4 +126,4 @@ def import(*fns) end end -include Rake::DSL +#include Rake::DSL diff --git a/lib/rake/environment.rb b/lib/rake/environment.rb index eec782556..2770b9dcc 100644 --- a/lib/rake/environment.rb +++ b/lib/rake/environment.rb @@ -15,6 +15,10 @@ def load_rakefile(rakefile_path) def load_string(code, file_name=nil) module_eval(code, file_name || "(eval)") end + + def run(&block) + module_eval(&block) + end end end end diff --git a/lib/rake/loaders/makefile.rb b/lib/rake/loaders/makefile.rb index be717ec7f..6f10e994f 100644 --- a/lib/rake/loaders/makefile.rb +++ b/lib/rake/loaders/makefile.rb @@ -4,6 +4,8 @@ module Rake # Makefile loader to be used with the import file loader. class MakefileLoader + include Rake::DSL + SPACE_MARK = "__&NBSP;__" # Load the makefile dependencies in +fn+. diff --git a/lib/rake/tasklib.rb b/lib/rake/tasklib.rb index c7fd98133..f3c433f65 100644 --- a/lib/rake/tasklib.rb +++ b/lib/rake/tasklib.rb @@ -7,6 +7,7 @@ module Rake # Base class for Task Libraries. class TaskLib include Cloneable + include Rake::DSL # Make a symbol by pasting two strings together. # diff --git a/test/data/rakelib/test1.rb b/test/data/rakelib/test1.rb index bb1c419b4..ad96c0f23 100644 --- a/test/data/rakelib/test1.rb +++ b/test/data/rakelib/test1.rb @@ -1,3 +1,5 @@ -task :default do - puts "TEST1" +Rake::Environment.run do + task :default do + puts "TEST1" + end end diff --git a/test/functional/session_based_tests.rb b/test/functional/session_based_tests.rb index 560e8d968..a67a282b6 100644 --- a/test/functional/session_based_tests.rb +++ b/test/functional/session_based_tests.rb @@ -113,7 +113,7 @@ def test_system_excludes_rakelib_files_too def test_by_default_rakelib_files_are_include in_environment('RAKE_SYSTEM' => 'test/data/sys') do - rake '-T', 'extra' + rake '-T', 'extra', '--trace' end assert_match %r{extra:extra}, @out end diff --git a/test/lib/clean_test.rb b/test/lib/clean_test.rb index da04ad149..73266c956 100644 --- a/test/lib/clean_test.rb +++ b/test/lib/clean_test.rb @@ -1,6 +1,7 @@ #!/usr/bin/env ruby require 'test/unit' +require 'rake' require 'rake/clean' class TestClean < Test::Unit::TestCase diff --git a/test/lib/dsl_test.rb b/test/lib/dsl_test.rb index 8f3a02215..cd9983f6e 100644 --- a/test/lib/dsl_test.rb +++ b/test/lib/dsl_test.rb @@ -12,6 +12,7 @@ require 'test/rake_test_setup' class DslTest < Test::Unit::TestCase + def test_namespace_command namespace "n" do task "t" diff --git a/test/test_helper.rb b/test/test_helper.rb index 55ef8933f..701d4d392 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -7,3 +7,7 @@ require 'flexmock/test_unit' require 'rake' + +class Test::Unit::TestCase + include Rake::DSL +end From c9fc213b0c5719c9071ae30484f6112b221ddf9a Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Thu, 4 Jun 2009 16:48:17 -0400 Subject: [PATCH 0061/1389] Use the DSL.environment command to execute arbitrary Ruby code in the Rake environment. --- CHANGES | 4 + lib/rake/clean.rb | 2 +- lib/rake/dsl.rb | 243 +++++++++++++++++++------------------ lib/rake/environment.rb | 16 +++ test/data/rakelib/test1.rb | 2 +- 5 files changed, 144 insertions(+), 123 deletions(-) diff --git a/CHANGES b/CHANGES index 1ef0066c7..1024e2116 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,10 @@ == Pre-Version 0.9.x +* Removed Rake's DSL methods from the top level scope. If you need to + call 'task :xzy' in your code, include Rake::DSL into your class, or + put the code in a Rake::DSL.environment do ... end block. + * Allow single line comments immediately prior to a task to be used in place of +desc+. diff --git a/lib/rake/clean.rb b/lib/rake/clean.rb index ccb26dd0a..ba461c9b5 100644 --- a/lib/rake/clean.rb +++ b/lib/rake/clean.rb @@ -15,7 +15,7 @@ require 'rake' -Rake::Environment.run do +Rake::DSL.environment do CLEAN = Rake::FileList["**/*~", "**/*.bak", "**/core"] CLEAN.clear_exclude.exclude { |fn| fn.pathmap("%f") == 'core' && File.directory?(fn) diff --git a/lib/rake/dsl.rb b/lib/rake/dsl.rb index 3a6584321..d8ff93d18 100644 --- a/lib/rake/dsl.rb +++ b/lib/rake/dsl.rb @@ -1,129 +1,130 @@ # Rake DSL functions. -module Rake::DSL - # Declare a basic task. - # - # Example: - # task :clobber => [:clean] do - # rm_rf "html" - # end - # - def task(*args, &block) - Rake::Task.define_task(*args, &block) - end - - - # Declare a file task. - # - # Example: - # file "config.cfg" => ["config.template"] do - # open("config.cfg", "w") do |outfile| - # open("config.template") do |infile| - # while line = infile.gets - # outfile.puts line - # end - # end - # end - # end - # - def file(*args, &block) - Rake::FileTask.define_task(*args, &block) - end - - # Declare a file creation task. - # (Mainly used for the directory command). - def file_create(args, &block) - Rake::FileCreationTask.define_task(args, &block) - end - - # Declare a set of files tasks to create the given directories on - # demand. - # - # Example: - # directory "testdata/doc" - # - def directory(dir) - Rake.each_dir_parent(dir) do |d| - file_create d do |t| - mkdir_p t.name if ! File.exist?(t.name) +module Rake + module DSL + # Declare a basic task. + # + # Example: + # task :clobber => [:clean] do + # rm_rf "html" + # end + # + def task(*args, &block) + Rake::Task.define_task(*args, &block) + end + + + # Declare a file task. + # + # Example: + # file "config.cfg" => ["config.template"] do + # open("config.cfg", "w") do |outfile| + # open("config.template") do |infile| + # while line = infile.gets + # outfile.puts line + # end + # end + # end + # end + # + def file(*args, &block) + Rake::FileTask.define_task(*args, &block) + end + + # Declare a file creation task. + # (Mainly used for the directory command). + def file_create(args, &block) + Rake::FileCreationTask.define_task(args, &block) + end + + # Declare a set of files tasks to create the given directories on + # demand. + # + # Example: + # directory "testdata/doc" + # + def directory(dir) + Rake.each_dir_parent(dir) do |d| + file_create d do |t| + mkdir_p t.name if ! File.exist?(t.name) + end end end - end - - # Declare a task that performs its prerequisites in - # parallel. Multitasks does *not* guarantee that its prerequisites - # will execute in any given order (which is obvious when you think - # about it) - # - # Example: - # multitask :deploy => [:deploy_gem, :deploy_rdoc] - # - def multitask(args, &block) - Rake::MultiTask.define_task(args, &block) - end - - # Create a new rake namespace and use it for evaluating the given - # block. Returns a NameSpace object that can be used to lookup - # tasks defined in the namespace. - # - # E.g. - # - # ns = namespace "nested" do - # task :run - # end - # task_run = ns[:run] # find :run in the given namespace. - # - def namespace(name=nil, &block) - name = name.to_s if name.kind_of?(Symbol) - name = name.to_str if name.respond_to?(:to_str) - unless name.kind_of?(String) || name.nil? - raise ArgumentError, "Expected a String or Symbol for a namespace name" + + # Declare a task that performs its prerequisites in + # parallel. Multitasks does *not* guarantee that its prerequisites + # will execute in any given order (which is obvious when you think + # about it) + # + # Example: + # multitask :deploy => [:deploy_gem, :deploy_rdoc] + # + def multitask(args, &block) + Rake::MultiTask.define_task(args, &block) end - Rake.application.in_namespace(name, &block) - end - - # Declare a rule for auto-tasks. - # - # Example: - # rule '.o' => '.c' do |t| - # sh %{cc -o #{t.name} #{t.source}} - # end - # - def rule(*args, &block) - Rake::Task.create_rule(*args, &block) - end - - # Describe the next rake task. - # - # Example: - # desc "Run the Unit Tests" - # task :test => [:build] - # runtests - # end - # - def desc(description) - Rake.application.last_description = description - end - - # Import the partial Rakefiles +fn+. Imported files are loaded - # _after_ the current file is completely loaded. This allows the - # import statement to appear anywhere in the importing file, and yet - # allowing the imported files to depend on objects defined in the - # importing file. - # - # A common use of the import statement is to include files - # containing dependency declarations. - # - # See also the --rakelibdir command line option. - # - # Example: - # import ".depend", "my_rules" - # - def import(*fns) - fns.each do |fn| - Rake.application.add_import(fn) + + # Create a new rake namespace and use it for evaluating the given + # block. Returns a NameSpace object that can be used to lookup + # tasks defined in the namespace. + # + # E.g. + # + # ns = namespace "nested" do + # task :run + # end + # task_run = ns[:run] # find :run in the given namespace. + # + def namespace(name=nil, &block) + name = name.to_s if name.kind_of?(Symbol) + name = name.to_str if name.respond_to?(:to_str) + unless name.kind_of?(String) || name.nil? + raise ArgumentError, "Expected a String or Symbol for a namespace name" + end + Rake.application.in_namespace(name, &block) + end + + # Declare a rule for auto-tasks. + # + # Example: + # rule '.o' => '.c' do |t| + # sh %{cc -o #{t.name} #{t.source}} + # end + # + def rule(*args, &block) + Rake::Task.create_rule(*args, &block) + end + + # Describe the next rake task. + # + # Example: + # desc "Run the Unit Tests" + # task :test => [:build] + # runtests + # end + # + def desc(description) + Rake.application.last_description = description + end + + # Import the partial Rakefiles +fn+. Imported files are loaded + # _after_ the current file is completely loaded. This allows the + # import statement to appear anywhere in the importing file, and yet + # allowing the imported files to depend on objects defined in the + # importing file. + # + # A common use of the import statement is to include files + # containing dependency declarations. + # + # See also the --rakelibdir command line option. + # + # Example: + # import ".depend", "my_rules" + # + def import(*fns) + fns.each do |fn| + Rake.application.add_import(fn) + end end end end - -#include Rake::DSL + diff --git a/lib/rake/environment.rb b/lib/rake/environment.rb index 2770b9dcc..aaac7f987 100644 --- a/lib/rake/environment.rb +++ b/lib/rake/environment.rb @@ -1,3 +1,5 @@ +require 'rake/dsl' + module Rake # Rakefile are evaluated in the Rake::Environment module space. Top @@ -7,18 +9,32 @@ module Environment extend Rake::DSL class << self + # Load a rakefile from the given path. The Rakefile is loaded + # in an environment that includes the Rake DSL methods. def load_rakefile(rakefile_path) rakefile = open(rakefile_path) { |f| f.read } load_string(rakefile, rakefile_path) end + # Load a string of code in the Rake DSL environment. If the + # string comes from a file, include the file path so that proper + # line numbers references may be retained. def load_string(code, file_name=nil) module_eval(code, file_name || "(eval)") end + # Run a block of code in the Rake DSL environment. def run(&block) module_eval(&block) end end end + + # Run the code block in an environment including the Rake DSL + # commands. + def DSL.environment(&block) + Rake::Environment.run(&block) + end end + + diff --git a/test/data/rakelib/test1.rb b/test/data/rakelib/test1.rb index ad96c0f23..fd3c95818 100644 --- a/test/data/rakelib/test1.rb +++ b/test/data/rakelib/test1.rb @@ -1,4 +1,4 @@ -Rake::Environment.run do +Rake::DSL.environment do task :default do puts "TEST1" end From cd368cf30dabe784ccc5c21e591ecea1bedaa47b Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Thu, 4 Jun 2009 16:55:46 -0400 Subject: [PATCH 0062/1389] Bumped version --- lib/rake.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rake.rb b/lib/rake.rb index 4811b08c5..1252ef603 100755 --- a/lib/rake.rb +++ b/lib/rake.rb @@ -23,7 +23,7 @@ # IN THE SOFTWARE. #++ -RAKEVERSION = '0.8.7.1' +RAKEVERSION = '0.8.99.1' require 'rbconfig' require 'fileutils' From 4eda73f878fa13f919cd9ebe5a4a4118c8008fe2 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Fri, 5 Jun 2009 03:23:17 -0400 Subject: [PATCH 0063/1389] Removed duplicate location detection logic between the comment and -W processing code. Other minor cleanup. --- lib/rake/task.rb | 5 ++-- lib/rake/task_manager.rb | 50 +++++++++++++++++----------------------- 2 files changed, 24 insertions(+), 31 deletions(-) diff --git a/lib/rake/task.rb b/lib/rake/task.rb index b1d18811b..e5b280696 100644 --- a/lib/rake/task.rb +++ b/lib/rake/task.rb @@ -31,8 +31,9 @@ class Task # Array of nested namespaces names used for task lookup by this task. attr_reader :scope - # File/Line location of the the task definition (only valid if the - # task was defined with the detect location option set). + # File/Line locations of each of the task definitions for this + # task (only valid if the task was defined with the detect + # location option set). attr_reader :locations # Return task name diff --git a/lib/rake/task_manager.rb b/lib/rake/task_manager.rb index adb576ef9..7efa4da9a 100644 --- a/lib/rake/task_manager.rb +++ b/lib/rake/task_manager.rb @@ -12,6 +12,7 @@ def initialize @rules = Array.new @scope = Array.new @last_description = nil + @need_descriptions = true end def create_rule(*args, &block) @@ -27,11 +28,11 @@ def define_task(task_class, *args, &block) deps = deps.collect {|d| d.to_s } task = intern(task_class, task_name) task.set_arg_names(arg_names) unless arg_names.empty? - task.add_description(get_description) + if @need_descriptions + add_location(task) + task.add_description(get_description(task)) + end task.enhance(deps, &block) - with_location { - task - } end # Lookup a task. Return an existing task if found, otherwise @@ -208,25 +209,20 @@ def in_namespace(name) private - # Add a location to the locations field of the yield object. - def with_location - result = yield + # Add a location to the locations field of the given task. + def add_location(task) loc = find_location - result.locations << loc if loc - result + task.locations << loc if loc + task end # Find the location that called into the dsl layer. def find_location - begin - raise StandardError.new - rescue StandardError => ex - locations = ex.backtrace - i = 0 - while locations[i] - return locations[i+1] if locations[i] =~ /rake\/dsl.rb/ - i += 1 - end + locations = caller + i = 0 + while locations[i] + return locations[i+1] if locations[i] =~ /rake\/dsl.rb/ + i += 1 end nil end @@ -294,25 +290,21 @@ def make_sources(task_name, extensions) # Return the current description. If there isn't one, try to find it # by reading in the source file and looking for a comment immediately # prior to the task definition - def get_description - desc = @last_description || find_preceding_comment_for_task + def get_description(task) + desc = @last_description || find_preceding_comment_for_task(task) @last_description = nil desc end - def find_preceding_comment_for_task - stack = caller - begin - where = stack.shift - end until stack.empty? || where =~ /in `task'/ - return nil if stack.empty? - file_name, line = parse_stack_line(stack.shift) + def find_preceding_comment_for_task(task) + loc = task.locations.last + file_name, line = parse_location(loc) return nil unless file_name comment_from_file(file_name, line) end - def parse_stack_line(where) - if where =~ /^(.*):(\d+)/ + def parse_location(loc) + if loc =~ /^(.*):(\d+)/ [ $1, Integer($2) ] else nil From f191142580155c38d02172a1960d65505b7bc51f Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Fri, 5 Jun 2009 10:27:30 -0400 Subject: [PATCH 0064/1389] Optimized comment loading to only happen with -T, -D or -W options. --- lib/rake/application.rb | 3 +++ lib/rake/task_manager.rb | 8 ++++++-- test/functional/session_based_tests.rb | 5 +++-- test/lib/application_test.rb | 1 + 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/rake/application.rb b/lib/rake/application.rb index 271bd26f4..6643d3464 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -282,6 +282,7 @@ def standard_rake_options lambda { |value| options.show_tasks = :describe options.show_task_pattern = Regexp.new(value || '') + TaskManager.record_task_metadata = true } ], ['--dry-run', '-n', "Do a dry run without executing actions.", @@ -365,6 +366,7 @@ def standard_rake_options lambda { |value| options.show_tasks = :tasks options.show_task_pattern = Regexp.new(value || '') + Rake::TaskManager.record_task_metadata = true } ], ['--trace', '-t', "Turn on invoke/execute tracing, enable full backtrace.", @@ -386,6 +388,7 @@ def standard_rake_options lambda { |value| options.show_tasks = :lines options.show_task_pattern = Regexp.new(value || '') + Rake::TaskManager.record_task_metadata = true } ], ] diff --git a/lib/rake/task_manager.rb b/lib/rake/task_manager.rb index 7efa4da9a..db9744ca5 100644 --- a/lib/rake/task_manager.rb +++ b/lib/rake/task_manager.rb @@ -12,7 +12,6 @@ def initialize @rules = Array.new @scope = Array.new @last_description = nil - @need_descriptions = true end def create_rule(*args, &block) @@ -28,7 +27,7 @@ def define_task(task_class, *args, &block) deps = deps.collect {|d| d.to_s } task = intern(task_class, task_name) task.set_arg_names(arg_names) unless arg_names.empty? - if @need_descriptions + if Rake::TaskManager.record_task_metadata add_location(task) task.add_description(get_description(task)) end @@ -319,6 +318,11 @@ def comment_from_file(file_name, line) return nil unless content[line] =~ /^\s*#\s*(.*)/ $1 end + + class << self + attr_accessor :record_task_metadata + TaskManager.record_task_metadata = false + end end end diff --git a/test/functional/session_based_tests.rb b/test/functional/session_based_tests.rb index a67a282b6..6eff02b43 100644 --- a/test/functional/session_based_tests.rb +++ b/test/functional/session_based_tests.rb @@ -9,6 +9,7 @@ require 'session' require 'test/in_environment' require 'test/rake_test_setup' +require 'rake' # Version 2.1.9 of session has a bug where the @debug instance # variable is not initialized, causing warning messages. This snippet @@ -111,9 +112,9 @@ def test_system_excludes_rakelib_files_too assert_no_match %r{extra:extra}, @out end - def test_by_default_rakelib_files_are_include + def test_by_default_rakelib_files_are_included in_environment('RAKE_SYSTEM' => 'test/data/sys') do - rake '-T', 'extra', '--trace' + rake '-T', 'extra' end assert_match %r{extra:extra}, @out end diff --git a/test/lib/application_test.rb b/test/lib/application_test.rb index 05fdab740..bdd0d1740 100644 --- a/test/lib/application_test.rb +++ b/test/lib/application_test.rb @@ -23,6 +23,7 @@ class TestApplication < Test::Unit::TestCase def setup @app = Rake::Application.new @app.options.rakelib = [] + Rake::TaskManager.record_task_metadata = true end def test_constant_warning From 5f74be339b7c14405aefb2b2c326985aaa85161e Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Fri, 5 Jun 2009 10:39:27 -0400 Subject: [PATCH 0065/1389] Bumped version to 0.8.99.2. --- lib/rake.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rake.rb b/lib/rake.rb index 1252ef603..78e497ec2 100755 --- a/lib/rake.rb +++ b/lib/rake.rb @@ -23,7 +23,7 @@ # IN THE SOFTWARE. #++ -RAKEVERSION = '0.8.99.1' +RAKEVERSION = '0.8.99.2' require 'rbconfig' require 'fileutils' From cae4327d49c61f0262da721af70bf9ddefc0cfcb Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Fri, 5 Jun 2009 14:29:42 -0400 Subject: [PATCH 0066/1389] Added -X option to enable DSL at top level. (option subject to change) --- lib/rake/application.rb | 5 +++++ lib/rake/dsl.rb | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/lib/rake/application.rb b/lib/rake/application.rb index 6643d3464..1dce168b9 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -369,6 +369,11 @@ def standard_rake_options Rake::TaskManager.record_task_metadata = true } ], + ['--top-level-dsl', '-X', "Put Rake DSL commands in the top level scope.", + lambda { |value| + Rake::DSL.include_in_top_scope + } + ], ['--trace', '-t', "Turn on invoke/execute tracing, enable full backtrace.", lambda { |value| options.trace = true diff --git a/lib/rake/dsl.rb b/lib/rake/dsl.rb index d8ff93d18..c144f0030 100644 --- a/lib/rake/dsl.rb +++ b/lib/rake/dsl.rb @@ -125,6 +125,12 @@ def import(*fns) Rake.application.add_import(fn) end end + + # Include the Rake DSL commands in the top level Ruby scope. + def self.include_in_top_scope + Object.send(:include, Rake::DSL) + end end + end From 0b11f0fada3e9a4cf11eb5cde78b91eff42741fe Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Fri, 5 Jun 2009 20:44:12 -0400 Subject: [PATCH 0067/1389] Fixed test_nested_libs_will_be_flattened to use File::PATH_SEPARATOR --- test/lib/testtask_test.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/lib/testtask_test.rb b/test/lib/testtask_test.rb index d28d26715..59955be02 100644 --- a/test/lib/testtask_test.rb +++ b/test/lib/testtask_test.rb @@ -36,7 +36,8 @@ def test_nested_libs_will_be_flattened test_task = Rake::TestTask.new(:tx) do |t| t.libs << ["A", "B"] end - assert_match(/lib:A:B/, test_task.ruby_opts_string) + expected = %w(lib A B).join(File::PATH_SEPARATOR) + assert_match(/#{expected}/, test_task.ruby_opts_string) end def test_empty_lib_path_implies_no_dash_I_option From 4e8233da4da833f357616001677f3ee32f5c6d27 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Tue, 30 Jun 2009 01:22:02 -0400 Subject: [PATCH 0068/1389] Top level DSL is make the default (for now). --- lib/rake/application.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/rake/application.rb b/lib/rake/application.rb index 1dce168b9..055974f9f 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -371,7 +371,7 @@ def standard_rake_options ], ['--top-level-dsl', '-X', "Put Rake DSL commands in the top level scope.", lambda { |value| - Rake::DSL.include_in_top_scope + options.top_level_dsl = value } ], ['--trace', '-t', "Turn on invoke/execute tracing, enable full backtrace.", @@ -417,6 +417,8 @@ def handle_options opts.environment('RAKEOPT') end.parse! + Rake::DSL.include_in_top_scope if options.top_level_dsl + # If class namespaces are requested, set the global options # according to the values in the options structure. if options.classic_namespace From 813408a3f9d5d11a59e330581ea75c5d5e6bcdca Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Tue, 30 Jun 2009 15:28:11 -0400 Subject: [PATCH 0069/1389] Fixed no top dsl option logic. --- lib/rake.rb | 2 +- lib/rake/application.rb | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/rake.rb b/lib/rake.rb index 78e497ec2..db89b71cd 100755 --- a/lib/rake.rb +++ b/lib/rake.rb @@ -23,7 +23,7 @@ # IN THE SOFTWARE. #++ -RAKEVERSION = '0.8.99.2' +RAKEVERSION = '0.8.99.3' require 'rbconfig' require 'fileutils' diff --git a/lib/rake/application.rb b/lib/rake/application.rb index 055974f9f..884f47f89 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -45,15 +45,16 @@ def initialize @tty_output = STDOUT.tty? end - # Run the Rake application. The run method performs the following three steps: + # Run the Rake application. The run method performs the following + # three steps: # # * Initialize the command line options (+init+). # * Define the tasks (+load_rakefile+). # * Run the top level tasks (+run_tasks+). # - # If you wish to build a custom rake command, you should call +init+ on your - # application. The define any tasks. Finally, call +top_level+ to run your top - # level tasks. + # If you wish to build a custom rake command, you should call + # +init+ on your application. The define any tasks. Finally, + # call +top_level+ to run your top level tasks. def run standard_exception_handling do init @@ -369,7 +370,12 @@ def standard_rake_options Rake::TaskManager.record_task_metadata = true } ], - ['--top-level-dsl', '-X', "Put Rake DSL commands in the top level scope.", + ['--no-top-level-dsl', '-X', "Do no put Rake DSL commands in the top level scope.", + lambda { |value| + options.top_level_dsl = ! value + } + ], + ['--top-level-dsl', "Put Rake DSL commands in the top level scope.", lambda { |value| options.top_level_dsl = value } @@ -402,6 +408,7 @@ def standard_rake_options # Read and handle the command line options. def handle_options options.rakelib = ['rakelib'] + options.top_level_dsl = true OptionParser.new do |opts| opts.banner = "rake [-f rakefile] {options} targets..." From 0712aed6a3331064196d1f430064fc20b1e73ef3 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 2 Jul 2009 10:51:18 -0600 Subject: [PATCH 0070/1389] Avoid command line too long problem when running large numbers of unit tests --- lib/rake/rake_test_loader.rb | 11 ++++++++++- lib/rake/testtask.rb | 4 ++-- test/lib/test_task_test.rb | 4 ++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/rake/rake_test_loader.rb b/lib/rake/rake_test_loader.rb index 8d7dad3c9..ccb8cfd47 100644 --- a/lib/rake/rake_test_loader.rb +++ b/lib/rake/rake_test_loader.rb @@ -2,4 +2,13 @@ # Load the test files from the command line. -ARGV.each { |f| load f unless f =~ /^-/ } +ARGV.each do |f| + next if f =~ /^-/ + + if f =~ /\*/ + FileList[f].to_a.each { |f| load f } + else + load f + end +end + diff --git a/lib/rake/testtask.rb b/lib/rake/testtask.rb index 7d200b7e5..298b1d479 100644 --- a/lib/rake/testtask.rb +++ b/lib/rake/testtask.rb @@ -129,8 +129,8 @@ def file_list # :nodoc: else result = [] result += @test_files.to_a if @test_files - result += FileList[ @pattern ].to_a if @pattern - FileList[result] + result << @pattern if @pattern + result end end diff --git a/test/lib/test_task_test.rb b/test/lib/test_task_test.rb index a8d7d4d57..8a18ec046 100644 --- a/test/lib/test_task_test.rb +++ b/test/lib/test_task_test.rb @@ -48,7 +48,7 @@ def test_pattern tt = Rake::TestTask.new do |t| t.pattern = '*.rb' end - assert_equal ['install.rb'], tt.file_list.to_a + assert_equal ['*.rb'], tt.file_list.to_a end def test_env_test @@ -71,7 +71,7 @@ def test_both_pattern_and_test_files t.test_files = FileList['a.rb', 'b.rb'] t.pattern = '*.rb' end - assert_equal ['a.rb', 'b.rb', 'install.rb'], tt.file_list.to_a + assert_equal ['a.rb', 'b.rb', '*.rb'], tt.file_list.to_a end end From c74532754eda9798638ee9bb8e5532e69ec88e4e Mon Sep 17 00:00:00 2001 From: warnickr Date: Tue, 7 Jul 2009 12:38:26 -0600 Subject: [PATCH 0071/1389] make sure rake lib is available --- lib/rake/rake_test_loader.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/rake/rake_test_loader.rb b/lib/rake/rake_test_loader.rb index ccb8cfd47..06e2e872a 100644 --- a/lib/rake/rake_test_loader.rb +++ b/lib/rake/rake_test_loader.rb @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +require 'rake' # Load the test files from the command line. From 75e3dee31586ad89f6da3448f99b89d6503d6749 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Tue, 7 Jul 2009 15:52:00 -0400 Subject: [PATCH 0072/1389] Updated CHANGES to mention the warnickr changes for test task. --- CHANGES | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES b/CHANGES index 1ef0066c7..b33b9306e 100644 --- a/CHANGES +++ b/CHANGES @@ -23,6 +23,9 @@ * Errors in Rake will now display the task invocation chain in effect at the time of the error. +* Accepted change by warnickr to not expand test patterns in shell + (allowing more files in the test suite). + == Version 0.8.7 * Fixed EXEEXT for JRuby on windows. From af242eeaf659baac811e94596c090218f443e84d Mon Sep 17 00:00:00 2001 From: warnickr Date: Mon, 13 Jul 2009 17:41:59 -0600 Subject: [PATCH 0073/1389] Windows needs the path to the base rake lib to be explicitly included --- lib/rake/testtask.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/rake/testtask.rb b/lib/rake/testtask.rb index 298b1d479..5c82824f3 100644 --- a/lib/rake/testtask.rb +++ b/lib/rake/testtask.rb @@ -154,7 +154,7 @@ def run_code when :testrb "-S testrb #{fix}" when :rake - "\"#{rake_loader}\"" + "-I\"#{rake_lib_dir}\" \"#{rake_loader}\"" end end @@ -170,6 +170,19 @@ def find_file(fn) # :nodoc: end nil end + + def rake_lib_dir # :nodoc: + find_dir('rake') or + fail "unable to find rake lib" + end + + def find_dir(fn) # :nodoc: + $LOAD_PATH.each do |path| + file_path = File.join(path, "#{fn}.rb") + return path if File.exist? file_path + end + nil + end end end From 8192fda97580c3be5d4ff08a2ec1dcb5fa71ba18 Mon Sep 17 00:00:00 2001 From: Alexey Borzenkov Date: Wed, 19 Aug 2009 17:20:51 +0400 Subject: [PATCH 0074/1389] Test scoped dependencies work for file tasks --- test/data/namespace/Rakefile | 9 +++++++++ test/functional/session_based_tests.rb | 15 +++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/test/data/namespace/Rakefile b/test/data/namespace/Rakefile index 6de98edae..2e6a88c98 100644 --- a/test/data/namespace/Rakefile +++ b/test/data/namespace/Rakefile @@ -55,3 +55,12 @@ namespace "file2" do end end +namespace "scopedep" do + task :prepare do + touch "scopedep.rb" + puts "PREPARE" + end + file "scopedep.rb" => [:prepare] do + puts "SCOPEDEP" + end +end diff --git a/test/functional/session_based_tests.rb b/test/functional/session_based_tests.rb index 1a80dd6e0..747be7477 100644 --- a/test/functional/session_based_tests.rb +++ b/test/functional/session_based_tests.rb @@ -341,6 +341,15 @@ def test_file_task_are_not_scoped_by_namespaces end end + def test_file_task_dependencies_scoped_by_namespaces + in_environment("PWD" => "test/data/namespace") do + rake "scopedep.rb" + assert_match(/^PREPARE\nSCOPEDEP$/m, @out) + end + ensure + remove_namespace_files + end + def test_rake_returns_status_error_values in_environment("PWD" => "test/data/statusreturn") do rake "exit5" @@ -391,6 +400,12 @@ def remove_chaining_files FileUtils.rm_f File.join("test/data/chains", fn) end end + + def remove_namespace_files + %w(scopedep.rb).each do |fn| + FileUtils.rm_f File.join("test/data/namespace", fn) + end + end class << self def format_command From fce3f05c9b07c0fc447c0e9a5bf50afe62e6a3e6 Mon Sep 17 00:00:00 2001 From: Alexey Borzenkov Date: Wed, 19 Aug 2009 15:51:12 +0400 Subject: [PATCH 0075/1389] Always use scope when looking up prerequisites --- lib/rake/file_task.rb | 2 +- lib/rake/multi_task.rb | 2 +- lib/rake/task.rb | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/rake/file_task.rb b/lib/rake/file_task.rb index 60e9b0783..78902a86f 100644 --- a/lib/rake/file_task.rb +++ b/lib/rake/file_task.rb @@ -29,7 +29,7 @@ def timestamp # Are there any prerequisites with a later time than the given time stamp? def out_of_date?(stamp) - @prerequisites.any? { |n| application[n].timestamp > stamp} + @prerequisites.any? { |n| application[n, @scope].timestamp > stamp} end # ---------------------------------------------------------------- diff --git a/lib/rake/multi_task.rb b/lib/rake/multi_task.rb index 176264945..21c8de732 100644 --- a/lib/rake/multi_task.rb +++ b/lib/rake/multi_task.rb @@ -7,7 +7,7 @@ class MultiTask < Task private def invoke_prerequisites(args, invocation_chain) threads = @prerequisites.collect { |p| - Thread.new(p) { |r| application[r].invoke_with_call_chain(args, invocation_chain) } + Thread.new(p) { |r| application[r, @scope].invoke_with_call_chain(args, invocation_chain) } } threads.each { |t| t.join } end diff --git a/lib/rake/task.rb b/lib/rake/task.rb index b1d18811b..1526cfda8 100644 --- a/lib/rake/task.rb +++ b/lib/rake/task.rb @@ -205,7 +205,7 @@ def needed? # Timestamp for this task. Basic tasks return the current time for their # time stamp. Other tasks can be more sophisticated. def timestamp - @prerequisites.collect { |p| application[p].timestamp }.max || Time.now + @prerequisites.collect { |p| application[p, @scope].timestamp }.max || Time.now end # Add a description to the task. The description can consist of an option @@ -253,12 +253,12 @@ def investigation result << "task needed: #{needed?}\n" result << "timestamp: #{timestamp}\n" result << "pre-requisites: \n" - prereqs = @prerequisites.collect {|name| application[name]} + prereqs = @prerequisites.collect {|name| application[name, @scope]} prereqs.sort! {|a,b| a.timestamp <=> b.timestamp} prereqs.each do |p| result << "--#{p.name} (#{p.timestamp})\n" end - latest_prereq = @prerequisites.collect{|n| application[n].timestamp}.max + latest_prereq = @prerequisites.collect{|n| application[n, @scope].timestamp}.max result << "latest-prerequisite time: #{latest_prereq}\n" result << "................................\n\n" return result From a39943a7c64adb0c4fb9c3c72a8b6c3d092f3f94 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Sat, 29 Aug 2009 11:01:46 -0400 Subject: [PATCH 0076/1389] Added ignore for transient data in test/data/namespace. --- test/data/namespace/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 test/data/namespace/.gitignore diff --git a/test/data/namespace/.gitignore b/test/data/namespace/.gitignore new file mode 100644 index 000000000..10cc0fb1f --- /dev/null +++ b/test/data/namespace/.gitignore @@ -0,0 +1 @@ +scopedep.rb From 7cc96f836d1bf1d9b1c7f4a6f1a6da1d19de57b6 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Sat, 29 Aug 2009 11:48:29 -0400 Subject: [PATCH 0077/1389] updated changes. --- CHANGES | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES b/CHANGES index b33b9306e..5f5084bb4 100644 --- a/CHANGES +++ b/CHANGES @@ -26,6 +26,9 @@ * Accepted change by warnickr to not expand test patterns in shell (allowing more files in the test suite). +* Fixed that file tasks did not perform prereq lookups in scope + (Redmine #57). + == Version 0.8.7 * Fixed EXEEXT for JRuby on windows. From 301828f38c8909205d03f089bace9ee321709658 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Sat, 5 Sep 2009 16:17:04 -0400 Subject: [PATCH 0078/1389] Updated fix for path statement. --- test/lib/testtask_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/lib/testtask_test.rb b/test/lib/testtask_test.rb index 59955be02..abde54a65 100644 --- a/test/lib/testtask_test.rb +++ b/test/lib/testtask_test.rb @@ -36,8 +36,8 @@ def test_nested_libs_will_be_flattened test_task = Rake::TestTask.new(:tx) do |t| t.libs << ["A", "B"] end - expected = %w(lib A B).join(File::PATH_SEPARATOR) - assert_match(/#{expected}/, test_task.ruby_opts_string) + sep = File::PATH_SEPARATOR + assert_match(/lib#{sep}A#{sep}B/, test_task.ruby_opts_string) end def test_empty_lib_path_implies_no_dash_I_option From 3fd4a8aeed53508a201b0cc077d07078f6aae48e Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Sat, 5 Sep 2009 19:10:10 -0400 Subject: [PATCH 0079/1389] Added default to --top-level-dsl option comment. --- lib/rake/application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rake/application.rb b/lib/rake/application.rb index 884f47f89..25aeddc65 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -375,7 +375,7 @@ def standard_rake_options options.top_level_dsl = ! value } ], - ['--top-level-dsl', "Put Rake DSL commands in the top level scope.", + ['--top-level-dsl', "Put Rake DSL commands in the top level scope (default).", lambda { |value| options.top_level_dsl = value } From 2c013dc7c1076529ba50212d82b16a780fbb7314 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Sat, 5 Sep 2009 21:55:07 -0400 Subject: [PATCH 0080/1389] Added pivotal link on a spot or two. --- CHANGES | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 1024e2116..fa53de350 100644 --- a/CHANGES +++ b/CHANGES @@ -14,7 +14,8 @@ * Support for the --where (-W) flag for showing where a task is defined. * Fixed quoting in test task. - (http://onestepback.org/redmine/issues/show/44) + (http://onestepback.org/redmine/issues/show/44, + http://www.pivotaltracker.com/story/show/1223138) * Fixed the silent option parsing problem. (http://onestepback.org/redmine/issues/show/47) From d459276f620dcbf55f03e1e183e62af593858d63 Mon Sep 17 00:00:00 2001 From: chrisk Date: Mon, 19 Oct 2009 23:29:15 -0700 Subject: [PATCH 0081/1389] Fix spelling in rakefile.rdoc --- doc/rakefile.rdoc | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/doc/rakefile.rdoc b/doc/rakefile.rdoc index b84c2ddbe..ac35b24a5 100644 --- a/doc/rakefile.rdoc +++ b/doc/rakefile.rdoc @@ -45,7 +45,7 @@ following ... Actions are defined by passing a block to the +task+ method. Any Ruby code can be placed in the block. The block may reference the task -object via the block paramter.. +object via the block parameter. task :name => [:prereq1, :prereq2] do |t| # actions (may reference t) @@ -119,14 +119,14 @@ Rake allows parallel execution of prerequisites using the following syntax: end In this example, +copy_files+ is a normal rake task. Its actions are -executed whereever all of its prerequisites are done. The big +executed whenever all of its prerequisites are done. The big difference is that the prerequisites (+copy_src+, +copy_bin+ and +copy_doc+) are executed in parallel. Each of the prerequisites are run in their own Ruby thread, possibly allowing faster overall runtime. === Secondary Prerequisites -If any of the primary prerequites of a multitask have common secondary +If any of the primary prerequisites of a multitask have common secondary prerequisites, all of the primary/parallel prerequisites will wait until the common prerequisites have been run. @@ -196,7 +196,7 @@ or RELEASE_VERSION rake release will work. Environment variable names must either match the task -parameter exactly, or match an all uppcase version of the task +parameter exactly, or match an all-uppercase version of the task parameter. === Tasks that Expect Parameters @@ -211,10 +211,10 @@ declared as: task :name, [:first_name, :last_name] The first argument is still the name of the task (:name in this case). -The next to argumements are the names of the parameters expected by +The next two arguments are the names of the parameters expected by :name in an array (:first_name and :last_name in the example). -To access the values of the paramters, the block defining the task +To access the values of the parameters, the block defining the task behaviour can now accept a second parameter: task :name, [:first_name, :last_name] do |t, args| @@ -259,9 +259,9 @@ dependencies. That format is still supported for compatibility, but is not recommended for use. The older format may be dropped in future versions of rake. -== Accessing Task Programatically +== Accessing Task Programmatically -Sometimes it is useful to manipulate tasks programatically in a +Sometimes it is useful to manipulate tasks programmatically in a Rakefile. To find a task object, use the :[] operator on the Rake::Task. @@ -435,7 +435,7 @@ common for task names to begin to clash. For example, if you might have a main program and a set of sample programs built by a single Rakefile. By placing the tasks related to the main program in one namespace, and the tasks for building the sample programs in a -different namespace, the task names will not will not interfer with +different namespace, the task names will not will not interfere with each other. For example: @@ -531,17 +531,17 @@ Or give it a glob pattern: == Odds and Ends -=== do/end verses { } +=== do/end versus { } Blocks may be specified with either a +do+/+end+ pair, or with curly braces in Ruby. We _strongly_ recommend using +do+/+end+ to specify the actions for tasks and rules. Because the rakefile idiom tends to -leave off parenthesis on the task/file/rule methods, unusual +leave off parentheses on the task/file/rule methods, unusual ambiguities can arise when using curly braces. For example, suppose that the method +object_files+ returns a list of object files in a project. Now we use +object_files+ as the -prerequistes in a rule specified with actions in curly braces. +prerequisites in a rule specified with actions in curly braces. # DON'T DO THIS! file "prog" => object_files { From 3806e74555cc37e7162308b9942e9653ea0c39be Mon Sep 17 00:00:00 2001 From: Daniel Corson Date: Sat, 7 Nov 2009 00:25:41 -0800 Subject: [PATCH 0082/1389] ftools is deprecated in ruby 1.9.1; use fileutils --- install.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/install.rb b/install.rb index 2d0dc619b..3b305c4f8 100644 --- a/install.rb +++ b/install.rb @@ -1,6 +1,6 @@ require 'rbconfig' require 'find' -require 'ftools' +require 'fileutils' include Config @@ -37,7 +37,8 @@ def installBIN(from, opfile) end opfile += ".rb" if CONFIG["target_os"] =~ /mswin/i - File::install(tmp_file, File.join($bindir, opfile), 0755, true) + FileUtils::install(tmp_file, File.join($bindir, opfile), + {:mode => 0755, :verbose => true}) File::unlink(tmp_file) end @@ -62,12 +63,12 @@ def installBIN(from, opfile) $bindir = destdir + $bindir $sitedir = destdir + $sitedir - File::makedirs($bindir) - File::makedirs($sitedir) + FileUtils::mkdir_p($bindir) + FileUtils::mkdir_p($sitedir) end rake_dest = File.join($sitedir, "rake") -File::makedirs(rake_dest, true) +FileUtils.mkdir_p(rake_dest, {:verbose => true}) File::chmod(0755, rake_dest) # The library files @@ -78,9 +79,10 @@ def installBIN(from, opfile) fn_dir = File.dirname(fn) target_dir = File.join($sitedir, fn_dir) if ! File.exist?(target_dir) - File.makedirs(target_dir) + FileUtils.mkdir_p(target_dir) end - File::install(File.join('lib', fn), File.join($sitedir, fn), 0644, true) + FileUtils::install(File.join('lib', fn), File.join($sitedir, fn), + {:mode => 0644, :verbose => true}) end # and the executable From 80990ea70832265ff153f5f5eb59e855345a44b8 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Tue, 22 Dec 2009 09:04:42 -0500 Subject: [PATCH 0083/1389] Renamed block variable to avoid shadowing. --- lib/rake/rake_test_loader.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rake/rake_test_loader.rb b/lib/rake/rake_test_loader.rb index 06e2e872a..9eda0773b 100644 --- a/lib/rake/rake_test_loader.rb +++ b/lib/rake/rake_test_loader.rb @@ -7,7 +7,7 @@ next if f =~ /^-/ if f =~ /\*/ - FileList[f].to_a.each { |f| load f } + FileList[f].to_a.each { |fn| load fn } else load f end From f5a1bcc4aa226be531b8dcf5ee9ce946a3048a8c Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Tue, 22 Dec 2009 09:21:49 -0500 Subject: [PATCH 0084/1389] Let's see what ruby version we are running. --- Rakefile | 3 ++- rakelib/ruby19.rake | 2 +- test/ruby_version_test.rb | 9 +++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 test/ruby_version_test.rb diff --git a/Rakefile b/Rakefile index 1df5bc62a..b24b5b858 100644 --- a/Rakefile +++ b/Rakefile @@ -62,12 +62,13 @@ task :test => "test:units" namespace :test do Rake::TestTask.new(:all) do |t| t.test_files = FileList[ + 'test/*_test.rb', 'test/lib/*_test.rb', 'test/contrib/*_test.rb', 'test/functional/*_test.rb' ] t.warning = true - t.verbose = false + t.verbose = true end Rake::TestTask.new(:units) do |t| diff --git a/rakelib/ruby19.rake b/rakelib/ruby19.rake index 075d77429..8bbd8015c 100644 --- a/rakelib/ruby19.rake +++ b/rakelib/ruby19.rake @@ -81,7 +81,7 @@ namespace "ruby19" do desc "Run the all the tests in Ruby 1.9" task :all, :opts, :needs => [:env19] do |t, args| - test_files = FileList['test/functional/*_test.rb', 'test/lib/*_test.rb'] + test_files = FileList['test/*_test.rb', 'test/functional/*_test.rb', 'test/lib/*_test.rb'] Ruby19.run_tests(test_files, args.opts) end end diff --git a/test/ruby_version_test.rb b/test/ruby_version_test.rb new file mode 100644 index 000000000..c176110ea --- /dev/null +++ b/test/ruby_version_test.rb @@ -0,0 +1,9 @@ +require 'test/unit' + +class RubyVersionTest < Test::Unit::TestCase + def test_ruby_version + puts(`which ruby`) + puts(`which ruby19`) + puts "\nRUBY VERSION = #{RUBY_VERSION}" + end +end From d8d1580d69e5a94e0267abad16b9a037a5c23407 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Tue, 22 Dec 2009 09:57:25 -0500 Subject: [PATCH 0085/1389] Trying exceptions on run code run --- Rakefile | 6 +++++- demo.rb | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 demo.rb diff --git a/Rakefile b/Rakefile index b24b5b858..6a178362c 100644 --- a/Rakefile +++ b/Rakefile @@ -47,7 +47,11 @@ SRC_RB = FileList['lib/**/*.rb'] # The default task is run if rake is given no explicit arguments. desc "Default Task" -task :default => "test:all" +# task :default => "test:all" + +task :default do + ruby "demo.rb" +end # Test Tasks --------------------------------------------------------- diff --git a/demo.rb b/demo.rb new file mode 100644 index 000000000..4f0cb8baa --- /dev/null +++ b/demo.rb @@ -0,0 +1,7 @@ +puts "Start" +begin + fail "Broken" +rescue Exception => ex + puts "Got Exception: #{ex}" +end +puts "DONE" From 61d2b6e7dd9abb697708008c3979d583abacb23e Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Tue, 22 Dec 2009 10:00:53 -0500 Subject: [PATCH 0086/1389] More r/c/r testing. --- Rakefile | 2 +- test/demo_test.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 test/demo_test.rb diff --git a/Rakefile b/Rakefile index 6a178362c..7e53b825c 100644 --- a/Rakefile +++ b/Rakefile @@ -50,7 +50,7 @@ desc "Default Task" # task :default => "test:all" task :default do - ruby "demo.rb" + ruby "test/demo_test.rb" end # Test Tasks --------------------------------------------------------- diff --git a/test/demo_test.rb b/test/demo_test.rb new file mode 100644 index 000000000..b7da39a07 --- /dev/null +++ b/test/demo_test.rb @@ -0,0 +1,9 @@ +require 'test/unit' + +class DemoTest < Test::Unit::TestCase + def test_demo + assert_raises RuntimeError do + raise "OUCH" + end + end +end From 37ed321af9d0fdf1f051132be372edc5c51704e1 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Tue, 22 Dec 2009 10:03:39 -0500 Subject: [PATCH 0087/1389] Trying assert_exception for R/C/R. --- Rakefile | 2 +- test/demo_test.rb | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index 7e53b825c..a0c27b0d2 100644 --- a/Rakefile +++ b/Rakefile @@ -50,7 +50,7 @@ desc "Default Task" # task :default => "test:all" task :default do - ruby "test/demo_test.rb" + ruby "-Ilib:test test/demo_test.rb" end # Test Tasks --------------------------------------------------------- diff --git a/test/demo_test.rb b/test/demo_test.rb index b7da39a07..df9dc9221 100644 --- a/test/demo_test.rb +++ b/test/demo_test.rb @@ -1,8 +1,11 @@ require 'test/unit' +require 'rake_test_setup' class DemoTest < Test::Unit::TestCase + include TestMethods + def test_demo - assert_raises RuntimeError do + assert_exception RuntimeError do raise "OUCH" end end From 796f502f25d569bb0c7f863739ec3434cdbe7621 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Tue, 22 Dec 2009 10:06:23 -0500 Subject: [PATCH 0088/1389] Fix for weird exception error --- test/rake_test_setup.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/rake_test_setup.rb b/test/rake_test_setup.rb index da38d97e2..9498d96ef 100644 --- a/test/rake_test_setup.rb +++ b/test/rake_test_setup.rb @@ -18,7 +18,7 @@ class Test::Unit::TestCase end module TestMethods - def assert_exception(ex, msg=nil, &block) + def assert_exception(ex, msg="", &block) assert_raise(ex, msg, &block) end end From 3e2e648a8011c5fff85631b312566e5c0aad3449 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Tue, 22 Dec 2009 10:07:19 -0500 Subject: [PATCH 0089/1389] Back to default rake task --- Rakefile | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Rakefile b/Rakefile index a0c27b0d2..b24b5b858 100644 --- a/Rakefile +++ b/Rakefile @@ -47,11 +47,7 @@ SRC_RB = FileList['lib/**/*.rb'] # The default task is run if rake is given no explicit arguments. desc "Default Task" -# task :default => "test:all" - -task :default do - ruby "-Ilib:test test/demo_test.rb" -end +task :default => "test:all" # Test Tasks --------------------------------------------------------- From 2fa0204917312487407f4da650007fde0c4b6a53 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Tue, 22 Dec 2009 10:16:34 -0500 Subject: [PATCH 0090/1389] Added test to rake_test_setup require. --- test/demo_test.rb | 2 +- test/lib/pathmap_test.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/test/demo_test.rb b/test/demo_test.rb index df9dc9221..035e532dc 100644 --- a/test/demo_test.rb +++ b/test/demo_test.rb @@ -1,5 +1,5 @@ require 'test/unit' -require 'rake_test_setup' +require 'test/rake_test_setup' class DemoTest < Test::Unit::TestCase include TestMethods diff --git a/test/lib/pathmap_test.rb b/test/lib/pathmap_test.rb index 4ba1a681b..b82b1ac83 100644 --- a/test/lib/pathmap_test.rb +++ b/test/lib/pathmap_test.rb @@ -1,6 +1,7 @@ #!/usr/bin/env ruby require 'test/unit' +require 'test/rake_test_setup' require 'rake' # ==================================================================== From 8ebd7f4ab5552b2215b7587ebee38775e87ca4aa Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Tue, 22 Dec 2009 10:31:39 -0500 Subject: [PATCH 0091/1389] problem expression for exceptions in a test --- test/demo_test.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/demo_test.rb b/test/demo_test.rb index 035e532dc..59e75bca7 100644 --- a/test/demo_test.rb +++ b/test/demo_test.rb @@ -5,8 +5,8 @@ class DemoTest < Test::Unit::TestCase include TestMethods def test_demo - assert_exception RuntimeError do - raise "OUCH" - end + ex = nil + e = StandardError.new + ex.instance_of?(Module) ? e.kind_of?(ex) : ex == e.class end end From 195e3a268ba6e413475fa1108f6d0f52138c8777 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Tue, 22 Dec 2009 10:36:13 -0500 Subject: [PATCH 0092/1389] Removed debugging output from the ruby test. --- test/ruby_version_test.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/ruby_version_test.rb b/test/ruby_version_test.rb index c176110ea..dc1fd58e1 100644 --- a/test/ruby_version_test.rb +++ b/test/ruby_version_test.rb @@ -2,8 +2,6 @@ class RubyVersionTest < Test::Unit::TestCase def test_ruby_version - puts(`which ruby`) - puts(`which ruby19`) puts "\nRUBY VERSION = #{RUBY_VERSION}" end end From 610f830abe95f651882c4b36da06c38d0e5f985b Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Tue, 22 Dec 2009 10:37:09 -0500 Subject: [PATCH 0093/1389] Removed demo files used for debugging Run Code Run issues. --- demo.rb | 7 ------- test/demo_test.rb | 12 ------------ 2 files changed, 19 deletions(-) delete mode 100644 demo.rb delete mode 100644 test/demo_test.rb diff --git a/demo.rb b/demo.rb deleted file mode 100644 index 4f0cb8baa..000000000 --- a/demo.rb +++ /dev/null @@ -1,7 +0,0 @@ -puts "Start" -begin - fail "Broken" -rescue Exception => ex - puts "Got Exception: #{ex}" -end -puts "DONE" diff --git a/test/demo_test.rb b/test/demo_test.rb deleted file mode 100644 index 59e75bca7..000000000 --- a/test/demo_test.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'test/unit' -require 'test/rake_test_setup' - -class DemoTest < Test::Unit::TestCase - include TestMethods - - def test_demo - ex = nil - e = StandardError.new - ex.instance_of?(Module) ? e.kind_of?(ex) : ex == e.class - end -end From 26ce90caf2376505fe10d02714c59f9b9b123505 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Wed, 23 Dec 2009 09:06:28 -0500 Subject: [PATCH 0094/1389] Moved test files into file lists. --- Rakefile | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Rakefile b/Rakefile index b24b5b858..154f0fa4c 100644 --- a/Rakefile +++ b/Rakefile @@ -59,32 +59,35 @@ task :tu => "test:units" task :tc => "test:contribs" task :test => "test:units" +module TestFiles + UNIT = FileList['test/lib/*_test.rb'] + FUNCTIONAL = FileList['test/functional/*_test.rb'] + CONTRIB = FileList['test/contrib/test*.rb'] + TOP = FileList['test/*_test.rb'] + ALL = TOP + UNIT + FUNCTIONAL + CONTRIB +end + namespace :test do Rake::TestTask.new(:all) do |t| - t.test_files = FileList[ - 'test/*_test.rb', - 'test/lib/*_test.rb', - 'test/contrib/*_test.rb', - 'test/functional/*_test.rb' - ] + t.test_files = TestFiles::ALL t.warning = true - t.verbose = true + t.verbose = false end Rake::TestTask.new(:units) do |t| - t.test_files = FileList['test/lib/*_test.rb'] + t.test_files = TestFiles::UNIT t.warning = true t.verbose = false end Rake::TestTask.new(:functional) do |t| - t.test_files = FileList['test/functional/*_test.rb'] + t.test_files = TestFiles::FUNCTIONAL t.warning = true t.verbose = false end Rake::TestTask.new(:contribs) do |t| - t.test_files = FileList['test/contrib/test*.rb'] + t.test_files = TestFiles::CONTRIB t.warning = true t.verbose = false end From ca5a5edfd7a3cfb870c7a043d7491fe9f59d185a Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Wed, 23 Dec 2009 09:47:56 -0500 Subject: [PATCH 0095/1389] Moved version display to file level and removed dummy test. --- test/ruby_version_test.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/test/ruby_version_test.rb b/test/ruby_version_test.rb index dc1fd58e1..7f196d9df 100644 --- a/test/ruby_version_test.rb +++ b/test/ruby_version_test.rb @@ -1,7 +1,3 @@ require 'test/unit' -class RubyVersionTest < Test::Unit::TestCase - def test_ruby_version - puts "\nRUBY VERSION = #{RUBY_VERSION}" - end -end +puts "\nRUBY VERSION = #{RUBY_VERSION}" From 7761a95feecffb17dd950ccc4674972156a54722 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Wed, 23 Dec 2009 09:49:54 -0500 Subject: [PATCH 0096/1389] Added prerequisite_tasks method. --- lib/rake/task.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/rake/task.rb b/lib/rake/task.rb index a4ecbd308..cc1b5296e 100644 --- a/lib/rake/task.rb +++ b/lib/rake/task.rb @@ -50,12 +50,16 @@ def inspect def sources @sources ||= [] end + + def prerequisite_tasks + prerequisites.collect { |pre| application[pre, @scope] } + end # First source from a rule (nil if no sources) def source @sources.first if defined?(@sources) end - + # Create a task named +task_name+ with no actions or prerequisites. Use # +enhance+ to add actions and prerequisites. def initialize(task_name, app) From 3df619e4ae3ed64233ba3e7edcf125f17a6af37c Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Wed, 23 Dec 2009 09:50:11 -0500 Subject: [PATCH 0097/1389] Moved some common includes to the setup file. --- test/rake_test_setup.rb | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/test/rake_test_setup.rb b/test/rake_test_setup.rb index 9498d96ef..59f79e604 100644 --- a/test/rake_test_setup.rb +++ b/test/rake_test_setup.rb @@ -8,16 +8,11 @@ end require 'flexmock/test_unit' - -if RUBY_VERSION >= "1.9.0" - class Test::Unit::TestCase -# def passed? -# true -# end - end -end +require 'test/filecreation' +require 'test/capture_stdout' module TestMethods + # Shim method for compatibility def assert_exception(ex, msg="", &block) assert_raise(ex, msg, &block) end From 43f2ec673d0f55724c618f35677902247a3ff52b Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Wed, 23 Dec 2009 09:50:52 -0500 Subject: [PATCH 0098/1389] Cleanup up tests. Added prereq and timestamp tests. --- test/lib/application_test.rb | 6 ++++ test/lib/task_test.rb | 67 ++++++++++++++++++++++++++++++++++-- 2 files changed, 71 insertions(+), 2 deletions(-) diff --git a/test/lib/application_test.rb b/test/lib/application_test.rb index bdd0d1740..be3e89bea 100644 --- a/test/lib/application_test.rb +++ b/test/lib/application_test.rb @@ -21,10 +21,16 @@ class TestApplication < Test::Unit::TestCase include TestMethods def setup + super @app = Rake::Application.new @app.options.rakelib = [] Rake::TaskManager.record_task_metadata = true end + + def teardown + Rake::TaskManager.record_task_metadata = false + super + end def test_constant_warning err = capture_stderr do @app.instance_eval { const_warning("Task") } end diff --git a/test/lib/task_test.rb b/test/lib/task_test.rb index 66a45425b..3594dfa85 100644 --- a/test/lib/task_test.rb +++ b/test/lib/task_test.rb @@ -3,8 +3,6 @@ require 'test/unit' require 'fileutils' require 'rake' -require 'test/filecreation' -require 'test/capture_stdout' require 'test/rake_test_setup' ###################################################################### @@ -12,9 +10,16 @@ class TestTask < Test::Unit::TestCase include CaptureStdout include Rake include TestMethods + include Rake::DSL def setup Task.clear + Rake::TaskManager.record_task_metadata = true + end + + def teardown + super + Rake::TaskManager.record_task_metadata = false end def test_create @@ -175,6 +180,56 @@ def test_filelists_can_be_prerequisites task :a => FileList.new.include("b", "c") assert_equal ["b", "c"], Task[:a].prerequisites end + + def test_prerequiste_tasks_returns_tasks_not_strings + a = task :a => ["b", "c"] + b = task :b + c = task :c + assert_equal [b, c], a.prerequisite_tasks + end + + def test_prerequiste_tasks_fails_if_prerequisites_are_undefined + a = task :a => ["b", "c"] + b = task :b + assert_exception(RuntimeError) do + a.prerequisite_tasks + end + end + + def test_prerequiste_tasks_honors_namespaces + a = b = nil + namespace "X" do + a = task :a => ["b", "c"] + b = task :b + end + c = task :c + + assert_equal [b, c], a.prerequisite_tasks + end + + def test_timestamp_returns_now_if_all_prereqs_have_no_times + a = task :a => ["b", "c"] + b = task :b + c = task :c + + faux_stamp = 100 + flexmock(Time, :now => faux_stamp) + + assert_equal faux_stamp, a.timestamp + end + + def test_timestamp_returns_latest_prereq_timestamp + a = task :a => ["b", "c"] + b = task :b + c = task :c + + faux_stamp = 100 + flexmock(Time, :now => faux_stamp-10) + flexmock(b, :timestamp => faux_stamp - 1) + flexmock(c, :timestamp => faux_stamp) + + assert_equal faux_stamp, a.timestamp + end def test_investigation_output t1 = task(:t1 => [:t2, :t3]) { |t| runlist << t.name; 3321 } @@ -223,9 +278,17 @@ class TestTaskWithArguments < Test::Unit::TestCase include CaptureStdout include Rake include TestMethods + include Rake::DSL def setup + super Task.clear + Rake::TaskManager.record_task_metadata = true + end + + def teardown + Rake::TaskManager.record_task_metadata = false + super end def test_no_args_given From 369cd12241d6577fd400daf36f30f9cff922356f Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Wed, 23 Dec 2009 09:58:24 -0500 Subject: [PATCH 0099/1389] Refactored prerequisite name lookup into a single method. --- lib/rake/task.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/rake/task.rb b/lib/rake/task.rb index cc1b5296e..d780d51f2 100644 --- a/lib/rake/task.rb +++ b/lib/rake/task.rb @@ -51,9 +51,15 @@ def sources @sources ||= [] end + # List of prerequisite tasks def prerequisite_tasks - prerequisites.collect { |pre| application[pre, @scope] } + prerequisites.collect { |pre| lookup_prerequisite(pre) } end + + def lookup_prerequisite(prerequisite_name) + application[prerequisite_name, @scope] + end + private :lookup_prerequisite # First source from a rule (nil if no sources) def source @@ -165,8 +171,7 @@ def add_chain_to(exception, new_chain) # Invoke all the prerequisites of a task. def invoke_prerequisites(task_args, invocation_chain) # :nodoc: - @prerequisites.each { |n| - prereq = application[n, @scope] + prerequisite_tasks.each { |prereq| prereq_args = task_args.new_scope(prereq.arg_names) prereq.invoke_with_call_chain(prereq_args, invocation_chain) } @@ -210,7 +215,7 @@ def needed? # Timestamp for this task. Basic tasks return the current time for their # time stamp. Other tasks can be more sophisticated. def timestamp - @prerequisites.collect { |p| application[p, @scope].timestamp }.max || Time.now + prerequisite_tasks.collect { |pre| pre.timestamp }.max || Time.now end # Add a description to the task. The description can consist of an option @@ -258,12 +263,12 @@ def investigation result << "task needed: #{needed?}\n" result << "timestamp: #{timestamp}\n" result << "pre-requisites: \n" - prereqs = @prerequisites.collect {|name| application[name, @scope]} + prereqs = prerequisite_tasks prereqs.sort! {|a,b| a.timestamp <=> b.timestamp} prereqs.each do |p| result << "--#{p.name} (#{p.timestamp})\n" end - latest_prereq = @prerequisites.collect{|n| application[n, @scope].timestamp}.max + latest_prereq = prerequisite_tasks.collect { |pre| pre.timestamp }.max result << "latest-prerequisite time: #{latest_prereq}\n" result << "................................\n\n" return result From 4cdc8738453fddbec6b5ad5f7c95a573effec192 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Wed, 23 Dec 2009 12:20:31 -0500 Subject: [PATCH 0100/1389] fileutils tests now use the currently running ruby for shell tests. --- lib/rake/file_utils.rb | 1 + test/lib/fileutils_test.rb | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/rake/file_utils.rb b/lib/rake/file_utils.rb index bcf81b00b..e20942e62 100644 --- a/lib/rake/file_utils.rb +++ b/lib/rake/file_utils.rb @@ -3,6 +3,7 @@ # added to the FileUtils utility functions. # module FileUtils + # Path to the currently running ruby. RUBY = File.join( Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'] + Config::CONFIG['EXEEXT']). diff --git a/test/lib/fileutils_test.rb b/test/lib/fileutils_test.rb index 083b2cc5d..c84e75d43 100644 --- a/test/lib/fileutils_test.rb +++ b/test/lib/fileutils_test.rb @@ -121,7 +121,7 @@ def test_fileutils_methods_dont_leak end def test_sh - verbose(false) { sh %{ruby test/shellcommand.rb} } + verbose(false) { sh %{#{FileUtils::RUBY} test/shellcommand.rb} } assert true, "should not fail" end @@ -137,37 +137,40 @@ def run(*args) def self.run(*args) new.run(*args) end + def self.ruby(*args) + Sh.run(RUBY, *args) + end end def test_sh_with_a_single_string_argument ENV['RAKE_TEST_SH'] = 'someval' verbose(false) { - sh %{ruby test/check_expansion.rb #{env_var} someval} + sh %{#{FileUtils::RUBY} test/check_expansion.rb #{env_var} someval} } end def test_sh_with_multiple_arguments ENV['RAKE_TEST_SH'] = 'someval' verbose(false) { - Sh.run 'ruby', 'test/check_no_expansion.rb', env_var, 'someval' + Sh.ruby 'test/check_no_expansion.rb', env_var, 'someval' } end def test_sh_failure assert_exception(RuntimeError) { - verbose(false) { Sh.run %{ruby test/shellcommand.rb 1} } + verbose(false) { Sh.run %{#{FileUtils::RUBY} test/shellcommand.rb 1} } } end def test_sh_special_handling count = 0 verbose(false) { - sh(%{ruby test/shellcommand.rb}) do |ok, res| + sh(%{#{FileUtils::RUBY} test/shellcommand.rb}) do |ok, res| assert(ok) assert_equal 0, res.exitstatus count += 1 end - sh(%{ruby test/shellcommand.rb 1}) do |ok, res| + sh(%{#{FileUtils::RUBY} test/shellcommand.rb 1}) do |ok, res| assert(!ok) assert_equal 1, res.exitstatus count += 1 From b6f9bdd6d00a6c405267e90ceb39588ce4e1c217 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Wed, 23 Dec 2009 12:20:47 -0500 Subject: [PATCH 0101/1389] Added comment about the RUBY constant --- lib/rake/file_utils.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rake/file_utils.rb b/lib/rake/file_utils.rb index e20942e62..21b56223c 100644 --- a/lib/rake/file_utils.rb +++ b/lib/rake/file_utils.rb @@ -3,7 +3,7 @@ # added to the FileUtils utility functions. # module FileUtils - # Path to the currently running ruby. + # Path to the currently running Ruby program RUBY = File.join( Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'] + Config::CONFIG['EXEEXT']). From 1b8942b9a5f2d496eb625fdfff20c4a7c04b6893 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Thu, 31 Dec 2009 12:20:07 -0500 Subject: [PATCH 0102/1389] Changed class method calls from :: to . --- install.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/install.rb b/install.rb index 3b305c4f8..f1e7c82a4 100644 --- a/install.rb +++ b/install.rb @@ -37,9 +37,9 @@ def installBIN(from, opfile) end opfile += ".rb" if CONFIG["target_os"] =~ /mswin/i - FileUtils::install(tmp_file, File.join($bindir, opfile), + FileUtils.install(tmp_file, File.join($bindir, opfile), {:mode => 0755, :verbose => true}) - File::unlink(tmp_file) + File.unlink(tmp_file) end $sitedir = CONFIG["sitelibdir"] @@ -63,13 +63,13 @@ def installBIN(from, opfile) $bindir = destdir + $bindir $sitedir = destdir + $sitedir - FileUtils::mkdir_p($bindir) - FileUtils::mkdir_p($sitedir) + FileUtils.mkdir_p($bindir) + FileUtils.mkdir_p($sitedir) end rake_dest = File.join($sitedir, "rake") FileUtils.mkdir_p(rake_dest, {:verbose => true}) -File::chmod(0755, rake_dest) +File.chmod(0755, rake_dest) # The library files @@ -81,7 +81,7 @@ def installBIN(from, opfile) if ! File.exist?(target_dir) FileUtils.mkdir_p(target_dir) end - FileUtils::install(File.join('lib', fn), File.join($sitedir, fn), + FileUtils.install(File.join('lib', fn), File.join($sitedir, fn), {:mode => 0644, :verbose => true}) end From eeb81eb05dcbe7456e059c5aa42e343aadfd3802 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Thu, 7 Jan 2010 09:16:04 -0800 Subject: [PATCH 0103/1389] Fixed egrep to capture errors. --- lib/rake/file_list.rb | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/rake/file_list.rb b/lib/rake/file_list.rb index cd6749c4b..0262e67c5 100644 --- a/lib/rake/file_list.rb +++ b/lib/rake/file_list.rb @@ -283,18 +283,22 @@ def ext(newext='') # standard out. def egrep(pattern, *options) each do |fn| - open(fn, "rb", *options) do |inf| - count = 0 - inf.each do |line| - count += 1 - if pattern.match(line) - if block_given? - yield fn, count, line - else - puts "#{fn}:#{count}:#{line}" + begin + open(fn, "rb", *options) do |inf| + count = 0 + inf.each do |line| + count += 1 + if pattern.match(line) + if block_given? + yield fn, count, line + else + puts "#{fn}:#{count}:#{line}" + end end end end + rescue StandardError => ex + puts "Error while processing '#{fn}': #{ex}" end end end From 853aa2e4d96369fc936938440f2f2589ca5eb47d Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Thu, 7 Jan 2010 09:16:17 -0800 Subject: [PATCH 0104/1389] Bumped version to 0.8.99.4 --- lib/rake.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rake.rb b/lib/rake.rb index db89b71cd..aa5f7ab01 100755 --- a/lib/rake.rb +++ b/lib/rake.rb @@ -23,7 +23,7 @@ # IN THE SOFTWARE. #++ -RAKEVERSION = '0.8.99.3' +RAKEVERSION = '0.8.99.4' require 'rbconfig' require 'fileutils' From 99137a80057adcb0566cad3bd6950ba1a2e4a728 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Fri, 8 Jan 2010 06:52:51 -0800 Subject: [PATCH 0105/1389] Added "." as library (for Ruby 1.9.2) --- Rakefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Rakefile b/Rakefile index 154f0fa4c..47daf3fe1 100644 --- a/Rakefile +++ b/Rakefile @@ -70,26 +70,26 @@ end namespace :test do Rake::TestTask.new(:all) do |t| t.test_files = TestFiles::ALL + t.libs << "." t.warning = true - t.verbose = false end Rake::TestTask.new(:units) do |t| t.test_files = TestFiles::UNIT + t.libs << "." t.warning = true - t.verbose = false end Rake::TestTask.new(:functional) do |t| t.test_files = TestFiles::FUNCTIONAL + t.libs << "." t.warning = true - t.verbose = false end Rake::TestTask.new(:contribs) do |t| t.test_files = TestFiles::CONTRIB + t.libs << "." t.warning = true - t.verbose = false end end From 285f2496a66803b739ce98fa90375c1c81758428 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Fri, 8 Jan 2010 22:46:51 -0800 Subject: [PATCH 0106/1389] Added <=> to list of must define methods for FileList (due to change in <=> behavior in latest 1.9.2) --- lib/rake/file_list.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rake/file_list.rb b/lib/rake/file_list.rb index 0262e67c5..eaf4c78f1 100644 --- a/lib/rake/file_list.rb +++ b/lib/rake/file_list.rb @@ -43,7 +43,7 @@ class FileList ARRAY_METHODS = (Array.instance_methods - Object.instance_methods).map { |n| n.to_s } # List of additional methods that must be delegated. - MUST_DEFINE = %w[to_a inspect] + MUST_DEFINE = %w[to_a inspect <=>] # List of methods that should not be delegated here (we define special # versions of them explicitly below). From 35ad8e96379928aa1be846a0649f61a0b6bdce0c Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Mon, 11 Jan 2010 07:24:25 -0500 Subject: [PATCH 0107/1389] require 'rake/file_list' can now be done without including all of rake. --- lib/rake/file_utils.rb | 3 +++ test/functional/session_based_tests.rb | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/lib/rake/file_utils.rb b/lib/rake/file_utils.rb index 21b56223c..153470524 100644 --- a/lib/rake/file_utils.rb +++ b/lib/rake/file_utils.rb @@ -1,3 +1,6 @@ +require 'rbconfig' +require 'fileutils' + # ########################################################################### # This a FileUtils extension that defines several additional commands to be # added to the FileUtils utility functions. diff --git a/test/functional/session_based_tests.rb b/test/functional/session_based_tests.rb index 5549dc638..b69f9bbe3 100644 --- a/test/functional/session_based_tests.rb +++ b/test/functional/session_based_tests.rb @@ -392,6 +392,13 @@ def test_correct_number_of_tasks_reported assert_equal(3, @out.split(/\n/).grep(/t\d/).size) end + def test_file_list_is_requirable_separately + @rake_path = '' + rake "-rrake/file_list", "-e 'puts Rake::FileList[\"a\"].size'" + assert_equal "1\n", @out + assert_equal 0, @status + end + private def assert_not_match(pattern, string, comment="'#{pattern}' was found (incorrectly) in '#{string}.inspect") From 8f5f008e9105ae395b318cee5d4df9a31b7ca83d Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Mon, 11 Jan 2010 07:46:55 -0500 Subject: [PATCH 0108/1389] Refactored session tests allowing command line ruby and rake commands. --- test/functional/session_based_tests.rb | 35 +++++++++++++------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/test/functional/session_based_tests.rb b/test/functional/session_based_tests.rb index b69f9bbe3..3ec55c883 100644 --- a/test/functional/session_based_tests.rb +++ b/test/functional/session_based_tests.rb @@ -33,7 +33,7 @@ class SessionBasedTests < Test::Unit::TestCase def setup @rake_path = File.expand_path("bin/rake") lib_path = File.expand_path("lib") - @ruby_options = "-I#{lib_path} -I." + @ruby_options = ["-I#{lib_path}", "-I."] @verbose = ! ENV['VERBOSE'].nil? if @verbose puts @@ -393,8 +393,7 @@ def test_correct_number_of_tasks_reported end def test_file_list_is_requirable_separately - @rake_path = '' - rake "-rrake/file_list", "-e 'puts Rake::FileList[\"a\"].size'" + ruby "-rrake/file_list", "-e 'puts Rake::FileList[\"a\"].size'" assert_equal "1\n", @out assert_equal 0, @status end @@ -417,22 +416,24 @@ def remove_namespace_files end end - class << self - def format_command - @format_command ||= lambda { |ruby_options, rake_path, options| - "ruby #{ruby_options} #{rake_path} #{options}" - } - end - - def format_command=(fmt_command) - @format_command = fmt_command - end + # Run a shell Ruby command with command line options (using the + # default test options). Output is captured in @out, @err and + # @status. + def ruby(*option_list) + run_ruby(@ruby_options + option_list) end - - def rake(*option_list) - options = option_list.join(' ') + + # Run a command line rake with the give rake options. Default + # command line ruby options are included. Output is captured in + # @out, @err and @status. + def rake(*rake_options) + run_ruby @ruby_options + [@rake_path] + rake_options + end + + # Low level ruby command runner ... + def run_ruby(option_list) shell = Session::Shell.new - command = self.class.format_command[@ruby_options, @rake_path, options] + command = "#{RUBY_COMMAND} " + option_list.join(' ') puts "COMMAND: [#{command}]" if @verbose @out, @err = shell.execute command @status = shell.exit_status From 57b88a8a1131ad3962664bcedf20698d06e22c73 Mon Sep 17 00:00:00 2001 From: quix Date: Mon, 11 Jan 2010 16:14:18 -0500 Subject: [PATCH 0109/1389] require 'rake/dsl' now includes DSL at top-level --- lib/rake.rb | 2 +- lib/rake/dsl.rb | 138 +------------------------------------ lib/rake/dsl_definition.rb | 136 ++++++++++++++++++++++++++++++++++++ lib/rake/environment.rb | 2 +- lib/rake/task_manager.rb | 2 +- test/lib/dsl_test.rb | 11 +++ 6 files changed, 152 insertions(+), 139 deletions(-) create mode 100644 lib/rake/dsl_definition.rb diff --git a/lib/rake.rb b/lib/rake.rb index aa5f7ab01..424e5a4c5 100755 --- a/lib/rake.rb +++ b/lib/rake.rb @@ -48,7 +48,7 @@ require 'rake/file_task' require 'rake/file_creation_task' require 'rake/multi_task' -require 'rake/dsl' +require 'rake/dsl_definition' require 'rake/rake_file_utils' require 'rake/file_list' require 'rake/default_loader' diff --git a/lib/rake/dsl.rb b/lib/rake/dsl.rb index c144f0030..88fc8e2ea 100644 --- a/lib/rake/dsl.rb +++ b/lib/rake/dsl.rb @@ -1,136 +1,2 @@ -# Rake DSL functions. - -module Rake - module DSL - # Declare a basic task. - # - # Example: - # task :clobber => [:clean] do - # rm_rf "html" - # end - # - def task(*args, &block) - Rake::Task.define_task(*args, &block) - end - - - # Declare a file task. - # - # Example: - # file "config.cfg" => ["config.template"] do - # open("config.cfg", "w") do |outfile| - # open("config.template") do |infile| - # while line = infile.gets - # outfile.puts line - # end - # end - # end - # end - # - def file(*args, &block) - Rake::FileTask.define_task(*args, &block) - end - - # Declare a file creation task. - # (Mainly used for the directory command). - def file_create(args, &block) - Rake::FileCreationTask.define_task(args, &block) - end - - # Declare a set of files tasks to create the given directories on - # demand. - # - # Example: - # directory "testdata/doc" - # - def directory(dir) - Rake.each_dir_parent(dir) do |d| - file_create d do |t| - mkdir_p t.name if ! File.exist?(t.name) - end - end - end - - # Declare a task that performs its prerequisites in - # parallel. Multitasks does *not* guarantee that its prerequisites - # will execute in any given order (which is obvious when you think - # about it) - # - # Example: - # multitask :deploy => [:deploy_gem, :deploy_rdoc] - # - def multitask(args, &block) - Rake::MultiTask.define_task(args, &block) - end - - # Create a new rake namespace and use it for evaluating the given - # block. Returns a NameSpace object that can be used to lookup - # tasks defined in the namespace. - # - # E.g. - # - # ns = namespace "nested" do - # task :run - # end - # task_run = ns[:run] # find :run in the given namespace. - # - def namespace(name=nil, &block) - name = name.to_s if name.kind_of?(Symbol) - name = name.to_str if name.respond_to?(:to_str) - unless name.kind_of?(String) || name.nil? - raise ArgumentError, "Expected a String or Symbol for a namespace name" - end - Rake.application.in_namespace(name, &block) - end - - # Declare a rule for auto-tasks. - # - # Example: - # rule '.o' => '.c' do |t| - # sh %{cc -o #{t.name} #{t.source}} - # end - # - def rule(*args, &block) - Rake::Task.create_rule(*args, &block) - end - - # Describe the next rake task. - # - # Example: - # desc "Run the Unit Tests" - # task :test => [:build] - # runtests - # end - # - def desc(description) - Rake.application.last_description = description - end - - # Import the partial Rakefiles +fn+. Imported files are loaded - # _after_ the current file is completely loaded. This allows the - # import statement to appear anywhere in the importing file, and yet - # allowing the imported files to depend on objects defined in the - # importing file. - # - # A common use of the import statement is to include files - # containing dependency declarations. - # - # See also the --rakelibdir command line option. - # - # Example: - # import ".depend", "my_rules" - # - def import(*fns) - fns.each do |fn| - Rake.application.add_import(fn) - end - end - - # Include the Rake DSL commands in the top level Ruby scope. - def self.include_in_top_scope - Object.send(:include, Rake::DSL) - end - end - -end - +require 'rake' +include Rake::DSL diff --git a/lib/rake/dsl_definition.rb b/lib/rake/dsl_definition.rb new file mode 100644 index 000000000..c144f0030 --- /dev/null +++ b/lib/rake/dsl_definition.rb @@ -0,0 +1,136 @@ +# Rake DSL functions. + +module Rake + module DSL + # Declare a basic task. + # + # Example: + # task :clobber => [:clean] do + # rm_rf "html" + # end + # + def task(*args, &block) + Rake::Task.define_task(*args, &block) + end + + + # Declare a file task. + # + # Example: + # file "config.cfg" => ["config.template"] do + # open("config.cfg", "w") do |outfile| + # open("config.template") do |infile| + # while line = infile.gets + # outfile.puts line + # end + # end + # end + # end + # + def file(*args, &block) + Rake::FileTask.define_task(*args, &block) + end + + # Declare a file creation task. + # (Mainly used for the directory command). + def file_create(args, &block) + Rake::FileCreationTask.define_task(args, &block) + end + + # Declare a set of files tasks to create the given directories on + # demand. + # + # Example: + # directory "testdata/doc" + # + def directory(dir) + Rake.each_dir_parent(dir) do |d| + file_create d do |t| + mkdir_p t.name if ! File.exist?(t.name) + end + end + end + + # Declare a task that performs its prerequisites in + # parallel. Multitasks does *not* guarantee that its prerequisites + # will execute in any given order (which is obvious when you think + # about it) + # + # Example: + # multitask :deploy => [:deploy_gem, :deploy_rdoc] + # + def multitask(args, &block) + Rake::MultiTask.define_task(args, &block) + end + + # Create a new rake namespace and use it for evaluating the given + # block. Returns a NameSpace object that can be used to lookup + # tasks defined in the namespace. + # + # E.g. + # + # ns = namespace "nested" do + # task :run + # end + # task_run = ns[:run] # find :run in the given namespace. + # + def namespace(name=nil, &block) + name = name.to_s if name.kind_of?(Symbol) + name = name.to_str if name.respond_to?(:to_str) + unless name.kind_of?(String) || name.nil? + raise ArgumentError, "Expected a String or Symbol for a namespace name" + end + Rake.application.in_namespace(name, &block) + end + + # Declare a rule for auto-tasks. + # + # Example: + # rule '.o' => '.c' do |t| + # sh %{cc -o #{t.name} #{t.source}} + # end + # + def rule(*args, &block) + Rake::Task.create_rule(*args, &block) + end + + # Describe the next rake task. + # + # Example: + # desc "Run the Unit Tests" + # task :test => [:build] + # runtests + # end + # + def desc(description) + Rake.application.last_description = description + end + + # Import the partial Rakefiles +fn+. Imported files are loaded + # _after_ the current file is completely loaded. This allows the + # import statement to appear anywhere in the importing file, and yet + # allowing the imported files to depend on objects defined in the + # importing file. + # + # A common use of the import statement is to include files + # containing dependency declarations. + # + # See also the --rakelibdir command line option. + # + # Example: + # import ".depend", "my_rules" + # + def import(*fns) + fns.each do |fn| + Rake.application.add_import(fn) + end + end + + # Include the Rake DSL commands in the top level Ruby scope. + def self.include_in_top_scope + Object.send(:include, Rake::DSL) + end + end + +end + diff --git a/lib/rake/environment.rb b/lib/rake/environment.rb index aaac7f987..4a7686313 100644 --- a/lib/rake/environment.rb +++ b/lib/rake/environment.rb @@ -1,4 +1,4 @@ -require 'rake/dsl' +require 'rake/dsl_definition' module Rake diff --git a/lib/rake/task_manager.rb b/lib/rake/task_manager.rb index db9744ca5..9a59b12e3 100644 --- a/lib/rake/task_manager.rb +++ b/lib/rake/task_manager.rb @@ -220,7 +220,7 @@ def find_location locations = caller i = 0 while locations[i] - return locations[i+1] if locations[i] =~ /rake\/dsl.rb/ + return locations[i+1] if locations[i] =~ /rake\/dsl_definition.rb/ i += 1 end nil diff --git a/test/lib/dsl_test.rb b/test/lib/dsl_test.rb index cd9983f6e..0f5b9bd33 100644 --- a/test/lib/dsl_test.rb +++ b/test/lib/dsl_test.rb @@ -38,4 +38,15 @@ def name.to_str end assert_not_nil Rake::Task["bob:t"] end + + def test_dsl_not_toplevel_by_default + actual = TOPLEVEL_BINDING.instance_eval { defined?(task) } + assert_nil actual + end + + def test_dsl_toplevel_when_require_rake_dsl + assert_nothing_raised { + ruby '-I./lib', '-rrake/dsl', '-e', 'task(:x) { }', :verbose => false + } + end end From 7329d526e4594467a65f5b5431f7ff408daa062f Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Tue, 12 Jan 2010 01:45:38 -0500 Subject: [PATCH 0110/1389] Removed blank line --- lib/rake/dsl_definition.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/rake/dsl_definition.rb b/lib/rake/dsl_definition.rb index c144f0030..bc33f8b62 100644 --- a/lib/rake/dsl_definition.rb +++ b/lib/rake/dsl_definition.rb @@ -133,4 +133,3 @@ def self.include_in_top_scope end end - From 1ae7442d01753b3f6aef4224ab85ae6925ff7aa2 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Tue, 12 Jan 2010 01:55:20 -0500 Subject: [PATCH 0111/1389] Moved to structured version numbers in a separate file. --- lib/rake.rb | 4 +++- lib/rake/version.rb | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 lib/rake/version.rb diff --git a/lib/rake.rb b/lib/rake.rb index 424e5a4c5..1830b4c39 100755 --- a/lib/rake.rb +++ b/lib/rake.rb @@ -23,7 +23,9 @@ # IN THE SOFTWARE. #++ -RAKEVERSION = '0.8.99.4' +require 'rake/version' + +RAKEVERSION = Rake::VERSION require 'rbconfig' require 'fileutils' diff --git a/lib/rake/version.rb b/lib/rake/version.rb new file mode 100644 index 000000000..0b83b253b --- /dev/null +++ b/lib/rake/version.rb @@ -0,0 +1,11 @@ +module Rake + module Version + NUMBERS = [ + MAJOR = 0, + MINOR = 8, + BUILD = 99, + BETA = 5, + ] + end + VERSION = Version::NUMBERS.join('.') +end From cb9fc5d19663108986c92f4608da489a0dfb9875 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Tue, 12 Jan 2010 07:59:50 -0500 Subject: [PATCH 0112/1389] Updated copyright notices. --- lib/rake.rb | 2 +- lib/rake/contrib/publisher.rb | 6 +----- lib/rake/contrib/sys.rb | 22 ++-------------------- 3 files changed, 4 insertions(+), 26 deletions(-) diff --git a/lib/rake.rb b/lib/rake.rb index 1830b4c39..99344d876 100755 --- a/lib/rake.rb +++ b/lib/rake.rb @@ -2,7 +2,7 @@ #-- -# Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 by Jim Weirich (jim.weirich@gmail.com) +# Copyright 2003-2010 by Jim Weirich (jim.weirich@gmail.com) # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to diff --git a/lib/rake/contrib/publisher.rb b/lib/rake/contrib/publisher.rb index 65cc01fb4..b78573582 100644 --- a/lib/rake/contrib/publisher.rb +++ b/lib/rake/contrib/publisher.rb @@ -1,12 +1,8 @@ #!/usr/bin/env ruby -# Copyright 2003, 2004, 2005, 2006, 2007, 2008 by Jim Weirich (jim@weirichhouse.org) +# Copyright 2003-2010 by Jim Weirich (jim.weirich@gmail.com) # All rights reserved. -# Permission is granted for use, copying, modification, distribution, -# and distribution of modified versions of this work as long as the -# above copyright notice is included. - # Configuration information about an upload host system. # * name :: Name of host system. # * webdir :: Base directory for the web information for the diff --git a/lib/rake/contrib/sys.rb b/lib/rake/contrib/sys.rb index d7e955452..c26803e33 100644 --- a/lib/rake/contrib/sys.rb +++ b/lib/rake/contrib/sys.rb @@ -1,26 +1,8 @@ #!/usr/bin/env ruby #-- -# Copyright 2003, 2004, 2005, 2006, 2007, 2008 by Jim Weirich (jim@weirichhouse.org) -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# Copyright 2003-2010 by Jim Weirich (jim.weirich@gmail.com) +# All rights reserved. #++ # begin From e401b55d04bc5bcc335101b68d3acf3ebd883e12 Mon Sep 17 00:00:00 2001 From: Rafael Rosa Date: Tue, 19 Jan 2010 12:18:13 -0200 Subject: [PATCH 0113/1389] Fixed rake_require to correctly save the loaded file names and avoid reloading after the first time --- lib/rake/application.rb | 4 ++-- test/lib/require_test.rb | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/rake/application.rb b/lib/rake/application.rb index 25aeddc65..359e73e02 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -440,9 +440,9 @@ def handle_options # Similar to the regular Ruby +require+ command, but will check # for *.rake files in addition to *.rb files. def rake_require(file_name, paths=$LOAD_PATH, loaded=$") - return false if loaded.include?(file_name) + fn = file_name + ".rake" + return false if loaded.include?(fn) paths.each do |path| - fn = file_name + ".rake" full_path = File.join(path, fn) if File.exist?(full_path) Rake::Environment.load_rakefile(full_path) diff --git a/test/lib/require_test.rb b/test/lib/require_test.rb index 6c2158f82..948f97098 100644 --- a/test/lib/require_test.rb +++ b/test/lib/require_test.rb @@ -17,8 +17,13 @@ def test_can_load_rake_library def test_wont_reload_rake_library app = Rake::Application.new + + paths = ['test/data/rakelib'] + loaded_files = [] + app.rake_require("test2", paths, loaded_files) + assert ! app.instance_eval { - rake_require("test2", ['test/data/rakelib'], ['test2']) + rake_require("test2", paths, loaded_files) } end From f26004e2c2f28565af0f162aa5f437599b2ed8a4 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Thu, 4 Feb 2010 22:00:52 -0500 Subject: [PATCH 0114/1389] Improved rake_ require test. --- test/lib/require_test.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/lib/require_test.rb b/test/lib/require_test.rb index 948f97098..7fd0889af 100644 --- a/test/lib/require_test.rb +++ b/test/lib/require_test.rb @@ -34,7 +34,8 @@ def test_throws_error_if_library_not_found rake_require("testx", ['test/data/rakelib'], []) } } - assert_match(/x/, ex.message) + assert_match(/(can *not|can't)\s+find/i, ex.message) + assert_match(/testx/, ex.message) end end From ebb22f387b4bff2bc42576ff4e5c41d9eccf56de Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Thu, 4 Feb 2010 22:06:32 -0500 Subject: [PATCH 0115/1389] Fixed misspelling of pseudo --- lib/rake.rb | 2 +- lib/rake/{psuedo_status.rb => pseudo_status.rb} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename lib/rake/{psuedo_status.rb => pseudo_status.rb} (100%) diff --git a/lib/rake.rb b/lib/rake.rb index 99344d876..1fe426cf8 100755 --- a/lib/rake.rb +++ b/lib/rake.rb @@ -43,7 +43,7 @@ require 'rake/task_argument_error' require 'rake/rule_recursion_overflow_error' require 'rake/rake_module' -require 'rake/psuedo_status' +require 'rake/pseudo_status' require 'rake/task_arguments' require 'rake/invocation_chain' require 'rake/task' diff --git a/lib/rake/psuedo_status.rb b/lib/rake/pseudo_status.rb similarity index 100% rename from lib/rake/psuedo_status.rb rename to lib/rake/pseudo_status.rb From 60ad5d90d469161524944b72bda67b40fa30ea65 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Thu, 4 Feb 2010 22:10:20 -0500 Subject: [PATCH 0116/1389] Fixed doc typos --- lib/rake/file_list.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/rake/file_list.rb b/lib/rake/file_list.rb index eaf4c78f1..faa892261 100644 --- a/lib/rake/file_list.rb +++ b/lib/rake/file_list.rb @@ -224,7 +224,7 @@ def resolve_exclude private :resolve_exclude # Return a new FileList with the results of running +sub+ against each - # element of the oringal list. + # element of the orignal list. # # Example: # FileList['a.c', 'b.c'].sub(/\.c$/, '.o') => ['a.o', 'b.o'] @@ -263,8 +263,8 @@ def pathmap(spec=nil) collect { |fn| fn.pathmap(spec) } end - # Return a new FileList with String#ext method applied - # to each member of the array. + # Return a new FileList with String#ext method applied to + # each member of the array. # # This method is a shortcut for: # From 5148aac8b61246432d6d87f19f26e401ace62853 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Thu, 4 Feb 2010 22:19:01 -0500 Subject: [PATCH 0117/1389] Task args no longer pick up values from the shell environment. --- lib/rake/task_arguments.rb | 4 ---- test/lib/task_arguments_test.rb | 6 +++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/rake/task_arguments.rb b/lib/rake/task_arguments.rb index 379cd2fb2..39fe3e781 100644 --- a/lib/rake/task_arguments.rb +++ b/lib/rake/task_arguments.rb @@ -64,10 +64,6 @@ def inspect def lookup(name) if @hash.has_key?(name) @hash[name] - elsif ENV.has_key?(name.to_s) - ENV[name.to_s] - elsif ENV.has_key?(name.to_s.upcase) - ENV[name.to_s.upcase] elsif @parent @parent.lookup(name) end diff --git a/test/lib/task_arguments_test.rb b/test/lib/task_arguments_test.rb index 520a16fc0..b2a1212eb 100644 --- a/test/lib/task_arguments_test.rb +++ b/test/lib/task_arguments_test.rb @@ -50,12 +50,12 @@ def test_extra_names_are_nil assert_nil ta.cc end - def test_args_can_reference_env_values + def test_args_do_not_reference_env_values ta = Rake::TaskArguments.new(["aa"], [1]) ENV['rev'] = "1.2" ENV['VER'] = "2.3" - assert_equal "1.2", ta.rev - assert_equal "2.3", ta.ver + assert_nil ta.rev + assert_nil ta.ver end def test_creating_new_argument_scopes From f4ca3dd48c3635a6af5ed95acd386b802910139f Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Thu, 17 Dec 2009 12:26:32 -0500 Subject: [PATCH 0118/1389] Changes to egrep --- lib/rake/file_list.rb | 7 +++++-- test/lib/filelist_test.rb | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/rake/file_list.rb b/lib/rake/file_list.rb index faa892261..11b0c37ae 100644 --- a/lib/rake/file_list.rb +++ b/lib/rake/file_list.rb @@ -280,8 +280,9 @@ def ext(newext='') # block is given, call the block on each matching line, passing the file # name, line number, and the matching line of text. If no block is given, # a standard emac style file:linenumber:line message will be printed to - # standard out. + # standard out. Returns the number of matched items. def egrep(pattern, *options) + matched = 0 each do |fn| begin open(fn, "rb", *options) do |inf| @@ -289,6 +290,7 @@ def egrep(pattern, *options) inf.each do |line| count += 1 if pattern.match(line) + matched += 1 if block_given? yield fn, count, line else @@ -301,8 +303,9 @@ def egrep(pattern, *options) puts "Error while processing '#{fn}': #{ex}" end end + matched end - + # Return a new file list that only contains file names from the current # file list that exist on the file system. def existing diff --git a/test/lib/filelist_test.rb b/test/lib/filelist_test.rb index 26483997d..f901cc626 100644 --- a/test/lib/filelist_test.rb +++ b/test/lib/filelist_test.rb @@ -323,6 +323,12 @@ def test_gsub! f.sort end + def test_egrep_returns_0_if_no_matches + files = FileList['test/lib/*_test.rb'] + the_line_number = __LINE__ + 1 + assert_equal 0, files.egrep(/XYZZY/) { } + end + def test_egrep_with_output files = FileList['test/lib/*_test.rb'] the_line_number = __LINE__ + 1 From b58d2e3a73377a1df7634253b6090205c2f0e63e Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Thu, 4 Feb 2010 22:59:51 -0500 Subject: [PATCH 0119/1389] Updated test for egrep --- test/lib/filelist_test.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/lib/filelist_test.rb b/test/lib/filelist_test.rb index f901cc626..c433ab37f 100644 --- a/test/lib/filelist_test.rb +++ b/test/lib/filelist_test.rb @@ -324,7 +324,7 @@ def test_gsub! end def test_egrep_returns_0_if_no_matches - files = FileList['test/lib/*_test.rb'] + files = FileList['test/lib/*_test.rb'].exclude("test/lib/filelist_test.rb") the_line_number = __LINE__ + 1 assert_equal 0, files.egrep(/XYZZY/) { } end @@ -338,15 +338,14 @@ def test_egrep_with_output def test_egrep_with_block files = FileList['test/lib/*_test.rb'] - found = false + found = nil the_line_number = __LINE__ + 1 files.egrep(/XYZZY/) do |fn, ln, line | - assert_equal 'test/lib/filelist_test.rb', fn - assert_equal the_line_number, ln - assert_match(/files\.egrep/, line) - found = true + found = [fn, ln, line] end - assert found, "should have found a matching line" + assert_equal 'test/lib/filelist_test.rb', found[0] + assert_equal the_line_number, found[1] + assert_match(/files\.egrep/, found[2]) end def test_existing From ce724c2ef6a52bcec572e15c44cb997ac9830491 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Fri, 5 Feb 2010 07:38:30 -0500 Subject: [PATCH 0120/1389] FileUtils methods are now part of the DSL --- lib/rake.rb | 8 -------- lib/rake/application.rb | 12 ++++++------ lib/rake/dsl_definition.rb | 11 +++++++++++ lib/rake/file_utils.rb | 4 ++-- lib/rake/rake_file_utils.rb | 3 --- test/lib/fileutils_test.rb | 1 + 6 files changed, 20 insertions(+), 19 deletions(-) diff --git a/lib/rake.rb b/lib/rake.rb index 1fe426cf8..de9fb306e 100755 --- a/lib/rake.rb +++ b/lib/rake.rb @@ -64,11 +64,3 @@ # Alias FileList to be available at the top level. FileList = Rake::FileList - -# Include the FileUtils file manipulation functions in the top level module, -# but mark them private so that they don't unintentionally define methods on -# other objects. - -include RakeFileUtils -private(*FileUtils.instance_methods(false)) -private(*RakeFileUtils.instance_methods(false)) diff --git a/lib/rake/application.rb b/lib/rake/application.rb index 359e73e02..8f653e835 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -288,8 +288,8 @@ def standard_rake_options ], ['--dry-run', '-n', "Do a dry run without executing actions.", lambda { |value| - verbose(true) - nowrite(true) + Rake.verbose(true) + Rake.nowrite(true) options.dryrun = true options.trace = true } @@ -317,7 +317,7 @@ def standard_rake_options lambda { |value| options.show_prereqs = true } ], ['--quiet', '-q', "Do not log messages to standard output.", - lambda { |value| verbose(false) } + lambda { |value| Rake.verbose(false) } ], ['--rakefile', '-f [FILE]', "Use FILE as the rakefile.", lambda { |value| @@ -351,7 +351,7 @@ def standard_rake_options ], ['--silent', '-s', "Like --quiet, but also suppresses the 'in directory' announcement.", lambda { |value| - verbose(false) + Rake.verbose(false) options.silent = true } ], @@ -383,11 +383,11 @@ def standard_rake_options ['--trace', '-t', "Turn on invoke/execute tracing, enable full backtrace.", lambda { |value| options.trace = true - verbose(true) + Rake.verbose(true) } ], ['--verbose', '-v', "Log message to standard output.", - lambda { |value| verbose(true) } + lambda { |value| Rake.verbose(true) } ], ['--version', '-V', "Display the program version.", lambda { |value| diff --git a/lib/rake/dsl_definition.rb b/lib/rake/dsl_definition.rb index bc33f8b62..d83e67a3d 100644 --- a/lib/rake/dsl_definition.rb +++ b/lib/rake/dsl_definition.rb @@ -1,7 +1,17 @@ # Rake DSL functions. +require 'rake/rake_file_utils' module Rake module DSL + + # Include the FileUtils file manipulation functions in the top + # level module, but mark them private so that they don't + # unintentionally define methods on other objects. + + include RakeFileUtils + private(*FileUtils.instance_methods(false)) + private(*RakeFileUtils.instance_methods(false)) + # Declare a basic task. # # Example: @@ -132,4 +142,5 @@ def self.include_in_top_scope end end + extend RakeFileUtils end diff --git a/lib/rake/file_utils.rb b/lib/rake/file_utils.rb index 153470524..ad0cb85d4 100644 --- a/lib/rake/file_utils.rb +++ b/lib/rake/file_utils.rb @@ -36,8 +36,8 @@ def sh(*cmd, &block) shell_runner = block_given? ? block : create_shell_runner(cmd) set_verbose_option(options) options[:noop] ||= RakeFileUtils.nowrite_flag - rake_check_options options, :noop, :verbose - rake_output_message cmd.join(" ") if options[:verbose] + Rake.rake_check_options options, :noop, :verbose + Rake.rake_output_message cmd.join(" ") if options[:verbose] unless options[:noop] res = rake_system(*cmd) status = $? diff --git a/lib/rake/rake_file_utils.rb b/lib/rake/rake_file_utils.rb index c1d88c049..3c11432da 100644 --- a/lib/rake/rake_file_utils.rb +++ b/lib/rake/rake_file_utils.rb @@ -109,13 +109,11 @@ def rake_merge_option(args, defaults) args.push defaults args end - private :rake_merge_option # Send the message to the default rake output (which is $stderr). def rake_output_message(message) $stderr.puts(message) end - private :rake_output_message # Check that the options do not contain options not listed in +optdecl+. An # ArgumentError exception is thrown if non-declared options are found. @@ -126,7 +124,6 @@ def rake_check_options(options, *optdecl) end raise ArgumentError, "no such option: #{h.keys.join(' ')}" unless h.empty? end - private :rake_check_options extend self end diff --git a/test/lib/fileutils_test.rb b/test/lib/fileutils_test.rb index c84e75d43..e9b6388e9 100644 --- a/test/lib/fileutils_test.rb +++ b/test/lib/fileutils_test.rb @@ -10,6 +10,7 @@ class TestFileUtils < Test::Unit::TestCase include FileCreation include TestMethods + include Rake::DSL def setup File.chmod(0750,"test/shellcommand.rb") From 22e6bf7d46d1008ed0787e66b3c197edf2cc048d Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Fri, 5 Feb 2010 07:53:11 -0500 Subject: [PATCH 0121/1389] Moved RakeFileUtils into the Rake module --- lib/rake/file_utils.rb | 4 +- lib/rake/rake_file_utils.rb | 232 ++++++++++++++------------- test/lib/application_test.rb | 26 +-- test/lib/file_task_test.rb | 4 +- test/lib/fileutils_test.rb | 16 +- test/lib/top_level_functions_test.rb | 4 +- 6 files changed, 144 insertions(+), 142 deletions(-) diff --git a/lib/rake/file_utils.rb b/lib/rake/file_utils.rb index ad0cb85d4..8cc55ee7b 100644 --- a/lib/rake/file_utils.rb +++ b/lib/rake/file_utils.rb @@ -35,7 +35,7 @@ def sh(*cmd, &block) options = (Hash === cmd.last) ? cmd.pop : {} shell_runner = block_given? ? block : create_shell_runner(cmd) set_verbose_option(options) - options[:noop] ||= RakeFileUtils.nowrite_flag + options[:noop] ||= Rake::RakeFileUtils.nowrite_flag Rake.rake_check_options options, :noop, :verbose Rake.rake_output_message cmd.join(" ") if options[:verbose] unless options[:noop] @@ -57,7 +57,7 @@ def create_shell_runner(cmd) def set_verbose_option(options) if options[:verbose].nil? - options[:verbose] = RakeFileUtils.verbose_flag.nil? || RakeFileUtils.verbose_flag + options[:verbose] = Rake::RakeFileUtils.verbose_flag.nil? || Rake::RakeFileUtils.verbose_flag end end private :set_verbose_option diff --git a/lib/rake/rake_file_utils.rb b/lib/rake/rake_file_utils.rb index 3c11432da..e6c9042a4 100644 --- a/lib/rake/rake_file_utils.rb +++ b/lib/rake/rake_file_utils.rb @@ -1,130 +1,132 @@ require 'rake/file_utils' -# ########################################################################### -# RakeFileUtils provides a custom version of the FileUtils methods that -# respond to the verbose and nowrite commands. -# -module RakeFileUtils - include FileUtils - - class << self - attr_accessor :verbose_flag, :nowrite_flag - end - RakeFileUtils.verbose_flag = nil - RakeFileUtils.nowrite_flag = false - - $fileutils_verbose = true - $fileutils_nowrite = false - - FileUtils::OPT_TABLE.each do |name, opts| - default_options = [] - if opts.include?(:verbose) || opts.include?("verbose") - default_options << ':verbose => RakeFileUtils.verbose_flag' +module Rake + # ########################################################################### + # RakeFileUtils provides a custom version of the FileUtils methods that + # respond to the verbose and nowrite commands. + # + module RakeFileUtils + include FileUtils + + class << self + attr_accessor :verbose_flag, :nowrite_flag end - if opts.include?(:noop) || opts.include?("noop") - default_options << ':noop => RakeFileUtils.nowrite_flag' + RakeFileUtils.verbose_flag = nil + RakeFileUtils.nowrite_flag = false + + $fileutils_verbose = true + $fileutils_nowrite = false + + FileUtils::OPT_TABLE.each do |name, opts| + default_options = [] + if opts.include?(:verbose) || opts.include?("verbose") + default_options << ':verbose => RakeFileUtils.verbose_flag' + end + if opts.include?(:noop) || opts.include?("noop") + default_options << ':noop => RakeFileUtils.nowrite_flag' + end + + next if default_options.empty? + module_eval(<<-EOS, __FILE__, __LINE__ + 1) + def #{name}( *args, &block ) + super( + *rake_merge_option(args, + #{default_options.join(', ')} + ), &block) + end + EOS end - - next if default_options.empty? - module_eval(<<-EOS, __FILE__, __LINE__ + 1) - def #{name}( *args, &block ) - super( - *rake_merge_option(args, - #{default_options.join(', ')} - ), &block) + + # Get/set the verbose flag controlling output from the FileUtils utilities. + # If verbose is true, then the utility method is echoed to standard output. + # + # Examples: + # verbose # return the current value of the verbose flag + # verbose(v) # set the verbose flag to _v_. + # verbose(v) { code } # Execute code with the verbose flag set temporarily to _v_. + # # Return to the original value when code is done. + def verbose(value=nil) + oldvalue = RakeFileUtils.verbose_flag + RakeFileUtils.verbose_flag = value unless value.nil? + if block_given? + begin + yield + ensure + RakeFileUtils.verbose_flag = oldvalue + end + end + RakeFileUtils.verbose_flag end - EOS - end - - # Get/set the verbose flag controlling output from the FileUtils utilities. - # If verbose is true, then the utility method is echoed to standard output. - # - # Examples: - # verbose # return the current value of the verbose flag - # verbose(v) # set the verbose flag to _v_. - # verbose(v) { code } # Execute code with the verbose flag set temporarily to _v_. - # # Return to the original value when code is done. - def verbose(value=nil) - oldvalue = RakeFileUtils.verbose_flag - RakeFileUtils.verbose_flag = value unless value.nil? - if block_given? - begin - yield - ensure - RakeFileUtils.verbose_flag = oldvalue + + # Get/set the nowrite flag controlling output from the FileUtils utilities. + # If verbose is true, then the utility method is echoed to standard output. + # + # Examples: + # nowrite # return the current value of the nowrite flag + # nowrite(v) # set the nowrite flag to _v_. + # nowrite(v) { code } # Execute code with the nowrite flag set temporarily to _v_. + # # Return to the original value when code is done. + def nowrite(value=nil) + oldvalue = RakeFileUtils.nowrite_flag + RakeFileUtils.nowrite_flag = value unless value.nil? + if block_given? + begin + yield + ensure + RakeFileUtils.nowrite_flag = oldvalue + end end + oldvalue end - RakeFileUtils.verbose_flag - end - - # Get/set the nowrite flag controlling output from the FileUtils utilities. - # If verbose is true, then the utility method is echoed to standard output. - # - # Examples: - # nowrite # return the current value of the nowrite flag - # nowrite(v) # set the nowrite flag to _v_. - # nowrite(v) { code } # Execute code with the nowrite flag set temporarily to _v_. - # # Return to the original value when code is done. - def nowrite(value=nil) - oldvalue = RakeFileUtils.nowrite_flag - RakeFileUtils.nowrite_flag = value unless value.nil? - if block_given? - begin + + # Use this function to prevent protentially destructive ruby code from + # running when the :nowrite flag is set. + # + # Example: + # + # when_writing("Building Project") do + # project.build + # end + # + # The following code will build the project under normal conditions. If the + # nowrite(true) flag is set, then the example will print: + # DRYRUN: Building Project + # instead of actually building the project. + # + def when_writing(msg=nil) + if RakeFileUtils.nowrite_flag + puts "DRYRUN: #{msg}" if msg + else yield - ensure - RakeFileUtils.nowrite_flag = oldvalue end end - oldvalue - end - - # Use this function to prevent protentially destructive ruby code from - # running when the :nowrite flag is set. - # - # Example: - # - # when_writing("Building Project") do - # project.build - # end - # - # The following code will build the project under normal conditions. If the - # nowrite(true) flag is set, then the example will print: - # DRYRUN: Building Project - # instead of actually building the project. - # - def when_writing(msg=nil) - if RakeFileUtils.nowrite_flag - puts "DRYRUN: #{msg}" if msg - else - yield + + # Merge the given options with the default values. + def rake_merge_option(args, defaults) + if Hash === args.last + defaults.update(args.last) + args.pop + end + args.push defaults + args end - end - - # Merge the given options with the default values. - def rake_merge_option(args, defaults) - if Hash === args.last - defaults.update(args.last) - args.pop + + # Send the message to the default rake output (which is $stderr). + def rake_output_message(message) + $stderr.puts(message) end - args.push defaults - args - end - - # Send the message to the default rake output (which is $stderr). - def rake_output_message(message) - $stderr.puts(message) - end - - # Check that the options do not contain options not listed in +optdecl+. An - # ArgumentError exception is thrown if non-declared options are found. - def rake_check_options(options, *optdecl) - h = options.dup - optdecl.each do |name| - h.delete name + + # Check that the options do not contain options not listed in +optdecl+. An + # ArgumentError exception is thrown if non-declared options are found. + def rake_check_options(options, *optdecl) + h = options.dup + optdecl.each do |name| + h.delete name + end + raise ArgumentError, "no such option: #{h.keys.join(' ')}" unless h.empty? end - raise ArgumentError, "no such option: #{h.keys.join(' ')}" unless h.empty? + + extend self end - - extend self + end - diff --git a/test/lib/application_test.rb b/test/lib/application_test.rb index be3e89bea..14a4d8289 100644 --- a/test/lib/application_test.rb +++ b/test/lib/application_test.rb @@ -322,15 +322,15 @@ class TestApplicationOptions < Test::Unit::TestCase def setup clear_argv - RakeFileUtils.verbose_flag = false - RakeFileUtils.nowrite_flag = false + Rake::RakeFileUtils.verbose_flag = false + Rake::RakeFileUtils.nowrite_flag = false TESTING_REQUIRE.clear end def teardown clear_argv - RakeFileUtils.verbose_flag = false - RakeFileUtils.nowrite_flag = false + Rake::RakeFileUtils.verbose_flag = false + Rake::RakeFileUtils.nowrite_flag = false end def clear_argv @@ -354,8 +354,8 @@ def test_default_options assert_nil opts.silent assert_nil opts.trace assert_equal ['rakelib'], opts.rakelib - assert ! RakeFileUtils.verbose_flag - assert ! RakeFileUtils.nowrite_flag + assert ! Rake::RakeFileUtils.verbose_flag + assert ! Rake::RakeFileUtils.nowrite_flag end end @@ -364,8 +364,8 @@ def test_dry_run flags('--dry-run', '-n') do |opts| assert opts.dryrun assert opts.trace - assert RakeFileUtils.verbose_flag - assert RakeFileUtils.nowrite_flag + assert Rake::RakeFileUtils.verbose_flag + assert Rake::RakeFileUtils.nowrite_flag end end end @@ -493,7 +493,7 @@ def test_prereqs def test_quiet in_environment do flags('--quiet', '-q') do |opts| - assert ! RakeFileUtils.verbose_flag + assert ! Rake::RakeFileUtils.verbose_flag assert ! opts.silent end end @@ -510,7 +510,7 @@ def test_no_search def test_silent in_environment do flags('--silent', '-s') do |opts| - assert ! RakeFileUtils.verbose_flag + assert ! Rake::RakeFileUtils.verbose_flag assert opts.silent end end @@ -536,8 +536,8 @@ def test_trace in_environment do flags('--trace', '-t') do |opts| assert opts.trace - assert RakeFileUtils.verbose_flag - assert ! RakeFileUtils.nowrite_flag + assert Rake::RakeFileUtils.verbose_flag + assert ! Rake::RakeFileUtils.nowrite_flag end end end @@ -566,7 +566,7 @@ def test_tasks def test_verbose in_environment do flags('--verbose', '-V') do |opts| - assert RakeFileUtils.verbose_flag + assert Rake::RakeFileUtils.verbose_flag assert ! opts.silent end end diff --git a/test/lib/file_task_test.rb b/test/lib/file_task_test.rb index bfb08f9c6..edac7e7b8 100644 --- a/test/lib/file_task_test.rb +++ b/test/lib/file_task_test.rb @@ -97,11 +97,11 @@ class TestDirectoryTask < Test::Unit::TestCase include Rake def setup - rm_rf "testdata", :verbose=>false + Rake.rm_rf "testdata", :verbose=>false end def teardown - rm_rf "testdata", :verbose=>false + Rake.rm_rf "testdata", :verbose=>false end def test_directory diff --git a/test/lib/fileutils_test.rb b/test/lib/fileutils_test.rb index e9b6388e9..d44c79a25 100644 --- a/test/lib/fileutils_test.rb +++ b/test/lib/fileutils_test.rb @@ -46,12 +46,12 @@ def test_rm_filelist def test_ln create_dir("testdata") open("testdata/a", "w") { |f| f.puts "TEST_LN" } - RakeFileUtils.safe_ln("testdata/a", "testdata/b", :verbose => false) + Rake::RakeFileUtils.safe_ln("testdata/a", "testdata/b", :verbose => false) assert_equal "TEST_LN\n", open("testdata/b") { |f| f.read } end class BadLink - include RakeFileUtils + include Rake::RakeFileUtils attr_reader :cp_args def initialize(klass) @failure_class = klass @@ -225,12 +225,12 @@ def test_ruby_with_multiple_arguments end def test_split_all - assert_equal ['a'], RakeFileUtils.split_all('a') - assert_equal ['..'], RakeFileUtils.split_all('..') - assert_equal ['/'], RakeFileUtils.split_all('/') - assert_equal ['a', 'b'], RakeFileUtils.split_all('a/b') - assert_equal ['/', 'a', 'b'], RakeFileUtils.split_all('/a/b') - assert_equal ['..', 'a', 'b'], RakeFileUtils.split_all('../a/b') + assert_equal ['a'], Rake::RakeFileUtils.split_all('a') + assert_equal ['..'], Rake::RakeFileUtils.split_all('..') + assert_equal ['/'], Rake::RakeFileUtils.split_all('/') + assert_equal ['a', 'b'], Rake::RakeFileUtils.split_all('a/b') + assert_equal ['/', 'a', 'b'], Rake::RakeFileUtils.split_all('/a/b') + assert_equal ['..', 'a', 'b'], Rake::RakeFileUtils.split_all('../a/b') end private diff --git a/test/lib/top_level_functions_test.rb b/test/lib/top_level_functions_test.rb index 193902877..1d90b1907 100644 --- a/test/lib/top_level_functions_test.rb +++ b/test/lib/top_level_functions_test.rb @@ -49,7 +49,7 @@ def test_when_writing end def test_when_not_writing - RakeFileUtils.nowrite_flag = true + Rake::RakeFileUtils.nowrite_flag = true out = capture_stdout do when_writing("NOTWRITING") do puts "WRITING" @@ -57,7 +57,7 @@ def test_when_not_writing end assert_equal "DRYRUN: NOTWRITING\n", out ensure - RakeFileUtils.nowrite_flag = false + Rake::RakeFileUtils.nowrite_flag = false end def test_missing_constants_task From 321178d888ecbce99a1ef3bfad80324e30f4c469 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Fri, 5 Feb 2010 08:01:25 -0500 Subject: [PATCH 0122/1389] Renamed RakeFileUtils to FileUtilsExt --- lib/rake.rb | 2 +- lib/rake/dsl_definition.rb | 8 +++--- lib/rake/file_list.rb | 2 +- lib/rake/file_utils.rb | 4 +-- .../{rake_file_utils.rb => file_utils_ext.rb} | 28 +++++++++---------- lib/rake/testtask.rb | 2 +- test/lib/application_test.rb | 26 ++++++++--------- test/lib/fileutils_test.rb | 16 +++++------ test/lib/top_level_functions_test.rb | 4 +-- 9 files changed, 46 insertions(+), 46 deletions(-) rename lib/rake/{rake_file_utils.rb => file_utils_ext.rb} (83%) diff --git a/lib/rake.rb b/lib/rake.rb index de9fb306e..1da819cfc 100755 --- a/lib/rake.rb +++ b/lib/rake.rb @@ -51,7 +51,7 @@ require 'rake/file_creation_task' require 'rake/multi_task' require 'rake/dsl_definition' -require 'rake/rake_file_utils' +require 'rake/file_utils_ext' require 'rake/file_list' require 'rake/default_loader' require 'rake/early_time' diff --git a/lib/rake/dsl_definition.rb b/lib/rake/dsl_definition.rb index d83e67a3d..2c0147609 100644 --- a/lib/rake/dsl_definition.rb +++ b/lib/rake/dsl_definition.rb @@ -1,5 +1,5 @@ # Rake DSL functions. -require 'rake/rake_file_utils' +require 'rake/file_utils_ext' module Rake module DSL @@ -8,9 +8,9 @@ module DSL # level module, but mark them private so that they don't # unintentionally define methods on other objects. - include RakeFileUtils + include FileUtilsExt private(*FileUtils.instance_methods(false)) - private(*RakeFileUtils.instance_methods(false)) + private(*FileUtilsExt.instance_methods(false)) # Declare a basic task. # @@ -142,5 +142,5 @@ def self.include_in_top_scope end end - extend RakeFileUtils + extend FileUtilsExt end diff --git a/lib/rake/file_list.rb b/lib/rake/file_list.rb index 11b0c37ae..6e5d4a0e7 100644 --- a/lib/rake/file_list.rb +++ b/lib/rake/file_list.rb @@ -1,5 +1,5 @@ require 'rake/cloneable' -require 'rake/rake_file_utils' +require 'rake/file_utils_ext' ###################################################################### module Rake diff --git a/lib/rake/file_utils.rb b/lib/rake/file_utils.rb index 8cc55ee7b..332cb0c10 100644 --- a/lib/rake/file_utils.rb +++ b/lib/rake/file_utils.rb @@ -35,7 +35,7 @@ def sh(*cmd, &block) options = (Hash === cmd.last) ? cmd.pop : {} shell_runner = block_given? ? block : create_shell_runner(cmd) set_verbose_option(options) - options[:noop] ||= Rake::RakeFileUtils.nowrite_flag + options[:noop] ||= Rake::FileUtilsExt.nowrite_flag Rake.rake_check_options options, :noop, :verbose Rake.rake_output_message cmd.join(" ") if options[:verbose] unless options[:noop] @@ -57,7 +57,7 @@ def create_shell_runner(cmd) def set_verbose_option(options) if options[:verbose].nil? - options[:verbose] = Rake::RakeFileUtils.verbose_flag.nil? || Rake::RakeFileUtils.verbose_flag + options[:verbose] = Rake::FileUtilsExt.verbose_flag.nil? || Rake::FileUtilsExt.verbose_flag end end private :set_verbose_option diff --git a/lib/rake/rake_file_utils.rb b/lib/rake/file_utils_ext.rb similarity index 83% rename from lib/rake/rake_file_utils.rb rename to lib/rake/file_utils_ext.rb index e6c9042a4..e670777f1 100644 --- a/lib/rake/rake_file_utils.rb +++ b/lib/rake/file_utils_ext.rb @@ -2,17 +2,17 @@ module Rake # ########################################################################### - # RakeFileUtils provides a custom version of the FileUtils methods that + # FileUtilsExt provides a custom version of the FileUtils methods that # respond to the verbose and nowrite commands. # - module RakeFileUtils + module FileUtilsExt include FileUtils class << self attr_accessor :verbose_flag, :nowrite_flag end - RakeFileUtils.verbose_flag = nil - RakeFileUtils.nowrite_flag = false + FileUtilsExt.verbose_flag = nil + FileUtilsExt.nowrite_flag = false $fileutils_verbose = true $fileutils_nowrite = false @@ -20,10 +20,10 @@ class << self FileUtils::OPT_TABLE.each do |name, opts| default_options = [] if opts.include?(:verbose) || opts.include?("verbose") - default_options << ':verbose => RakeFileUtils.verbose_flag' + default_options << ':verbose => FileUtilsExt.verbose_flag' end if opts.include?(:noop) || opts.include?("noop") - default_options << ':noop => RakeFileUtils.nowrite_flag' + default_options << ':noop => FileUtilsExt.nowrite_flag' end next if default_options.empty? @@ -46,16 +46,16 @@ def #{name}( *args, &block ) # verbose(v) { code } # Execute code with the verbose flag set temporarily to _v_. # # Return to the original value when code is done. def verbose(value=nil) - oldvalue = RakeFileUtils.verbose_flag - RakeFileUtils.verbose_flag = value unless value.nil? + oldvalue = FileUtilsExt.verbose_flag + FileUtilsExt.verbose_flag = value unless value.nil? if block_given? begin yield ensure - RakeFileUtils.verbose_flag = oldvalue + FileUtilsExt.verbose_flag = oldvalue end end - RakeFileUtils.verbose_flag + FileUtilsExt.verbose_flag end # Get/set the nowrite flag controlling output from the FileUtils utilities. @@ -67,13 +67,13 @@ def verbose(value=nil) # nowrite(v) { code } # Execute code with the nowrite flag set temporarily to _v_. # # Return to the original value when code is done. def nowrite(value=nil) - oldvalue = RakeFileUtils.nowrite_flag - RakeFileUtils.nowrite_flag = value unless value.nil? + oldvalue = FileUtilsExt.nowrite_flag + FileUtilsExt.nowrite_flag = value unless value.nil? if block_given? begin yield ensure - RakeFileUtils.nowrite_flag = oldvalue + FileUtilsExt.nowrite_flag = oldvalue end end oldvalue @@ -94,7 +94,7 @@ def nowrite(value=nil) # instead of actually building the project. # def when_writing(msg=nil) - if RakeFileUtils.nowrite_flag + if FileUtilsExt.nowrite_flag puts "DRYRUN: #{msg}" if msg else yield diff --git a/lib/rake/testtask.rb b/lib/rake/testtask.rb index 5c82824f3..8278e8cdb 100644 --- a/lib/rake/testtask.rb +++ b/lib/rake/testtask.rb @@ -97,7 +97,7 @@ def initialize(name=:test) def define desc "Run tests" + (@name==:test ? "" : " for #{@name}") task @name do - RakeFileUtils.verbose(@verbose) do + FileUtilsExt.verbose(@verbose) do ruby "#{ruby_opts_string} #{run_code} #{file_list_string} #{option_list}" end end diff --git a/test/lib/application_test.rb b/test/lib/application_test.rb index 14a4d8289..4c2d33ea4 100644 --- a/test/lib/application_test.rb +++ b/test/lib/application_test.rb @@ -322,15 +322,15 @@ class TestApplicationOptions < Test::Unit::TestCase def setup clear_argv - Rake::RakeFileUtils.verbose_flag = false - Rake::RakeFileUtils.nowrite_flag = false + Rake::FileUtilsExt.verbose_flag = false + Rake::FileUtilsExt.nowrite_flag = false TESTING_REQUIRE.clear end def teardown clear_argv - Rake::RakeFileUtils.verbose_flag = false - Rake::RakeFileUtils.nowrite_flag = false + Rake::FileUtilsExt.verbose_flag = false + Rake::FileUtilsExt.nowrite_flag = false end def clear_argv @@ -354,8 +354,8 @@ def test_default_options assert_nil opts.silent assert_nil opts.trace assert_equal ['rakelib'], opts.rakelib - assert ! Rake::RakeFileUtils.verbose_flag - assert ! Rake::RakeFileUtils.nowrite_flag + assert ! Rake::FileUtilsExt.verbose_flag + assert ! Rake::FileUtilsExt.nowrite_flag end end @@ -364,8 +364,8 @@ def test_dry_run flags('--dry-run', '-n') do |opts| assert opts.dryrun assert opts.trace - assert Rake::RakeFileUtils.verbose_flag - assert Rake::RakeFileUtils.nowrite_flag + assert Rake::FileUtilsExt.verbose_flag + assert Rake::FileUtilsExt.nowrite_flag end end end @@ -493,7 +493,7 @@ def test_prereqs def test_quiet in_environment do flags('--quiet', '-q') do |opts| - assert ! Rake::RakeFileUtils.verbose_flag + assert ! Rake::FileUtilsExt.verbose_flag assert ! opts.silent end end @@ -510,7 +510,7 @@ def test_no_search def test_silent in_environment do flags('--silent', '-s') do |opts| - assert ! Rake::RakeFileUtils.verbose_flag + assert ! Rake::FileUtilsExt.verbose_flag assert opts.silent end end @@ -536,8 +536,8 @@ def test_trace in_environment do flags('--trace', '-t') do |opts| assert opts.trace - assert Rake::RakeFileUtils.verbose_flag - assert ! Rake::RakeFileUtils.nowrite_flag + assert Rake::FileUtilsExt.verbose_flag + assert ! Rake::FileUtilsExt.nowrite_flag end end end @@ -566,7 +566,7 @@ def test_tasks def test_verbose in_environment do flags('--verbose', '-V') do |opts| - assert Rake::RakeFileUtils.verbose_flag + assert Rake::FileUtilsExt.verbose_flag assert ! opts.silent end end diff --git a/test/lib/fileutils_test.rb b/test/lib/fileutils_test.rb index d44c79a25..7af8b8168 100644 --- a/test/lib/fileutils_test.rb +++ b/test/lib/fileutils_test.rb @@ -46,12 +46,12 @@ def test_rm_filelist def test_ln create_dir("testdata") open("testdata/a", "w") { |f| f.puts "TEST_LN" } - Rake::RakeFileUtils.safe_ln("testdata/a", "testdata/b", :verbose => false) + Rake::FileUtilsExt.safe_ln("testdata/a", "testdata/b", :verbose => false) assert_equal "TEST_LN\n", open("testdata/b") { |f| f.read } end class BadLink - include Rake::RakeFileUtils + include Rake::FileUtilsExt attr_reader :cp_args def initialize(klass) @failure_class = klass @@ -225,12 +225,12 @@ def test_ruby_with_multiple_arguments end def test_split_all - assert_equal ['a'], Rake::RakeFileUtils.split_all('a') - assert_equal ['..'], Rake::RakeFileUtils.split_all('..') - assert_equal ['/'], Rake::RakeFileUtils.split_all('/') - assert_equal ['a', 'b'], Rake::RakeFileUtils.split_all('a/b') - assert_equal ['/', 'a', 'b'], Rake::RakeFileUtils.split_all('/a/b') - assert_equal ['..', 'a', 'b'], Rake::RakeFileUtils.split_all('../a/b') + assert_equal ['a'], Rake::FileUtilsExt.split_all('a') + assert_equal ['..'], Rake::FileUtilsExt.split_all('..') + assert_equal ['/'], Rake::FileUtilsExt.split_all('/') + assert_equal ['a', 'b'], Rake::FileUtilsExt.split_all('a/b') + assert_equal ['/', 'a', 'b'], Rake::FileUtilsExt.split_all('/a/b') + assert_equal ['..', 'a', 'b'], Rake::FileUtilsExt.split_all('../a/b') end private diff --git a/test/lib/top_level_functions_test.rb b/test/lib/top_level_functions_test.rb index 1d90b1907..fc8366cf1 100644 --- a/test/lib/top_level_functions_test.rb +++ b/test/lib/top_level_functions_test.rb @@ -49,7 +49,7 @@ def test_when_writing end def test_when_not_writing - Rake::RakeFileUtils.nowrite_flag = true + Rake::FileUtilsExt.nowrite_flag = true out = capture_stdout do when_writing("NOTWRITING") do puts "WRITING" @@ -57,7 +57,7 @@ def test_when_not_writing end assert_equal "DRYRUN: NOTWRITING\n", out ensure - Rake::RakeFileUtils.nowrite_flag = false + Rake::FileUtilsExt.nowrite_flag = false end def test_missing_constants_task From c9bf4d287e00a7ee4735cb8f590aaedcfeeab791 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Mon, 8 Feb 2010 14:30:05 -0500 Subject: [PATCH 0123/1389] Updated rake readme to point to the pivotal and the bug reports. --- README.rdoc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/README.rdoc b/README.rdoc index ed1e8eb1c..6ac73b6fb 100644 --- a/README.rdoc +++ b/README.rdoc @@ -111,13 +111,16 @@ If you wish to run the unit and functional tests that come with Rake: === Issues and Bug Reports -Bugs, features requests and other issues can be logged at +Feature requests and bug reports can be made here -* http://onestepback.org/redmine/projects/show/rake +* http://onestepback.org/cgi-bin/bugs.cgi?project=rake + +No account is needed for posting requests. Or you can send me an +email (at jim dot weirich at gmail dot com) -You will need an account to before you can post issues. Register at -http://onestepback.org/redmine/account/register. Or you can send me -an email (at jim dot weirich at gmail dot com) +Issues and bug reports can be tracked here: + +* http://www.pivotaltracker.com/projects/28469 == Online Resources @@ -128,6 +131,8 @@ an email (at jim dot weirich at gmail dot com) * Rake API Documents: http://rake.rubyforge.org * Rake Source Code Repo: http://github.com/jimweirich/rake * Rake Git Repo Clone URL: git://github.com/jimweirich/rake.git +* Rake Issue Tracking: http://www.pivotaltracker.com/projects/28469 +* Rake Bug Reports: http://onestepback.org/cgi-bin/bugs.cgi?project=rake === Presentations and Articles about Rake From e43d143aba7afdaa158f9aefeb0f5c39ccb17600 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Wed, 24 Mar 2010 07:21:44 +0000 Subject: [PATCH 0124/1389] Example failure --- test/lib/application_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/lib/application_test.rb b/test/lib/application_test.rb index 4c2d33ea4..50785db23 100644 --- a/test/lib/application_test.rb +++ b/test/lib/application_test.rb @@ -34,7 +34,7 @@ def teardown def test_constant_warning err = capture_stderr do @app.instance_eval { const_warning("Task") } end - assert_match(/warning/i, err) + assert_match(/xwarning/i, err) assert_match(/deprecated/i, err) assert_match(/Task/i, err) end From e2c6553a4be02f6d5ed12ff5a9a1c1ad0d02eb1f Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Wed, 24 Mar 2010 07:23:04 +0000 Subject: [PATCH 0125/1389] Fixed example failure --- test/lib/application_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/lib/application_test.rb b/test/lib/application_test.rb index 50785db23..4c2d33ea4 100644 --- a/test/lib/application_test.rb +++ b/test/lib/application_test.rb @@ -34,7 +34,7 @@ def teardown def test_constant_warning err = capture_stderr do @app.instance_eval { const_warning("Task") } end - assert_match(/xwarning/i, err) + assert_match(/warning/i, err) assert_match(/deprecated/i, err) assert_match(/Task/i, err) end From fa52911b9f31528118b01512c640811630fa2ec5 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Wed, 24 Mar 2010 12:04:13 +0000 Subject: [PATCH 0126/1389] Explicitly broke a test. --- test/lib/filelist_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/lib/filelist_test.rb b/test/lib/filelist_test.rb index c433ab37f..0cf28b0aa 100644 --- a/test/lib/filelist_test.rb +++ b/test/lib/filelist_test.rb @@ -29,7 +29,7 @@ def test_delgating_methods_do_not_include_to_a_or_to_ary def test_create fl = FileList.new - assert_equal 0, fl.size + assert_equal 1, fl.size end def test_create_with_args From c90c7b5727a806dda7598c4f572db4fee683a182 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Wed, 24 Mar 2010 12:10:10 +0000 Subject: [PATCH 0127/1389] Fixed demo broken test. --- test/lib/filelist_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/lib/filelist_test.rb b/test/lib/filelist_test.rb index 0cf28b0aa..c433ab37f 100644 --- a/test/lib/filelist_test.rb +++ b/test/lib/filelist_test.rb @@ -29,7 +29,7 @@ def test_delgating_methods_do_not_include_to_a_or_to_ary def test_create fl = FileList.new - assert_equal 1, fl.size + assert_equal 0, fl.size end def test_create_with_args From 0df4b81b12f1992119e46090ffd1ab162eb6164f Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Wed, 19 May 2010 09:28:50 -0400 Subject: [PATCH 0128/1389] updated readme. --- README.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rdoc b/README.rdoc index 6ac73b6fb..7b8ec9a67 100644 --- a/README.rdoc +++ b/README.rdoc @@ -3,7 +3,7 @@ Supporting Rake version: 0.8.7. This package contains Rake, a simple ruby build program with -capabilities similar to make. +capabilities similar to make. Rake has the following features: From 82f13eb5ec89d754249137ff696a538aa5a19f6b Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Fri, 24 Sep 2010 12:24:47 -0400 Subject: [PATCH 0129/1389] More sophisticated tag generation. --- rakelib/tags.rake | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/rakelib/tags.rake b/rakelib/tags.rake index d1e11291e..da499b142 100644 --- a/rakelib/tags.rake +++ b/rakelib/tags.rake @@ -2,17 +2,55 @@ module Tags PROG = ENV['TAGS'] || 'ctags' - RUBY_FILES = FileList['**/*.rb'].exclude('sys.rb') - RUBY_FILES.include('**/*.rake') + + RAKEFILES = FileList['Rakefile', '**/*.rake'] + + FILES = FileList['**/*.rb', '**/*.js'] + RAKEFILES + FILES.exclude('pkg', 'dist') + + RVM_GEMDIR = File.join(`rvm gemdir`.strip, "gems") + DIR_LIST = ['.'] + DIR_LIST << RVM_GEMDIR if File.exists?(RVM_GEMDIR) + DIRS = DIR_LIST.join(" ") + + OPTION_FILE = '.ctags_options' + + module_function + + # Convert key_word to --key-word. + def keyword(key) + k = key.to_s.gsub(/_/, '-') + (k.length == 1) ? "-#{k}" : "--#{k}" + end + + # Run ctags command + def run(*args) + opts = { + :e => true, + :totals => true, + :recurse => true, + } + opts = opts.merge(args.pop) if args.last.is_a?(Hash) + command_args = opts.map { |k, v| + (v == true) ? keyword(k) : "#{keyword(k)}=#{v}" + }.join(" ") + sh %{#{Tags::PROG} #{command_args} #{args.join(' ')}} + end end namespace "tags" do desc "Generate an Emacs TAGS file" - task :emacs => Tags::RUBY_FILES do + task :emacs => Tags::FILES do puts "Making Emacs TAGS file" - sh "#{Tags::PROG} -e #{Tags::RUBY_FILES}", :verbose => false + verbose(true) do + Tags.run(Tags::DIRS) + Tags.run(Tags::RAKEFILES, + :language_force => "ruby", + :append => true) + end end end desc "Generate the TAGS file" task :tags => ["tags:emacs"] + From 9dad17999fb8710cfcad9fc6dc93a34c9271cf70 Mon Sep 17 00:00:00 2001 From: Jim Weirich Date: Fri, 24 Sep 2010 13:23:45 -0400 Subject: [PATCH 0130/1389] Removed option file constant. --- rakelib/tags.rake | 2 -- 1 file changed, 2 deletions(-) diff --git a/rakelib/tags.rake b/rakelib/tags.rake index da499b142..465a60b85 100644 --- a/rakelib/tags.rake +++ b/rakelib/tags.rake @@ -13,8 +13,6 @@ module Tags DIR_LIST << RVM_GEMDIR if File.exists?(RVM_GEMDIR) DIRS = DIR_LIST.join(" ") - OPTION_FILE = '.ctags_options' - module_function # Convert key_word to --key-word. From bf7bc7796cd8198f5843a5db285c393bad6c965f Mon Sep 17 00:00:00 2001 From: raggi Date: Thu, 11 Nov 2010 11:49:48 -0800 Subject: [PATCH 0131/1389] fix rakefile_location for nil callers and not catching methods in the call trace --- lib/rake/application.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/rake/application.rb b/lib/rake/application.rb index 8f653e835..15d229219 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -569,11 +569,9 @@ def const_warning(const_name) end def rakefile_location - begin - fail - rescue RuntimeError => ex - ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || "" - end + bt = caller + bt.map { |t| t[/([^:]+):/,1] } + bt.find {|str| str =~ /^#{@rakefile}$/ } || "" end end end From 66326539bb531a41e67df097de852f8bf6010cdc Mon Sep 17 00:00:00 2001 From: Alex Chaffee Date: Fri, 12 Nov 2010 16:36:42 -0800 Subject: [PATCH 0132/1389] don't print the rakefile directory message if it's in the same directory we started in --- README.rdoc | 1 + lib/rake/application.rb | 8 ++++-- test/functional/functional_test.rb | 4 +-- test/lib/application_test.rb | 39 ++++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 5 deletions(-) diff --git a/README.rdoc b/README.rdoc index 7b8ec9a67..c51d01c59 100644 --- a/README.rdoc +++ b/README.rdoc @@ -102,6 +102,7 @@ http://github.com/jimweirich/rake. The public git clone URL is If you wish to run the unit and functional tests that come with Rake: +* Install the 'flexmock' gem * Install the 'session' gem in order to run the functional tests. * CD into the top project directory of rake. * Type one of the following: diff --git a/lib/rake/application.rb b/lib/rake/application.rb index 8f653e835..f0d802929 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -467,12 +467,16 @@ def find_rakefile_location Dir.chdir(Rake.original_dir) end + def maybe_print_rakefile_directory(location) + puts "(in #{Dir.pwd})" unless (options.silent or original_dir == location) + end + def raw_load_rakefile # :nodoc: rakefile, location = find_rakefile_location if (! options.ignore_system) && (options.load_system || rakefile.nil?) && system_dir && File.directory?(system_dir) - puts "(in #{Dir.pwd})" unless options.silent + maybe_print_rakefile_directory(location) glob("#{system_dir}/*.rake") do |name| add_import name end @@ -481,7 +485,7 @@ def raw_load_rakefile # :nodoc: rakefile.nil? @rakefile = rakefile Dir.chdir(location) - puts "(in #{Dir.pwd})" unless options.silent + maybe_print_rakefile_directory(location) $rakefile = @rakefile if options.classic_namespace Rake::Environment.load_rakefile(File.expand_path(@rakefile)) if @rakefile && @rakefile != '' options.rakelib.each do |rlib| diff --git a/test/functional/functional_test.rb b/test/functional/functional_test.rb index 301f78370..805f20bb9 100644 --- a/test/functional/functional_test.rb +++ b/test/functional/functional_test.rb @@ -5,11 +5,9 @@ gem 'session' require 'session' rescue LoadError - puts "UNABLE TO RUN FUNCTIONAL TESTS" - puts "No Session Found (gem install session)" + puts "Unable to run functional tests -- please run \"gem install session\"" end if defined?(Session) - puts "RUNNING WITH SESSIONS" require 'test/functional/session_based_tests.rb' end diff --git a/test/lib/application_test.rb b/test/lib/application_test.rb index 4c2d33ea4..170e991dd 100644 --- a/test/lib/application_test.rb +++ b/test/lib/application_test.rb @@ -154,6 +154,19 @@ def test_load_rakefile end end + def test_load_rakefile_doesnt_print_rakefile_directory_from_same_dir + in_environment("PWD" => "test/data/unittest") do + out = capture_stdout do + @app.instance_eval do + @original_dir = File.expand_path(".") # pretend we started from the unittest dir + raw_load_rakefile + end + end + rakefile, location = @app.find_rakefile_location + assert_no_match(/\(in #{location}\)/, out) + end + end + def test_load_rakefile_from_subdir in_environment("PWD" => "test/data/unittest/subdir") do @app.instance_eval do @@ -166,6 +179,32 @@ def test_load_rakefile_from_subdir end end + def test_load_rakefile_prints_rakefile_directory_from_subdir + in_environment("PWD" => "test/data/unittest/subdir") do + out = capture_stdout do + @app.instance_eval do + raw_load_rakefile + end + end + rakefile, location = @app.find_rakefile_location + assert_match(/\(in #{location}\)/, out) + end + end + + def test_load_rakefile_doesnt_print_rakefile_directory_from_subdir_if_silent + in_environment("PWD" => "test/data/unittest/subdir") do + out = capture_stdout do + @app.instance_eval do + handle_options + options.silent = true + raw_load_rakefile + end + end + rakefile, location = @app.find_rakefile_location + assert_no_match(/\(in #{location}\)/, out) + end + end + def test_load_rakefile_not_found in_environment("PWD" => "/", "RAKE_SYSTEM" => 'not_exist') do @app.instance_eval do From f02a90a768dfc168358ebe63e117c42d084b38eb Mon Sep 17 00:00:00 2001 From: Sean Moon Date: Fri, 19 Nov 2010 19:26:51 -0500 Subject: [PATCH 0133/1389] agregious typo --- README.rdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rdoc b/README.rdoc index 7b8ec9a67..32de19004 100644 --- a/README.rdoc +++ b/README.rdoc @@ -174,7 +174,7 @@ The Rake homepage is http://rake.rubyforge.org. You can find the Rake RubyForge page at http://rubyforge.org/projects/rake. Feel free to submit commits or feature requests. If you send a patch, -remember to update the corresponding unit tests. If fact, I prefer +remember to update the corresponding unit tests. In fact, I prefer new feature to be submitted in the form of new unit tests. For other information, feel free to ask on the ruby-talk mailing list From 8010b88cf20b3bcb36860f0ac287bbe2bf25ff0a Mon Sep 17 00:00:00 2001 From: Sean Moon Date: Fri, 19 Nov 2010 19:26:51 -0500 Subject: [PATCH 0134/1389] agregious typos --- lib/rake/application.rb | 4 ++-- lib/rake/contrib/ftptools.rb | 2 +- lib/rake/ext/string.rb | 4 ++-- lib/rake/file_list.rb | 6 +++--- lib/rake/file_utils_ext.rb | 2 +- lib/rake/invocation_exception_mixin.rb | 2 +- lib/rake/packagetask.rb | 2 +- lib/rake/task.rb | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/rake/application.rb b/lib/rake/application.rb index 8f653e835..1312a49f9 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -53,7 +53,7 @@ def initialize # * Run the top level tasks (+run_tasks+). # # If you wish to build a custom rake command, you should call - # +init+ on your application. The define any tasks. Finally, + # +init+ on your application. Then define any tasks. Finally, # call +top_level+ to run your top level tasks. def run standard_exception_handling do @@ -123,7 +123,7 @@ def parse_task_string(string) [name, args] end - # Provide standard execption handling for the given block. + # Provide standard exception handling for the given block. def standard_exception_handling begin yield diff --git a/lib/rake/contrib/ftptools.rb b/lib/rake/contrib/ftptools.rb index 4cd02f3ec..6d8b99b8d 100644 --- a/lib/rake/contrib/ftptools.rb +++ b/lib/rake/contrib/ftptools.rb @@ -102,7 +102,7 @@ def connect(path, host, account, password) end end - # Create an FTP uploader targetting the directory +path+ on +host+ + # Create an FTP uploader targeting the directory +path+ on +host+ # using the given account and password. +path+ will be the root # path of the uploader. def initialize(path, host, account, password) diff --git a/lib/rake/ext/string.rb b/lib/rake/ext/string.rb index 293b7950e..96d0ee0f0 100644 --- a/lib/rake/ext/string.rb +++ b/lib/rake/ext/string.rb @@ -76,7 +76,7 @@ def pathmap_replace(patterns, &block) # * %x -- The file extension of the path. An empty string if there # is no extension. # * %X -- Everything *but* the file extension. - # * %s -- The alternate file separater if defined, otherwise use + # * %s -- The alternate file separator if defined, otherwise use # the standard file separator. # * %% -- A percent sign. # @@ -92,7 +92,7 @@ def pathmap_replace(patterns, &block) # # Also the %d, %p, %f, %n, %x, and %X operators can take a # pattern/replacement argument to perform simple string substititions on a - # particular part of the path. The pattern and replacement are speparated + # particular part of the path. The pattern and replacement are separated # by a comma and are enclosed by curly braces. The replacement spec comes # after the % character but before the operator letter. (e.g. # "%{old,new}d"). Muliple replacement specs should be separated by diff --git a/lib/rake/file_list.rb b/lib/rake/file_list.rb index 6e5d4a0e7..3dfdb3daa 100644 --- a/lib/rake/file_list.rb +++ b/lib/rake/file_list.rb @@ -224,7 +224,7 @@ def resolve_exclude private :resolve_exclude # Return a new FileList with the results of running +sub+ against each - # element of the orignal list. + # element of the original list. # # Example: # FileList['a.c', 'b.c'].sub(/\.c$/, '.o') => ['a.o', 'b.o'] @@ -244,7 +244,7 @@ def gsub(pat, rep) inject(FileList.new) { |res, fn| res << fn.gsub(pat,rep) } end - # Same as +sub+ except that the oringal file list is modified. + # Same as +sub+ except that the original file list is modified. def sub!(pat, rep) each_with_index { |fn, i| self[i] = fn.sub(pat,rep) } self @@ -279,7 +279,7 @@ def ext(newext='') # Grep each of the files in the filelist using the given pattern. If a # block is given, call the block on each matching line, passing the file # name, line number, and the matching line of text. If no block is given, - # a standard emac style file:linenumber:line message will be printed to + # a standard emacs style file:linenumber:line message will be printed to # standard out. Returns the number of matched items. def egrep(pattern, *options) matched = 0 diff --git a/lib/rake/file_utils_ext.rb b/lib/rake/file_utils_ext.rb index e670777f1..9359764e0 100644 --- a/lib/rake/file_utils_ext.rb +++ b/lib/rake/file_utils_ext.rb @@ -79,7 +79,7 @@ def nowrite(value=nil) oldvalue end - # Use this function to prevent protentially destructive ruby code from + # Use this function to prevent potentially destructive ruby code from # running when the :nowrite flag is set. # # Example: diff --git a/lib/rake/invocation_exception_mixin.rb b/lib/rake/invocation_exception_mixin.rb index 4936e9632..84ff3353b 100644 --- a/lib/rake/invocation_exception_mixin.rb +++ b/lib/rake/invocation_exception_mixin.rb @@ -1,7 +1,7 @@ module Rake module InvocationExceptionMixin # Return the invocation chain (list of Rake tasks) that were in - # effect when this execption was detected by rake. May be null if + # effect when this exception was detected by rake. May be null if # no tasks were active. def chain @rake_invocation_chain ||= nil diff --git a/lib/rake/packagetask.rb b/lib/rake/packagetask.rb index 71b66a648..d8f674e7e 100644 --- a/lib/rake/packagetask.rb +++ b/lib/rake/packagetask.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -# Define a package task libarary to aid in the definition of +# Define a package task library to aid in the definition of # redistributable package files. require 'rake' diff --git a/lib/rake/task.rb b/lib/rake/task.rb index d780d51f2..1d12f89f7 100644 --- a/lib/rake/task.rb +++ b/lib/rake/task.rb @@ -231,7 +231,7 @@ def comment=(description) add_description(description) end - # Add a comment to the task. If a comment alread exists, separate + # Add a comment to the task. If a comment already exists, separate # the new comment with " / ". def add_comment(comment) if @full_comment From e4de3899c7266a6e268f678f110d258e05d22f8d Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Tue, 21 Dec 2010 11:37:32 -0200 Subject: [PATCH 0135/1389] Config is deprecated on 1.8.8 and 1.9.3 use RbConfig --- Rakefile | 2 +- install.rb | 2 +- lib/rake/alt_system.rb | 2 +- lib/rake/application.rb | 2 +- lib/rake/contrib/sys.rb | 2 +- lib/rake/file_utils.rb | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Rakefile b/Rakefile index 47daf3fe1..3424aa73a 100644 --- a/Rakefile +++ b/Rakefile @@ -405,7 +405,7 @@ end desc "Install the jamis RDoc template" task :install_jamis_template do require 'rbconfig' - dest_dir = File.join(Config::CONFIG['rubylibdir'], "rdoc/generators/template/html") + dest_dir = File.join(RbConfig::CONFIG['rubylibdir'], "rdoc/generators/template/html") fail "Unabled to write to #{dest_dir}" unless File.writable?(dest_dir) install "doc/jamis.rb", dest_dir, :verbose => true end diff --git a/install.rb b/install.rb index f1e7c82a4..1db443fae 100644 --- a/install.rb +++ b/install.rb @@ -2,7 +2,7 @@ require 'find' require 'fileutils' -include Config +include RbConfig $ruby = CONFIG['ruby_install_name'] diff --git a/lib/rake/alt_system.rb b/lib/rake/alt_system.rb index 510c40c9c..b0b799cfe 100644 --- a/lib/rake/alt_system.rb +++ b/lib/rake/alt_system.rb @@ -29,7 +29,7 @@ # for ruby-1.8 and earlier. # module Rake::AltSystem - WINDOWS = Config::CONFIG["host_os"] =~ %r!(msdos|mswin|djgpp|mingw)! + WINDOWS = RbConfig::CONFIG["host_os"] =~ %r!(msdos|mswin|djgpp|mingw)! class << self def define_module_function(name, &block) diff --git a/lib/rake/application.rb b/lib/rake/application.rb index 8f653e835..762533cf1 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -246,7 +246,7 @@ def dynamic_width_tput end def unix? - Config::CONFIG['host_os'] =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i + RbConfig::CONFIG['host_os'] =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i end def windows? diff --git a/lib/rake/contrib/sys.rb b/lib/rake/contrib/sys.rb index c26803e33..0bcf9508b 100644 --- a/lib/rake/contrib/sys.rb +++ b/lib/rake/contrib/sys.rb @@ -22,7 +22,7 @@ # in Ruby 1.8. # module Sys - RUBY = Config::CONFIG['ruby_install_name'] + RUBY = RbConfig::CONFIG['ruby_install_name'] # Install all the files matching +wildcard+ into the +dest_dir+ # directory. The permission mode is set to +mode+. diff --git a/lib/rake/file_utils.rb b/lib/rake/file_utils.rb index 332cb0c10..3ee335f7d 100644 --- a/lib/rake/file_utils.rb +++ b/lib/rake/file_utils.rb @@ -8,8 +8,8 @@ module FileUtils # Path to the currently running Ruby program RUBY = File.join( - Config::CONFIG['bindir'], - Config::CONFIG['ruby_install_name'] + Config::CONFIG['EXEEXT']). + RbConfig::CONFIG['bindir'], + RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['EXEEXT']). sub(/.*\s.*/m, '"\&"') OPT_TABLE['sh'] = %w(noop verbose) From 91f6016a98828eaa79487df307e85abdad1c20ac Mon Sep 17 00:00:00 2001 From: Jo Liss Date: Fri, 7 Jan 2011 22:00:19 +0100 Subject: [PATCH 0136/1389] Guard against missing rvm. --- rakelib/tags.rake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rakelib/tags.rake b/rakelib/tags.rake index 465a60b85..e7607d1b4 100644 --- a/rakelib/tags.rake +++ b/rakelib/tags.rake @@ -8,9 +8,9 @@ module Tags FILES = FileList['**/*.rb', '**/*.js'] + RAKEFILES FILES.exclude('pkg', 'dist') - RVM_GEMDIR = File.join(`rvm gemdir`.strip, "gems") + RVM_GEMDIR = (File.join(`rvm gemdir`.strip, "gems") rescue nil) DIR_LIST = ['.'] - DIR_LIST << RVM_GEMDIR if File.exists?(RVM_GEMDIR) + DIR_LIST << RVM_GEMDIR if RVM_GEMDIR && File.exists?(RVM_GEMDIR) DIRS = DIR_LIST.join(" ") module_function From 355f7032d16126a705b8e67d87664aa6794054a7 Mon Sep 17 00:00:00 2001 From: Jo Liss Date: Fri, 7 Jan 2011 22:02:51 +0100 Subject: [PATCH 0137/1389] Leave test/shellcommand.rb world-readable after test. --- test/lib/fileutils_test.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/lib/fileutils_test.rb b/test/lib/fileutils_test.rb index 7af8b8168..7372115c6 100644 --- a/test/lib/fileutils_test.rb +++ b/test/lib/fileutils_test.rb @@ -13,10 +13,11 @@ class TestFileUtils < Test::Unit::TestCase include Rake::DSL def setup - File.chmod(0750,"test/shellcommand.rb") + File.chmod(0750, "test/shellcommand.rb") end def teardown + File.chmod(0755, "test/shellcommand.rb") FileUtils.rm_rf("testdata") FileUtils::LN_SUPPORTED[0] = true end From d39b6c476c8eef642b4f556fb75bbd4a37b6a398 Mon Sep 17 00:00:00 2001 From: Eric Hodel Date: Fri, 7 Jan 2011 15:15:21 -0800 Subject: [PATCH 0138/1389] Use $stderr when we're printing user-only messages --- lib/rake/application.rb | 4 ++-- lib/rake/classic_namespace.rb | 2 +- lib/rake/contrib/ftptools.rb | 4 ++-- lib/rake/contrib/sys.rb | 4 ++-- lib/rake/file_list.rb | 2 +- lib/rake/file_utils_ext.rb | 2 +- lib/rake/runtest.rb | 6 +++--- lib/rake/task.rb | 6 +++--- lib/rake/task_manager.rb | 3 ++- test/functional/session_based_tests.rb | 4 ++-- test/lib/task_test.rb | 4 ++-- test/lib/top_level_functions_test.rb | 2 +- 12 files changed, 22 insertions(+), 21 deletions(-) diff --git a/lib/rake/application.rb b/lib/rake/application.rb index 8f653e835..f897fc3e7 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -472,7 +472,7 @@ def raw_load_rakefile # :nodoc: if (! options.ignore_system) && (options.load_system || rakefile.nil?) && system_dir && File.directory?(system_dir) - puts "(in #{Dir.pwd})" unless options.silent + $stderr.puts "(in #{Dir.pwd})" unless options.silent glob("#{system_dir}/*.rake") do |name| add_import name end @@ -481,7 +481,7 @@ def raw_load_rakefile # :nodoc: rakefile.nil? @rakefile = rakefile Dir.chdir(location) - puts "(in #{Dir.pwd})" unless options.silent + $stderr.puts "(in #{Dir.pwd})" unless options.silent $rakefile = @rakefile if options.classic_namespace Rake::Environment.load_rakefile(File.expand_path(@rakefile)) if @rakefile && @rakefile != '' options.rakelib.each do |rlib| diff --git a/lib/rake/classic_namespace.rb b/lib/rake/classic_namespace.rb index 6865cf77d..d87aba0f3 100644 --- a/lib/rake/classic_namespace.rb +++ b/lib/rake/classic_namespace.rb @@ -2,7 +2,7 @@ # Loading this file enables compatibility with older Rakefile that # referenced Task from the top level. -puts "WARNING: Classic namespaces are deprecated and will be removed from future versions of Rake." +warn "WARNING: Classic namespaces are deprecated and will be removed from future versions of Rake." Task = Rake::Task FileTask = Rake::FileTask FileCreationTask = Rake::FileCreationTask diff --git a/lib/rake/contrib/ftptools.rb b/lib/rake/contrib/ftptools.rb index 4cd02f3ec..8d9a18b09 100644 --- a/lib/rake/contrib/ftptools.rb +++ b/lib/rake/contrib/ftptools.rb @@ -121,7 +121,7 @@ def makedirs(path) current_dir = File.join(route) if @created[current_dir].nil? @created[current_dir] = true - puts "Creating Directory #{current_dir}" if @verbose + $stderr.puts "Creating Directory #{current_dir}" if @verbose @ftp.mkdir(current_dir) rescue nil end end @@ -144,7 +144,7 @@ def close # Upload a single file to the uploader's root path. def upload(file) - puts "Uploading #{file}" if @verbose + $stderr.puts "Uploading #{file}" if @verbose dir = File.dirname(file) makedirs(dir) @ftp.putbinaryfile(file, file) unless File.directory?(file) diff --git a/lib/rake/contrib/sys.rb b/lib/rake/contrib/sys.rb index c26803e33..e04226570 100644 --- a/lib/rake/contrib/sys.rb +++ b/lib/rake/contrib/sys.rb @@ -142,10 +142,10 @@ def split_all(path) return split_all(head) + [tail] end - # Write a message to standard out if $verbose is enabled. + # Write a message to standard error if $verbose is enabled. def log(msg) print " " if $trace && $verbose - puts msg if $verbose + $stderr.puts msg if $verbose end # Perform a block with $verbose disabled. diff --git a/lib/rake/file_list.rb b/lib/rake/file_list.rb index 6e5d4a0e7..a4f23d48a 100644 --- a/lib/rake/file_list.rb +++ b/lib/rake/file_list.rb @@ -300,7 +300,7 @@ def egrep(pattern, *options) end end rescue StandardError => ex - puts "Error while processing '#{fn}': #{ex}" + $stderr.puts "Error while processing '#{fn}': #{ex}" end end matched diff --git a/lib/rake/file_utils_ext.rb b/lib/rake/file_utils_ext.rb index e670777f1..ad69171f8 100644 --- a/lib/rake/file_utils_ext.rb +++ b/lib/rake/file_utils_ext.rb @@ -95,7 +95,7 @@ def nowrite(value=nil) # def when_writing(msg=nil) if FileUtilsExt.nowrite_flag - puts "DRYRUN: #{msg}" if msg + $stderr.puts "DRYRUN: #{msg}" if msg else yield end diff --git a/lib/rake/runtest.rb b/lib/rake/runtest.rb index 3f1d20520..b19da8cad 100644 --- a/lib/rake/runtest.rb +++ b/lib/rake/runtest.rb @@ -8,12 +8,12 @@ module Rake def run_tests(pattern='test/test*.rb', log_enabled=false) Dir["#{pattern}"].each { |fn| - puts fn if log_enabled + $stderr.puts fn if log_enabled begin load fn rescue Exception => ex - puts "Error in #{fn}: #{ex.message}" - puts ex.backtrace + $stderr.puts "Error in #{fn}: #{ex.message}" + $stderr.puts ex.backtrace assert false end } diff --git a/lib/rake/task.rb b/lib/rake/task.rb index d780d51f2..10cd204e6 100644 --- a/lib/rake/task.rb +++ b/lib/rake/task.rb @@ -150,7 +150,7 @@ def invoke_with_call_chain(task_args, invocation_chain) # :nodoc: new_chain = InvocationChain.append(self, invocation_chain) @lock.synchronize do if application.options.trace - puts "** Invoke #{name} #{format_trace_flags}" + $stderr.puts "** Invoke #{name} #{format_trace_flags}" end return if @already_invoked @already_invoked = true @@ -190,11 +190,11 @@ def format_trace_flags def execute(args=nil) args ||= EMPTY_TASK_ARGS if application.options.dryrun - puts "** Execute (dry run) #{name}" + $stderr.puts "** Execute (dry run) #{name}" return end if application.options.trace - puts "** Execute #{name}" + $stderr.puts "** Execute #{name}" end application.enhance_with_matching_rule(name) if @actions.empty? @actions.each do |act| diff --git a/lib/rake/task_manager.rb b/lib/rake/task_manager.rb index 9a59b12e3..f4eec3214 100644 --- a/lib/rake/task_manager.rb +++ b/lib/rake/task_manager.rb @@ -234,7 +234,8 @@ def generate_name end def trace_rule(level, message) - puts "#{" "*level}#{message}" if Rake.application.options.trace_rules + $stderr.puts "#{" "*level}#{message}" if + Rake.application.options.trace_rules end # Attempt to create a rule given the list of prerequisites. diff --git a/test/functional/session_based_tests.rb b/test/functional/session_based_tests.rb index 3ec55c883..caf3eb6f5 100644 --- a/test/functional/session_based_tests.rb +++ b/test/functional/session_based_tests.rb @@ -215,8 +215,8 @@ def test_standalone_verbose_false_should_not_show_command def test_dry_run in_environment("PWD" => "test/data/default") do rake "-n", "other" end - assert_match %r{Execute \(dry run\) default}, @out - assert_match %r{Execute \(dry run\) other}, @out + assert_match %r{Execute \(dry run\) default}, @err + assert_match %r{Execute \(dry run\) other}, @err assert_no_match %r{DEFAULT}, @out assert_no_match %r{OTHER}, @out end diff --git a/test/lib/task_test.rb b/test/lib/task_test.rb index 3594dfa85..644667cb9 100644 --- a/test/lib/task_test.rb +++ b/test/lib/task_test.rb @@ -68,7 +68,7 @@ def test_dry_run_prevents_actions Rake.application.options.dryrun = true runlist = [] t1 = task(:t1) { |t| runlist << t.name; 3321 } - out = capture_stdout { t1.invoke } + out = capture_stderr { t1.invoke } assert_match(/execute .*t1/i, out) assert_match(/dry run/i, out) assert_no_match(/invoke/i, out) @@ -80,7 +80,7 @@ def test_dry_run_prevents_actions def test_tasks_can_be_traced Rake.application.options.trace = true t1 = task(:t1) - out = capture_stdout { + out = capture_stderr { t1.invoke } assert_match(/invoke t1/i, out) diff --git a/test/lib/top_level_functions_test.rb b/test/lib/top_level_functions_test.rb index fc8366cf1..21efe1566 100644 --- a/test/lib/top_level_functions_test.rb +++ b/test/lib/top_level_functions_test.rb @@ -50,7 +50,7 @@ def test_when_writing def test_when_not_writing Rake::FileUtilsExt.nowrite_flag = true - out = capture_stdout do + out = capture_stderr do when_writing("NOTWRITING") do puts "WRITING" end From 147a1b7a8d5ed2febd2b42f6affdbe9ddb601687 Mon Sep 17 00:00:00 2001 From: Eric Hodel Date: Fri, 7 Jan 2011 15:31:06 -0800 Subject: [PATCH 0139/1389] Tests can now run on 1.9 --- rakelib/tags.rake | 9 +++++++-- test/lib/application_test.rb | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/rakelib/tags.rake b/rakelib/tags.rake index 465a60b85..9dbfdf48f 100644 --- a/rakelib/tags.rake +++ b/rakelib/tags.rake @@ -8,9 +8,14 @@ module Tags FILES = FileList['**/*.rb', '**/*.js'] + RAKEFILES FILES.exclude('pkg', 'dist') - RVM_GEMDIR = File.join(`rvm gemdir`.strip, "gems") + RVM_GEMDIR = begin + File.join(`rvm gemdir`.strip, "gems") + rescue Errno::ENOENT + nil + end + DIR_LIST = ['.'] - DIR_LIST << RVM_GEMDIR if File.exists?(RVM_GEMDIR) + DIR_LIST << RVM_GEMDIR if RVM_GEMDIR and File.exists? RVM_GEMDIR DIRS = DIR_LIST.join(" ") module_function diff --git a/test/lib/application_test.rb b/test/lib/application_test.rb index 4c2d33ea4..42d9bb0f5 100644 --- a/test/lib/application_test.rb +++ b/test/lib/application_test.rb @@ -477,7 +477,7 @@ def test_missing_require flags(['--require', 'test/missing']) do |opts| end end - assert_match(/no such file/, ex.message) + assert_match(/such file/, ex.message) assert_match(/test\/missing/, ex.message) end end From 50a952a6f72bb4e6a830191f355a33a2601a7efb Mon Sep 17 00:00:00 2001 From: Eric Hodel Date: Fri, 7 Jan 2011 15:32:24 -0800 Subject: [PATCH 0140/1389] Ignore .swp files, root directory ignores --- .gitignore | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 5c2982f4c..408365385 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,13 @@ *.bak *.patch *.rbc +*.swp .#* .idea -TAGS -coverage -html -pkg +/TAGS +/coverage +/html +/pkg r19.diff temp_* testdata From ffad055f5aea480c3ca25d2ebbd682fa139ca4e2 Mon Sep 17 00:00:00 2001 From: Eric Hodel Date: Fri, 7 Jan 2011 15:49:24 -0800 Subject: [PATCH 0141/1389] Suppress unused variable warnings for 1.9.3dev --- lib/rake/application.rb | 2 +- lib/rake/contrib/ftptools.rb | 3 +-- lib/rake/file_utils.rb | 4 ++-- lib/rake/task_manager.rb | 4 ++-- test/functional/session_based_tests.rb | 2 +- test/lib/application_test.rb | 5 ++--- test/lib/earlytime_test.rb | 1 - test/lib/filelist_test.rb | 1 - test/lib/package_task_test.rb | 2 +- test/lib/pathmap_test.rb | 2 +- test/lib/rdoc_task_test.rb | 2 +- test/lib/rules_test.rb | 1 - test/lib/task_manager_test.rb | 2 +- test/test_helper.rb | 3 +-- 14 files changed, 14 insertions(+), 20 deletions(-) diff --git a/lib/rake/application.rb b/lib/rake/application.rb index 9894cc49f..795839d90 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -337,7 +337,7 @@ def standard_rake_options rescue LoadError => ex begin rake_require value - rescue LoadError => ex2 + rescue LoadError raise ex end end diff --git a/lib/rake/contrib/ftptools.rb b/lib/rake/contrib/ftptools.rb index 8d9a18b09..e0451c9f2 100644 --- a/lib/rake/contrib/ftptools.rb +++ b/lib/rake/contrib/ftptools.rb @@ -25,7 +25,7 @@ def self.time def initialize(path, entry) @path = path - @mode, line, @owner, @group, size, d1, d2, d3, @name = entry.split(' ') + @mode, _, @owner, @group, size, d1, d2, d3, @name = entry.split(' ') @size = size.to_i @time = determine_time(d1, d2, d3) end @@ -59,7 +59,6 @@ def parse_mode(m) def determine_time(d1, d2, d3) now = self.class.time.now if /:/ =~ d3 - h, m = d3.split(':') result = Time.parse("#{d1} #{d2} #{now.year} #{d3}") if result > now result = Time.parse("#{d1} #{d2} #{now.year-1} #{d3}") diff --git a/lib/rake/file_utils.rb b/lib/rake/file_utils.rb index 3ee335f7d..9e0198e64 100644 --- a/lib/rake/file_utils.rb +++ b/lib/rake/file_utils.rb @@ -49,7 +49,7 @@ def sh(*cmd, &block) def create_shell_runner(cmd) show_command = cmd.join(" ") show_command = show_command[0,42] + "..." unless $trace - block = lambda { |ok, status| + lambda { |ok, status| ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]" } end @@ -91,7 +91,7 @@ def safe_ln(*args) else begin ln(*args) - rescue StandardError, NotImplementedError => ex + rescue StandardError, NotImplementedError LN_SUPPORTED[0] = false cp(*args) end diff --git a/lib/rake/task_manager.rb b/lib/rake/task_manager.rb index f4eec3214..2d27e5c43 100644 --- a/lib/rake/task_manager.rb +++ b/lib/rake/task_manager.rb @@ -15,7 +15,7 @@ def initialize end def create_rule(*args, &block) - pattern, arg_names, deps = resolve_args(args) + pattern, _, deps = resolve_args(args) pattern = Regexp.new(Regexp.quote(pattern) + '$') if String === pattern @rules << [pattern, deps, block] end @@ -124,7 +124,7 @@ def enhance_with_matching_rule(task_name, level=0) fail Rake::RuleRecursionOverflowError, "Rule Recursion Too Deep" if level >= 16 @rules.each do |pattern, extensions, block| - if md = pattern.match(task_name) + if pattern.match(task_name) task = attempt_rule(task_name, extensions, block, level) return task if task end diff --git a/test/functional/session_based_tests.rb b/test/functional/session_based_tests.rb index caf3eb6f5..9e461afd7 100644 --- a/test/functional/session_based_tests.rb +++ b/test/functional/session_based_tests.rb @@ -2,7 +2,7 @@ begin require 'rubygems' -rescue LoadError => ex +rescue LoadError end require 'test/unit' require 'fileutils' diff --git a/test/lib/application_test.rb b/test/lib/application_test.rb index 42d9bb0f5..6b95aef29 100644 --- a/test/lib/application_test.rb +++ b/test/lib/application_test.rb @@ -65,7 +65,6 @@ def test_display_tasks_with_task_name_wider_than_tty_display in_environment('RAKE_COLUMNS' => '80') do @app.options.show_tasks = :tasks @app.options.show_task_pattern = // - description = "something short" task_name = "task name" * 80 @app.last_description = "something short" @app.define_task(Rake::Task, task_name ) @@ -306,7 +305,7 @@ def test_run_with_bad_options ARGV.clear ARGV << '-f' << '-s' << '--xyzzy' assert_exception(SystemExit) { - err = capture_stderr { capture_stdout { @app.run } } + capture_stderr { capture_stdout { @app.run } } } ensure ARGV.clear @@ -635,7 +634,7 @@ def flags(*sets) sets.each do |set| ARGV.clear @out = capture_stdout { - @exit = catch(:system_exit) { opts = command_line(*set) } + @exit = catch(:system_exit) { command_line(*set) } } yield(@app.options) if block_given? end diff --git a/test/lib/earlytime_test.rb b/test/lib/earlytime_test.rb index e63bd5432..9c1ebe974 100644 --- a/test/lib/earlytime_test.rb +++ b/test/lib/earlytime_test.rb @@ -6,7 +6,6 @@ class TestEarlyTime < Test::Unit::TestCase def test_create early = Rake::EarlyTime.instance - time = Time.mktime(1970, 1, 1, 0, 0, 0) assert early <= Time.now assert early < Time.now assert early != Time.now diff --git a/test/lib/filelist_test.rb b/test/lib/filelist_test.rb index c433ab37f..4b8e8a63b 100644 --- a/test/lib/filelist_test.rb +++ b/test/lib/filelist_test.rb @@ -325,7 +325,6 @@ def test_gsub! def test_egrep_returns_0_if_no_matches files = FileList['test/lib/*_test.rb'].exclude("test/lib/filelist_test.rb") - the_line_number = __LINE__ + 1 assert_equal 0, files.egrep(/XYZZY/) { } end diff --git a/test/lib/package_task_test.rb b/test/lib/package_task_test.rb index 62043e60e..980b65999 100644 --- a/test/lib/package_task_test.rb +++ b/test/lib/package_task_test.rb @@ -43,7 +43,7 @@ def test_create def test_missing_version assert_exception(RuntimeError) { - pkg = Rake::PackageTask.new("pkgr") { |p| } + Rake::PackageTask.new("pkgr") { |p| } } end diff --git a/test/lib/pathmap_test.rb b/test/lib/pathmap_test.rb index b82b1ac83..941cf7cec 100644 --- a/test/lib/pathmap_test.rb +++ b/test/lib/pathmap_test.rb @@ -88,7 +88,7 @@ def test_percent_percent_returns_percent end def test_undefined_percent_causes_error - ex = assert_exception(ArgumentError) { + assert_exception(ArgumentError) { "dir/abc.rb".pathmap("%z") } end diff --git a/test/lib/rdoc_task_test.rb b/test/lib/rdoc_task_test.rb index d1a55ed87..2b6519453 100644 --- a/test/lib/rdoc_task_test.rb +++ b/test/lib/rdoc_task_test.rb @@ -46,7 +46,7 @@ def test_tasks_creation_with_custom_name_hash end def test_tasks_creation_with_custom_name_hash_will_use_default_if_an_option_isnt_given - rd = Rake::RDocTask.new(:clobber_rdoc => "rdoc:clean") + Rake::RDocTask.new(:clobber_rdoc => "rdoc:clean") assert Task[:rdoc] assert Task[:"rdoc:clean"] assert Task[:rerdoc] diff --git a/test/lib/rules_test.rb b/test/lib/rules_test.rb index d2210aa97..4f7147010 100644 --- a/test/lib/rules_test.rb +++ b/test/lib/rules_test.rb @@ -278,7 +278,6 @@ def test_second_rule_doest_run_if_first_triggers_with_reversed_rules end def test_rule_with_proc_dependent_will_trigger - ran = false mkdir_p("testdata/src/jw") create_file("testdata/src/jw/X.java") rule %r(classes/.*\.class) => [ diff --git a/test/lib/task_manager_test.rb b/test/lib/task_manager_test.rb index 37ed85bb5..c60fb53bd 100644 --- a/test/lib/task_manager_test.rb +++ b/test/lib/task_manager_test.rb @@ -72,7 +72,7 @@ def test_name_lookup_with_implicit_file_tasks def test_name_lookup_with_nonexistent_task assert_exception(RuntimeError) { - t = @tm["DOES NOT EXIST"] + @tm["DOES NOT EXIST"] } end diff --git a/test/test_helper.rb b/test/test_helper.rb index 701d4d392..c000c70f3 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,7 +1,6 @@ begin require 'rubygems' -rescue LoadError => ex - # No rubygems available +rescue LoadError end require 'test/unit' require 'flexmock/test_unit' From 2365bd2a4ea303b6aa6a95cd1922392d38eefceb Mon Sep 17 00:00:00 2001 From: Eric Hodel Date: Fri, 7 Jan 2011 15:57:46 -0800 Subject: [PATCH 0142/1389] Remove trailing whitespace from rake --- README.rdoc | 8 +++--- Rakefile | 30 +++++++++++------------ doc/rakefile.rdoc | 16 ++++++------ doc/release_notes/rake-0.7.0.rdoc | 2 +- doc/release_notes/rake-0.7.2.rdoc | 6 ++--- doc/release_notes/rake-0.7.3.rdoc | 4 +-- doc/release_notes/rake-0.8.0.rdoc | 2 +- doc/release_notes/rake-0.8.2.rdoc | 2 +- doc/release_notes/rake-0.8.3.rdoc | 2 +- doc/release_notes/rake-0.8.4.rdoc | 2 +- doc/release_notes/rake-0.8.5.rdoc | 2 +- doc/release_notes/rake-0.8.6.rdoc | 2 +- doc/release_notes/rake-0.8.7.rdoc | 2 +- install.rb | 4 +-- lib/rake/alt_system.rb | 10 ++++---- lib/rake/application.rb | 14 +++++------ lib/rake/clean.rb | 10 ++++---- lib/rake/contrib/publisher.rb | 2 +- lib/rake/contrib/sshpublisher.rb | 8 +++--- lib/rake/contrib/sys.rb | 2 +- lib/rake/dsl_definition.rb | 20 +++++++-------- lib/rake/environment.rb | 2 +- lib/rake/ext/string.rb | 2 +- lib/rake/file_list.rb | 4 +-- lib/rake/file_utils_ext.rb | 24 +++++++++--------- lib/rake/invocation_chain.rb | 4 +-- lib/rake/name_space.rb | 2 +- lib/rake/pseudo_status.rb | 2 +- lib/rake/rdoctask.rb | 30 +++++++++++------------ lib/rake/task.rb | 8 +++--- lib/rake/task_arguments.rb | 4 +-- lib/rake/task_manager.rb | 18 +++++++------- lib/rake/testtask.rb | 8 +++--- rakelib/rbx.rake | 2 +- rakelib/ruby19.rake | 2 +- test/functional/session_based_tests.rb | 20 +++++++-------- test/lib/application_test.rb | 34 +++++++++++++------------- test/lib/definitions_test.rb | 4 +-- test/lib/earlytime_test.rb | 2 +- test/lib/file_task_test.rb | 2 +- test/lib/filelist_test.rb | 22 ++++++++--------- test/lib/multitask_test.rb | 2 +- test/lib/pathmap_test.rb | 2 +- test/lib/rake_test.rb | 2 +- test/lib/rdoc_task_test.rb | 24 +++++++++--------- test/lib/task_arguments_test.rb | 2 +- test/lib/task_manager_test.rb | 4 +-- test/lib/test_task_test.rb | 2 +- 48 files changed, 192 insertions(+), 192 deletions(-) diff --git a/README.rdoc b/README.rdoc index 7b8ec9a67..9f5b67404 100644 --- a/README.rdoc +++ b/README.rdoc @@ -1,9 +1,9 @@ -= RAKE -- Ruby Make += RAKE -- Ruby Make Supporting Rake version: 0.8.7. This package contains Rake, a simple ruby build program with -capabilities similar to make. +capabilities similar to make. Rake has the following features: @@ -52,7 +52,7 @@ First, you must write a "Rakefile" file which contains the build rules. Here's a simple example: task :default => [:test] - + task :test do ruby "test/unittest.rb" end @@ -114,7 +114,7 @@ If you wish to run the unit and functional tests that come with Rake: Feature requests and bug reports can be made here * http://onestepback.org/cgi-bin/bugs.cgi?project=rake - + No account is needed for posting requests. Or you can send me an email (at jim dot weirich at gmail dot com) diff --git a/Rakefile b/Rakefile index 3424aa73a..8bbb8bc5b 100644 --- a/Rakefile +++ b/Rakefile @@ -73,19 +73,19 @@ namespace :test do t.libs << "." t.warning = true end - + Rake::TestTask.new(:units) do |t| t.test_files = TestFiles::UNIT t.libs << "." t.warning = true end - + Rake::TestTask.new(:functional) do |t| t.test_files = TestFiles::FUNCTIONAL t.libs << "." t.warning = true end - + Rake::TestTask.new(:contribs) do |t| t.test_files = TestFiles::CONTRIB t.libs << "." @@ -98,10 +98,10 @@ begin Rcov::RcovTask.new do |t| t.libs << "test" - dot_rakes = + dot_rakes = t.rcov_opts = [ '-xRakefile', '-xrakefile', '-xpublish.rf', - '-xlib/rake/contrib', '-x/Library', + '-xlib/rake/contrib', '-x/Library', '--text-report', '--sort coverage' ] + FileList['rakelib/*.rake'].pathmap("-x%p") @@ -152,7 +152,7 @@ rd = Rake::RDocTask.new("rdoc") do |rdoc| rdoc.title = "Rake -- Ruby Make" rdoc.options = BASE_RDOC_OPTIONS.dup rdoc.options << '-SHN' << '-f' << 'darkfish' if DARKFISH_ENABLED - + rdoc.rdoc_files.include('README.rdoc', 'MIT-LICENSE', 'TODO', 'CHANGES') rdoc.rdoc_files.include('lib/**/*.rb', 'doc/**/*.rdoc') rdoc.rdoc_files.exclude(/\bcontrib\b/) @@ -165,8 +165,8 @@ end PKG_FILES = FileList[ 'install.rb', '[A-Z]*', - 'bin/**/*', - 'lib/**/*.rb', + 'bin/**/*', + 'lib/**/*.rb', 'test/**/*.rb', 'test/**/*.rf', 'test/**/*.mf', @@ -182,7 +182,7 @@ if ! defined?(Gem) puts "Package Target requires RubyGEMs" else SPEC = Gem::Specification.new do |s| - + #### Basic information. s.name = 'rake' @@ -190,7 +190,7 @@ else s.summary = "Ruby based make-like utility." s.description = <<-EOF Rake is a Make-like program implemented in Ruby. Tasks - and dependencies are specified in standard Ruby syntax. + and dependencies are specified in standard Ruby syntax. EOF #### Dependencies and requirements. @@ -295,7 +295,7 @@ task :todo do end desc "List all ruby files" -task :rubyfiles do +task :rubyfiles do puts RUBY_FILES puts FileList['bin/*'].exclude('bin/*.rb') end @@ -321,23 +321,23 @@ task :release, :rel, :reuse, :reltest, :package, :tag ] do - announce + announce announce "**************************************************************" announce "* Release #{$package_version} Complete." announce "* Packages ready to upload." announce "**************************************************************" - announce + announce end # Validate that everything is ready to go for a release. task :prerelease, :rel, :reuse, :reltest do |t, args| $package_version = args.rel - announce + announce announce "**************************************************************" announce "* Making RubyGem Release #{$package_version}" announce "* (current version #{CURRENT_VERSION})" announce "**************************************************************" - announce + announce # Is a release number supplied? unless args.rel diff --git a/doc/rakefile.rdoc b/doc/rakefile.rdoc index ac35b24a5..4fdf3adeb 100644 --- a/doc/rakefile.rdoc +++ b/doc/rakefile.rdoc @@ -278,7 +278,7 @@ actions. task :dont do Rake::Task[:doit].clear - end + end Running this example: @@ -287,7 +287,7 @@ Running this example: DONE $ rake dont doit (in /Users/jim/working/git/rake/x) - $ + $ The ability to programmatically manipulate tasks gives rake very powerful meta-programming capabilities w.r.t. task execution, but @@ -312,7 +312,7 @@ Rake is able to find a file named "mycode.c", it will automatically create a task that builds "mycode.o" from "mycode.c". If the file "mycode.c" does not exist, rake will attempt -to recursively synthesize a rule for it. +to recursively synthesize a rule for it. When a task is synthesized from a rule, the +source+ attribute of the task is set to the matching source file. This allows us to write @@ -330,7 +330,7 @@ The following rule is equivalent to the example above. proc {|task_name| task_name.sub(/\.[^.]+$/, '.c') } ]) do |t| sh "cc #{t.source} -c -o #{t.name}" - end + end NOTE: Because of a _quirk_ in Ruby syntax, parenthesis are required on *rule* when the first argument is a regular expression. @@ -340,7 +340,7 @@ The following rule might be used for Java files ... rule '.java' => [ proc { |tn| tn.sub(/\.class$/, '.java').sub(/^classes\//, 'src/') } ] do |t| - java_compile(t.source, t.name) + java_compile(t.source, t.name) end NOTE: +java_compile+ is a hypothetical method that invokes the @@ -400,14 +400,14 @@ are allowed === Example: desc 'Create a distribution package' - + task :package => [ ... ] do ... end The +desc+ comment takes priority over the comment for of description. The "-T" switch (or "--tasks" if you like to spell things out) will display a list of tasks that have a description. If you use -comments or +desc+ to describe your major tasks, you have a +comments or +desc+ to describe your major tasks, you have a semi-automatic way of generating a summary of your Rake file. traken$ rake -T @@ -461,7 +461,7 @@ Nested namespaces are supported, so Note that the name given in the +task+ command is always the unadorned task name without any namespace prefixes. The +task+ command always -defines a task in the current namespace. +defines a task in the current namespace. === FileTasks diff --git a/doc/release_notes/rake-0.7.0.rdoc b/doc/release_notes/rake-0.7.0.rdoc index 9c07c7f58..b8bf56ebb 100644 --- a/doc/release_notes/rake-0.7.0.rdoc +++ b/doc/release_notes/rake-0.7.0.rdoc @@ -64,7 +64,7 @@ commands: Or invoke both via the :build_all command: - rake build_all + rake build_all Namespaces may be nested arbitrarily. Since the name of file tasks correspond to the name of a file in the external file system, diff --git a/doc/release_notes/rake-0.7.2.rdoc b/doc/release_notes/rake-0.7.2.rdoc index 2cc86becc..ec99ee0c0 100644 --- a/doc/release_notes/rake-0.7.2.rdoc +++ b/doc/release_notes/rake-0.7.2.rdoc @@ -24,7 +24,7 @@ Rake: appliation instead of using its own data. * Fixed the method name leak from FileUtils (bug found by Glenn - Vanderburg). + Vanderburg). * Added test for noop, bad_option and verbose flags to sh command. @@ -40,13 +40,13 @@ Rake: The following new features are available in Rake version 0.7.2: * Added square and curly bracket patterns to FileList#include (Tilman - Sauerbeck). + Sauerbeck). * FileLists can now pass a block to FileList#exclude to exclude files based on calculated values. * Added plain filename support to rule dependents (suggested by Nobu - Nakada). + Nakada). * Added pathmap support to rule dependents. In other words, if a pathmap format (beginning with a '%') is given as a Rake rule diff --git a/doc/release_notes/rake-0.7.3.rdoc b/doc/release_notes/rake-0.7.3.rdoc index 39e91bb98..7e9f92198 100755 --- a/doc/release_notes/rake-0.7.3.rdoc +++ b/doc/release_notes/rake-0.7.3.rdoc @@ -13,11 +13,11 @@ support custom Rake applications. require 'rake' Rake.application.init('myrake') - + task :default do something_interesting end - + Rake.application.top_level == What is Rake diff --git a/doc/release_notes/rake-0.8.0.rdoc b/doc/release_notes/rake-0.8.0.rdoc index 05e5877f6..4fc7fdd7b 100644 --- a/doc/release_notes/rake-0.8.0.rdoc +++ b/doc/release_notes/rake-0.8.0.rdoc @@ -1,7 +1,7 @@ = Rake 0.8.0/0.8.1 Released Rake version 0.8.0 is a new release of rake that includes serveral new -features. +features. == Changes diff --git a/doc/release_notes/rake-0.8.2.rdoc b/doc/release_notes/rake-0.8.2.rdoc index cfb994189..6119a5984 100644 --- a/doc/release_notes/rake-0.8.2.rdoc +++ b/doc/release_notes/rake-0.8.2.rdoc @@ -53,7 +53,7 @@ new features and numerous bug fixes. * Changed from using Mutex to Monitor. Evidently Mutex causes thread join errors when Ruby is compiled with -disable-pthreads. (Patch - supplied by Ittay Dror) + supplied by Ittay Dror) * Fixed bug in makefile parser that had problems with extra spaces in file task names. (Patch supplied by Ittay Dror) diff --git a/doc/release_notes/rake-0.8.3.rdoc b/doc/release_notes/rake-0.8.3.rdoc index fefc8c073..3ee38ccb6 100644 --- a/doc/release_notes/rake-0.8.3.rdoc +++ b/doc/release_notes/rake-0.8.3.rdoc @@ -12,7 +12,7 @@ Rake version 0.8.3 is a bug-fix release of rake. directory. * Added fix to handle ruby installations in directories with spaces in - their name. + their name. == What is Rake diff --git a/doc/release_notes/rake-0.8.4.rdoc b/doc/release_notes/rake-0.8.4.rdoc index 8ccb1abc2..d27de8b27 100644 --- a/doc/release_notes/rake-0.8.4.rdoc +++ b/doc/release_notes/rake-0.8.4.rdoc @@ -69,7 +69,7 @@ Otherwise, you can get it from the more traditional places: Home Page:: http://rake.rubyforge.org/ Download:: http://rubyforge.org/project/showfiles.php?group_id=50 -GitHub:: git://github.com/jimweirich/rake.git +GitHub:: git://github.com/jimweirich/rake.git == Task Argument Examples diff --git a/doc/release_notes/rake-0.8.5.rdoc b/doc/release_notes/rake-0.8.5.rdoc index 9c828cef8..0ee2583dd 100644 --- a/doc/release_notes/rake-0.8.5.rdoc +++ b/doc/release_notes/rake-0.8.5.rdoc @@ -39,7 +39,7 @@ Otherwise, you can get it from the more traditional places: Home Page:: http://rake.rubyforge.org/ Download:: http://rubyforge.org/project/showfiles.php?group_id=50 -GitHub:: git://github.com/jimweirich/rake.git +GitHub:: git://github.com/jimweirich/rake.git == Thanks diff --git a/doc/release_notes/rake-0.8.6.rdoc b/doc/release_notes/rake-0.8.6.rdoc index e1031ad33..476446077 100644 --- a/doc/release_notes/rake-0.8.6.rdoc +++ b/doc/release_notes/rake-0.8.6.rdoc @@ -41,7 +41,7 @@ Otherwise, you can get it from the more traditional places: Home Page:: http://rake.rubyforge.org/ Download:: http://rubyforge.org/project/showfiles.php?group_id=50 -GitHub:: git://github.com/jimweirich/rake.git +GitHub:: git://github.com/jimweirich/rake.git == Thanks diff --git a/doc/release_notes/rake-0.8.7.rdoc b/doc/release_notes/rake-0.8.7.rdoc index fb0c5d4e3..884f4c659 100644 --- a/doc/release_notes/rake-0.8.7.rdoc +++ b/doc/release_notes/rake-0.8.7.rdoc @@ -42,7 +42,7 @@ Otherwise, you can get it from the more traditional places: Home Page:: http://rake.rubyforge.org/ Download:: http://rubyforge.org/project/showfiles.php?group_id=50 -GitHub:: git://github.com/jimweirich/rake.git +GitHub:: git://github.com/jimweirich/rake.git == Thanks diff --git a/install.rb b/install.rb index 1db443fae..f5e84c391 100644 --- a/install.rb +++ b/install.rb @@ -27,7 +27,7 @@ def installBIN(from, opfile) fail "Cannot find a temporary directory" unless tmp_dir tmp_file = File.join(tmp_dir, "_tmp") - + File.open(from) do |ip| File.open(tmp_file, "w") do |op| ruby = File.join($realbindir, $ruby) @@ -62,7 +62,7 @@ def installBIN(from, opfile) if (destdir = ENV['DESTDIR']) $bindir = destdir + $bindir $sitedir = destdir + $sitedir - + FileUtils.mkdir_p($bindir) FileUtils.mkdir_p($sitedir) end diff --git a/lib/rake/alt_system.rb b/lib/rake/alt_system.rb index b0b799cfe..b7f967a03 100644 --- a/lib/rake/alt_system.rb +++ b/lib/rake/alt_system.rb @@ -1,6 +1,6 @@ # # Copyright (c) 2008 James M. Lawrence -# +# # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation files # (the "Software"), to deal in the Software without restriction, @@ -8,10 +8,10 @@ # publish, distribute, sublicense, and/or sell copies of the Software, # and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: -# +# # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. -# +# # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -27,7 +27,7 @@ # # Alternate implementations of system() and backticks `` on Windows # for ruby-1.8 and earlier. -# +# module Rake::AltSystem WINDOWS = RbConfig::CONFIG["host_os"] =~ %r!(msdos|mswin|djgpp|mingw)! @@ -37,7 +37,7 @@ def define_module_function(name, &block) module_function(name) end end - + if WINDOWS and RUBY_VERSION < "1.9.0" RUNNABLE_EXTS = %w[com exe bat cmd] RUNNABLE_PATTERN = %r!\.(#{RUNNABLE_EXTS.join('|')})\Z!i diff --git a/lib/rake/application.rb b/lib/rake/application.rb index 795839d90..f919c6c3b 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -5,7 +5,7 @@ require 'rake/win32' module Rake - + ###################################################################### # Rake main application object. When invoking +rake+ from the # command line, a Rake::Application object is created and run. @@ -232,7 +232,7 @@ def terminal_width 80 end - # Calculate the dynamic width of the + # Calculate the dynamic width of the def dynamic_width @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput) end @@ -248,7 +248,7 @@ def dynamic_width_tput def unix? RbConfig::CONFIG['host_os'] =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i end - + def windows? Win32.windows? end @@ -308,7 +308,7 @@ def standard_rake_options ], ['--execute-continue', '-E CODE', "Execute some Ruby code, then continue with normal task processing.", - lambda { |value| eval(value) } + lambda { |value| eval(value) } ], ['--libdir', '-I LIBDIR', "Include LIBDIR in the search path for required modules.", lambda { |value| $:.push(value) } @@ -320,9 +320,9 @@ def standard_rake_options lambda { |value| Rake.verbose(false) } ], ['--rakefile', '-f [FILE]', "Use FILE as the rakefile.", - lambda { |value| + lambda { |value| value ||= '' - @rakefiles.clear + @rakefiles.clear @rakefiles << value } ], @@ -509,7 +509,7 @@ def system_dir end end end - + # The standard directory containing system wide rake files. if Win32.windows? def standard_system_dir #:nodoc: diff --git a/lib/rake/clean.rb b/lib/rake/clean.rb index ba461c9b5..e42c73c0a 100644 --- a/lib/rake/clean.rb +++ b/lib/rake/clean.rb @@ -17,17 +17,17 @@ Rake::DSL.environment do CLEAN = Rake::FileList["**/*~", "**/*.bak", "**/core"] - CLEAN.clear_exclude.exclude { |fn| - fn.pathmap("%f") == 'core' && File.directory?(fn) + CLEAN.clear_exclude.exclude { |fn| + fn.pathmap("%f") == 'core' && File.directory?(fn) } - + desc "Remove any temporary products." task :clean do CLEAN.each { |fn| rm_r fn rescue nil } end - + CLOBBER = Rake::FileList.new - + desc "Remove any generated file." task :clobber => [:clean] do CLOBBER.each { |fn| rm_r fn rescue nil } diff --git a/lib/rake/contrib/publisher.rb b/lib/rake/contrib/publisher.rb index b78573582..356c158bb 100644 --- a/lib/rake/contrib/publisher.rb +++ b/lib/rake/contrib/publisher.rb @@ -9,7 +9,7 @@ # application. The application name (APP) is appended to # this directory before using. # * pkgdir :: Directory on the host system where packages can be -# placed. +# placed. HostInfo = Struct.new(:name, :webdir, :pkgdir) # Manage several publishers as a single entity. diff --git a/lib/rake/contrib/sshpublisher.rb b/lib/rake/contrib/sshpublisher.rb index d77fcc377..15158bb88 100644 --- a/lib/rake/contrib/sshpublisher.rb +++ b/lib/rake/contrib/sshpublisher.rb @@ -12,12 +12,12 @@ def initialize(host, remote_dir, local_dir) @remote_dir = remote_dir @local_dir = local_dir end - + def upload sh %{scp -rq #{@local_dir}/* #{@host}:#{@remote_dir}} end end - + # Publish an entire directory to a fresh remote directory using SSH. class SshFreshDirPublisher < SshDirPublisher def upload @@ -26,7 +26,7 @@ def upload super end end - + # Publish a list of files to an existing remote directory. class SshFilePublisher # Create a publisher using the give host information. @@ -36,7 +36,7 @@ def initialize(host, remote_dir, local_dir, *files) @local_dir = local_dir @files = files end - + # Upload the local directory to the remote directory. def upload @files.each do |fn| diff --git a/lib/rake/contrib/sys.rb b/lib/rake/contrib/sys.rb index b89bdb86b..d1c4ff3f7 100644 --- a/lib/rake/contrib/sys.rb +++ b/lib/rake/contrib/sys.rb @@ -42,7 +42,7 @@ def run(cmd) def ruby(*args) run "#{RUBY} #{args.join(' ')}" end - + # Copy a single file from +file_name+ to +dest_file+. def copy(file_name, dest_file) log "Copying file #{file_name} to #{dest_file}" diff --git a/lib/rake/dsl_definition.rb b/lib/rake/dsl_definition.rb index 2c0147609..b098036fe 100644 --- a/lib/rake/dsl_definition.rb +++ b/lib/rake/dsl_definition.rb @@ -7,7 +7,7 @@ module DSL # Include the FileUtils file manipulation functions in the top # level module, but mark them private so that they don't # unintentionally define methods on other objects. - + include FileUtilsExt private(*FileUtils.instance_methods(false)) private(*FileUtilsExt.instance_methods(false)) @@ -22,8 +22,8 @@ module DSL def task(*args, &block) Rake::Task.define_task(*args, &block) end - - + + # Declare a file task. # # Example: @@ -40,13 +40,13 @@ def task(*args, &block) def file(*args, &block) Rake::FileTask.define_task(*args, &block) end - + # Declare a file creation task. # (Mainly used for the directory command). def file_create(args, &block) Rake::FileCreationTask.define_task(args, &block) end - + # Declare a set of files tasks to create the given directories on # demand. # @@ -60,7 +60,7 @@ def directory(dir) end end end - + # Declare a task that performs its prerequisites in # parallel. Multitasks does *not* guarantee that its prerequisites # will execute in any given order (which is obvious when you think @@ -72,7 +72,7 @@ def directory(dir) def multitask(args, &block) Rake::MultiTask.define_task(args, &block) end - + # Create a new rake namespace and use it for evaluating the given # block. Returns a NameSpace object that can be used to lookup # tasks defined in the namespace. @@ -92,7 +92,7 @@ def namespace(name=nil, &block) end Rake.application.in_namespace(name, &block) end - + # Declare a rule for auto-tasks. # # Example: @@ -103,7 +103,7 @@ def namespace(name=nil, &block) def rule(*args, &block) Rake::Task.create_rule(*args, &block) end - + # Describe the next rake task. # # Example: @@ -115,7 +115,7 @@ def rule(*args, &block) def desc(description) Rake.application.last_description = description end - + # Import the partial Rakefiles +fn+. Imported files are loaded # _after_ the current file is completely loaded. This allows the # import statement to appear anywhere in the importing file, and yet diff --git a/lib/rake/environment.rb b/lib/rake/environment.rb index 4a7686313..e33ad0c67 100644 --- a/lib/rake/environment.rb +++ b/lib/rake/environment.rb @@ -37,4 +37,4 @@ def DSL.environment(&block) end end - + diff --git a/lib/rake/ext/string.rb b/lib/rake/ext/string.rb index 293b7950e..d271965b8 100644 --- a/lib/rake/ext/string.rb +++ b/lib/rake/ext/string.rb @@ -44,7 +44,7 @@ def pathmap_partial(n) File.join(partial_dirs) end protected :pathmap_partial - + # Preform the pathmap replacement operations on the given path. The # patterns take the form 'pat1,rep1;pat2,rep2...'. def pathmap_replace(patterns, &block) diff --git a/lib/rake/file_list.rb b/lib/rake/file_list.rb index a4f23d48a..da830b9be 100644 --- a/lib/rake/file_list.rb +++ b/lib/rake/file_list.rb @@ -305,7 +305,7 @@ def egrep(pattern, *options) end matched end - + # Return a new file list that only contains file names from the current # file list that exist on the file system. def existing @@ -383,7 +383,7 @@ def [](*args) new(*args) end end - end + end end module Rake diff --git a/lib/rake/file_utils_ext.rb b/lib/rake/file_utils_ext.rb index ad69171f8..40fe5ac3d 100644 --- a/lib/rake/file_utils_ext.rb +++ b/lib/rake/file_utils_ext.rb @@ -7,16 +7,16 @@ module Rake # module FileUtilsExt include FileUtils - + class << self attr_accessor :verbose_flag, :nowrite_flag end FileUtilsExt.verbose_flag = nil FileUtilsExt.nowrite_flag = false - + $fileutils_verbose = true $fileutils_nowrite = false - + FileUtils::OPT_TABLE.each do |name, opts| default_options = [] if opts.include?(:verbose) || opts.include?("verbose") @@ -25,7 +25,7 @@ class << self if opts.include?(:noop) || opts.include?("noop") default_options << ':noop => FileUtilsExt.nowrite_flag' end - + next if default_options.empty? module_eval(<<-EOS, __FILE__, __LINE__ + 1) def #{name}( *args, &block ) @@ -36,7 +36,7 @@ def #{name}( *args, &block ) end EOS end - + # Get/set the verbose flag controlling output from the FileUtils utilities. # If verbose is true, then the utility method is echoed to standard output. # @@ -57,7 +57,7 @@ def verbose(value=nil) end FileUtilsExt.verbose_flag end - + # Get/set the nowrite flag controlling output from the FileUtils utilities. # If verbose is true, then the utility method is echoed to standard output. # @@ -78,7 +78,7 @@ def nowrite(value=nil) end oldvalue end - + # Use this function to prevent protentially destructive ruby code from # running when the :nowrite flag is set. # @@ -100,7 +100,7 @@ def when_writing(msg=nil) yield end end - + # Merge the given options with the default values. def rake_merge_option(args, defaults) if Hash === args.last @@ -110,12 +110,12 @@ def rake_merge_option(args, defaults) args.push defaults args end - + # Send the message to the default rake output (which is $stderr). def rake_output_message(message) $stderr.puts(message) end - + # Check that the options do not contain options not listed in +optdecl+. An # ArgumentError exception is thrown if non-declared options are found. def rake_check_options(options, *optdecl) @@ -125,8 +125,8 @@ def rake_check_options(options, *optdecl) end raise ArgumentError, "no such option: #{h.keys.join(' ')}" unless h.empty? end - + extend self end - + end diff --git a/lib/rake/invocation_chain.rb b/lib/rake/invocation_chain.rb index a2c858589..8a01ab4c2 100644 --- a/lib/rake/invocation_chain.rb +++ b/lib/rake/invocation_chain.rb @@ -1,5 +1,5 @@ module Rake - + #################################################################### # InvocationChain tracks the chain of task invocations to detect # circular dependencies. @@ -47,5 +47,5 @@ def to_s end EMPTY = EmptyInvocationChain.new - end + end end diff --git a/lib/rake/name_space.rb b/lib/rake/name_space.rb index 073285468..e1cc0940b 100644 --- a/lib/rake/name_space.rb +++ b/lib/rake/name_space.rb @@ -1,5 +1,5 @@ module Rake - + # The NameSpace class will lookup task names in the the scope # defined by a +namespace+ command. # diff --git a/lib/rake/pseudo_status.rb b/lib/rake/pseudo_status.rb index 8ce050309..b58df3da1 100644 --- a/lib/rake/pseudo_status.rb +++ b/lib/rake/pseudo_status.rb @@ -1,5 +1,5 @@ module Rake - + #################################################################### # Exit status class for times the system just gives us a nil. class PseudoStatus diff --git a/lib/rake/rdoctask.rb b/lib/rake/rdoctask.rb index 660f3a2f0..8050afce7 100644 --- a/lib/rake/rdoctask.rb +++ b/lib/rake/rdoctask.rb @@ -11,7 +11,7 @@ module Rake # The RDocTask will create the following targets: # # [rdoc] - # Main task for this RDOC task. + # Main task for this RDOC task. # # [:clobber_rdoc] # Delete all the rdoc files. This target is automatically @@ -44,7 +44,7 @@ module Rake # end # # The tasks would then be named :rdoc_dev, :clobber_rdoc_dev, and - # :rerdoc_dev. + # :rerdoc_dev. # # If you wish to have completely different task names, then pass a Hash as # first argument. With the :rdoc, :clobber_rdoc and @@ -81,7 +81,7 @@ class RDocTask < TaskLib # Whether to run the rdoc process as an external shell (default is false) attr_accessor :external - + attr_accessor :inline_source # Create an RDoc task with the given name. See the RDocTask class overview @@ -93,7 +93,7 @@ def initialize(name = :rdoc) # :yield: self raise ArgumentError, "Invalid option(s) passed to RDocTask.new: #{invalid_options.join(", ")}" end end - + @name = name @rdoc_files = Rake::FileList.new @rdoc_dir = 'html' @@ -106,7 +106,7 @@ def initialize(name = :rdoc) # :yield: self yield self if block_given? define end - + # Create the tasks defined by this task lib. def define if rdoc_task_name != "rdoc" @@ -115,17 +115,17 @@ def define desc "Build the #{rdoc_task_name} HTML Files" end task rdoc_task_name - + desc "Force a rebuild of the RDOC files" task rerdoc_task_name => [clobber_task_name, rdoc_task_name] - - desc "Remove rdoc products" + + desc "Remove rdoc products" task clobber_task_name do rm_r rdoc_dir rescue nil end - + task :clobber => [clobber_task_name] - + directory @rdoc_dir task rdoc_task_name => [rdoc_target] file rdoc_target => @rdoc_files + [Rake.application.rakefile] do @@ -164,7 +164,7 @@ def quote(str) def option_string option_list.join(' ') end - + # The block passed to this method will be called just before running the # RDoc generator. It is allowed to modify RDocTask attributes inside the # block. @@ -173,11 +173,11 @@ def before_running_rdoc(&block) end private - + def rdoc_target "#{rdoc_dir}/index.html" end - + def rdoc_task_name case name when Hash @@ -186,7 +186,7 @@ def rdoc_task_name name.to_s end end - + def clobber_task_name case name when Hash @@ -195,7 +195,7 @@ def clobber_task_name "clobber_#{name}" end end - + def rerdoc_task_name case name when Hash diff --git a/lib/rake/task.rb b/lib/rake/task.rb index 10cd204e6..21f39558e 100644 --- a/lib/rake/task.rb +++ b/lib/rake/task.rb @@ -1,7 +1,7 @@ require 'rake/invocation_exception_mixin' module Rake - + # ######################################################################### # A Task is the basic unit of work in a Rakefile. Tasks have associated # actions (possibly more than one) and a list of prerequisites. When @@ -50,12 +50,12 @@ def inspect def sources @sources ||= [] end - + # List of prerequisite tasks def prerequisite_tasks prerequisites.collect { |pre| lookup_prerequisite(pre) } end - + def lookup_prerequisite(prerequisite_name) application[prerequisite_name, @scope] end @@ -65,7 +65,7 @@ def lookup_prerequisite(prerequisite_name) def source @sources.first if defined?(@sources) end - + # Create a task named +task_name+ with no actions or prerequisites. Use # +enhance+ to add actions and prerequisites. def initialize(task_name, app) diff --git a/lib/rake/task_arguments.rb b/lib/rake/task_arguments.rb index 39fe3e781..f22c87e19 100644 --- a/lib/rake/task_arguments.rb +++ b/lib/rake/task_arguments.rb @@ -58,9 +58,9 @@ def to_s def inspect to_s end - + protected - + def lookup(name) if @hash.has_key?(name) @hash[name] diff --git a/lib/rake/task_manager.rb b/lib/rake/task_manager.rb index 2d27e5c43..ba40b1713 100644 --- a/lib/rake/task_manager.rb +++ b/lib/rake/task_manager.rb @@ -84,7 +84,7 @@ def resolve_args_without_dependencies(args) [task_name, arg_names, []] end private :resolve_args_without_dependencies - + # Resolve task arguments for a task or rule when there are # dependencies declared. # @@ -115,7 +115,7 @@ def resolve_args_with_dependencies(args, hash) # :nodoc: [task_name, arg_names, deps] end private :resolve_args_with_dependencies - + # If a rule can be found that matches the task name, enhance the # task with the prerequisites and actions from the rule. Set the # source attribute of the task appropriately for the rule. Return @@ -207,14 +207,14 @@ def in_namespace(name) end private - + # Add a location to the locations field of the given task. def add_location(task) loc = find_location task.locations << loc if loc task end - + # Find the location that called into the dsl layer. def find_location locations = caller @@ -225,7 +225,7 @@ def find_location end nil end - + # Generate an anonymous namespace name. def generate_name @seed ||= 0 @@ -285,8 +285,8 @@ def make_sources(task_name, extensions) end - private - + private + # Return the current description. If there isn't one, try to find it # by reading in the source file and looking for a comment immediately # prior to the task definition @@ -295,14 +295,14 @@ def get_description(task) @last_description = nil desc end - + def find_preceding_comment_for_task(task) loc = task.locations.last file_name, line = parse_location(loc) return nil unless file_name comment_from_file(file_name, line) end - + def parse_location(loc) if loc =~ /^(.*):(\d+)/ [ $1, Integer($2) ] diff --git a/lib/rake/testtask.rb b/lib/rake/testtask.rb index 8278e8cdb..afcfe3d1f 100644 --- a/lib/rake/testtask.rb +++ b/lib/rake/testtask.rb @@ -10,7 +10,7 @@ module Rake # Create a task that runs a set of tests. # # Example: - # + # # Rake::TestTask.new do |t| # t.libs << "test" # t.test_files = FileList['test/test*.rb'] @@ -63,7 +63,7 @@ class TestTask < TaskLib # * :rake -- Rake provided test loading script (default). # * :testrb -- Ruby provided test loading script. # * :direct -- Load tests using command line loader. - # + # attr_accessor :loader # Array of commandline options to pass to ruby when running test loader. @@ -118,7 +118,7 @@ def ruby_opts_string def lib_path @libs.join(File::PATH_SEPARATOR) end - + def file_list_string file_list.collect { |fn| "\"#{fn}\"" }.join(' ') end @@ -170,7 +170,7 @@ def find_file(fn) # :nodoc: end nil end - + def rake_lib_dir # :nodoc: find_dir('rake') or fail "unable to find rake lib" diff --git a/rakelib/rbx.rake b/rakelib/rbx.rake index c5ba10918..8791dbbb3 100644 --- a/rakelib/rbx.rake +++ b/rakelib/rbx.rake @@ -38,7 +38,7 @@ namespace "rbx" do task :check_svn do fail "Cannot find Ruby 1.9 SVN directory: #{Rbx::SVN}" unless - File.directory?(Rbx::SVN) + File.directory?(Rbx::SVN) end diff --git a/rakelib/ruby19.rake b/rakelib/ruby19.rake index 8bbd8015c..36f60964c 100644 --- a/rakelib/ruby19.rake +++ b/rakelib/ruby19.rake @@ -44,7 +44,7 @@ namespace "ruby19" do task :check_svn do fail "Cannot find Ruby 1.9 SVN directory: #{Ruby19::SVN}" unless - File.directory?(Ruby19::SVN) + File.directory?(Ruby19::SVN) end diff --git a/test/functional/session_based_tests.rb b/test/functional/session_based_tests.rb index 9e461afd7..521aedea7 100644 --- a/test/functional/session_based_tests.rb +++ b/test/functional/session_based_tests.rb @@ -80,7 +80,7 @@ def test_multi_desc assert_no_match %r{^rake c}, @out assert_match %r{^rake d *# x{65}\.\.\.$}, @out end - + def test_long_description in_environment("PWD" => "test/data/multidesc") do rake "--describe" @@ -341,7 +341,7 @@ def test_file_task_are_not_scoped_by_namespaces assert_match(/^XYZ1\nXYZ2$/m, @out) end end - + def test_file_task_dependencies_scoped_by_namespaces in_environment("PWD" => "test/data/namespace") do rake "scopedep.rb" @@ -350,7 +350,7 @@ def test_file_task_dependencies_scoped_by_namespaces ensure remove_namespace_files end - + def test_rake_returns_status_error_values in_environment("PWD" => "test/data/statusreturn") do rake "exit5" @@ -371,7 +371,7 @@ def test_comment_before_task_acts_like_desc end assert_match("comment for t1", @out) end - + def test_comment_separated_from_task_by_blank_line_is_not_picked_up Dir.chdir("test/data/comments") { rake("-T")} assert_not_match("t2", @out) @@ -381,35 +381,35 @@ def test_comment_after_desc_is_ignored Dir.chdir("test/data/comments") { rake("-T")} assert_match("override comment for t3", @out) end - + def test_comment_before_desc_is_ignored Dir.chdir("test/data/comments") { rake("-T")} assert_match("override comment for t4", @out) end - + def test_correct_number_of_tasks_reported Dir.chdir("test/data/comments") { rake("-T")} assert_equal(3, @out.split(/\n/).grep(/t\d/).size) end - + def test_file_list_is_requirable_separately ruby "-rrake/file_list", "-e 'puts Rake::FileList[\"a\"].size'" assert_equal "1\n", @out assert_equal 0, @status end - + private def assert_not_match(pattern, string, comment="'#{pattern}' was found (incorrectly) in '#{string}.inspect") assert_nil Regexp.new(pattern).match(string), comment end - + def remove_chaining_files %w(play.scpt play.app base).each do |fn| FileUtils.rm_f File.join("test/data/chains", fn) end end - + def remove_namespace_files %w(scopedep.rb).each do |fn| FileUtils.rm_f File.join("test/data/namespace", fn) diff --git a/test/lib/application_test.rb b/test/lib/application_test.rb index 6b95aef29..3aaf511da 100644 --- a/test/lib/application_test.rb +++ b/test/lib/application_test.rb @@ -26,7 +26,7 @@ def setup @app.options.rakelib = [] Rake::TaskManager.record_task_metadata = true end - + def teardown Rake::TaskManager.record_task_metadata = false super @@ -143,7 +143,7 @@ def test_not_finding_rakefile def test_load_rakefile in_environment("PWD" => "test/data/unittest") do - @app.instance_eval do + @app.instance_eval do handle_options options.silent = true load_rakefile @@ -171,8 +171,8 @@ def test_load_rakefile_not_found handle_options options.silent = true end - ex = assert_exception(RuntimeError) do - @app.instance_eval do raw_load_rakefile end + ex = assert_exception(RuntimeError) do + @app.instance_eval do raw_load_rakefile end end assert_match(/no rakefile found/i, ex.message) end @@ -331,7 +331,7 @@ def teardown Rake::FileUtilsExt.verbose_flag = false Rake::FileUtilsExt.nowrite_flag = false end - + def clear_argv while ! ARGV.empty? ARGV.pop @@ -469,7 +469,7 @@ def test_require assert_equal 3, TESTING_REQUIRE.size end end - + def test_missing_require in_environment do ex = assert_exception(LoadError) do @@ -580,7 +580,7 @@ def test_version end end end - + def test_classic_namespace in_environment do flags(['--classic-namespace'], ['-C', '-T', '-P', '-n', '-s', '-t']) do |opts| @@ -598,7 +598,7 @@ def test_bad_option in_environment do error_output = capture_stderr do ex = assert_exception(OptionParser::InvalidOption) do - flags('--bad-option') + flags('--bad-option') end if ex.message =~ /^While/ # Ruby 1.9 error message assert_match(/while parsing/i, ex.message) @@ -615,12 +615,12 @@ def test_task_collection command_line("a", "b") assert_equal ["a", "b"], @tasks.sort end - + def test_default_task_collection command_line() assert_equal ["default"], @tasks end - + def test_environment_definition ENV.delete('TESTKEY') command_line("a", "TESTKEY=12") @@ -628,12 +628,12 @@ def test_environment_definition assert '12', ENV['TESTKEY'] end - private + private def flags(*sets) sets.each do |set| ARGV.clear - @out = capture_stdout { + @out = capture_stdout { @exit = catch(:system_exit) { command_line(*set) } } yield(@app.options) if block_given? @@ -659,31 +659,31 @@ class TestTaskArgumentParsing < Test::Unit::TestCase def setup @app = Rake::Application.new end - + def test_name_only name, args = @app.parse_task_string("name") assert_equal "name", name assert_equal [], args end - + def test_empty_args name, args = @app.parse_task_string("name[]") assert_equal "name", name assert_equal [], args end - + def test_one_argument name, args = @app.parse_task_string("name[one]") assert_equal "name", name assert_equal ["one"], args end - + def test_two_arguments name, args = @app.parse_task_string("name[one,two]") assert_equal "name", name assert_equal ["one", "two"], args end - + def test_can_handle_spaces_between_args name, args = @app.parse_task_string("name[one, two,\tthree , \tfour]") assert_equal "name", name diff --git a/test/lib/definitions_test.rb b/test/lib/definitions_test.rb index 5fba312e6..248879f90 100644 --- a/test/lib/definitions_test.rb +++ b/test/lib/definitions_test.rb @@ -10,7 +10,7 @@ class TestDefinitions < Test::Unit::TestCase include Rake include TestMethods - + EXISTINGFILE = "testdata/existing" def setup @@ -82,4 +82,4 @@ def create_existing_file end end - + diff --git a/test/lib/earlytime_test.rb b/test/lib/earlytime_test.rb index 9c1ebe974..819e25dda 100644 --- a/test/lib/earlytime_test.rb +++ b/test/lib/earlytime_test.rb @@ -25,7 +25,7 @@ def test_original_time_compare_is_not_messed_up assert t1 < t2 assert t2 > t1 assert t1 == t1 - assert t2 == t2 + assert t2 == t2 end def test_to_s diff --git a/test/lib/file_task_test.rb b/test/lib/file_task_test.rb index edac7e7b8..1d7032de4 100644 --- a/test/lib/file_task_test.rb +++ b/test/lib/file_task_test.rb @@ -77,7 +77,7 @@ def test_existing_file_depends_on_non_existing_file # deleting the file target on failure is always the proper thing to # do. I'm willing to hear input on this topic. def ztest_file_deletes_on_failure - task :obj + task :obj file NEWFILE => [:obj] do |t| FileUtils.touch NEWFILE fail "Ooops" diff --git a/test/lib/filelist_test.rb b/test/lib/filelist_test.rb index 4b8e8a63b..a50ee2b85 100644 --- a/test/lib/filelist_test.rb +++ b/test/lib/filelist_test.rb @@ -87,7 +87,7 @@ def test_add_return h = f.include("y") assert_equal f.object_id, h.object_id end - + def test_match fl = FileList.new fl.include('test/lib/*_test.rb') @@ -153,7 +153,7 @@ def test_exclude fl.exclude('testdata/existing') assert_equal [], fl end - + def test_excluding_via_block fl = FileList['testdata/a.c', 'testdata/b.c', 'testdata/xyz.c'] fl.exclude { |fn| fn.pathmap('%n') == 'xyz' } @@ -233,24 +233,24 @@ def test_sub assert_equal ["testdata/abc.o", "testdata/x.o", "testdata/xyz.o"].sort, f3.sort end - + def test_claim_to_be_a_kind_of_array fl = FileList['testdata/*.c'] assert fl.is_a?(Array) assert fl.kind_of?(Array) end - + def test_claim_to_be_a_kind_of_filelist fl = FileList['testdata/*.c'] assert fl.is_a?(FileList) assert fl.kind_of?(FileList) end - + def test_claim_to_be_a_filelist_instance fl = FileList['testdata/*.c'] assert fl.instance_of?(FileList) end - + def test_dont_claim_to_be_an_array_instance fl = FileList['testdata/*.c'] assert ! fl.instance_of?(Array) @@ -592,12 +592,12 @@ def test_other_array_returning_methods assert_equal ['b', 'd'], r assert_equal FileList, r.class end - + def test_file_utils_can_use_filelists cfiles = FileList['testdata/*.c'] - + cp cfiles, @cdir, :verbose => false - + assert File.exist?(File.join(@cdir, 'abc.c')) assert File.exist?(File.join(@cdir, 'xyz.c')) assert File.exist?(File.join(@cdir, 'x.c')) @@ -605,7 +605,7 @@ def test_file_utils_can_use_filelists def create_test_data verbose(false) do - + mkdir "testdata" unless File.exist? "testdata" mkdir "testdata/CVS" rescue nil mkdir "testdata/.svn" rescue nil @@ -623,5 +623,5 @@ def create_test_data touch "testdata/existing" end end - + end diff --git a/test/lib/multitask_test.rb b/test/lib/multitask_test.rb index 04d9ee31e..6527a2764 100644 --- a/test/lib/multitask_test.rb +++ b/test/lib/multitask_test.rb @@ -50,4 +50,4 @@ def test_all_multitasks_wait_on_slow_prerequisites end end - + diff --git a/test/lib/pathmap_test.rb b/test/lib/pathmap_test.rb index 941cf7cec..b572837f5 100644 --- a/test/lib/pathmap_test.rb +++ b/test/lib/pathmap_test.rb @@ -27,7 +27,7 @@ def test_f_returns_basename def test_n_returns_basename_without_extension assert_equal "abc", "abc.rb".pathmap("%n") - assert_equal "abc", "abc".pathmap("%n") + assert_equal "abc", "abc".pathmap("%n") assert_equal "abc", "this/is/a/dir/abc.rb".pathmap("%n") assert_equal "abc", "/this/is/a/dir/abc.rb".pathmap("%n") assert_equal "abc", "/this/is/a/dir/abc".pathmap("%n") diff --git a/test/lib/rake_test.rb b/test/lib/rake_test.rb index c99596572..58e11e222 100644 --- a/test/lib/rake_test.rb +++ b/test/lib/rake_test.rb @@ -37,5 +37,5 @@ def test_can_override_application def test_original_dir_reports_current_dir assert_equal Dir.pwd, Rake.original_dir end - + end diff --git a/test/lib/rdoc_task_test.rb b/test/lib/rdoc_task_test.rb index 2b6519453..4262b793f 100644 --- a/test/lib/rdoc_task_test.rb +++ b/test/lib/rdoc_task_test.rb @@ -7,18 +7,18 @@ class TestRDocTask < Test::Unit::TestCase include Rake include TestMethods - + def setup Task.clear end - + def test_tasks_creation Rake::RDocTask.new assert Task[:rdoc] assert Task[:clobber_rdoc] assert Task[:rerdoc] end - + def test_tasks_creation_with_custom_name_symbol rd = Rake::RDocTask.new(:rdoc_dev) assert Task[:rdoc_dev] @@ -26,7 +26,7 @@ def test_tasks_creation_with_custom_name_symbol assert Task[:rerdoc_dev] assert_equal :rdoc_dev, rd.name end - + def test_tasks_creation_with_custom_name_string rd = Rake::RDocTask.new("rdoc_dev") assert Task[:rdoc_dev] @@ -34,7 +34,7 @@ def test_tasks_creation_with_custom_name_string assert Task[:rerdoc_dev] assert_equal "rdoc_dev", rd.name end - + def test_tasks_creation_with_custom_name_hash options = { :rdoc => "rdoc", :clobber_rdoc => "rdoc:clean", :rerdoc => "rdoc:force" } rd = Rake::RDocTask.new(options) @@ -44,42 +44,42 @@ def test_tasks_creation_with_custom_name_hash assert_raises(RuntimeError) { Task[:clobber_rdoc] } assert_equal options, rd.name end - + def test_tasks_creation_with_custom_name_hash_will_use_default_if_an_option_isnt_given Rake::RDocTask.new(:clobber_rdoc => "rdoc:clean") assert Task[:rdoc] assert Task[:"rdoc:clean"] assert Task[:rerdoc] end - + def test_tasks_creation_with_custom_name_hash_raises_exception_if_invalid_option_given assert_raises(ArgumentError) do Rake::RDocTask.new(:foo => "bar") end - + begin Rake::RDocTask.new(:foo => "bar") rescue ArgumentError => e assert_match(/foo/, e.message) end end - + def test_inline_source_is_enabled_by_default rd = Rake::RDocTask.new assert rd.option_list.include?('--inline-source') end - + def test_inline_source_option_is_only_appended_if_option_not_already_given rd = Rake::RDocTask.new rd.options << '--inline-source' assert_equal 1, rd.option_list.grep('--inline-source').size - + rd = Rake::RDocTask.new rd.options << '-S' assert_equal 1, rd.option_list.grep('-S').size assert_equal 0, rd.option_list.grep('--inline-source').size end - + def test_inline_source_option_can_be_disabled rd = Rake::RDocTask.new rd.inline_source = false diff --git a/test/lib/task_arguments_test.rb b/test/lib/task_arguments_test.rb index b2a1212eb..48d4f1747 100644 --- a/test/lib/task_arguments_test.rb +++ b/test/lib/task_arguments_test.rb @@ -73,7 +73,7 @@ def test_child_hides_parent_arg_names child = Rake::TaskArguments.new(['aa'], [2], parent) assert_equal 2, child.aa end - + def test_default_arguments_values_can_be_merged ta = Rake::TaskArguments.new(["aa", "bb"], [nil, "original_val"]) ta.with_defaults({ :aa => 'default_val' }) diff --git a/test/lib/task_manager_test.rb b/test/lib/task_manager_test.rb index c60fb53bd..8d4c78923 100644 --- a/test/lib/task_manager_test.rb +++ b/test/lib/task_manager_test.rb @@ -129,7 +129,7 @@ def test_lookup_with_explicit_scopes end end assert_equal t1, @tm[:t, []] - assert_equal t2, @tm[:t, ["a"]] + assert_equal t2, @tm[:t, ["a"]] assert_equal t3, @tm[:t, ["a", "b"]] assert_equal s, @tm[:s, ["a", "b"]] assert_equal s, @tm[:s, ["a"]] @@ -147,7 +147,7 @@ def test_correctly_scoped_prerequisites_are_invoked @tm["a:x"].invoke assert_equal ["next z"], values end - + end class TestTaskManagerArgumentResolution < Test::Unit::TestCase diff --git a/test/lib/test_task_test.rb b/test/lib/test_task_test.rb index 8a18ec046..90b1bdfe5 100644 --- a/test/lib/test_task_test.rb +++ b/test/lib/test_task_test.rb @@ -6,7 +6,7 @@ class TestTestTask < Test::Unit::TestCase include Rake include TestMethods - + def setup Task.clear ENV.delete('TEST') From c225f5d5eeb0668aa5e02fbe52ef62952d9757eb Mon Sep 17 00:00:00 2001 From: Eric Hodel Date: Fri, 7 Jan 2011 16:15:53 -0800 Subject: [PATCH 0143/1389] Replace Rake::GemPackageTask with Gem::PackageTask --- Rakefile | 1 + lib/rake/gempackagetask.rb | 96 +++-------------------------------- test/lib/package_task_test.rb | 55 +------------------- 3 files changed, 8 insertions(+), 144 deletions(-) diff --git a/Rakefile b/Rakefile index 8bbb8bc5b..db06564a3 100644 --- a/Rakefile +++ b/Rakefile @@ -195,6 +195,7 @@ else #### Dependencies and requirements. + s.required_rubygems_version '>= 1.3.2' #s.add_dependency('log4r', '> 1.0.4') #s.requirements << "" diff --git a/lib/rake/gempackagetask.rb b/lib/rake/gempackagetask.rb index 1e4632a26..51e92236f 100644 --- a/lib/rake/gempackagetask.rb +++ b/lib/rake/gempackagetask.rb @@ -1,97 +1,13 @@ -#!/usr/bin/env ruby +# rake/gempackagetask is deprecated in favor of rubygems/package_task -# Define a package task library to aid in the definition of GEM -# packages. +warn 'rake/gempackagetask is deprecated. Use rubygems/package_task instead' require 'rubygems' +require 'rubygems/package_task' + require 'rake' -require 'rake/packagetask' -require 'rubygems/user_interaction' -require 'rubygems/builder' module Rake - - # Create a package based upon a Gem spec. Gem packages, as well as - # zip files and tar/gzipped packages can be produced by this task. - # - # In addition to the Rake targets generated by PackageTask, a - # GemPackageTask will also generate the following tasks: - # - # ["package_dir/name-version.gem"] - # Create a Ruby GEM package with the given name and version. - # - # Example using a Ruby GEM spec: - # - # require 'rubygems' - # - # spec = Gem::Specification.new do |s| - # s.platform = Gem::Platform::RUBY - # s.summary = "Ruby based make-like utility." - # s.name = 'rake' - # s.version = PKG_VERSION - # s.requirements << 'none' - # s.require_path = 'lib' - # s.autorequire = 'rake' - # s.files = PKG_FILES - # s.description = < [:gem] - desc "Build the gem file #{gem_file}" - task :gem => ["#{package_dir}/#{gem_file}"] - file "#{package_dir}/#{gem_file}" => [package_dir] + @gem_spec.files do - when_writing("Creating GEM") { - Gem::Builder.new(gem_spec).build - verbose(true) { - mv gem_file, "#{package_dir}/#{gem_file}" - } - } - end - end - - def gem_file - if @gem_spec.platform == Gem::Platform::RUBY - "#{package_name}.gem" - else - "#{package_name}-#{@gem_spec.platform}.gem" - end - end - - end + GemPackageTask = Gem::PackageTask end + diff --git a/test/lib/package_task_test.rb b/test/lib/package_task_test.rb index 980b65999..d0e25efdd 100644 --- a/test/lib/package_task_test.rb +++ b/test/lib/package_task_test.rb @@ -2,6 +2,7 @@ require 'test/unit' require 'rake/packagetask' +require 'rake/gempackagetask' require 'test/rake_test_setup' class TestPackageTask < Test::Unit::TestCase @@ -62,57 +63,3 @@ def test_clone end end - -begin - require 'rubygems' - require 'rake/gempackagetask' -rescue Exception - puts "WARNING: RubyGems not installed" -end - -if ! defined?(Gem) - puts "WARNING: Unable to test GemPackaging ... requires RubyGems" -else - class TestGemPackageTask < Test::Unit::TestCase - def test_gem_package - gem = Gem::Specification.new do |g| - g.name = "pkgr" - g.version = "1.2.3" - g.files = FileList["x"].resolve - end - pkg = Rake::GemPackageTask.new(gem) do |p| - p.package_files << "y" - end - assert_equal ["x", "y"], pkg.package_files - assert_equal "pkgr-1.2.3.gem", pkg.gem_file - end - - def test_gem_package_with_current_platform - gem = Gem::Specification.new do |g| - g.name = "pkgr" - g.version = "1.2.3" - g.files = FileList["x"].resolve - g.platform = Gem::Platform::CURRENT - end - pkg = Rake::GemPackageTask.new(gem) do |p| - p.package_files << "y" - end - assert_equal ["x", "y"], pkg.package_files - assert_match(/^pkgr-1\.2\.3-(\S+)\.gem$/, pkg.gem_file) - end - - def test_gem_package_with_ruby_platform - gem = Gem::Specification.new do |g| - g.name = "pkgr" - g.version = "1.2.3" - g.files = FileList["x"].resolve - g.platform = Gem::Platform::RUBY - end - pkg = Rake::GemPackageTask.new(gem) do |p| - p.package_files << "y" - end - assert_equal ["x", "y"], pkg.package_files - assert_equal "pkgr-1.2.3.gem", pkg.gem_file - end - end -end From ab97d7e74946f32f7a2f8c347da36cbf396a72b1 Mon Sep 17 00:00:00 2001 From: Eric Hodel Date: Fri, 7 Jan 2011 16:18:37 -0800 Subject: [PATCH 0144/1389] Update with recent commits --- CHANGES | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGES b/CHANGES index 3fd627d71..e6be4512c 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,13 @@ == Pre-Version 0.9.x +* Rake::GemPackageTask is deprecated. Use Gem::PackageTask (require + 'rubygems/package_task') + +* Rake now outputs various messages to $stderr instead of $stdout. + +* Rake no longer emits warnings for Config. Patch by Santiago Pastorino. + * Removed Rake's DSL methods from the top level scope. If you need to call 'task :xzy' in your code, include Rake::DSL into your class, or put the code in a Rake::DSL.environment do ... end block. From e13d857250a03aa578a801d96c853f2ea4b2e749 Mon Sep 17 00:00:00 2001 From: Eric Hodel Date: Fri, 7 Jan 2011 16:21:32 -0800 Subject: [PATCH 0145/1389] Update Rakefile to use Gem::PackageTask --- Rakefile | 7 +++---- test/lib/package_task_test.rb | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Rakefile b/Rakefile index db06564a3..d279017e8 100644 --- a/Rakefile +++ b/Rakefile @@ -8,9 +8,8 @@ begin require 'rubygems' - require 'rake/gempackagetask' + require 'rubygems/package_task' rescue Exception - nil end require 'rake/clean' require 'rake/testtask' @@ -195,7 +194,7 @@ else #### Dependencies and requirements. - s.required_rubygems_version '>= 1.3.2' + s.required_rubygems_version = '>= 1.3.2' #s.add_dependency('log4r', '> 1.0.4') #s.requirements << "" @@ -233,7 +232,7 @@ else # end end - package_task = Rake::GemPackageTask.new(SPEC) do |pkg| + package_task = Gem::PackageTask.new(SPEC) do |pkg| pkg.need_zip = true pkg.need_tar = true end diff --git a/test/lib/package_task_test.rb b/test/lib/package_task_test.rb index d0e25efdd..fe5a47ead 100644 --- a/test/lib/package_task_test.rb +++ b/test/lib/package_task_test.rb @@ -2,7 +2,6 @@ require 'test/unit' require 'rake/packagetask' -require 'rake/gempackagetask' require 'test/rake_test_setup' class TestPackageTask < Test::Unit::TestCase From eecdaf40ac9cd22d1e667525c38d833d57f7b632 Mon Sep 17 00:00:00 2001 From: Eric Hodel Date: Fri, 7 Jan 2011 16:31:33 -0800 Subject: [PATCH 0146/1389] Replace Rake::RDocTask with RDoc::Task --- CHANGES | 3 + Rakefile | 15 +- lib/rake/rdoctask.rb | 385 +++++++++++++++++++------------------ test/lib/rdoc_task_test.rb | 5 - 4 files changed, 215 insertions(+), 193 deletions(-) diff --git a/CHANGES b/CHANGES index e6be4512c..424edaaf0 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ == Pre-Version 0.9.x +* Rake::RDocTask is deprecated. Use RDoc::Task from RDoc 2.4.2+ (require + 'rdoc/task') + * Rake::GemPackageTask is deprecated. Use Gem::PackageTask (require 'rubygems/package_task') diff --git a/Rakefile b/Rakefile index d279017e8..ae3c55e56 100644 --- a/Rakefile +++ b/Rakefile @@ -6,14 +6,17 @@ # This file may be distributed under an MIT style license. See # MIT-LICENSE for details. -begin - require 'rubygems' - require 'rubygems/package_task' -rescue Exception -end +require 'rubygems' +require 'rubygems/package_task' require 'rake/clean' require 'rake/testtask' -require 'rake/rdoctask' + +begin + gem 'rdoc' + require 'rdoc/task' +rescue Gem::LoadError + require 'rake/rdoctask' +end CLEAN.include('**/*.o', '*.dot', '**/*.rbc') CLOBBER.include('doc/example/main', 'testdata') diff --git a/lib/rake/rdoctask.rb b/lib/rake/rdoctask.rb index 8050afce7..a0116842b 100644 --- a/lib/rake/rdoctask.rb +++ b/lib/rake/rdoctask.rb @@ -1,209 +1,230 @@ -#!/usr/bin/env ruby - -require 'rake' -require 'rake/tasklib' - -module Rake - - # Create a documentation task that will generate the RDoc files for - # a project. - # - # The RDocTask will create the following targets: - # - # [rdoc] - # Main task for this RDOC task. - # - # [:clobber_rdoc] - # Delete all the rdoc files. This target is automatically - # added to the main clobber target. - # - # [:rerdoc] - # Rebuild the rdoc files from scratch, even if they are not out - # of date. - # - # Simple Example: - # - # Rake::RDocTask.new do |rd| - # rd.main = "README.rdoc" - # rd.rdoc_files.include("README.rdoc", "lib/**/*.rb") - # end - # - # The +rd+ object passed to the block is an RDocTask object. See the - # attributes list for the RDocTask class for available customization options. - # - # == Specifying different task names - # - # You may wish to give the task a different name, such as if you are - # generating two sets of documentation. For instance, if you want to have a - # development set of documentation including private methods: - # - # Rake::RDocTask.new(:rdoc_dev) do |rd| - # rd.main = "README.doc" - # rd.rdoc_files.include("README.rdoc", "lib/**/*.rb") - # rd.options << "--all" - # end - # - # The tasks would then be named :rdoc_dev, :clobber_rdoc_dev, and - # :rerdoc_dev. - # - # If you wish to have completely different task names, then pass a Hash as - # first argument. With the :rdoc, :clobber_rdoc and - # :rerdoc options, you can customize the task names to your liking. - # For example: - # - # Rake::RDocTask.new(:rdoc => "rdoc", :clobber_rdoc => "rdoc:clean", :rerdoc => "rdoc:force") - # - # This will create the tasks :rdoc, :rdoc_clean and - # :rdoc:force. - # - class RDocTask < TaskLib - # Name of the main, top level task. (default is :rdoc) - attr_accessor :name - - # Name of directory to receive the html output files. (default is "html") - attr_accessor :rdoc_dir - - # Title of RDoc documentation. (defaults to rdoc's default) - attr_accessor :title - - # Name of file to be used as the main, top level file of the - # RDoc. (default is none) - attr_accessor :main - - # Name of template to be used by rdoc. (defaults to rdoc's default) - attr_accessor :template - - # List of files to be included in the rdoc generation. (default is []) - attr_accessor :rdoc_files - - # Additional list of options to be passed rdoc. (default is []) - attr_accessor :options - - # Whether to run the rdoc process as an external shell (default is false) - attr_accessor :external - - attr_accessor :inline_source - - # Create an RDoc task with the given name. See the RDocTask class overview - # for documentation. - def initialize(name = :rdoc) # :yield: self - if name.is_a?(Hash) - invalid_options = name.keys.map { |k| k.to_sym } - [:rdoc, :clobber_rdoc, :rerdoc] - if !invalid_options.empty? - raise ArgumentError, "Invalid option(s) passed to RDocTask.new: #{invalid_options.join(", ")}" +# rake/rdoctask is deprecated in favor of rdoc/task + +warn 'rake/rdoctask is deprecated. Use rdoc/task instead (in RDoc 2.4.2+)' + +require 'rubygems' + +begin + gem 'rdoc' + require 'rdoc' + require 'rdoc/task' +rescue LoadError, Gem::LoadError +end + +if defined?(RDoc::Task) then + module Rake + RDocTask = RDoc::Task unless const_defined? :RDocTask + end +else + require 'rake' + require 'rake/tasklib' + + module Rake + + # NOTE: Rake::RDocTask is deprecated in favor of RDoc:Task which is included + # in RDoc 2.4.2+. Use require 'rdoc/task' to require it. + # + # Create a documentation task that will generate the RDoc files for + # a project. + # + # The RDocTask will create the following targets: + # + # [rdoc] + # Main task for this RDOC task. + # + # [:clobber_rdoc] + # Delete all the rdoc files. This target is automatically + # added to the main clobber target. + # + # [:rerdoc] + # Rebuild the rdoc files from scratch, even if they are not out + # of date. + # + # Simple Example: + # + # Rake::RDocTask.new do |rd| + # rd.main = "README.rdoc" + # rd.rdoc_files.include("README.rdoc", "lib/**/*.rb") + # end + # + # The +rd+ object passed to the block is an RDocTask object. See the + # attributes list for the RDocTask class for available customization options. + # + # == Specifying different task names + # + # You may wish to give the task a different name, such as if you are + # generating two sets of documentation. For instance, if you want to have a + # development set of documentation including private methods: + # + # Rake::RDocTask.new(:rdoc_dev) do |rd| + # rd.main = "README.doc" + # rd.rdoc_files.include("README.rdoc", "lib/**/*.rb") + # rd.options << "--all" + # end + # + # The tasks would then be named :rdoc_dev, :clobber_rdoc_dev, and + # :rerdoc_dev. + # + # If you wish to have completely different task names, then pass a Hash as + # first argument. With the :rdoc, :clobber_rdoc and + # :rerdoc options, you can customize the task names to your liking. + # For example: + # + # Rake::RDocTask.new(:rdoc => "rdoc", :clobber_rdoc => "rdoc:clean", :rerdoc => "rdoc:force") + # + # This will create the tasks :rdoc, :rdoc_clean and + # :rdoc:force. + # + class RDocTask < TaskLib + # Name of the main, top level task. (default is :rdoc) + attr_accessor :name + + # Name of directory to receive the html output files. (default is "html") + attr_accessor :rdoc_dir + + # Title of RDoc documentation. (defaults to rdoc's default) + attr_accessor :title + + # Name of file to be used as the main, top level file of the + # RDoc. (default is none) + attr_accessor :main + + # Name of template to be used by rdoc. (defaults to rdoc's default) + attr_accessor :template + + # List of files to be included in the rdoc generation. (default is []) + attr_accessor :rdoc_files + + # Additional list of options to be passed rdoc. (default is []) + attr_accessor :options + + # Whether to run the rdoc process as an external shell (default is false) + attr_accessor :external + + attr_accessor :inline_source + + # Create an RDoc task with the given name. See the RDocTask class overview + # for documentation. + def initialize(name = :rdoc) # :yield: self + if name.is_a?(Hash) + invalid_options = name.keys.map { |k| k.to_sym } - [:rdoc, :clobber_rdoc, :rerdoc] + if !invalid_options.empty? + raise ArgumentError, "Invalid option(s) passed to RDocTask.new: #{invalid_options.join(", ")}" + end end + + @name = name + @rdoc_files = Rake::FileList.new + @rdoc_dir = 'html' + @main = nil + @title = nil + @template = nil + @external = false + @inline_source = true + @options = [] + yield self if block_given? + define end - @name = name - @rdoc_files = Rake::FileList.new - @rdoc_dir = 'html' - @main = nil - @title = nil - @template = nil - @external = false - @inline_source = true - @options = [] - yield self if block_given? - define - end + # Create the tasks defined by this task lib. + def define + if rdoc_task_name != "rdoc" + desc "Build the RDOC HTML Files" + else + desc "Build the #{rdoc_task_name} HTML Files" + end + task rdoc_task_name - # Create the tasks defined by this task lib. - def define - if rdoc_task_name != "rdoc" - desc "Build the RDOC HTML Files" - else - desc "Build the #{rdoc_task_name} HTML Files" - end - task rdoc_task_name + desc "Force a rebuild of the RDOC files" + task rerdoc_task_name => [clobber_task_name, rdoc_task_name] - desc "Force a rebuild of the RDOC files" - task rerdoc_task_name => [clobber_task_name, rdoc_task_name] + desc "Remove rdoc products" + task clobber_task_name do + rm_r rdoc_dir rescue nil + end - desc "Remove rdoc products" - task clobber_task_name do - rm_r rdoc_dir rescue nil + task :clobber => [clobber_task_name] + + directory @rdoc_dir + task rdoc_task_name => [rdoc_target] + file rdoc_target => @rdoc_files + [Rake.application.rakefile] do + rm_r @rdoc_dir rescue nil + @before_running_rdoc.call if @before_running_rdoc + args = option_list + @rdoc_files + if @external + argstring = args.join(' ') + sh %{ruby -Ivendor vendor/rd #{argstring}} + else + require 'rdoc/rdoc' + RDoc::RDoc.new.document(args) + end + end + self end - task :clobber => [clobber_task_name] + def option_list + result = @options.dup + result << "-o" << @rdoc_dir + result << "--main" << quote(main) if main + result << "--title" << quote(title) if title + result << "-T" << quote(template) if template + result << "--inline-source" if inline_source && !@options.include?("--inline-source") && !@options.include?("-S") + result + end - directory @rdoc_dir - task rdoc_task_name => [rdoc_target] - file rdoc_target => @rdoc_files + [Rake.application.rakefile] do - rm_r @rdoc_dir rescue nil - @before_running_rdoc.call if @before_running_rdoc - args = option_list + @rdoc_files + def quote(str) if @external - argstring = args.join(' ') - sh %{ruby -Ivendor vendor/rd #{argstring}} + "'#{str}'" else - require 'rdoc/rdoc' - RDoc::RDoc.new.document(args) + str end end - self - end - - def option_list - result = @options.dup - result << "-o" << @rdoc_dir - result << "--main" << quote(main) if main - result << "--title" << quote(title) if title - result << "-T" << quote(template) if template - result << "--inline-source" if inline_source && !@options.include?("--inline-source") && !@options.include?("-S") - result - end - def quote(str) - if @external - "'#{str}'" - else - str + def option_string + option_list.join(' ') end - end - def option_string - option_list.join(' ') - end - - # The block passed to this method will be called just before running the - # RDoc generator. It is allowed to modify RDocTask attributes inside the - # block. - def before_running_rdoc(&block) - @before_running_rdoc = block - end + # The block passed to this method will be called just before running the + # RDoc generator. It is allowed to modify RDocTask attributes inside the + # block. + def before_running_rdoc(&block) + @before_running_rdoc = block + end - private + private - def rdoc_target - "#{rdoc_dir}/index.html" - end + def rdoc_target + "#{rdoc_dir}/index.html" + end - def rdoc_task_name - case name - when Hash - (name[:rdoc] || "rdoc").to_s - else - name.to_s + def rdoc_task_name + case name + when Hash + (name[:rdoc] || "rdoc").to_s + else + name.to_s + end end - end - def clobber_task_name - case name - when Hash - (name[:clobber_rdoc] || "clobber_rdoc").to_s - else - "clobber_#{name}" + def clobber_task_name + case name + when Hash + (name[:clobber_rdoc] || "clobber_rdoc").to_s + else + "clobber_#{name}" + end end - end - def rerdoc_task_name - case name - when Hash - (name[:rerdoc] || "rerdoc").to_s - else - "re#{name}" + def rerdoc_task_name + case name + when Hash + (name[:rerdoc] || "rerdoc").to_s + else + "re#{name}" + end end - end + end end end + diff --git a/test/lib/rdoc_task_test.rb b/test/lib/rdoc_task_test.rb index 4262b793f..9a2d78f91 100644 --- a/test/lib/rdoc_task_test.rb +++ b/test/lib/rdoc_task_test.rb @@ -64,11 +64,6 @@ def test_tasks_creation_with_custom_name_hash_raises_exception_if_invalid_option end end - def test_inline_source_is_enabled_by_default - rd = Rake::RDocTask.new - assert rd.option_list.include?('--inline-source') - end - def test_inline_source_option_is_only_appended_if_option_not_already_given rd = Rake::RDocTask.new rd.options << '--inline-source' From b60e4effec5dc11c0008ed133ae934856b127837 Mon Sep 17 00:00:00 2001 From: Eric Hodel Date: Fri, 7 Jan 2011 17:01:05 -0800 Subject: [PATCH 0147/1389] Recognize 'Windows Server' as a windows system --- CHANGES | 3 +++ lib/rake/alt_system.rb | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 424edaaf0..6867752b0 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ == Pre-Version 0.9.x +* Rake now recognizes "Windows Server" as a windows system. Patch by Matthias + Lüdtke + * Rake::RDocTask is deprecated. Use RDoc::Task from RDoc 2.4.2+ (require 'rdoc/task') diff --git a/lib/rake/alt_system.rb b/lib/rake/alt_system.rb index b7f967a03..05af19863 100644 --- a/lib/rake/alt_system.rb +++ b/lib/rake/alt_system.rb @@ -29,7 +29,8 @@ # for ruby-1.8 and earlier. # module Rake::AltSystem - WINDOWS = RbConfig::CONFIG["host_os"] =~ %r!(msdos|mswin|djgpp|mingw)! + WINDOWS = RbConfig::CONFIG["host_os"] =~ + %r!(msdos|mswin|djgpp|mingw|[Ww]indows)! class << self def define_module_function(name, &block) From 4ec139d37c46656d0906d5fdd07954b779b741ca Mon Sep 17 00:00:00 2001 From: Eric Hodel Date: Fri, 7 Jan 2011 17:03:24 -0800 Subject: [PATCH 0148/1389] Add development dependencies for rake --- Rakefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index ae3c55e56..7d57edeb6 100644 --- a/Rakefile +++ b/Rakefile @@ -198,8 +198,8 @@ else #### Dependencies and requirements. s.required_rubygems_version = '>= 1.3.2' - #s.add_dependency('log4r', '> 1.0.4') - #s.requirements << "" + s.add_development_dependency 'session', '~> 2.4' + s.add_development_dependency 'flexmock', '~> 0.8.11' #### Which files are to be included in this gem? Everything! (Except CVS directories.) From fb30c60e7d2a5ffa9a5e1939b4ac3d47cd38d57e Mon Sep 17 00:00:00 2001 From: Eric Hodel Date: Sat, 8 Jan 2011 14:46:24 -0800 Subject: [PATCH 0149/1389] Update CHANGES --- CHANGES | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES b/CHANGES index bca7fe05f..0c314d9ff 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ == Pre-Version 0.9.x +* Rake now prints the Rakefile directory only when it's different from the + current directory. Patch by Alex Chaffee. + * Improved rakefile_location discovery on Windows. Patch by James Tucker. * Rake now recognizes "Windows Server" as a windows system. Patch by Matthias From 50ca7391052b1d00ec57a4878d36d944d27240cc Mon Sep 17 00:00:00 2001 From: Eric Hodel Date: Sat, 8 Jan 2011 14:50:55 -0800 Subject: [PATCH 0150/1389] Update CHANGES --- CHANGES | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES b/CHANGES index 0c314d9ff..639918bc2 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,8 @@ == Pre-Version 0.9.x +* Fixed "Agregious typos" in documentation. Patch by Sean Scot August Moon + * Rake now prints the Rakefile directory only when it's different from the current directory. Patch by Alex Chaffee. From 7f6f640d23b330448ba076fa4e24a75b98d8cd82 Mon Sep 17 00:00:00 2001 From: quix Date: Mon, 7 Jun 2010 00:40:44 -0400 Subject: [PATCH 0151/1389] When a file depends on another with the same timestamp, run instead of skip --- lib/rake/file_task.rb | 2 +- test/lib/file_task_test.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/rake/file_task.rb b/lib/rake/file_task.rb index 78902a86f..75b20aac8 100644 --- a/lib/rake/file_task.rb +++ b/lib/rake/file_task.rb @@ -29,7 +29,7 @@ def timestamp # Are there any prerequisites with a later time than the given time stamp? def out_of_date?(stamp) - @prerequisites.any? { |n| application[n, @scope].timestamp > stamp} + @prerequisites.any? { |n| application[n, @scope].timestamp >= stamp} end # ---------------------------------------------------------------- diff --git a/test/lib/file_task_test.rb b/test/lib/file_task_test.rb index 1d7032de4..9197c8be0 100644 --- a/test/lib/file_task_test.rb +++ b/test/lib/file_task_test.rb @@ -90,6 +90,23 @@ def ztest_file_deletes_on_failure assert( ! File.exist?(NEWFILE), "NEWFILE should be deleted") end + def test_timestamp_granularity + a, b = %w[a b].map { |n| "testdata/#{n}" } + @runs = [] + + file a => b do + @runs << a + touch a + end + file b do + @runs << b + touch b + end + + touch a + Rake::Task[a].invoke + assert_equal [b, a], @runs + end end ###################################################################### From 24394a118bb3a2f3ec9189c54db34b2318812122 Mon Sep 17 00:00:00 2001 From: Eric Hodel Date: Sat, 8 Jan 2011 15:21:07 -0800 Subject: [PATCH 0152/1389] Update CHANGES --- CHANGES | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES b/CHANGES index 639918bc2..b176161fe 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ == Pre-Version 0.9.x +* Rake now runs tasks when they have equal timestamps. Patch by James M. + Lawrence. + * Fixed "Agregious typos" in documentation. Patch by Sean Scot August Moon * Rake now prints the Rakefile directory only when it's different from the From 9e2bb414b60c2084fdc1e4368c2a85e37e1a1f3d Mon Sep 17 00:00:00 2001 From: Cezary Baginski Date: Mon, 13 Sep 2010 22:39:02 +0200 Subject: [PATCH 0153/1389] Allow require by avoiding load --- lib/rake/rake_test_loader.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/rake/rake_test_loader.rb b/lib/rake/rake_test_loader.rb index 9eda0773b..c943148aa 100644 --- a/lib/rake/rake_test_loader.rb +++ b/lib/rake/rake_test_loader.rb @@ -3,13 +3,12 @@ # Load the test files from the command line. -ARGV.each do |f| +ARGV.each do |f| next if f =~ /^-/ if f =~ /\*/ - FileList[f].to_a.each { |fn| load fn } + FileList[f].to_a.each { |fn| require File.expand_path(fn) } else - load f + require File.expand_path(f) end end - From 4fedcd466b8cb1ef522d538c1d664874761def58 Mon Sep 17 00:00:00 2001 From: Eric Hodel Date: Sat, 8 Jan 2011 15:27:25 -0800 Subject: [PATCH 0154/1389] Update CHANGES --- CHANGES | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES b/CHANGES index b176161fe..4b723e7b4 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ == Pre-Version 0.9.x +* Rake now requires (instead of loads) files in the test task. Patch by Cezary + Baginski. + * Rake now runs tasks when they have equal timestamps. Patch by James M. Lawrence. From 91259b46adc050362281fc70d7fc0d25f06dbbe1 Mon Sep 17 00:00:00 2001 From: Eric Hodel Date: Sat, 8 Jan 2011 18:26:06 -0800 Subject: [PATCH 0155/1389] Use case-insensitive comparison to find Rakefile on Windows. Partial patch by Roger Pack --- CHANGES | 3 +++ lib/rake/application.rb | 13 ++++++++----- test/lib/win32_test.rb | 19 +++++++++++++++++++ 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index 4b723e7b4..14adc6d11 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ == Pre-Version 0.9.x +* Rake now uses case-insensitive comparisons to find the Rakefile on Windows. + Based on patch by Roger Pack. + * Rake now requires (instead of loads) files in the test task. Patch by Cezary Baginski. diff --git a/lib/rake/application.rb b/lib/rake/application.rb index 9452e0b0d..17b7a4287 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -147,7 +147,7 @@ def display_error_message(ex) if options.trace $stderr.puts ex.backtrace.join("\n") else - $stderr.puts ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || "" + $stderr.puts rakefile_location(ex.backtrace) end $stderr.puts "Tasks: #{ex.chain}" if has_chain?(ex) $stderr.puts "(See full trace by running task with --trace)" unless options.trace @@ -573,10 +573,13 @@ def const_warning(const_name) @const_warning = true end - def rakefile_location - bt = caller - bt.map { |t| t[/([^:]+):/,1] } - bt.find {|str| str =~ /^#{@rakefile}$/ } || "" + def rakefile_location backtrace = caller + backtrace.map { |t| t[/([^:]+):/,1] } + + re = /^#{@rakefile}$/ + re = /#{re.source}/i if windows? + + backtrace.find { |str| str =~ re } || '' end end end diff --git a/test/lib/win32_test.rb b/test/lib/win32_test.rb index f68a492f3..40ca30c7d 100644 --- a/test/lib/win32_test.rb +++ b/test/lib/win32_test.rb @@ -9,6 +9,7 @@ class TestWin32 < Test::Unit::TestCase include InEnvironment include TestMethods + include CaptureStdout Win32 = Rake::Win32 @@ -69,4 +70,22 @@ def test_win32_system_dir_nil_of_no_env_vars end end + def test_win32_backtrace_with_different_case + ex = nil + begin + raise 'test exception' + rescue => ex + end + + ex.set_backtrace ['abc', 'rakefile'] + + rake = Rake::Application.new + rake.options.trace = true + rake.instance_variable_set(:@rakefile, 'Rakefile') + + err = capture_stderr { rake.display_error_message(ex) } + + assert_match(/rakefile/, err) + end + end From b6f760248e9802b605a475740c1ea8c455351092 Mon Sep 17 00:00:00 2001 From: Eric Hodel Date: Sat, 8 Jan 2011 18:36:32 -0800 Subject: [PATCH 0156/1389] Convert history to UTF-8 --- CHANGES | 18 +++++++++--------- doc/release_notes/rake-0.8.2.rdoc | 4 ++-- doc/release_notes/rake-0.8.3.rdoc | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CHANGES b/CHANGES index 14adc6d11..5874646f9 100644 --- a/CHANGES +++ b/CHANGES @@ -19,7 +19,7 @@ * Improved rakefile_location discovery on Windows. Patch by James Tucker. * Rake now recognizes "Windows Server" as a windows system. Patch by Matthias - Lüdtke + Lüdtke * Rake::RDocTask is deprecated. Use RDoc::Task from RDoc 2.4.2+ (require 'rdoc/task') @@ -102,7 +102,7 @@ * Fixed stray ARGV option problem that was interfering with Test::Unit::Runner. -* Fixed default verbose mode (was accidently changed to false). +* Fixed default verbose mode (was accidently changed to false). * Removed reference to manage_gem to fix the warning produced by the gem package task. @@ -115,7 +115,7 @@ directory. * Added fix to handle ruby installations in directories with spaces in - their name. + their name. == Version 0.8.2 @@ -132,7 +132,7 @@ symbol/string differences. (Patch supplied by Edwin Pratomo) * Fixed bug with rules involving multiple source (Patch supplied by - Emanuel Indermühle) + Emanuel Indermühle) * Switched from getoptlong to optparse (patches supplied by Edwin Pratomo) @@ -153,7 +153,7 @@ * Changed from using Mutex to Monitor. Evidently Mutex causes thread join errors when Ruby is compiled with -disable-pthreads. (Patch - supplied by Ittay Dror) + supplied by Ittay Dror) * Fixed bug in makefile parser that had problems with extra spaces in file task names. (Patch supplied by Ittay Dror) @@ -208,14 +208,14 @@ * Fixed some bugs where the application object was going to the global appliation instead of using its own data. * Added square and curly bracket patterns to FileList#include (Tilman - Sauerbeck). + Sauerbeck). * Added plain filename support to rule dependents (suggested by Nobu - Nakada). + Nakada). * Added pathmap support to rule dependents. * Added a 'tasks' method to a namespace to get a list of tasks associated with the namespace. * Fixed the method name leak from FileUtils (bug found by Glenn - Vanderburg). + Vanderburg). * Added rake_extension to handle detection of extension collisions. * Added test for noop, bad_option and verbose flags to sh command. * Removed dependency on internal fu_xxx functions from FileUtils. @@ -336,7 +336,7 @@ * Fixed a bug that prevented the TESTOPTS flag from working with the revised for 1.8.2 test task. * Updated the docs on --trace to indicate that it also enables a full - backtrace on errors. + backtrace on errors. == Version 0.4.14 diff --git a/doc/release_notes/rake-0.8.2.rdoc b/doc/release_notes/rake-0.8.2.rdoc index 6119a5984..a822a9497 100644 --- a/doc/release_notes/rake-0.8.2.rdoc +++ b/doc/release_notes/rake-0.8.2.rdoc @@ -46,7 +46,7 @@ new features and numerous bug fixes. * Fixed bug with rules involving multiple source, where only the first dependency of a rule has any effect (Patch supplied by Emanuel - Indermühle) + Indermühle) * FileList#clone and FileList#dup have better sematics w.r.t. taint and freeze. @@ -157,7 +157,7 @@ otherwise helpful comments. Thanks to ... * Gavin Stark * Adam Q. Salter * Adam Majer -* Emanuel Indermühle +* Emanuel Indermühle * Ittay Dror * Bheeshmar Redheendran (for spending an afternoon with me debugging windows issues) diff --git a/doc/release_notes/rake-0.8.3.rdoc b/doc/release_notes/rake-0.8.3.rdoc index 3ee38ccb6..97184c390 100644 --- a/doc/release_notes/rake-0.8.3.rdoc +++ b/doc/release_notes/rake-0.8.3.rdoc @@ -104,7 +104,7 @@ otherwise helpful comments. Thanks to ... * Gavin Stark * Adam Q. Salter * Adam Majer -* Emanuel Indermühle +* Emanuel Indermühle * Ittay Dror * Bheeshmar Redheendran (for spending an afternoon with me debugging windows issues) From 3bff3a1c4359e5376590f8beb65de518a4eca82f Mon Sep 17 00:00:00 2001 From: Eric Hodel Date: Sat, 8 Jan 2011 18:49:47 -0800 Subject: [PATCH 0157/1389] Join the future and use RDoc::Task! --- Rakefile | 49 +++++++++++++++++++++---------------------------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/Rakefile b/Rakefile index 7d57edeb6..3b64afa34 100644 --- a/Rakefile +++ b/Rakefile @@ -135,29 +135,24 @@ end # Create a task to build the RDOC documentation tree. -begin - require 'darkfish-rdoc' - DARKFISH_ENABLED = true -rescue LoadError => ex - DARKFISH_ENABLED = false -end - BASE_RDOC_OPTIONS = [ - '--line-numbers', '--inline-source', - '--main' , 'README.rdoc', + '--line-numbers', '--show-hash', + '--main', 'README.rdoc', '--title', 'Rake -- Ruby Make' ] -rd = Rake::RDocTask.new("rdoc") do |rdoc| - rdoc.rdoc_dir = 'html' - rdoc.template = 'doc/jamis.rb' - rdoc.title = "Rake -- Ruby Make" - rdoc.options = BASE_RDOC_OPTIONS.dup - rdoc.options << '-SHN' << '-f' << 'darkfish' if DARKFISH_ENABLED +if defined?(RDoc::Task) then + RDoc::Task.new do |rdoc| + rdoc.rdoc_dir = 'html' + rdoc.title = "Rake -- Ruby Make" + rdoc.options = BASE_RDOC_OPTIONS.dup - rdoc.rdoc_files.include('README.rdoc', 'MIT-LICENSE', 'TODO', 'CHANGES') - rdoc.rdoc_files.include('lib/**/*.rb', 'doc/**/*.rdoc') - rdoc.rdoc_files.exclude(/\bcontrib\b/) + rdoc.rdoc_files.include('README.rdoc', 'MIT-LICENSE', 'TODO', 'CHANGES') + rdoc.rdoc_files.include('lib/**/*.rb', 'doc/**/*.rdoc') + rdoc.rdoc_files.exclude(/\bcontrib\b/) + end +else + warn "RDoc 2.4.2+ is required to build documentation" end # ==================================================================== @@ -219,8 +214,14 @@ else #### Documentation and testing. - s.has_rdoc = true - s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a + s.extra_rdoc_files = FileList[ + 'README.rdoc', + 'MIT-LICENSE', + 'TODO', + 'CHANGES', + 'doc/**/*.rdoc' + ] + s.rdoc_options = BASE_RDOC_OPTIONS #### Author and project details. @@ -405,14 +406,6 @@ task :tag, :rel, :reuse, :reltest, end end -desc "Install the jamis RDoc template" -task :install_jamis_template do - require 'rbconfig' - dest_dir = File.join(RbConfig::CONFIG['rubylibdir'], "rdoc/generators/template/html") - fail "Unabled to write to #{dest_dir}" unless File.writable?(dest_dir) - install "doc/jamis.rb", dest_dir, :verbose => true -end - # Require experimental XForge/Metaproject support. load 'xforge.rf' if File.exist?('xforge.rf') From 68c7a8c2119ca3146aa2fbd07951d84c29b562a9 Mon Sep 17 00:00:00 2001 From: Eric Hodel Date: Sat, 8 Jan 2011 18:51:06 -0800 Subject: [PATCH 0158/1389] Fix indentation --- Rakefile | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/Rakefile b/Rakefile index 3b64afa34..b3a187682 100644 --- a/Rakefile +++ b/Rakefile @@ -15,7 +15,6 @@ begin gem 'rdoc' require 'rdoc/task' rescue Gem::LoadError - require 'rake/rdoctask' end CLEAN.include('**/*.o', '*.dot', '**/*.rbc') @@ -375,13 +374,13 @@ task :update_version, :rel, :reuse, :reltest, announce "Updating Rake version to #{args.rel}" open("lib/rake.rb") do |rakein| open("lib/rake.rb.new", "w") do |rakeout| - rakein.each do |line| - if line =~ /^RAKEVERSION\s*=\s*/ - rakeout.puts "RAKEVERSION = '#{args.rel}'" - else - rakeout.puts line - end - end + rakein.each do |line| + if line =~ /^RAKEVERSION\s*=\s*/ + rakeout.puts "RAKEVERSION = '#{args.rel}'" + else + rakeout.puts line + end + end end end mv "lib/rake.rb.new", "lib/rake.rb" From 81d0b988b907c8b635e33a28c963b9c373a78ef2 Mon Sep 17 00:00:00 2001 From: Eric Hodel Date: Sat, 8 Jan 2011 19:00:00 -0800 Subject: [PATCH 0159/1389] Update CHANGES --- CHANGES | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES b/CHANGES index 5874646f9..18b1dfce1 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,8 @@ == Pre-Version 0.9.x +* Rake history is now UTF-8 encoded. + * Rake now uses case-insensitive comparisons to find the Rakefile on Windows. Based on patch by Roger Pack. From 53219cadcdf9fb08b344f2a5b19c35237732fdcd Mon Sep 17 00:00:00 2001 From: "R.T. Lechow" Date: Mon, 10 Jan 2011 12:58:58 -0500 Subject: [PATCH 0160/1389] Typos. --- TODO | 2 +- doc/glossary.rdoc | 2 +- doc/rakefile.rdoc | 2 +- doc/rational.rdoc | 6 +++--- lib/rake/ext/string.rb | 4 ++-- lib/rake/task.rb | 2 +- lib/rake/task_arguments.rb | 2 +- rake.blurb | 2 +- test/functional/session_based_tests.rb | 4 ++-- test/lib/filelist_test.rb | 2 +- test/lib/rules_test.rb | 2 +- test/lib/task_arguments_test.rb | 2 +- 12 files changed, 16 insertions(+), 16 deletions(-) diff --git a/TODO b/TODO index bd8a9694f..d0482e22c 100644 --- a/TODO +++ b/TODO @@ -6,7 +6,7 @@ the rake-devel@rubyforge.org mailing list. === To Do * Need a nice API for accessing tasks in namespaces, namespaces in an app, etc. * Provide a way to disable -w warning mode. -* Define a set of default rules that work in the absense of any Rakefile +* Define a set of default rules that work in the absence of any Rakefile * What about cyclic dependencies? * Java support utilities * Installation support utilities diff --git a/doc/glossary.rdoc b/doc/glossary.rdoc index 0ca186930..6726f0a91 100644 --- a/doc/glossary.rdoc +++ b/doc/glossary.rdoc @@ -37,7 +37,7 @@ not needed. This may change in the future. [prerequisites] - Every task has a set (possiblity empty) of prerequisites. A + Every task has a set (possibility empty) of prerequisites. A prerequisite P to Task T is itself a task that must be invoked before Task T. diff --git a/doc/rakefile.rdoc b/doc/rakefile.rdoc index 4fdf3adeb..9668a83c3 100644 --- a/doc/rakefile.rdoc +++ b/doc/rakefile.rdoc @@ -27,7 +27,7 @@ parameter that is the name of the task. === Tasks with Prerequisites -Any prerequisites are given as a list (inclosed in square brackets) +Any prerequisites are given as a list (enclosed in square brackets) following the name and an arrow (=>). task :name => [:prereq1, :prereq2] diff --git a/doc/rational.rdoc b/doc/rational.rdoc index f741e65bf..0abac22ed 100644 --- a/doc/rational.rdoc +++ b/doc/rational.rdoc @@ -44,7 +44,7 @@ prototype of Ruby make, complete with dependencies and actions. I showed the code to my coworker and we had a good laugh. It was just about a page worth of code that reproduced an amazing amount of the -functionality of make. We were both truely stunned with the power of +functionality of make. We were both truly stunned with the power of Ruby. But it didn't do everything make did. In particular, it didn't have @@ -53,7 +53,7 @@ prerequisite files have a later timestamp). Obviously THAT would be a pain to add and so Ruby Make would remain an interesting experiment. ... Except as I walked back to my desk, I started thinking about what -file based dependecies would really need. Rats! I was hooked again, +file based dependencies would really need. Rats! I was hooked again, and by adding a new class and two new methods, file/timestamp dependencies were implemented. @@ -133,7 +133,7 @@ created for rake. That's it. There's no documentation (other than whats in this message). Does this sound interesting to anyone? If so, I'll continue to clean it up and write it up and publish it on RAA. Otherwise, I'll -leave it as an interesting excerise and a tribute to the power of Ruby. +leave it as an interesting exercise and a tribute to the power of Ruby. Why /might/ rake be interesting to Ruby programmers. I don't know, perhaps ... diff --git a/lib/rake/ext/string.rb b/lib/rake/ext/string.rb index d3be84f58..45ef8375d 100644 --- a/lib/rake/ext/string.rb +++ b/lib/rake/ext/string.rb @@ -91,11 +91,11 @@ def pathmap_replace(patterns, &block) # 'a/b/c/d/file.txt'.pathmap("%-2d") => 'c/d' # # Also the %d, %p, %f, %n, %x, and %X operators can take a - # pattern/replacement argument to perform simple string substititions on a + # pattern/replacement argument to perform simple string substitutions on a # particular part of the path. The pattern and replacement are separated # by a comma and are enclosed by curly braces. The replacement spec comes # after the % character but before the operator letter. (e.g. - # "%{old,new}d"). Muliple replacement specs should be separated by + # "%{old,new}d"). Multiple replacement specs should be separated by # semi-colons (e.g. "%{old,new;src,bin}d"). # # Regular expressions may be used for the pattern, and back refs may be diff --git a/lib/rake/task.rb b/lib/rake/task.rb index c2e11d46c..f977d1871 100644 --- a/lib/rake/task.rb +++ b/lib/rake/task.rb @@ -138,7 +138,7 @@ def clear_actions self end - # Invoke the task if it is needed. Prerequites are invoked first. + # Invoke the task if it is needed. Prerequisites are invoked first. def invoke(*args) task_args = TaskArguments.new(arg_names, args) invoke_with_call_chain(task_args, InvocationChain::EMPTY) diff --git a/lib/rake/task_arguments.rb b/lib/rake/task_arguments.rb index f22c87e19..ab404d67f 100644 --- a/lib/rake/task_arguments.rb +++ b/lib/rake/task_arguments.rb @@ -1,7 +1,7 @@ module Rake #################################################################### - # TaskAguments manage the arguments passed to a task. + # TaskArguments manage the arguments passed to a task. # class TaskArguments include Enumerable diff --git a/rake.blurb b/rake.blurb index bf23a7b89..f1b70d807 100644 --- a/rake.blurb +++ b/rake.blurb @@ -12,7 +12,7 @@ description: > defined in standard Ruby syntax. No XML files to edit. No quirky Makefile syntax to worry about (is that a tab or a space?)
  • Users can specify tasks with prerequisites.
  • -
  • Rake supports rule patterns to sythesize implicit tasks.
  • +
  • Rake supports rule patterns to synthesize implicit tasks.
  • Rake is lightweight. It can be distributed with other projects as a single file. Projects that depend upon rake do not require that rake be installed on target systems.
  • diff --git a/test/functional/session_based_tests.rb b/test/functional/session_based_tests.rb index 521aedea7..902712c89 100644 --- a/test/functional/session_based_tests.rb +++ b/test/functional/session_based_tests.rb @@ -56,13 +56,13 @@ def test_rake_error_on_bad_task assert_status(1) end - def test_env_availabe_at_top_scope + def test_env_available_at_top_scope Dir.chdir("test/data/default") do rake "TESTTOPSCOPE=1" end assert_match(/^TOPSCOPE$/, @out) assert_status end - def test_env_availabe_at_task_scope + def test_env_available_at_task_scope Dir.chdir("test/data/default") do rake "TESTTASKSCOPE=1 task_scope" end assert_match(/^TASKSCOPE$/, @out) assert_status diff --git a/test/lib/filelist_test.rb b/test/lib/filelist_test.rb index a50ee2b85..15d32a28f 100644 --- a/test/lib/filelist_test.rb +++ b/test/lib/filelist_test.rb @@ -20,7 +20,7 @@ def teardown FileUtils.rm_rf("testdata") end - def test_delgating_methods_do_not_include_to_a_or_to_ary + def test_delegating_methods_do_not_include_to_a_or_to_ary assert ! FileList::DELEGATING_METHODS.include?("to_a"), "should not include to_a" assert ! FileList::DELEGATING_METHODS.include?(:to_a), "should not include to_a" assert ! FileList::DELEGATING_METHODS.include?("to_ary"), "should not include to_ary" diff --git a/test/lib/rules_test.rb b/test/lib/rules_test.rb index 4f7147010..88ad1eafd 100644 --- a/test/lib/rules_test.rb +++ b/test/lib/rules_test.rb @@ -97,7 +97,7 @@ def test_plain_strings_as_dependents_refer_to_files assert_equal [OBJFILE], @runs end - def test_file_names_beginning_with_dot_can_be_tricked_into_refering_to_file + def test_file_names_beginning_with_dot_can_be_tricked_into_referring_to_file verbose(false) do chdir("testdata") do create_file('.foo') diff --git a/test/lib/task_arguments_test.rb b/test/lib/task_arguments_test.rb index 48d4f1747..e2d5c4288 100644 --- a/test/lib/task_arguments_test.rb +++ b/test/lib/task_arguments_test.rb @@ -81,7 +81,7 @@ def test_default_arguments_values_can_be_merged assert_equal 'original_val', ta[:bb] end - def test_default_arguements_that_dont_match_names_are_ignored + def test_default_arguments_that_dont_match_names_are_ignored ta = Rake::TaskArguments.new(["aa", "bb"], [nil, "original_val"]) ta.with_defaults({ "cc" => "default_val" }) assert_nil ta[:cc] From 16ec2628c31b70a8e209b5f6119ef468dd4dfbf5 Mon Sep 17 00:00:00 2001 From: Eric Hodel Date: Mon, 10 Jan 2011 19:12:06 -0800 Subject: [PATCH 0161/1389] Update CHANGES with further typo patches --- CHANGES | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 18b1dfce1..7210fe586 100644 --- a/CHANGES +++ b/CHANGES @@ -13,7 +13,7 @@ * Rake now runs tasks when they have equal timestamps. Patch by James M. Lawrence. -* Fixed "Agregious typos" in documentation. Patch by Sean Scot August Moon +* Fixed typos. Patches by Sean Scot August Moon and R.T. Lechow. * Rake now prints the Rakefile directory only when it's different from the current directory. Patch by Alex Chaffee. From af62240122cac37ade5d3d67445e077e78489355 Mon Sep 17 00:00:00 2001 From: "R.T. Lechow" Date: Wed, 12 Jan 2011 23:33:55 -0500 Subject: [PATCH 0162/1389] Clean up trailing whitespace. --- doc/command_line_usage.rdoc | 2 +- doc/glossary.rdoc | 2 +- doc/jamis.rb | 4 +-- doc/proto_rake.rdoc | 44 ++++++++++++------------- doc/rake.1.gz | Bin 1369 -> 1370 bytes doc/rational.rdoc | 6 ++-- doc/release_notes/rake-0.4.15.rdoc | 2 +- doc/release_notes/rake-0.5.0.rdoc | 2 +- lib/rake/contrib/compositepublisher.rb | 4 +-- lib/rake/contrib/ftptools.rb | 2 +- lib/rake/contrib/rubyforgepublisher.rb | 4 +-- lib/rake/default_loader.rb | 2 +- lib/rake/loaders/makefile.rb | 2 +- lib/rake/packagetask.rb | 18 +++++----- lib/rake/win32.rb | 8 ++--- rake.gemspec | 38 ++++++++++----------- rakelib/publish.rake | 4 +-- test/data/comments/Rakefile | 2 +- test/data/default/Rakefile | 2 +- test/data/dryrun/Rakefile | 2 +- test/data/file_creation_task/Rakefile | 2 +- test/in_environment.rb | 4 +-- test/lib/dsl_test.rb | 2 +- test/lib/extension_test.rb | 4 +-- test/lib/fileutils_test.rb | 10 +++--- test/lib/task_test.rb | 10 +++--- 26 files changed, 91 insertions(+), 91 deletions(-) diff --git a/doc/command_line_usage.rdoc b/doc/command_line_usage.rdoc index c60e53f51..bc75d5fec 100644 --- a/doc/command_line_usage.rdoc +++ b/doc/command_line_usage.rdoc @@ -9,7 +9,7 @@ Options are: [name=value] Set the environment variable name to value during the execution of the rake command. You can access - the value by using ENV['name']. + the value by using ENV['name']. [--classic-namespace (-n)] Import the Task, FileTask, and FileCreateTask into the top-level diff --git a/doc/glossary.rdoc b/doc/glossary.rdoc index 6726f0a91..ef508b00f 100644 --- a/doc/glossary.rdoc +++ b/doc/glossary.rdoc @@ -39,7 +39,7 @@ [prerequisites] Every task has a set (possibility empty) of prerequisites. A prerequisite P to Task T is itself a task that must be invoked - before Task T. + before Task T. [rule] A rule is a recipe for synthesizing a task when no task is diff --git a/doc/jamis.rb b/doc/jamis.rb index c7439d88e..c7bc84ac5 100644 --- a/doc/jamis.rb +++ b/doc/jamis.rb @@ -183,7 +183,7 @@ module Page CSS XHTML_PREAMBLE = %{ - } @@ -510,7 +510,7 @@ module Page