From 79183fab131b0e426abf647472469aed160e66f7 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 12 Dec 2020 11:44:50 +0200 Subject: feat: support symbolic links --- subplot/summain.py | 12 ++++++++---- subplot/summain.yaml | 3 +++ 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'subplot') diff --git a/subplot/summain.py b/subplot/summain.py index 98eecf2..4efc8c4 100644 --- a/subplot/summain.py +++ b/subplot/summain.py @@ -17,14 +17,18 @@ def create_file(ctx, filename=None): open(filename, "w").close() +def create_symlink(ctx, linkname=None, target=None): + os.symlink(target, linkname) + + def set_atime(ctx, filename=None, timestamp=None): st = os.lstat(filename) - os.utime(filename, (int(timestamp), int(st.st_mtime))) + os.utime(filename, (int(timestamp), int(st.st_mtime)), follow_symlinks=False) def set_mtime(ctx, filename=None, timestamp=None): st = os.lstat(filename) - os.utime(filename, (int(st.st_atime), int(timestamp))) + os.utime(filename, (int(st.st_atime), int(timestamp)), follow_symlinks=False) def output_matches_file(ctx, filename=None): @@ -35,6 +39,6 @@ def output_matches_file(ctx, filename=None): actual = runcmd_get_stdout(ctx) expected = get_file(filename).decode("UTF-8") logging.debug("output_matches:") - logging.debug(f" actual: {actual!r}") - logging.debug(f" expect: {expected!r}") + logging.debug(f" actual:\n{actual}") + logging.debug(f" expect:\n{expected}") assert_eq(actual, expected) diff --git a/subplot/summain.yaml b/subplot/summain.yaml index 31bc28c..2fd12a5 100644 --- a/subplot/summain.yaml +++ b/subplot/summain.yaml @@ -7,6 +7,9 @@ - given: file {filename} function: create_file +- given: symlink {linkname} pointing at {target} + function: create_symlink + - given: atime for {filename} is {timestamp} function: set_atime -- cgit v1.2.1