]> git.wincent.com - docvim.git/commitdiff
Add bin/get and bin/put for updating integration tests and downstreams
authorGreg Hurrell <greg@hurrell.net>
Sun, 12 Jun 2016 06:50:47 +0000 (23:50 -0700)
committerGreg Hurrell <greg@hurrell.net>
Sun, 12 Jun 2016 06:50:47 +0000 (23:50 -0700)
bin/get [new file with mode: 0755]
bin/put [new file with mode: 0755]

diff --git a/bin/get b/bin/get
new file mode 100755 (executable)
index 0000000..a0de464
--- /dev/null
+++ b/bin/get
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+# Get fresh copies of source files for the integration tests.
+#
+# Assumes source repos exist as peers of the current repo.
+
+set -e
+
+usage() {
+  echo "Get fresh copies of source files for use in integration tests."
+  echo
+  echo "Usage:"
+  echo
+  echo "  bin/get ferret   # freshen a specific source"
+  echo "  bin/get scalpel"
+  echo "  --------------------------------------------"
+  echo "  bin/get all      # freshen all sources"
+  exit
+}
+
+update() {
+  local PROJECT
+  PROJECT="$1"
+  echo "Updating $PROJECT"
+  git --git-dir "../$PROJECT/.git" archive --prefix="$PROJECT/input/" master \
+    | tar -x -C tests/fixtures/integration -f -
+}
+
+if [ $# -eq 0 ]; then
+  usage
+else
+  while [ $# -gt 0 ]; do
+    PROJECT=$1
+    shift
+    case $PROJECT in
+      all)
+        update "ferret"
+        update "scalpel"
+        ;;
+      ferret|scalpel)
+        update "$PROJECT"
+        ;;
+      *)
+        echo "Unrecognized project: $PROJECT"
+        echo
+        usage
+        ;;
+    esac
+  done
+fi
diff --git a/bin/put b/bin/put
new file mode 100755 (executable)
index 0000000..fe9d7bb
--- /dev/null
+++ b/bin/put
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+# Put fresh copies of output files into downstream projects based on integration
+# test golden files.
+#
+# Assumes downstreams exist as peers of the current repo.
+#
+# Note: Normally one would update the downstreams from each downstream itself,
+# using the globally installed `docvim` instance, but this script provides a
+# means of conveniently running an arbitary, potentially unreleased, version of
+# `docvim` against a downstream.
+
+set -e
+
+usage() {
+  echo "Install fresh copies of generated files from integration tests."
+  echo
+  echo "Usage:"
+  echo
+  echo "  bin/put ferret   # freshen a specific downstream"
+  echo "  bin/put scalpel"
+  echo "  ------------------------------------------------"
+  echo "  bin/put all      # freshen all downstreams"
+  exit
+}
+
+update() {
+  local PROJECT
+  PROJECT="$1"
+  echo "Updating $PROJECT"
+  cp "tests/fixtures/integration/$PROJECT/golden/markdown.golden" \
+    "../$PROJECT/README.md"
+  cp "tests/fixtures/integration/$PROJECT/golden/plaintext.golden" \
+    "../$PROJECT/doc/$PROJECT.txt"
+}
+
+if [ $# -eq 0 ]; then
+  usage
+else
+  while [ $# -gt 0 ]; do
+    PROJECT=$1
+    shift
+    case $PROJECT in
+      all)
+        update "ferret"
+        update "scalpel"
+        ;;
+      ferret|scalpel)
+        update "$PROJECT"
+        ;;
+      *)
+        echo "Unrecognized project: $PROJECT"
+        echo
+        usage
+        ;;
+    esac
+  done
+fi