diff options
author | Yang Tang <ytang@users.noreply.github.com> | 2018-10-12 18:29:50 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-12 18:29:50 +0300 |
commit | a98fa7ff54a0dc7b926deec99b69d5a0a0864a94 (patch) | |
tree | b35d3df1b0ad12324f4094af98a576c6c933571e /test/segments/dir.spec | |
parent | 24bbbfc9bdbdc0666a53cd4a60a8b57551e9f0ca (diff) | |
parent | b16c0d51d65249f0fdea86cd12cd64f6f0643b7e (diff) |
Merge branch 'master' into fix-rprompt-icons-cut-off
Diffstat (limited to 'test/segments/dir.spec')
-rwxr-xr-x | test/segments/dir.spec | 558 |
1 files changed, 341 insertions, 217 deletions
diff --git a/test/segments/dir.spec b/test/segments/dir.spec index 04601622..46e0cfb8 100755 --- a/test/segments/dir.spec +++ b/test/segments/dir.spec @@ -7,179 +7,199 @@ SHUNIT_PARENT=$0 function setUp() { export TERM="xterm-256color" - # Load Powerlevel9k - source powerlevel9k.zsh-theme - # Every test should at least use the dir segment - POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + P9K_HOME="${PWD}" } function tearDown() { - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + unset P9K_HOME } function testDirPathAbsoluteWorks() { - POWERLEVEL9K_DIR_PATH_ABSOLUTE=true + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_DIR_PATH_ABSOLUTE=true + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme cd ~ - assertEquals "%K{blue} %F{black}/home/travis %k%F{blue}%f " "$(build_left_prompt)" + + # Unfortunately, we cannot fake Linux or OSX here, because + # of /home or /Users path.. That is why we change the test + # according to the OS of the host. + if [[ "${OS}" == 'Linux' ]]; then + assertEquals "%K{004} %F{000}/home/${USER} %k%F{004}%f " "$(build_left_prompt)" + elif [[ "${OS}" == 'OSX' ]]; then + assertEquals "%K{004} %F{000}/Users/${USER} %k%F{004}%f " "$(build_left_prompt)" + fi cd - - unset POWERLEVEL9K_DIR_PATH_ABSOLUTE } function testTruncateFoldersWorks() { - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_folders' + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 + local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_folders' - FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + + local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 mkdir -p $FOLDER cd $FOLDER - assertEquals "%K{blue} %F{black}…/12345678/123456789 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}…/12345678/123456789 %k%F{004}%f " "$(build_left_prompt)" cd - rm -fr /tmp/powerlevel9k-test - - unset FOLDER - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH - unset POWERLEVEL9K_SHORTEN_STRATEGY } function testTruncateFolderWithHomeDirWorks() { - POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 - CURRENT_DIR=$(pwd) + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 + local CURRENT_DIR=$(pwd) + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme cd ~ - FOLDER="powerlevel9k-test-${RANDOM}" + local FOLDER="powerlevel9k-test-${RANDOM}" mkdir -p $FOLDER cd $FOLDER # Switch back to home folder as this causes the problem. cd .. - assertEquals "%K{blue} %F{black}~ %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}~ %k%F{004}%f " "$(build_left_prompt)" rmdir $FOLDER cd ${CURRENT_DIR} - - unset CURRENT_DIR - unset FOLDER - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH } function testTruncateMiddleWorks() { - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_middle' + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 + local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_middle' - FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + + local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 mkdir -p $FOLDER cd $FOLDER - assertEquals "%K{blue} %F{black}/tmp/po…st/1/12/123/1234/12…45/12…56/12…67/12…78/123456789 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}/tmp/po…st/1/12/123/1234/12…45/12…56/12…67/12…78/123456789 %k%F{004}%f " "$(build_left_prompt)" cd - rm -fr /tmp/powerlevel9k-test - - unset FOLDER - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_SHORTEN_STRATEGY } function testTruncationFromRightWorks() { - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_from_right' + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 + local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_from_right' - FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + + local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 mkdir -p $FOLDER cd $FOLDER - assertEquals "%K{blue} %F{black}/tmp/po…/1/12/123/12…/12…/12…/12…/12…/123456789 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}/tmp/po…/1/12/123/12…/12…/12…/12…/12…/123456789 %k%F{004}%f " "$(build_left_prompt)" cd - rm -fr /tmp/powerlevel9k-test - - unset FOLDER - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH - unset POWERLEVEL9K_SHORTEN_STRATEGY } function testTruncateToLastWorks() { - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY="truncate_to_last" + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 + local POWERLEVEL9K_SHORTEN_STRATEGY="truncate_to_last" - FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + + local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 mkdir -p $FOLDER cd $FOLDER - assertEquals "%K{blue} %F{black}123456789 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}123456789 %k%F{004}%f " "$(build_left_prompt)" cd - rm -fr /tmp/powerlevel9k-test - - unset FOLDER - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH - unset POWERLEVEL9K_SHORTEN_STRATEGY } function testTruncateToFirstAndLastWorks() { - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY="truncate_to_first_and_last" + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 + local POWERLEVEL9K_SHORTEN_STRATEGY="truncate_to_first_and_last" + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme - FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 + local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 mkdir -p $FOLDER cd $FOLDER - assertEquals "%K{blue} %F{black}/tmp/powerlevel9k-test/…/…/…/…/…/…/…/12345678/123456789 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}/tmp/powerlevel9k-test/…/…/…/…/…/…/…/12345678/123456789 %k%F{004}%f " "$(build_left_prompt)" cd - rm -fr /tmp/powerlevel9k-test - - unset FOLDER - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH - unset POWERLEVEL9K_SHORTEN_STRATEGY } function testTruncateAbsoluteWorks() { - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY="truncate_absolute" + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 + local POWERLEVEL9K_SHORTEN_STRATEGY="truncate_absolute" + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme - FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 + local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 mkdir -p $FOLDER cd $FOLDER - assertEquals "%K{blue} %F{black}…89 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}…89 %k%F{004}%f " "$(build_left_prompt)" cd - rm -fr /tmp/powerlevel9k-test - - unset FOLDER - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH - unset POWERLEVEL9K_SHORTEN_STRATEGY } function testTruncationFromRightWithEmptyDelimiter() { - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_DELIMITER="" - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_from_right' + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 + local POWERLEVEL9K_SHORTEN_DELIMITER="" + local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_from_right' + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme - FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 + local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789 mkdir -p $FOLDER cd $FOLDER - assertEquals "%K{blue} %F{black}/tmp/po/1/12/123/12/12/12/12/12/123456789 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}/tmp/po/1/12/123/12/12/12/12/12/123456789 %k%F{004}%f " "$(build_left_prompt)" cd - rm -fr /tmp/powerlevel9k-test - - unset FOLDER - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH - unset POWERLEVEL9K_SHORTEN_DELIMITER - unset POWERLEVEL9K_SHORTEN_STRATEGY } function testTruncateWithFolderMarkerWorks() { + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) - POWERLEVEL9K_SHORTEN_STRATEGY="truncate_with_folder_marker" + local POWERLEVEL9K_SHORTEN_STRATEGY="truncate_with_folder_marker" + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme local BASEFOLDER=/tmp/powerlevel9k-test local FOLDER=$BASEFOLDER/1/12/123/1234/12345/123456/1234567 @@ -187,20 +207,20 @@ function testTruncateWithFolderMarkerWorks() { # Setup folder marker touch $BASEFOLDER/1/12/.shorten_folder_marker cd $FOLDER - assertEquals "%K{blue} %F{black}/…/12/123/1234/12345/123456/1234567 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}/…/12/123/1234/12345/123456/1234567 %k%F{004}%f " "$(build_left_prompt)" cd - rm -fr $BASEFOLDER - unset BASEFOLDER - unset FOLDER - unset POWERLEVEL9K_SHORTEN_STRATEGY - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS } function testTruncateWithFolderMarkerWithChangedFolderMarker() { + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) - POWERLEVEL9K_SHORTEN_STRATEGY="truncate_with_folder_marker" - POWERLEVEL9K_SHORTEN_FOLDER_MARKER='.xxx' + local POWERLEVEL9K_SHORTEN_STRATEGY="truncate_with_folder_marker" + local POWERLEVEL9K_SHORTEN_FOLDER_MARKER='.xxx' + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme local BASEFOLDER=/tmp/powerlevel9k-test local FOLDER=$BASEFOLDER/1/12/123/1234/12345/123456/1234567 @@ -208,15 +228,10 @@ function testTruncateWithFolderMarkerWithChangedFolderMarker() { # Setup folder marker touch $BASEFOLDER/1/12/.xxx cd $FOLDER - assertEquals "%K{blue} %F{black}/…/12/123/1234/12345/123456/1234567 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}/…/12/123/1234/12345/123456/1234567 %k%F{004}%f " "$(build_left_prompt)" cd - rm -fr $BASEFOLDER - unset BASEFOLDER - unset FOLDER - unset POWERLEVEL9K_SHORTEN_FOLDER_MARKER - unset POWERLEVEL9K_SHORTEN_STRATEGY - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS } function testTruncateWithPackageNameWorks() { @@ -237,18 +252,19 @@ function testTruncateWithPackageNameWorks() { # Go back to deeper folder cd "${FOLDER}" + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name' + local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 + local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name' - assertEquals "%K{blue} %F{black}My_Package/1/12/123/12…/12…/12…/12…/12…/123456789 %k%F{blue}%f " "$(build_left_prompt)" + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + + assertEquals "%K{004} %F{000}My_Package/1/12/123/12…/12…/12…/12…/12…/123456789 %k%F{004}%f " "$(build_left_prompt)" # Go back cd $p9kFolder rm -fr $BASEFOLDER - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_SHORTEN_STRATEGY - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH } function testTruncateWithPackageNameIfRepoIsSymlinkedInsideDeepFolder() { @@ -276,18 +292,19 @@ function testTruncateWithPackageNameIfRepoIsSymlinkedInsideDeepFolder() { # Go to deep folder inside linked repo cd linked-repo/asdfasdf/qwerqwer + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name' + local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 + local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name' + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme - assertEquals "%K{blue} %F{black}My_Package/as…/qwerqwer %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}My_Package/as…/qwerqwer %k%F{004}%f " "$(build_left_prompt)" # Go back cd $p9kFolder rm -fr $BASEFOLDER - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_SHORTEN_STRATEGY - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH } function testTruncateWithPackageNameIfRepoIsSymlinkedInsideGitDir() { @@ -311,123 +328,162 @@ function testTruncateWithPackageNameIfRepoIsSymlinkedInsideGitDir() { cd linked-repo/.git/refs/heads + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name' + local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 + local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name' - assertEquals "%K{blue} %F{black}My_Package/.g…/re…/heads %k%F{blue}%f " "$(build_left_prompt)" + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + + assertEquals "%K{004} %F{000}My_Package/.g…/re…/heads %k%F{004}%f " "$(build_left_prompt)" # Go back cd $p9kFolder rm -fr $BASEFOLDER - unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unset POWERLEVEL9K_SHORTEN_STRATEGY - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH } function testHomeFolderDetectionWorks() { - POWERLEVEL9K_HOME_ICON='home-icon' + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_HOME_ICON='home-icon' + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme cd ~ - assertEquals "%K{blue} %F{black%}home-icon %F{black}~ %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}home-icon %F{000}~ %k%F{004}%f " "$(build_left_prompt)" cd - - unset POWERLEVEL9K_HOME_ICON } function testHomeSubfolderDetectionWorks() { - POWERLEVEL9K_HOME_SUB_ICON='sub-icon' + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_HOME_SUB_ICON='sub-icon' + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme - FOLDER=~/powerlevel9k-test + local FOLDER=~/powerlevel9k-test mkdir $FOLDER cd $FOLDER - assertEquals "%K{blue} %F{black%}sub-icon %F{black}~/powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}sub-icon %F{000}~/powerlevel9k-test %k%F{004}%f " "$(build_left_prompt)" cd - rm -fr $FOLDER - unset FOLDER - unset POWERLEVEL9K_HOME_SUB_ICON } function testOtherFolderDetectionWorks() { - POWERLEVEL9K_FOLDER_ICON='folder-icon' + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_FOLDER_ICON='folder-icon' - FOLDER=/tmp/powerlevel9k-test + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + + local FOLDER=/tmp/powerlevel9k-test mkdir $FOLDER cd $FOLDER - assertEquals "%K{blue} %F{black%}folder-icon %F{black}/tmp/powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}folder-icon %F{000}/tmp/powerlevel9k-test %k%F{004}%f " "$(build_left_prompt)" cd - rm -fr $FOLDER - unset FOLDER - unset POWERLEVEL9K_FOLDER_ICON } function testChangingDirPathSeparator() { - POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + local FOLDER="/tmp/powerlevel9k-test/1/2" mkdir -p $FOLDER cd $FOLDER - assertEquals "%K{blue} %F{black}xXxtmpxXxpowerlevel9k-testxXx1xXx2 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}xXxtmpxXxpowerlevel9k-testxXx1xXx2 %k%F{004}%f " "$(build_left_prompt)" cd - - unset FOLDER rm -fr /tmp/powerlevel9k-test - unset POWERLEVEL9K_DIR_PATH_SEPARATOR } function testHomeFolderAbbreviation() { - local POWERLEVEL9K_HOME_FOLDER_ABBREVIATION + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) local dir=$PWD cd ~/ # default - POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='~' - assertEquals "%K{blue} %F{black}~ %k%F{blue}%f " "$(build_left_prompt)" + local POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='~' + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + + assertEquals "%K{004} %F{000}~ %k%F{004}%f " "$(build_left_prompt)" # substituted - POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='qQq' - assertEquals "%K{blue} %F{black}qQq %k%F{blue}%f " "$(build_left_prompt)" + local POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='qQq' + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + + assertEquals "%K{004} %F{000}qQq %k%F{004}%f " "$(build_left_prompt)" cd /tmp # default - POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='~' - assertEquals "%K{blue} %F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)" + local POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='~' + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + + assertEquals "%K{004} %F{000}/tmp %k%F{004}%f " "$(build_left_prompt)" # substituted - POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='qQq' - assertEquals "%K{blue} %F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)" + local POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='qQq' + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + + assertEquals "%K{004} %F{000}/tmp %k%F{004}%f " "$(build_left_prompt)" cd "$dir" } function testOmittingFirstCharacterWorks() { - POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true - POWERLEVEL9K_FOLDER_ICON='folder-icon' + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true + local POWERLEVEL9K_FOLDER_ICON='folder-icon' + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + cd /tmp - assertEquals "%K{blue} %F{black%}folder-icon %F{black}tmp %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}folder-icon %F{000}tmp %k%F{004}%f " "$(build_left_prompt)" cd - - unset POWERLEVEL9K_FOLDER_ICON - unset POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER } function testOmittingFirstCharacterWorksWithChangingPathSeparator() { - POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true - POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' - POWERLEVEL9K_FOLDER_ICON='folder-icon' + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true + local POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' + local POWERLEVEL9K_FOLDER_ICON='folder-icon' + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + mkdir -p /tmp/powerlevel9k-test/1/2 cd /tmp/powerlevel9k-test/1/2 - assertEquals "%K{blue} %F{black%}folder-icon %F{black}tmpxXxpowerlevel9k-testxXx1xXx2 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}folder-icon %F{000}tmpxXxpowerlevel9k-testxXx1xXx2 %k%F{004}%f " "$(build_left_prompt)" cd - rm -fr /tmp/powerlevel9k-test - unset POWERLEVEL9K_FOLDER_ICON - unset POWERLEVEL9K_DIR_PATH_SEPARATOR - unset POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER } # This test makes it obvious that combining a truncation strategy @@ -438,210 +494,278 @@ function testOmittingFirstCharacterWorksWithChangingPathSeparator() { # But it does more sense in combination with other truncation # strategies. function testOmittingFirstCharacterWorksWithChangingPathSeparatorAndDefaultTruncation() { - POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true - POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_folders' + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true + local POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' + local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 + local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_folders' + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + mkdir -p /tmp/powerlevel9k-test/1/2 cd /tmp/powerlevel9k-test/1/2 - assertEquals "%K{blue} %F{black}xXx1xXx2 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}xXx1xXx2 %k%F{004}%f " "$(build_left_prompt)" cd - rm -fr /tmp/powerlevel9k-test - unset POWERLEVEL9K_DIR_PATH_SEPARATOR - unset POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH - unset POWERLEVEL9K_SHORTEN_STRATEGY } function testOmittingFirstCharacterWorksWithChangingPathSeparatorAndMiddleTruncation() { - POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true - POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_middle' + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true + local POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' + local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 + local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_middle' + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + mkdir -p /tmp/powerlevel9k-test/1/2 cd /tmp/powerlevel9k-test/1/2 - assertEquals "%K{blue} %F{black}tmpxXxpo…stxXx1xXx2 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}tmpxXxpo…stxXx1xXx2 %k%F{004}%f " "$(build_left_prompt)" cd - rm -fr /tmp/powerlevel9k-test - unset POWERLEVEL9K_DIR_PATH_SEPARATOR - unset POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH - unset POWERLEVEL9K_SHORTEN_STRATEGY } function testOmittingFirstCharacterWorksWithChangingPathSeparatorAndRightTruncation() { - POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true - POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_from_right' + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true + local POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' + local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 + local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_from_right' + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + mkdir -p /tmp/powerlevel9k-test/1/2 cd /tmp/powerlevel9k-test/1/2 - assertEquals "%K{blue} %F{black}tmpxXxpo…xXx1xXx2 %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}tmpxXxpo…xXx1xXx2 %k%F{004}%f " "$(build_left_prompt)" cd - rm -fr /tmp/powerlevel9k-test - unset POWERLEVEL9K_DIR_PATH_SEPARATOR - unset POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH - unset POWERLEVEL9K_SHORTEN_STRATEGY } function testTruncateToUniqueWorks() { - POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true - POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' - POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 - POWERLEVEL9K_SHORTEN_STRATEGY='truncate_to_unique' + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER=true + local POWERLEVEL9K_DIR_PATH_SEPARATOR='xXx' + local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 + local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_to_unique' + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + mkdir -p /tmp/powerlevel9k-test/adam/devl mkdir -p /tmp/powerlevel9k-test/alice/devl mkdir -p /tmp/powerlevel9k-test/alice/docs mkdir -p /tmp/powerlevel9k-test/bob/docs cd /tmp/powerlevel9k-test/alice/devl - assertEquals "%K{blue} %F{black}txXxpxXxalxXxde %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}txXxpxXxalxXxde %k%F{004}%f " "$(build_left_prompt)" cd - rm -fr /tmp/powerlevel9k-test - unset POWERLEVEL9K_DIR_PATH_SEPARATOR - unset POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER - unset POWERLEVEL9K_SHORTEN_DIR_LENGTH - unset POWERLEVEL9K_SHORTEN_STRATEGY } function testBoldHomeDirWorks() { - POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + cd ~ - assertEquals "%K{blue} %F{black}%B~%b %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}%B~%b %k%F{004}%f " "$(build_left_prompt)" cd - - unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD } function testBoldHomeSubdirWorks() { - POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + mkdir -p ~/powerlevel9k-test cd ~/powerlevel9k-test - assertEquals "%K{blue} %F{black}~/%Bpowerlevel9k-test%b %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}~/%Bpowerlevel9k-test%b %k%F{004}%f " "$(build_left_prompt)" cd - rm -fr ~/powerlevel9k-test - unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD } function testBoldRootDirWorks() { - POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + cd / - assertEquals "%K{blue} %F{black}%B/%b %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}%B/%b %k%F{004}%f " "$(build_left_prompt)" cd - - unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD } function testBoldRootSubdirWorks() { - POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + cd /tmp - assertEquals "%K{blue} %F{black}/%Btmp%b %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}/%Btmp%b %k%F{004}%f " "$(build_left_prompt)" cd - - unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD } function testBoldRootSubSubdirWorks() { - POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD=true + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + mkdir -p /tmp/powerlevel9k-test cd /tmp/powerlevel9k-test - assertEquals "%K{blue} %F{black}/tmp/%Bpowerlevel9k-test%b %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}/tmp/%Bpowerlevel9k-test%b %k%F{004}%f " "$(build_left_prompt)" cd - rm -fr /tmp/powerlevel9k-test - unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BOLD } function testHighlightHomeWorks() { - POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + cd ~ - assertEquals "%K{blue} %F{black}%F{red}~ %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}%F{red}~ %k%F{004}%f " "$(build_left_prompt)" cd - - unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND } function testHighlightHomeSubdirWorks() { - POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + mkdir -p ~/powerlevel9k-test cd ~/powerlevel9k-test - assertEquals "%K{blue} %F{black}~/%F{red}powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}~/%F{red}powerlevel9k-test %k%F{004}%f " "$(build_left_prompt)" cd - rm -fr ~/powerlevel9k-test - unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND } function testHighlightRootWorks() { - POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + cd / - assertEquals "%K{blue} %F{black}%F{red}/ %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}%F{red}/ %k%F{004}%f " "$(build_left_prompt)" cd - - unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND } function testHighlightRootSubdirWorks() { - POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + cd /tmp - assertEquals "%K{blue} %F{black}/%F{red}tmp %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}/%F{red}tmp %k%F{004}%f " "$(build_left_prompt)" cd - - unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND } function testHighlightRootSubSubdirWorks() { - POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND='red' + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + mkdir /tmp/powerlevel9k-test cd /tmp/powerlevel9k-test - assertEquals "%K{blue} %F{black}/tmp/%F{red}powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}/tmp/%F{red}powerlevel9k-test %k%F{004}%f " "$(build_left_prompt)" cd - rm -fr /tmp/powerlevel9k-test - unset POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND } function testDirSeparatorColorHomeSubdirWorks() { - POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND='red' + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND='red' + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + mkdir -p ~/powerlevel9k-test cd ~/powerlevel9k-test - assertEquals "%K{blue} %F{black}~%F{red}/%F{black}powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}~%F{red}/%F{black}powerlevel9k-test %k%F{004}%f " "$(build_left_prompt)" cd - rm -fr ~/powerlevel9k-test - unset POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND } function testDirSeparatorColorRootSubSubdirWorks() { - POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND='red' + local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS + POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir) + local POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND='red' + + # Load Powerlevel9k + source ${P9K_HOME}/powerlevel9k.zsh-theme + mkdir -p /tmp/powerlevel9k-test cd /tmp/powerlevel9k-test - assertEquals "%K{blue} %F{black}%F{red}/%F{black}tmp%F{red}/%F{black}powerlevel9k-test %k%F{blue}%f " "$(build_left_prompt)" + assertEquals "%K{004} %F{000}%F{red}/%F{black}tmp%F{red}/%F{black}powerlevel9k-test %k%F{004}%f " "$(build_left_prompt)" cd - rm -fr /tmp/powerlevel9k-test - unset POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND } -source shunit2/source/2.1/src/shunit2 +source shunit2/shunit2 |