diff --git a/snakemake/dag.py b/snakemake/dag.py index eed5d0059..6daa8cbb5 100755 --- a/snakemake/dag.py +++ b/snakemake/dag.py @@ -639,8 +639,11 @@ def unneeded_files(): yield from filterfalse(partial(needed, job), tempfiles) for f in unneeded_files(): - logger.info("Removing temporary output file {}.".format(f)) - f.remove(remove_non_empty_dir=True) + if self.dryrun: + logger.info(f"Would remove temporary output {f}") + else: + logger.info("Removing temporary output {}.".format(f)) + f.remove(remove_non_empty_dir=True) def handle_log(self, job, upload_remote=True): for f in job.log: diff --git a/tests/test_github_issue1542/Snakefile b/tests/test_github_issue1542/Snakefile new file mode 100644 index 000000000..221fec1bc --- /dev/null +++ b/tests/test_github_issue1542/Snakefile @@ -0,0 +1,20 @@ +# Snakefile +rule all: + input: + "b.txt", + + +rule a: + output: + temp("a.txt"), + shell: + "touch a.txt" + + +rule b: + input: + "a.txt", + output: + "b.txt", + shell: + "touch b.txt" diff --git a/tests/test_github_issue1542/a.txt b/tests/test_github_issue1542/a.txt new file mode 100644 index 000000000..e69de29bb diff --git a/tests/test_github_issue1542/expected-results/a.txt b/tests/test_github_issue1542/expected-results/a.txt new file mode 100644 index 000000000..e69de29bb diff --git a/tests/tests.py b/tests/tests.py index bd5702a0e..515e780fa 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -1580,3 +1580,7 @@ def test_pipe_depend(): @skip_on_windows # no pipe support on windows def test_pipe_depend_target_file(): run(dpath("test_pipe_depend"), targets=["test.txt"], shouldfail=True) + + +def test_github_issue1542(): + run(dpath("test_github_issue1542"), dryrun=True)