1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-11-22 12:20:07 +00:00

Fix tests on older ZSH versions

This commit is contained in:
Dominik Ritter 2018-07-19 22:39:19 +02:00
parent 4b32b2c0b2
commit 16e5e14af7
23 changed files with 227 additions and 132 deletions

View file

@ -13,7 +13,8 @@ function setUp() {
function testAnacondaSegmentPrintsNothingIfNoAnacondaPathIsSet() {
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(anaconda custom_world)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(anaconda custom_world)
# Unset anacona variables
unset CONDA_ENV_PATH
unset CONDA_PREFIX
@ -24,7 +25,8 @@ function testAnacondaSegmentPrintsNothingIfNoAnacondaPathIsSet() {
function testAnacondaSegmentWorksIfOnlyAnacondaPathIsSet() {
CONDA_ENV_PATH=/tmp
unset CONDA_PREFIX
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(anaconda)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(anaconda)
local POWERLEVEL9K_PYTHON_ICON="icon-here"
assertEquals "%K{blue} %F{black%}icon-here %f%F{black}(tmp) %k%F{blue}%f " "$(build_left_prompt)"
@ -33,7 +35,8 @@ function testAnacondaSegmentWorksIfOnlyAnacondaPathIsSet() {
function testAnacondaSegmentWorksIfOnlyAnacondaPrefixIsSet() {
unset CONDA_ENV_PATH
local CONDA_PREFIX="test"
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(anaconda)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(anaconda)
local POWERLEVEL9K_PYTHON_ICON="icon-here"
assertEquals "%K{blue} %F{black%}icon-here %f%F{black}(test) %k%F{blue}%f " "$(build_left_prompt)"
@ -42,7 +45,8 @@ function testAnacondaSegmentWorksIfOnlyAnacondaPrefixIsSet() {
function testAnacondaSegmentWorks() {
local CONDA_ENV_PATH=/tmp
local CONDA_PREFIX="test"
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(anaconda)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(anaconda)
local POWERLEVEL9K_PYTHON_ICON="icon-here"
assertEquals "%K{blue} %F{black%}icon-here %f%F{black}(tmptest) %k%F{blue}%f " "$(build_left_prompt)"

View file

@ -23,7 +23,7 @@ function testAwsEbEnvSegmentWorksIfElasticBeanstalkEnvironmentIsSet() {
echo "test:\n environment: test" > /tmp/powerlevel9k-test/.elasticbeanstalk/config.yml
cd /tmp/powerlevel9k-test
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(aws_eb_env)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(aws_eb_env)
assertEquals "%K{black} %F{green%}🌱 %f%F{green}test %k%F{black}%f " "$(build_left_prompt)"
@ -40,7 +40,8 @@ function testAwsEbEnvSegmentWorksIfElasticBeanstalkEnvironmentIsSetInParentDirec
echo "test:\n environment: test" > /tmp/powerlevel9k-test/.elasticbeanstalk/config.yml
cd /tmp/powerlevel9k-test/1/12/123/1234/12345
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(aws_eb_env)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(aws_eb_env)
assertEquals "%K{black} %F{green%}🌱 %f%F{green}test %k%F{black}%f " "$(build_left_prompt)"

View file

@ -13,7 +13,8 @@ function setUp() {
function testBackgroundJobsSegmentPrintsNothingWithoutBackgroundJobs() {
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(background_jobs custom_world)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(background_jobs custom_world)
alias jobs="nojobs 2>/dev/null"
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
@ -23,7 +24,8 @@ function testBackgroundJobsSegmentPrintsNothingWithoutBackgroundJobs() {
function testBackgroundJobsSegmentWorksWithOneBackgroundJob() {
unset POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(background_jobs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(background_jobs)
jobs() {
echo '[1] + 30444 suspended nvim xx'
}
@ -35,7 +37,8 @@ function testBackgroundJobsSegmentWorksWithOneBackgroundJob() {
function testBackgroundJobsSegmentWorksWithMultipleBackgroundJobs() {
unset POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(background_jobs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(background_jobs)
jobs() {
echo "[1] 31190 suspended nvim xx"
echo "[2] - 31194 suspended nvim xx2"
@ -49,7 +52,8 @@ function testBackgroundJobsSegmentWorksWithMultipleBackgroundJobs() {
function testBackgroundJobsSegmentWithVerboseMode() {
local POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE=true
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(background_jobs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(background_jobs)
jobs() {
echo "[1] 31190 suspended nvim xx"
echo "[2] - 31194 suspended nvim xx2"

View file

@ -65,7 +65,6 @@ function makeBatterySay() {
function testBatterySegmentIfBatteryIsLowWhileDischargingOnOSX() {
local OS='OSX' # Fake OSX
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(battery)
makeBatterySay "Now drawing from 'Battery Power'
-InternalBattery-0 (id=1234567) 4%; discharging; 0:05 remaining present: true"
@ -74,7 +73,6 @@ function testBatterySegmentIfBatteryIsLowWhileDischargingOnOSX() {
function testBatterySegmentIfBatteryIsLowWhileChargingOnOSX() {
local OS='OSX' # Fake OSX
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(battery)
makeBatterySay "Now drawing from 'Battery Power'
-InternalBattery-0 (id=1234567) 4%; charging; 0:05 remaining present: true"
@ -83,7 +81,6 @@ function testBatterySegmentIfBatteryIsLowWhileChargingOnOSX() {
function testBatterySegmentIfBatteryIsAlmostFullWhileDischargingOnOSX() {
local OS='OSX' # Fake OSX
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(battery)
makeBatterySay "Now drawing from 'Battery Power'
-InternalBattery-0 (id=1234567) 98%; discharging; 3:57 remaining present: true"
@ -92,7 +89,6 @@ function testBatterySegmentIfBatteryIsAlmostFullWhileDischargingOnOSX() {
function testBatterySegmentIfBatteryIsAlmostFullWhileChargingOnOSX() {
local OS='OSX' # Fake OSX
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(battery)
makeBatterySay "Now drawing from 'Battery Power'
-InternalBattery-0 (id=1234567) 98%; charging; 3:57 remaining present: true"
@ -109,7 +105,6 @@ function testBatterySegmentIfBatteryIsFullOnOSX() {
function testBatterySegmentIfBatteryIsCalculatingOnOSX() {
local OS='OSX' # Fake OSX
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(battery)
makeBatterySay "Now drawing from 'Battery Power'
-InternalBattery-0 (id=1234567) 99%; discharging; (no estimate) present: true"
@ -118,7 +113,6 @@ function testBatterySegmentIfBatteryIsCalculatingOnOSX() {
function testBatterySegmentIfBatteryIsLowWhileDischargingOnLinux() {
local OS='Linux' # Fake Linux
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(battery)
makeBatterySay "4" "Discharging"
assertEquals "%K{black} %F{red%}🔋 %f%F{red}4%% " "$(prompt_battery left 1 false ${FOLDER})"
@ -126,7 +120,6 @@ function testBatterySegmentIfBatteryIsLowWhileDischargingOnLinux() {
function testBatterySegmentIfBatteryIsLowWhileChargingOnLinux() {
local OS='Linux' # Fake Linux
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(battery)
makeBatterySay "4" "Charging"
assertEquals "%K{black} %F{yellow%}🔋 %f%F{yellow}4%% " "$(prompt_battery left 1 false ${FOLDER})"
@ -134,7 +127,6 @@ function testBatterySegmentIfBatteryIsLowWhileChargingOnLinux() {
function testBatterySegmentIfBatteryIsNormalWhileDischargingOnLinux() {
local OS='Linux' # Fake Linux
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(battery)
makeBatterySay "10" "Discharging"
assertEquals "%K{black} %F{white%}🔋 %f%F{white}10%% " "$(prompt_battery left 1 false ${FOLDER})"
@ -142,7 +134,6 @@ function testBatterySegmentIfBatteryIsNormalWhileDischargingOnLinux() {
function testBatterySegmentIfBatteryIsNormalWhileChargingOnLinux() {
local OS='Linux' # Fake Linux
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(battery)
makeBatterySay "10" "Charging"
assertEquals "%K{black} %F{yellow%}🔋 %f%F{yellow}10%% " "$(prompt_battery left 1 false ${FOLDER})"
@ -150,7 +141,6 @@ function testBatterySegmentIfBatteryIsNormalWhileChargingOnLinux() {
function testBatterySegmentIfBatteryIsFullOnLinux() {
local OS='Linux' # Fake Linux
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(battery)
makeBatterySay "100" "Full"
assertEquals "%K{black} %F{green%}🔋 %f%F{green}100%% " "$(prompt_battery left 1 false ${FOLDER})"
@ -158,7 +148,6 @@ function testBatterySegmentIfBatteryIsFullOnLinux() {
function testBatterySegmentIfBatteryIsNormalWithAcpiEnabledOnLinux() {
local OS='Linux' # Fake Linux
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(battery)
makeBatterySay "50" "Discharging"
echo "echo 'Batter 0: Discharging, 50%, 01:38:54 remaining'" > ${FOLDER}/usr/bin/acpi
chmod +x ${FOLDER}/usr/bin/acpi
@ -172,7 +161,6 @@ function testBatterySegmentIfBatteryIsNormalWithAcpiEnabledOnLinux() {
function testBatterySegmentIfBatteryIsCalculatingWithAcpiEnabledOnLinux() {
local OS='Linux' # Fake Linux
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(battery)
makeBatterySay "50" "Discharging"
# Todo: Include real acpi output!
echo "echo 'Batter 0: Discharging, 50%, rate remaining'" > ${FOLDER}/usr/bin/acpi

View file

@ -23,41 +23,47 @@ function tearDown() {
function testContextSegmentDoesNotGetRenderedWithDefaultUser() {
local DEFAULT_USER=$(whoami)
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context custom_world)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context custom_world)
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
}
function testContextSegmentDoesGetRenderedWhenSshConnectionIsOpen() {
local SSH_CLIENT="putty"
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context)
assertEquals "%K{black} %F{yellow}%n@%m %k%F{black}%f " "$(build_left_prompt)"
}
function testContextSegmentWithForeignUser() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context)
assertEquals "%K{black} %F{yellow}%n@%m %k%F{black}%f " "$(build_left_prompt)"
}
# TODO: How to test root?
function testContextSegmentWithRootUser() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context)
startSkipping # Skip test
assertEquals "%K{black} %F{yellow}%n@%m %k%F{black}%f " "$(build_left_prompt)"
}
function testOverridingContextTemplate() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context)
local POWERLEVEL9K_CONTEXT_TEMPLATE=xx
assertEquals "%K{black} %F{yellow}xx %k%F{black}%f " "$(build_left_prompt)"
}
function testContextSegmentIsShownIfDefaultUserIsSetWhenForced() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context)
local POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true
local DEFAULT_USER=$(whoami)
@ -65,7 +71,8 @@ function testContextSegmentIsShownIfDefaultUserIsSetWhenForced() {
}
function testContextSegmentIsShownIfForced() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context)
local POWERLEVEL9K_ALWAYS_SHOW_USER=true
local DEFAULT_USER=$(whoami)

View file

@ -12,14 +12,16 @@ function setUp() {
}
function testCustomDirectOutputSegment() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world)
local POWERLEVEL9K_CUSTOM_WORLD="echo world"
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world)
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
}
function testCustomClosureSegment() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world)
function p9k_hello_world() {
echo "world"
}
@ -29,7 +31,8 @@ function testCustomClosureSegment() {
}
function testSettingBackgroundForCustomSegment() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world)
local POWERLEVEL9K_CUSTOM_WORLD="echo world"
local POWERLEVEL9K_CUSTOM_WORLD_BACKGROUND="yellow"
@ -37,7 +40,8 @@ function testSettingBackgroundForCustomSegment() {
}
function testSettingForegroundForCustomSegment() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world)
local POWERLEVEL9K_CUSTOM_WORLD="echo world"
local POWERLEVEL9K_CUSTOM_WORLD_FOREGROUND="red"
@ -45,7 +49,8 @@ function testSettingForegroundForCustomSegment() {
}
function testSettingVisualIdentifierForCustomSegment() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world)
local POWERLEVEL9K_CUSTOM_WORLD="echo world"
local POWERLEVEL9K_CUSTOM_WORLD_ICON="hw"
@ -53,7 +58,8 @@ function testSettingVisualIdentifierForCustomSegment() {
}
function testSettingVisualIdentifierForegroundColorForCustomSegment() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world)
local POWERLEVEL9K_CUSTOM_WORLD="echo world"
local POWERLEVEL9K_CUSTOM_WORLD_ICON="hw"
local POWERLEVEL9K_CUSTOM_WORLD_VISUAL_IDENTIFIER_COLOR="red"

View file

@ -12,10 +12,11 @@ function setUp() {
}
function testDetectVirtSegmentPrintsNothingIfSystemdIsNotAvailable() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(detect_virt custom_world)
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
alias systemd-detect-virt="novirt"
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(detect_virt custom_world)
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
@ -23,7 +24,8 @@ function testDetectVirtSegmentPrintsNothingIfSystemdIsNotAvailable() {
}
function testDetectVirtSegmentIfSystemdReturnsPlainName() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(detect_virt)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(detect_virt)
alias systemd-detect-virt="echo 'xxx'"
assertEquals "%K{black} %F{yellow}xxx %k%F{black}%f " "$(build_left_prompt)"
@ -32,7 +34,8 @@ function testDetectVirtSegmentIfSystemdReturnsPlainName() {
}
function testDetectVirtSegmentIfRootFsIsOnExpectedInode() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(detect_virt)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(detect_virt)
# Well. This is a weak test, as it fixates the implementation,
# but it is necessary, as the implementation relys on the root
# directory having the inode number "2"..
@ -49,7 +52,8 @@ function testDetectVirtSegmentIfRootFsIsOnExpectedInode() {
}
function testDetectVirtSegmentIfRootFsIsNotOnExpectedInode() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(detect_virt)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(detect_virt)
# Well. This is a weak test, as it fixates the implementation,
# but it is necessary, as the implementation relys on the root
# directory having the inode number "2"..

View file

@ -32,11 +32,12 @@ function tearDown() {
}
function testDiskUsageSegmentWhenDiskIsAlmostFull() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(disk_usage)
df() {
echo "Filesystem 1K-blocks Used Available Use% Mounted on
/dev/disk1 487219288 471466944 15496344 97% /"
}
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(disk_usage)
assertEquals "%K{red} %F{white%}hdd %f%F{white}97%% %k%F{red}%f " "$(build_left_prompt)"
@ -44,11 +45,12 @@ function testDiskUsageSegmentWhenDiskIsAlmostFull() {
}
function testDiskUsageSegmentWhenDiskIsVeryFull() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(disk_usage)
df() {
echo "Filesystem 1K-blocks Used Available Use% Mounted on
/dev/disk1 487219288 471466944 15496344 94% /"
}
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(disk_usage)
assertEquals "%K{yellow} %F{black%}hdd %f%F{black}94%% %k%F{yellow}%f " "$(build_left_prompt)"
@ -56,11 +58,12 @@ function testDiskUsageSegmentWhenDiskIsVeryFull() {
}
function testDiskUsageSegmentWhenDiskIsQuiteEmpty() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(disk_usage)
df() {
echo "Filesystem 1K-blocks Used Available Use% Mounted on
/dev/disk1 487219288 471466944 15496344 4% /"
}
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(disk_usage)
assertEquals "%K{black} %F{yellow%}hdd %f%F{yellow}4%% %k%F{black}%f " "$(build_left_prompt)"
@ -68,12 +71,13 @@ function testDiskUsageSegmentWhenDiskIsQuiteEmpty() {
}
function testDiskUsageSegmentPrintsNothingIfDiskIsQuiteEmptyAndOnlyWarningsShouldBeDisplayed() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(disk_usage custom_world)
df() {
echo "Filesystem 1K-blocks Used Available Use% Mounted on
/dev/disk1 487219288 471466944 15496344 4% /"
}
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(disk_usage custom_world)
local POWERLEVEL9K_DISK_USAGE_ONLY_WARNING=true
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
@ -83,11 +87,12 @@ function testDiskUsageSegmentPrintsNothingIfDiskIsQuiteEmptyAndOnlyWarningsShoul
}
function testDiskUsageSegmentWarningLevelCouldBeAdjusted() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(disk_usage)
df() {
echo "Filesystem 1K-blocks Used Available Use% Mounted on
/dev/disk1 487219288 471466944 15496344 11% /"
}
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(disk_usage)
local POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL=10
assertEquals "%K{yellow} %F{black%}hdd %f%F{black}11%% %k%F{yellow}%f " "$(build_left_prompt)"
@ -96,11 +101,12 @@ function testDiskUsageSegmentWarningLevelCouldBeAdjusted() {
}
function testDiskUsageSegmentCriticalLevelCouldBeAdjusted() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(disk_usage)
df() {
echo "Filesystem 1K-blocks Used Available Use% Mounted on
/dev/disk1 487219288 471466944 15496344 11% /"
}
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(disk_usage)
local POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL=5
local POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL=10

View file

@ -12,8 +12,9 @@ function setUp() {
}
function testIpSegmentPrintsNothingOnOsxIfNotConnected() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip custom_world)
alias networksetup='echo "not connected"'
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip custom_world)
local OS="OSX" # Fake OSX
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
@ -23,8 +24,9 @@ function testIpSegmentPrintsNothingOnOsxIfNotConnected() {
}
function testIpSegmentPrintsNothingOnLinuxIfNotConnected() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip custom_world)
alias ip='echo "not connected"'
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip custom_world)
local OS="Linux" # Fake Linux
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
@ -34,7 +36,8 @@ function testIpSegmentPrintsNothingOnLinuxIfNotConnected() {
}
function testIpSegmentWorksOnOsxWithNoInterfaceSpecified() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip)
local OS='OSX' # Fake OSX
alias networksetup="echo 'An asterisk (*) denotes that a network service is disabled.
(1) Ethernet
@ -69,7 +72,8 @@ function testIpSegmentWorksOnOsxWithNoInterfaceSpecified() {
# in hierarchical order, but from outside this is not obvious
# (implementation detail). So we need a test for this case.
function testIpSegmentWorksOnOsxWithMultipleInterfacesSpecified() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip)
local OS='OSX' # Fake OSX
alias networksetup="echo 'An asterisk (*) denotes that a network service is disabled.
(1) Ethernet
@ -116,7 +120,8 @@ function testIpSegmentWorksOnOsxWithMultipleInterfacesSpecified() {
}
function testIpSegmentWorksOnOsxWithInterfaceSpecified() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip)
local OS='OSX' # Fake OSX
local POWERLEVEL9K_IP_INTERFACE='xxx'
alias ipconfig="_(){ echo '1.2.3.4'; };_"
@ -155,7 +160,8 @@ function testIpSegmentWorksOnLinuxWithNoInterfaceSpecified() {
function testIpSegmentWorksOnLinuxWithMultipleInterfacesSpecified() {
setopt aliases
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip)
local OS='Linux' # Fake Linux
# That command is harder to test, as it is used at first
# to get all relevant network interfaces and then for
@ -185,7 +191,8 @@ function testIpSegmentWorksOnLinuxWithMultipleInterfacesSpecified() {
}
function testIpSegmentWorksOnLinuxWithInterfaceSpecified() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip)
local OS='Linux' # Fake Linux
local POWERLEVEL9K_IP_INTERFACE='xxx'
ip(){

View file

@ -12,7 +12,8 @@ function setUp() {
}
function testNodeVersionSegmentPrintsNothingWithoutNode() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(node_version custom_world)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(node_version custom_world)
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
alias node="nonode 2>/dev/null"
@ -23,7 +24,8 @@ function testNodeVersionSegmentPrintsNothingWithoutNode() {
}
function testNodeVersionSegmentWorks() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(node_version)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(node_version)
node() {
echo "v1.2.3"
}

View file

@ -17,7 +17,8 @@ function setUp() {
}
function testNodeenvSegmentPrintsNothingWithoutNode() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nodeenv custom_world)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nodeenv custom_world)
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
alias node="nonode 2>/dev/null"
@ -27,7 +28,8 @@ function testNodeenvSegmentPrintsNothingWithoutNode() {
}
function testNodeenvSegmentPrintsNothingIfNodeVirtualEnvIsNotSet() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nodeenv custom_world)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nodeenv custom_world)
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
node() {
echo "v1.2.3"
@ -39,7 +41,8 @@ function testNodeenvSegmentPrintsNothingIfNodeVirtualEnvIsNotSet() {
}
function testNodeenvSegmentPrintsNothingIfNodeVirtualEnvDisablePromptIsSet() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nodeenv custom_world)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nodeenv custom_world)
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
node() {
echo "v1.2.3"
@ -55,7 +58,8 @@ function testNodeenvSegmentPrintsNothingIfNodeVirtualEnvDisablePromptIsSet() {
}
function testNodeenvSegmentPrintsAtLeastNodeEnvWithoutNode() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nodeenv)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nodeenv)
alias node="nonode 2>/dev/null"
NODE_VIRTUAL_ENV="node-env"
@ -66,7 +70,8 @@ function testNodeenvSegmentPrintsAtLeastNodeEnvWithoutNode() {
}
function testNodeenvSegmentWorks() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nodeenv)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nodeenv)
node() {
echo "v1.2.3"
}

View file

@ -32,14 +32,16 @@ function tearDown() {
}
function testNvmSegmentPrintsNothingIfNvmIsNotAvailable() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nvm custom_world)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nvm custom_world)
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
}
function testNvmSegmentWorksWithoutHavingADefaultAlias() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nvm)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nvm)
function nvm_version() {
[[ ${1} == 'current' ]] && echo 'v4.6.0' || echo 'v1.4.0'
@ -49,7 +51,8 @@ function testNvmSegmentWorksWithoutHavingADefaultAlias() {
}
function testNvmSegmentPrintsNothingWhenOnDefaultVersion() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nvm custom_world)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nvm custom_world)
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
function nvm_version() {

View file

@ -12,7 +12,8 @@ function setUp() {
}
function testPhpVersionSegmentPrintsNothingIfPhpIsNotAvailable() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(php_version custom_world)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(php_version custom_world)
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
alias php="nophp"
@ -22,7 +23,8 @@ function testPhpVersionSegmentPrintsNothingIfPhpIsNotAvailable() {
}
function testPhpVersionSegmentWorks() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(php_version)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(php_version)
alias php="echo 'PHP 5.6.27 (cli) (built: Oct 23 2016 11:47:58)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

View file

@ -36,7 +36,8 @@ function tearDown() {
}
function testPublicIpSegmentPrintsNothingByDefaultIfHostIsNotAvailable() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip custom_world)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip custom_world)
local POWERLEVEL9K_PUBLIC_IP_HOST='http://unknown.xyz'
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
# We need to overwrite dig, as this is a fallback method that
@ -49,7 +50,8 @@ function testPublicIpSegmentPrintsNothingByDefaultIfHostIsNotAvailable() {
}
function testPublicIpSegmentPrintsNoticeIfNotConnected() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
local POWERLEVEL9K_PUBLIC_IP_HOST='http://unknown.xyz'
local POWERLEVEL9K_PUBLIC_IP_NONE="disconnected"
# We need to overwrite dig, as this is a fallback method that
@ -62,7 +64,8 @@ function testPublicIpSegmentPrintsNoticeIfNotConnected() {
}
function testPublicIpSegmentWorksWithWget() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
alias dig='nodig'
alias curl='nocurl'
wget() {
@ -77,7 +80,8 @@ function testPublicIpSegmentWorksWithWget() {
}
function testPublicIpSegmentUsesCurlAsFallbackMethodIfWgetIsNotAvailable() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
alias dig='nodig'
alias wget='nowget'
curl() {
@ -92,7 +96,8 @@ function testPublicIpSegmentUsesCurlAsFallbackMethodIfWgetIsNotAvailable() {
}
function testPublicIpSegmentUsesDigAsFallbackMethodIfWgetAndCurlAreNotAvailable() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
alias curl='nocurl'
alias wget='nowget'
dig() {
@ -107,7 +112,8 @@ function testPublicIpSegmentUsesDigAsFallbackMethodIfWgetAndCurlAreNotAvailable(
}
function testPublicIpSegmentCachesFile() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
dig() {
echo "first"
}
@ -125,7 +131,8 @@ function testPublicIpSegmentCachesFile() {
}
function testPublicIpSegmentRefreshesCachesFileAfterTimeout() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
local POWERLEVEL9K_PUBLIC_IP_TIMEOUT=2
dig() {
echo "first"
@ -145,7 +152,8 @@ function testPublicIpSegmentRefreshesCachesFileAfterTimeout() {
}
function testPublicIpSegmentRefreshesCachesFileIfEmpty() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
dig() {
echo "first"
}
@ -166,7 +174,8 @@ function testPublicIpSegmentRefreshesCachesFileIfEmpty() {
}
function testPublicIpSegmentWhenGoingOnline() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
local POWERLEVEL9K_PUBLIC_IP_METHODS="dig"
local POWERLEVEL9K_PUBLIC_IP_NONE="disconnected"
alias dig="nodig"

View file

@ -28,7 +28,6 @@ function tearDown() {
}
function testRamSegmentWorksOnOsx() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ram)
local OS="OSX" # Fake OSX
alias vm_stat="echo 'Mach Virtual Memory Statistics: (page size of 4096 bytes)
Pages free: 299687.
@ -42,7 +41,6 @@ Pages inactive: 1313411.
}
function testRamSegmentWorksOnBsd() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ram)
local OS="BSD" # Fake BSD
mkdir -p var/run
echo "avail memory 5678B 299687 4444G 299" > var/run/dmesg.boot
@ -51,7 +49,6 @@ function testRamSegmentWorksOnBsd() {
}
function testRamSegmentWorksOnLinux() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ram)
local OS="Linux" # Fake Linux
mkdir proc
echo "MemAvailable: 299687" > proc/meminfo

View file

@ -16,7 +16,8 @@ function mockRust() {
}
function testSshSegmentPrintsNothingIfNoSshConnection() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ssh custom_world)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ssh custom_world)
local POWERLEVEL9K_CUSTOM_WORLD='echo "world"'
local POWERLEVEL9K_SSH_ICON="ssh-icon"
# Weak test: Emulate No SSH connection by unsetting
@ -28,7 +29,8 @@ function testSshSegmentPrintsNothingIfNoSshConnection() {
}
function testSshSegmentWorksIfOnlySshClientIsSet() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ssh)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ssh)
local POWERLEVEL9K_SSH_ICON="ssh-icon"
# Weak test: Emulate No SSH connection by unsetting
# $SSH_CLIENT and $SSH_TTY
@ -41,7 +43,8 @@ function testSshSegmentWorksIfOnlySshClientIsSet() {
}
function testSshSegmentWorksIfOnlySshTtyIsSet() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ssh)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ssh)
local POWERLEVEL9K_SSH_ICON="ssh-icon"
# Weak test: Emulate No SSH connection by unsetting
# $SSH_CLIENT and $SSH_TTY
@ -54,7 +57,8 @@ function testSshSegmentWorksIfOnlySshTtyIsSet() {
}
function testSshSegmentWorksIfAllNecessaryVariablesAreSet() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ssh)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ssh)
local POWERLEVEL9K_SSH_ICON="ssh-icon"
# Weak test: Emulate No SSH connection by unsetting
# $SSH_CLIENT and $SSH_TTY

View file

@ -17,8 +17,9 @@ function setUp() {
}
function testStatusPrintsNothingIfReturnCodeIsZeroAndVerboseIsUnset() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status custom_world)
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status custom_world)
local POWERLEVEL9K_STATUS_VERBOSE=false
local POWERLEVEL9K_STATUS_SHOW_PIPESTATUS=false
@ -26,56 +27,63 @@ function testStatusPrintsNothingIfReturnCodeIsZeroAndVerboseIsUnset() {
}
function testStatusWorksAsExpectedIfReturnCodeIsZeroAndVerboseIsSet() {
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status)
local POWERLEVEL9K_STATUS_VERBOSE=true
local POWERLEVEL9K_STATUS_SHOW_PIPESTATUS=false
local POWERLEVEL9K_STATUS_HIDE_SIGNAME=true
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status)
assertEquals "%K{black} %F{green%}%f %k%F{black}%f " "$(build_left_prompt)"
}
function testStatusInGeneralErrorCase() {
local RETVAL=1
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status)
local POWERLEVEL9K_STATUS_VERBOSE=true
local POWERLEVEL9K_STATUS_SHOW_PIPESTATUS=false
local RETVAL=1
assertEquals "%K{red} %F{yellow1%} %f%F{yellow1}1 %k%F{red}%f " "$(build_left_prompt)"
}
function testPipestatusInErrorCase() {
local -a RETVALS
RETVALS=(0 0 1 0)
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status)
local POWERLEVEL9K_STATUS_VERBOSE=true
local POWERLEVEL9K_STATUS_SHOW_PIPESTATUS=true
local -a RETVALS
RETVALS=(0 0 1 0)
assertEquals "%K{red} %F{yellow1%} %f%F{yellow1}0|0|1|0 %k%F{red}%f " "$(build_left_prompt)"
}
function testStatusCrossWinsOverVerbose() {
local RETVAL=1
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status)
local POWERLEVEL9K_STATUS_SHOW_PIPESTATUS=false
local POWERLEVEL9K_STATUS_VERBOSE=true
local POWERLEVEL9K_STATUS_CROSS=true
local RETVAL=1
assertEquals "%K{black} %F{red%}%f %k%F{black}%f " "$(build_left_prompt)"
}
function testStatusShowsSignalNameInErrorCase() {
local RETVAL=132
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status)
local POWERLEVEL9K_STATUS_SHOW_PIPESTATUS=false
local POWERLEVEL9K_STATUS_VERBOSE=true
local POWERLEVEL9K_STATUS_HIDE_SIGNAME=false
local RETVAL=132
assertEquals "%K{red} %F{yellow1%} %f%F{yellow1}SIGILL(4) %k%F{red}%f " "$(build_left_prompt)"
}
function testStatusSegmentIntegrated() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status)
local POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=()
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status)
local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=()
false; powerlevel9k_prepare_prompts

View file

@ -28,7 +28,8 @@ function tearDown() {
}
function testSwapSegmentWorksOnOsx() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(swap)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(swap)
local OS="OSX" # Fake OSX
sysctl() {
echo "vm.swapusage: total = 3072,00M used = 1620,50M free = 1451,50M (encrypted)"
@ -40,7 +41,8 @@ function testSwapSegmentWorksOnOsx() {
}
function testSwapSegmentWorksOnLinux() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(swap)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(swap)
local OS="Linux" # Fake Linux
mkdir proc
echo "SwapTotal: 1000000" > proc/meminfo

View file

@ -28,7 +28,8 @@ function tearDown() {
}
function testSwiftSegmentPrintsNothingIfSwiftIsNotAvailable() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(swift_version custom_world)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(swift_version custom_world)
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
alias swift="noswift"
@ -39,7 +40,8 @@ function testSwiftSegmentPrintsNothingIfSwiftIsNotAvailable() {
}
function testSwiftSegmentWorks() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(swift_version)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(swift_version)
function swift() {
echo "Apple Swift version 3.0.1 (swiftlang-800.0.58.6 clang-800.0.42.1)\nTarget: x86_64-apple-macosx10.9"
}

View file

@ -28,7 +28,8 @@ function tearDown() {
}
function testSymfonyVersionSegmentPrintsNothingIfPhpIsNotAvailable() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(symfony2_version custom_world)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(symfony2_version custom_world)
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
alias php="nophp"
@ -38,7 +39,8 @@ function testSymfonyVersionSegmentPrintsNothingIfPhpIsNotAvailable() {
}
function testSymfonyVersionSegmentPrintsNothingIfSymfonyIsNotAvailable() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(symfony2_version custom_world)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(symfony2_version custom_world)
# "Symfony" is not a command, but rather a framework.
# To sucessfully execute this test, we just need to
# navigate into a folder that does not contain symfony.
@ -48,7 +50,8 @@ function testSymfonyVersionSegmentPrintsNothingIfSymfonyIsNotAvailable() {
}
function testSymfonyVersionPrintsNothingIfPhpThrowsAnError() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(symfony2_version custom_world)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(symfony2_version custom_world)
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
mkdir app
touch app/AppKernel.php
@ -65,7 +68,8 @@ function testSymfonyVersionPrintsNothingIfPhpThrowsAnError() {
function testSymfonyVersionSegmentWorks() {
startSkipping # Skip test
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(symfony2_version)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(symfony2_version)
mkdir app
touch app/AppKernel.php
@ -80,7 +84,8 @@ function testSymfonyVersionSegmentWorks() {
function testSymfonyVersionSegmentWorksInNestedFolder() {
startSkipping # Skip test
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(symfony2_version)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(symfony2_version)
mkdir app
touch app/AppKernel.php

View file

@ -33,7 +33,8 @@ function tearDown() {
}
function testTodoSegmentPrintsNothingIfTodoShIsNotInstalled() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(todo custom_world)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(todo custom_world)
local POWERLEVEL9K_CUSTOM_WORLD='echo world'
assertEquals "%K{white} %F{black}world %k%F{white}%f " "$(build_left_prompt)"
@ -41,7 +42,8 @@ function testTodoSegmentPrintsNothingIfTodoShIsNotInstalled() {
function testTodoSegmentWorksAsExpected() {
# TODO: Skript in den PATH legen!
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(todo)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(todo)
echo '#!/bin/sh' > ${FOLDER}/bin/todo.sh
echo 'echo "TODO: 34 of 100 tasks shown";' >> ${FOLDER}/bin/todo.sh
chmod +x ${FOLDER}/bin/todo.sh

View file

@ -70,7 +70,8 @@ function tearDown() {
}
function testColorOverridingForCleanStateWorks() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local POWERLEVEL9K_VCS_CLEAN_FOREGROUND='cyan'
local POWERLEVEL9K_VCS_CLEAN_BACKGROUND='white'
@ -78,7 +79,8 @@ function testColorOverridingForCleanStateWorks() {
}
function testColorOverridingForModifiedStateWorks() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local POWERLEVEL9K_VCS_MODIFIED_FOREGROUND='red'
local POWERLEVEL9K_VCS_MODIFIED_BACKGROUND='yellow'
@ -91,7 +93,8 @@ function testColorOverridingForModifiedStateWorks() {
}
function testColorOverridingForUntrackedStateWorks() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND='cyan'
local POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND='yellow'
@ -108,7 +111,8 @@ function testGitIconWorks() {
}
function testGitlabIconWorks() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local POWERLEVEL9K_VCS_GIT_GITLAB_ICON='GL-Icon'
# Add a GitLab project as remote origin. This is
@ -119,7 +123,8 @@ function testGitlabIconWorks() {
}
function testBitbucketIconWorks() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local POWERLEVEL9K_VCS_GIT_BITBUCKET_ICON='BB-Icon'
# Add a BitBucket project as remote origin. This is
@ -130,7 +135,8 @@ function testBitbucketIconWorks() {
}
function testGitHubIconWorks() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local POWERLEVEL9K_VCS_GIT_GITHUB_ICON='GH-Icon'
# Add a GitHub project as remote origin. This is
@ -141,7 +147,8 @@ function testGitHubIconWorks() {
}
function testUntrackedFilesIconWorks() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local POWERLEVEL9K_VCS_UNTRACKED_ICON='?'
# Create untracked file
@ -151,7 +158,8 @@ function testUntrackedFilesIconWorks() {
}
function testStagedFilesIconWorks() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local POWERLEVEL9K_VCS_STAGED_ICON='+'
# Create staged file
@ -165,7 +173,8 @@ function testStagedFilesIconWorks() {
}
function testUnstagedFilesIconWorks() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local POWERLEVEL9K_VCS_UNSTAGED_ICON='M'
# Create unstaged (modified, but not added to index) file
@ -178,7 +187,8 @@ function testUnstagedFilesIconWorks() {
}
function testStashIconWorks() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local POWERLEVEL9K_VCS_STASH_ICON='S'
# Create modified file
@ -192,7 +202,8 @@ function testStashIconWorks() {
}
function testTagIconWorks() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local POWERLEVEL9K_VCS_TAG_ICON='T'
touch "file.txt"
@ -204,7 +215,8 @@ function testTagIconWorks() {
}
function testTagIconInDetachedHeadState() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local POWERLEVEL9K_VCS_TAG_ICON='T'
touch "file.txt"
@ -221,7 +233,8 @@ function testTagIconInDetachedHeadState() {
}
function testActionHintWorks() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
touch "i-am-modified.txt"
git add i-am-modified.txt
@ -240,7 +253,8 @@ function testActionHintWorks() {
}
function testIncomingHintWorks() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local POWERLEVEL9K_VCS_INCOMING_CHANGES_ICON='I'
touch "i-am-modified.txt"
@ -258,7 +272,8 @@ function testIncomingHintWorks() {
}
function testOutgoingHintWorks() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local POWERLEVEL9K_VCS_OUTGOING_CHANGES_ICON='o'
touch "i-am-modified.txt"
@ -276,7 +291,8 @@ function testOutgoingHintWorks() {
}
function testShorteningCommitHashWorks() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local POWERLEVEL9K_SHOW_CHANGESET=true
local POWERLEVEL9K_CHANGESET_HASH_LENGTH='4'
@ -292,7 +308,8 @@ function testShorteningCommitHashWorks() {
}
function testShorteningCommitHashIsNotShownIfShowChangesetIsFalse() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local POWERLEVEL9K_SHOW_CHANGESET=false
local POWERLEVEL9K_CHANGESET_HASH_LENGTH='4'

View file

@ -34,7 +34,8 @@ function tearDown() {
}
function testColorOverridingForCleanStateWorks() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local POWERLEVEL9K_VCS_CLEAN_FOREGROUND='cyan'
local POWERLEVEL9K_VCS_CLEAN_BACKGROUND='white'
@ -42,7 +43,8 @@ function testColorOverridingForCleanStateWorks() {
}
function testColorOverridingForModifiedStateWorks() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local POWERLEVEL9K_VCS_MODIFIED_FOREGROUND='red'
local POWERLEVEL9K_VCS_MODIFIED_BACKGROUND='yellow'
@ -60,7 +62,8 @@ function testColorOverridingForModifiedStateWorks() {
# This may be improved in future versions, to be a bit more consistent with
# the git part.
function testAddedFilesIconWorks() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
touch "myfile.txt"
hg add myfile.txt
@ -70,7 +73,8 @@ function testAddedFilesIconWorks() {
# We don't support tagging in mercurial right now..
function testTagIconWorks() {
startSkipping # Skip test
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local POWERLEVEL9K_VCS_TAG_ICON='T'
touch "file.txt"
@ -83,7 +87,8 @@ function testTagIconWorks() {
function testTagIconInDetachedHeadState() {
startSkipping # Skip test
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local POWERLEVEL9K_VCS_TAG_ICON='T'
touch "file.txt"
@ -100,7 +105,8 @@ function testTagIconInDetachedHeadState() {
}
function testActionHintWorks() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
touch "i-am-modified.txt"
hg add i-am-modified.txt
hg commit -m "Add File" &>/dev/null
@ -119,7 +125,8 @@ function testActionHintWorks() {
}
function testShorteningCommitHashWorks() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local POWERLEVEL9K_SHOW_CHANGESET=true
local POWERLEVEL9K_CHANGESET_HASH_LENGTH='4'
@ -136,7 +143,8 @@ function testShorteningCommitHashWorks() {
}
function testShorteningCommitHashIsNotShownIfShowChangesetIsFalse() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local POWERLEVEL9K_SHOW_CHANGESET=false
local POWERLEVEL9K_CHANGESET_HASH_LENGTH='4'
@ -152,14 +160,16 @@ function testShorteningCommitHashIsNotShownIfShowChangesetIsFalse() {
}
function testMercurialIconWorks() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local POWERLEVEL9K_VCS_HG_ICON='HG-Icon'
assertEquals "%K{green} %F{black%}HG-Icon %f%F{black} default %k%F{green}%f " "$(build_left_prompt)"
}
function testBookmarkIconWorks() {
local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
local POWERLEVEL9K_VCS_BOOKMARK_ICON='B'
hg bookmark "initial"