diff options
author | Lars Wirzenius <liw@liw.fi> | 2020-11-27 16:57:21 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2020-11-28 10:37:40 +0200 |
commit | aa6709b2f657a964c2af04f6370e7eb7c117bf9e (patch) | |
tree | 9e0f5ba56f45eb24d286ac38a67b27ed0899f9d6 /subplot/summain.py | |
parent | b5b5884097219d77aa0b4cd6ad4d3a9c1407f5a6 (diff) | |
download | summain-rs-aa6709b2f657a964c2af04f6370e7eb7c117bf9e.tar.gz |
feat: implement Summain in Rust
Diffstat (limited to 'subplot/summain.py')
-rw-r--r-- | subplot/summain.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/subplot/summain.py b/subplot/summain.py new file mode 100644 index 0000000..3ea6188 --- /dev/null +++ b/subplot/summain.py @@ -0,0 +1,36 @@ +import os + + +def install_summain(ctx): + runcmd_prepend_to_path = globals()["runcmd_prepend_to_path"] + srcdir = globals()["srcdir"] + bindir = os.path.join(srcdir, "target", "debug") + runcmd_prepend_to_path(ctx, dirname=bindir) + + +def create_directory(ctx, dirname=None): + os.mkdir(dirname) + + +def create_file(ctx, filename=None): + open(filename, "w").close() + + +def set_atime(ctx, filename=None, timestamp=None): + st = os.lstat(filename) + os.utime(filename, (int(timestamp), int(st.st_mtime))) + + +def set_mtime(ctx, filename=None, timestamp=None): + st = os.lstat(filename) + os.utime(filename, (int(st.st_atime), int(timestamp))) + + +def output_matches_file(ctx, filename=None): + runcmd_get_stdout = globals()["runcmd_get_stdout"] + get_file = globals()["get_file"] + assert_eq = globals()["assert_eq"] + + actual = runcmd_get_stdout(ctx) + expected = get_file(filename).decode("UTF-8") + assert_eq(actual, expected) |