Skip to content
Permalink
Browse files
fix: SameFileError #1153 (#1220)
* Fixes #1153. Path.parent replaces target path when full paths are provided, matching file and target locations.

* Turn absolute path into relative one instead of avoiding file path altogether.

Co-authored-by: Benjamin Essigman <essigman@scailyte.com>
Co-authored-by: Johannes Köster <johannes.koester@uni-due.de>
Co-authored-by: Johannes Köster <johannes.koester@tu-dortmund.de>
  • Loading branch information
4 people committed Nov 27, 2021
1 parent 426d92f commit ede313dcd31ea5f136b3b8f743e2265331475342
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
@@ -75,7 +75,12 @@ def generate(dag, path, deploy=["conda", "singularity"], configfiles=None):
def copy_files(files, content_type):
for f in files:
f = Path(f)
target = path / rulename / content_type / f.parent
parent = f.parent
if parent.is_absolute():
root = str(f.parents[len(f.parents) - 1])
parent = str(parent)[len(root) :]
print(parent)
target = path / rulename / content_type / parent
os.makedirs(target, exist_ok=True)
if f.is_dir():
shutil.copytree(f, target)
@@ -1,8 +1,12 @@
import os

rule all:
input:
expand("test/{sample}.tsv", sample=range(3))

rule a:
input:
os.environ["UNIT_TEST_TMPFILE"]
output:
temp("test/{sample}.txt")
shell:
@@ -1192,13 +1192,15 @@ def test_github_issue640():

@skip_on_windows # TODO check whether this might be enabled later
def test_generate_unit_tests():
tmpdir = run(
dpath("test_generate_unit_tests"),
generate_unit_tests=".tests/unit",
check_md5=False,
cleanup=False,
)
sp.check_call(["pytest", ".tests", "-vs"], cwd=tmpdir)
with tempfile.NamedTemporaryFile() as tmpfile:
os.environ["UNIT_TEST_TMPFILE"] = tmpfile.name
tmpdir = run(
dpath("test_generate_unit_tests"),
generate_unit_tests=".tests/unit",
check_md5=False,
cleanup=False,
)
sp.check_call(["pytest", ".tests", "-vs"], cwd=tmpdir)


@skip_on_windows

0 comments on commit ede313d

Please sign in to comment.