1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/rake: Update to rake 10.4.0

* test/rake:  ditto.
* NEWS:  ditto.

* test/lib/minitest/unit.rb:  Add compatibility shim for minitest 5.
  This only provides minitest 5 unit test naming compatibility.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48560 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
drbrain 2014-11-25 07:03:36 +00:00
parent f20f84d60a
commit 3908d5d330
18 changed files with 90 additions and 35 deletions

View file

@ -1,3 +1,12 @@
Tue Nov 25 15:59:46 2014 Eric Hodel <drbrain@segment7.net>
* lib/rake: Update to rake 10.4.0
* test/rake: ditto.
* NEWS: ditto.
* test/lib/minitest/unit.rb: Add compatibility shim for minitest 5.
This only provides minitest 5 unit test naming compatibility.
Tue Nov 25 15:26:33 2014 Nobuyoshi Nakada <nobu@ruby-lang.org> Tue Nov 25 15:26:33 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* tool/vcs.rb (get_revisions): use Time.new instead of Time.mktime * tool/vcs.rb (get_revisions): use Time.new instead of Time.mktime

5
NEWS
View file

@ -180,6 +180,11 @@ with all sufficient information, see the ChangeLog file.
* New methods: * New methods:
* Pathname#birthtime * Pathname#birthtime
* Rake
* Updated to Rake 10.4.0. For full release notes see:
http://docs.seattlerb.org/rake/History_rdoc.html#label-10.4.0
* RubyGems * RubyGems
* Updated to RubyGems 2.4.2. For full release notes see: * Updated to RubyGems 2.4.2. For full release notes see:

View file

@ -21,7 +21,7 @@
#++ #++
module Rake module Rake
VERSION = '10.3.2' VERSION = '10.4.0'
end end
require 'rake/version' require 'rake/version'
@ -63,6 +63,7 @@ require 'rake/file_utils_ext'
require 'rake/file_list' require 'rake/file_list'
require 'rake/default_loader' require 'rake/default_loader'
require 'rake/early_time' require 'rake/early_time'
require 'rake/late_time'
require 'rake/name_space' require 'rake/name_space'
require 'rake/task_manager' require 'rake/task_manager'
require 'rake/application' require 'rake/application'

View file

@ -20,6 +20,9 @@ module Rake
include TaskManager include TaskManager
include TraceOutput include TraceOutput
# The command-line arguments rake is using (defaults to ARGV)
attr_reader :argv # :nodoc:
# The name of the application (typically 'rake') # The name of the application (typically 'rake')
attr_reader :name attr_reader :name
@ -45,6 +48,7 @@ module Rake
# Initialize a Rake::Application object. # Initialize a Rake::Application object.
def initialize def initialize
super super
@argv = ARGV.dup
@name = 'rake' @name = 'rake'
@rakefiles = DEFAULT_RAKEFILES.dup @rakefiles = DEFAULT_RAKEFILES.dup
@rakefile = nil @rakefile = nil
@ -73,6 +77,8 @@ module Rake
# call +top_level+ to run your top level tasks. # call +top_level+ to run your top level tasks.
def run def run
standard_exception_handling do standard_exception_handling do
@argv = argv
init init
load_rakefile load_rakefile
top_level top_level
@ -633,7 +639,7 @@ module Rake
standard_rake_options.each { |args| opts.on(*args) } standard_rake_options.each { |args| opts.on(*args) }
opts.environment('RAKEOPT') opts.environment('RAKEOPT')
end.parse! end.parse! @argv
end end
# Similar to the regular Ruby +require+ command, but will check # Similar to the regular Ruby +require+ command, but will check
@ -729,7 +735,7 @@ module Rake
# Environmental assignments are processed at this time as well. # Environmental assignments are processed at this time as well.
def collect_command_line_tasks # :nodoc: def collect_command_line_tasks # :nodoc:
@top_level_tasks = [] @top_level_tasks = []
ARGV.each do |arg| @argv.each do |arg|
if arg =~ /^(\w+)=(.*)$/m if arg =~ /^(\w+)=(.*)$/m
ENV[$1] = $2 ENV[$1] = $2
else else

View file

@ -1 +0,0 @@

View file

@ -1,12 +1,13 @@
#-- #--
# Extensions to time to allow comparisons with an early time class. # Extensions to time to allow comparisons with early and late time classes.
require 'rake/early_time' require 'rake/early_time'
require 'rake/late_time'
class Time # :nodoc: all class Time # :nodoc: all
alias rake_original_time_compare :<=> alias rake_original_time_compare :<=>
def <=>(other) def <=>(other)
if Rake::EarlyTime === other if Rake::EarlyTime === other || Rake::LateTime === other
- other.<=>(self) - other.<=>(self)
else else
rake_original_time_compare(other) rake_original_time_compare(other)

View file

@ -21,7 +21,7 @@ module Rake
if File.exist?(name) if File.exist?(name)
File.mtime(name.to_s) File.mtime(name.to_s)
else else
Rake::EARLY Rake::LATE
end end
end end

17
lib/rake/late_time.rb Normal file
View file

@ -0,0 +1,17 @@
module Rake
# LateTime is a fake timestamp that occurs _after_ any other time value.
class LateTime
include Comparable
include Singleton
def <=>(other)
1
end
def to_s
'<LATE TIME>'
end
end
LATE = LateTime.instance
end

View file

@ -143,10 +143,7 @@ module Rake
end end
end end
directory package_dir directory package_dir_path => @package_files do
file package_dir_path => @package_files do
mkdir_p package_dir rescue nil
@package_files.each do |fn| @package_files.each do |fn|
f = File.join(package_dir_path, fn) f = File.join(package_dir_path, fn)
fdir = File.dirname(f) fdir = File.dirname(f)

View file

@ -111,7 +111,7 @@ module Rake
if args.empty? if args.empty?
task_name = key task_name = key
arg_names = [] arg_names = []
deps = value deps = value || []
else else
task_name = args.shift task_name = args.shift
arg_names = key arg_names = key

View file

@ -1412,6 +1412,8 @@ module MiniTest
include MiniTest::Assertions include MiniTest::Assertions
end # class TestCase end # class TestCase
end # class Unit end # class Unit
Test = Unit::TestCase
end # module MiniTest end # module MiniTest
Minitest = MiniTest # :nodoc: because ugh... I typo this all the time Minitest = MiniTest # :nodoc: because ugh... I typo this all the time

View file

@ -2,7 +2,7 @@ require 'rubygems'
$:.unshift File.expand_path('../../lib', __FILE__) $:.unshift File.expand_path('../../lib', __FILE__)
begin begin
gem 'minitest', '~> 4' gem 'minitest', '~> 5'
rescue Gem::LoadError rescue Gem::LoadError
end end
@ -21,7 +21,7 @@ rescue NoMethodError, LoadError
require 'test/support/rakefile_definitions' require 'test/support/rakefile_definitions'
end end
class Rake::TestCase < MiniTest::Unit::TestCase class Rake::TestCase < Minitest::Test
include FileCreation include FileCreation
include Rake::DSL include Rake::DSL

View file

@ -460,7 +460,7 @@ end
TEST_TASK TEST_TASK
open 'a_test.rb', 'w' do |io| open 'a_test.rb', 'w' do |io|
io << "require 'minitest/autorun'\n" io << "require 'minitest/autorun'\n"
io << "class ExitTaskTest < MiniTest::Unit::TestCase\n" io << "class ExitTaskTest < Minitest::Test\n"
io << " def test_exit\n" io << " def test_exit\n"
io << " assert false, 'this should fail'\n" io << " assert false, 'this should fail'\n"
io << " end\n" io << " end\n"

View file

@ -10,9 +10,9 @@ class TestRakeApplication < Rake::TestCase
end end
def setup_command_line(*options) def setup_command_line(*options)
ARGV.clear @app.argv.clear
options.each do |option| options.each do |option|
ARGV << option @app.argv << option
end end
end end
@ -268,7 +268,7 @@ class TestRakeApplication < Rake::TestCase
end end
def test_load_rakefile_not_found def test_load_rakefile_not_found
ARGV.clear @app.argv.clear
Dir.chdir @tempdir Dir.chdir @tempdir
ENV['RAKE_SYSTEM'] = 'not_exist' ENV['RAKE_SYSTEM'] = 'not_exist'
@ -378,7 +378,7 @@ class TestRakeApplication < Rake::TestCase
@app.handle_options @app.handle_options
assert !ARGV.include?(valid_option) assert !@app.argv.include?(valid_option)
assert @app.options.trace assert @app.options.trace
end end
@ -406,14 +406,14 @@ class TestRakeApplication < Rake::TestCase
setup_command_line("--trace", "sometask") setup_command_line("--trace", "sometask")
@app.handle_options @app.handle_options
assert ARGV.include?("sometask") assert @app.argv.include?("sometask")
assert @app.options.trace assert @app.options.trace
end end
def test_good_run def test_good_run
ran = false ran = false
ARGV << '--rakelib=""' @app.argv << '--rakelib=""'
@app.options.silent = true @app.options.silent = true
@ -468,7 +468,7 @@ class TestRakeApplication < Rake::TestCase
} }
assert_match(/see full trace/i, err) assert_match(/see full trace/i, err)
ensure ensure
ARGV.clear @app.argv.clear
end end
def test_bad_run_with_trace def test_bad_run_with_trace
@ -479,7 +479,7 @@ class TestRakeApplication < Rake::TestCase
} }
refute_match(/see full trace/i, err) refute_match(/see full trace/i, err)
ensure ensure
ARGV.clear @app.argv.clear
end end
def test_bad_run_with_backtrace def test_bad_run_with_backtrace
@ -492,7 +492,7 @@ class TestRakeApplication < Rake::TestCase
} }
refute_match(/see full trace/, err) refute_match(/see full trace/, err)
ensure ensure
ARGV.clear @app.argv.clear
end end
CustomError = Class.new(RuntimeError) CustomError = Class.new(RuntimeError)
@ -549,7 +549,7 @@ class TestRakeApplication < Rake::TestCase
end end
assert_match(/Secondary Error/, err) assert_match(/Secondary Error/, err)
ensure ensure
ARGV.clear @app.argv.clear
end end
def test_run_with_bad_options def test_run_with_bad_options
@ -559,7 +559,7 @@ class TestRakeApplication < Rake::TestCase
capture_io { @app.run } capture_io { @app.run }
} }
ensure ensure
ARGV.clear @app.argv.clear
end end
def test_standard_exception_handling_invalid_option def test_standard_exception_handling_invalid_option

View file

@ -59,6 +59,11 @@ class TestRakeDefinitions < Rake::TestCase
assert_raises(RuntimeError) { Task[:x].invoke } assert_raises(RuntimeError) { Task[:x].invoke }
end end
def test_falsey_dependencies
task :x => nil
assert_equal [], Task[:x].prerequisites
end
def test_implicit_file_dependencies def test_implicit_file_dependencies
runs = [] runs = []
create_existing_file create_existing_file

View file

@ -24,6 +24,7 @@ class TestRakeFileTask < Rake::TestCase
File.delete(ftask.name) rescue nil File.delete(ftask.name) rescue nil
assert ftask.needed?, "file should be needed" assert ftask.needed?, "file should be needed"
assert_equal Rake::LATE, ftask.timestamp
open(ftask.name, "w") { |f| f.puts "HI" } open(ftask.name, "w") { |f| f.puts "HI" }
@ -84,19 +85,14 @@ class TestRakeFileTask < Rake::TestCase
end end
def test_existing_file_depends_on_non_existing_file def test_existing_file_depends_on_non_existing_file
@ran = false
create_file(OLDFILE) create_file(OLDFILE)
delete_file(NEWFILE) delete_file(NEWFILE)
file NEWFILE do file NEWFILE do |t| @runs << t.name end
@ran = true file OLDFILE => NEWFILE do |t| @runs << t.name end
end
file OLDFILE => NEWFILE
Task[OLDFILE].invoke Task[OLDFILE].invoke
assert @ran assert_equal [NEWFILE, OLDFILE], @runs
end end
def test_needed_eh_build_all def test_needed_eh_build_all

View file

@ -0,0 +1,18 @@
require File.expand_path('../helper', __FILE__)
class TestRakeLateTime < Rake::TestCase
def test_late_time_comparisons
late = Rake::LATE
assert_equal late, late
assert late >= Time.now
assert late > Time.now
assert late != Time.now
assert Time.now < late
assert Time.now <= late
assert Time.now != late
end
def test_to_s
assert_equal '<LATE TIME>', Rake::LATE.to_s
end
end

View file

@ -1,6 +1,5 @@
require File.expand_path('../helper', __FILE__) require File.expand_path('../helper', __FILE__)
require 'rake/thread_pool' require 'rake/thread_pool'
require 'test/unit/assertions'
class TestRakeTestThreadPool < Rake::TestCase class TestRakeTestThreadPool < Rake::TestCase
include Rake include Rake