mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/rake: Update rake to fix some bugs and hide deprecated features
from RDoc. * lib/rake/version.rb: Bump version to 0.9.2.1 to distinguish it from the released version. * NEWS: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
84ece95163
commit
2619f216fe
19 changed files with 170 additions and 84 deletions
|
|
@ -6,6 +6,7 @@ class TestRakeFileUtils < Rake::TestCase
|
|||
|
||||
def teardown
|
||||
FileUtils::LN_SUPPORTED[0] = true
|
||||
RakeFileUtils.verbose_flag = Rake::FileUtilsExt::DEFAULT
|
||||
|
||||
super
|
||||
end
|
||||
|
|
@ -101,7 +102,11 @@ class TestRakeFileUtils < Rake::TestCase
|
|||
|
||||
def test_file_utils_methods_are_available_at_top_level
|
||||
create_file("a")
|
||||
rm_rf "a"
|
||||
|
||||
capture_io do
|
||||
rm_rf "a"
|
||||
end
|
||||
|
||||
refute File.exist?("a")
|
||||
end
|
||||
|
||||
|
|
@ -208,7 +213,7 @@ class TestRakeFileUtils < Rake::TestCase
|
|||
assert_equal "shellcommand.rb\n", err
|
||||
end
|
||||
|
||||
def test_sh_no_verbose
|
||||
def test_sh_verbose_false
|
||||
shellcommand
|
||||
|
||||
_, err = capture_io do
|
||||
|
|
@ -220,6 +225,16 @@ class TestRakeFileUtils < Rake::TestCase
|
|||
assert_equal '', err
|
||||
end
|
||||
|
||||
def test_sh_verbose_flag_nil
|
||||
shellcommand
|
||||
|
||||
RakeFileUtils.verbose_flag = nil
|
||||
|
||||
assert_silent do
|
||||
sh %{shellcommand.rb}, :noop=>true
|
||||
end
|
||||
end
|
||||
|
||||
def test_ruby_with_a_single_string_argument
|
||||
check_expansion
|
||||
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ class TestRakeFunctional < Rake::TestCase
|
|||
|
||||
rake
|
||||
|
||||
assert_not_match %r{^BAD:}, @out
|
||||
refute_match %r{^BAD:}, @out
|
||||
end
|
||||
|
||||
def test_rbext
|
||||
|
|
@ -441,7 +441,7 @@ class TestRakeFunctional < Rake::TestCase
|
|||
|
||||
rake "-T"
|
||||
|
||||
assert_not_match("t2", @out)
|
||||
refute_match("t2", @out)
|
||||
end
|
||||
|
||||
def test_comment_after_desc_is_ignored
|
||||
|
|
@ -476,10 +476,6 @@ class TestRakeFunctional < Rake::TestCase
|
|||
|
||||
private
|
||||
|
||||
def assert_not_match(pattern, string, comment="'#{pattern}' was found (incorrectly) in '#{string}.inspect")
|
||||
assert_nil Regexp.new(pattern).match(string), comment
|
||||
end
|
||||
|
||||
# Run a shell Ruby command with command line options (using the
|
||||
# default test options). Output is captured in @out, @err and
|
||||
# @status.
|
||||
|
|
|
|||
21
test/rake/test_rake_rake_test_loader.rb
Normal file
21
test/rake/test_rake_rake_test_loader.rb
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
require File.expand_path('../helper', __FILE__)
|
||||
|
||||
class TestRakeRakeTestLoader < Rake::TestCase
|
||||
|
||||
def test_pattern
|
||||
orig_LOADED_FEATURES = $:.dup
|
||||
FileUtils.touch 'foo.rb'
|
||||
FileUtils.touch 'test_a.rb'
|
||||
FileUtils.touch 'test_b.rb'
|
||||
|
||||
ARGV.replace %w[foo.rb test_*.rb -v]
|
||||
|
||||
load File.join(@orig_PWD, 'lib/rake/rake_test_loader.rb')
|
||||
|
||||
assert_equal %w[-v], ARGV
|
||||
ensure
|
||||
$:.replace orig_LOADED_FEATURES
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
@ -158,5 +158,13 @@ class TestRakeTaskWithArguments < Rake::TestCase
|
|||
t = task(:t => [:pre])
|
||||
t.invoke("bill", "1.2")
|
||||
end
|
||||
|
||||
def test_values_at
|
||||
t = task(:pre, [:a, :b, :c]) { |t, args|
|
||||
a, b, c = args.values_at(:a, :b, :c)
|
||||
assert_equal %w[1 2 3], [a, b, c]
|
||||
}
|
||||
t.invoke(*%w[1 2 3])
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -4,18 +4,7 @@ require 'rake/testtask'
|
|||
class TestRakeTestTask < Rake::TestCase
|
||||
include Rake
|
||||
|
||||
def setup
|
||||
super
|
||||
|
||||
Task.clear
|
||||
ENV.delete('TEST')
|
||||
end
|
||||
|
||||
def test_no_task
|
||||
assert ! Task.task_defined?(:test)
|
||||
end
|
||||
|
||||
def test_defaults
|
||||
def test_initialize
|
||||
tt = Rake::TestTask.new do |t| end
|
||||
refute_nil tt
|
||||
assert_equal :test, tt.name
|
||||
|
|
@ -25,7 +14,7 @@ class TestRakeTestTask < Rake::TestCase
|
|||
assert Task.task_defined?(:test)
|
||||
end
|
||||
|
||||
def test_non_defaults
|
||||
def test_initialize_override
|
||||
tt = Rake::TestTask.new(:example) do |t|
|
||||
t.libs = ['src', 'ext']
|
||||
t.pattern = 'test/tc_*.rb'
|
||||
|
|
@ -39,29 +28,43 @@ class TestRakeTestTask < Rake::TestCase
|
|||
assert Task.task_defined?(:example)
|
||||
end
|
||||
|
||||
def test_pattern
|
||||
def test_file_list_ENV_TEST
|
||||
ENV['TEST'] = 'testfile.rb'
|
||||
tt = Rake::TestTask.new do |t|
|
||||
t.pattern = '*'
|
||||
end
|
||||
|
||||
assert_equal ["testfile.rb"], tt.file_list.to_a
|
||||
ensure
|
||||
ENV.delete 'TEST'
|
||||
end
|
||||
|
||||
def test_libs_equals
|
||||
test_task = Rake::TestTask.new do |t|
|
||||
t.libs << ["A", "B"]
|
||||
end
|
||||
|
||||
path = %w[lib A B].join File::PATH_SEPARATOR
|
||||
|
||||
assert_equal "-I\"#{path}\"", test_task.ruby_opts_string
|
||||
end
|
||||
|
||||
def test_libs_equals_empty
|
||||
test_task = Rake::TestTask.new do |t|
|
||||
t.libs = []
|
||||
end
|
||||
|
||||
assert_equal '', test_task.ruby_opts_string
|
||||
end
|
||||
|
||||
def test_pattern_equals
|
||||
tt = Rake::TestTask.new do |t|
|
||||
t.pattern = '*.rb'
|
||||
end
|
||||
assert_equal ['*.rb'], tt.file_list.to_a
|
||||
end
|
||||
|
||||
def test_env_test
|
||||
ENV['TEST'] = 'testfile.rb'
|
||||
tt = Rake::TestTask.new do |t|
|
||||
t.pattern = '*'
|
||||
end
|
||||
assert_equal ["testfile.rb"], tt.file_list.to_a
|
||||
end
|
||||
|
||||
def test_test_files
|
||||
tt = Rake::TestTask.new do |t|
|
||||
t.test_files = FileList['a.rb', 'b.rb']
|
||||
end
|
||||
assert_equal ["a.rb", 'b.rb'], tt.file_list.to_a
|
||||
end
|
||||
|
||||
def test_both_pattern_and_test_files
|
||||
def test_pattern_equals_test_files_equals
|
||||
tt = Rake::TestTask.new do |t|
|
||||
t.test_files = FileList['a.rb', 'b.rb']
|
||||
t.pattern = '*.rb'
|
||||
|
|
@ -69,48 +72,49 @@ class TestRakeTestTask < Rake::TestCase
|
|||
assert_equal ['a.rb', 'b.rb', '*.rb'], tt.file_list.to_a
|
||||
end
|
||||
|
||||
def test_direct_run_has_quoted_paths
|
||||
test_task = Rake::TestTask.new(:tx) do |t|
|
||||
def test_run_code_direct
|
||||
test_task = Rake::TestTask.new do |t|
|
||||
t.loader = :direct
|
||||
end
|
||||
assert_match(/-e ".*"/, test_task.run_code)
|
||||
|
||||
assert_equal '-e "ARGV.each{|f| require f}"', test_task.run_code
|
||||
end
|
||||
|
||||
def test_testrb_run_has_quoted_paths_on_ruby_182
|
||||
test_task = Rake::TestTask.new(:tx) do |t|
|
||||
def test_run_code_rake
|
||||
test_task = Rake::TestTask.new do |t|
|
||||
t.loader = :rake
|
||||
end
|
||||
|
||||
assert_match(/-I".*?" ".*?"/, test_task.run_code)
|
||||
end
|
||||
|
||||
def test_run_code_testrb_ruby_1_8_2
|
||||
test_task = Rake::TestTask.new 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|
|
||||
def test_run_code_testrb_ruby_1_8_6
|
||||
test_task = Rake::TestTask.new 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
|
||||
def test_test_files_equals
|
||||
tt = Rake::TestTask.new do |t|
|
||||
t.test_files = FileList['a.rb', 'b.rb']
|
||||
end
|
||||
assert_match(/".*"/, test_task.run_code)
|
||||
|
||||
assert_equal ["a.rb", 'b.rb'], tt.file_list.to_a
|
||||
end
|
||||
|
||||
def test_nested_libs_will_be_flattened
|
||||
test_task = Rake::TestTask.new(:tx) do |t|
|
||||
t.libs << ["A", "B"]
|
||||
end
|
||||
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
|
||||
test_task = Rake::TestTask.new(:tx) do |t|
|
||||
t.libs = []
|
||||
end
|
||||
refute_match(/-I/, test_task.ruby_opts_string)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue