Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make test file requires directory independent

Always reset PWD
  • Loading branch information...
commit cbce3c7b36680591021b0dd824587e81dc63ba56 1 parent 75c354f
@drbrain drbrain authored
Showing with 111 additions and 51 deletions.
  1. +11 −1 test/helper.rb
  2. +4 −1 test/in_environment.rb
  3. +1 −1  test/test_rake.rb
  4. +9 −4 test/test_rake_application.rb
  5. +1 −1  test/test_rake_clean.rb
  6. +3 −2 test/test_rake_definitions.rb
  7. +1 −1  test/test_rake_dsl.rb
  8. +1 −1  test/test_rake_early_time.rb
  9. +1 −1  test/test_rake_extension.rb
  10. +5 −3 test/test_rake_file_creation_task.rb
  11. +5 −1 test/test_rake_file_list.rb
  12. +7 −3 test/test_rake_file_task.rb
  13. +5 −3 test/test_rake_file_utils.rb
  14. +3 −1 test/test_rake_ftp_file.rb
  15. +4 −3 test/test_rake_functional.rb
  16. +7 −1 test/test_rake_invocation_chain.rb
  17. +1 −1  test/test_rake_makefile_loader.rb
  18. +3 −1 test/test_rake_multi_task.rb
  19. +1 −1  test/test_rake_name_space.rb
  20. +1 −1  test/test_rake_package_task.rb
  21. +3 −1 test/test_rake_path_map.rb
  22. +1 −1  test/test_rake_pseudo_status.rb
  23. +3 −1 test/test_rake_rdoc_task.rb
  24. +1 −1  test/test_rake_require.rb
  25. +5 −3 test/test_rake_rules.rb
  26. +7 −2 test/test_rake_task.rb
  27. +1 −1  test/test_rake_task_arguments.rb
  28. +1 −1  test/test_rake_task_lib.rb
  29. +5 −1 test/test_rake_task_manager.rb
  30. +5 −1 test/test_rake_test_task.rb
  31. +3 −1 test/test_rake_top_level_functions.rb
  32. +1 −2  test/test_rake_win32.rb
  33. +1 −3 test/test_sys.rb
View
12 test/helper.rb
@@ -3,16 +3,26 @@
require 'flexmock/test_unit_integration'
require 'minitest/autorun'
require 'rake'
+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
+ include InEnvironment
+ include FileCreation
+
include Rake::DSL
+ def setup
+ @orig_PWD = Dir.pwd
+ end
+
def teardown
flexmock_teardown
- super
+
+ Dir.chdir @orig_PWD
end
def ignore_deprecations
View
5 test/in_environment.rb
@@ -13,10 +13,12 @@ def in_environment(settings=nil)
end
# Set the environment according to the settings hash.
- def set_env(settings) # :nodoc:
+ 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)
@@ -26,6 +28,7 @@ def set_env(settings) # :nodoc:
ENV[k] = v
end
end
+
result
end
View
2  test/test_rake.rb
@@ -1,4 +1,4 @@
-require 'test/helper'
+require File.expand_path('../helper', __FILE__)
class TestRake < Rake::TestCase
def test_each_dir_parent
View
13 test/test_rake_application.rb
@@ -1,5 +1,4 @@
-require 'test/helper'
-require 'test/in_environment'
+require File.expand_path('../helper', __FILE__)
TESTING_REQUIRE = [ ]
@@ -9,6 +8,7 @@ class TestRakeApplication < Rake::TestCase
def setup
super
+
@app = Rake::Application.new
@app.options.rakelib = []
Rake::TaskManager.record_task_metadata = true
@@ -16,6 +16,7 @@ def setup
def teardown
Rake::TaskManager.record_task_metadata = false
+
super
end
@@ -367,9 +368,10 @@ def test_deprecation_message
######################################################################
class TestRakeApplicationOptions < Rake::TestCase
- include InEnvironment
def setup
+ super
+
clear_argv
Rake::FileUtilsExt.verbose_flag = false
Rake::FileUtilsExt.nowrite_flag = false
@@ -380,6 +382,8 @@ def teardown
clear_argv
Rake::FileUtilsExt.verbose_flag = false
Rake::FileUtilsExt.nowrite_flag = false
+
+ super
end
def clear_argv
@@ -743,6 +747,8 @@ def @app.exit(*args)
class TestRakeTaskArgumentParsing < Rake::TestCase
def setup
+ super
+
@app = Rake::Application.new
end
@@ -785,7 +791,6 @@ def test_keeps_embedded_spaces
end
class TestRakeTaskArgumentParsing < Rake::TestCase
- include InEnvironment
def test_terminal_width_using_env
app = Rake::Application.new
View
2  test/test_rake_clean.rb
@@ -1,4 +1,4 @@
-require 'test/helper'
+require File.expand_path('../helper', __FILE__)
require 'rake/clean'
class TestRakeClean < Rake::TestCase
View
5 test/test_rake_definitions.rb
@@ -1,6 +1,5 @@
-require 'test/helper'
+require File.expand_path('../helper', __FILE__)
require 'fileutils'
-require 'test/file_creation'
######################################################################
class TestRakeDefinitions < Rake::TestCase
@@ -9,6 +8,8 @@ class TestRakeDefinitions < Rake::TestCase
EXISTINGFILE = "testdata/existing"
def setup
+ super
+
Task.clear
end
View
2  test/test_rake_dsl.rb
@@ -1,4 +1,4 @@
-require 'test/helper'
+require File.expand_path('../helper', __FILE__)
class TestRakeDsl < Rake::TestCase
View
2  test/test_rake_early_time.rb
@@ -1,4 +1,4 @@
-require 'test/helper'
+require File.expand_path('../helper', __FILE__)
class TestRakeEarlyTime < Rake::TestCase
def test_create
View
2  test/test_rake_extension.rb
@@ -1,4 +1,4 @@
-require 'test/helper'
+require File.expand_path('../helper', __FILE__)
require 'stringio'
######################################################################
View
8 test/test_rake_file_creation_task.rb
@@ -1,21 +1,23 @@
-require 'test/helper'
+require File.expand_path('../helper', __FILE__)
require 'fileutils'
-require 'test/file_creation'
######################################################################
class TestRakeFileCreationTask < Rake::TestCase
include Rake
include Rake::DSL
- include FileCreation
DUMMY_DIR = 'testdata/dummy_dir'
def setup
+ super
+
Task.clear
end
def teardown
FileUtils.rm_rf DUMMY_DIR
+
+ super
end
def test_file_needed
View
6 test/test_rake_file_list.rb
@@ -1,15 +1,19 @@
-require 'test/helper'
+require File.expand_path('../helper', __FILE__)
class TestRakeFileList < Rake::TestCase
FileList = Rake::FileList
def setup
+ super
+
create_test_data
end
def teardown
# FileList.select_default_ignore_patterns
FileUtils.rm_rf("testdata")
+
+ super
end
def test_delegating_methods_do_not_include_to_a_or_to_ary
View
10 test/test_rake_file_task.rb
@@ -1,13 +1,13 @@
-require 'test/helper'
+require File.expand_path('../helper', __FILE__)
require 'fileutils'
-require 'test/file_creation'
######################################################################
class TestRakeFileTask < Rake::TestCase
include Rake
- include FileCreation
def setup
+ super
+
Task.clear
@runs = Array.new
FileUtils.rm_f NEWFILE
@@ -108,11 +108,15 @@ class TestRakeDirectoryTask < Rake::TestCase
include Rake
def setup
+ super
+
Rake.rm_rf "testdata", :verbose=>false
end
def teardown
Rake.rm_rf "testdata", :verbose=>false
+
+ super
end
def test_directory
View
8 test/test_rake_file_utils.rb
@@ -1,12 +1,12 @@
-require 'test/helper'
-require 'test/file_creation'
+require File.expand_path('../helper', __FILE__)
require 'fileutils'
require 'stringio'
class TestRakeFileUtils < Rake::TestCase
- include FileCreation
def setup
+ super
+
File.chmod(0750, "test/shellcommand.rb")
end
@@ -14,6 +14,8 @@ def teardown
File.chmod(0755, "test/shellcommand.rb")
FileUtils.rm_rf("testdata")
FileUtils::LN_SUPPORTED[0] = true
+
+ super
end
def test_rm_one_file
View
4 test/test_rake_ftp_file.rb
@@ -1,4 +1,4 @@
-require 'test/helper'
+require File.expand_path('../helper', __FILE__)
require 'date'
require 'time'
require 'rake/contrib/ftptools'
@@ -16,6 +16,8 @@ def self.now
class TestRakeFtpFile < Rake::TestCase
def setup
+ super
+
Rake::FtpFile.class_eval { @date_class = FakeDate; @time_class = FakeDate }
end
View
7 test/test_rake_functional.rb
@@ -18,9 +18,8 @@
end
end
-require 'test/helper'
+require File.expand_path('../helper', __FILE__)
require 'fileutils'
-require 'test/in_environment'
# Version 2.1.9 of session has a bug where the @debug instance
# variable is not initialized, causing warning messages. This snippet
@@ -36,15 +35,17 @@ def initialize(*args)
end if defined? Session
class TestRakeFunctional < Rake::TestCase
- include InEnvironment
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?
+
if @verbose
puts
puts
View
8 test/test_rake_invocation_chain.rb
@@ -1,9 +1,11 @@
-require 'test/helper'
+require File.expand_path('../helper', __FILE__)
######################################################################
class TestRakeAnEmptyInvocationChain < Rake::TestCase
def setup
+ super
+
@empty = Rake::InvocationChain::EMPTY
end
@@ -22,6 +24,8 @@ def test_to_s
class TestRakeAnInvocationChainWithOneMember < Rake::TestCase
def setup
+ super
+
@empty = Rake::InvocationChain::EMPTY
@first_member = "A"
@chain = @empty.append(@first_member)
@@ -49,6 +53,8 @@ def test_to_s
class TestRakeAnInvocationChainWithMultipleMember < Rake::TestCase
def setup
+ super
+
@first_member = "A"
@second_member = "B"
ch = Rake::InvocationChain::EMPTY.append(@first_member)
View
2  test/test_rake_makefile_loader.rb
@@ -1,4 +1,4 @@
-require 'test/helper'
+require File.expand_path('../helper', __FILE__)
require 'rake/loaders/makefile'
class TestRakeMakefileLoader < Rake::TestCase
View
4 test/test_rake_multi_task.rb
@@ -1,4 +1,4 @@
-require 'test/helper'
+require File.expand_path('../helper', __FILE__)
require 'thread'
######################################################################
@@ -7,6 +7,8 @@ class TestRakeMultiTask < Rake::TestCase
include Rake::DSL
def setup
+ super
+
Task.clear
@runs = Array.new
@mutex = Mutex.new
View
2  test/test_rake_name_space.rb
@@ -1,4 +1,4 @@
-require 'test/helper'
+require File.expand_path('../helper', __FILE__)
class TestRakeNameSpace < Rake::TestCase
View
2  test/test_rake_package_task.rb
@@ -1,4 +1,4 @@
-require 'test/helper'
+require File.expand_path('../helper', __FILE__)
require 'rake/packagetask'
class TestRakePackageTask < Rake::TestCase
View
4 test/test_rake_path_map.rb
@@ -1,4 +1,4 @@
-require 'test/helper'
+require File.expand_path('../helper', __FILE__)
# ====================================================================
class TestRakePathMap < Rake::TestCase
@@ -158,6 +158,8 @@ def test_complex_patterns
class TestRakePathMapExplode < Rake::TestCase
def setup
+ super
+
String.class_eval { public :pathmap_explode }
end
View
2  test/test_rake_pseudo_status.rb
@@ -1,4 +1,4 @@
-require 'test/helper'
+require File.expand_path('../helper', __FILE__)
class TestRakePseudoStatus < Rake::TestCase
def test_with_zero_exit_status
View
4 test/test_rake_rdoc_task.rb
@@ -1,4 +1,4 @@
-require 'test/helper'
+require File.expand_path('../helper', __FILE__)
begin
old_verbose = $VERBOSE
$VERBOSE = nil
@@ -11,6 +11,8 @@ class TestRakeRDocTask < Rake::TestCase
include Rake
def setup
+ super
+
Task.clear
end
View
2  test/test_rake_require.rb
@@ -1,4 +1,4 @@
-require 'test/helper'
+require File.expand_path('../helper', __FILE__)
# ====================================================================
class TestRakeRequire < Rake::TestCase
View
8 test/test_rake_rules.rb
@@ -1,11 +1,9 @@
-require 'test/helper'
+require File.expand_path('../helper', __FILE__)
require 'fileutils'
-require 'test/file_creation'
######################################################################
class TestRakeRules < Rake::TestCase
include Rake
- include FileCreation
SRCFILE = "testdata/abc.c"
SRCFILE2 = "testdata/xyz.c"
@@ -15,6 +13,8 @@ class TestRakeRules < Rake::TestCase
DOTFOOFILE = "testdata/.foo"
def setup
+ super
+
Task.clear
@runs = []
FileUtils.mkdir_p 'testdata' # HACK use tmpdir
@@ -22,6 +22,8 @@ def setup
def teardown
FileList['testdata/*'].uniq.each do |f| rm_r(f, :verbose=>false) end
+
+ super
end
def test_multiple_rules1
View
9 test/test_rake_task.rb
@@ -1,4 +1,4 @@
-require 'test/helper'
+require File.expand_path('../helper', __FILE__)
require 'fileutils'
######################################################################
@@ -6,13 +6,16 @@ class TestRakeTask < Rake::TestCase
include Rake
def setup
+ super
+
Task.clear
Rake::TaskManager.record_task_metadata = true
end
def teardown
- super
Rake::TaskManager.record_task_metadata = false
+
+ super
end
def test_create
@@ -273,12 +276,14 @@ class TestRakeTaskWithArguments < Rake::TestCase
def setup
super
+
Task.clear
Rake::TaskManager.record_task_metadata = true
end
def teardown
Rake::TaskManager.record_task_metadata = false
+
super
end
View
2  test/test_rake_task_arguments.rb
@@ -1,4 +1,4 @@
-require 'test/helper'
+require File.expand_path('../helper', __FILE__)
######################################################################
class TestRakeTaskArguments < Rake::TestCase
View
2  test/test_rake_task_lib.rb
@@ -1,4 +1,4 @@
-require 'test/helper'
+require File.expand_path('../helper', __FILE__)
require 'rake/tasklib'
class TestRakeTaskLib < Rake::TestCase
View
6 test/test_rake_task_manager.rb
@@ -1,4 +1,4 @@
-require 'test/helper'
+require File.expand_path('../helper', __FILE__)
class TaskManager
include Rake::TaskManager
@@ -7,6 +7,8 @@ class TaskManager
class TestRakeTaskManager < Rake::TestCase
def setup
+ super
+
@tm = TaskManager.new
end
@@ -148,11 +150,13 @@ def test_correctly_scoped_prerequisites_are_invoked
class TestRakeTaskManagerArgumentResolution < Rake::TestCase
def setup
super
+
Rake.application.options.ignore_deprecate = true
end
def teardown
Rake.application.options.ignore_deprecate = false
+
super
end
View
6 test/test_rake_test_task.rb
@@ -1,16 +1,20 @@
-require 'test/helper'
+require File.expand_path('../helper', __FILE__)
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
View
4 test/test_rake_top_level_functions.rb
@@ -1,9 +1,10 @@
-require 'test/helper'
+require File.expand_path('../helper', __FILE__)
class TestRakeTopLevelFunctions < Rake::TestCase
def setup
super
+
@app = Rake.application
Rake.application = flexmock("app")
Rake.application.should_receive(:deprecate).
@@ -12,6 +13,7 @@ def setup
def teardown
Rake.application = @app
+
super
end
View
3  test/test_rake_win32.rb
@@ -1,5 +1,4 @@
-require 'test/helper'
-require 'test/in_environment'
+require File.expand_path('../helper', __FILE__)
class TestRakeWin32 < Rake::TestCase
include InEnvironment
View
4 test/test_sys.rb
@@ -1,5 +1,4 @@
-require 'test/helper'
-require 'test/file_creation'
+require File.expand_path('../helper', __FILE__)
begin
old_verbose = $VERBOSE
$VERBOSE = nil
@@ -9,7 +8,6 @@
end
class TestSys < Rake::TestCase
- include FileCreation
def test_split_all
assert_equal ['a'], Sys.split_all('a')
Please sign in to comment.
Something went wrong with that request. Please try again.