Skip to content

Commit

Permalink
feat: increase tests coverage of checking themes activation
Browse files Browse the repository at this point in the history
  • Loading branch information
egel committed Sep 22, 2024
1 parent 0f19833 commit f726f4d
Show file tree
Hide file tree
Showing 7 changed files with 196 additions and 10 deletions.
4 changes: 2 additions & 2 deletions tests/linux/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Linux tests

Those test is meant to run on linux
Those tests are meant to run on linux:

- ubuntu 20.04 LTS
- bash
- with bash
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ set -g @plugin 'tmux-plugins/tmux-sensible'
# Other plugins
set -g @plugin 'egel/tmux-gruvbox'
set -g @tmux-gruvbox 'dark'
set -g @tmux-gruvbox 'dark256'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
Expand All @@ -31,16 +31,22 @@ EOF
# start new detached session
tmux new -d

# default value of status-left section from gruvbox theme
# check if left side match
_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_current" != "$_status_left_expected" ]]; then
helper_print_fail "status-left did not match" "$_status_left_current" "$_status_left_expected"
helper_teardown
exit 1
fi
# check if status is not transparent
_status_style_expected="bg=colour237,fg=colour223"
_status_style_current=$(tmux show-option -gqv status-style)
if [[ "$_status_style_current" != "$_status_style_expected" ]]; then
helper_print_fail "status-style did not match" "$_status_style_current" "$_status_style_expected"
helper_teardown
exit 1
fi

helper_print_success "status-left match"
helper_teardown
Expand Down
57 changes: 57 additions & 0 deletions tests/linux/test_check_gruvbox_dark_transparent_enabled.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash

CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# shellcheck disable=SC1091
source "${CURRENT_DIR}/../tmux_helpers.sh"

main() {
helper_tearup_linux

cat <<EOF >~/.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 'dark-transparent'
# 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

# check if left side match
_status_left_expected="#[bg=default,fg=colour248] #S #[bg=colour237,fg=colour241,nobold,noitalics,nounderscore]"
_status_left_current=$(tmux show-option -gqv status-left)
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
# check if status is not transparent
_status_style_expected="bg=colour237,fg=colour223"
_status_style_current=$(tmux show-option -gqv status-style)
if [[ "$_status_style_current" != "$_status_style_expected" ]]; then
helper_print_fail "status-style did not match" "$_status_style_current" "$_status_style_expected"
helper_teardown
exit 1
fi

helper_print_success "status-left match"
helper_teardown
exit 0

}

main "$@"
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,22 @@ EOF
# start new detached session
tmux new -d

# default value of status-left section from gruvbox theme
# check if left side match
_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
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
# check if status is not transparent
_status_style_expected="bg=colour243,fg=colour255"
_status_style_current=$(tmux show-option -gqv status-style)
if [[ "$_status_style_current" != "$_status_style_expected" ]]; then
helper_print_fail "status-style did not match" "$_status_style_current" "$_status_style_expected"
helper_teardown
exit 1
fi

helper_print_success "status-left match"
helper_teardown
Expand Down
57 changes: 57 additions & 0 deletions tests/linux/test_check_gruvbox_light_transparent_enabled.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash

CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# shellcheck disable=SC1091
source "${CURRENT_DIR}/../tmux_helpers.sh"

main() {
helper_tearup_linux

cat <<EOF >~/.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 'light-transparent'
# 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

# check if left side match
_status_left_expected="#[bg=colour243,fg=colour255] #S #[bg=colour252,fg=colour243,nobold,noitalics,nounderscore]"
_status_left_current=$(tmux show-option -gqv status-left)
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
# check if status is not transparent
_status_style_expected="bg=default,fg=colour255"
_status_style_current=$(tmux show-option -gqv status-style)
if [[ "$_status_style_current" != "$_status_style_expected" ]]; then
helper_print_fail "status-style did not match" "$_status_style_current" "$_status_style_expected"
helper_teardown
exit 1
fi

helper_print_success "status-left match"
helper_teardown
exit 0

}

main "$@"
59 changes: 59 additions & 0 deletions tests/linux/test_without_theme_fallback_to_gruvbox_dark256.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# shellcheck disable=SC1091
source "${CURRENT_DIR}/../tmux_helpers.sh"

####
# Test: when the theme is not defined in config it should fallback to 'dark256'
#
main() {
helper_tearup_linux

# set config without theme defined
cat <<EOF >~/.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'
# 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

# check if left side match
_status_left_expected="#[bg=colour241,fg=colour248] #S #[bg=colour237,fg=colour241,nobold,noitalics,nounderscore]"
_status_left_current=$(tmux show-option -gqv status-left)
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
# check if status is not transparent
_status_style_expected="bg=colour237,fg=colour223"
_status_style_current=$(tmux show-option -gqv status-style)
if [[ "$_status_style_current" != "$_status_style_expected" ]]; then
helper_print_fail "status-style did not match" "$_status_style_current" "$_status_style_expected"
helper_teardown
exit 1
fi

helper_print_success "status-left match"
helper_teardown
exit 0
}

main "$@"
1 change: 1 addition & 0 deletions tests/run_all_linux_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ main() {
_countFailures=0
_files=$(find "$CURRENT_DIR/linux" -name "test_*" -type f)
for test in $_files; do
printf ""
printf "\n=============================================="
printf "\n %s" "$test"
printf "\n=============================================="
Expand Down

0 comments on commit f726f4d

Please sign in to comment.