|
@@ -1,12 +1,32 @@
|
|
|
#!/bin/bash
|
|
|
set -euo pipefail
|
|
|
+exec 3>&1
|
|
|
|
|
|
+FILTER="${1:-}"
|
|
|
+: "${DEBUG:=false}"
|
|
|
+if "$DEBUG"
|
|
|
+then
|
|
|
+ REDIR1="&1"
|
|
|
+ REDIR2="&2"
|
|
|
+else
|
|
|
+ REDIR1=/dev/null
|
|
|
+ REDIR2=/dev/null
|
|
|
+fi
|
|
|
DEFAULT_CLEANUP=false
|
|
|
[ "${LOG_ROOT:-}" ] || {
|
|
|
LOG_ROOT="$(mktemp -d)"
|
|
|
DEFAULT_CLEANUP=true
|
|
|
}
|
|
|
[ "${CLEANUP+set}" ] || CLEANUP="$DEFAULT_CLEANUP"
|
|
|
+TEST_CASE () { {
|
|
|
+ if ! "$DEBUG"; then set +x; fi
|
|
|
+ if [ "$FILTER" ] && ! [[ "$*" =~ $FILTER ]]
|
|
|
+ then
|
|
|
+ printf "\x1b[s\x1b[1F\x1b[2CSKIPPED \x1b[u" >&3
|
|
|
+ exit
|
|
|
+ fi
|
|
|
+ : "$@"
|
|
|
+} 2>"$REDIR2"; }
|
|
|
|
|
|
cleanup () {
|
|
|
ret="$?"
|
|
@@ -29,36 +49,31 @@ export LOG_ROOT RECALL_PREFIX
|
|
|
cd "$RECALL_PREFIX"/tests
|
|
|
|
|
|
set -x
|
|
|
+{
|
|
|
+ RECALL_FZF_ENABLE=false
|
|
|
+ RECALL_VIPE_ENABLE=false
|
|
|
+ RECALL_ISELECT_ENABLE=false
|
|
|
+}
|
|
|
+export RECALL_FZF_ENABLE RECALL_VIPE_ENABLE RECALL_ISELECT_ENABLE
|
|
|
|
|
|
: "CLEANUP=$CLEANUP"
|
|
|
: "LOG_ROOT=$LOG_ROOT"
|
|
|
|
|
|
-: "Capture : ls"
|
|
|
-(
|
|
|
- set +x
|
|
|
- CMD="ls -lah capture-ls-data"
|
|
|
- + $CMD
|
|
|
- [ "$(head -n1 "$LOG_ROOT"/ls/*/info)" = "$CMD" ]
|
|
|
- [ "$(@ ls)" = "$($CMD)" ]
|
|
|
-) >/dev/null
|
|
|
+( TEST_CASE "Capture : ls"
|
|
|
+ CMD=(ls -lah capture-ls-data)
|
|
|
+ + "${CMD[@]}"
|
|
|
+ [ "$(@ ls)" = "$("${CMD[@]}")" ]
|
|
|
+ [ "$(@ -ln1 ls)" = "$(readlink -e "$LOG_ROOT"/ls/*)" ]
|
|
|
+ [ "$(@ -sln1 ls)" = "${CMD[*]}" ]
|
|
|
+) >"$REDIR1"
|
|
|
|
|
|
-: "Capture : sudo ls"
|
|
|
-(
|
|
|
- set +x
|
|
|
- CMD="sudo ls -lah capture-ls-data"
|
|
|
- + $CMD
|
|
|
- [ "$(head -n1 "$LOG_ROOT"/sudo/ls/*/info)" = "$CMD" ]
|
|
|
- [ "$(@ sudo ls)" = "$($CMD)" ]
|
|
|
- [ "$(@ ls)" = "$($CMD)" ]
|
|
|
-) >/dev/null
|
|
|
+( TEST_CASE "Capture : sudo ls"
|
|
|
|
|
|
-: "Recall : ls"
|
|
|
-(
|
|
|
- set -a
|
|
|
- RECALL_FZF_ENABLE=false
|
|
|
- RECALL_VIPE_ENABLE=false
|
|
|
- RECALL_ISELECT_ENABLE=false
|
|
|
- set +x
|
|
|
- @ -l ls
|
|
|
+ CMD=(sudo ls -lah capture-ls-data)
|
|
|
+ + "${CMD[@]}"
|
|
|
+ [ "$(@ sudo ls)" = "$("${CMD[@]}")" ]
|
|
|
+ [ "$(@ -ln1 sudo ls)" = "$(readlink -e "$LOG_ROOT"/sudo/ls/*)" ]
|
|
|
[ "$(@ -ln1 ls)" = "$(readlink -e "$LOG_ROOT"/sudo/ls/*)" ]
|
|
|
-) >/dev/null
|
|
|
+ [ "$(@ -sln1 sudo ls)" = "${CMD[*]}" ]
|
|
|
+ [ "$(@ -sln1 ls)" = "${CMD[*]}" ]
|
|
|
+) >"$REDIR1"
|