|
@@ -9,7 +9,10 @@ then
|
|
REDIR1=/proc/self/fd/1
|
|
REDIR1=/proc/self/fd/1
|
|
REDIR2=/proc/self/fd/2
|
|
REDIR2=/proc/self/fd/2
|
|
else
|
|
else
|
|
- REDIR1=/dev/null
|
|
|
|
|
|
+ # can not redirect stdout
|
|
|
|
+ # as behaviour is altered
|
|
|
|
+ # if stdout is tty or not
|
|
|
|
+ REDIR1=/proc/self/fd/1
|
|
REDIR2=/dev/null
|
|
REDIR2=/dev/null
|
|
fi
|
|
fi
|
|
DEFAULT_CLEANUP=false
|
|
DEFAULT_CLEANUP=false
|
|
@@ -25,6 +28,7 @@ TEST_CASE () { {
|
|
printf "\x1b[s\x1b[1F\x1b[2CSKIPPED \x1b[u" >&3
|
|
printf "\x1b[s\x1b[1F\x1b[2CSKIPPED \x1b[u" >&3
|
|
exit
|
|
exit
|
|
fi
|
|
fi
|
|
|
|
+ find "$LOG_ROOT" -mindepth 1 -delete
|
|
: "$@"
|
|
: "$@"
|
|
} 2>"$REDIR2"; }
|
|
} 2>"$REDIR2"; }
|
|
|
|
|
|
@@ -59,28 +63,64 @@ export RECALL_FZF_ENABLE RECALL_VIPE_ENABLE RECALL_ISELECT_ENABLE
|
|
: "CLEANUP=$CLEANUP"
|
|
: "CLEANUP=$CLEANUP"
|
|
: "LOG_ROOT=$LOG_ROOT"
|
|
: "LOG_ROOT=$LOG_ROOT"
|
|
|
|
|
|
-( TEST_CASE "Capture : ls"
|
|
|
|
-
|
|
|
|
|
|
+( TEST_CASE "Capture : subshell : ls"
|
|
|
|
+ : Given
|
|
CMD=(ls -lah capture-ls-data)
|
|
CMD=(ls -lah capture-ls-data)
|
|
|
|
+ : When
|
|
OUT="$(+ "${CMD[@]}")"
|
|
OUT="$(+ "${CMD[@]}")"
|
|
|
|
+ : Then
|
|
[ "$OUT" = "$("${CMD[@]}")" ]
|
|
[ "$OUT" = "$("${CMD[@]}")" ]
|
|
@ sudo ls && exit 2
|
|
@ sudo ls && exit 2
|
|
[ "$(@ ls)" = "$("${CMD[@]}")" ]
|
|
[ "$(@ ls)" = "$("${CMD[@]}")" ]
|
|
@ -ln1 sudo ls && exit 2
|
|
@ -ln1 sudo ls && exit 2
|
|
- [ "$(@ -ln1 ls)" = "$(readlink -e "$LOG_ROOT"/ls/*)" ]
|
|
|
|
|
|
+ [ "$(@ -ln1 ls)" = "$(find "$LOG_ROOT"/ls -mindepth 1 -maxdepth 1 -print0 | head -z -n1 | xargs -0 readlink -e)" ]
|
|
@ -sln1 sudo ls && exit 2
|
|
@ -sln1 sudo ls && exit 2
|
|
[ "$(@ -sln1 ls)" = "${CMD[*]}" ]
|
|
[ "$(@ -sln1 ls)" = "${CMD[*]}" ]
|
|
) >"$REDIR1"
|
|
) >"$REDIR1"
|
|
|
|
|
|
-( TEST_CASE "Capture : sudo ls"
|
|
|
|
|
|
+( TEST_CASE "Capture : ls"
|
|
|
|
+ : Given
|
|
|
|
+ CMD=(ls -lah capture-ls-data)
|
|
|
|
+ : When
|
|
|
|
+ + "${CMD[@]}"
|
|
|
|
+ : Then
|
|
|
|
+ @ sudo ls && exit 2
|
|
|
|
+ [ "$(@ ls)" = "$("${CMD[@]}")" ]
|
|
|
|
+ @ -ln1 sudo ls && exit 2
|
|
|
|
+ [ "$(@ -ln1 ls)" = "$(find "$LOG_ROOT"/ls -mindepth 1 -maxdepth 1 -print0 | head -z -n1 | xargs -0 readlink -e)" ]
|
|
|
|
+ @ -sln1 sudo ls && exit 2
|
|
|
|
+ [ "$(@ -sln1 ls)" = "${CMD[*]}" ]
|
|
|
|
+) >"$REDIR1"
|
|
|
|
|
|
|
|
+( TEST_CASE "Capture : subshell : ls; sudo ls"
|
|
|
|
+ : Given
|
|
|
|
+ CMD=(ls -lah capture-ls-data)
|
|
|
|
+ + "${CMD[@]}"
|
|
CMD=(sudo ls -lah capture-ls-data)
|
|
CMD=(sudo ls -lah capture-ls-data)
|
|
|
|
+ : When
|
|
OUT="$(+ "${CMD[@]}")"
|
|
OUT="$(+ "${CMD[@]}")"
|
|
|
|
+ : Then
|
|
[ "$OUT" = "$("${CMD[@]}")" ]
|
|
[ "$OUT" = "$("${CMD[@]}")" ]
|
|
[ "$(@ sudo ls)" = "$("${CMD[@]}")" ]
|
|
[ "$(@ sudo ls)" = "$("${CMD[@]}")" ]
|
|
[ "$(@ ls)" = "$("${CMD[@]}")" ]
|
|
[ "$(@ ls)" = "$("${CMD[@]}")" ]
|
|
- [ "$(@ -ln1 sudo ls)" = "$(readlink -e "$LOG_ROOT"/sudo/ls/*)" ]
|
|
|
|
- [ "$(@ -ln1 ls)" = "$(readlink -e "$LOG_ROOT"/sudo/ls/*)" ]
|
|
|
|
|
|
+ [ "$(@ -ln1 sudo ls)" = "$(find "$LOG_ROOT"/sudo/ls -mindepth 1 -maxdepth 1 -print0 | head -z -n1 | xargs -0 readlink -e)" ]
|
|
|
|
+ [ "$(@ -ln1 ls)" = "$(find "$LOG_ROOT"/sudo/ls -mindepth 1 -maxdepth 1 -print0 | head -z -n1 | xargs -0 readlink -e)" ]
|
|
|
|
+ [ "$(@ -sln1 sudo ls)" = "${CMD[*]}" ]
|
|
|
|
+ [ "$(@ -sln1 ls)" = "${CMD[*]}" ]
|
|
|
|
+) >"$REDIR1"
|
|
|
|
+
|
|
|
|
+( TEST_CASE "Capture : ls; sudo ls"
|
|
|
|
+ : Given
|
|
|
|
+ CMD=(ls -lah capture-ls-data)
|
|
|
|
+ + "${CMD[@]}"
|
|
|
|
+ CMD=(sudo ls -lah capture-ls-data)
|
|
|
|
+ : When
|
|
|
|
+ + "${CMD[@]}"
|
|
|
|
+ : Then
|
|
|
|
+ [ "$(@ sudo ls)" = "$("${CMD[@]}")" ]
|
|
|
|
+ [ "$(@ ls)" = "$("${CMD[@]}")" ]
|
|
|
|
+ [ "$(@ -ln1 sudo ls)" = "$(find "$LOG_ROOT"/sudo/ls -mindepth 1 -maxdepth 1 -print0 | head -z -n1 | xargs -0 readlink -e)" ]
|
|
|
|
+ [ "$(@ -ln1 ls)" = "$(find "$LOG_ROOT"/sudo/ls -mindepth 1 -maxdepth 1 -print0 | head -z -n1 | xargs -0 readlink -e)" ]
|
|
[ "$(@ -sln1 sudo ls)" = "${CMD[*]}" ]
|
|
[ "$(@ -sln1 sudo ls)" = "${CMD[*]}" ]
|
|
[ "$(@ -sln1 ls)" = "${CMD[*]}" ]
|
|
[ "$(@ -sln1 ls)" = "${CMD[*]}" ]
|
|
) >"$REDIR1"
|
|
) >"$REDIR1"
|