diff --git a/.github/workflows/dev-push-check.yml b/.github/workflows/dev-push-check.yml index 79f60b7..37f02ad 100644 --- a/.github/workflows/dev-push-check.yml +++ b/.github/workflows/dev-push-check.yml @@ -5,20 +5,20 @@ jobs: lint_shellcheck: runs-on: ubuntu-latest steps: - - name: install shellcheck + - name: Install shellcheck run: sudo apt-get install -y shellcheck - - name: checkout repo + - name: Checkout repo uses: actions/checkout@main - - name: lint files against shellcheck + - name: Lint files against shellcheck run: make lint_shellcheck lint_shfmt: runs-on: ubuntu-latest steps: - - name: install shfmt + - name: Install shfmt run: sudo apt-get install -y shfmt - - name: checkout repo + - name: Checkout repository uses: actions/checkout@main - - name: lint files against shfmt + - name: Lint files against shfmt run: make lint_shfmt test_setup_linux: runs-on: ubuntu-latest @@ -26,9 +26,9 @@ jobs: - lint_shfmt - lint_shellcheck steps: - - name: install soft + - name: Install required software run: sudo apt install -y tmux git - - name: checkout repo + - name: Checkout repository uses: actions/checkout@main - - name: run all linux tests + - name: Execute all linux tests and check results run: ./tests/run_all_linux_tests.sh diff --git a/tests/linux/test_linux_default_startup.sh b/tests/linux/test_default_start_set_gruvbox_dark256.sh similarity index 62% rename from tests/linux/test_linux_default_startup.sh rename to tests/linux/test_default_start_set_gruvbox_dark256.sh index e8ac63b..eb68479 100755 --- a/tests/linux/test_linux_default_startup.sh +++ b/tests/linux/test_default_start_set_gruvbox_dark256.sh @@ -5,9 +5,6 @@ CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # shellcheck disable=SC1091 source "${CURRENT_DIR}/../tmux_helpers.sh" -# default value of status-left section from gruvbox theme -readonly STATUS_LEFT_DEFAULT="#[bg=colour241,fg=colour248] #S #[bg=colour237,fg=colour241,nobold,noitalics,nounderscore]" - main() { helper_tearup_linux @@ -26,27 +23,29 @@ EOF cat ~/.tmux.conf - echo "Current DIR: $CURRENT_DIR" - - # link current repo to plugin list + # it's essential to link current repo to the plugins' directory ln -sfv "$CURRENT_DIR/../../../tmux-gruvbox" "${HOME}/.tmux/plugins/tmux-gruvbox" - ls -al ~/.tmux/plugins/ - helper_install_tpm_plugins # start new detached session tmux new -d + # default value of status-left section from gruvbox theme + _status_left_expected="#[bg=colour241,fg=colour248] #S #[bg=colour237,fg=colour241,nobold,noitalics,nounderscore]" + # get status of something from theme _status_left_current=$(tmux show-option -gqv status-left) - if [[ "$STATUS_LEFT_DEFAULT" != "$_status_left_current" ]]; then - helper_print_fail_and_exit "status-left did not match" # fail fast - else - helper_print_success "status-left match" + if [[ "$_status_left_current" != "$_status_left_expected" ]]; then + helper_print_fail "status-left did not match" "$_status_left_current" "$_status_left_expected" + helper_teardown + exit 1 fi + helper_print_success "status-left match" helper_teardown + exit 0 + } main "$@" diff --git a/tests/linux/test_gruvbox_light256_theme_enabled.sh b/tests/linux/test_gruvbox_light256_theme_enabled.sh new file mode 100755 index 0000000..3a62099 --- /dev/null +++ b/tests/linux/test_gruvbox_light256_theme_enabled.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# shellcheck disable=SC1091 +source "${CURRENT_DIR}/../tmux_helpers.sh" + +main() { + helper_tearup_linux + + cat <~/.tmux.conf +# List of plugins +set -g @plugin 'tmux-plugins/tpm' +set -g @plugin 'tmux-plugins/tmux-sensible' + +# Other plugins +set -g @plugin 'egel/tmux-gruvbox' +set -g @tmux-gruvbox 'light256' + +# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) +run '~/.tmux/plugins/tpm/tpm' +EOF + + cat ~/.tmux.conf + + # it's essential to link current repo to the plugins' directory + ln -sfv "$CURRENT_DIR/../../../tmux-gruvbox" "${HOME}/.tmux/plugins/tmux-gruvbox" + + helper_install_tpm_plugins + + # start new detached session + tmux new -d + + # default value of status-left section from gruvbox theme + _status_left_expected="#[bg=colour243,fg=colour255] #S #[bg=colour252,fg=colour243,nobold,noitalics,nounderscore]" + + # get status of something from theme + _status_left_current=$(tmux show-option -gqv status-left) + if [[ "$_status_left_expected" != "$_status_left_current" ]]; then + helper_print_fail "status-left did not match" "$_status_left_current" "$_status_left_expected" + helper_teardown + exit 1 + fi + + helper_print_success "status-left match" + helper_teardown + exit 0 + +} + +main "$@" diff --git a/tests/run_all_linux_tests.sh b/tests/run_all_linux_tests.sh index a801053..317a2a0 100755 --- a/tests/run_all_linux_tests.sh +++ b/tests/run_all_linux_tests.sh @@ -7,8 +7,11 @@ main() { declare -i _countFailures local _files _countFailures=0 - _files=$(find "$CURRENT_DIR" -name "test_linux_*" -type f) + _files=$(find "$CURRENT_DIR/linux" -name "test_*" -type f) for test in $_files; do + printf "\n==============================================" + printf "\n %s" "$test" + printf "\n==============================================" bash -c "$test" # run all and count failures diff --git a/tests/tmux_helpers.sh b/tests/tmux_helpers.sh index 9e45b15..3a6128a 100644 --- a/tests/tmux_helpers.sh +++ b/tests/tmux_helpers.sh @@ -24,8 +24,12 @@ helper_tearup_linux() { } helper_print_fail() { - local _msg="${1:-}" + local _msg="${1}" + local _current_val="${2}" + local _expected_val="${3}" printf "FAIL. %s\n" "${_msg}" + printf "current value:\t%s" "$_current_val" + printf "expected value:\t%s" "$_expected_val" } helper_print_success() { @@ -34,12 +38,12 @@ helper_print_success() { } helper_print_fail_and_exit() { - helper_print_fail "$1" + helper_print_fail "$1" "$2" "$3" exit 1 } helper_print_success_and_exit() { - helper_print_success "$1" + helper_print_success "$1" "$2" "$3" exit 0 }