summaryrefslogtreecommitdiff
path: root/test/segments/dir.spec
diff options
context:
space:
mode:
authorDominik Ritter <dritter03@googlemail.com>2018-07-24 17:24:33 +0300
committerDominik Ritter <dritter03@googlemail.com>2018-07-24 17:24:33 +0300
commit4972f0b8eba711f0dafc46cdbb4e191d550da091 (patch)
treecac634f7706fc43973785ca467c2285423608d39 /test/segments/dir.spec
parent822b820a6e0d7cec4ec60de23faecec6b77712b6 (diff)
Improve tests by making use of local variables
Diffstat (limited to 'test/segments/dir.spec')
-rwxr-xr-xtest/segments/dir.spec316
1 files changed, 143 insertions, 173 deletions
diff --git a/test/segments/dir.spec b/test/segments/dir.spec
index 3e66e918..df80b23c 100755
--- a/test/segments/dir.spec
+++ b/test/segments/dir.spec
@@ -9,17 +9,12 @@ 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)
-}
-
-function tearDown() {
- unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
}
function testDirPathAbsoluteWorks() {
- POWERLEVEL9K_DIR_PATH_ABSOLUTE=true
+ local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
+ POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
+ local POWERLEVEL9K_DIR_PATH_ABSOLUTE=true
cd ~
@@ -33,14 +28,15 @@ function testDirPathAbsoluteWorks() {
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
+ local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789
mkdir -p $FOLDER
cd $FOLDER
@@ -48,18 +44,16 @@ function testTruncateFoldersWorks() {
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)
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.
@@ -69,17 +63,15 @@ function testTruncateFolderWithHomeDirWorks() {
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
+ local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789
mkdir -p $FOLDER
cd $FOLDER
@@ -87,17 +79,15 @@ function testTruncateMiddleWorks() {
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
+ local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789
mkdir -p $FOLDER
cd $FOLDER
@@ -105,17 +95,15 @@ function testTruncationFromRightWorks() {
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
+ local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789
mkdir -p $FOLDER
cd $FOLDER
@@ -123,17 +111,15 @@ function testTruncateToLastWorks() {
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"
- 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
@@ -141,17 +127,15 @@ function testTruncateToFirstAndLastWorks() {
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"
- 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
@@ -159,18 +143,16 @@ function testTruncateAbsoluteWorks() {
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'
- 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
@@ -178,16 +160,12 @@ function testTruncationFromRightWithEmptyDelimiter() {
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"
local BASEFOLDER=/tmp/powerlevel9k-test
local FOLDER=$BASEFOLDER/1/12/123/1234/12345/123456/1234567
@@ -199,16 +177,13 @@ function testTruncateWithFolderMarkerWorks() {
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'
local BASEFOLDER=/tmp/powerlevel9k-test
local FOLDER=$BASEFOLDER/1/12/123/1234/12345/123456/1234567
@@ -220,11 +195,6 @@ function testTruncateWithFolderMarkerWithChangedFolderMarker() {
cd -
rm -fr $BASEFOLDER
- unset BASEFOLDER
- unset FOLDER
- unset POWERLEVEL9K_SHORTEN_FOLDER_MARKER
- unset POWERLEVEL9K_SHORTEN_STRATEGY
- unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
}
function testTruncateWithPackageNameWorks() {
@@ -245,18 +215,16 @@ 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)"
# Go back
cd $p9kFolder
rm -fr $BASEFOLDER
- unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- unset POWERLEVEL9K_SHORTEN_STRATEGY
- unset POWERLEVEL9K_SHORTEN_DIR_LENGTH
}
function testTruncateWithPackageNameIfRepoIsSymlinkedInsideDeepFolder() {
@@ -284,18 +252,16 @@ 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'
assertEquals "%K{blue} %F{black}My_Package/as…/qwerqwer %k%F{blue}%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() {
@@ -319,60 +285,61 @@ 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)"
# 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'
cd ~
assertEquals "%K{blue} %F{black%}home-icon %f%F{black}~ %k%F{blue}%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'
- FOLDER=~/powerlevel9k-test
+ local FOLDER=~/powerlevel9k-test
mkdir $FOLDER
cd $FOLDER
assertEquals "%K{blue} %F{black%}sub-icon %f%F{black}~/powerlevel9k-test %k%F{blue}%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
+ local FOLDER=/tmp/powerlevel9k-test
mkdir $FOLDER
cd $FOLDER
assertEquals "%K{blue} %F{black%}folder-icon %f%F{black}/tmp/powerlevel9k-test %k%F{blue}%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'
local FOLDER="/tmp/powerlevel9k-test/1/2"
mkdir -p $FOLDER
cd $FOLDER
@@ -380,12 +347,12 @@ function testChangingDirPathSeparator() {
assertEquals "%K{blue} %F{black}xXxtmpxXxpowerlevel9k-testxXx1xXx2 %k%F{blue}%f " "$(build_left_prompt)"
cd -
- unset FOLDER
rm -fr /tmp/powerlevel9k-test
- unset POWERLEVEL9K_DIR_PATH_SEPARATOR
}
function testHomeFolderAbbreviation() {
+ local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
+ POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
local POWERLEVEL9K_HOME_FOLDER_ABBREVIATION
local dir=$PWD
@@ -411,21 +378,23 @@ function testHomeFolderAbbreviation() {
}
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'
cd /tmp
assertEquals "%K{blue} %F{black%}folder-icon %f%F{black}tmp %k%F{blue}%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'
mkdir -p /tmp/powerlevel9k-test/1/2
cd /tmp/powerlevel9k-test/1/2
@@ -433,9 +402,6 @@ function testOmittingFirstCharacterWorksWithChangingPathSeparator() {
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
@@ -446,10 +412,12 @@ 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'
mkdir -p /tmp/powerlevel9k-test/1/2
cd /tmp/powerlevel9k-test/1/2
@@ -457,17 +425,15 @@ function testOmittingFirstCharacterWorksWithChangingPathSeparatorAndDefaultTrunc
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'
mkdir -p /tmp/powerlevel9k-test/1/2
cd /tmp/powerlevel9k-test/1/2
@@ -475,17 +441,15 @@ function testOmittingFirstCharacterWorksWithChangingPathSeparatorAndMiddleTrunca
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'
mkdir -p /tmp/powerlevel9k-test/1/2
cd /tmp/powerlevel9k-test/1/2
@@ -493,17 +457,15 @@ function testOmittingFirstCharacterWorksWithChangingPathSeparatorAndRightTruncat
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'
mkdir -p /tmp/powerlevel9k-test/adam/devl
mkdir -p /tmp/powerlevel9k-test/alice/devl
mkdir -p /tmp/powerlevel9k-test/alice/docs
@@ -514,24 +476,23 @@ function testTruncateToUniqueWorks() {
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
cd ~
assertEquals "%K{blue} %F{black}%B~%b %k%F{blue}%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
mkdir -p ~/powerlevel9k-test
cd ~/powerlevel9k-test
@@ -539,31 +500,34 @@ function testBoldHomeSubdirWorks() {
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
cd /
assertEquals "%K{blue} %F{black}%B/%b %k%F{blue}%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
cd /tmp
assertEquals "%K{blue} %F{black}/%Btmp%b %k%F{blue}%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
mkdir -p /tmp/powerlevel9k-test
cd /tmp/powerlevel9k-test
@@ -571,21 +535,23 @@ function testBoldRootSubSubdirWorks() {
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'
cd ~
assertEquals "%K{blue} %F{black}%F{red}~ %k%F{blue}%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'
mkdir -p ~/powerlevel9k-test
cd ~/powerlevel9k-test
@@ -593,31 +559,34 @@ function testHighlightHomeSubdirWorks() {
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'
cd /
assertEquals "%K{blue} %F{black}%F{red}/ %k%F{blue}%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'
cd /tmp
assertEquals "%K{blue} %F{black}/%F{red}tmp %k%F{blue}%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'
mkdir /tmp/powerlevel9k-test
cd /tmp/powerlevel9k-test
@@ -625,11 +594,12 @@ function testHighlightRootSubSubdirWorks() {
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'
mkdir -p ~/powerlevel9k-test
cd ~/powerlevel9k-test
@@ -637,11 +607,12 @@ function testDirSeparatorColorHomeSubdirWorks() {
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'
mkdir -p /tmp/powerlevel9k-test
cd /tmp/powerlevel9k-test
@@ -649,7 +620,6 @@ function testDirSeparatorColorRootSubSubdirWorks() {
cd -
rm -fr /tmp/powerlevel9k-test
- unset POWERLEVEL9K_DIR_PATH_SEPARATOR_FOREGROUND
}
source shunit2/source/2.1/src/shunit2