Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/rake/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,13 @@ def standard_rake_options # :nodoc:
select_tasks_to_show(options, :describe, value)
}
],
["--directory", "-C [DIRECTORY]",
"Change to DIRECTORY before doing anything.",
lambda { |value|
Dir.chdir value
@original_dir = Dir.pwd
}
],
["--dry-run", "-n",
"Do a dry run without executing actions.",
lambda { |value|
Expand Down
22 changes: 22 additions & 0 deletions test/test_rake_application_options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,28 @@ def test_describe_with_pattern
end
end

def test_directory
pwd = Dir.pwd
[["--directory"], "--directory=", ["-C"], "-C"].each do |flag|
Dir.mktmpdir do |dir|
begin
flags(flag.dup << dir) do
assert_equal(File.realpath(dir), @app.original_dir)
end
ensure
Dir.chdir(pwd)
end
begin
assert_raises(Errno::ENOENT) do
flags(flag.dup << dir+"/nonexistent")
end
ensure
Dir.chdir(pwd)
end
end
end
end

def test_execute
$xyzzy = 0
flags("--execute=$xyzzy=1", "-e $xyzzy=1") do
Expand Down