Fix Cache#mkdir_p to handle absolute paths - fix #5
This commit is contained in:
parent
5a0d80b781
commit
ea30b0b5ee
@ -181,6 +181,7 @@ module Rscons
|
|||||||
def mkdir_p(path)
|
def mkdir_p(path)
|
||||||
parts = path.split(/[\\\/]/)
|
parts = path.split(/[\\\/]/)
|
||||||
parts.each_index do |i|
|
parts.each_index do |i|
|
||||||
|
next if parts[i] == ""
|
||||||
subpath = File.join(*parts[0, i + 1])
|
subpath = File.join(*parts[0, i + 1])
|
||||||
unless File.exists?(subpath)
|
unless File.exists?(subpath)
|
||||||
FileUtils.mkdir(subpath)
|
FileUtils.mkdir(subpath)
|
||||||
|
@ -225,6 +225,16 @@ module Rscons
|
|||||||
cache.mkdir_p("one\\two\\four")
|
cache.mkdir_p("one\\two\\four")
|
||||||
cache.directories.should == ["one/two", "one/two/three", "one/two/four"]
|
cache.directories.should == ["one/two", "one/two/three", "one/two/four"]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "handles absolute paths" do
|
||||||
|
_cache = {}
|
||||||
|
cache = build_from(_cache)
|
||||||
|
File.should_receive(:exists?).with("/one").and_return(true)
|
||||||
|
File.should_receive(:exists?).with("/one/two").and_return(false)
|
||||||
|
FileUtils.should_receive(:mkdir).with("/one/two")
|
||||||
|
cache.mkdir_p("/one/two")
|
||||||
|
cache.directories.should == ["/one/two"]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#directories" do
|
describe "#directories" do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user