From a906714c951c8b5ee010a30cb2d3399dc56566cf Mon Sep 17 00:00:00 2001 From: Krystine Sherwin <93062060+KrystalDelusion@users.noreply.github.com> Date: Sat, 2 Aug 2025 09:17:21 +1200 Subject: [PATCH] Add test for copying directories As per https://stackoverflow.com/a/54950959, `os.path.basename()` returns an empty string if the string ends with a trailing slash. This means that the target implied by `dir/` differs from an explicit target of `dir/`, and changes the behaviour to copy files to the root `src` directory instead. --- tests/links/symlink.py | 2 +- tests/links/symlink.sby | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/links/symlink.py b/tests/links/symlink.py index a6a06d5..bf5bd6b 100644 --- a/tests/links/symlink.py +++ b/tests/links/symlink.py @@ -1,4 +1,3 @@ -import os from pathlib import Path import sys @@ -13,6 +12,7 @@ def main(): assert(local_contents.strip() == 'log foo') else: assert(srcfile.is_symlink() == (task == "link")) + assert(srcfile.name != "script.ys") if __name__ == "__main__": main() diff --git a/tests/links/symlink.sby b/tests/links/symlink.sby index 52fa881..c3841ce 100644 --- a/tests/links/symlink.sby +++ b/tests/links/symlink.sby @@ -1,6 +1,8 @@ [tasks] link copy +dir_implicit: dir +dir_explicit: dir [options] mode prep @@ -15,7 +17,9 @@ script dir/script.ys [files] ../../docs/examples/demos/picorv32.v prv32fmcmp.v -dir +~dir: dir +dir_implicit: dir/ +dir_explicit: dir/ dir/ [file heredoc] log foo