Skip to content

Commit

Permalink
added cli wrapper script
Browse files Browse the repository at this point in the history
  • Loading branch information
osteensco committed Jan 30, 2025
1 parent c2c64b8 commit 129542b
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 8 deletions.
3 changes: 3 additions & 0 deletions shells/tests/cli/bash/bash_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
source ~/.fzf.bash
source ./maketree.sh


# TODO
# - Implement test
4 changes: 4 additions & 0 deletions shells/tests/cli/bash/sudo.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

# Used to spoof sudo.
# Docker typically runs as root, so trying to use sudo throws an error.
# Hence, we must spoof.

sudo() {
eval "$@"
}
34 changes: 34 additions & 0 deletions shells/tests/cli/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,38 @@



set -eo pipefail

declare -A TESTS=(
["./tests/bash/bash_test.sh"]="/bin/bash"
# ["./tests/zsh/zsh_test.sh"]="/bin/zsh"
)

all_tests_passed=true

for TEST in "${!TESTS[@]}"; do
SHELL="${TESTS[$TEST]}"
echo "Running cli test $TEST with $SHELL..."

if ! command -v "$SHELL" >/dev/null 2>&1; then
echo "ERROR: Shell $SHELL not found!"
exit 1
fi

if "$SHELL" -c "set -e; $TEST"; then
echo -e "PASSED: $TEST"
else
echo -e "FAILED: $TEST (exit code $?)"
all_tests_passed=false
fi
done


if $all_tests_passed; then
echo "All cli tests passed!"
else
echo "Some cli tests failed."
exit 1
fi


6 changes: 3 additions & 3 deletions shells/tests/shellfuncs/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ all_tests_passed=true

for TEST in "${!TESTS[@]}"; do
SHELL="${TESTS[$TEST]}"
echo "Running $TEST with $SHELL..."
echo "Running shellfunc test $TEST with $SHELL..."

if ! command -v "$SHELL" >/dev/null 2>&1; then
echo "ERROR: Shell $SHELL not found!"
Expand All @@ -32,8 +32,8 @@ done


if $all_tests_passed; then
echo "All tests passed!"
echo "All shell function tests passed!"
else
echo "Some tests failed."
echo "Some shell function tests failed."
exit 1
fi
6 changes: 1 addition & 5 deletions testenv/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,4 @@ services:
stdin_open: true
tty: true

# TODO
# - add cli interactive service
# - implement cli bash test script(s)
# - implement cli wrapper test script
# - update cli/dockerfile if needed

0 comments on commit 129542b

Please sign in to comment.