properly handle symlinks as relative to the output dir
the code meant to make symlinks relative to the output directory, but only actually succeeded at it for targets in the root of the output directory; since we already check that the target is not breaking out of the instance, we can generate the output symlink relative to itself and fix the subdirred-symlink behavior Signed-off-by: Brian S. Stephan <bss@incorporeal.org>
This commit is contained in:
@@ -52,6 +52,23 @@ def test_file_copy_symlink():
|
||||
assert os.path.islink(os.path.join(tmpdir, 'symlink-to-foo.txt'))
|
||||
|
||||
|
||||
def test_file_copy_subdir_symlink():
|
||||
"""Test the ability to sync a symlink in a subdirectory to the output dir."""
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
src_dir = os.path.join(HERE, 'instance')
|
||||
generator = ssg.StaticSiteGenerator(src_dir, tmpdir)
|
||||
# need to make the subdirectory as if the generator already did
|
||||
os.mkdir(os.path.join(tmpdir, 'subdir'))
|
||||
generator.build_file_in_destination(os.path.join(instance_dir, 'pages'), 'subdir',
|
||||
'relative-symlink-to-parent.md', tmpdir)
|
||||
# need to copy the destination for os.path.exists to be happy with this
|
||||
generator.build_file_in_destination(os.path.join(instance_dir, 'pages'), '', 'more-metadata.md', tmpdir)
|
||||
logger.warning("created symlink %s",
|
||||
os.readlink(os.path.join(tmpdir, 'subdir', 'relative-symlink-to-parent.md')))
|
||||
assert os.path.islink(os.path.join(tmpdir, 'subdir', 'relative-symlink-to-parent.md'))
|
||||
assert os.path.exists(os.path.join(tmpdir, 'subdir', 'relative-symlink-to-parent.md'))
|
||||
|
||||
|
||||
def test_file_copy_symlink_of_markdown_also_has_html_symlink():
|
||||
"""Test the ability to sync source and generated symlinks to the output dir."""
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
|
||||
Reference in New Issue
Block a user