My configuration files for Debian/Ubuntu applications
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

79 lines
1.7 KiB

  1. #!/usr/bin/env bash
  2. CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  3. TPM_DIR="$PWD"
  4. PLUGINS_DIR="$HOME/.tmux/plugins"
  5. CUSTOM_PLUGINS_DIR="$HOME/foo/plugins"
  6. source "$CURRENT_DIR/helpers/helpers.sh"
  7. source "$CURRENT_DIR/helpers/tpm.sh"
  8. check_binding_defined() {
  9. local binding="$1"
  10. tmux list-keys | grep -q "$binding"
  11. }
  12. create_test_plugin_helper() {
  13. local plugin_path="$PLUGINS_DIR/tmux_test_plugin/"
  14. rm -rf "$plugin_path"
  15. mkdir -p "$plugin_path"
  16. while read line; do
  17. echo "$line" >> "$plugin_path/test_plugin.tmux"
  18. done
  19. chmod +x "$plugin_path/test_plugin.tmux"
  20. }
  21. check_tpm_path() {
  22. local correct_tpm_path="$1"
  23. local tpm_path="$(tmux start-server\; show-environment -g TMUX_PLUGIN_MANAGER_PATH | cut -f2 -d=)"
  24. [ "$correct_tpm_path" == "$tpm_path" ]
  25. }
  26. test_plugin_sourcing() {
  27. set_tmux_conf_helper <<- HERE
  28. set -g mode-keys vi
  29. set -g @plugin "doesnt_matter/tmux_test_plugin"
  30. run-shell "$TPM_DIR/tpm"
  31. HERE
  32. # manually creates a local tmux plugin
  33. create_test_plugin_helper <<- HERE
  34. tmux bind-key R run-shell foo_command
  35. HERE
  36. tmux new-session -d # tmux starts detached
  37. check_binding_defined "R run-shell foo_command" ||
  38. fail_helper "Plugin sourcing fails"
  39. teardown_helper
  40. }
  41. test_default_tpm_path() {
  42. set_tmux_conf_helper <<- HERE
  43. set -g mode-keys vi
  44. run-shell "$TPM_DIR/tpm"
  45. HERE
  46. check_tpm_path "${PLUGINS_DIR}/" ||
  47. fail_helper "Default TPM path not correct"
  48. teardown_helper
  49. }
  50. test_custom_tpm_path() {
  51. set_tmux_conf_helper <<- HERE
  52. set -g mode-keys vi
  53. set-environment -g TMUX_PLUGIN_MANAGER_PATH '$CUSTOM_PLUGINS_DIR'
  54. run-shell "$TPM_DIR/tpm"
  55. HERE
  56. check_tpm_path "$CUSTOM_PLUGINS_DIR" ||
  57. fail_helper "Custom TPM path not correct"
  58. teardown_helper
  59. }
  60. run_tests