diff --git a/Rakefile b/Rakefile index 43b997911..cd2fde637 100644 --- a/Rakefile +++ b/Rakefile @@ -106,16 +106,28 @@ end begin require 'rcov/rcovtask' + IGNORE_COVERAGE_IN = FileList[ + 'lib/rake/rdoctask.rb', + 'lib/rake/testtask.rb', + 'lib/rake/packagetask.rb', + 'lib/rake/clean.rb', + ] + + unless File::ALT_SEPARATOR + IGNORE_COVERAGE_IN.include( + 'lib/rake/alt_system.rb', + 'lib/rake/win32.rb') + end Rcov::RcovTask.new do |t| t.libs << "test" - dot_rakes = t.rcov_opts = [ '-xRakefile', '-xrakefile', '-xpublish.rf', - '-xlib/rake/contrib', '-x/Library', + '-xlib/rake/contrib', '-x/Library', '-x.rvm', '--text-report', '--sort coverage' - ] + FileList['rakelib/*.rake'].pathmap("-x%p") + ] + FileList['rakelib/*.rake'].pathmap("-x%p") + + IGNORE_COVERAGE_IN.map { |fn| "-x#{fn}" } t.test_files = FileList[ 'test/lib/*_test.rb', 'test/contrib/*_test.rb', @@ -248,7 +260,7 @@ else # end end - package_task = Gem::PackageTask.new(SPEC) do |pkg| + Gem::PackageTask.new(SPEC) do |pkg| pkg.need_zip = true pkg.need_tar = true end diff --git a/lib/rake.rb b/lib/rake.rb index 3ccefebb1..d88cf6cfe 100644 --- a/lib/rake.rb +++ b/lib/rake.rb @@ -56,7 +56,6 @@ 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 5d77304c2..634a32daa 100644 --- a/lib/rake/application.rb +++ b/lib/rake/application.rb @@ -449,7 +449,7 @@ def rake_require(file_name, paths=$LOAD_PATH, loaded=$") paths.each do |path| full_path = File.join(path, fn) if File.exist?(full_path) - Rake::Environment.load_rakefile(full_path) + Rake.load_rakefile(full_path) loaded << fn return true end @@ -492,7 +492,7 @@ def raw_load_rakefile # :nodoc: Dir.chdir(location) print_rakefile_directory(location) $rakefile = @rakefile if options.classic_namespace - Rake::Environment.load_rakefile(File.expand_path(@rakefile)) if @rakefile && @rakefile != '' + Rake.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/clean.rb b/lib/rake/clean.rb index 56d79eb08..62f27d575 100644 --- a/lib/rake/clean.rb +++ b/lib/rake/clean.rb @@ -13,21 +13,19 @@ require 'rake' -Rake::DSL.environment do - CLEAN = Rake::FileList["**/*~", "**/*.bak", "**/core"] - CLEAN.clear_exclude.exclude { |fn| - fn.pathmap("%f") == 'core' && File.directory?(fn) - } +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 +desc "Remove any temporary products." +task :clean do + CLEAN.each { |fn| rm_r fn rescue nil } +end - CLOBBER = Rake::FileList.new +CLOBBER = Rake::FileList.new - desc "Remove any generated file." - task :clobber => [:clean] do - CLOBBER.each { |fn| rm_r fn rescue nil } - end +desc "Remove any generated file." +task :clobber => [:clean] do + CLOBBER.each { |fn| rm_r fn rescue nil } end diff --git a/lib/rake/default_loader.rb b/lib/rake/default_loader.rb index c7a15bb03..5dd3c0561 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) - Rake::Environment.load_rakefile(File.expand_path(fn)) + Rake.load_rakefile(File.expand_path(fn)) end end diff --git a/lib/rake/environment.rb b/lib/rake/environment.rb deleted file mode 100644 index d7bc92b7e..000000000 --- a/lib/rake/environment.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'rake/dsl_definition' - -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 - # 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 - - # Run a block of code in the Rake DSL environment. - def run(&block) - block.call - 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) - eval(code, binding, file_name) - 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/lib/rake/rake_module.rb b/lib/rake/rake_module.rb index 9aa9c4339..a9d210c63 100644 --- a/lib/rake/rake_module.rb +++ b/lib/rake/rake_module.rb @@ -20,6 +20,10 @@ def original_dir application.original_dir end + # Load a rakefile. + def load_rakefile(path) + load(path) + end end end diff --git a/lib/rake/task_manager.rb b/lib/rake/task_manager.rb index 1e76c940e..4c3c26aa3 100644 --- a/lib/rake/task_manager.rb +++ b/lib/rake/task_manager.rb @@ -238,8 +238,7 @@ def generate_name end def trace_rule(level, message) - $stderr.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. @@ -266,7 +265,7 @@ def attempt_rule(task_name, extensions, block, level) # Make a list of sources from the list of file name extensions / # translation procs. def make_sources(task_name, extensions) - extensions.collect { |ext| + result = extensions.collect { |ext| case ext when /%/ task_name.pathmap(ext) @@ -285,7 +284,8 @@ def make_sources(task_name, extensions) else fail "Don't know how to handle rule dependent: #{ext.inspect}" end - }.flatten + } + result.flatten end diff --git a/lib/rake/testtask.rb b/lib/rake/testtask.rb index dedd63a19..04d3ae473 100644 --- a/lib/rake/testtask.rb +++ b/lib/rake/testtask.rb @@ -103,7 +103,12 @@ def define end def option_list # :nodoc: - ENV['TESTOPTS'] || @options || "" + (ENV['TESTOPTS'] || + ENV['TESTOPT'] || + ENV['TEST_OPTS'] || + ENV['TEST_OPT'] || + @options || + "") end def ruby_opts_string diff --git a/lib/rake/version.rb b/lib/rake/version.rb index 55c6c45c1..9c32ce8fd 100644 --- a/lib/rake/version.rb +++ b/lib/rake/version.rb @@ -5,7 +5,7 @@ module Version MINOR = 9, BUILD = 0, BETA = 'beta', - BETANUM = 4, + BETANUM = 5, ] end VERSION = Version::NUMBERS.join('.') diff --git a/rakelib/rbx.rake b/rakelib/rbx.rake deleted file mode 100644 index 4aad24801..000000000 --- a/rakelib/rbx.rake +++ /dev/null @@ -1,82 +0,0 @@ -module Rbx - PROG = '/usr/local/bin/rbx' - GEM_HOME = '/usr/local/lib/rubinius/gems/1.8' - - RELEASE_FILES = FileList['bin/rake', 'lib/rake.rb', 'lib/rake/**/*'] - RELEASE_FILES.exclude('lib/rake/lib', 'project.rake', 'lib/rake/plugins', 'lib/rake/contrib') - - SVN = "../thirdparty/ruby" - - def run_tests(files, opts='') - sh "#{PROG} -Ilib lib/rake/rake_test_loader.rb #{opts} #{files}" - end - - extend self -end - -namespace "rbx" do - desc "Ruby Release Files" - task :release_files do - puts Rbx::RELEASE_FILES - end - - desc "Release Rake Files to Ruby 19 SVN working area" - task :release => [:check_svn] do - dirs = Rbx::RELEASE_FILES.select { |fn| File.directory?(fn) } - dirs.each do |dir| mkdir_p "#{Rbx::SVN}/#{dir}" end - Rbx::RELEASE_FILES.each do |fn| - cp fn, "#{Rbx::SVN}/#{fn}" unless File.directory?(fn) - end - end - - desc "Remove Rake from the Ruby 19 SVN" - task :unrelease => [:check_svn] do - rm_r "#{Rbx::SVN}/bin/rake" rescue nil - rm_r "#{Rbx::SVN}/lib/rake" rescue nil - rm_r "#{Rbx::SVN}/lib/rake.rb" rescue nil - end - - task :check_svn do - fail "Cannot find Ruby 1.9 SVN directory: #{Rbx::SVN}" unless - File.directory?(Rbx::SVN) - end - - - namespace "test" do - - desc "Check the file paths" - task :check do - raise "Ruby 1.9 executable not found" unless File.exist?(Rbx::PROG) - raise "Ruby 1.9 Gem Home not found" unless File.exist?(Rbx::GEM_HOME) - end - - task :env19 => :check do - ENV['GEM_HOME'] = Rbx::GEM_HOME - end - - desc "Describe the Ruby 1.9 version used for testing" - task :version => [:env19] do - sh "#{Rbx::PROG} --version", :verbose => false - sh "#{Rbx::PROG} -rubygems -e 'puts \"Gem Path = \#{Gem.path}\"'", :verbose => false - sh "#{Rbx::PROG} -Ilib bin/rake --version" - end - - desc "Run the unit tests in Ruby 1.9" - task :units, [:opts] => [:env19] do |t, args| - 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] => [:env19] do |t, args| - 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] => [:env19] do |t, args| - test_files = FileList['test/functional/*_test.rb', 'test/lib/*_test.rb'] - Rbx.run_tests(test_files, args.opts) - end - end -end diff --git a/rakelib/ruby19.rake b/rakelib/ruby19.rake deleted file mode 100644 index 33ecffa22..000000000 --- a/rakelib/ruby19.rake +++ /dev/null @@ -1,88 +0,0 @@ -module Ruby19 - PROG = '/Users/jim/local/ruby19/bin/ruby' - GEM_HOME = '/Users/jim/local/ruby19.gems' - - RELEASE_FILES = FileList['bin/rake', 'lib/rake.rb', 'lib/rake/**/*'] - RELEASE_FILES.exclude('lib/rake/lib', 'project.rake', 'lib/rake/plugins', 'lib/rake/contrib') - - SVN = "#{ENV['HOME']}/working/svn/software/thirdparty/ruby" - - def run_tests(files, opts='') - sh "#{PROG} -w -Ilib lib/rake/rake_test_loader.rb #{opts} #{files}" - end - - extend self -end - -namespace "ruby19" do - desc "Generate a diff file between the primary repo and Ruby 1.9" - task :diff => [:check_svn] do - sh %{diff -u #{Ruby19::SVN}/lib/rake.rb lib/rake.rb} - sh %{diff -u -x .svn -x contrib -x lib #{Ruby19::SVN}/lib/rake lib/rake} - end - - desc "Ruby Release Files" - task :release_files do - puts Ruby19::RELEASE_FILES - end - - desc "Release Rake Files to Ruby 19 SVN working area" - task :release => [:check_svn] do - dirs = Ruby19::RELEASE_FILES.select { |fn| File.directory?(fn) } - dirs.each do |dir| mkdir_p "#{Ruby19::SVN}/#{dir}" end - Ruby19::RELEASE_FILES.each do |fn| - cp fn, "#{Ruby19::SVN}/#{fn}" unless File.directory?(fn) - end - end - - desc "Remove Rake from the Ruby 19 SVN" - task :unrelease => [:check_svn] do - rm_r "#{Ruby19::SVN}/bin/rake" rescue nil - rm_r "#{Ruby19::SVN}/lib/rake" rescue nil - rm_r "#{Ruby19::SVN}/lib/rake.rb" rescue nil - end - - task :check_svn do - fail "Cannot find Ruby 1.9 SVN directory: #{Ruby19::SVN}" unless - File.directory?(Ruby19::SVN) - end - - - namespace "test" do - - desc "Check the file paths" - task :check do - raise "Ruby 1.9 executable not found" unless File.exist?(Ruby19::PROG) - raise "Ruby 1.9 Gem Home not found" unless File.exist?(Ruby19::GEM_HOME) - end - - task :env19 => :check do - ENV['GEM_HOME'] = Ruby19::GEM_HOME - end - - desc "Describe the Ruby 1.9 version used for testing" - task :version => [:env19] do - sh "#{Ruby19::PROG} --version", :verbose => false - sh "#{Ruby19::PROG} -rubygems -e 'puts \"Gem Path = \#{Gem.path}\"'", :verbose => false - sh "#{Ruby19::PROG} -Ilib bin/rake --version" - end - - desc "Run the unit tests in Ruby 1.9" - task :units, [:opts] => [:env19] do |t, args| - 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] => [:env19] do |t, args| - 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] => [:env19] do |t, args| - test_files = FileList['test/*_test.rb', 'test/functional/*_test.rb', 'test/lib/*_test.rb'] - Ruby19.run_tests(test_files, args.opts) - end - end -end diff --git a/rakelib/tags.rake b/rakelib/tags.rake index 9dbfdf48f..7f7ae7516 100644 --- a/rakelib/tags.rake +++ b/rakelib/tags.rake @@ -1,6 +1,8 @@ #!/usr/bin/env ruby module Tags + extend Rake::DSL if defined?(Rake::DSL) + PROG = ENV['TAGS'] || 'ctags' RAKEFILES = FileList['Rakefile', '**/*.rake'] diff --git a/rakelib/test_times.rake b/rakelib/test_times.rake new file mode 100644 index 000000000..daf1bc6e9 --- /dev/null +++ b/rakelib/test_times.rake @@ -0,0 +1,25 @@ +module TestTimes + def self.run(test_results, limit=0) + limit = limit.nonzero? || 10 + tests = [] + test_results.split(/\n/).each do |line| + if line =~ /^(.+?#[^:]+): ([0-9.]+) s: \.$/ + tests << [$1, $2.to_f, line] + end + end + + puts "#{limit} Slowest tests" + puts tests.sort_by { |item| + item[1] + }.reverse[0...limit].map { |item| + "%6.3f: %-s\n" % [item[1], item[0]] + } + end +end + +namespace :test do + desc "Find the slowest unit tests" + task :times, [:limit] do |t, args| + TestTimes.run `rake test:units TESTOPTS='--verbose'`, args.limit.to_i + end +end diff --git a/test/contrib/test_sys.rb b/test/contrib/test_sys.rb index 49e9045a1..ccc9848c1 100644 --- a/test/contrib/test_sys.rb +++ b/test/contrib/test_sys.rb @@ -1,7 +1,7 @@ #!/usr/bin/env ruby require 'test/unit' -require 'test/filecreation' +require 'test/file_creation' begin old_verbose = $VERBOSE $VERBOSE = nil diff --git a/test/data/rakelib/test1.rb b/test/data/rakelib/test1.rb index fd3c95818..8a1ca2553 100644 --- a/test/data/rakelib/test1.rb +++ b/test/data/rakelib/test1.rb @@ -1,5 +1,4 @@ -Rake::DSL.environment do - task :default do - puts "TEST1" - end + +task :default do + puts "TEST1" end diff --git a/test/filecreation.rb b/test/file_creation.rb similarity index 58% rename from test/filecreation.rb rename to test/file_creation.rb index 7a8bc8783..e0f12ec8e 100644 --- a/test/filecreation.rb +++ b/test/file_creation.rb @@ -5,13 +5,16 @@ module FileCreation NEWFILE = "testdata/new" def create_timed_files(oldfile, *newfiles) - return if File.exist?(oldfile) && newfiles.all? { |newfile| File.exist?(newfile) } - old_time = create_file(oldfile) + return if (File.exist?(oldfile) && + newfiles.all? { |newfile| + File.exist?(newfile) && File.stat(newfile).mtime > File.stat(oldfile).mtime + }) + now = Time.now + + create_file(oldfile, now - 60) + newfiles.each do |newfile| - while create_file(newfile) <= old_time - sleep(0.1) - File.delete(newfile) rescue nil - end + create_file(newfile, now) end end @@ -20,9 +23,10 @@ def create_dir(dirname) File.stat(dirname).mtime end - def create_file(name) + def create_file(name, file_time=nil) create_dir(File.dirname(name)) FileUtils.touch(name) unless File.exist?(name) + File.utime(file_time, file_time, name) unless file_time.nil? File.stat(name).mtime end diff --git a/test/lib/application_test.rb b/test/lib/application_test.rb index c0cc72037..393328951 100644 --- a/test/lib/application_test.rb +++ b/test/lib/application_test.rb @@ -33,10 +33,10 @@ def teardown end def test_constant_warning - err = capture_stderr do @app.instance_eval { const_warning("Task") } end - assert_match(/warning/i, err) - assert_match(/deprecated/i, err) - assert_match(/Task/i, err) + error_messages = capture_stderr do @app.instance_eval { const_warning("Task") } end + assert_match(/warning/i, error_messages) + assert_match(/deprecated/i, error_messages) + assert_match(/Task/i, error_messages) end def test_display_tasks @@ -155,14 +155,14 @@ def test_load_rakefile def test_load_rakefile_doesnt_print_rakefile_directory_from_same_dir in_environment("PWD" => "test/data/unittest") do - err = capture_stderr do + error_messages = capture_stderr do @app.instance_eval do @original_dir = File.expand_path(".") # pretend we started from the unittest dir raw_load_rakefile end end _, location = @app.find_rakefile_location - assert_no_match(/\(in #{location}\)/, err) + assert_no_match(/\(in #{location}\)/, error_messages) end end @@ -180,19 +180,19 @@ def test_load_rakefile_from_subdir def test_load_rakefile_prints_rakefile_directory_from_subdir in_environment("PWD" => "test/data/unittest/subdir") do - err = capture_stderr do + error_messages = capture_stderr do @app.instance_eval do raw_load_rakefile end end _, location = @app.find_rakefile_location - assert_match(/\(in #{location}\)/, err) + assert_match(/\(in #{location}\)/, error_messages) end end def test_load_rakefile_doesnt_print_rakefile_directory_from_subdir_if_silent in_environment("PWD" => "test/data/unittest/subdir") do - err = capture_stderr do + error_messages = capture_stderr do @app.instance_eval do handle_options options.silent = true @@ -200,7 +200,7 @@ def test_load_rakefile_doesnt_print_rakefile_directory_from_subdir_if_silent end end _, location = @app.find_rakefile_location - assert_no_match(/\(in #{location}\)/, err) + assert_no_match(/\(in #{location}\)/, error_messages) end end @@ -232,6 +232,21 @@ def test_load_from_system_rakefile end end + def test_load_from_calculated_system_rakefile + flexmock(@app, :standard_system_dir => "__STD_SYS_DIR__") + in_environment('RAKE_SYSTEM' => nil) do + @app.options.rakelib = [] + @app.instance_eval do + handle_options + options.silent = true + options.load_system = true + options.rakelib = [] + load_rakefile + end + assert_equal "__STD_SYS_DIR__", @app.system_dir + end + end + def test_windows assert ! (@app.windows? && @app.unix?) end @@ -320,8 +335,8 @@ def test_bad_run ARGV.clear ARGV << '-f' << '-s' << '--rakelib=""' assert_exception(SystemExit) { - err = capture_stderr { @app.run } - assert_match(/see full trace/, err) + error_messages = capture_stderr { @app.run } + assert_match(/see full trace/, error_messages) } ensure ARGV.clear @@ -332,8 +347,8 @@ def test_bad_run_with_trace ARGV.clear ARGV << '-f' << '-s' << '-t' assert_exception(SystemExit) { - err = capture_stderr { capture_stdout { @app.run } } - assert_no_match(/see full trace/, err) + error_messages = capture_stderr { capture_stdout { @app.run } } + assert_no_match(/see full trace/, error_messages) } ensure ARGV.clear @@ -349,6 +364,17 @@ def test_run_with_bad_options ensure ARGV.clear end + + def test_deprecation_message + in_environment do + error_messages = capture_stderr do + @app.deprecate("a", "b", "c") + end + assert_match(/'a' is deprecated/i, error_messages) + assert_match(/use 'b' instead/i, error_messages) + assert_match(/at c$/i, error_messages) + end + end end @@ -596,7 +622,28 @@ def test_tasks end flags(['--tasks', 'xyz'], ['-Txyz']) do |opts| assert_equal :tasks, opts.show_tasks - assert_equal(/xyz/, opts.show_task_pattern) + assert_equal(/xyz/.to_s, opts.show_task_pattern.to_s) + end + end + end + + def test_where + in_environment do + flags('--where', '-W') do |opts| + assert_equal :lines, opts.show_tasks + assert_equal(//.to_s, opts.show_task_pattern.to_s) + end + flags(['--where', 'xyz'], ['-Wxyz']) do |opts| + assert_equal :lines, opts.show_tasks + assert_equal(/xyz/.to_s, opts.show_task_pattern.to_s) + end + end + end + + def test_no_deprecated_messages + in_environment do + flags('--no-deprecation-warnings', '-X') do |opts| + assert opts.ignore_deprecate end end end @@ -622,7 +669,7 @@ def test_version def test_classic_namespace in_environment do - error_output = capture_stderr do + error_messages = capture_stderr do flags(['--classic-namespace'], ['-C', '-T', '-P', '-n', '-s', '-t']) do |opts| assert opts.classic_namespace assert_equal opts.show_tasks, $show_tasks @@ -632,13 +679,13 @@ def test_classic_namespace assert_equal opts.silent, $silent end end - assert_match(/deprecated/, error_output) + assert_match(/deprecated/, error_messages) end end def test_bad_option in_environment do - error_output = capture_stderr do + error_messages = capture_stderr do ex = assert_exception(OptionParser::InvalidOption) do flags('--bad-option') end @@ -649,7 +696,7 @@ def test_bad_option assert_match(/--bad-option/, ex.message) end end - assert_equal '', error_output + assert_equal '', error_messages end end diff --git a/test/lib/definitions_test.rb b/test/lib/definitions_test.rb index 248879f90..5424384d7 100644 --- a/test/lib/definitions_test.rb +++ b/test/lib/definitions_test.rb @@ -3,7 +3,7 @@ require 'test/unit' require 'fileutils' require 'rake' -require 'test/filecreation' +require 'test/file_creation' require 'test/rake_test_setup' ###################################################################### diff --git a/test/lib/environment_test.rb b/test/lib/environment_test.rb deleted file mode 100644 index 59cd8d956..000000000 --- a/test/lib/environment_test.rb +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env ruby - -require 'test/test_helper' -require 'rake/environment' - -class TestEnvironment < Test::Unit::TestCase - 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 - - def test_run - Rake::Task.clear - Rake::Environment.run do - desc "demo comment" - task :default - end - assert Rake::Task[:default], "Should have a default task" - end - - def test_environment - Rake::Task.clear - Rake::DSL.environment do - desc "demo comment" - task :default - end - assert Rake::Task[:default], "Should have a default task" - end -end diff --git a/test/lib/file_creation_task_test.rb b/test/lib/file_creation_task_test.rb index 1544e14d2..ebd4063d3 100644 --- a/test/lib/file_creation_task_test.rb +++ b/test/lib/file_creation_task_test.rb @@ -3,7 +3,7 @@ require 'test/unit' require 'fileutils' require 'rake' -require 'test/filecreation' +require 'test/file_creation' ###################################################################### class TestFileCreationTask < Test::Unit::TestCase diff --git a/test/lib/file_task_test.rb b/test/lib/file_task_test.rb index 1d7032de4..d72c1dcb6 100644 --- a/test/lib/file_task_test.rb +++ b/test/lib/file_task_test.rb @@ -3,7 +3,7 @@ require 'test/unit' require 'fileutils' require 'rake' -require 'test/filecreation' +require 'test/file_creation' require 'test/rake_test_setup' ###################################################################### diff --git a/test/lib/filelist_test.rb b/test/lib/filelist_test.rb index 15d32a28f..bc0147fce 100644 --- a/test/lib/filelist_test.rb +++ b/test/lib/filelist_test.rb @@ -347,6 +347,16 @@ def test_egrep_with_block assert_match(/files\.egrep/, found[2]) end + def test_egrep_with_error + files = FileList['test/lib/*_test.rb'] + error_messages = capture_stderr do + files.egrep(/ANYTHING/) do |fn, ln, line | + fail "_EGREP_FAILURE_" + end + end + assert_match(/_EGREP_FAILURE_/, error_messages) + end + def test_existing fl = FileList['testdata/abc.c', 'testdata/notthere.c'] assert_equal ["testdata/abc.c"], fl.existing diff --git a/test/lib/fileutils_test.rb b/test/lib/fileutils_test.rb index 8f57599db..493dfb127 100644 --- a/test/lib/fileutils_test.rb +++ b/test/lib/fileutils_test.rb @@ -2,7 +2,7 @@ require 'rake' require 'test/unit' -require 'test/filecreation' +require 'test/file_creation' require 'fileutils' require 'stringio' require 'test/rake_test_setup' diff --git a/test/lib/rules_test.rb b/test/lib/rules_test.rb index 88ad1eafd..4c129ebe4 100644 --- a/test/lib/rules_test.rb +++ b/test/lib/rules_test.rb @@ -3,7 +3,7 @@ require 'test/unit' require 'fileutils' require 'rake' -require 'test/filecreation' +require 'test/file_creation' require 'test/rake_test_setup' ###################################################################### diff --git a/test/lib/top_level_functions_test.rb b/test/lib/top_level_functions_test.rb index 4337de976..10285add1 100644 --- a/test/lib/top_level_functions_test.rb +++ b/test/lib/top_level_functions_test.rb @@ -41,6 +41,12 @@ def test_import Rake.import('x', 'y', 'z') end + def test_deprecated_import + Rake.application.should_receive(:add_import).with("x").once.ordered + error_messages = capture_stderr { import('x') } + assert_match(/deprecated/, error_messages) + end + def test_when_writing out = capture_stdout do when_writing("NOTWRITING") do diff --git a/test/rake_test_setup.rb b/test/rake_test_setup.rb index e28c62337..5365ba3b9 100644 --- a/test/rake_test_setup.rb +++ b/test/rake_test_setup.rb @@ -8,7 +8,7 @@ end require 'flexmock/test_unit' -require 'test/filecreation' +require 'test/file_creation' require 'test/capture_stdout' require 'test/test_helper'