Permalink
Browse files

don't print the rakefile directory message if it's in the same direct…

…ory we started in
  • Loading branch information...
1 parent 9dad179 commit 66326539bb531a41e67df097de852f8bf6010cdc @alexch alexch committed Nov 13, 2010
Showing with 47 additions and 5 deletions.
  1. +1 −0 README.rdoc
  2. +6 −2 lib/rake/application.rb
  3. +1 −3 test/functional/functional_test.rb
  4. +39 −0 test/lib/application_test.rb
View
@@ -102,6 +102,7 @@ http://github.com/jimweirich/rake. The public git clone URL is
If you wish to run the unit and functional tests that come with Rake:
+* Install the 'flexmock' gem
* Install the 'session' gem in order to run the functional tests.
* CD into the top project directory of rake.
* Type one of the following:
View
@@ -467,12 +467,16 @@ def find_rakefile_location
Dir.chdir(Rake.original_dir)
end
+ def maybe_print_rakefile_directory(location)
+ puts "(in #{Dir.pwd})" unless (options.silent or original_dir == location)
+ end
+
def raw_load_rakefile # :nodoc:
rakefile, location = find_rakefile_location
if (! options.ignore_system) &&
(options.load_system || rakefile.nil?) &&
system_dir && File.directory?(system_dir)
- puts "(in #{Dir.pwd})" unless options.silent
+ maybe_print_rakefile_directory(location)
glob("#{system_dir}/*.rake") do |name|
add_import name
end
@@ -481,7 +485,7 @@ def raw_load_rakefile # :nodoc:
rakefile.nil?
@rakefile = rakefile
Dir.chdir(location)
- puts "(in #{Dir.pwd})" unless options.silent
+ maybe_print_rakefile_directory(location)
$rakefile = @rakefile if options.classic_namespace
Rake::Environment.load_rakefile(File.expand_path(@rakefile)) if @rakefile && @rakefile != ''
options.rakelib.each do |rlib|
@@ -5,11 +5,9 @@
gem 'session'
require 'session'
rescue LoadError
- puts "UNABLE TO RUN FUNCTIONAL TESTS"
- puts "No Session Found (gem install session)"
+ puts "Unable to run functional tests -- please run \"gem install session\""
end
if defined?(Session)
- puts "RUNNING WITH SESSIONS"
require 'test/functional/session_based_tests.rb'
end
@@ -154,6 +154,19 @@ def test_load_rakefile
end
end
+ def test_load_rakefile_doesnt_print_rakefile_directory_from_same_dir
+ in_environment("PWD" => "test/data/unittest") do
+ out = capture_stdout do
+ @app.instance_eval do
+ @original_dir = File.expand_path(".") # pretend we started from the unittest dir
+ raw_load_rakefile
+ end
+ end
+ rakefile, location = @app.find_rakefile_location
+ assert_no_match(/\(in #{location}\)/, out)
+ end
+ end
+
def test_load_rakefile_from_subdir
in_environment("PWD" => "test/data/unittest/subdir") do
@app.instance_eval do
@@ -166,6 +179,32 @@ def test_load_rakefile_from_subdir
end
end
+ def test_load_rakefile_prints_rakefile_directory_from_subdir
+ in_environment("PWD" => "test/data/unittest/subdir") do
+ out = capture_stdout do
+ @app.instance_eval do
+ raw_load_rakefile
+ end
+ end
+ rakefile, location = @app.find_rakefile_location
+ assert_match(/\(in #{location}\)/, out)
+ end
+ end
+
+ def test_load_rakefile_doesnt_print_rakefile_directory_from_subdir_if_silent
+ in_environment("PWD" => "test/data/unittest/subdir") do
+ out = capture_stdout do
+ @app.instance_eval do
+ handle_options
+ options.silent = true
+ raw_load_rakefile
+ end
+ end
+ rakefile, location = @app.find_rakefile_location
+ assert_no_match(/\(in #{location}\)/, out)
+ end
+ end
+
def test_load_rakefile_not_found
in_environment("PWD" => "/", "RAKE_SYSTEM" => 'not_exist') do
@app.instance_eval do

0 comments on commit 6632653

Please sign in to comment.