[前][次][番号順一覧][スレッド一覧]

ruby-changes:25946

From: drbrain <ko1@a...>
Date: Fri, 30 Nov 2012 04:17:12 +0900 (JST)
Subject: [ruby-changes:25946] drbrain:r38003 (trunk): * lib/rake/*: Updated to rake 0.9.5

drbrain	2012-11-30 04:16:46 +0900 (Fri, 30 Nov 2012)

  New Revision: 38003

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38003

  Log:
    * lib/rake/*:  Updated to rake 0.9.5
    * test/rake/*:  ditto.
    * NEWS:  ditto.

  Added files:
    trunk/lib/rake/trace_output.rb
    trunk/test/rake/test_trace_output.rb
  Modified files:
    trunk/ChangeLog
    trunk/NEWS
    trunk/lib/rake/application.rb
    trunk/lib/rake/file_list.rb
    trunk/lib/rake/task.rb
    trunk/lib/rake/version.rb
    trunk/lib/rake.rb
    trunk/test/rake/helper.rb
    trunk/test/rake/test_rake_application.rb
    trunk/test/rake/test_rake_application_options.rb
    trunk/test/rake/test_rake_backtrace.rb
    trunk/test/rake/test_rake_file_task.rb
    trunk/test/rake/test_rake_functional.rb
    trunk/test/rake/test_rake_rake_test_loader.rb
    trunk/test/rake/test_rake_reduce_compat.rb
    trunk/test/rake/test_rake_task_with_arguments.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38002)
+++ ChangeLog	(revision 38003)
@@ -1,3 +1,9 @@
+Fri Nov 30 04:16:29 2012  Eric Hodel  <drbrain@s...>
+
+	* lib/rake/*:  Updated to rake 0.9.5
+	* test/rake/*:  ditto.
+	* NEWS:  ditto.
+
 Fri Nov 30 02:53:47 2012  Aaron Patterson <aaron@t...>
 
 	* vm.c: add a return hook when a method raises an exception.
Index: lib/rake/trace_output.rb
===================================================================
--- lib/rake/trace_output.rb	(revision 0)
+++ lib/rake/trace_output.rb	(revision 38003)
@@ -0,0 +1,19 @@
+module Rake
+  module TraceOutput
+
+    # Write trace output to output stream +out+.
+    #
+    # The write is done as a single IO call (to print) to lessen the
+    # chance that the trace output is interrupted by other tasks also
+    # producing output.
+    def trace_on(out, *strings)
+      sep = $\ || "\n"
+      if strings.empty?
+        output = sep
+      else
+        output = strings.map { |s| s.end_with?(sep) ? s : s + sep }.join
+      end
+      out.print(output)
+    end
+  end
+end

Property changes on: lib/rake/trace_output.rb
___________________________________________________________________
Added: svn:eol-style
   + LF

Index: lib/rake/application.rb
===================================================================
--- lib/rake/application.rb	(revision 38002)
+++ lib/rake/application.rb	(revision 38003)
@@ -5,6 +5,7 @@
 require 'rake/file_list'
 require 'rake/thread_pool'
 require 'rake/thread_history_display'
+require 'rake/trace_output'
 require 'rake/win32'
 
 module Rake
@@ -17,6 +18,7 @@
   #
   class Application
     include TaskManager
+    include TraceOutput
 
     # The name of the application (typically 'rake')
     attr_reader :name
@@ -176,7 +178,7 @@
       if options.backtrace
         trace ex.backtrace.join("\n")
       else
-        trace Backtrace.collapse(ex.backtrace)
+        trace Backtrace.collapse(ex.backtrace).join("\n")
       end
       trace "Tasks: #{ex.chain}" if has_chain?(ex)
       trace "(See full trace by running task with --trace)" unless options.backtrace
@@ -314,9 +316,9 @@
       end
     end
 
-    def trace(*str)
+    def trace(*strings)
       options.trace_output ||= $stderr
-      options.trace_output.puts(*str)
+      trace_on(options.trace_output, *strings)
     end
 
     def sort_options(options)
@@ -336,7 +338,7 @@
               options.show_all_tasks = value
             }
           ],
-          ['--backtrace [OUT]', "Enable full backtrace.  OUT can be stderr (default) or stdout.",
+          ['--backtrace=[OUT]', "Enable full backtrace.  OUT can be stderr (default) or stdout.",
             lambda { |value|
               options.backtrace = true
               select_trace_output(options, 'backtrace', value)
@@ -467,7 +469,7 @@
               select_tasks_to_show(options, :tasks, value)
             }
           ],
-          ['--trace', '-t [OUT]', "Turn on invoke/execute tracing, enable full backtrace. OUT can be stderr (default) or stdout.",
+          ['--trace=[OUT]', '-t', "Turn on invoke/execute tracing, enable full backtrace. OUT can be stderr (default) or stdout.",
             lambda { |value|
               options.trace = true
               options.backtrace = true
Index: lib/rake/version.rb
===================================================================
--- lib/rake/version.rb	(revision 38002)
+++ lib/rake/version.rb	(revision 38003)
@@ -1,10 +1,13 @@
 module Rake
+  VERSION = '0.9.5'
+
   module Version # :nodoc: all
+    MAJOR, MINOR, BUILD, = Rake::VERSION.split '.'
+
     NUMBERS = [
-      MAJOR = 0,
-      MINOR = 9,
-      BUILD = 4,
+      MAJOR,
+      MINOR,
+      BUILD,
     ]
   end
-  VERSION = "0.9.4"
 end
Index: lib/rake/task.rb
===================================================================
--- lib/rake/task.rb	(revision 38002)
+++ lib/rake/task.rb	(revision 38003)
@@ -105,7 +105,7 @@
 
     # Argument description (nil if none).
     def arg_description # :nodoc:
-      @arg_names ? "[#{(arg_names || []).join(',')}]" : nil
+      @arg_names ? "[#{arg_names.join(',')}]" : nil
     end
 
     # Name of arguments for this task.
@@ -182,18 +182,19 @@
       if application.options.always_multitask
         invoke_prerequisites_concurrently(task_args, invocation_chain)
       else
-        prerequisite_tasks.each { |prereq|
-          prereq_args = task_args.new_scope(prereq.arg_names)
-          prereq.invoke_with_call_chain(prereq_args, invocation_chain)
+        prerequisite_tasks.each { |p|
+          prereq_args = task_args.new_scope(p.arg_names)
+          p.invoke_with_call_chain(prereq_args, invocation_chain)
         }
       end
     end
 
     # Invoke all the prerequisites of a task in parallel.
-    def invoke_prerequisites_concurrently(args, invocation_chain) # :nodoc:
-      futures = @prerequisites.collect do |p|
+    def invoke_prerequisites_concurrently(task_args, invocation_chain) # :nodoc:
+      futures = prerequisite_tasks.collect do |p|
+        prereq_args = task_args.new_scope(p.arg_names)
         application.thread_pool.future(p) do |r|
-          application[r, @scope].invoke_with_call_chain(args, invocation_chain)
+          r.invoke_with_call_chain(prereq_args, invocation_chain)
         end
       end
       futures.each { |f| f.value }
Index: lib/rake/file_list.rb
===================================================================
--- lib/rake/file_list.rb	(revision 38002)
+++ lib/rake/file_list.rb	(revision 38003)
@@ -385,7 +385,7 @@
       end
 
       # Get a sorted list of files matching the pattern. This method
-      # should be prefered to Dir[pattern] and Dir.glob[pattern] because
+      # should be prefered to Dir[pattern] and Dir.glob(pattern) because
       # the files returned are guaranteed to be sorted.
       def glob(pattern, *args)
         Dir.glob(pattern, *args).sort
Index: lib/rake.rb
===================================================================
--- lib/rake.rb	(revision 38002)
+++ lib/rake.rb	(revision 38003)
@@ -43,6 +43,7 @@
 require 'rake/task_argument_error'
 require 'rake/rule_recursion_overflow_error'
 require 'rake/rake_module'
+require 'rake/trace_output'
 require 'rake/pseudo_status'
 require 'rake/task_arguments'
 require 'rake/invocation_chain'
Index: NEWS
===================================================================
--- NEWS	(revision 38002)
+++ NEWS	(revision 38003)
@@ -269,14 +269,14 @@
     * Pathname#find returns an enumerator if no block is given.
 
 * rake
-  * rake has been updated to version 0.9.4.
+  * rake has been updated to version 0.9.5.
 
     This version is backwards-compatible with previous rake versions and
     contains many bug fixes.
 
     See
-    http://rake.rubyforge.org/doc/release_notes/rake-0_9_4_rdoc.html for a list
-    of changes in rake 0.9.3 and 0.9.4.
+    http://rake.rubyforge.org/doc/release_notes/rake-0_9_5_rdoc.html for a list
+    of changes in rake 0.9.3, 0.9.4 and 0.9.5.
 
 * rdoc
   * rdoc has been updated to version 4.0
Index: test/rake/test_rake_application_options.rb
===================================================================
--- test/rake/test_rake_application_options.rb	(revision 38002)
+++ test/rake/test_rake_application_options.rb	(revision 38003)
@@ -228,7 +228,7 @@
   end
 
   def test_trace_with_stdout
-    flags('--trace=stdout', '-tstdout', '-t stdout') do |opts|
+    flags('--trace=stdout', '-tstdout') do |opts|
       assert opts.trace, "should enable trace option"
       assert opts.backtrace, "should enabled backtrace option"
       assert_equal $stdout, opts.trace_output
@@ -238,7 +238,7 @@
   end
 
   def test_trace_with_stderr
-    flags('--trace=stderr', '-tstderr', '-t stderr') do |opts|
+    flags('--trace=stderr', '-tstderr') do |opts|
       assert opts.trace, "should enable trace option"
       assert opts.backtrace, "should enabled backtrace option"
       assert_equal $stderr, opts.trace_output
@@ -254,13 +254,21 @@
     assert_match(/un(known|recognized).*\btrace\b.*xyzzy/i, ex.message)
   end
 
+  def test_trace_with_following_task_name
+    flags(['--trace', 'taskname'], ['-t', 'taskname']) do |opts|
+      assert opts.trace, "should enable trace option"
+      assert opts.backtrace, "should enabled backtrace option"
+      assert_equal $stderr, opts.trace_output
+      assert Rake::FileUtilsExt.verbose_flag
+      assert_equal ['taskname'], @app.top_level_tasks
+    end
+  end
 
   def test_backtrace
     flags('--backtrace') do |opts|
       assert opts.backtrace, "should enable backtrace option"
       assert_equal $stderr, opts.trace_output
       assert ! opts.trace, "should not enable trace option"
-      assert ! Rake::FileUtilsExt.verbose_flag
     end
   end
 
@@ -269,7 +277,6 @@
       assert opts.backtrace, "should enable backtrace option"
       assert_equal $stdout, opts.trace_output
       assert ! opts.trace, "should not enable trace option"
-      assert ! Rake::FileUtilsExt.verbose_flag
     end
   end
 
@@ -278,7 +285,6 @@
       assert opts.backtrace, "should enable backtrace option"
       assert_equal $stderr, opts.trace_output
       assert ! opts.trace, "should not enable trace option"
-      assert ! Rake::FileUtilsExt.verbose_flag
     end
   end
 
@@ -289,6 +295,15 @@
     assert_match(/un(known|recognized).*\bbacktrace\b.*xyzzy/i, ex.message)
   end
 
+  def test_backtrace_with_following_task_name
+    flags(['--backtrace', 'taskname']) do |opts|
+      assert ! opts.trace, "should enable trace option"
+      assert opts.backtrace, "should enabled backtrace option"
+      assert_equal $stderr, opts.trace_output
+      assert_equal ['taskname'], @app.top_level_tasks
+    end
+  end
+
   def test_trace_rules
     flags('--rules') do |opts|
       assert opts.trace_rules
Index: test/rake/test_rake_task_with_arguments.rb
===================================================================
--- test/rake/test_rake_task_with_arguments.rb	(revision 38002)
+++ test/rake/test_rake_task_with_arguments.rb	(revision 38003)
@@ -142,7 +142,7 @@
     assert_equal "1.2", value
   end
 
-  def test_args_not_passed_if_no_prereq_names
+  def test_args_not_passed_if_no_prereq_names_on_task
     pre = task(:pre) { |t, args|
       assert_equal({}, args.to_hash)
       assert_equal "bill", args.name
@@ -151,6 +151,15 @@
     t.invoke("bill", "1.2")
   end
 
+  def test_args_not_passed_if_no_prereq_names_on_multitask
+    pre = task(:pre) { |t, args|
+      assert_equal({}, args.to_hash)
+      assert_equal "bill", args.name
+    }
+    t = multitask(:t, [:name, :rev] => [:pre])
+    t.invoke("bill", "1.2")
+  end
+
   def test_args_not_passed_if_no_arg_names
     pre = task(:pre, :rev) { |t, args|
       assert_equal({}, args.to_hash)
@@ -170,4 +179,3 @@
     # HACK no assertions
   end
 end
-
Index: test/rake/test_rake_functional.rb
===================================================================
--- test/rake/test_rake_functional.rb	(revision 38002)
+++ test/rake/test_rake_functional.rb	(revision 38003)
@@ -5,9 +5,9 @@
 class TestRakeFunctional < Rake::TestCase
 
   def setup
-    @rake_path = File.expand_path("../../../bin/rake", __FILE__)
-    lib_path = File.expand_path("../../../lib", __FILE__)
-    @ruby_options = ["-I#{lib_path}", "-I."]
+    super
+
+    @ruby_options = ["-I#{@rake_lib}", "-I."]
     @verbose = ENV['VERBOSE']
 
     if @verbose
@@ -17,8 +17,6 @@
       puts @__name__
       puts '-' * 80
     end
-
-    super
   end
 
   def test_rake_default
@@ -466,7 +464,7 @@
   # command line ruby options are included.  Output is captured in
   # @out and @err
   def rake(*rake_options)
-    run_ruby @ruby_options + [@rake_path] + rake_options
+    run_ruby @ruby_options + [@rake_exec] + rake_options
   end
 
   # Low level ruby command runner ...
Index: test/rake/test_rake_reduce_compat.rb
===================================================================
--- test/rake/test_rake_reduce_compat.rb	(revision 38002)
+++ test/rake/test_rake_reduce_compat.rb	(revision 38003)
@@ -4,9 +4,9 @@
 class TestRakeReduceCompat < Rake::TestCase
   # TODO: factor out similar code in test_rake_functional.rb
   def rake(*args)
-    lib =  File.expand_path('../../../lib', __FILE__)
-    bin_rake =  File.expand_path('../../../bin/rake', __FILE__)
-    Open3.popen3(RUBY, "-I", lib, bin_rake, *args) { |_, out, _, _| out.read }
+    Open3.popen3(RUBY, "-I", @rake_lib, @rake_exec, *args) { |_, out, _, _|
+      out.read
+    }
   end
 
   def invoke_normal(task_name)
Index: test/rake/test_trace_output.rb
===================================================================
--- test/rake/test_trace_output.rb	(revision 0)
+++ test/rake/test_trace_output.rb	(revision 38003)
@@ -0,0 +1,43 @@
+require File.expand_path('../helper', __FILE__)
+require 'stringio'
+
+class TestTraceOutput < Rake::TestCase
+  include Rake::TraceOutput
+
+  class PrintSpy
+    attr_reader :result, :calls
+    def initialize
+      @result = ""
+      @calls = 0
+    end
+    def print(string)
+      @result << string
+      @calls += 1
+    end
+  end
+
+  def test_trace_issues_single_io_for_args_with_empty_args
+    spy = PrintSpy.new
+    trace_on(spy)
+    assert_equal "\n", spy.result
+    assert_equal 1, spy.calls
+  end
+
+  def test_trace_issues_single_io_for_args_multiple_strings
+    spy = PrintSpy.new
+    trace_on(spy, "HI\n", "LO")
+    assert_equal "HI\nLO\n", spy.result
+    assert_equal 1, spy.calls
+  end
+
+  def test_trace_issues_single_io_for_args_multiple_strings_and_alternate_sep
+    old_sep = $\
+    $\ = "\r"
+    spy = PrintSpy.new
+    trace_on(spy, "HI\r", "LO")
+    assert_equal "HI\rLO\r", spy.result
+    assert_equal 1, spy.calls
+  ensure
+    $\ = old_sep
+  end
+end

Property changes on: test/rake/test_trace_output.rb
___________________________________________________________________
Added: svn:eol-style
   + LF

Index: test/rake/helper.rb
===================================================================
--- test/rake/helper.rb	(revision 38002)
+++ test/rake/helper.rb	(revision 38003)
@@ -31,6 +31,19 @@
   def setup
     ARGV.clear
 
+    test_dir = File.basename File.dirname File.expand_path __FILE__
+
+    @rake_root = if test_dir == 'test' then
+                   # rake repository
+                   File.expand_path '../../', __FILE__
+                 else
+                   # ruby repository
+                   File.expand_path '../../../', __FILE__
+                 end
+
+    @rake_exec = File.join @rake_root, 'bin', 'rake'
+    @rake_lib  = File.join @rake_root, 'lib'
+
     @orig_PWD = Dir.pwd
     @orig_APPDATA      = ENV['APPDATA']
     @orig_HOME         = ENV['HOME']
Index: test/rake/test_rake_backtrace.rb
===================================================================
--- test/rake/test_rake_backtrace.rb	(revision 38002)
+++ test/rake/test_rake_backtrace.rb	(revision 38003)
@@ -4,9 +4,9 @@
 class TestRakeBacktrace < Rake::TestCase
   # TODO: factor out similar code in test_rake_functional.rb
   def rake(*args)
-    lib = File.expand_path('../../../lib', __FILE__)
-    bin_rake = File.expand_path('../../../bin/rake', __FILE__)
-    Open3.popen3(RUBY, "-I", lib, bin_rake, *args) { |_, _, err, _| err.read }
+    Open3.popen3(RUBY, "-I", @rake_lib, @rake_exec, *args) { |_, _, err, _|
+      err.read
+    }
   end
 
   def invoke(task_name)
Index: test/rake/test_rake_file_task.rb
===================================================================
--- test/rake/test_rake_file_task.rb	(revision 38002)
+++ test/rake/test_rake_file_task.rb	(revision 38003)
@@ -116,7 +116,7 @@
   end
 
   def load_phony
-    load File.expand_path('../../../lib/rake/phony.rb', __FILE__)
+    load File.join(@rake_lib, "rake/phony.rb")
   end
 
 end
Index: test/rake/test_rake_application.rb
===================================================================
--- test/rake/test_rake_application.rb	(revision 38002)
+++ test/rake/test_rake_application.rb	(revision 38003)
@@ -309,6 +309,37 @@
     assert @app.options.trace
   end
 
+  def test_handle_options_trace_default_is_stderr
+    ARGV.clear
+    ARGV << "--trace"
+
+    @app.handle_options
+
+    assert_equal STDERR, @app.options.trace_output
+    assert @app.options.trace
+  end
+
+  def test_handle_options_trace_overrides_to_stdout
+    ARGV.clear
+    ARGV << "--trace=stdout"
+
+    @app.handle_options
+
+    assert_equal STDOUT, @app.options.trace_output
+    assert @app.options.trace
+  end
+
+  def test_handle_options_trace_does_not_eat_following_task_names
+    assert !@app.options.trace
+
+    ARGV.clear
+    ARGV << "--trace" << "sometask"
+
+    @app.handle_options
+    assert ARGV.include?("sometask")
+    assert @app.options.trace
+  end
+
   def test_good_run
     ran = false
 
Index: test/rake/test_rake_rake_test_loader.rb
===================================================================
--- test/rake/test_rake_rake_test_loader.rb	(revision 38002)
+++ test/rake/test_rake_rake_test_loader.rb	(revision 38003)
@@ -10,7 +10,7 @@
 
     ARGV.replace %w[foo.rb test_*.rb -v]
 
-    load File.expand_path('../../../lib/rake/rake_test_loader.rb', __FILE__)
+    load File.join(@rake_lib, 'rake/rake_test_loader.rb')
 
     assert_equal %w[-v], ARGV
   ensure

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]