aboutsummaryrefslogtreecommitdiff
path: root/test/segments/dir.spec
diff options
context:
space:
mode:
authorDominik Ritter <dritter03@googlemail.com>2018-07-25 08:52:06 +0300
committerDominik Ritter <dritter03@googlemail.com>2018-07-25 08:52:06 +0300
commit06de83cc0f2282b2217c6151277dfd6789593c2e (patch)
tree8e7d013b2f66f9431b732f64fe8c8c5c8a87e7c5 /test/segments/dir.spec
parent99f0eddd62806f99b8116e3f327689bc32529d5d (diff)
Prepare tests for performance optimizations
Diffstat (limited to 'test/segments/dir.spec')
-rwxr-xr-xtest/segments/dir.spec160
1 files changed, 153 insertions, 7 deletions
diff --git a/test/segments/dir.spec b/test/segments/dir.spec
index df80b23c..1f0440cd 100755
--- a/test/segments/dir.spec
+++ b/test/segments/dir.spec
@@ -7,8 +7,12 @@ SHUNIT_PARENT=$0
function setUp() {
export TERM="xterm-256color"
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
+
+ P9K_HOME="${PWD}"
+}
+
+function tearDown() {
+ unset P9K_HOME
}
function testDirPathAbsoluteWorks() {
@@ -16,6 +20,9 @@ function testDirPathAbsoluteWorks() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
local POWERLEVEL9K_DIR_PATH_ABSOLUTE=true
+ # Load Powerlevel9k
+ source ${P9K_HOME}/powerlevel9k.zsh-theme
+
cd ~
# Unfortunately, we cannot fake Linux or OSX here, because
@@ -36,6 +43,9 @@ function testTruncateFoldersWorks() {
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_folders'
+ # 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
@@ -52,6 +62,9 @@ function testTruncateFolderWithHomeDirWorks() {
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
local CURRENT_DIR=$(pwd)
+ # Load Powerlevel9k
+ source ${P9K_HOME}/powerlevel9k.zsh-theme
+
cd ~
local FOLDER="powerlevel9k-test-${RANDOM}"
mkdir -p $FOLDER
@@ -71,6 +84,9 @@ function testTruncateMiddleWorks() {
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_middle'
+ # 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
@@ -87,6 +103,9 @@ function testTruncationFromRightWorks() {
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_from_right'
+ # 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
@@ -103,6 +122,9 @@ function testTruncateToLastWorks() {
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
local POWERLEVEL9K_SHORTEN_STRATEGY="truncate_to_last"
+ # 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
@@ -119,6 +141,9 @@ function testTruncateToFirstAndLastWorks() {
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
local POWERLEVEL9K_SHORTEN_STRATEGY="truncate_to_first_and_last"
+ # 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
@@ -135,6 +160,9 @@ function testTruncateAbsoluteWorks() {
local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
local POWERLEVEL9K_SHORTEN_STRATEGY="truncate_absolute"
+ # 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
@@ -152,6 +180,9 @@ function testTruncationFromRightWithEmptyDelimiter() {
local POWERLEVEL9K_SHORTEN_DELIMITER=""
local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_from_right'
+ # 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
@@ -167,6 +198,9 @@ function testTruncateWithFolderMarkerWorks() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
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
mkdir -p $FOLDER
@@ -185,6 +219,9 @@ function testTruncateWithFolderMarkerWithChangedFolderMarker() {
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
mkdir -p $FOLDER
@@ -220,6 +257,9 @@ function testTruncateWithPackageNameWorks() {
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/1/12/123/12…/12…/12…/12…/12…/123456789 %k%F{blue}%f " "$(build_left_prompt)"
# Go back
@@ -257,6 +297,9 @@ function testTruncateWithPackageNameIfRepoIsSymlinkedInsideDeepFolder() {
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)"
# Go back
@@ -290,6 +333,9 @@ function testTruncateWithPackageNameIfRepoIsSymlinkedInsideGitDir() {
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/.g…/re…/heads %k%F{blue}%f " "$(build_left_prompt)"
# Go back
@@ -302,6 +348,9 @@ function testHomeFolderDetectionWorks() {
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%F{black}~ %k%F{blue}%f " "$(build_left_prompt)"
@@ -313,6 +362,9 @@ function testHomeSubfolderDetectionWorks() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
local POWERLEVEL9K_HOME_SUB_ICON='sub-icon'
+ # Load Powerlevel9k
+ source ${P9K_HOME}/powerlevel9k.zsh-theme
+
local FOLDER=~/powerlevel9k-test
mkdir $FOLDER
cd $FOLDER
@@ -327,6 +379,9 @@ function testOtherFolderDetectionWorks() {
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
local POWERLEVEL9K_FOLDER_ICON='folder-icon'
+ # Load Powerlevel9k
+ source ${P9K_HOME}/powerlevel9k.zsh-theme
+
local FOLDER=/tmp/powerlevel9k-test
mkdir $FOLDER
cd $FOLDER
@@ -340,6 +395,10 @@ function testChangingDirPathSeparator() {
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
@@ -353,25 +412,40 @@ function testChangingDirPathSeparator() {
function testHomeFolderAbbreviation() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
- local POWERLEVEL9K_HOME_FOLDER_ABBREVIATION
local dir=$PWD
cd ~/
# default
- POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='~'
+ local POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='~'
+
+ # Load Powerlevel9k
+ source ${P9K_HOME}/powerlevel9k.zsh-theme
+
assertEquals "%K{blue} %F{black}~ %k%F{blue}%f " "$(build_left_prompt)"
# substituted
- POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='qQq'
+ local POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='qQq'
+
+ # Load Powerlevel9k
+ source ${P9K_HOME}/powerlevel9k.zsh-theme
+
assertEquals "%K{blue} %F{black}qQq %k%F{blue}%f " "$(build_left_prompt)"
cd /tmp
# default
- POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='~'
+ local POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='~'
+
+ # Load Powerlevel9k
+ source ${P9K_HOME}/powerlevel9k.zsh-theme
+
assertEquals "%K{blue} %F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)"
# substituted
- POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='qQq'
+ local POWERLEVEL9K_HOME_FOLDER_ABBREVIATION='qQq'
+
+ # Load Powerlevel9k
+ source ${P9K_HOME}/powerlevel9k.zsh-theme
+
assertEquals "%K{blue} %F{black}/tmp %k%F{blue}%f " "$(build_left_prompt)"
cd "$dir"
@@ -382,6 +456,10 @@ function testOmittingFirstCharacterWorks() {
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%F{black}tmp %k%F{blue}%f " "$(build_left_prompt)"
@@ -395,6 +473,10 @@ function testOmittingFirstCharacterWorksWithChangingPathSeparator() {
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
@@ -418,6 +500,10 @@ function testOmittingFirstCharacterWorksWithChangingPathSeparatorAndDefaultTrunc
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
@@ -434,6 +520,10 @@ function testOmittingFirstCharacterWorksWithChangingPathSeparatorAndMiddleTrunca
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
@@ -450,6 +540,10 @@ function testOmittingFirstCharacterWorksWithChangingPathSeparatorAndRightTruncat
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
@@ -466,6 +560,10 @@ function testTruncateToUniqueWorks() {
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
@@ -482,6 +580,10 @@ function testBoldHomeDirWorks() {
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)"
@@ -493,6 +595,10 @@ function testBoldHomeSubdirWorks() {
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
@@ -506,6 +612,10 @@ function testBoldRootDirWorks() {
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)"
@@ -517,6 +627,10 @@ function testBoldRootSubdirWorks() {
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)"
@@ -528,6 +642,10 @@ function testBoldRootSubSubdirWorks() {
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
@@ -541,6 +659,10 @@ function testHighlightHomeWorks() {
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)"
@@ -552,6 +674,10 @@ function testHighlightHomeSubdirWorks() {
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
@@ -565,6 +691,10 @@ function testHighlightRootWorks() {
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)"
@@ -576,6 +706,10 @@ function testHighlightRootSubdirWorks() {
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)"
@@ -587,6 +721,10 @@ function testHighlightRootSubSubdirWorks() {
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
@@ -600,6 +738,10 @@ function testDirSeparatorColorHomeSubdirWorks() {
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
@@ -613,6 +755,10 @@ function testDirSeparatorColorRootSubSubdirWorks() {
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