Skip to content

Commit

Permalink
don't print the rakefile directory message if it's in the same direct…
Browse files Browse the repository at this point in the history
…ory we started in
  • Loading branch information
alexch committed Nov 13, 2010
1 parent 9dad179 commit 6632653
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.rdoc
Expand Up @@ -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:
Expand Down
8 changes: 6 additions & 2 deletions lib/rake/application.rb
Expand Up @@ -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
Expand All @@ -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|
Expand Down
4 changes: 1 addition & 3 deletions test/functional/functional_test.rb
Expand Up @@ -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
39 changes: 39 additions & 0 deletions test/lib/application_test.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 6632653

Please sign in to comment.