[DRE-commits] [SCM] rake.git branch, master, updated. debian/0.9.2-1-20-ge7bdb9f

Antonio Terceiro terceiro at debian.org
Sat Nov 19 21:55:40 UTC 2011


The following commit has been merged in the master branch:
commit 6b266883cb69fcfba5e13aa247278480fcea0838
Author: Antonio Terceiro <terceiro at debian.org>
Date:   Sat Nov 19 17:23:08 2011 -0200

    Imported Upstream version 0.9.2.2

diff --git a/CHANGES b/CHANGES
index c4929ed..7008bb7 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,18 @@
 = Rake Changelog
 
+== Master (for 0.9.3)
+
+* The rake test loader now removes arguments it has processed.  Issue #51
+* Rake::TaskArguments now responds to #values_at
+* RakeFileUtils.verbose_flag = nil silences output the same as 0.8.7
+* Rake tests are now directory-independent
+* Rake tests are no longer require flexmock
+* Commands constant is no longer polluting top level namespace.
+
+== Version 0.9.2
+
+* Unknown
+
 == Version 0.9.1
 
 * Added deprecation warnings to the Rake DSL methods.
diff --git a/README.rdoc b/README.rdoc
index 8b7e843..62efebf 100644
--- a/README.rdoc
+++ b/README.rdoc
@@ -1,9 +1,7 @@
 = RAKE -- Ruby Make
 
-Supporting Rake version: 0.8.7.
-
-This package contains Rake, a simple ruby build program with
-capabilities similar to make.
+This package contains Rake, a simple ruby build program with capabilities
+similar to make.
 
 Rake has the following features:
 
@@ -19,16 +17,17 @@ Rake has the following features:
   file names and paths.
 
 * A library of prepackaged tasks to make building rakefiles easier. For example,
-  tasks for building tarballs, gems and RDoc output are provided.
+  tasks for building tarballs and publishing to FTP or SSH sites.  (Formerly
+  tasks for building RDoc and Gems were included in rake but they're now
+  available in RDoc and RubyGems respectively.)
 
 * Supports parallel execution of tasks.
 
-
 == Installation
 
 === Gem Installation
 
-Download and install  rake with the following.
+Download and install rake with the following.
 
    gem install rake
 
@@ -114,12 +113,9 @@ 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)
+* https://github.com/jimweirich/rake/issues
 
-Issues and bug reports can be tracked here:
+Issues and bug reports can also be tracked here:
 
 * http://www.pivotaltracker.com/projects/28469
 
@@ -133,11 +129,12 @@ Issues and bug reports can be tracked here:
 * 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
+* Rake Bug Reports: https://github.com/jimweirich/rake/issues
 
 === Presentations and Articles about Rake
 
-* Jim Weirich's 2003 RubyConf presentation: http://onestepback.org/articles/buildingwithrake/
+* Jim Weirich's 2003 RubyConf presentation:
+  http://onestepback.org/articles/buildingwithrake/
 * Martin Fowler's article on Rake: http://martinfowler.com/articles/rake.html
 
 == Other Make Reinvisionings ...
@@ -187,7 +184,7 @@ jim dot weirich at gmail.com.
 = Other stuff
 
 Author::   Jim Weirich <jim.weirich at gmail.com>
-Requires:: Ruby 1.8.0 or later
+Requires:: Ruby 1.8.6 or later
 License::  Copyright 2003-2008 by Jim Weirich.
            Released under an MIT-style license.  See the LICENSE file
            included in the distribution.
diff --git a/RRR b/RRR
deleted file mode 100644
index 119310a..0000000
--- a/RRR
+++ /dev/null
@@ -1,9 +0,0 @@
-class Zippy
-  def initialize
-    task :a
-    task :b
-    file "x"
-  end
-end
-
-Zippy.new
diff --git a/Rakefile b/Rakefile
index f49328b..2e2c40d 100644
--- a/Rakefile
+++ b/Rakefile
@@ -12,7 +12,7 @@ require 'rubygems'
 system_rake = File.join RbConfig::CONFIG['rubylibdir'], 'rake.rb'
 
 # Use our rake, not the installed rake from system
-if $".include? system_rake then
+if $".include? system_rake or $".grep(/rake\/name_space\.rb$/).empty? then
   exec Gem.ruby, '-Ilib', 'bin/rake', *ARGV
 end
 
@@ -28,11 +28,7 @@ rescue Gem::LoadError
 end
 
 CLEAN.include('**/*.o', '*.dot', '**/*.rbc')
-CLOBBER.include('doc/example/main', 'testdata')
-CLOBBER.include('test/data/**/temp_*')
-CLOBBER.include('test/data/chains/play.*')
-CLOBBER.include('test/data/file_creation_task/build')
-CLOBBER.include('test/data/file_creation_task/src')
+CLOBBER.include('doc/example/main')
 CLOBBER.include('TAGS')
 CLOBBER.include('coverage', 'rcov_aggregate')
 
@@ -107,9 +103,6 @@ rescue LoadError
   end
 end
 
-directory 'testdata'
-task :test => ['testdata']
-
 # CVS Tasks ----------------------------------------------------------
 
 # Install rake using the standard install.rb script.
@@ -149,13 +142,9 @@ PKG_FILES = FileList[
   '.gemtest',
   'install.rb',
   '[A-Z]*',
-  'bin/**/*',
+  'bin/rake',
   'lib/**/*.rb',
   'test/**/*.rb',
-  'test/**/*.rf',
-  'test/**/*.mf',
-  'test/**/Rakefile',
-  'test/**/subdir',
   'doc/**/*'
 ]
 PKG_FILES.exclude('doc/example/*.o')
@@ -163,44 +152,25 @@ PKG_FILES.exclude('TAGS')
 PKG_FILES.exclude(%r{doc/example/main$})
 
 if ! defined?(Gem)
-  puts "Package Target requires RubyGEMs"
+  puts "Package Target requires RubyGems"
 else
   SPEC = Gem::Specification.new do |s|
-
-    #### Basic information.
-
     s.name = 'rake'
     s.version = $package_version
     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.
+    s.description = <<-EOF.delete "\n"
+Rake is a Make-like program implemented in Ruby. Tasks and dependencies are
+specified in standard Ruby syntax.
     EOF
 
-    #### Dependencies and requirements.
-
+    s.required_ruby_version = '>= 1.8.6'
     s.required_rubygems_version = '>= 1.3.2'
     s.add_development_dependency 'minitest', '~> 2.1'
-    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.)
 
     s.files = PKG_FILES.to_a
 
-    #### C code extensions.
-
-    #s.extensions << "ext/rmagic/extconf.rb"
-
-    #### Load-time details: library and application (you will need one or both).
-
-    s.require_path = 'lib'                         # Use these for libraries.
-
-    s.bindir = "bin"                               # Use these for applications.
     s.executables = ["rake"]
 
-    #### Documentation and testing.
-
     s.extra_rdoc_files = FileList[
       'README.rdoc',
       'MIT-LICENSE',
@@ -211,16 +181,10 @@ else
 
     s.rdoc_options = BASE_RDOC_OPTIONS
 
-    #### Author and project details.
-
     s.author = "Jim Weirich"
     s.email = "jim at weirichhouse.org"
     s.homepage = "http://rake.rubyforge.org"
     s.rubyforge_project = "rake"
-#     if ENV['CERT_DIR']
-#       s.signing_key = File.join(ENV['CERT_DIR'], 'gem-private_key.pem')
-#       s.cert_chain  = [File.join(ENV['CERT_DIR'], 'gem-public_cert.pem')]
-#     end
   end
 
   Gem::PackageTask.new(SPEC) do |pkg|
diff --git a/bin/rake b/bin/rake
index 0de43c9..4e0bbb7 100755
--- a/bin/rake
+++ b/bin/rake
@@ -24,6 +24,7 @@
 
 begin
   require 'rubygems'
+  gem 'rake'
 rescue LoadError
 end
 
diff --git a/lib/rake.rb b/lib/rake.rb
index d88cf6c..fc1a6a5 100644
--- a/lib/rake.rb
+++ b/lib/rake.rb
@@ -23,7 +23,9 @@
 
 require 'rake/version'
 
+# :stopdoc:
 RAKEVERSION = Rake::VERSION
+# :startdoc:
 
 require 'rbconfig'
 require 'fileutils'
@@ -59,6 +61,8 @@ require 'rake/application'
 
 $trace = false
 
+# :stopdoc:
+#
 # Some top level Constants.
 
 FileList = Rake::FileList
diff --git a/lib/rake/application.rb b/lib/rake/application.rb
index 634a32d..2079fb9 100644
--- a/lib/rake/application.rb
+++ b/lib/rake/application.rb
@@ -22,6 +22,9 @@ module Rake
     # Name of the actual rakefile used.
     attr_reader :rakefile
 
+    # Number of columns on the terminal
+    attr_accessor :terminal_columns
+
     # List of the top level task names (task names from the command line).
     attr_reader :top_level_tasks
 
@@ -43,6 +46,7 @@ module Rake
       add_loader('rf', DefaultLoader.new)
       add_loader('rake', DefaultLoader.new)
       @tty_output = STDOUT.tty?
+      @terminal_columns = ENV['RAKE_COLUMNS'].to_i
     end
 
     # Run the Rake application.  The run method performs the following
@@ -198,7 +202,7 @@ module Rake
     # 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']
+      tty_output? || @terminal_columns.nonzero?
     end
 
     # Display the tasks and comments.
@@ -210,6 +214,7 @@ module Rake
       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
@@ -234,8 +239,8 @@ module Rake
     end
 
     def terminal_width
-      if ENV['RAKE_COLUMNS']
-        result = ENV['RAKE_COLUMNS'].to_i
+      if @terminal_columns.nonzero?
+        result = @terminal_columns
       else
         result = unix? ? dynamic_width : 80
       end
@@ -343,6 +348,7 @@ module Rake
         ],
         ['--rakelibdir', '--rakelib', '-R RAKELIBDIR',
           "Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib')",
+          # HACK Use File::PATH_SEPARATOR
           lambda { |value| options.rakelib = value.split(':') }
         ],
         ['--require', '-r MODULE', "Require MODULE before executing rakefile.",
diff --git a/lib/rake/classic_namespace.rb b/lib/rake/classic_namespace.rb
index d87aba0..6e71012 100644
--- a/lib/rake/classic_namespace.rb
+++ b/lib/rake/classic_namespace.rb
@@ -3,7 +3,9 @@
 # referenced Task from the top level.
 
 warn "WARNING: Classic namespaces are deprecated and will be removed from future versions of Rake."
+# :stopdoc:
 Task = Rake::Task
 FileTask = Rake::FileTask
 FileCreationTask = Rake::FileCreationTask
 RakeApp = Rake::Application
+# :startdoc:
diff --git a/lib/rake/clean.rb b/lib/rake/clean.rb
index 62f27d5..5c9cbcd 100644
--- a/lib/rake/clean.rb
+++ b/lib/rake/clean.rb
@@ -13,6 +13,7 @@
 
 require 'rake'
 
+# :stopdoc:
 CLEAN = Rake::FileList["**/*~", "**/*.bak", "**/core"]
 CLEAN.clear_exclude.exclude { |fn|
   fn.pathmap("%f") == 'core' && File.directory?(fn)
diff --git a/lib/rake/contrib/publisher.rb b/lib/rake/contrib/publisher.rb
index baa9a36..8b11edb 100644
--- a/lib/rake/contrib/publisher.rb
+++ b/lib/rake/contrib/publisher.rb
@@ -1,15 +1,19 @@
 # Copyright 2003-2010 by Jim Weirich (jim.weirich at gmail.com)
 # All rights reserved.
 
+# :stopdoc:
+
 # Configuration information about an upload host system.
-# * name   :: Name of host system.
-# * webdir :: Base directory for the web information for the
-#             application.  The application name (APP) is appended to
-#             this directory before using.
-# * pkgdir :: Directory on the host system where packages can be
-#             placed.
+# name   :: Name of host system.
+# webdir :: Base directory for the web information for the
+#           application.  The application name (APP) is appended to
+#           this directory before using.
+# pkgdir :: Directory on the host system where packages can be
+#           placed.
 HostInfo = Struct.new(:name, :webdir, :pkgdir)
 
+# :startdoc:
+
 # Manage several publishers as a single entity.
 class CompositePublisher
   def initialize
diff --git a/lib/rake/contrib/sshpublisher.rb b/lib/rake/contrib/sshpublisher.rb
index e679716..bd6adc1 100644
--- a/lib/rake/contrib/sshpublisher.rb
+++ b/lib/rake/contrib/sshpublisher.rb
@@ -1,3 +1,4 @@
+require 'rake/dsl_definition'
 require 'rake/contrib/compositepublisher'
 
 module Rake
@@ -5,6 +6,8 @@ module Rake
   # Publish an entire directory to an existing remote directory using
   # SSH.
   class SshDirPublisher
+    include Rake::DSL
+
     def initialize(host, remote_dir, local_dir)
       @host = host
       @remote_dir = remote_dir
@@ -27,6 +30,8 @@ module Rake
 
   # Publish a list of files to an existing remote directory.
   class SshFilePublisher
+    include Rake::DSL
+
     # Create a publisher using the give host information.
     def initialize(host, remote_dir, local_dir, *files)
       @host = host
diff --git a/lib/rake/dsl_definition.rb b/lib/rake/dsl_definition.rb
index e0b9c6f..6d9a6b8 100644
--- a/lib/rake/dsl_definition.rb
+++ b/lib/rake/dsl_definition.rb
@@ -2,11 +2,18 @@
 require 'rake/file_utils_ext'
 
 module Rake
+
+  ##
+  # DSL is a module that provides #task, #desc, #namespace, etc.  Use this
+  # when you'd like to use rake outside the top level scope.
+
   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))
@@ -137,10 +144,12 @@ module Rake
         Rake.application.add_import(fn)
       end
     end
+
   end
 
-  module DeprecatedObjectDSL
-    Commands = Object.new.extend DSL
+  DeprecatedCommands = Object.new.extend(DSL)
+
+  module DeprecatedObjectDSL # :nodoc:
     DSL.private_instance_methods(false).each do |name|
       line = __LINE__+1
       class_eval %{
@@ -153,8 +162,8 @@ module Rake
             end
             $stderr.puts "WARNING: DSL method \#{self.class}##{name} called at \#{caller.first}"
           end
-          Rake::DeprecatedObjectDSL::Commands.send(:#{name}, *args, &block)
-          end
+          Rake::DeprecatedCommands.send(:#{name}, *args, &block)
+        end
         private :#{name}
       }, __FILE__, line
     end
diff --git a/lib/rake/ext/time.rb b/lib/rake/ext/time.rb
index ca3ea2a..7877abf 100644
--- a/lib/rake/ext/time.rb
+++ b/lib/rake/ext/time.rb
@@ -1,6 +1,6 @@
-# ###########################################################################
+#--
 # Extensions to time to allow comparisons with an early time class.
-#
+
 class Time
   alias rake_original_time_compare :<=>
   def <=>(other)
@@ -10,5 +10,5 @@ class Time
       rake_original_time_compare(other)
     end
   end
-end # class Time
+end
 
diff --git a/lib/rake/file_utils.rb b/lib/rake/file_utils.rb
index 9e0198e..e02d541 100644
--- a/lib/rake/file_utils.rb
+++ b/lib/rake/file_utils.rb
@@ -1,10 +1,9 @@
 require 'rbconfig'
 require 'fileutils'
 
-# ###########################################################################
+#--
 # This a FileUtils extension that defines several additional commands to be
 # added to the FileUtils utility functions.
-#
 module FileUtils
   # Path to the currently running Ruby program
   RUBY = File.join(
@@ -38,6 +37,7 @@ module FileUtils
     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]
       res = rake_system(*cmd)
       status = $?
@@ -46,7 +46,7 @@ module FileUtils
     end
   end
 
-  def create_shell_runner(cmd)
+  def create_shell_runner(cmd) # :nodoc:
     show_command = cmd.join(" ")
     show_command = show_command[0,42] + "..." unless $trace
     lambda { |ok, status|
@@ -55,14 +55,16 @@ module FileUtils
   end
   private :create_shell_runner
 
-  def set_verbose_option(options)
-    if options[:verbose].nil?
-      options[:verbose] = Rake::FileUtilsExt.verbose_flag.nil? || Rake::FileUtilsExt.verbose_flag
+  def set_verbose_option(options) # :nodoc:
+    unless options.key? :verbose
+      options[:verbose] =
+        Rake::FileUtilsExt.verbose_flag == Rake::FileUtilsExt::DEFAULT ||
+        Rake::FileUtilsExt.verbose_flag
     end
   end
   private :set_verbose_option
 
-  def rake_system(*cmd)
+  def rake_system(*cmd) # :nodoc:
     Rake::AltSystem.system(*cmd)
   end
   private :rake_system
diff --git a/lib/rake/file_utils_ext.rb b/lib/rake/file_utils_ext.rb
index 7c22f80..557420d 100644
--- a/lib/rake/file_utils_ext.rb
+++ b/lib/rake/file_utils_ext.rb
@@ -12,7 +12,10 @@ module Rake
     class << self
       attr_accessor :verbose_flag, :nowrite_flag
     end
-    FileUtilsExt.verbose_flag = nil
+
+    DEFAULT = Object.new
+
+    FileUtilsExt.verbose_flag = DEFAULT
     FileUtilsExt.nowrite_flag = false
 
     $fileutils_verbose = true
diff --git a/lib/rake/gempackagetask.rb b/lib/rake/gempackagetask.rb
index 51e9223..5f1fc4d 100644
--- a/lib/rake/gempackagetask.rb
+++ b/lib/rake/gempackagetask.rb
@@ -7,6 +7,8 @@ require 'rubygems/package_task'
 
 require 'rake'
 
+# :stopdoc:
+
 module Rake
   GemPackageTask = Gem::PackageTask
 end
diff --git a/lib/rake/rake_test_loader.rb b/lib/rake/rake_test_loader.rb
index 045a12f..7e3a6b3 100644
--- a/lib/rake/rake_test_loader.rb
+++ b/lib/rake/rake_test_loader.rb
@@ -1,13 +1,22 @@
 require 'rake'
 
 # Load the test files from the command line.
+argv = ARGV.select do |argument|
+  case argument
+  when /^-/ then
+    argument
+  when /\*/ then
+    FileList[argument].to_a.each do |file|
+      require File.expand_path file
+    end
 
-ARGV.each do |f|
-  next if f =~ /^-/
-
-  if f =~ /\*/
-    FileList[f].to_a.each { |fn| require File.expand_path(fn) }
+    false
   else
-    require File.expand_path(f)
+    require File.expand_path argument
+
+    false
   end
 end
+
+ARGV.replace argv
+
diff --git a/lib/rake/rdoctask.rb b/lib/rake/rdoctask.rb
index a011684..b6ae224 100644
--- a/lib/rake/rdoctask.rb
+++ b/lib/rake/rdoctask.rb
@@ -1,6 +1,8 @@
 # rake/rdoctask is deprecated in favor of rdoc/task
 
-warn 'rake/rdoctask is deprecated.  Use rdoc/task instead (in RDoc 2.4.2+)'
+if Rake.application
+  Rake.application.deprecate('require \'rake/rdoctask\'', 'require \'rdoc/task\' (in RDoc 2.4.2+)', __FILE__)
+end
 
 require 'rubygems'
 
@@ -11,6 +13,8 @@ begin
 rescue LoadError, Gem::LoadError
 end
 
+# :stopdoc:
+
 if defined?(RDoc::Task) then
   module Rake
     RDocTask = RDoc::Task unless const_defined? :RDocTask
diff --git a/lib/rake/task_arguments.rb b/lib/rake/task_arguments.rb
index ab404d6..02d01b9 100644
--- a/lib/rake/task_arguments.rb
+++ b/lib/rake/task_arguments.rb
@@ -43,6 +43,10 @@ module Rake
       @hash.each(&block)
     end
 
+    def values_at(*keys)
+      keys.map { |k| lookup(k) }
+    end
+
     def method_missing(sym, *args, &block)
       lookup(sym.to_sym)
     end
diff --git a/lib/rake/version.rb b/lib/rake/version.rb
index dbad21e..4e9f35f 100644
--- a/lib/rake/version.rb
+++ b/lib/rake/version.rb
@@ -1,10 +1,8 @@
 module Rake
-  module Version
-    NUMBERS = [
-      MAJOR = 0,
-      MINOR = 9,
-      BUILD = 2,
-    ]
+  VERSION = '0.9.2.2'
+
+  module Version # :nodoc: all
+    MAJOR, MINOR, BUILD, PATCH = VERSION.split('.')
+    NUMBERS = [ MAJOR, MINOR, BUILD, PATCH ]
   end
-  VERSION = Version::NUMBERS.join('.')
 end
diff --git a/metadata.yml b/metadata.yml
index b1e0be4..2b08289 100644
--- a/metadata.yml
+++ b/metadata.yml
@@ -2,7 +2,7 @@
 name: rake
 version: !ruby/object:Gem::Version 
   prerelease: 
-  version: 0.9.2
+  version: 0.9.2.2
 platform: ruby
 authors: 
 - Jim Weirich
@@ -10,7 +10,7 @@ autorequire:
 bindir: bin
 cert_chain: []
 
-date: 2011-06-05 00:00:00 Z
+date: 2011-10-22 00:00:00 Z
 dependencies: 
 - !ruby/object:Gem::Dependency 
   name: minitest
@@ -23,29 +23,7 @@ dependencies:
         version: "2.1"
   type: :development
   version_requirements: *id001
-- !ruby/object:Gem::Dependency 
-  name: session
-  prerelease: false
-  requirement: &id002 !ruby/object:Gem::Requirement 
-    none: false
-    requirements: 
-    - - ~>
-      - !ruby/object:Gem::Version 
-        version: "2.4"
-  type: :development
-  version_requirements: *id002
-- !ruby/object:Gem::Dependency 
-  name: flexmock
-  prerelease: false
-  requirement: &id003 !ruby/object:Gem::Requirement 
-    none: false
-    requirements: 
-    - - ~>
-      - !ruby/object:Gem::Version 
-        version: 0.8.11
-  type: :development
-  version_requirements: *id003
-description: "      Rake is a Make-like program implemented in Ruby. Tasks\n      and dependencies are specified in standard Ruby syntax.\n"
+description: Rake is a Make-like program implemented in Ruby. Tasks and dependencies arespecified in standard Ruby syntax.
 email: jim at weirichhouse.org
 executables: 
 - rake
@@ -88,7 +66,6 @@ files:
 - MIT-LICENSE
 - Rakefile
 - README.rdoc
-- RRR
 - TODO
 - bin/rake
 - lib/rake/alt_system.rb
@@ -138,16 +115,8 @@ files:
 - lib/rake/version.rb
 - lib/rake/win32.rb
 - lib/rake.rb
-- test/check_expansion.rb
-- test/check_no_expansion.rb
-- test/data/rakelib/test1.rb
-- test/data/rbext/rakefile.rb
 - test/file_creation.rb
 - test/helper.rb
-- test/in_environment.rb
-- test/reqfile.rb
-- test/reqfile2.rb
-- test/shellcommand.rb
 - test/test_rake.rb
 - test/test_rake_application.rb
 - test/test_rake_application_options.rb
@@ -173,6 +142,7 @@ files:
 - test/test_rake_path_map_explode.rb
 - test/test_rake_path_map_partial.rb
 - test/test_rake_pseudo_status.rb
+- test/test_rake_rake_test_loader.rb
 - test/test_rake_rdoc_task.rb
 - test/test_rake_require.rb
 - test/test_rake_rules.rb
@@ -187,22 +157,6 @@ files:
 - test/test_rake_top_level_functions.rb
 - test/test_rake_win32.rb
 - test/test_sys.rb
-- test/data/imports/deps.mf
-- test/data/sample.mf
-- test/data/access/Rakefile
-- test/data/chains/Rakefile
-- test/data/comments/Rakefile
-- test/data/default/Rakefile
-- test/data/deprecated_import/Rakefile
-- test/data/dryrun/Rakefile
-- test/data/extra/Rakefile
-- test/data/file_creation_task/Rakefile
-- test/data/imports/Rakefile
-- test/data/multidesc/Rakefile
-- test/data/namespace/Rakefile
-- test/data/statusreturn/Rakefile
-- test/data/unittest/Rakefile
-- test/data/verbose/Rakefile
 - doc/command_line_usage.rdoc
 - doc/example/a.c
 - doc/example/b.c
@@ -253,7 +207,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
   requirements: 
   - - ">="
     - !ruby/object:Gem::Version 
-      version: "0"
+      version: 1.8.6
 required_rubygems_version: !ruby/object:Gem::Requirement 
   none: false
   requirements: 
@@ -263,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
 requirements: []
 
 rubyforge_project: rake
-rubygems_version: 1.8.3
+rubygems_version: 1.8.11
 signing_key: 
 specification_version: 3
 summary: Ruby based make-like utility.
diff --git a/test/check_expansion.rb b/test/check_expansion.rb
deleted file mode 100644
index 659cf71..0000000
--- a/test/check_expansion.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-if ARGV[0] != ARGV[1]
-  exit 1
-else
-  exit 0
-end
diff --git a/test/check_no_expansion.rb b/test/check_no_expansion.rb
deleted file mode 100644
index 24f586a..0000000
--- a/test/check_no_expansion.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-if ARGV[0] != ARGV[1]
-  exit 0
-else
-  exit 1
-end
diff --git a/test/data/access/Rakefile b/test/data/access/Rakefile
deleted file mode 100644
index c064cac..0000000
--- a/test/data/access/Rakefile
+++ /dev/null
@@ -1,35 +0,0 @@
-TOP_LEVEL_CONSTANT = 0
-
-def a_top_level_function
-end
-
-task :default => [:work, :obj, :const]
-
-task :work do
-  begin
-    a_top_level_function
-    puts "GOOD:M Top level methods can be called in tasks"
-  rescue NameError => ex
-    puts "BAD:M  Top level methods can not be called in tasks"
-  end
-end
-
-# TODO: remove `disabled_' when DeprecatedObjectDSL removed
-task :obj
-task :disabled_obj do
-  begin
-    Object.new.instance_eval { task :xyzzy }
-    puts "BAD:D  Rake DSL are polluting objects"
-  rescue StandardError => ex
-    puts "GOOD:D Rake DSL are not polluting objects"
-  end
-end
-
-task :const do
-  begin
-    TOP_LEVEL_CONSTANT
-    puts "GOOD:C Top level constants are available in tasks"
-  rescue StandardError => ex
-    puts "BAD:C  Top level constants are NOT available in tasks"
-  end
-end
diff --git a/test/data/chains/Rakefile b/test/data/chains/Rakefile
deleted file mode 100644
index 31bdc25..0000000
--- a/test/data/chains/Rakefile
+++ /dev/null
@@ -1,15 +0,0 @@
-# -*- ruby -*-
-
-task :default => "play.app"
-
-file "play.scpt" => "base" do |t|
-  cp t.prerequisites.first, t.name
-end
-
-rule ".app" => ".scpt" do |t|
-  cp t.source, t.name
-end
-
-file 'base' do
-  touch 'base'
-end
diff --git a/test/data/comments/Rakefile b/test/data/comments/Rakefile
deleted file mode 100644
index 499e85c..0000000
--- a/test/data/comments/Rakefile
+++ /dev/null
@@ -1,18 +0,0 @@
-# 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
diff --git a/test/data/default/Rakefile b/test/data/default/Rakefile
deleted file mode 100644
index 4c1091b..0000000
--- a/test/data/default/Rakefile
+++ /dev/null
@@ -1,17 +0,0 @@
-if ENV['TESTTOPSCOPE']
-  puts "TOPSCOPE"
-end
-
-task :default do
-  puts "DEFAULT"
-end
-
-task :other => [:default] do
-  puts "OTHER"
-end
-
-task :task_scope do
-  if ENV['TESTTASKSCOPE']
-    puts "TASKSCOPE"
-  end
-end
diff --git a/test/data/deprecated_import/Rakefile b/test/data/deprecated_import/Rakefile
deleted file mode 100644
index 4c80e97..0000000
--- a/test/data/deprecated_import/Rakefile
+++ /dev/null
@@ -1 +0,0 @@
-import "a"
diff --git a/test/data/dryrun/Rakefile b/test/data/dryrun/Rakefile
deleted file mode 100644
index 370e0d6..0000000
--- a/test/data/dryrun/Rakefile
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-
-task :default => ["temp_main"]
-
-file "temp_main" => [:all_apps]  do touch "temp_main" end
-
-task :all_apps => [:one, :two]
-task :one => ["temp_one"]
-task :two => ["temp_two"]
-
-file "temp_one" do |t|
-  touch "temp_one"
-end
-file "temp_two" do |t|
-  touch "temp_two"
-end
-
-task :clean do
-  ["temp_one", "temp_two", "temp_main"].each do |file|
-    rm_f file
-  end
-end
diff --git a/test/data/extra/Rakefile b/test/data/extra/Rakefile
deleted file mode 100644
index 5cfd6d9..0000000
--- a/test/data/extra/Rakefile
+++ /dev/null
@@ -1 +0,0 @@
-task :default
diff --git a/test/data/file_creation_task/Rakefile b/test/data/file_creation_task/Rakefile
deleted file mode 100644
index 3789a0a..0000000
--- a/test/data/file_creation_task/Rakefile
+++ /dev/null
@@ -1,31 +0,0 @@
-N = 2
-
-task :default => :run
-
-BUILD_DIR = 'build'
-task :clean do
-  rm_rf 'build'
-  rm_rf 'src'
-end
-
-task :run
-
-TARGET_DIR = 'build/copies'
-
-FileList['src/*'].each do |src|
-  directory TARGET_DIR
-  target = File.join TARGET_DIR, File.basename(src)
-  file target => [src, TARGET_DIR] do
-    cp src, target
-    # sleep 3 if src !~ /foo#{N-1}$/   # I'm commenting out this sleep, it doesn't seem to do anything.
-  end
-  task :run => target
-end
-
-task :prep => :clean do
-  mkdir_p 'src'
-  N.times do |n|
-    puts "DBG: Touching src/foo#{n}"
-    touch "src/foo#{n}"
-  end
-end
diff --git a/test/data/imports/Rakefile b/test/data/imports/Rakefile
deleted file mode 100644
index 6a60f61..0000000
--- a/test/data/imports/Rakefile
+++ /dev/null
@@ -1,19 +0,0 @@
-# -*- ruby -*-
-
-require 'rake/loaders/makefile'
-
-task :default
-
-task :other do
-  puts "OTHER"
-end
-
-file "dynamic_deps" do |t|
-  open(t.name, "w") do |f| f.puts "puts 'DYNAMIC'" end
-end
-
-import "dynamic_deps"
-import "static_deps"
-import "static_deps"
-import "deps.mf"
-puts "FIRST"
diff --git a/test/data/imports/deps.mf b/test/data/imports/deps.mf
deleted file mode 100644
index 04643d0..0000000
--- a/test/data/imports/deps.mf
+++ /dev/null
@@ -1 +0,0 @@
-default: other
diff --git a/test/data/multidesc/Rakefile b/test/data/multidesc/Rakefile
deleted file mode 100644
index 32d45e3..0000000
--- a/test/data/multidesc/Rakefile
+++ /dev/null
@@ -1,15 +0,0 @@
-task :b
-
-desc "A"
-task :a
-
-desc "B"
-task :b
-
-desc "A2"
-task :a
-
-task :c
-
-desc "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
-task :d
diff --git a/test/data/namespace/Rakefile b/test/data/namespace/Rakefile
deleted file mode 100644
index a47271c..0000000
--- a/test/data/namespace/Rakefile
+++ /dev/null
@@ -1,64 +0,0 @@
-desc "copy"
-task :copy do
-  puts "COPY"
-end
-
-namespace "nest" do
-  desc "nest copy"
-  task :copy do
-    puts "NEST COPY"
-  end
-  task :xx => :copy
-end
-
-anon_ns = namespace do
-  desc "anonymous copy task"
-  task :copy do
-    puts "ANON COPY"
-  end
-end
-
-desc "Top level task to run the anonymous version of copy"
-task :anon => anon_ns[:copy]
-
-namespace "very" do
-  namespace "nested" do
-    task "run" => "rake:copy"
-  end
-end
-
-namespace "a" do
-  desc "Run task in the 'a' namespace"
-  task "run" do
-    puts "IN A"
-  end
-end
-
-namespace "b" do
-  desc "Run task in the 'b' namespace"
-  task "run" => "a:run" do
-    puts "IN B"
-  end
-end
-
-namespace "file1" do
-  file "xyz.rb" do
-    puts "XYZ1"
-  end
-end
-
-namespace "file2" do
-  file "xyz.rb" do
-    puts "XYZ2"
-  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/data/rakelib/test1.rb b/test/data/rakelib/test1.rb
deleted file mode 100644
index 8a1ca25..0000000
--- a/test/data/rakelib/test1.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-
-task :default do
-  puts "TEST1"
-end
diff --git a/test/data/rbext/rakefile.rb b/test/data/rbext/rakefile.rb
deleted file mode 100644
index 670604d..0000000
--- a/test/data/rbext/rakefile.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-task :default do
-  puts "OK"
-end
diff --git a/test/data/sample.mf b/test/data/sample.mf
deleted file mode 100644
index 778e9d4..0000000
--- a/test/data/sample.mf
+++ /dev/null
@@ -1,14 +0,0 @@
-# Comments
-a: a1 a2 a3 a4
-b: b1 b2 b3 \
-   b4 b5 b6\
-# Mid: Comment
-b7
-
- a : a5 a6 a7
-c: c1
-d: d1 d2 \
-
-e f : e1 f1
-
-g\ 0: g1 g\ 2 g\ 3 g4
diff --git a/test/data/statusreturn/Rakefile b/test/data/statusreturn/Rakefile
deleted file mode 100644
index 8578564..0000000
--- a/test/data/statusreturn/Rakefile
+++ /dev/null
@@ -1,6 +0,0 @@
-task :exit5 do
-  exit(5)
-end
-
-task :normal do
-end
diff --git a/test/data/unittest/Rakefile b/test/data/unittest/Rakefile
deleted file mode 100644
index 9c3b8ac..0000000
--- a/test/data/unittest/Rakefile
+++ /dev/null
@@ -1 +0,0 @@
-# Empty Rakefile for Unit Test
diff --git a/test/data/verbose/Rakefile b/test/data/verbose/Rakefile
deleted file mode 100644
index 08b19b9..0000000
--- a/test/data/verbose/Rakefile
+++ /dev/null
@@ -1,34 +0,0 @@
-
-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/file_creation.rb b/test/file_creation.rb
index 7d28e70..facc57a 100644
--- a/test/file_creation.rb
+++ b/test/file_creation.rb
@@ -1,6 +1,6 @@
 module FileCreation
-  OLDFILE = "testdata/old"
-  NEWFILE = "testdata/new"
+  OLDFILE = "old"
+  NEWFILE = "new"
 
   def create_timed_files(oldfile, *newfiles)
     return if (File.exist?(oldfile) &&
diff --git a/test/helper.rb b/test/helper.rb
index 3616c07..65443fc 100644
--- a/test/helper.rb
+++ b/test/helper.rb
@@ -1,16 +1,22 @@
 require 'rubygems'
-require 'minitest/unit'
-require 'flexmock/test_unit_integration'
+
+begin
+  gem 'minitest'
+rescue Gem::LoadError
+end
+
 require 'minitest/autorun'
 require 'rake'
+require 'tmpdir'
 require File.expand_path('../file_creation', __FILE__)
-require File.expand_path('../in_environment', __FILE__)
 
-class Rake::TestCase < MiniTest::Unit::TestCase
-  include FlexMock::ArgumentTypes
-  include FlexMock::MockContainer
+begin
+  require 'test/ruby/envutil'
+rescue LoadError
+  # for ruby trunk
+end
 
-  include InEnvironment
+class Rake::TestCase < MiniTest::Unit::TestCase
   include FileCreation
 
   include Rake::DSL
@@ -19,14 +25,53 @@ class Rake::TestCase < MiniTest::Unit::TestCase
     include Rake::TaskManager
   end
 
+  RUBY = defined?(EnvUtil) ? EnvUtil.rubybin : Gem.ruby
+
   def setup
+    ARGV.clear
+
     @orig_PWD = Dir.pwd
+    @orig_APPDATA      = ENV['APPDATA']
+    @orig_HOME         = ENV['HOME']
+    @orig_HOMEDRIVE    = ENV['HOMEDRIVE']
+    @orig_HOMEPATH     = ENV['HOMEPATH']
+    @orig_RAKE_COLUMNS = ENV['RAKE_COLUMNS']
+    @orig_RAKE_SYSTEM  = ENV['RAKE_SYSTEM']
+    @orig_RAKEOPT      = ENV['RAKEOPT']
+    @orig_USERPROFILE  = ENV['USERPROFILE']
+    ENV.delete 'RAKE_COLUMNS'
+    ENV.delete 'RAKE_SYSTEM'
+    ENV.delete 'RAKEOPT'
+
+    tmpdir = Dir.chdir Dir.tmpdir do Dir.pwd end
+    @tempdir = File.join tmpdir, "test_rake_#{$$}"
+
+    FileUtils.mkdir_p @tempdir
+
+    Dir.chdir @tempdir
+
+    Rake.application = Rake::Application.new
+    Rake::TaskManager.record_task_metadata = true
+    RakeFileUtils.verbose_flag = false
   end
 
   def teardown
-    flexmock_teardown
-
     Dir.chdir @orig_PWD
+    FileUtils.rm_rf @tempdir
+
+    if @orig_APPDATA then
+      ENV['APPDATA'] = @orig_APPDATA
+    else
+      ENV.delete 'APPDATA'
+    end
+
+    ENV['HOME']         = @orig_HOME
+    ENV['HOMEDRIVE']    = @orig_HOMEDRIVE
+    ENV['HOMEPATH']     = @orig_HOMEPATH
+    ENV['RAKE_COLUMNS'] = @orig_RAKE_COLUMNS
+    ENV['RAKE_SYSTEM']  = @orig_RAKE_SYSTEM
+    ENV['RAKEOPT']      = @orig_RAKEOPT
+    ENV['USERPROFILE']  = @orig_USERPROFILE
   end
 
   def ignore_deprecations
@@ -36,9 +81,412 @@ class Rake::TestCase < MiniTest::Unit::TestCase
     Rake.application.options.ignore_deprecate = false
   end
 
+  def rake_system_dir
+    @system_dir = 'system'
+
+    FileUtils.mkdir_p @system_dir
+
+    open File.join(@system_dir, 'sys1.rake'), 'w' do |io|
+      io << <<-SYS
+task "sys1" do
+  puts "SYS1"
+end
+      SYS
+    end
+
+    ENV['RAKE_SYSTEM'] = @system_dir
+  end
+
+  def rakefile contents
+    open 'Rakefile', 'w' do |io|
+      io << contents
+    end
+  end
+
+  def rakefile_access
+    rakefile <<-ACCESS
+TOP_LEVEL_CONSTANT = 0
+
+def a_top_level_function
+end
+
+task :default => [:work, :obj, :const]
+
+task :work do
+  begin
+    a_top_level_function
+    puts "GOOD:M Top level methods can be called in tasks"
+  rescue NameError => ex
+    puts "BAD:M  Top level methods can not be called in tasks"
+  end
+end
+
+# TODO: remove `disabled_' when DeprecatedObjectDSL removed
+task :obj
+task :disabled_obj do
+  begin
+    Object.new.instance_eval { task :xyzzy }
+    puts "BAD:D  Rake DSL are polluting objects"
+  rescue StandardError => ex
+    puts "GOOD:D Rake DSL are not polluting objects"
+  end
+end
+
+task :const do
+  begin
+    TOP_LEVEL_CONSTANT
+    puts "GOOD:C Top level constants are available in tasks"
+  rescue StandardError => ex
+    puts "BAD:C  Top level constants are NOT available in tasks"
+  end
+end
+    ACCESS
+  end
+
+  def rakefile_chains
+    rakefile <<-DEFAULT
+task :default => "play.app"
+
+file "play.scpt" => "base" do |t|
+  cp t.prerequisites.first, t.name
+end
+
+rule ".app" => ".scpt" do |t|
+  cp t.source, t.name
+end
+
+file 'base' do
+  touch 'base'
+end
+    DEFAULT
+  end
+
+  def rakefile_comments
+    rakefile <<-COMMENTS
+# 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
+    COMMENTS
+  end
+
+  def rakefile_default
+    rakefile <<-DEFAULT
+if ENV['TESTTOPSCOPE']
+  puts "TOPSCOPE"
+end
+
+task :default do
+  puts "DEFAULT"
+end
+
+task :other => [:default] do
+  puts "OTHER"
+end
+
+task :task_scope do
+  if ENV['TESTTASKSCOPE']
+    puts "TASKSCOPE"
+  end
+end
+    DEFAULT
+  end
+
+  def rakefile_dryrun
+    rakefile <<-DRYRUN
+task :default => ["temp_main"]
+
+file "temp_main" => [:all_apps]  do touch "temp_main" end
+
+task :all_apps => [:one, :two]
+task :one => ["temp_one"]
+task :two => ["temp_two"]
+
+file "temp_one" do |t|
+  touch "temp_one"
+end
+file "temp_two" do |t|
+  touch "temp_two"
+end
+
+task :clean do
+  ["temp_one", "temp_two", "temp_main"].each do |file|
+    rm_f file
+  end
+end
+    DRYRUN
+
+    FileUtils.touch 'temp_main'
+    FileUtils.touch 'temp_two'
+  end
+
+  def rakefile_extra
+    rakefile 'task :default'
+
+    FileUtils.mkdir_p 'rakelib'
+
+    open File.join('rakelib', 'extra.rake'), 'w' do |io|
+      io << <<-EXTRA_RAKE
+# Added for testing
+
+namespace :extra do
+  desc "An Extra Task"
+  task :extra do
+    puts "Read all about it"
+  end
+end
+      EXTRA_RAKE
+    end
+  end
+
+  def rakefile_file_creation
+    rakefile <<-'FILE_CREATION'
+N = 2
+
+task :default => :run
+
+BUILD_DIR = 'build'
+task :clean do
+  rm_rf 'build'
+  rm_rf 'src'
+end
+
+task :run
+
+TARGET_DIR = 'build/copies'
+
+FileList['src/*'].each do |src|
+  directory TARGET_DIR
+  target = File.join TARGET_DIR, File.basename(src)
+  file target => [src, TARGET_DIR] do
+    cp src, target
+    # sleep 3 if src !~ /foo#{N-1}$/   # I'm commenting out this sleep, it doesn't seem to do anything.
+  end
+  task :run => target
+end
+
+task :prep => :clean do
+  mkdir_p 'src'
+  N.times do |n|
+    touch "src/foo#{n}"
+  end
+end
+    FILE_CREATION
+  end
+
+  def rakefile_imports
+    rakefile <<-IMPORTS
+require 'rake/loaders/makefile'
+
+task :default
+
+task :other do
+  puts "OTHER"
+end
+
+file "dynamic_deps" do |t|
+  open(t.name, "w") do |f| f.puts "puts 'DYNAMIC'" end
+end
+
+import "dynamic_deps"
+import "static_deps"
+import "static_deps"
+import "deps.mf"
+puts "FIRST"
+    IMPORTS
+
+    open 'deps.mf', 'w' do |io|
+      io << <<-DEPS
+default: other
+      DEPS
+    end
+
+    open "static_deps", "w" do |f|
+      f.puts 'puts "STATIC"'
+    end
+  end
+
+  def rakefile_multidesc
+    rakefile <<-MULTIDESC
+task :b
+
+desc "A"
+task :a
+
+desc "B"
+task :b
+
+desc "A2"
+task :a
+
+task :c
+
+desc "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
+task :d
+    MULTIDESC
+  end
+
+  def rakefile_namespace
+    rakefile <<-NAMESPACE
+desc "copy"
+task :copy do
+  puts "COPY"
+end
+
+namespace "nest" do
+  desc "nest copy"
+  task :copy do
+    puts "NEST COPY"
+  end
+  task :xx => :copy
+end
+
+anon_ns = namespace do
+  desc "anonymous copy task"
+  task :copy do
+    puts "ANON COPY"
+  end
+end
+
+desc "Top level task to run the anonymous version of copy"
+task :anon => anon_ns[:copy]
+
+namespace "very" do
+  namespace "nested" do
+    task "run" => "rake:copy"
+  end
+end
+
+namespace "a" do
+  desc "Run task in the 'a' namespace"
+  task "run" do
+    puts "IN A"
+  end
+end
+
+namespace "b" do
+  desc "Run task in the 'b' namespace"
+  task "run" => "a:run" do
+    puts "IN B"
+  end
+end
+
+namespace "file1" do
+  file "xyz.rb" do
+    puts "XYZ1"
+  end
+end
+
+namespace "file2" do
+  file "xyz.rb" do
+    puts "XYZ2"
+  end
+end
+
+namespace "scopedep" do
+  task :prepare do
+    touch "scopedep.rb"
+    puts "PREPARE"
+  end
+  file "scopedep.rb" => [:prepare] do
+    puts "SCOPEDEP"
+  end
+end
+    NAMESPACE
+  end
+
+  def rakefile_nosearch
+    FileUtils.touch 'dummy'
+  end
+
+  def rakefile_rakelib
+    FileUtils.mkdir_p 'rakelib'
+
+    Dir.chdir 'rakelib' do
+      open 'test1.rb', 'w' do |io|
+        io << <<-TEST1
+task :default do
+  puts "TEST1"
 end
+        TEST1
+      end
+
+      open 'test2.rake', 'w' do |io|
+        io << <<-TEST1
+task :default do
+  puts "TEST2"
+end
+        TEST1
+      end
+    end
+  end
+
+  def rakefile_rbext
+    open 'rakefile.rb', 'w' do |io|
+      io << 'task :default do puts "OK" end'
+    end
+  end
+
+  def rakefile_unittest
+    rakefile '# Empty Rakefile for Unit Test'
 
-# workarounds for 1.8
-$" << 'test/helper.rb'
-Test::Unit.run = true if Test::Unit.respond_to? :run=
+    readme = File.join 'subdir', 'README'
+    FileUtils.mkdir_p File.dirname readme
+
+    FileUtils.touch readme
+  end
+
+  def rakefile_verbose
+    rakefile <<-VERBOSE
+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
+    VERBOSE
+  end
+
+end
 
diff --git a/test/in_environment.rb b/test/in_environment.rb
deleted file mode 100644
index fb62a22..0000000
--- a/test/in_environment.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-module InEnvironment
-  private
-
-  # 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=nil)
-    settings ||= {}
-    full_settings = {"RAKEOPT" => nil}.merge(settings)
-    original_settings = set_env(full_settings)
-    yield
-  ensure
-    set_env(original_settings) rescue nil
-  end
-
-  # Set the environment according to the settings hash.
-  def set_env(settings) # :nodoc:
-    result = {}
-
-    settings.each do |k, v|
-      result[k] = ENV[k]
-
-      if k == 'PWD'
-        result[k] = Dir.pwd
-        Dir.chdir(v)
-      elsif v.nil?
-        ENV.delete(k)
-      else
-        ENV[k] = v
-      end
-    end
-
-    result
-  end
-
-end
diff --git a/test/reqfile.rb b/test/reqfile.rb
deleted file mode 100644
index 5372544..0000000
--- a/test/reqfile.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-# For --require testing
-
-TESTING_REQUIRE << 1
diff --git a/test/reqfile2.rb b/test/reqfile2.rb
deleted file mode 100644
index 6599390..0000000
--- a/test/reqfile2.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-# For --require testing
-
-TESTING_REQUIRE << 2
diff --git a/test/shellcommand.rb b/test/shellcommand.rb
deleted file mode 100755
index 58db8a0..0000000
--- a/test/shellcommand.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env ruby
-
-exit((ARGV[0] || "0").to_i)
diff --git a/test/test_rake.rb b/test/test_rake.rb
index f9552cd..b2a3928 100644
--- a/test/test_rake.rb
+++ b/test/test_rake.rb
@@ -26,13 +26,15 @@ class TestRake < Rake::TestCase
     old_app = Rake.application
     fake_app = Object.new
     Rake.application = fake_app
+
     assert_equal fake_app, Rake.application
+
   ensure
     Rake.application = old_app
   end
 
   def test_original_dir_reports_current_dir
-    assert_equal Dir.pwd, Rake.original_dir
+    assert_equal @tempdir, Rake.original_dir
   end
 
 end
diff --git a/test/test_rake_application.rb b/test/test_rake_application.rb
index 4a99cf6..b5d8c65 100644
--- a/test/test_rake_application.rb
+++ b/test/test_rake_application.rb
@@ -1,20 +1,12 @@
 require File.expand_path('../helper', __FILE__)
 
 class TestRakeApplication < Rake::TestCase
-  include InEnvironment
 
   def setup
     super
 
-    @app = Rake::Application.new
+    @app = Rake.application
     @app.options.rakelib = []
-    Rake::TaskManager.record_task_metadata = true
-  end
-
-  def teardown
-    Rake::TaskManager.record_task_metadata = false
-
-    super
   end
 
   def test_constant_warning
@@ -35,28 +27,30 @@ class TestRakeApplication < Rake::TestCase
   end
 
   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")
-      out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
-      assert_match(/^rake t/, out)
-      assert_match(/# 12345678901234567890123456789012345678901234567890123456789012345\.\.\./, out)
-    end
+    @app.terminal_columns = 80
+    @app.options.show_tasks = :tasks
+    @app.options.show_task_pattern = //
+    @app.last_description = "1234567890" * 8
+    @app.define_task(Rake::Task, "t")
+
+    out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
+
+    assert_match(/^rake t/, out)
+    assert_match(/# 12345678901234567890123456789012345678901234567890123456789012345\.\.\./, out)
   end
 
   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 = //
-      task_name = "task name" * 80
-      @app.last_description = "something short"
-      @app.define_task(Rake::Task, task_name )
-      out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
-      # Ensure the entire task name is output and we end up showing no description
-      assert_match(/rake #{task_name}  # .../, out)
-    end
+    @app.terminal_columns = 80
+    @app.options.show_tasks = :tasks
+    @app.options.show_task_pattern = //
+    task_name = "task name" * 80
+    @app.last_description = "something short"
+    @app.define_task(Rake::Task, task_name )
+
+    out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
+
+    # Ensure the entire task name is output and we end up showing no description
+    assert_match(/rake #{task_name}  # .../, out)
   end
 
   def test_display_tasks_with_very_long_task_name_to_a_non_tty_shows_name_and_comment
@@ -67,7 +61,9 @@ class TestRakeApplication < Rake::TestCase
     task_name = "task name" * 80
     @app.last_description = "something short"
     @app.define_task(Rake::Task, task_name )
+
     out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
+
     # Ensure the entire task name is output and we end up showing no description
     assert_match(/rake #{task_name}  # #{description}/, out)
   end
@@ -84,16 +80,17 @@ class TestRakeApplication < Rake::TestCase
   end
 
   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
-      @app.define_task(Rake::Task, "t")
-      out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
-      assert_match(/^rake t/, out)
-      assert_match(/# 12345678901234567890123456789012345678901234567890123456789012345\.\.\./, out)
-    end
+    @app.terminal_columns = 80
+    @app.options.show_tasks = :tasks
+    @app.options.show_task_pattern = //
+    @app.tty_output = false
+    @app.last_description = "1234567890" * 8
+    @app.define_task(Rake::Task, "t")
+
+    out, = capture_io do @app.instance_eval { display_tasks_and_comments } end
+
+    assert_match(/^rake t/, out)
+    assert_match(/# 12345678901234567890123456789012345678901234567890123456789012345\.\.\./, out)
   end
 
   def test_describe_tasks
@@ -117,6 +114,8 @@ class TestRakeApplication < Rake::TestCase
   end
 
   def test_finding_rakefile
+    rakefile_default
+
     assert_match(/Rakefile/i, @app.instance_eval { have_rakefile })
   end
 
@@ -127,108 +126,144 @@ class TestRakeApplication < Rake::TestCase
   end
 
   def test_load_rakefile
-    in_environment("PWD" => "test/data/unittest") do
-      @app.instance_eval do
-        handle_options
-        options.silent = true
-        load_rakefile
-      end
-      assert_equal "rakefile", @app.rakefile.downcase
-      assert_match(%r(unittest$), Dir.pwd)
+    rakefile_unittest
+
+    @app.instance_eval do
+      handle_options
+      options.silent = true
+      load_rakefile
     end
+
+    assert_equal "rakefile", @app.rakefile.downcase
+    assert_equal @tempdir, Dir.pwd
   end
 
   def test_load_rakefile_doesnt_print_rakefile_directory_from_same_dir
-    in_environment("PWD" => "test/data/unittest") do
-      _, err = capture_io do
-        @app.instance_eval do
-          @original_dir = File.expand_path(".") # pretend we started from the unittest dir
-          raw_load_rakefile
-        end
+    rakefile_unittest
+
+    _, err = capture_io do
+      @app.instance_eval do
+        # pretend we started from the unittest dir
+        @original_dir = File.expand_path(".")
+        raw_load_rakefile
       end
-      _, location = @app.find_rakefile_location
-      refute_match(/\(in #{location}\)/, err)
     end
+
+    assert_empty err
   end
 
   def test_load_rakefile_from_subdir
-    in_environment("PWD" => "test/data/unittest/subdir") do
-      @app.instance_eval do
-        handle_options
-        options.silent = true
-        load_rakefile
-      end
-      assert_equal "rakefile", @app.rakefile.downcase
-      assert_match(%r(unittest$), Dir.pwd)
+    rakefile_unittest
+    Dir.chdir 'subdir'
+
+    @app.instance_eval do
+      handle_options
+      options.silent = true
+      load_rakefile
     end
+
+    assert_equal "rakefile", @app.rakefile.downcase
+    assert_equal @tempdir, Dir.pwd
   end
 
   def test_load_rakefile_prints_rakefile_directory_from_subdir
-    in_environment("PWD" => "test/data/unittest/subdir") do
-      _, err = capture_io do
-        @app.instance_eval do
-          raw_load_rakefile
-        end
+    rakefile_unittest
+    Dir.chdir 'subdir'
+
+    app = Rake::Application.new
+    app.options.rakelib = []
+
+    _, err = capture_io do
+      app.instance_eval do
+        raw_load_rakefile
       end
-      _, location = @app.find_rakefile_location
-      assert_match(/\(in #{location}\)/, err)
     end
+
+    assert_equal "(in #{@tempdir}\)\n", err
   end
 
   def test_load_rakefile_doesnt_print_rakefile_directory_from_subdir_if_silent
-    in_environment("PWD" => "test/data/unittest/subdir") do
-      _, err = capture_io do
-        @app.instance_eval do
-          handle_options
-          options.silent = true
-          raw_load_rakefile
-        end
-      end
-      _, location = @app.find_rakefile_location
-      refute_match(/\(in #{location}\)/, err)
-    end
-  end
+    rakefile_unittest
+    Dir.chdir 'subdir'
 
-  def test_load_rakefile_not_found
-    in_environment("PWD" => "/", "RAKE_SYSTEM" => 'not_exist') do
+    _, err = capture_io do
       @app.instance_eval do
         handle_options
         options.silent = true
+        raw_load_rakefile
       end
-      ex = assert_raises(RuntimeError) do
-        @app.instance_eval do raw_load_rakefile end
-      end
-      assert_match(/no rakefile found/i, ex.message)
     end
+
+    assert_empty err
+  end
+
+  def test_load_rakefile_not_found
+    Dir.chdir @tempdir
+    ENV['RAKE_SYSTEM'] = 'not_exist'
+
+    @app.instance_eval do
+      handle_options
+      options.silent = true
+    end
+
+    ex = assert_raises(RuntimeError) do
+      @app.instance_eval do raw_load_rakefile end
+    end
+
+    assert_match(/no rakefile found/i, ex.message)
   end
 
   def test_load_from_system_rakefile
-    in_environment('RAKE_SYSTEM' => 'test/data/sys') do
-      @app.options.rakelib = []
-      @app.instance_eval do
-        handle_options
-        options.silent = true
-        options.load_system = true
-        options.rakelib = []
-        load_rakefile
-      end
-      assert_equal "test/data/sys", @app.system_dir
-      assert_nil @app.rakefile
+    rake_system_dir
+
+    @app.instance_eval do
+      handle_options
+      options.silent = true
+      options.load_system = true
+      options.rakelib = []
+      load_rakefile
     end
+
+    assert_equal @system_dir, @app.system_dir
+    assert_nil @app.rakefile
+  rescue SystemExit
+    flunk 'failed to load rakefile'
   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
+    rakefile_default
+    def @app.standard_system_dir
+      "__STD_SYS_DIR__"
+    end
+
+    ENV['RAKE_SYSTEM'] = nil
+
+    @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
+  rescue SystemExit
+    flunk 'failed to find system rakefile'
+  end
+
+  def test_terminal_columns
+    old_RAKE_COLUMNS = ENV['RAKE_COLUMNS']
+
+    ENV['RAKE_COLUMNS'] = '42'
+
+    app = Rake::Application.new
+
+    assert_equal 42, app.terminal_columns
+  ensure
+    if old_RAKE_COLUMNS then
+      ENV['RAKE_COLUMNS'].delete
+    else
+      ENV['RAKE_COLUMNS'] = old_RAKE_COLUMNS
     end
   end
 
@@ -237,25 +272,28 @@ class TestRakeApplication < Rake::TestCase
   end
 
   def test_loading_imports
-    mock = flexmock("loader")
-    mock.should_receive(:load).with("x.dummy").once
+    loader = util_loader
+
     @app.instance_eval do
-      add_loader("dummy", mock)
+      add_loader("dummy", loader)
       add_import("x.dummy")
       load_imports
     end
+
+    # HACK no assertions
   end
 
   def test_building_imported_files_on_demand
-    mock = flexmock("loader")
-    mock.should_receive(:load).with("x.dummy").once
-    mock.should_receive(:make_dummy).with_no_args.once
+    loader = util_loader
+
     @app.instance_eval do
-      intern(Rake::Task, "x.dummy").enhance do mock.make_dummy end
-        add_loader("dummy", mock)
+      intern(Rake::Task, "x.dummy").enhance do loader.make_dummy end
+      add_loader("dummy", loader)
       add_import("x.dummy")
       load_imports
     end
+
+    # HACK no assertions
   end
 
   def test_handle_options_should_strip_options_from_ARGV
@@ -273,16 +311,24 @@ class TestRakeApplication < Rake::TestCase
 
   def test_good_run
     ran = false
-    ARGV.clear
+
     ARGV << '--rakelib=""'
+
     @app.options.silent = true
+
     @app.instance_eval do
       intern(Rake::Task, "default").enhance { ran = true }
     end
-    in_environment("PWD" => "test/data/default") do
+
+    rakefile_default
+
+    out, err = capture_io do
       @app.run
     end
+
     assert ran
+    assert_empty err
+    assert_equal "DEFAULT\n", out
   end
 
   def test_display_task_run
@@ -351,14 +397,93 @@ class TestRakeApplication < Rake::TestCase
   end
 
   def test_deprecation_message
-    in_environment do
-      _, err = capture_io do
-        @app.deprecate("a", "b", "c")
+    _, err = capture_io do
+      @app.deprecate("a", "b", "c")
+    end
+    assert_match(/'a' is deprecated/i, err)
+    assert_match(/use 'b' instead/i, err)
+    assert_match(/at c$/i, err)
+  end
+
+  def test_standard_exception_handling_invalid_option
+    out, err = capture_io do
+      e = assert_raises SystemExit do
+        @app.standard_exception_handling do
+          raise OptionParser::InvalidOption, 'blah'
+        end
+      end
+
+      assert_equal 1, e.status
+    end
+
+    assert_empty out
+    assert_equal "invalid option: blah\n", err
+  end
+
+  def test_standard_exception_handling_other
+    out, err = capture_io do
+      e = assert_raises SystemExit do
+        @app.standard_exception_handling do
+          raise 'blah'
+        end
+      end
+
+      assert_equal 1, e.status
+    end
+
+    assert_empty out
+    assert_match "rake aborted!\n", err
+    assert_match "blah\n", err
+  end
+
+  def test_standard_exception_handling_system_exit
+    out, err = capture_io do
+      e = assert_raises SystemExit do
+        @app.standard_exception_handling do
+          exit 0
+        end
       end
-      assert_match(/'a' is deprecated/i, err)
-      assert_match(/use 'b' instead/i, err)
-      assert_match(/at c$/i, err)
+
+      assert_equal 0, e.status
+    end
+
+    assert_empty out
+    assert_empty err
+  end
+
+  def test_standard_exception_handling_system_exit_nonzero
+    out, err = capture_io do
+      e = assert_raises SystemExit do
+        @app.standard_exception_handling do
+          exit 5
+        end
+      end
+
+      assert_equal 5, e.status
     end
+
+    assert_empty out
+    assert_empty err
   end
+
+  def util_loader
+    loader = Object.new
+
+    loader.instance_variable_set :@load_called, false
+    def loader.load arg
+      raise 'called more than once' if @load_called
+      raise ArgumentError, arg unless arg == 'x.dummy'
+      @load_called = true
+    end
+
+    loader.instance_variable_set :@make_dummy_called, false
+    def loader.make_dummy
+      raise 'called more than once' if @make_dummy_called
+      @make_dummy_called = true
+    end
+
+    loader
+  end
+
 end
 
diff --git a/test/test_rake_application_options.rb b/test/test_rake_application_options.rb
index 0ae9465..c1471f4 100644
--- a/test/test_rake_application_options.rb
+++ b/test/test_rake_application_options.rb
@@ -28,312 +28,267 @@ class TestRakeApplicationOptions < Rake::TestCase
   end
 
   def test_default_options
-    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 ! Rake::FileUtilsExt.verbose_flag
-      assert ! Rake::FileUtilsExt.nowrite_flag
-    end
+    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 ! Rake::FileUtilsExt.verbose_flag
+    assert ! Rake::FileUtilsExt.nowrite_flag
   end
 
   def test_dry_run
-    in_environment do
-      flags('--dry-run', '-n') do |opts|
-        assert opts.dryrun
-        assert opts.trace
-        assert Rake::FileUtilsExt.verbose_flag
-        assert Rake::FileUtilsExt.nowrite_flag
-      end
+    flags('--dry-run', '-n') do |opts|
+      assert opts.dryrun
+      assert opts.trace
+      assert Rake::FileUtilsExt.verbose_flag
+      assert Rake::FileUtilsExt.nowrite_flag
     end
   end
 
   def test_describe
-    in_environment do
-      flags('--describe') do |opts|
-        assert_equal :describe, opts.show_tasks
-        assert_equal(//.to_s, opts.show_task_pattern.to_s)
-      end
+    flags('--describe') do |opts|
+      assert_equal :describe, opts.show_tasks
+      assert_equal(//.to_s, opts.show_task_pattern.to_s)
     end
   end
 
   def test_describe_with_pattern
-    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
+    flags('--describe=X') do |opts|
+      assert_equal :describe, opts.show_tasks
+      assert_equal(/X/.to_s, opts.show_task_pattern.to_s)
     end
   end
 
   def test_execute
-    in_environment do
+    $xyzzy = 0
+    flags('--execute=$xyzzy=1', '-e $xyzzy=1') do |opts|
+      assert_equal 1, $xyzzy
+      assert_equal :exit, @exit
       $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
-    in_environment do
+    $xyzzy = 0
+    flags('--execute-continue=$xyzzy=1', '-E $xyzzy=1') do |opts|
+      assert_equal 1, $xyzzy
+      refute_equal :exit, @exit
       $xyzzy = 0
-      flags('--execute-continue=$xyzzy=1', '-E $xyzzy=1') do |opts|
-        assert_equal 1, $xyzzy
-        refute_equal :exit, @exit
-        $xyzzy = 0
-      end
     end
   end
 
   def test_execute_and_print
-    in_environment do
-      $xyzzy = 0
-      out, = capture_io do
-        flags('--execute-print=$xyzzy="pugh"', '-p $xyzzy="pugh"') do |opts|
-          assert_equal 'pugh', $xyzzy
-          assert_equal :exit, @exit
-          $xyzzy = 0
-        end
+    $xyzzy = 0
+    out, = capture_io do
+      flags('--execute-print=$xyzzy="pugh"', '-p $xyzzy="pugh"') do |opts|
+        assert_equal 'pugh', $xyzzy
+        assert_equal :exit, @exit
+        $xyzzy = 0
       end
-
-      assert_match(/^pugh$/, out)
     end
+
+    assert_match(/^pugh$/, out)
   end
 
   def test_help
-    in_environment do
-      out, = capture_io do
-        flags '--help', '-H', '-h'
-      end
-
-      assert_match(/\Arake/, out)
-      assert_match(/\boptions\b/, out)
-      assert_match(/\btargets\b/, out)
-      assert_equal :exit, @exit
+    out, = capture_io do
+      flags '--help', '-H', '-h'
     end
+
+    assert_match(/\Arake/, out)
+    assert_match(/\boptions\b/, out)
+    assert_match(/\btargets\b/, out)
+    assert_equal :exit, @exit
   end
 
   def test_libdir
-    in_environment do
-      flags(['--libdir', 'xx'], ['-I', 'xx'], ['-Ixx']) do |opts|
-        $:.include?('xx')
-      end
+    flags(['--libdir', 'xx'], ['-I', 'xx'], ['-Ixx']) do |opts|
+      $:.include?('xx')
     end
   ensure
     $:.delete('xx')
   end
 
   def test_rakefile
-    in_environment do
-      flags(['--rakefile', 'RF'], ['--rakefile=RF'], ['-f', 'RF'], ['-fRF']) do |opts|
-        assert_equal ['RF'], @app.instance_eval { @rakefiles }
-      end
+    flags(['--rakefile', 'RF'], ['--rakefile=RF'], ['-f', 'RF'], ['-fRF']) do |opts|
+      assert_equal ['RF'], @app.instance_eval { @rakefiles }
     end
   end
 
   def test_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
+    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
 
   def test_require
-    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
+    $LOAD_PATH.unshift @tempdir
+
+    open 'reqfile.rb',    'w' do |io| io << 'TESTING_REQUIRE << 1' end
+    open 'reqfile2.rb',   'w' do |io| io << 'TESTING_REQUIRE << 2' end
+    open 'reqfile3.rake', 'w' do |io| io << 'TESTING_REQUIRE << 3' end
+
+    flags(['--require', 'reqfile'], '-rreqfile2', '-rreqfile3')
+
+    assert_includes TESTING_REQUIRE, 1
+    assert_includes TESTING_REQUIRE, 2
+    assert_includes TESTING_REQUIRE, 3
+
+    assert_equal 3, TESTING_REQUIRE.size
+  ensure
+    $LOAD_PATH.delete @tempdir
   end
 
   def test_missing_require
-    in_environment do
-      ex = assert_raises(LoadError) do
-        flags(['--require', 'test/missing']) do |opts|
-        end
+    ex = assert_raises(LoadError) do
+      flags(['--require', 'test/missing']) do |opts|
       end
-      assert_match(/such file/, ex.message)
-      assert_match(/test\/missing/, ex.message)
     end
+    assert_match(/such file/, ex.message)
+    assert_match(/test\/missing/, ex.message)
   end
 
   def test_prereqs
-    in_environment do
-      flags('--prereqs', '-P') do |opts|
-        assert opts.show_prereqs
-      end
+    flags('--prereqs', '-P') do |opts|
+      assert opts.show_prereqs
     end
   end
 
   def test_quiet
-    in_environment do
-      flags('--quiet', '-q') do |opts|
-        assert ! Rake::FileUtilsExt.verbose_flag
-        assert ! opts.silent
-      end
+    flags('--quiet', '-q') do |opts|
+      assert ! Rake::FileUtilsExt.verbose_flag
+      assert ! opts.silent
     end
   end
 
   def test_no_search
-    in_environment do
-      flags('--nosearch', '--no-search', '-N') do |opts|
-        assert opts.nosearch
-      end
+    flags('--nosearch', '--no-search', '-N') do |opts|
+      assert opts.nosearch
     end
   end
 
   def test_silent
-    in_environment do
-      flags('--silent', '-s') do |opts|
-        assert ! Rake::FileUtilsExt.verbose_flag
-        assert opts.silent
-      end
+    flags('--silent', '-s') do |opts|
+      assert ! Rake::FileUtilsExt.verbose_flag
+      assert opts.silent
     end
   end
 
   def test_system
-    in_environment do
-      flags('--system', '-g') do |opts|
-        assert opts.load_system
-      end
+    flags('--system', '-g') do |opts|
+      assert opts.load_system
     end
   end
 
   def test_no_system
-    in_environment do
-      flags('--no-system', '-G') do |opts|
-        assert opts.ignore_system
-      end
+    flags('--no-system', '-G') do |opts|
+      assert opts.ignore_system
     end
   end
 
   def test_trace
-    in_environment do
-      flags('--trace', '-t') do |opts|
-        assert opts.trace
-        assert Rake::FileUtilsExt.verbose_flag
-        assert ! Rake::FileUtilsExt.nowrite_flag
-      end
+    flags('--trace', '-t') do |opts|
+      assert opts.trace
+      assert Rake::FileUtilsExt.verbose_flag
+      assert ! Rake::FileUtilsExt.nowrite_flag
     end
   end
 
   def test_trace_rules
-    in_environment do
-      flags('--rules') do |opts|
-        assert opts.trace_rules
-      end
+    flags('--rules') do |opts|
+      assert opts.trace_rules
     end
   end
 
   def test_tasks
-    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/.to_s, opts.show_task_pattern.to_s)
-      end
+    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/.to_s, opts.show_task_pattern.to_s)
     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
+    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
 
   def test_no_deprecated_messages
-    in_environment do
-      flags('--no-deprecation-warnings', '-X') do |opts|
-        assert opts.ignore_deprecate
-      end
+    flags('--no-deprecation-warnings', '-X') do |opts|
+      assert opts.ignore_deprecate
     end
   end
 
   def test_verbose
-    in_environment do
-      out, = capture_io do
-        flags('--verbose', '-V') do |opts|
-          assert Rake::FileUtilsExt.verbose_flag
-          assert ! opts.silent
-        end
+    out, = capture_io do
+      flags('--verbose', '-V') do |opts|
+        assert Rake::FileUtilsExt.verbose_flag
+        assert ! opts.silent
       end
-
-      assert_equal "rake, version #{Rake::VERSION}\n", out
     end
+
+    assert_equal "rake, version #{Rake::VERSION}\n", out
   end
 
   def test_version
-    in_environment do
-      out, = capture_io do
-        flags '--version', '-V'
-      end
-
-      assert_match(/\bversion\b/, out)
-      assert_match(/\b#{RAKEVERSION}\b/, out)
-      assert_equal :exit, @exit
+    out, = capture_io do
+      flags '--version', '-V'
     end
+
+    assert_match(/\bversion\b/, out)
+    assert_match(/\b#{RAKEVERSION}\b/, out)
+    assert_equal :exit, @exit
   end
 
   def test_classic_namespace
-    in_environment do
-      _, err = capture_io 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
-
-      assert_match(/deprecated/, err)
+    _, err = capture_io 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
+
+    assert_match(/deprecated/, err)
   end
 
   def test_bad_option
-    in_environment do
-      _, err = capture_io do
-        ex = assert_raises(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
+    _, err = capture_io do
+      ex = assert_raises(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
-      assert_equal '', err
     end
+
+    assert_equal '', err
   end
 
   def test_task_collection
@@ -353,8 +308,6 @@ class TestRakeApplicationOptions < Rake::TestCase
     assert '12', ENV['TESTKEY']
   end
 
-  private
-
   def flags(*sets)
     sets.each do |set|
       ARGV.clear
diff --git a/test/test_rake_clean.rb b/test/test_rake_clean.rb
index df265a9..1541c69 100644
--- a/test/test_rake_clean.rb
+++ b/test/test_rake_clean.rb
@@ -4,6 +4,8 @@ require 'rake/clean'
 class TestRakeClean < Rake::TestCase
   include Rake
   def test_clean
+    load 'rake/clean.rb', true
+
     assert Task['clean'], "Should define clean"
     assert Task['clobber'], "Should define clobber"
     assert Task['clobber'].prerequisites.include?("clean"),
diff --git a/test/test_rake_definitions.rb b/test/test_rake_definitions.rb
index 8a83b21..839c404 100644
--- a/test/test_rake_definitions.rb
+++ b/test/test_rake_definitions.rb
@@ -4,7 +4,7 @@ require 'fileutils'
 class TestRakeDefinitions < Rake::TestCase
   include Rake
 
-  EXISTINGFILE = "testdata/existing"
+  EXISTINGFILE = "existing"
 
   def setup
     super
@@ -23,10 +23,10 @@ class TestRakeDefinitions < Rake::TestCase
 
   def test_file_task
     done = false
-    file "testdata/one" => "testdata/two" do done = true end
-    file "testdata/two"
-    file "testdata/three" => ["testdata/one", "testdata/two"]
-    check_tasks("testdata/one", "testdata/two", "testdata/three")
+    file "one" => "two" do done = true end
+    file "two"
+    file "three" => ["one", "two"]
+    check_tasks("one", "two", "three")
     assert done, "Should be done"
   end
 
@@ -55,7 +55,7 @@ class TestRakeDefinitions < Rake::TestCase
   end
 
   def test_missing_dependencies
-    task :x => ["testdata/missing"]
+    task :x => ["missing"]
     assert_raises(RuntimeError) { Task[:x].invoke }
   end
 
diff --git a/test/test_rake_directory_task.rb b/test/test_rake_directory_task.rb
index d7c9dcd..631882c 100644
--- a/test/test_rake_directory_task.rb
+++ b/test/test_rake_directory_task.rb
@@ -4,52 +4,43 @@ require 'fileutils'
 class TestRakeDirectoryTask < Rake::TestCase
   include Rake
 
-  def setup
-    super
+  def test_directory
+    desc "DESC"
 
-    Rake.rm_rf "testdata", :verbose=>false
-  end
+    directory "a/b/c"
 
-  def teardown
-    Rake.rm_rf "testdata", :verbose=>false
+    assert_equal FileCreationTask, Task["a"].class
+    assert_equal FileCreationTask, Task["a/b"].class
+    assert_equal FileCreationTask, Task["a/b/c"].class
 
-    super
-  end
+    assert_nil             Task["a"].comment
+    assert_nil             Task["a/b"].comment
+    assert_equal "DESC",   Task["a/b/c"].comment
 
-  def test_directory
-    desc "DESC"
-    directory "testdata/a/b/c"
-    assert_equal FileCreationTask, Task["testdata"].class
-    assert_equal FileCreationTask, Task["testdata/a"].class
-    assert_equal FileCreationTask, Task["testdata/a/b/c"].class
-    assert_nil             Task["testdata"].comment
-    assert_equal "DESC",   Task["testdata/a/b/c"].comment
-    assert_nil             Task["testdata/a/b"].comment
     verbose(false) {
-      Task['testdata/a/b'].invoke
+      Task['a/b'].invoke
     }
-    assert File.exist?("testdata/a/b")
-    assert ! File.exist?("testdata/a/b/c")
+
+    assert File.exist?("a/b")
+    refute File.exist?("a/b/c")
   end
 
   if Rake::Win32.windows?
     def test_directory_win32
       desc "WIN32 DESC"
-      FileUtils.mkdir_p("testdata")
-      Dir.chdir("testdata") do
-        directory 'c:/testdata/a/b/c'
-        assert_equal FileCreationTask, Task['c:/testdata'].class
-        assert_equal FileCreationTask, Task['c:/testdata/a'].class
-        assert_equal FileCreationTask, Task['c:/testdata/a/b/c'].class
-        assert_nil             Task['c:/testdata'].comment
-        assert_equal "WIN32 DESC",   Task['c:/testdata/a/b/c'].comment
-        assert_nil             Task['c:/testdata/a/b'].comment
-        verbose(false) {
-          Task['c:/testdata/a/b'].invoke
-        }
-        assert File.exist?('c:/testdata/a/b')
-        assert ! File.exist?('c:/testdata/a/b/c')
-      end
+      directory 'c:/a/b/c'
+      assert_equal FileTask, Task['c:'].class
+      assert_equal FileCreationTask, Task['c:/a'].class
+      assert_equal FileCreationTask, Task['c:/a/b'].class
+      assert_equal FileCreationTask, Task['c:/a/b/c'].class
+      assert_nil             Task['c:/'].comment
+      assert_equal "WIN32 DESC",   Task['c:/a/b/c'].comment
+      assert_nil             Task['c:/a/b'].comment
+      verbose(false) {
+        Task['c:/a/b'].invoke
+      }
+      assert File.exist?('c:/a/b')
+      refute File.exist?('c:/a/b/c')
     end
   end
 end
diff --git a/test/test_rake_dsl.rb b/test/test_rake_dsl.rb
index 294ff2b..de83b89 100644
--- a/test/test_rake_dsl.rb
+++ b/test/test_rake_dsl.rb
@@ -56,6 +56,10 @@ class TestRakeDsl < Rake::TestCase
     assert_match(/test_rake_dsl\.rb:\d+/, err)
   end
 
+  def test_no_commands_constant
+    assert ! defined?(Commands), "should not define Commands"
+  end
+
   def test_deprecated_object_dsl_with_suppressed_warnings
     Rake.application.options.ignore_deprecate = true
     out, err = capture_io do
diff --git a/test/test_rake_file_creation_task.rb b/test/test_rake_file_creation_task.rb
index 80bee35..d486d2f 100644
--- a/test/test_rake_file_creation_task.rb
+++ b/test/test_rake_file_creation_task.rb
@@ -6,7 +6,7 @@ class TestRakeFileCreationTask < Rake::TestCase
   include Rake
   include Rake::DSL
 
-  DUMMY_DIR = 'testdata/dummy_dir'
+  DUMMY_DIR = 'dummy_dir'
 
   def setup
     super
@@ -14,12 +14,6 @@ class TestRakeFileCreationTask < Rake::TestCase
     Task.clear
   end
 
-  def teardown
-    FileUtils.rm_rf DUMMY_DIR
-
-    super
-  end
-
   def test_file_needed
     create_dir DUMMY_DIR
     fc_task = Task[DUMMY_DIR]
diff --git a/test/test_rake_file_list.rb b/test/test_rake_file_list.rb
index 1287a18..08939fb 100644
--- a/test/test_rake_file_list.rb
+++ b/test/test_rake_file_list.rb
@@ -6,14 +6,26 @@ class TestRakeFileList < Rake::TestCase
   def setup
     super
 
-    create_test_data
-  end
-
-  def teardown
-#    FileList.select_default_ignore_patterns
-    FileUtils.rm_rf("testdata")
+    FileUtils.mkdir "CVS" rescue nil
+    FileUtils.mkdir ".svn" rescue nil
+    @cdir = "cfiles"
+    FileUtils.mkdir @cdir rescue nil
+    FileUtils.touch ".dummy"
+    FileUtils.touch "x.bak"
+    FileUtils.touch "x~"
+    FileUtils.touch "core"
+    FileUtils.touch "x.c"
+    FileUtils.touch "xyz.c"
+    FileUtils.touch "abc.c"
+    FileUtils.touch "abc.h"
+    FileUtils.touch "abc.x"
+    FileUtils.touch "existing"
+
+    open 'xyzzy.txt', 'w' do |io|
+      io.puts 'x'
+      io.puts 'XYZZY'
+    end
 
-    super
   end
 
   def test_delegating_methods_do_not_include_to_a_or_to_ary
@@ -29,8 +41,8 @@ class TestRakeFileList < Rake::TestCase
   end
 
   def test_create_with_args
-    fl = FileList.new("testdata/*.c", "x")
-    assert_equal ["testdata/abc.c", "testdata/x.c", "testdata/xyz.c", "x"].sort,
+    fl = FileList.new("*.c", "x")
+    assert_equal ["abc.c", "x.c", "xyz.c", "x"].sort,
       fl.sort
   end
 
@@ -40,14 +52,14 @@ class TestRakeFileList < Rake::TestCase
   end
 
   def test_create_with_brackets
-    fl = FileList["testdata/*.c", "x"]
-    assert_equal ["testdata/abc.c", "testdata/x.c", "testdata/xyz.c", "x"].sort,
+    fl = FileList["*.c", "x"]
+    assert_equal ["abc.c", "x.c", "xyz.c", "x"].sort,
       fl.sort
   end
 
   def test_create_with_brackets_and_filelist
-    fl = FileList[FileList["testdata/*.c", "x"]]
-    assert_equal ["testdata/abc.c", "testdata/x.c", "testdata/xyz.c", "x"].sort,
+    fl = FileList[FileList["*.c", "x"]]
+    assert_equal ["abc.c", "x.c", "xyz.c", "x"].sort,
       fl.sort
   end
 
@@ -57,8 +69,8 @@ class TestRakeFileList < Rake::TestCase
   end
 
   def test_include_with_another_filelist
-    fl = FileList.new.include(FileList["testdata/*.c", "x"])
-    assert_equal ["testdata/abc.c", "testdata/x.c", "testdata/xyz.c", "x"].sort,
+    fl = FileList.new.include(FileList["*.c", "x"])
+    assert_equal ["abc.c", "x.c", "xyz.c", "x"].sort,
       fl.sort
   end
 
@@ -86,86 +98,87 @@ class TestRakeFileList < Rake::TestCase
 
   def test_match
     fl = FileList.new
-    fl.include('test/test_*.rb')
-    assert fl.include?("test/test_rake_file_list.rb")
-    assert fl.size > 3
-    fl.each { |fn| assert_match(/\.rb$/, fn) }
+    fl.include '*.c'
+
+    assert_equal %w[abc.c x.c xyz.c], fl.sort
   end
 
   def test_add_matching
     fl = FileList.new
     fl << "a.java"
-    fl.include("test/*.rb")
-    assert_equal "a.java", fl[0]
-    assert fl.size > 2
-    assert fl.include?("test/test_rake_file_list.rb")
+    fl.include '*.c'
+
+    assert_equal %w[a.java abc.c x.c xyz.c], fl.sort
   end
 
   def test_multiple_patterns
-    create_test_data
     fl = FileList.new
-    fl.include('*.c', '*xist*')
+    fl.include('*.z', '*foo*')
+
     assert_equal [], fl
-    fl.include('testdata/*.c', 'testdata/*xist*')
-    assert_equal [
-      'testdata/x.c', 'testdata/xyz.c', 'testdata/abc.c', 'testdata/existing'
-    ].sort, fl.sort
+
+    fl.include('*.c', '*xist*')
+    assert_equal %w[x.c xyz.c abc.c existing].sort, fl.sort
   end
 
   def test_square_bracket_pattern
     fl = FileList.new
-    fl.include("testdata/abc.[ch]")
+    fl.include("abc.[ch]")
     assert fl.size == 2
-    assert fl.include?("testdata/abc.c")
-    assert fl.include?("testdata/abc.h")
+    assert fl.include?("abc.c")
+    assert fl.include?("abc.h")
   end
 
   def test_curly_bracket_pattern
     fl = FileList.new
-    fl.include("testdata/abc.{c,h}")
+    fl.include("abc.{c,h}")
     assert fl.size == 2
-    assert fl.include?("testdata/abc.c")
-    assert fl.include?("testdata/abc.h")
+    assert fl.include?("abc.c")
+    assert fl.include?("abc.h")
   end
 
   def test_reject
     fl = FileList.new
-    fl.include %w(testdata/x.c testdata/abc.c testdata/xyz.c testdata/existing)
-    fl.reject! { |fn| fn =~ %r{/x} }
-    assert_equal [
-      'testdata/abc.c', 'testdata/existing'
-    ], fl
+    fl.include %w(x.c abc.c xyz.c existing)
+    fl.reject! { |fn| fn =~ /^x/ }
+    assert_equal %w[abc.c existing], fl
   end
 
   def test_exclude
-    fl = FileList['testdata/x.c', 'testdata/abc.c', 'testdata/xyz.c', 'testdata/existing']
+    fl = FileList['x.c', 'abc.c', 'xyz.c', 'existing']
     fl.each { |fn| touch fn, :verbose => false }
-    x = fl.exclude(%r{/x.+\.})
+
+    x = fl.exclude(%r{^x.+\.})
+
     assert_equal FileList, x.class
-    assert_equal %w(testdata/x.c testdata/abc.c testdata/existing), fl
+    assert_equal %w(x.c abc.c existing), fl
     assert_equal fl.object_id, x.object_id
-    fl.exclude('testdata/*.c')
-    assert_equal ['testdata/existing'], fl
-    fl.exclude('testdata/existing')
+
+    fl.exclude('*.c')
+
+    assert_equal ['existing'], fl
+
+    fl.exclude('existing')
+
     assert_equal [], fl
   end
 
   def test_excluding_via_block
-    fl = FileList['testdata/a.c', 'testdata/b.c', 'testdata/xyz.c']
+    fl = FileList['a.c', 'b.c', 'xyz.c']
     fl.exclude { |fn| fn.pathmap('%n') == 'xyz' }
     assert fl.exclude?("xyz.c"), "Should exclude xyz.c"
-    assert_equal ['testdata/a.c', 'testdata/b.c'], fl
+    assert_equal ['a.c', 'b.c'], fl
   end
 
   def test_exclude_return_on_create
-    fl = FileList['testdata/*'].exclude(/.*\.[hcx]$/)
-    assert_equal ['testdata/existing', 'testdata/cfiles'].sort, fl.sort
+    fl = FileList['*'].exclude(/.*\.[hcx]$/)
+    assert_equal %w[cfiles existing xyzzy.txt], fl.sort
     assert_equal FileList, fl.class
   end
 
   def test_exclude_with_string_return_on_create
-    fl = FileList['testdata/*'].exclude('testdata/abc.c')
-    assert_equal %w(testdata/existing testdata/cfiles testdata/x.c testdata/abc.h testdata/abc.x testdata/xyz.c).sort, fl.sort
+    fl = FileList['*'].exclude('abc.c')
+    assert_equal %w[abc.h abc.x cfiles existing x.c xyz.c xyzzy.txt], fl.sort
     assert_equal FileList, fl.class
   end
 
@@ -173,8 +186,8 @@ class TestRakeFileList < Rake::TestCase
     fl = FileList.new
     fl.clear_exclude
     fl.include("**/*~", "**/*.bak", "**/core")
-    assert fl.member?("testdata/core"), "Should include core"
-    assert fl.member?("testdata/x.bak"), "Should include .bak files"
+    assert fl.member?("core"), "Should include core"
+    assert fl.member?("x.bak"), "Should include .bak files"
   end
 
   def test_unique
@@ -201,54 +214,54 @@ class TestRakeFileList < Rake::TestCase
   end
 
   def test_to_s_pending
-    fl = FileList['testdata/abc.*']
+    fl = FileList['abc.*']
     result = fl.to_s
-    assert_match(%r{testdata/abc\.c}, result)
-    assert_match(%r{testdata/abc\.h}, result)
-    assert_match(%r{testdata/abc\.x}, result)
-    assert_match(%r{(testdata/abc\..\b ?){2}}, result)
+    assert_match(%r{abc\.c}, result)
+    assert_match(%r{abc\.h}, result)
+    assert_match(%r{abc\.x}, result)
+    assert_match(%r{(abc\..\b ?){2}}, result)
   end
 
   def test_inspect_pending
-    fl = FileList['testdata/abc.*']
+    fl = FileList['abc.*']
     result = fl.inspect
-    assert_match(%r{"testdata/abc\.c"}, result)
-    assert_match(%r{"testdata/abc\.h"}, result)
-    assert_match(%r{"testdata/abc\.x"}, result)
-    assert_match(%r|^\[("testdata/abc\..", ){2}"testdata/abc\.."\]$|, result)
+    assert_match(%r{"abc\.c"}, result)
+    assert_match(%r{"abc\.h"}, result)
+    assert_match(%r{"abc\.x"}, result)
+    assert_match(%r|^\[("abc\..", ){2}"abc\.."\]$|, result)
   end
 
   def test_sub
-    fl = FileList["testdata/*.c"]
+    fl = FileList["*.c"]
     f2 = fl.sub(/\.c$/, ".o")
     assert_equal FileList, f2.class
-    assert_equal ["testdata/abc.o", "testdata/x.o", "testdata/xyz.o"].sort,
+    assert_equal ["abc.o", "x.o", "xyz.o"].sort,
       f2.sort
     f3 = fl.gsub(/\.c$/, ".o")
     assert_equal FileList, f3.class
-    assert_equal ["testdata/abc.o", "testdata/x.o", "testdata/xyz.o"].sort,
+    assert_equal ["abc.o", "x.o", "xyz.o"].sort,
       f3.sort
   end
 
   def test_claim_to_be_a_kind_of_array
-    fl = FileList['testdata/*.c']
+    fl = FileList['*.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']
+    fl = FileList['*.c']
     assert fl.is_a?(FileList)
     assert fl.kind_of?(FileList)
   end
 
   def test_claim_to_be_a_filelist_instance
-    fl = FileList['testdata/*.c']
+    fl = FileList['*.c']
     assert fl.instance_of?(FileList)
   end
 
   def test_dont_claim_to_be_an_array_instance
-    fl = FileList['testdata/*.c']
+    fl = FileList['*.c']
     assert ! fl.instance_of?(Array)
   end
 
@@ -304,18 +317,16 @@ class TestRakeFileList < Rake::TestCase
   end
 
   def test_gsub
-    create_test_data
-    fl = FileList["testdata/*.c"]
+    fl = FileList["*.c"]
     f2 = fl.gsub(/a/, "A")
-    assert_equal ["testdAtA/Abc.c", "testdAtA/x.c", "testdAtA/xyz.c"].sort,
+    assert_equal ["Abc.c", "x.c", "xyz.c"].sort,
       f2.sort
   end
 
   def test_gsub!
-    create_test_data
-    f = FileList["testdata/*.c"]
+    f = FileList["*.c"]
     f.gsub!(/a/, "A")
-    assert_equal ["testdAtA/Abc.c", "testdAtA/x.c", "testdAtA/xyz.c"].sort,
+    assert_equal ["Abc.c", "x.c", "xyz.c"].sort,
       f.sort
   end
 
@@ -325,66 +336,70 @@ class TestRakeFileList < Rake::TestCase
   end
 
   def test_egrep_with_output
-    files = FileList['test/test_*.rb']
-    the_line_number = __LINE__ + 1
-    out, = capture_io do files.egrep(/PUGH/) end
-    assert_match(/:#{the_line_number}:/, out)
+    files = FileList['*.txt']
+
+    out, = capture_io do
+      files.egrep(/XYZZY/)
+    end
+
+    assert_equal "xyzzy.txt:2:XYZZY\n", out
   end
 
   def test_egrep_with_block
-    files = FileList['test/test_*.rb']
+    files = FileList['*.txt']
     found = nil
-    the_line_number = __LINE__ + 1
-    files.egrep(/XYZZY/) do |fn, ln, line |
+
+    files.egrep(/XYZZY/) do |fn, ln, line|
       found = [fn, ln, line]
     end
-    assert_equal 'test/test_rake_file_list.rb', found[0]
-    assert_equal the_line_number, found[1]
-    assert_match(/files\.egrep/, found[2])
+
+    assert_equal ["xyzzy.txt", 2, "XYZZY\n"], found
   end
 
   def test_egrep_with_error
-    files = FileList['test/test_*.rb']
+    files = FileList['*.txt']
+
     _, err = capture_io do
-      files.egrep(/ANYTHING/) do |fn, ln, line |
-        fail "_EGREP_FAILURE_"
+      files.egrep(/XYZZY/) do |fn, ln, line |
+        raise "_EGREP_FAILURE_"
       end
     end
-    assert_match(/_EGREP_FAILURE_/, err)
+
+    assert_equal "Error while processing 'xyzzy.txt': _EGREP_FAILURE_\n", err
   end
 
   def test_existing
-    fl = FileList['testdata/abc.c', 'testdata/notthere.c']
-    assert_equal ["testdata/abc.c"], fl.existing
+    fl = FileList['abc.c', 'notthere.c']
+    assert_equal ["abc.c"], fl.existing
     assert fl.existing.is_a?(FileList)
   end
 
   def test_existing!
-    fl = FileList['testdata/abc.c', 'testdata/notthere.c']
+    fl = FileList['abc.c', 'notthere.c']
     result = fl.existing!
-    assert_equal ["testdata/abc.c"], fl
+    assert_equal ["abc.c"], fl
     assert_equal fl.object_id, result.object_id
   end
 
   def test_ignore_special
-    f = FileList['testdata/*']
-    assert ! f.include?("testdata/CVS"), "Should not contain CVS"
-    assert ! f.include?("testdata/.svn"), "Should not contain .svn"
-    assert ! f.include?("testdata/.dummy"), "Should not contain dot files"
-    assert ! f.include?("testdata/x.bak"), "Should not contain .bak files"
-    assert ! f.include?("testdata/x~"), "Should not contain ~ files"
-    assert ! f.include?("testdata/core"), "Should not contain core files"
+    f = FileList['*']
+    assert ! f.include?("CVS"), "Should not contain CVS"
+    assert ! f.include?(".svn"), "Should not contain .svn"
+    assert ! f.include?(".dummy"), "Should not contain dot files"
+    assert ! f.include?("x.bak"), "Should not contain .bak files"
+    assert ! f.include?("x~"), "Should not contain ~ files"
+    assert ! f.include?("core"), "Should not contain core files"
   end
 
   def test_clear_ignore_patterns
-    f = FileList['testdata/*', 'testdata/.svn']
+    f = FileList['*', '.svn']
     f.clear_exclude
-    assert f.include?("testdata/abc.c")
-    assert f.include?("testdata/xyz.c")
-    assert f.include?("testdata/CVS")
-    assert f.include?("testdata/.svn")
-    assert f.include?("testdata/x.bak")
-    assert f.include?("testdata/x~")
+    assert f.include?("abc.c")
+    assert f.include?("xyz.c")
+    assert f.include?("CVS")
+    assert f.include?(".svn")
+    assert f.include?("x.bak")
+    assert f.include?("x~")
   end
 
   def test_exclude_with_alternate_file_seps
@@ -422,8 +437,8 @@ class TestRakeFileList < Rake::TestCase
   end
 
   def test_flatten
-    assert_equal ['a', 'testdata/x.c', 'testdata/xyz.c', 'testdata/abc.c'].sort,
-      ['a', FileList['testdata/*.c']].flatten.sort
+    assert_equal ['a', 'x.c', 'xyz.c', 'abc.c'].sort,
+      ['a', FileList['*.c']].flatten.sort
   end
 
   def test_clone_and_dup
@@ -600,7 +615,7 @@ class TestRakeFileList < Rake::TestCase
   end
 
   def test_file_utils_can_use_filelists
-    cfiles = FileList['testdata/*.c']
+    cfiles = FileList['*.c']
 
     cp cfiles, @cdir, :verbose => false
 
@@ -609,25 +624,5 @@ class TestRakeFileList < Rake::TestCase
     assert File.exist?(File.join(@cdir, 'x.c'))
   end
 
-  def create_test_data
-    verbose(false) do
-
-      mkdir "testdata" unless File.exist? "testdata"
-      mkdir "testdata/CVS" rescue nil
-      mkdir "testdata/.svn" rescue nil
-      @cdir = "testdata/cfiles"
-      mkdir @cdir rescue nil
-      touch "testdata/.dummy"
-      touch "testdata/x.bak"
-      touch "testdata/x~"
-      touch "testdata/core"
-      touch "testdata/x.c"
-      touch "testdata/xyz.c"
-      touch "testdata/abc.c"
-      touch "testdata/abc.h"
-      touch "testdata/abc.x"
-      touch "testdata/existing"
-    end
-  end
-
 end
+
diff --git a/test/test_rake_file_task.rb b/test/test_rake_file_task.rb
index d965f03..e586551 100644
--- a/test/test_rake_file_task.rb
+++ b/test/test_rake_file_task.rb
@@ -14,9 +14,7 @@ class TestRakeFileTask < Rake::TestCase
   end
 
   def test_file_need
-    FileUtils.mkdir_p 'testdata' # HACK use tmpdir
-
-    name = "testdata/dummy"
+    name = "dummy"
     file name
 
     ftask = Task[name]
diff --git a/test/test_rake_file_utils.rb b/test/test_rake_file_utils.rb
index 0be6050..90565e3 100644
--- a/test/test_rake_file_utils.rb
+++ b/test/test_rake_file_utils.rb
@@ -4,47 +4,41 @@ require 'stringio'
 
 class TestRakeFileUtils < Rake::TestCase
 
-  def setup
-    super
-
-    File.chmod(0750, "test/shellcommand.rb")
-  end
-
   def teardown
-    File.chmod(0755, "test/shellcommand.rb")
-    FileUtils.rm_rf("testdata")
     FileUtils::LN_SUPPORTED[0] = true
+    RakeFileUtils.verbose_flag = Rake::FileUtilsExt::DEFAULT
 
     super
   end
 
   def test_rm_one_file
-    create_file("testdata/a")
-    FileUtils.rm_rf "testdata/a"
-    assert ! File.exist?("testdata/a")
+    create_file("a")
+    FileUtils.rm_rf "a"
+    refute File.exist?("a")
   end
 
   def test_rm_two_files
-    create_file("testdata/a")
-    create_file("testdata/b")
-    FileUtils.rm_rf ["testdata/a", "testdata/b"]
-    assert ! File.exist?("testdata/a")
-    assert ! File.exist?("testdata/b")
+    create_file("a")
+    create_file("b")
+    FileUtils.rm_rf ["a", "b"]
+    refute File.exist?("a")
+    refute File.exist?("b")
   end
 
   def test_rm_filelist
-    list = Rake::FileList.new << "testdata/a" << "testdata/b"
+    list = Rake::FileList.new << "a" << "b"
     list.each { |fn| create_file(fn) }
     FileUtils.rm_r list
-    assert ! File.exist?("testdata/a")
-    assert ! File.exist?("testdata/b")
+    refute File.exist?("a")
+    refute File.exist?("b")
   end
 
   def test_ln
-    create_dir("testdata")
-    open("testdata/a", "w") { |f| f.puts "TEST_LN" }
-    Rake::FileUtilsExt.safe_ln("testdata/a", "testdata/b", :verbose => false)
-    assert_equal "TEST_LN\n", open("testdata/b") { |f| f.read }
+    open("a", "w") { |f| f.puts "TEST_LN" }
+
+    Rake::FileUtilsExt.safe_ln("a", "b", :verbose => false)
+
+    assert_equal "TEST_LN\n", File.read('b')
   end
 
   class BadLink
@@ -107,9 +101,13 @@ class TestRakeFileUtils < Rake::TestCase
   end
 
   def test_file_utils_methods_are_available_at_top_level
-    create_file("testdata/a")
-    rm_rf "testdata/a"
-    assert ! File.exist?("testdata/a")
+    create_file("a")
+
+    capture_io do
+      rm_rf "a"
+    end
+
+    refute File.exist?("a")
   end
 
   def test_fileutils_methods_dont_leak
@@ -119,56 +117,49 @@ class TestRakeFileUtils < Rake::TestCase
   end
 
   def test_sh
-    verbose(false) { sh %{#{FileUtils::RUBY} test/shellcommand.rb} }
-    assert true, "should not fail"
-  end
+    shellcommand
 
-  # If the :sh method is invoked directly from a test unit instance
-  # (under mini/test), the mini/test version of fail is invoked rather
-  # than the kernel version of fail. So we run :sh from within a
-  # non-test class to avoid the problem.
-  class Sh
-    include FileUtils
-    def run(*args)
-      sh(*args)
-    end
-    def self.run(*args)
-      new.run(*args)
-    end
-    def self.ruby(*args)
-      Sh.run(RUBY, *args)
-    end
+    verbose(false) { sh %{#{Rake::TestCase::RUBY} shellcommand.rb} }
+    assert true, "should not fail"
   end
 
   def test_sh_with_a_single_string_argument
+    check_expansion
+
     ENV['RAKE_TEST_SH'] = 'someval'
     verbose(false) {
-      sh %{#{FileUtils::RUBY} test/check_expansion.rb #{env_var} someval}
+      sh %{#{RUBY} check_expansion.rb #{env_var} someval}
     }
   end
 
   def test_sh_with_multiple_arguments
+    check_no_expansion
     ENV['RAKE_TEST_SH'] = 'someval'
+
     verbose(false) {
-      Sh.ruby 'test/check_no_expansion.rb', env_var, 'someval'
+      sh RUBY, 'check_no_expansion.rb', env_var, 'someval'
     }
   end
 
   def test_sh_failure
+    shellcommand
+
     assert_raises(RuntimeError) {
-      verbose(false) { Sh.run %{#{FileUtils::RUBY} test/shellcommand.rb 1} }
+      verbose(false) { sh %{#{RUBY} shellcommand.rb 1} }
     }
   end
 
   def test_sh_special_handling
+    shellcommand
+
     count = 0
     verbose(false) {
-      sh(%{#{FileUtils::RUBY} test/shellcommand.rb}) do |ok, res|
+      sh(%{#{RUBY} shellcommand.rb}) do |ok, res|
         assert(ok)
         assert_equal 0, res.exitstatus
         count += 1
       end
-      sh(%{#{FileUtils::RUBY} test/shellcommand.rb 1}) do |ok, res|
+      sh(%{#{RUBY} shellcommand.rb 1}) do |ok, res|
         assert(!ok)
         assert_equal 1, res.exitstatus
         count += 1
@@ -178,46 +169,75 @@ class TestRakeFileUtils < Rake::TestCase
   end
 
   def test_sh_noop
-    verbose(false) { sh %{test/shellcommand.rb 1}, :noop=>true }
+    shellcommand
+
+    verbose(false) { sh %{shellcommand.rb 1}, :noop=>true }
     assert true, "should not fail"
   end
 
   def test_sh_bad_option
+    shellcommand
+
     ex = assert_raises(ArgumentError) {
-      verbose(false) { sh %{test/shellcommand.rb}, :bad_option=>true }
+      verbose(false) { sh %{shellcommand.rb}, :bad_option=>true }
     }
     assert_match(/bad_option/, ex.message)
   end
 
   def test_sh_verbose
-    out = redirect_stderr {
+    shellcommand
+
+    _, err = capture_io do
       verbose(true) {
-        sh %{test/shellcommand.rb}, :noop=>true
+        sh %{shellcommand.rb}, :noop=>true
       }
-    }
-    assert_match(/^test\/shellcommand\.rb$/, out)
+    end
+
+    assert_equal "shellcommand.rb\n", err
   end
 
-  def test_sh_no_verbose
-    out = redirect_stderr {
+  def test_sh_verbose_false
+    shellcommand
+
+    _, err = capture_io do
       verbose(false) {
-        sh %{test/shellcommand.rb}, :noop=>true
+        sh %{shellcommand.rb}, :noop=>true
       }
-    }
-    assert_equal '', out
+    end
+
+    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
+
     ENV['RAKE_TEST_SH'] = 'someval'
+
     verbose(false) {
-      ruby %{test/check_expansion.rb #{env_var} someval}
+      replace_ruby {
+        ruby %{check_expansion.rb #{env_var} someval}
+      }
     }
   end
 
   def test_ruby_with_multiple_arguments
+    check_no_expansion
+
     ENV['RAKE_TEST_SH'] = 'someval'
     verbose(false) {
-      ruby 'test/check_no_expansion.rb', env_var, 'someval'
+      replace_ruby {
+        ruby 'check_no_expansion.rb', env_var, 'someval'
+      }
     }
   end
 
@@ -230,23 +250,56 @@ class TestRakeFileUtils < Rake::TestCase
     assert_equal ['..', 'a', 'b'], Rake::FileUtilsExt.split_all('../a/b')
   end
 
-  private
+  def command name, text
+    open name, 'w', 0750 do |io|
+      io << text
+    end
+  end
 
-  def redirect_stderr
-    old_err = $stderr
-    $stderr = StringIO.new
+  def check_no_expansion
+    command 'check_no_expansion.rb', <<-CHECK_EXPANSION
+if ARGV[0] != ARGV[1]
+  exit 0
+else
+  exit 1
+end
+    CHECK_EXPANSION
+  end
+
+  def check_expansion
+    command 'check_expansion.rb', <<-CHECK_EXPANSION
+if ARGV[0] != ARGV[1]
+  exit 1
+else
+  exit 0
+end
+    CHECK_EXPANSION
+  end
+
+  def replace_ruby
+    ruby = FileUtils::RUBY
+    FileUtils.send :remove_const, :RUBY
+    FileUtils.const_set :RUBY, RUBY
     yield
-    $stderr.string
   ensure
-    $stderr = old_err
+    FileUtils.send :remove_const, :RUBY
+    FileUtils.const_set:RUBY, ruby
   end
 
-  def windows?
-    ! File::ALT_SEPARATOR.nil?
+  def shellcommand
+    command 'shellcommand.rb', <<-SHELLCOMMAND
+#!/usr/bin/env ruby
+
+exit((ARGV[0] || "0").to_i)
+    SHELLCOMMAND
   end
 
   def env_var
     windows? ? '%RAKE_TEST_SH%' : '$RAKE_TEST_SH'
   end
 
+  def windows?
+    ! File::ALT_SEPARATOR.nil?
+  end
+
 end
diff --git a/test/test_rake_functional.rb b/test/test_rake_functional.rb
index 8df208b..3a7e368 100644
--- a/test/test_rake_functional.rb
+++ b/test/test_rake_functional.rb
@@ -1,91 +1,64 @@
-begin
-  old_verbose = $VERBOSE
-  $VERBOSE = nil
-  require 'session'
-rescue LoadError
-  if File::ALT_SEPARATOR
-    puts "Unable to run functional tests on MS Windows. Skipping."
-  else
-    puts "Unable to run functional tests -- please run \"gem install session\""
-  end
-ensure
-  $VERBOSE = old_verbose
-end
-
-if defined?(Session)
-  if File::ALT_SEPARATOR
-    puts "Unable to run functional tests on MS Windows. Skipping."
-  end
-end
-
 require File.expand_path('../helper', __FILE__)
 require 'fileutils'
-
-# Version 2.1.9 of session has a bug where the @debug instance
-# variable is not initialized, causing warning messages.  This snippet
-# of code fixes that problem.
-module Session
-  class AbstractSession
-    alias old_initialize initialize
-    def initialize(*args)
-      @debug = nil
-      old_initialize(*args)
-    end
-  end
-end if defined? Session
+require 'open3'
 
 class TestRakeFunctional < Rake::TestCase
 
-  RUBY_COMMAND = 'ruby'
-
   def setup
-    super
-
     @rake_path = File.expand_path("bin/rake")
     lib_path = File.expand_path("lib")
     @ruby_options = ["-I#{lib_path}", "-I."]
-    @verbose = ! ENV['VERBOSE'].nil?
+    @verbose = ENV['VERBOSE']
 
     if @verbose
       puts
       puts
-      puts "--------------------------------------------------------------------"
-      puts name
-      puts "--------------------------------------------------------------------"
+      puts '-' * 80
+      puts @__name__
+      puts '-' * 80
     end
+
+    super
   end
 
   def test_rake_default
-    Dir.chdir("test/data/default") do rake end
+    rakefile_default
+
+    rake
+
     assert_match(/^DEFAULT$/, @out)
-    assert_status
   end
 
   def test_rake_error_on_bad_task
-    Dir.chdir("test/data/default") do rake "xyz" end
+    rakefile_default
+
+    rake '-t', 'xyz'
+
     assert_match(/rake aborted/, @err)
-    assert_status(1)
   end
 
   def test_env_available_at_top_scope
-    Dir.chdir("test/data/default") do rake "TESTTOPSCOPE=1" end
+    rakefile_default
+
+    rake "TESTTOPSCOPE=1"
+
     assert_match(/^TOPSCOPE$/, @out)
-    assert_status
   end
 
   def test_env_available_at_task_scope
-    Dir.chdir("test/data/default") do rake "TESTTASKSCOPE=1 task_scope" end
+    rakefile_default
+
+    rake 'TESTTASKSCOPE=1', 'task_scope'
+
     assert_match(/^TASKSCOPE$/, @out)
-    assert_status
   end
 
   def test_multi_desc
-    in_environment(
-      'RAKE_COLUMNS' => "80",
-      "PWD" => "test/data/multidesc"
-      ) do
-      rake "-T"
-    end
+    ENV['RAKE_COLUMNS'] = '80'
+    rakefile_multidesc
+
+    rake "-T"
+
     assert_match %r{^rake a *# A / A2 *$}, @out
     assert_match %r{^rake b *# B *$}, @out
     refute_match %r{^rake c}, @out
@@ -93,9 +66,10 @@ class TestRakeFunctional < Rake::TestCase
   end
 
   def test_long_description
-    in_environment("PWD" => "test/data/multidesc") do
-      rake "--describe"
-    end
+    rakefile_multidesc
+
+    rake "--describe"
+
     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
@@ -103,136 +77,159 @@ class TestRakeFunctional < Rake::TestCase
   end
 
   def test_proper_namespace_access
-    in_environment("PWD" => "test/data/access") do
-      rake
-    end
-    assert_not_match %r{^BAD:}, @out
+    rakefile_access
+
+    rake
+
+    refute_match %r{^BAD:}, @out
   end
 
   def test_rbext
-    in_environment("PWD" => "test/data/rbext") do
-      rake "-N"
-    end
+    rakefile_rbext
+
+    rake "-N"
+
     assert_match %r{^OK$}, @out
   end
 
   def test_system
-    in_environment('RAKE_SYSTEM' => 'test/data/sys') do
-      rake '-g', "sys1"
-    end
+    rake_system_dir
+
+    rake '-g', "sys1"
+
     assert_match %r{^SYS1}, @out
   end
 
   def test_system_excludes_rakelib_files_too
-    in_environment('RAKE_SYSTEM' => 'test/data/sys') do
-      rake '-g', "sys1", '-T', 'extra'
-    end
+    rake_system_dir
+
+    rake '-g', "sys1", '-T', 'extra'
+
     refute_match %r{extra:extra}, @out
   end
 
   def test_by_default_rakelib_files_are_included
-    in_environment('RAKE_SYSTEM' => 'test/data/sys', "PWD" => 'test/data/extra') do
-      rake '-T', 'extra', '--trace'
-    end
+    rake_system_dir
+    rakefile_extra
+
+    rake '-T', 'extra', '--trace'
+
     assert_match %r{extra:extra}, @out
   end
 
   def test_implicit_system
-    in_environment('RAKE_SYSTEM' => File.expand_path('test/data/sys'), "PWD" => "/") do
-      rake "sys1", "--trace"
-    end
+    rake_system_dir
+    Dir.chdir @tempdir
+
+    rake "sys1", "--trace"
+
     assert_match %r{^SYS1}, @out
   end
 
   def test_no_system
-    in_environment('RAKE_SYSTEM' => 'test/data/sys', "PWD" => "test/data/extra") do
-      rake '-G', "sys1"
-    end
+    rake_system_dir
+    rakefile_extra
+
+    rake '-G', "sys1"
+
     assert_match %r{^Don't know how to build task}, @err # emacs wart: '
   end
 
   def test_nosearch_with_rakefile_uses_local_rakefile
-    in_environment("PWD" => "test/data/default") do
-      rake "--nosearch"
-    end
+    rakefile_default
+
+    rake "--nosearch"
+
     assert_match %r{^DEFAULT}, @out
   end
 
   def test_nosearch_without_rakefile_finds_system
-    in_environment(
-      "PWD" => "test/data/nosearch",
-      "RAKE_SYSTEM" => File.expand_path("test/data/sys")
-      ) do
-      rake "--nosearch", "sys1"
-    end
+    rakefile_nosearch
+    rake_system_dir
+
+    rake "--nosearch", "sys1"
+
     assert_match %r{^SYS1}, @out
   end
 
   def test_nosearch_without_rakefile_and_no_system_fails
-    in_environment("PWD" => "test/data/nosearch", "RAKE_SYSTEM" => "not_exist") do
-      rake "--nosearch"
-    end
+    rakefile_nosearch
+    ENV['RAKE_SYSTEM'] = 'not_exist'
+
+    rake "--nosearch"
+
     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
+    rakefile_default
+
+    rake "--bad-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)
+    rakefile_verbose
+
+    rake "inline_verbose_default"
+
+    assert_match(/#{Regexp.quote(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)
+    rakefile_verbose
+
+    rake "inline_verbose_true"
+
+    assert_match(/#{Regexp.quote(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
-    refute_match(/ruby -e/, @err)
+    rakefile_verbose
+
+    rake "inline_verbose_false"
+
+    refute_match(/#{Regexp.quote(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
-    refute_match(/ruby -e/, @err)
+    rakefile_verbose
+
+    rake "block_verbose_false"
+
+    refute_match(/#{Regexp.quote(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)
+    rakefile_verbose
+
+    rake "block_verbose_true"
+
+    assert_match(/#{Regexp.quote(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)
+    rakefile_verbose
+
+    rake "standalone_verbose_true"
+
+    assert_match(/#{Regexp.quote(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
-    refute_match(/ruby -e/, @err)
+    rakefile_verbose
+
+    rake "standalone_verbose_false"
+
+    refute_match(/#{Regexp.quote(RUBY)} -e/, @err)
   end
 
   def test_dry_run
-    in_environment("PWD" => "test/data/default") do rake "-n", "other" end
+    rakefile_default
+
+    rake "-n", "other"
+
     assert_match %r{Execute \(dry run\) default}, @err
     assert_match %r{Execute \(dry run\) other}, @err
     refute_match %r{DEFAULT}, @out
@@ -241,228 +238,213 @@ class TestRakeFunctional < Rake::TestCase
 
   # Test for the trace/dry_run bug found by Brian Chandler
   def test_dry_run_bug
-    in_environment("PWD" => "test/data/dryrun") do
-      rake
-    end
-    FileUtils.rm_f "test/data/dryrun/temp_one"
-    in_environment("PWD" => "test/data/dryrun") do
-      rake "--dry-run"
-    end
+    rakefile_dryrun
+
+    rake
+
+    FileUtils.rm_f 'temp_one'
+
+    rake "--dry-run"
+
     refute_match(/No such file/, @out)
-    assert_status
   end
 
   # Test for the trace/dry_run bug found by Brian Chandler
   def test_trace_bug
-    in_environment("PWD" => "test/data/dryrun") do
-      rake
-    end
-    FileUtils.rm_f "test/data/dryrun/temp_one"
-    in_environment("PWD" => "test/data/dryrun") do
-      rake "--trace"
-    end
+    rakefile_dryrun
+
+    rake
+
+    FileUtils.rm_f 'temp_one'
+
+    rake "--trace"
+
     refute_match(/No such file/, @out)
-    assert_status
   end
 
   def test_imports
-    open("test/data/imports/static_deps", "w") do |f|
-      f.puts 'puts "STATIC"'
-    end
-    FileUtils.rm_f "test/data/imports/dynamic_deps"
-    in_environment("PWD" => "test/data/imports") do
-      rake
-    end
-    assert File.exist?("test/data/imports/dynamic_deps"),
-      "'dynamic_deps' file should exist"
+    rakefile_imports
+
+    rake
+
+    assert File.exist?(File.join(@tempdir, 'dynamic_deps')),
+           "'dynamic_deps' file should exist"
     assert_match(/^FIRST$\s+^DYNAMIC$\s+^STATIC$\s+^OTHER$/, @out)
-    assert_status
-    FileUtils.rm_f "test/data/imports/dynamic_deps"
-    FileUtils.rm_f "test/data/imports/static_deps"
   end
 
   def test_rules_chaining_to_file_task
-    remove_chaining_files
-    in_environment("PWD" => "test/data/chains") do
-      rake
-    end
-    assert File.exist?("test/data/chains/play.app"),
-      "'play.app' file should exist"
-    assert_status
-    remove_chaining_files
+    rakefile_chains
+
+    rake
+
+    assert File.exist?(File.join(@tempdir, 'play.app')),
+           "'play.app' file should exist"
   end
 
   def test_file_creation_task
-    in_environment("PWD" => "test/data/file_creation_task") do
-      rake "prep"
-      rake "run"
-      rake "run"
-    end
+    rakefile_file_creation
+
+    rake "prep"
+    rake "run"
+    rake "run"
+
     assert(@err !~ /^cp src/, "Should not recopy data")
   end
 
   def test_dash_f_with_no_arg_foils_rakefile_lookup
-    rake "-I test/data/rakelib -rtest1 -f"
+    rakefile_rakelib
+
+    rake '-I', 'rakelib', '-rtest1', '-f'
+
     assert_match(/^TEST1$/, @out)
   end
 
   def test_dot_rake_files_can_be_loaded_with_dash_r
-    rake "-I test/data/rakelib -rtest2 -f"
+    rakefile_rakelib
+
+    rake '-I', 'rakelib', '-rtest2', '-f'
+
+    assert_empty @err
     assert_match(/^TEST2$/, @out)
   end
 
   def test_can_invoke_task_in_toplevel_namespace
-    in_environment("PWD" => "test/data/namespace") do
-      rake "copy"
-    end
+    rakefile_namespace
+
+    rake "copy"
+
     assert_match(/^COPY$/, @out)
   end
 
   def test_can_invoke_task_in_nested_namespace
-    in_environment("PWD" => "test/data/namespace") do
-      rake "nest:copy"
-      assert_match(/^NEST COPY$/, @out)
-    end
+    rakefile_namespace
+
+    rake "nest:copy"
+
+    assert_match(/^NEST COPY$/, @out)
   end
 
   def test_tasks_can_reference_task_in_same_namespace
-    in_environment("PWD" => "test/data/namespace") do
-      rake "nest:xx"
-      assert_match(/^NEST COPY$/m, @out)
-    end
+    rakefile_namespace
+
+    rake "nest:xx"
+
+    assert_match(/^NEST COPY$/m, @out)
   end
 
   def test_tasks_can_reference_task_in_other_namespaces
-    in_environment("PWD" => "test/data/namespace") do
-      rake "b:run"
-      assert_match(/^IN A\nIN B$/m, @out)
-    end
+    rakefile_namespace
+
+    rake "b:run"
+
+    assert_match(/^IN A\nIN B$/m, @out)
   end
 
   def test_anonymous_tasks_can_be_invoked_indirectly
-    in_environment("PWD" => "test/data/namespace") do
-      rake "anon"
-      assert_match(/^ANON COPY$/m, @out)
-    end
+    rakefile_namespace
+
+    rake "anon"
+
+    assert_match(/^ANON COPY$/m, @out)
   end
 
   def test_rake_namespace_refers_to_toplevel
-    in_environment("PWD" => "test/data/namespace") do
-      rake "very:nested:run"
-      assert_match(/^COPY$/m, @out)
-    end
+    rakefile_namespace
+
+    rake "very:nested:run"
+
+    assert_match(/^COPY$/m, @out)
   end
 
   def test_file_task_are_not_scoped_by_namespaces
-    in_environment("PWD" => "test/data/namespace") do
-      rake "xyz.rb"
-      assert_match(/^XYZ1\nXYZ2$/m, @out)
-    end
+    rakefile_namespace
+
+    rake "xyz.rb"
+
+    assert_match(/^XYZ1\nXYZ2$/m, @out)
   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
+    rakefile_namespace
 
-  def test_rake_returns_status_error_values
-    in_environment("PWD" => "test/data/statusreturn") do
-      rake "exit5"
-      assert_status(5)
-    end
-  end
+    rake "scopedep.rb"
 
-  def test_rake_returns_no_status_error_on_normal_exit
-    in_environment("PWD" => "test/data/statusreturn") do
-      rake "normal"
-      assert_status(0)
-    end
+    assert_match(/^PREPARE\nSCOPEDEP$/m, @out)
   end
 
   def test_comment_before_task_acts_like_desc
-    in_environment("PWD" => "test/data/comments") do
-      rake "-T"
-    end
+    rakefile_comments
+
+    rake "-T"
+
     refute_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)
+    rakefile_comments
+
+    rake "-T"
+
+    refute_match("t2", @out)
   end
 
   def test_comment_after_desc_is_ignored
-    Dir.chdir("test/data/comments") { rake("-T")}
+    rakefile_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")}
+    rakefile_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")}
+    rakefile_comments
+
+    rake "-T"
+
     assert_equal(2, @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'"
+    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)
-    end
-  end
-
   # Run a shell Ruby command with command line options (using the
-  # default test options). Output is captured in @out, @err and
-  # @status.
+  # default test options). Output is captured in @out and @err
   def ruby(*option_list)
     run_ruby(@ruby_options + option_list)
   end
 
   # 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.
+  # @out and @err
   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 = "#{RUBY_COMMAND} " + option_list.join(' ')
-    puts "COMMAND: [#{command}]" if @verbose
-    @out, @err = shell.execute command
-    @status = shell.exit_status
-    puts "STATUS:  [#{@status}]" if @verbose
+    puts "COMMAND: [#{RUBY} #{option_list.join ' '}]" if @verbose
+
+    inn, out, err = Open3.popen3(Gem.ruby, *option_list)
+    inn.close
+
+    @out = out.read
+    @err = err.read
+
     puts "OUTPUT:  [#{@out}]" if @verbose
     puts "ERROR:   [#{@err}]" if @verbose
     puts "PWD:     [#{Dir.pwd}]" if @verbose
-    shell.close
   end
 
-  def assert_status(expected_status=0)
-    assert_equal expected_status, @status
-  end
-end if defined?(Session)
+end
diff --git a/test/test_rake_makefile_loader.rb b/test/test_rake_makefile_loader.rb
index e130caf..bd3c99b 100644
--- a/test/test_rake_makefile_loader.rb
+++ b/test/test_rake_makefile_loader.rb
@@ -5,9 +5,30 @@ class TestRakeMakefileLoader < Rake::TestCase
   include Rake
 
   def test_parse
+    Dir.chdir @tempdir
+
+    open 'sample.mf', 'w' do |io|
+      io << <<-'SAMPLE_MF'
+# Comments
+a: a1 a2 a3 a4
+b: b1 b2 b3 \
+   b4 b5 b6\
+# Mid: Comment
+b7
+
+ a : a5 a6 a7
+c: c1
+d: d1 d2 \
+
+e f : e1 f1
+
+g\ 0: g1 g\ 2 g\ 3 g4
+      SAMPLE_MF
+    end
+
     Task.clear
     loader = Rake::MakefileLoader.new
-    loader.load("test/data/sample.mf")
+    loader.load 'sample.mf'
     %w(a b c d).each do |t|
       assert Task.task_defined?(t), "#{t} should be a defined task"
     end
diff --git a/test/test_rake_package_task.rb b/test/test_rake_package_task.rb
index 32b7472..87cb57c 100644
--- a/test/test_rake_package_task.rb
+++ b/test/test_rake_package_task.rb
@@ -4,16 +4,15 @@ require 'rake/packagetask'
 class TestRakePackageTask < Rake::TestCase
 
   def test_initialize
+    touch 'install.rb'
+    touch 'a.c'
+    touch 'b.c'
+    mkdir 'CVS'
+    touch 'a.rb~'
+
     pkg = Rake::PackageTask.new("pkgr", "1.2.3") { |p|
       p.package_files << "install.rb"
-      p.package_files.include(
-        '[A-Z]*',
-        'bin/**/*',
-        'lib/**/*.rb',
-        'test/**/*.rb',
-        'doc/**/*',
-        'build/rubyapp.rb',
-        '*.blurb')
+      p.package_files.include '*.c'
       p.package_files.exclude(/\bCVS\b/)
       p.package_files.exclude(/~$/)
       p.package_dir = 'pkg'
@@ -24,7 +23,9 @@ class TestRakePackageTask < Rake::TestCase
     }
 
     assert_equal "pkg", pkg.package_dir
-    assert pkg.package_files.include?("bin/rake")
+
+    assert_includes pkg.package_files, 'a.c'
+
     assert_equal 'pkgr', pkg.name
     assert_equal '1.2.3', pkg.version
     assert Rake::Task[:package]
diff --git a/test/test_rake_path_map_explode.rb b/test/test_rake_path_map_explode.rb
index 84966aa..a79235e 100644
--- a/test/test_rake_path_map_explode.rb
+++ b/test/test_rake_path_map_explode.rb
@@ -9,6 +9,8 @@ class TestRakePathMapExplode < Rake::TestCase
 
   def teardown
     String.class_eval { protected :pathmap_explode }
+
+    super
   end
 
   def test_explode
@@ -18,6 +20,7 @@ class TestRakePathMapExplode < Rake::TestCase
     assert_equal ['/', 'a'], '/a'.pathmap_explode
     assert_equal ['/', 'a', 'b'], '/a/b'.pathmap_explode
     assert_equal ['/', 'a', 'b', 'c'], '/a/b/c'.pathmap_explode
+
     if File::ALT_SEPARATOR
       assert_equal ['c:.', 'a'], 'c:a'.pathmap_explode
       assert_equal ['c:.', 'a', 'b'], 'c:a/b'.pathmap_explode
diff --git a/test/test_rake_pseudo_status.rb b/test/test_rake_pseudo_status.rb
index 3ad4d5b..51b3fef 100644
--- a/test/test_rake_pseudo_status.rb
+++ b/test/test_rake_pseudo_status.rb
@@ -6,15 +6,16 @@ class TestRakePseudoStatus < Rake::TestCase
     assert_equal 0, s.exitstatus
     assert_equal 0, s.to_i
     assert_equal 0, s >> 8
-    assert ! s.stopped?
+    refute s.stopped?
     assert s.exited?
   end
+
   def test_with_99_exit_status
     s = Rake::PseudoStatus.new(99)
     assert_equal 99, s.exitstatus
     assert_equal 25344, s.to_i
     assert_equal 99, s >> 8
-    assert ! s.stopped?
+    refute s.stopped?
     assert s.exited?
   end
 end
diff --git a/test/test_rake_rake_test_loader.rb b/test/test_rake_rake_test_loader.rb
new file mode 100644
index 0000000..5b5e81d
--- /dev/null
+++ b/test/test_rake_rake_test_loader.rb
@@ -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
+
diff --git a/test/test_rake_rdoc_task.rb b/test/test_rake_rdoc_task.rb
index bac6998..0d24ef0 100644
--- a/test/test_rake_rdoc_task.rb
+++ b/test/test_rake_rdoc_task.rb
@@ -1,10 +1,12 @@
 require File.expand_path('../helper', __FILE__)
 begin
-  old_verbose = $VERBOSE
-  $VERBOSE = nil
+  old_stderr = $stderr
+  dev_null = File.exist?('/dev/null') ? '/dev/null' : 'NUL'
+  $stderr = open dev_null, 'w'
   require 'rake/rdoctask'
 ensure
-  $VERBOSE = old_verbose
+  $stderr.close
+  $stderr = old_stderr
 end
 
 class TestRakeRDocTask < Rake::TestCase
diff --git a/test/test_rake_require.rb b/test/test_rake_require.rb
index 99cff35..d229edb 100644
--- a/test/test_rake_require.rb
+++ b/test/test_rake_require.rb
@@ -3,16 +3,19 @@ require File.expand_path('../helper', __FILE__)
 class TestRakeRequire < Rake::TestCase
 
   def test_can_load_rake_library
+    rakefile_rakelib
     app = Rake::Application.new
+
     assert app.instance_eval {
-      rake_require("test2", ['test/data/rakelib'], [])
+      rake_require("test2", ['rakelib'], [])
     }
   end
 
   def test_wont_reload_rake_library
+    rakefile_rakelib
     app = Rake::Application.new
 
-    paths = ['test/data/rakelib']
+    paths = ['rakelib']
     loaded_files = []
     app.rake_require("test2", paths, loaded_files)
 
@@ -22,10 +25,12 @@ class TestRakeRequire < Rake::TestCase
   end
 
   def test_throws_error_if_library_not_found
+    rakefile_rakelib
+
     app = Rake::Application.new
     ex = assert_raises(LoadError) {
       assert app.instance_eval {
-        rake_require("testx", ['test/data/rakelib'], [])
+        rake_require("testx", ['rakelib'], [])
       }
     }
     assert_match(/(can *not|can't)\s+find/i, ex.message)
diff --git a/test/test_rake_rules.rb b/test/test_rake_rules.rb
index d060470..3f6e352 100644
--- a/test/test_rake_rules.rb
+++ b/test/test_rake_rules.rb
@@ -1,29 +1,21 @@
 require File.expand_path('../helper', __FILE__)
 require 'fileutils'
 
-######################################################################
 class TestRakeRules < Rake::TestCase
   include Rake
 
-  SRCFILE  = "testdata/abc.c"
-  SRCFILE2 =  "testdata/xyz.c"
-  FTNFILE  = "testdata/abc.f"
-  OBJFILE  = "testdata/abc.o"
-  FOOFILE  = "testdata/foo"
-  DOTFOOFILE = "testdata/.foo"
+  SRCFILE    = "abc.c"
+  SRCFILE2   = "xyz.c"
+  FTNFILE    = "abc.f"
+  OBJFILE    = "abc.o"
+  FOOFILE    = "foo"
+  DOTFOOFILE = ".foo"
 
   def setup
     super
 
     Task.clear
     @runs = []
-    FileUtils.mkdir_p 'testdata' # HACK use tmpdir
-  end
-
-  def teardown
-    FileList['testdata/*'].uniq.each do |f| rm_r(f, :verbose=>false) end
-
-    super
   end
 
   def test_multiple_rules1
@@ -97,79 +89,68 @@ class TestRakeRules < Rake::TestCase
 
   def test_file_names_beginning_with_dot_can_be_tricked_into_referring_to_file
     verbose(false) do
-      chdir("testdata") do
-        create_file('.foo')
-        rule '.o' => "./.foo" do |t|
-          @runs << t.name
-        end
-        Task[OBJFILE].invoke
-        assert_equal [OBJFILE], @runs
+      create_file('.foo')
+      rule '.o' => "./.foo" do |t|
+        @runs << t.name
       end
+      Task[OBJFILE].invoke
+      assert_equal [OBJFILE], @runs
     end
   end
 
   def test_file_names_beginning_with_dot_can_be_wrapped_in_lambda
     verbose(false) do
-      chdir("testdata") do
-        create_file(".foo")
-        rule '.o' => lambda{".foo"} do |t|
-          @runs << "#{t.name} - #{t.source}"
-        end
-        Task[OBJFILE].invoke
-        assert_equal ["#{OBJFILE} - .foo"], @runs
+
+      create_file(".foo")
+      rule '.o' => lambda{".foo"} do |t|
+        @runs << "#{t.name} - #{t.source}"
       end
+      Task[OBJFILE].invoke
+      assert_equal ["#{OBJFILE} - .foo"], @runs
     end
   end
 
   def test_file_names_containing_percent_can_be_wrapped_in_lambda
     verbose(false) do
-      chdir("testdata") do
-        create_file("foo%x")
-        rule '.o' => lambda{"foo%x"} do |t|
-          @runs << "#{t.name} - #{t.source}"
-        end
-        Task[OBJFILE].invoke
-        assert_equal ["#{OBJFILE} - foo%x"], @runs
+      create_file("foo%x")
+      rule '.o' => lambda{"foo%x"} do |t|
+        @runs << "#{t.name} - #{t.source}"
       end
+      Task[OBJFILE].invoke
+      assert_equal ["#{OBJFILE} - foo%x"], @runs
     end
   end
 
   def test_non_extension_rule_name_refers_to_file
     verbose(false) do
-      chdir("testdata") do
-        create_file("abc.c")
-        rule "abc" => '.c' do |t|
-          @runs << t.name
-        end
-        Task["abc"].invoke
-        assert_equal ["abc"], @runs
+      create_file("abc.c")
+      rule "abc" => '.c' do |t|
+        @runs << t.name
       end
+      Task["abc"].invoke
+      assert_equal ["abc"], @runs
     end
   end
 
   def test_pathmap_automatically_applies_to_name
     verbose(false) do
-      chdir("testdata") do
-        create_file("zzabc.c")
-        rule ".o" => 'zz%{x,a}n.c' do |t|
-          @runs << "#{t.name} - #{t.source}"
-        end
-        Task["xbc.o"].invoke
-        assert_equal ["xbc.o - zzabc.c"], @runs
+      create_file("zzabc.c")
+      rule ".o" => 'zz%{x,a}n.c' do |t|
+        @runs << "#{t.name} - #{t.source}"
       end
+      Task["xbc.o"].invoke
+      assert_equal ["xbc.o - zzabc.c"], @runs
     end
   end
 
   def test_plain_strings_are_just_filenames
     verbose(false) do
-      chdir("testdata") do
-        create_file("plainname")
-        rule ".o" => 'plainname' do |t|
-          @runs << "#{t.name} - #{t.source}"
-        end
-        Task["xbc.o"].invoke
-        assert_equal ["xbc.o - plainname"], @runs
+      create_file("plainname")
+      rule ".o" => 'plainname' do |t|
+        @runs << "#{t.name} - #{t.source}"
       end
+      Task["xbc.o"].invoke
+      assert_equal ["xbc.o - plainname"], @runs
     end
   end
 
@@ -186,12 +167,12 @@ class TestRakeRules < Rake::TestCase
   end
 
   def test_close_matches_on_name_do_not_trigger_rule
-    create_file("testdata/x.c")
+    create_file("x.c")
     rule '.o' => ['.c'] do |t|
       @runs << t.name
     end
-    assert_raises(RuntimeError) { Task['testdata/x.obj'].invoke }
-    assert_raises(RuntimeError) { Task['testdata/x.xyo'].invoke }
+    assert_raises(RuntimeError) { Task['x.obj'].invoke }
+    assert_raises(RuntimeError) { Task['x.xyo'].invoke }
   end
 
   def test_rule_rebuilds_obj_when_source_is_newer
@@ -276,26 +257,26 @@ class TestRakeRules < Rake::TestCase
   end
 
   def test_rule_with_proc_dependent_will_trigger
-    mkdir_p("testdata/src/jw")
-    create_file("testdata/src/jw/X.java")
+    mkdir_p("src/jw")
+    create_file("src/jw/X.java")
     rule %r(classes/.*\.class) => [
-      proc { |fn| fn.pathmap("%{classes,testdata/src}d/%n.java") }
+      proc { |fn| fn.pathmap("%{classes,src}d/%n.java") }
     ] do |task|
       assert_equal task.name, 'classes/jw/X.class'
-      assert_equal task.source, 'testdata/src/jw/X.java'
+      assert_equal task.source, 'src/jw/X.java'
       @runs << :RULE
     end
     Task['classes/jw/X.class'].invoke
     assert_equal [:RULE], @runs
   ensure
-    rm_r("testdata/src", :verbose=>false) rescue nil
+    rm_r("src", :verbose=>false) rescue nil
   end
 
   def test_proc_returning_lists_are_flattened_into_prereqs
     ran = false
-    mkdir_p("testdata/flatten")
-    create_file("testdata/flatten/a.txt")
-    task 'testdata/flatten/b.data' do |t|
+    mkdir_p("flatten")
+    create_file("flatten/a.txt")
+    task 'flatten/b.data' do |t|
       ran = true
       touch t.name, :verbose => false
     end
@@ -303,38 +284,38 @@ class TestRakeRules < Rake::TestCase
       proc { |fn|
       [
         fn.ext("txt"),
-        "testdata/flatten/b.data"
+        "flatten/b.data"
       ]
     } do |task|
     end
-    Task['testdata/flatten/a.html'].invoke
+    Task['flatten/a.html'].invoke
     assert ran, "Should have triggered flattened dependency"
   ensure
-    rm_r("testdata/flatten", :verbose=>false) rescue nil
+    rm_r("flatten", :verbose=>false) rescue nil
   end
 
   def test_recursive_rules_will_work_as_long_as_they_terminate
     actions = []
-    create_file("testdata/abc.xml")
+    create_file("abc.xml")
     rule '.y' => '.xml' do actions << 'y' end
     rule '.c' => '.y' do actions << 'c'end
     rule '.o' => '.c' do actions << 'o'end
     rule '.exe' => '.o' do actions << 'exe'end
-    Task["testdata/abc.exe"].invoke
+    Task["abc.exe"].invoke
     assert_equal ['y', 'c', 'o', 'exe'], actions
   end
 
   def test_recursive_rules_that_dont_terminate_will_overflow
-    create_file("testdata/a.a")
+    create_file("a.a")
     prev = 'a'
     ('b'..'z').each do |letter|
       rule ".#{letter}" => ".#{prev}" do |t| puts "#{t.name}" end
       prev = letter
     end
     ex = assert_raises(Rake::RuleRecursionOverflowError) {
-      Task["testdata/a.z"].invoke
+      Task["a.z"].invoke
     }
-    assert_match(/a\.z => testdata\/a.y/, ex.message)
+    assert_match(/a\.z => a.y/, ex.message)
   end
 
   def test_rules_with_bad_dependents_will_fail
diff --git a/test/test_rake_task.rb b/test/test_rake_task.rb
index ebbcb2a..a5bc693 100644
--- a/test/test_rake_task.rb
+++ b/test/test_rake_task.rb
@@ -208,10 +208,7 @@ class TestRakeTask < Rake::TestCase
     b = task :b
     c = task :c
 
-    faux_stamp = 100
-    flexmock(Time, :now => faux_stamp)
-
-    assert_equal faux_stamp, a.timestamp
+    assert_in_delta Time.now, a.timestamp, 0.1, 'computer too slow?'
   end
 
   def test_timestamp_returns_latest_prereq_timestamp
@@ -219,12 +216,11 @@ class TestRakeTask < Rake::TestCase
     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)
+    now = Time.now
+    def b.timestamp() Time.now + 10 end
+    def c.timestamp() Time.now + 5 end
 
-    assert_equal faux_stamp, a.timestamp
+    assert_in_delta now + 10, a.timestamp, 0.1, 'computer too slow?'
   end
 
   def test_investigation_output
diff --git a/test/test_rake_task_argument_parsing.rb b/test/test_rake_task_argument_parsing.rb
index aaccfb9..9b99991 100644
--- a/test/test_rake_task_argument_parsing.rb
+++ b/test/test_rake_task_argument_parsing.rb
@@ -45,72 +45,59 @@ class TestRakeTaskArgumentParsing < Rake::TestCase
 
   def test_terminal_width_using_env
     app = Rake::Application.new
-    in_environment('RAKE_COLUMNS' => '1234') do
-      assert_equal 1234, app.terminal_width
-    end
+    app.terminal_columns = 1234
+
+    assert_equal 1234, app.terminal_width
   end
 
   def test_terminal_width_using_stty
-    app = Rake::Application.new
-    flexmock(app,
-      :unix? => true,
-      :dynamic_width_stty => 1235,
-      :dynamic_width_tput => 0)
-    in_environment('RAKE_COLUMNS' => nil) do
-      assert_equal 1235, app.terminal_width
-    end
+    def @app.unix?() true end
+    def @app.dynamic_width_stty() 1235 end
+    def @app.dynamic_width_tput() 0 end
+
+    assert_equal 1235, @app.terminal_width
   end
 
   def test_terminal_width_using_tput
-    app = Rake::Application.new
-    flexmock(app,
-      :unix? => true,
-      :dynamic_width_stty => 0,
-      :dynamic_width_tput => 1236)
-    in_environment('RAKE_COLUMNS' => nil) do
-      assert_equal 1236, app.terminal_width
-    end
+    def @app.unix?() true end
+    def @app.dynamic_width_stty() 0 end
+    def @app.dynamic_width_tput() 1236 end
+
+    assert_equal 1236, @app.terminal_width
   end
 
   def test_terminal_width_using_hardcoded_80
-    app = Rake::Application.new
-    flexmock(app, :unix? => false)
-    in_environment('RAKE_COLUMNS' => nil) do
-      assert_equal 80, app.terminal_width
-    end
+    def @app.unix?() false end
+
+    assert_equal 80, @app.terminal_width
   end
 
   def test_terminal_width_with_failure
-    app = Rake::Application.new
-    flexmock(app).should_receive(:unix?).and_throw(RuntimeError)
-    in_environment('RAKE_COLUMNS' => nil) do
-      assert_equal 80, app.terminal_width
-    end
+    def @app.unix?() raise end
+
+    assert_equal 80, @app.terminal_width
   end
 
   def test_no_rakeopt
-    in_environment do
-      ARGV << '--trace'
-      app = Rake::Application.new
-      app.init
-      assert !app.options.silent
-    end
+    ARGV << '--trace'
+    app = Rake::Application.new
+    app.init
+    assert !app.options.silent
   end
 
   def test_rakeopt_with_blank_options
-    in_environment("RAKEOPT" => "") do
-      ARGV << '--trace'
-      app = Rake::Application.new
-      app.init
-      assert !app.options.silent
-    end
+    ARGV << '--trace'
+    app = Rake::Application.new
+    app.init
+    assert !app.options.silent
   end
 
   def test_rakeopt_with_silent_options
-    in_environment("RAKEOPT" => "-s") do
-      app = Rake::Application.new
-      app.init
-      assert app.options.silent
-    end
+    ENV['RAKEOPT'] = '-s'
+    app = Rake::Application.new
+
+    app.init
+
+    assert app.options.silent
   end
 end
diff --git a/test/test_rake_task_arguments.rb b/test/test_rake_task_arguments.rb
index 3f89d6f..7001a4a 100644
--- a/test/test_rake_task_arguments.rb
+++ b/test/test_rake_task_arguments.rb
@@ -5,6 +5,8 @@ class TestRakeTaskArguments < Rake::TestCase
   def teardown
     ENV.delete('rev')
     ENV.delete('VER')
+
+    super
   end
 
   def test_empty_arg_list_is_empty
diff --git a/test/test_rake_task_manager.rb b/test/test_rake_task_manager.rb
index ce33b53..110ce65 100644
--- a/test/test_rake_task_manager.rb
+++ b/test/test_rake_task_manager.rb
@@ -19,6 +19,14 @@ class TestRakeTaskManager < Rake::TestCase
     assert_equal @tm, t.application
   end
 
+  def test_index
+    e = assert_raises RuntimeError do
+      @tm['bad']
+    end
+
+    assert_equal "Don't know how to build task 'bad'", e.message
+  end
+
   def test_name_lookup
     t = @tm.define_task(Rake::Task, :t)
     assert_equal t, @tm[:t]
@@ -46,6 +54,7 @@ class TestRakeTaskManager < Rake::TestCase
       t = @tm.define_task(Rake::FileTask, "fn")
       assert_equal "fn", t.name
     end
+
     assert_equal ["fn"], @tm.tasks.collect { |t| t.name }
   end
 
@@ -58,7 +67,10 @@ class TestRakeTaskManager < Rake::TestCase
   end
 
   def test_name_lookup_with_implicit_file_tasks
+    FileUtils.touch 'README.rdoc'
+
     t = @tm["README.rdoc"]
+
     assert_equal "README.rdoc", t.name
     assert Rake::FileTask === t
   end
diff --git a/test/test_rake_task_with_arguments.rb b/test/test_rake_task_with_arguments.rb
index bbbc82f..ce81a4c 100644
--- a/test/test_rake_task_with_arguments.rb
+++ b/test/test_rake_task_with_arguments.rb
@@ -158,5 +158,16 @@ class TestRakeTaskWithArguments < Rake::TestCase
     t = task(:t  => [:pre])
     t.invoke("bill", "1.2")
   end
+
+  def test_values_at
+    t = task(:pre, [:a, :b, :c]) { |task, 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])
+
+    # HACK no assertions
+  end
 end
 
diff --git a/test/test_rake_test_task.rb b/test/test_rake_test_task.rb
index fd34b9e..1a6d23e 100644
--- a/test/test_rake_test_task.rb
+++ b/test/test_rake_test_task.rb
@@ -4,24 +4,7 @@ require 'rake/testtask'
 class TestRakeTestTask < Rake::TestCase
   include Rake
 
-  def setup
-    super
-
-    Task.clear
-    ENV.delete('TEST')
-  end
-
-  def teardown
-    FileUtils.rm_rf("testdata")
-
-    super
-  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
@@ -31,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'
@@ -45,29 +28,43 @@ class TestRakeTestTask < Rake::TestCase
     assert Task.task_defined?(:example)
   end
 
-  def test_pattern
-    tt = Rake::TestTask.new do |t|
-      t.pattern = '*.rb'
-    end
-    assert_equal ['*.rb'], tt.file_list.to_a
-  end
-
-  def test_env_test
+  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_test_files
+  def test_pattern_equals
     tt = Rake::TestTask.new do |t|
-      t.test_files = FileList['a.rb', 'b.rb']
+      t.pattern = '*.rb'
     end
-    assert_equal ["a.rb", 'b.rb'], tt.file_list.to_a
+    assert_equal ['*.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'
@@ -75,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')
+
+    def test_task.ruby_version() '1.8.2' end
+
     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')
+
+    def test_task.ruby_version() '1.8.6' end
+
     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)
-  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)
+    assert_equal ["a.rb", 'b.rb'], tt.file_list.to_a
   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
+
diff --git a/test/test_rake_top_level_functions.rb b/test/test_rake_top_level_functions.rb
index 69ef869..1ed1af0 100644
--- a/test/test_rake_top_level_functions.rb
+++ b/test/test_rake_top_level_functions.rb
@@ -5,28 +5,43 @@ class TestRakeTopLevelFunctions < Rake::TestCase
   def setup
     super
 
-    @app = Rake.application
-    Rake.application = flexmock("app")
-    Rake.application.should_receive(:deprecate).
-      and_return { |old, new, call| @app.deprecate(old, new, call) }
-  end
+    @app = Object.new
 
-  def teardown
-    Rake.application = @app
+    def @app.called
+      @called
+    end
 
-    super
+    def @app.method_missing(*a, &b)
+      @called ||= []
+      @called << [a, b]
+      nil
+    end
+
+    Rake.application = @app
   end
 
   def test_namespace
-    Rake.application.should_receive(:in_namespace).with("xyz", any).once
-    namespace "xyz" do end
+    block = proc do end
+
+    namespace("xyz", &block) 
+
+    expected = [
+      [[:in_namespace, 'xyz'], block]
+    ]
+
+    assert_equal expected, @app.called
   end
 
   def test_import
-    Rake.application.should_receive(:add_import).with("x").once.ordered
-    Rake.application.should_receive(:add_import).with("y").once.ordered
-    Rake.application.should_receive(:add_import).with("z").once.ordered
     import('x', 'y', 'z')
+
+    expected = [
+      [[:add_import, 'x'], nil],
+      [[:add_import, 'y'], nil],
+      [[:add_import, 'z'], nil],
+    ]
+
+    assert_equal expected, @app.called
   end
 
   def test_when_writing
@@ -51,23 +66,43 @@ class TestRakeTopLevelFunctions < Rake::TestCase
   end
 
   def test_missing_constants_task
-    Rake.application.should_receive(:const_warning).with(:Task).once
     Object.const_missing(:Task)
+
+    expected = [
+      [[:const_warning, :Task], nil]
+    ]
+
+    assert_equal expected, @app.called
   end
 
   def test_missing_constants_file_task
-    Rake.application.should_receive(:const_warning).with(:FileTask).once
     Object.const_missing(:FileTask)
+
+    expected = [
+      [[:const_warning, :FileTask], nil]
+    ]
+
+    assert_equal expected, @app.called
   end
 
   def test_missing_constants_file_creation_task
-    Rake.application.should_receive(:const_warning).with(:FileCreationTask).once
     Object.const_missing(:FileCreationTask)
+
+    expected = [
+      [[:const_warning, :FileCreationTask], nil]
+    ]
+
+    assert_equal expected, @app.called
   end
 
   def test_missing_constants_rake_app
-    Rake.application.should_receive(:const_warning).with(:RakeApp).once
     Object.const_missing(:RakeApp)
+
+    expected = [
+      [[:const_warning, :RakeApp], nil]
+    ]
+
+    assert_equal expected, @app.called
   end
 
   def test_missing_other_constant
diff --git a/test/test_rake_win32.rb b/test/test_rake_win32.rb
index d6ba0f2..fc2746a 100644
--- a/test/test_rake_win32.rb
+++ b/test/test_rake_win32.rb
@@ -1,64 +1,53 @@
 require File.expand_path('../helper', __FILE__)
 
 class TestRakeWin32 < Rake::TestCase
-  include InEnvironment
 
   Win32 = Rake::Win32
 
   def test_win32_system_dir_uses_home_if_defined
-    in_environment('RAKE_SYSTEM' => nil, 'HOME' => 'C:\\HP') do
-      assert_equal "C:/HP/Rake", Win32.win32_system_dir
-    end
+    ENV['HOME'] = 'C:\\HP'
+
+    assert_equal "C:/HP/Rake", Win32.win32_system_dir
   end
 
   def test_win32_system_dir_uses_homedrive_homepath_when_no_home_defined
-    in_environment(
-      'RAKE_SYSTEM' => nil,
-      'HOME' => nil,
-      'HOMEDRIVE' => "C:",
-      'HOMEPATH' => "\\HP"
-      ) do
-      assert_equal "C:/HP/Rake", Win32.win32_system_dir
-    end
+    ENV['HOME']      = nil
+    ENV['HOMEDRIVE'] = 'C:'
+    ENV['HOMEPATH']  = '\\HP'
+
+    assert_equal "C:/HP/Rake", Win32.win32_system_dir
   end
 
   def test_win32_system_dir_uses_appdata_when_no_home_or_home_combo
-    in_environment(
-      'RAKE_SYSTEM' => nil,
-      'HOME' => nil,
-      'HOMEDRIVE' => nil,
-      'HOMEPATH' => nil,
-      'APPDATA' => "C:\\Documents and Settings\\HP\\Application Data"
-      ) do
-      assert_equal "C:/Documents and Settings/HP/Application Data/Rake", Win32.win32_system_dir
-    end
+    ENV['APPDATA']   = "C:\\Documents and Settings\\HP\\Application Data"
+    ENV['HOME']      = nil
+    ENV['HOMEDRIVE'] = nil
+    ENV['HOMEPATH']  = nil
+
+    assert_equal "C:/Documents and Settings/HP/Application Data/Rake",
+                 Win32.win32_system_dir
   end
 
   def test_win32_system_dir_fallback_to_userprofile_otherwise
-    in_environment(
-      'RAKE_SYSTEM' => nil,
-      'HOME' => nil,
-      'HOMEDRIVE' => nil,
-      'HOMEPATH' => nil,
-      'APPDATA' => nil,
-      'USERPROFILE' => "C:\\Documents and Settings\\HP"
-      ) do
-      assert_equal "C:/Documents and Settings/HP/Rake", Win32.win32_system_dir
-    end
+    ENV['HOME']        = nil
+    ENV['HOMEDRIVE']   = nil
+    ENV['HOMEPATH']    = nil
+    ENV['APPDATA']     = nil
+    ENV['USERPROFILE'] = "C:\\Documents and Settings\\HP"
+
+    assert_equal "C:/Documents and Settings/HP/Rake", Win32.win32_system_dir
   end
 
   def test_win32_system_dir_nil_of_no_env_vars
-    in_environment(
-      'RAKE_SYSTEM' => nil,
-      'HOME' => nil,
-      'HOMEDRIVE' => nil,
-      "HOMEPATH" => nil,
-      'APPDATA' => nil,
-      "USERPROFILE" => nil
-      ) do
-      assert_raises(Rake::Win32::Win32HomeError) do
-        Win32.win32_system_dir
-      end
+    ENV['APPDATA']     = nil
+    ENV['HOME']        = nil
+    ENV['HOMEDRIVE']   = nil
+    ENV['HOMEPATH']    = nil
+    ENV['RAKE_SYSTEM'] = nil
+    ENV['USERPROFILE'] = nil
+
+    assert_raises(Rake::Win32::Win32HomeError) do
+      Win32.win32_system_dir
     end
   end
 

-- 
rake.git



More information about the Pkg-ruby-extras-commits mailing list