Create symlink only if target is accessible (#7429)
Merge pull request 7429
This commit is contained in:
parent
8c0a250da4
commit
c368fec322
|
@ -190,6 +190,15 @@ class JekyllUnitTest < Minitest::Test
|
||||||
skip msg.to_s.magenta
|
skip msg.to_s.magenta
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def symlink_if_allowed(target, sym_file)
|
||||||
|
FileUtils.ln_sf(target, sym_file)
|
||||||
|
rescue Errno::EACCES
|
||||||
|
skip "Permission denied for creating a symlink to #{target.inspect} " \
|
||||||
|
"on this machine".magenta
|
||||||
|
rescue NotImplementedError => error
|
||||||
|
skip error.to_s.magenta
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class FakeLogger
|
class FakeLogger
|
||||||
|
|
|
@ -35,7 +35,8 @@ class TestLayoutReader < JekyllUnitTest
|
||||||
|
|
||||||
context "when a layout is a symlink" do
|
context "when a layout is a symlink" do
|
||||||
setup do
|
setup do
|
||||||
FileUtils.ln_sf("/etc/passwd", source_dir("_layouts", "symlink.html"))
|
symlink_if_allowed("/etc/passwd", source_dir("_layouts", "symlink.html"))
|
||||||
|
|
||||||
@site = fixture_site(
|
@site = fixture_site(
|
||||||
"safe" => true,
|
"safe" => true,
|
||||||
"include" => ["symlink.html"]
|
"include" => ["symlink.html"]
|
||||||
|
@ -43,7 +44,7 @@ class TestLayoutReader < JekyllUnitTest
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
FileUtils.rm(source_dir("_layouts", "symlink.html"))
|
FileUtils.rm_f(source_dir("_layouts", "symlink.html"))
|
||||||
end
|
end
|
||||||
|
|
||||||
should "only read the layouts which are in the site" do
|
should "only read the layouts which are in the site" do
|
||||||
|
@ -57,7 +58,7 @@ class TestLayoutReader < JekyllUnitTest
|
||||||
|
|
||||||
context "with a theme" do
|
context "with a theme" do
|
||||||
setup do
|
setup do
|
||||||
FileUtils.ln_sf("/etc/passwd", theme_dir("_layouts", "theme-symlink.html"))
|
symlink_if_allowed("/etc/passwd", theme_dir("_layouts", "theme-symlink.html"))
|
||||||
@site = fixture_site(
|
@site = fixture_site(
|
||||||
"include" => ["theme-symlink.html"],
|
"include" => ["theme-symlink.html"],
|
||||||
"theme" => "test-theme",
|
"theme" => "test-theme",
|
||||||
|
@ -66,7 +67,7 @@ class TestLayoutReader < JekyllUnitTest
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
FileUtils.rm(theme_dir("_layouts", "theme-symlink.html"))
|
FileUtils.rm_f(theme_dir("_layouts", "theme-symlink.html"))
|
||||||
end
|
end
|
||||||
|
|
||||||
should "not read a symlink'd theme" do
|
should "not read a symlink'd theme" do
|
||||||
|
|
Loading…
Reference in New Issue