summaryrefslogtreecommitdiff
path: root/yarns/900-implements.yarn
diff options
context:
space:
mode:
Diffstat (limited to 'yarns/900-implements.yarn')
-rw-r--r--yarns/900-implements.yarn36
1 files changed, 36 insertions, 0 deletions
diff --git a/yarns/900-implements.yarn b/yarns/900-implements.yarn
index 57f52aa..26a05a7 100644
--- a/yarns/900-implements.yarn
+++ b/yarns/900-implements.yarn
@@ -83,3 +83,39 @@ The stdout, stderr, and exit code have been saved. Inspect them.
IMPLEMENTS THEN output matches (.+)
cat "$DATADIR/stdout"
grep "$MATCH_1" "$DATADIR/stdout"
+
+## Manage a remote temporary directory
+
+Whenever we need to do anything that takes more than one step, we'll
+need a temporary directory in which to work. This is similar to the
+`DATADIR` that yarn provides us on the local machine.
+
+ IMPLEMENTS GIVEN a remote temporary directory to use
+ . "$DATADIR/config.sh"
+ name="$(ssh "$ACCOUNT@$SERVER" mktemp -d)"
+ echo "REMOTETMP=$name" >> "$DATADIR/config.sh"
+
+ IMPLEMENTS FINALLY remove remote temporary directory
+ # FIXME: The following will fail if REMOTETMP contains shell's
+ # magic characters or whitespace. Ugh.
+ . "$DATADIR/config.sh"
+ ssh "$ACCOUNT@$SERVER" rm -rf "$REMOTETMP"
+
+## Create remote directory
+
+ IMPLEMENTS GIVEN a directory (\S+) on the server
+ . "$DATADIR/config.sh"
+ run_remotely "$ACCOUNT@$SERVER" "$REMOTETMP" "mkdir $MATCH_1"
+
+## Check for files on the remote end
+
+ IMPLEMENTS THEN remote files (\S+) exist
+ . "$DATADIR/config.sh"
+ run_remotely "$ACCOUNT@$SERVER" "$REMOTETMP" "ls -d $MATCH_1" |
+ grep .
+
+## Run a command on the server
+
+ IMPLEMENTS WHEN server runs (.+)
+ . "$DATADIR/config.sh"
+ run_remotely "$ACCOUNT@$SERVER" "$REMOTETMP" "$MATCH_1"