Skip to content

Commit

Permalink
Now loading system directories
Browse files Browse the repository at this point in the history
  • Loading branch information
jimweirich committed Aug 30, 2008
1 parent 2da66fd commit fa2e26f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/rake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1888,6 +1888,7 @@ def initialize
@default_loader = Rake::DefaultLoader.new
@original_dir = Dir.pwd
@top_level_tasks = []
add_loader('rb', DefaultLoader.new)
add_loader('rf', DefaultLoader.new)
add_loader('rake', DefaultLoader.new)
@tty_output = STDOUT.tty?
Expand Down Expand Up @@ -2071,6 +2072,10 @@ def unix?
RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux|)/i
end

def windows?
Config::CONFIG['host_os'] =~ /mswin/
end

def truncate(string, width)
if string.length <= width
string
Expand Down Expand Up @@ -2179,11 +2184,11 @@ def handle_options
options.silent = true
}
],
['--system', '-G',
['--system', '-g',
"Using system wide (global) rakefiles (usually '~/.rake/*.rake').",
lambda { |value| options.load_system = true }
],
['--no-system', '-g',
['--no-system', '-G',
"Use standard project Rakefile search paths, ignore system wide rakefiles.",
lambda { |value| options.ignore_system = true }
],
Expand Down Expand Up @@ -2276,7 +2281,9 @@ def raw_load_rakefile # :nodoc:
rakefile, location = find_rakefile_location
if (! options.ignore_system) && (options.load_system || rakefile.nil?)
puts "(in #{Dir.pwd})" unless options.silent
puts "NO SYSTEM HERE"
Dir["#{system_dir}/*.rake"].each do |name|
add_import name
end
else
@rakefile = rakefile
Dir.chdir(location)
Expand Down
20 changes: 20 additions & 0 deletions test/session_functional.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env ruby

begin
require 'rubygems'
rescue LoadError => ex
end
require 'test/unit'
require 'fileutils'
require 'session'
Expand Down Expand Up @@ -85,6 +89,22 @@ def test_rbext
assert_match %r{^OK$}, @out
end

def test_system
ENV['RAKE_SYSTEM'] = 'test/data/sys'
rake '-g', "sys1"
assert_match %r{^SYS1}, @out
ensure
ENV['RAKE_SYSTEM'] = nil
end

def test_no_system
ENV['RAKE_SYSTEM'] = 'test/data/sys'
rake '-G', "sys1"
assert_match %r{^Don't know how to build task}, @err # emacs wart: '
ensure
ENV['RAKE_SYSTEM'] = nil
end

def test_nosearch
mkdir_p "test/data/nosearch", :verbose => false rescue nil
Dir.chdir("test/data/nosearch") do rake "-N" end
Expand Down

0 comments on commit fa2e26f

Please sign in to comment.