summaryrefslogtreecommitdiff
path: root/subplot
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-12-12 11:44:50 +0200
committerLars Wirzenius <liw@liw.fi>2020-12-12 11:44:50 +0200
commit79183fab131b0e426abf647472469aed160e66f7 (patch)
tree156f23311b1e2ceabb069dd46bd4af871f5005d3 /subplot
parent0e3bec381d9c1a04448b62483d1635961ca3b3d3 (diff)
downloadsummain-rs-79183fab131b0e426abf647472469aed160e66f7.tar.gz
feat: support symbolic links
Diffstat (limited to 'subplot')
-rw-r--r--subplot/summain.py12
-rw-r--r--subplot/summain.yaml3
2 files changed, 11 insertions, 4 deletions
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