3
0
Fork 0
mirror of https://github.com/YosysHQ/sby.git synced 2025-09-03 10:08:17 +00:00
sby/tests/links/symlink.py
Krystine Sherwin a906714c95
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.
2025-08-02 09:17:21 +12:00

18 lines
541 B
Python

from pathlib import Path
import sys
def main():
workdir, task = sys.argv[1:]
src = Path(workdir) / "src"
for srcfile in src.iterdir():
if srcfile.name == "heredoc":
assert(not srcfile.is_symlink())
with open(srcfile, "r") as f:
local_contents = f.readline()
assert(local_contents.strip() == 'log foo')
else:
assert(srcfile.is_symlink() == (task == "link"))
assert(srcfile.name != "script.ys")
if __name__ == "__main__":
main()