Skip to content
Browse files

Don't use PWD to load libraries

This allows rake tests to be run from outside the source directory.
  • Loading branch information...
1 parent b9df816 commit 7f9edafd06799778c12889e92a70d6e7033637e3 @drbrain drbrain committed
View
13 test/helper.rb
@@ -31,6 +31,19 @@ class TaskManager
def setup
ARGV.clear
+ test_dir = File.basename File.dirname File.expand_path __FILE__
+
+ @rake_root = if test_dir == 'test' then
+ # rake repository
+ File.expand_path '../../', __FILE__
+ else
+ # ruby repository
+ File.expand_path '../../../', __FILE__
+ end
+
+ @rake_exec = File.join @rake_root, 'bin', 'rake'
+ @rake_lib = File.join @rake_root, 'lib'
+
@orig_PWD = Dir.pwd
@orig_APPDATA = ENV['APPDATA']
@orig_HOME = ENV['HOME']
View
6 test/test_rake_backtrace.rb
@@ -4,9 +4,9 @@
class TestRakeBacktrace < Rake::TestCase
# TODO: factor out similar code in test_rake_functional.rb
def rake(*args)
- lib = File.join(@orig_PWD, "lib")
- bin_rake = File.join(@orig_PWD, "bin", "rake")
- Open3.popen3(RUBY, "-I", lib, bin_rake, *args) { |_, _, err, _| err.read }
+ Open3.popen3(RUBY, "-I", @rake_lib, @rake_exec, *args) { |_, _, err, _|
+ err.read
+ }
end
def invoke(task_name)
View
2 test/test_rake_file_task.rb
@@ -116,7 +116,7 @@ def ztest_file_deletes_on_failure
end
def load_phony
- load File.join(@orig_PWD, "lib/rake/phony.rb")
+ load File.join(@rake_lib, "rake/phony.rb")
end
end
View
10 test/test_rake_functional.rb
@@ -5,9 +5,9 @@
class TestRakeFunctional < Rake::TestCase
def setup
- @rake_path = File.expand_path("bin/rake")
- lib_path = File.expand_path("lib")
- @ruby_options = ["-I#{lib_path}", "-I."]
+ super
+
+ @ruby_options = ["-I#{@rake_lib}", "-I."]
@verbose = ENV['VERBOSE']
if @verbose
@@ -17,8 +17,6 @@ def setup
puts @__name__
puts '-' * 80
end
-
- super
end
def test_rake_default
@@ -466,7 +464,7 @@ def ruby(*option_list)
# command line ruby options are included. Output is captured in
# @out and @err
def rake(*rake_options)
- run_ruby @ruby_options + [@rake_path] + rake_options
+ run_ruby @ruby_options + [@rake_exec] + rake_options
end
# Low level ruby command runner ...
View
2 test/test_rake_rake_test_loader.rb
@@ -10,7 +10,7 @@ def test_pattern
ARGV.replace %w[foo.rb test_*.rb -v]
- load File.join(@orig_PWD, 'lib/rake/rake_test_loader.rb')
+ load File.join(@rake_lib, 'rake/rake_test_loader.rb')
assert_equal %w[-v], ARGV
ensure
View
6 test/test_rake_reduce_compat.rb
@@ -4,9 +4,9 @@
class TestRakeReduceCompat < Rake::TestCase
# TODO: factor out similar code in test_rake_functional.rb
def rake(*args)
- lib = File.join(@orig_PWD, "lib")
- bin_rake = File.join(@orig_PWD, "bin", "rake")
- Open3.popen3(RUBY, "-I", lib, bin_rake, *args) { |_, out, _, _| out.read }
+ Open3.popen3(RUBY, "-I", @rake_lib, @rake_exec, *args) { |_, out, _, _|
+ out.read
+ }
end
def invoke_normal(task_name)

0 comments on commit 7f9edaf

Please sign in to comment.
Something went wrong with that request. Please try again.