aboutsummaryrefslogtreecommitdiff
path: root/test/segments
diff options
context:
space:
mode:
Diffstat (limited to 'test/segments')
-rwxr-xr-xtest/segments/anaconda.spec69
-rwxr-xr-xtest/segments/aws_eb_env.spec61
-rwxr-xr-xtest/segments/background_jobs.spec78
-rwxr-xr-xtest/segments/battery.spec177
-rwxr-xr-xtest/segments/command_execution_time.spec104
-rwxr-xr-xtest/segments/context.spec131
-rwxr-xr-xtest/segments/custom.spec86
-rwxr-xr-xtest/segments/detect_virt.spec83
-rwxr-xr-xtest/segments/dir.spec789
-rwxr-xr-xtest/segments/disk_usage.spec131
-rwxr-xr-xtest/segments/go_version.spec88
-rwxr-xr-xtest/segments/ip.spec231
-rwxr-xr-xtest/segments/kubecontext.spec104
-rwxr-xr-xtest/segments/laravel_version.spec72
-rwxr-xr-xtest/segments/load.spec149
-rwxr-xr-xtest/segments/newline.spec42
-rwxr-xr-xtest/segments/node_version.spec41
-rwxr-xr-xtest/segments/nodeenv.spec79
-rwxr-xr-xtest/segments/nvm.spec72
-rwxr-xr-xtest/segments/php_version.spec42
-rwxr-xr-xtest/segments/public_ip.spec222
-rwxr-xr-xtest/segments/ram.spec66
-rwxr-xr-xtest/segments/rust_version.spec51
-rwxr-xr-xtest/segments/ssh.spec80
-rwxr-xr-xtest/segments/status.spec113
-rwxr-xr-xtest/segments/swap.spec58
-rwxr-xr-xtest/segments/swift_version.spec57
-rwxr-xr-xtest/segments/symfony_version.spec117
-rwxr-xr-xtest/segments/todo.spec58
-rwxr-xr-xtest/segments/vcs-git.spec535
-rwxr-xr-xtest/segments/vcs-hg.spec220
-rwxr-xr-xtest/segments/vi_mode.spec48
32 files changed, 0 insertions, 4254 deletions
diff --git a/test/segments/anaconda.spec b/test/segments/anaconda.spec
deleted file mode 100755
index a25aed9b..00000000
--- a/test/segments/anaconda.spec
+++ /dev/null
@@ -1,69 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
-}
-
-function testAnacondaSegmentPrintsNothingIfNoAnacondaPathIsSet() {
- local POWERLEVEL9K_CUSTOM_WORLD='echo world'
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(anaconda custom_world)
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- # Unset anacona variables
- unset CONDA_ENV_PATH
- unset CONDA_PREFIX
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-}
-
-function testAnacondaSegmentWorksIfOnlyAnacondaPathIsSet() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(anaconda)
- local POWERLEVEL9K_PYTHON_ICON="icon-here"
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- CONDA_ENV_PATH=/tmp
- unset CONDA_PREFIX
-
- assertEquals "%K{004} %F{000}icon-here %F{000}(tmp) %k%F{004}%f " "$(build_left_prompt)"
-}
-
-function testAnacondaSegmentWorksIfOnlyAnacondaPrefixIsSet() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(anaconda)
- local POWERLEVEL9K_PYTHON_ICON="icon-here"
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- unset CONDA_ENV_PATH
- local CONDA_PREFIX="test"
-
- assertEquals "%K{004} %F{000}icon-here %F{000}(test) %k%F{004}%f " "$(build_left_prompt)"
-}
-
-function testAnacondaSegmentWorks() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(anaconda)
- local POWERLEVEL9K_PYTHON_ICON="icon-here"
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- local CONDA_ENV_PATH=/tmp
- local CONDA_PREFIX="test"
-
- assertEquals "%K{004} %F{000}icon-here %F{000}(tmptest) %k%F{004}%f " "$(build_left_prompt)"
-}
-
-source shunit2/shunit2 \ No newline at end of file
diff --git a/test/segments/aws_eb_env.spec b/test/segments/aws_eb_env.spec
deleted file mode 100755
index 6cd8931c..00000000
--- a/test/segments/aws_eb_env.spec
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
-}
-
-function testAwsEbEnvSegmentPrintsNothingIfNoElasticBeanstalkEnvironmentIsSet() {
- local POWERLEVEL9K_CUSTOM_WORLD='echo world'
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(aws_eb_env custom_world)
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-}
-
-function testAwsEbEnvSegmentWorksIfElasticBeanstalkEnvironmentIsSet() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(aws_eb_env)
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- mkdir -p /tmp/powerlevel9k-test/.elasticbeanstalk
- echo "test:\n environment: test" > /tmp/powerlevel9k-test/.elasticbeanstalk/config.yml
- cd /tmp/powerlevel9k-test
-
- assertEquals "%K{000} %F{002}🌱 %F{002}test %k%F{000}%f " "$(build_left_prompt)"
-
- rm -fr /tmp/powerlevel9k-test
- cd -
-}
-
-function testAwsEbEnvSegmentWorksIfElasticBeanstalkEnvironmentIsSetInParentDirectory() {
- # Skip test, because currently we cannot detect
- # if the configuration is in a parent directory
- startSkipping # Skip test
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(aws_eb_env)
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- mkdir -p /tmp/powerlevel9k-test/.elasticbeanstalk
- mkdir -p /tmp/powerlevel9k-test/1/12/123/1234/12345
- echo "test:\n environment: test" > /tmp/powerlevel9k-test/.elasticbeanstalk/config.yml
- cd /tmp/powerlevel9k-test/1/12/123/1234/12345
-
- assertEquals "%K{000} %F{002}🌱 %F{002}test %k%F{000}%f " "$(build_left_prompt)"
-
- rm -fr /tmp/powerlevel9k-test
- cd -
-}
-
-source shunit2/shunit2 \ No newline at end of file
diff --git a/test/segments/background_jobs.spec b/test/segments/background_jobs.spec
deleted file mode 100755
index 558ad1aa..00000000
--- a/test/segments/background_jobs.spec
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
-}
-
-function testBackgroundJobsSegmentPrintsNothingWithoutBackgroundJobs() {
- local POWERLEVEL9K_CUSTOM_WORLD='echo world'
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(background_jobs custom_world)
- alias jobs="nojobs 2>/dev/null"
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-
- unalias jobs
-}
-
-function testBackgroundJobsSegmentWorksWithOneBackgroundJob() {
- unset POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(background_jobs)
- jobs() {
- echo '[1] + 30444 suspended nvim xx'
- }
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{000} %F{006}⚙ %k%F{000}%f " "$(build_left_prompt)"
-
- unfunction jobs
-}
-
-function testBackgroundJobsSegmentWorksWithMultipleBackgroundJobs() {
- local POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE=false
- 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"
- echo "[3] + 31206 suspended nvim xx3"
- }
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{000} %F{006}⚙ %k%F{000}%f " "$(build_left_prompt)"
-
- unfunction jobs
-}
-
-function testBackgroundJobsSegmentWithVerboseMode() {
- local POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE=true
- 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"
- echo "[3] + 31206 suspended nvim xx3"
- }
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{000} %F{006}⚙ %F{006}3 %k%F{000}%f " "$(build_left_prompt)"
-
- unfunction jobs
-}
-
-source shunit2/shunit2 \ No newline at end of file
diff --git a/test/segments/battery.spec b/test/segments/battery.spec
deleted file mode 100755
index 39437b7f..00000000
--- a/test/segments/battery.spec
+++ /dev/null
@@ -1,177 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- P9K_HOME=$(pwd)
- ### Test specific
- # Create default folder
- FOLDER=/tmp/powerlevel9k-test
- mkdir -p "${FOLDER}"
- cd $FOLDER
-
- # Prepare folder for pmset (OSX)
- PMSET_PATH=$FOLDER/usr/bin
- mkdir -p $PMSET_PATH
- # Prepare folder for $BATTERY (Linux)
- BATTERY_PATH=$FOLDER/sys/class/power_supply
- mkdir -p $BATTERY_PATH
- mkdir -p $BATTERY_PATH/BAT0
- mkdir -p $BATTERY_PATH/BAT1
-}
-
-function tearDown() {
- # Go back to powerlevel9k folder
- cd "${P9K_HOME}"
- # Remove eventually created test-specific folder
- rm -fr "${FOLDER}" &>/dev/null
- # At least remove test folder completely
- rm -fr /tmp/powerlevel9k-test &>/dev/null
- unset PMSET_PATH
- unset BATTERY_PATH
- unset FOLDER
- unset P9K_HOME
-}
-
-# Mock Battery
-# For mocking pmset on OSX this function takes one argument (the
-# content that pmset should echo).
-# For mocking the battery on Linux this function takes two
-# arguments: $1 is the capacity; $2 the battery status.
-function makeBatterySay() {
- if [[ -z "${FOLDER}" ]]; then
- echo "Fake root path is not correctly set!"
- exit 1
- fi
- # OSX
- echo "#!/bin/sh" > $PMSET_PATH/pmset
- echo "echo \"$1\"" >> $PMSET_PATH/pmset
- chmod +x $PMSET_PATH/pmset
-
- # Linux
- local capacity="$1"
- echo "$capacity" > $BATTERY_PATH/BAT0/capacity
- echo "$capacity" > $BATTERY_PATH/BAT1/capacity
- local battery_status="$2"
- echo "$battery_status" > $BATTERY_PATH/BAT0/status
- echo "$battery_status" > $BATTERY_PATH/BAT1/status
-}
-
-function testBatterySegmentIfBatteryIsLowWhileDischargingOnOSX() {
- local OS='OSX' # Fake OSX
- makeBatterySay "Now drawing from 'Battery Power'
- -InternalBattery-0 (id=1234567) 4%; discharging; 0:05 remaining present: true"
-
- assertEquals "%K{000} %F{001}🔋 %F{001}4%% (0:05) " "$(prompt_battery left 1 false ${FOLDER})"
-}
-
-function testBatterySegmentIfBatteryIsLowWhileChargingOnOSX() {
- local OS='OSX' # Fake OSX
- makeBatterySay "Now drawing from 'Battery Power'
- -InternalBattery-0 (id=1234567) 4%; charging; 0:05 remaining present: true"
-
- assertEquals "%K{000} %F{003}🔋 %F{003}4%% (0:05) " "$(prompt_battery left 1 false ${FOLDER})"
-}
-
-function testBatterySegmentIfBatteryIsAlmostFullWhileDischargingOnOSX() {
- local OS='OSX' # Fake OSX
- makeBatterySay "Now drawing from 'Battery Power'
- -InternalBattery-0 (id=1234567) 98%; discharging; 3:57 remaining present: true"
-
- assertEquals "%K{000} %F{007}🔋 %F{007}98%% (3:57) " "$(prompt_battery left 1 false ${FOLDER})"
-}
-
-function testBatterySegmentIfBatteryIsAlmostFullWhileChargingOnOSX() {
- local OS='OSX' # Fake OSX
- makeBatterySay "Now drawing from 'Battery Power'
- -InternalBattery-0 (id=1234567) 98%; charging; 3:57 remaining present: true"
-
- assertEquals "%K{000} %F{003}🔋 %F{003}98%% (3:57) " "$(prompt_battery left 1 false ${FOLDER})"
-}
-
-function testBatterySegmentIfBatteryIsFullOnOSX() {
- local OS='OSX' # Fake OSX
- makeBatterySay "Now drawing from 'AC Power'
- -InternalBattery-0 (id=1234567) 99%; charged; 0:00 remaining present: true"
-
- assertEquals "%K{000} %F{002}🔋 %F{002}99%% " "$(prompt_battery left 1 false ${FOLDER})"
-}
-
-function testBatterySegmentIfBatteryIsCalculatingOnOSX() {
- local OS='OSX' # Fake OSX
- makeBatterySay "Now drawing from 'Battery Power'
- -InternalBattery-0 (id=1234567) 99%; discharging; (no estimate) present: true"
-
- assertEquals "%K{000} %F{007}🔋 %F{007}99%% (...) " "$(prompt_battery left 1 false ${FOLDER})"
-}
-
-function testBatterySegmentIfBatteryIsLowWhileDischargingOnLinux() {
- local OS='Linux' # Fake Linux
- makeBatterySay "4" "Discharging"
-
- assertEquals "%K{000} %F{001}🔋 %F{001}4%% " "$(prompt_battery left 1 false ${FOLDER})"
-}
-
-function testBatterySegmentIfBatteryIsLowWhileChargingOnLinux() {
- local OS='Linux' # Fake Linux
- makeBatterySay "4" "Charging"
-
- assertEquals "%K{000} %F{003}🔋 %F{003}4%% " "$(prompt_battery left 1 false ${FOLDER})"
-}
-
-function testBatterySegmentIfBatteryIsNormalWhileDischargingOnLinux() {
- local OS='Linux' # Fake Linux
- makeBatterySay "10" "Discharging"
-
- assertEquals "%K{000} %F{007}🔋 %F{007}10%% " "$(prompt_battery left 1 false ${FOLDER})"
-}
-
-function testBatterySegmentIfBatteryIsNormalWhileChargingOnLinux() {
- local OS='Linux' # Fake Linux
- makeBatterySay "10" "Charging"
-
- assertEquals "%K{000} %F{003}🔋 %F{003}10%% " "$(prompt_battery left 1 false ${FOLDER})"
-}
-
-function testBatterySegmentIfBatteryIsFullOnLinux() {
- local OS='Linux' # Fake Linux
- makeBatterySay "100" "Full"
-
- assertEquals "%K{000} %F{002}🔋 %F{002}100%% " "$(prompt_battery left 1 false ${FOLDER})"
-}
-
-function testBatterySegmentIfBatteryIsNormalWithAcpiEnabledOnLinux() {
- local OS='Linux' # Fake Linux
- makeBatterySay "50" "Discharging"
- echo "echo 'Batter 0: Discharging, 50%, 01:38:54 remaining'" > ${FOLDER}/usr/bin/acpi
- chmod +x ${FOLDER}/usr/bin/acpi
- # For running on Mac, we need to mock date :(
- [[ -f /usr/local/bin/gdate ]] && alias date=gdate
-
- assertEquals "%K{000} %F{007}🔋 %F{007}50%% (1:38) " "$(prompt_battery left 1 false ${FOLDER})"
-
- unalias date &>/dev/null
- # unaliasing date fails where it was never aliased (e.g. on Linux).
- # This causes the whole test to fail, because the return code is
- # non-zero.
- return 0
-}
-
-function testBatterySegmentIfBatteryIsCalculatingWithAcpiEnabledOnLinux() {
- local OS='Linux' # Fake Linux
- makeBatterySay "50" "Discharging"
- # Todo: Include real acpi output!
- echo "echo 'Batter 0: Discharging, 50%, rate remaining'" > ${FOLDER}/usr/bin/acpi
- chmod +x ${FOLDER}/usr/bin/acpi
-
- assertEquals "%K{000} %F{007}🔋 %F{007}50%% (...) " "$(prompt_battery left 1 false ${FOLDER})"
-}
-
-source shunit2/shunit2 \ No newline at end of file
diff --git a/test/segments/command_execution_time.spec b/test/segments/command_execution_time.spec
deleted file mode 100755
index 6d2d7ad9..00000000
--- a/test/segments/command_execution_time.spec
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
-}
-
-function testCommandExecutionTimeIsNotShownIfTimeIsBelowThreshold() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world command_execution_time)
- local POWERLEVEL9K_CUSTOM_WORLD='echo world'
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- # Override payload
- local _P9K_COMMAND_DURATION=2
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-}
-
-function testCommandExecutionTimeThresholdCouldBeChanged() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time)
- local POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=1
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- # Override payload
- local _P9K_COMMAND_DURATION=2.03
-
- assertEquals "%K{001} %F{226}Dur %F{226}2.03 %k%F{001}%f " "$(build_left_prompt)"
-}
-
-function testCommandExecutionTimeThresholdCouldBeSetToZero() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time)
- local POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=0
- local _P9K_COMMAND_DURATION=0.03
-
- assertEquals "%K{001} %F{226}Dur %F{226}0.03 %k%F{001}%f " "$(build_left_prompt)"
-}
-
-function testCommandExecutionTimePrecisionCouldBeChanged() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time)
- local POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=0
- local POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=4
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- # Override payload
- local _P9K_COMMAND_DURATION=0.0001
-
- assertEquals "%K{001} %F{226}Dur %F{226}0.0001 %k%F{001}%f " "$(build_left_prompt)"
-}
-
-function testCommandExecutionTimePrecisionCouldBeSetToZero() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time)
- local POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- # Override payload
- local _P9K_COMMAND_DURATION=23.5001
-
- assertEquals "%K{001} %F{226}Dur %F{226}23 %k%F{001}%f " "$(build_left_prompt)"
-}
-
-function testCommandExecutionTimeIsFormattedHumandReadbleForMinuteLongCommand() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time)
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- # Override payload
- local _P9K_COMMAND_DURATION=180
-
- assertEquals "%K{001} %F{226}Dur %F{226}03:00 %k%F{001}%f " "$(build_left_prompt)"
-}
-
-function testCommandExecutionTimeIsFormattedHumandReadbleForHourLongCommand() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(command_execution_time)
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- # Override payload
- local _P9K_COMMAND_DURATION=7200
-
- assertEquals "%K{001} %F{226}Dur %F{226}02:00:00 %k%F{001}%f " "$(build_left_prompt)"
-}
-
-source shunit2/shunit2 \ No newline at end of file
diff --git a/test/segments/context.spec b/test/segments/context.spec
deleted file mode 100755
index 25c355a7..00000000
--- a/test/segments/context.spec
+++ /dev/null
@@ -1,131 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
-
- # Test specific settings
- OLD_DEFAULT_USER=$DEFAULT_USER
- unset DEFAULT_USER
-
- # Fix leaked state for travis
- OLD_POWERLEVEL9K_CONTEXT_ALWAYS_SHOW=$POWERLEVEL9K_CONTEXT_ALWAYS_SHOW
- unset POWERLEVEL9K_CONTEXT_ALWAYS_SHOW
- OLD_SSH_CLIENT=$SSH_CLIENT
- unset SSH_CLIENT
- OLD_SSH_TTY=$SSH_TTY
- unset SSH_TTY
-}
-
-function tearDown() {
- # Restore old variables
- [[ -n "$OLD_DEFAULT_USER" ]] && DEFAULT_USER=$OLD_DEFAULT_USER
- unset OLD_DEFAULT_USER
-
- [[ -n "$OLD_POWERLEVEL9K_CONTEXT_ALWAYS_SHOW" ]] && POWERLEVEL9K_CONTEXT_ALWAYS_SHOW=$OLD_POWERLEVEL9K_CONTEXT_ALWAYS_SHOW
- unset OLD_POWERLEVEL9K_CONTEXT_ALWAYS_SHOW
-
- [[ -n "$OLD_SSH_CLIENT" ]] && SSH_CLIENT=$OLD_SSH_CLIENT
- unset OLD_SSH_CLIENT
-
- [[ -n "$OLD_SSH_TTY" ]] && SSH_TTY=$OLD_SSH_TTY
- unset OLD_SSH_TTY
-
- return 0
-}
-
-function testContextSegmentDoesNotGetRenderedWithDefaultUser() {
- local DEFAULT_USER=$(whoami)
- local POWERLEVEL9K_CUSTOM_WORLD='echo world'
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context custom_world)
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-}
-
-function testContextSegmentDoesGetRenderedWhenSshConnectionIsOpen() {
- function sudo() {
- return 0
- }
- local SSH_CLIENT="putty"
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context)
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{000} %F{003}%n@%m %k%F{000}%f " "$(build_left_prompt)"
-
- unfunction sudo
-}
-
-function testContextSegmentWithForeignUser() {
- function sudo() {
- return 0
- }
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context)
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{000} %F{003}%n@%m %k%F{000}%f " "$(build_left_prompt)"
-
- unfunction sudo
-}
-
-# TODO: How to test root?
-function testContextSegmentWithRootUser() {
- startSkipping # Skip test
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context)
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{000} %F{003}%n@%m %k%F{000}%f " "$(build_left_prompt)"
-}
-
-function testOverridingContextTemplate() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context)
- local POWERLEVEL9K_CONTEXT_TEMPLATE=xx
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{000} %F{003}xx %k%F{000}%f " "$(build_left_prompt)"
-}
-
-function testContextSegmentIsShownIfDefaultUserIsSetWhenForced() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context)
- local POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true
- local DEFAULT_USER=$(whoami)
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{000} %F{003}%n@%m %k%F{000}%f " "$(build_left_prompt)"
-}
-
-function testContextSegmentIsShownIfForced() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context)
- local POWERLEVEL9K_ALWAYS_SHOW_USER=true
- local DEFAULT_USER=$(whoami)
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{000} %F{003}$(whoami) %k%F{000}%f " "$(build_left_prompt)"
-}
-
-source shunit2/shunit2 \ No newline at end of file
diff --git a/test/segments/custom.spec b/test/segments/custom.spec
deleted file mode 100755
index 7aef02b0..00000000
--- a/test/segments/custom.spec
+++ /dev/null
@@ -1,86 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
-}
-
-function testCustomDirectOutputSegment() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world)
- local POWERLEVEL9K_CUSTOM_WORLD="echo world"
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-}
-
-function testCustomClosureSegment() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world)
- function p9k_hello_world() {
- echo "world"
- }
- local POWERLEVEL9K_CUSTOM_WORLD='p9k_hello_world'
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-}
-
-function testSettingBackgroundForCustomSegment() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world)
- local POWERLEVEL9K_CUSTOM_WORLD="echo world"
- local POWERLEVEL9K_CUSTOM_WORLD_BACKGROUND="yellow"
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{003} %F{000}world %k%F{003}%f " "$(build_left_prompt)"
-}
-
-function testSettingForegroundForCustomSegment() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world)
- local POWERLEVEL9K_CUSTOM_WORLD="echo world"
- local POWERLEVEL9K_CUSTOM_WORLD_FOREGROUND="red"
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{001}world %k%F{007}%f " "$(build_left_prompt)"
-}
-
-function testSettingVisualIdentifierForCustomSegment() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world)
- local POWERLEVEL9K_CUSTOM_WORLD="echo world"
- local POWERLEVEL9K_CUSTOM_WORLD_ICON="hw"
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{000}hw %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-}
-
-function testSettingVisualIdentifierForegroundColorForCustomSegment() {
- 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"
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{001}hw %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-}
-
-source shunit2/shunit2 \ No newline at end of file
diff --git a/test/segments/detect_virt.spec b/test/segments/detect_virt.spec
deleted file mode 100755
index 910f52eb..00000000
--- a/test/segments/detect_virt.spec
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-}
-
-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"
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-
- unalias systemd-detect-virt
-}
-
-function testDetectVirtSegmentIfSystemdReturnsPlainName() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(detect_virt)
- alias systemd-detect-virt="echo 'xxx'"
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{000} %F{003}xxx %k%F{000}%f " "$(build_left_prompt)"
-
- unalias systemd-detect-virt
-}
-
-function testDetectVirtSegmentIfRootFsIsOnExpectedInode() {
- 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"..
- alias systemd-detect-virt="echo 'none'"
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- # The original command in the implementation is "ls -di / | grep -o 2",
- # which translates to: Show the inode number of "/" and test if it is "2".
- alias ls="echo '2'"
-
- assertEquals "%K{000} %F{003}none %k%F{000}%f " "$(build_left_prompt)"
-
- unalias ls
- unalias systemd-detect-virt
-}
-
-function testDetectVirtSegmentIfRootFsIsNotOnExpectedInode() {
- 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"..
- alias systemd-detect-virt="echo 'none'"
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- # The original command in the implementation is "ls -di / | grep -o 2",
- # which translates to: Show the inode number of "/" and test if it is "2".
- alias ls="echo '3'"
-
- assertEquals "%K{000} %F{003}chroot %k%F{000}%f " "$(build_left_prompt)"
-
- unalias ls
- unalias systemd-detect-virt
-}
-
-source shunit2/shunit2 \ No newline at end of file
diff --git a/test/segments/dir.spec b/test/segments/dir.spec
deleted file mode 100755
index d75ca42f..00000000
--- a/test/segments/dir.spec
+++ /dev/null
@@ -1,789 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
-
- P9K_HOME="${PWD}"
-}
-
-function tearDown() {
- unset P9K_HOME
-}
-
-function testDirPathAbsoluteWorks() {
- 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 ~
-
- # 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 -
-}
-
-function testTruncateFoldersWorks() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
- 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
-
- assertEquals "%K{004} %F{000}…/12345678/123456789 %k%F{004}%f " "$(build_left_prompt)"
-
- cd -
- rm -fr /tmp/powerlevel9k-test
-}
-
-function testTruncateFolderWithHomeDirWorks() {
- 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 ~
- local FOLDER="powerlevel9k-test-${RANDOM}"
- mkdir -p $FOLDER
- cd $FOLDER
- # Switch back to home folder as this causes the problem.
- cd ..
-
- assertEquals "%K{004} %F{000}~ %k%F{004}%f " "$(build_left_prompt)"
-
- rmdir $FOLDER
- cd ${CURRENT_DIR}
-}
-
-function testTruncateMiddleWorks() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
- 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
-
- 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
-}
-
-function testTruncationFromRightWorks() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
- 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
-
- 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
-}
-
-function testTruncateToLastWorks() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
- 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
-
- assertEquals "%K{004} %F{000}123456789 %k%F{004}%f " "$(build_left_prompt)"
-
- cd -
- rm -fr /tmp/powerlevel9k-test
-}
-
-function testTruncateToFirstAndLastWorks() {
- 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
-
- local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789
- mkdir -p $FOLDER
- cd $FOLDER
-
- assertEquals "%K{004} %F{000}/tmp/powerlevel9k-test/…/…/…/…/…/…/…/12345678/123456789 %k%F{004}%f " "$(build_left_prompt)"
-
- cd -
- rm -fr /tmp/powerlevel9k-test
-}
-
-function testTruncateAbsoluteWorks() {
- 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
-
- local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789
- mkdir -p $FOLDER
- cd $FOLDER
-
- assertEquals "%K{004} %F{000}…89 %k%F{004}%f " "$(build_left_prompt)"
-
- cd -
- rm -fr /tmp/powerlevel9k-test
-}
-
-function testTruncationFromRightWithEmptyDelimiter() {
- 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
-
- local FOLDER=/tmp/powerlevel9k-test/1/12/123/1234/12345/123456/1234567/12345678/123456789
- mkdir -p $FOLDER
- cd $FOLDER
-
- 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
-}
-
-function testTruncateWithFolderMarkerWorks() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- 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
- # Setup folder marker
- touch $BASEFOLDER/1/12/.shorten_folder_marker
- cd $FOLDER
- assertEquals "%K{004} %F{000}/…/12/123/1234/12345/123456/1234567 %k%F{004}%f " "$(build_left_prompt)"
-
- cd -
- rm -fr $BASEFOLDER
-}
-
-function testTruncateWithFolderMarkerWithChangedFolderMarker() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
- 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
- # Setup folder marker
- touch $BASEFOLDER/1/12/.xxx
- cd $FOLDER
- assertEquals "%K{004} %F{000}/…/12/123/1234/12345/123456/1234567 %k%F{004}%f " "$(build_left_prompt)"
-
- cd -
- rm -fr $BASEFOLDER
-}
-
-function testTruncateWithPackageNameWorks() {
- local p9kFolder=$(pwd)
- local BASEFOLDER=/tmp/powerlevel9k-test
- local FOLDER=$BASEFOLDER/1/12/123/1234/12345/123456/1234567/12345678/123456789
- mkdir -p $FOLDER
-
- cd /tmp/powerlevel9k-test
- echo '
-{
- "name": "My_Package"
-}
-' > package.json
- # Unfortunately: The main folder must be a git repo..
- git init &>/dev/null
-
- # Go back to deeper folder
- cd "${FOLDER}"
-
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
- local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
- local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name'
-
- # 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
-}
-
-function testTruncateWithPackageNameIfRepoIsSymlinkedInsideDeepFolder() {
- local p9kFolder=$(pwd)
- local BASEFOLDER=/tmp/powerlevel9k-test
- local FOLDER=$BASEFOLDER/1/12/123/1234/12345/123456/1234567/12345678/123456789
- mkdir -p $FOLDER
- cd $FOLDER
-
- # Unfortunately: The main folder must be a git repo..
- git init &>/dev/null
-
- echo '
-{
- "name": "My_Package"
-}
-' > package.json
-
- # Create a subdir inside the repo
- mkdir -p asdfasdf/qwerqwer
-
- cd $BASEFOLDER
- ln -s ${FOLDER} linked-repo
-
- # Go to deep folder inside linked repo
- cd linked-repo/asdfasdf/qwerqwer
-
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
- local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
- local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name'
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{004} %F{000}My_Package/as…/qwerqwer %k%F{004}%f " "$(build_left_prompt)"
-
- # Go back
- cd $p9kFolder
- rm -fr $BASEFOLDER
-}
-
-function testTruncateWithPackageNameIfRepoIsSymlinkedInsideGitDir() {
- local p9kFolder=$(pwd)
- local BASEFOLDER=/tmp/powerlevel9k-test
- local FOLDER=$BASEFOLDER/1/12/123/1234/12345/123456/1234567/12345678/123456789
- mkdir -p $FOLDER
- cd $FOLDER
-
- # Unfortunately: The main folder must be a git repo..
- git init &>/dev/null
-
- echo '
-{
- "name": "My_Package"
-}
-' > package.json
-
- cd $BASEFOLDER
- ln -s ${FOLDER} linked-repo
-
- cd linked-repo/.git/refs/heads
-
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
- local POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
- local POWERLEVEL9K_SHORTEN_STRATEGY='truncate_with_package_name'
-
- # 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
-}
-
-function testHomeFolderDetectionWorks() {
- 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{004} %F{000}home-icon %F{000}~ %k%F{004}%f " "$(build_left_prompt)"
-
- cd -
-}
-
-function testHomeSubfolderDetectionWorks() {
- 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
-
- local FOLDER=~/powerlevel9k-test
- mkdir $FOLDER
- cd $FOLDER
- assertEquals "%K{004} %F{000}sub-icon %F{000}~/powerlevel9k-test %k%F{004}%f " "$(build_left_prompt)"
-
- cd -
- rm -fr $FOLDER
-}
-
-function testOtherFolderDetectionWorks() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- 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
- assertEquals "%K{004} %F{000}folder-icon %F{000}/tmp/powerlevel9k-test %k%F{004}%f " "$(build_left_prompt)"
-
- cd -
- rm -fr $FOLDER
-}
-
-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
-
- assertEquals "%K{004} %F{000}xXxtmpxXxpowerlevel9k-testxXx1xXx2 %k%F{004}%f " "$(build_left_prompt)"
-
- cd -
- rm -fr /tmp/powerlevel9k-test
-}
-
-function testHomeFolderAbbreviation() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
- local dir=$PWD
-
- cd ~/
- # default
- 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
- 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
- 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
- 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() {
- 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{004} %F{000}folder-icon %F{000}tmp %k%F{004}%f " "$(build_left_prompt)"
-
- cd -
-}
-
-function testOmittingFirstCharacterWorksWithChangingPathSeparator() {
- 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{004} %F{000}folder-icon %F{000}tmpxXxpowerlevel9k-testxXx1xXx2 %k%F{004}%f " "$(build_left_prompt)"
-
- cd -
- rm -fr /tmp/powerlevel9k-test
-}
-
-# This test makes it obvious that combining a truncation strategy
-# that cuts off folders from the left and omitting the the first
-# character does not make much sense. The truncation strategy
-# comes first, prints an ellipsis and that gets then cut off by
-# POWERLEVEL9K_DIR_OMIT_FIRST_CHARACTER..
-# But it does more sense in combination with other truncation
-# strategies.
-function testOmittingFirstCharacterWorksWithChangingPathSeparatorAndDefaultTruncation() {
- 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{004} %F{000}xXx1xXx2 %k%F{004}%f " "$(build_left_prompt)"
-
- cd -
- rm -fr /tmp/powerlevel9k-test
-}
-
-function testOmittingFirstCharacterWorksWithChangingPathSeparatorAndMiddleTruncation() {
- 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{004} %F{000}tmpxXxpo…stxXx1xXx2 %k%F{004}%f " "$(build_left_prompt)"
-
- cd -
- rm -fr /tmp/powerlevel9k-test
-}
-
-function testOmittingFirstCharacterWorksWithChangingPathSeparatorAndRightTruncation() {
- 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{004} %F{000}tmpxXxpo…xXx1xXx2 %k%F{004}%f " "$(build_left_prompt)"
-
- cd -
- rm -fr /tmp/powerlevel9k-test
-}
-
-function testTruncateToUniqueWorks() {
- 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{004} %F{000}txXxpxXxalxXxde %k%F{004}%f " "$(build_left_prompt)"
-
- cd -
- rm -fr /tmp/powerlevel9k-test
-}
-
-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{004} %F{000}%B~%b %k%F{004}%f " "$(build_left_prompt)"
-
- cd -
-}
-
-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
-
- assertEquals "%K{004} %F{000}~/%Bpowerlevel9k-test%b %k%F{004}%f " "$(build_left_prompt)"
-
- cd -
- rm -fr ~/powerlevel9k-test
-}
-
-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{004} %F{000}%B/%b %k%F{004}%f " "$(build_left_prompt)"
-
- cd -
-}
-
-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{004} %F{000}/%Btmp%b %k%F{004}%f " "$(build_left_prompt)"
-
- cd -
-}
-
-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
-
- assertEquals "%K{004} %F{000}/tmp/%Bpowerlevel9k-test%b %k%F{004}%f " "$(build_left_prompt)"
-
- cd -
- rm -fr /tmp/powerlevel9k-test
-}
-
-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{004} %F{000}%F{red}~ %k%F{004}%f " "$(build_left_prompt)"
-
- cd -
-}
-
-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
-
- assertEquals "%K{004} %F{000}~/%F{red}powerlevel9k-test %k%F{004}%f " "$(build_left_prompt)"
-
- cd -
- rm -fr ~/powerlevel9k-test
-}
-
-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{004} %F{000}%F{red}/ %k%F{004}%f " "$(build_left_prompt)"
-
- cd -
-}
-
-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{004} %F{000}/%F{red}tmp %k%F{004}%f " "$(build_left_prompt)"
-
- cd -
-}
-
-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
-
- assertEquals "%K{004} %F{000}/tmp/%F{red}powerlevel9k-test %k%F{004}%f " "$(build_left_prompt)"
-
- cd -
- rm -fr /tmp/powerlevel9k-test
-}
-
-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
-
- assertEquals "%K{004} %F{000}~%F{red}/%F{black}powerlevel9k-test %k%F{004}%f " "$(build_left_prompt)"
-
- cd -
- rm -fr ~/powerlevel9k-test
-}
-
-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
-
- 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
-}
-
-function testDirHomeTruncationWorksOnlyAtTheBeginning() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir)
-
- local FOLDER=/tmp/p9ktest
- local SAVED_HOME="${HOME}"
- HOME="/p9ktest"
-
- mkdir -p $FOLDER
- # Setup folder marker
- cd $FOLDER
- assertEquals "%K{004} %F{000}/tmp/p9ktest %k%F{004}%f " "$(build_left_prompt)"
-
- cd -
- rm -fr $FOLDER
- HOME="${SAVED_HOME}"
-}
-
-source shunit2/shunit2
diff --git a/test/segments/disk_usage.spec b/test/segments/disk_usage.spec
deleted file mode 100755
index 7858da4f..00000000
--- a/test/segments/disk_usage.spec
+++ /dev/null
@@ -1,131 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
-
- # Test specific
- P9K_HOME=$(pwd)
- FOLDER=/tmp/powerlevel9k-test
- mkdir -p $FOLDER
- cd $FOLDER
-}
-
-function tearDown() {
- # Go back to powerlevel9k folder
- cd "${P9K_HOME}"
- # Remove eventually created test-specific folder
- rm -fr "${FOLDER}"
- # At least remove test folder completely
- rm -fr /tmp/powerlevel9k-test
- unset FOLDER
- unset P9K_HOME
-
- # Remove IP cache file
- rm -f ${POWERLEVEL9K_PUBLIC_IP_FILE}
-}
-
-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% /"
- }
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{001} %F{007}hdd %F{007}97%% %k%F{001}%f " "$(build_left_prompt)"
-
- unfunction df
-}
-
-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% /"
- }
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{003} %F{000}hdd %F{000}94%% %k%F{003}%f " "$(build_left_prompt)"
-
- unfunction df
-}
-
-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% /"
- }
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{000} %F{003}hdd %F{003}4%% %k%F{000}%f " "$(build_left_prompt)"
-
- unfunction df
-}
-
-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_DISK_USAGE_ONLY_WARNING=true
- local POWERLEVEL9K_CUSTOM_WORLD='echo world'
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-
- unfunction df
-}
-
-function testDiskUsageSegmentWarningLevelCouldBeAdjusted() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(disk_usage)
- local POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL=10
- df() {
- echo "Filesystem 1K-blocks Used Available Use% Mounted on
-/dev/disk1 487219288 471466944 15496344 11% /"
- }
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{003} %F{000}hdd %F{000}11%% %k%F{003}%f " "$(build_left_prompt)"
-
- unfunction df
-}
-
-function testDiskUsageSegmentCriticalLevelCouldBeAdjusted() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(disk_usage)
- local POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL=5
- local POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL=10
- df() {
- echo "Filesystem 1K-blocks Used Available Use% Mounted on
-/dev/disk1 487219288 471466944 15496344 11% /"
- }
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{001} %F{007}hdd %F{007}11%% %k%F{001}%f " "$(build_left_prompt)"
-
- unfunction df
-}
-
-source shunit2/shunit2 \ No newline at end of file
diff --git a/test/segments/go_version.spec b/test/segments/go_version.spec
deleted file mode 100755
index 3ac51eaf..00000000
--- a/test/segments/go_version.spec
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
-}
-
-function mockGo() {
- case "$1" in
- 'version')
- echo 'go version go1.5.3 darwin/amd64'
- ;;
- 'env')
- echo "$HOME/go"
- ;;
- esac
-}
-
-function mockGoEmptyGopath() {
- case "$1" in
- 'version')
- echo 'go version go1.5.3 darwin/amd64'
- ;;
- 'env')
- echo ""
- ;;
- esac
-}
-
-function testGo() {
- alias go=mockGo
- local POWERLEVEL9K_GO_ICON=""
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(go_version)
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- local PWD="$HOME/go/src/github.com/bhilburn/powerlevel9k"
-
- assertEquals "%K{002} %F{255} %F{255}go1.5.3 %k%F{002}%f " "$(build_left_prompt)"
-
- unalias go
-}
-
-function testGoSegmentPrintsNothingIfEmptyGopath() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world go_version)
- local POWERLEVEL9K_CUSTOM_WORLD='echo world'
- alias go=mockGoEmptyGopath
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-}
-
-function testGoSegmentPrintsNothingIfNotInGopath() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world go_version)
- local POWERLEVEL9K_CUSTOM_WORLD='echo world'
- alias go=mockGo
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-}
-
-function testGoSegmentPrintsNothingIfGoIsNotAvailable() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world go_version)
- local POWERLEVEL9K_CUSTOM_WORLD='echo world'
- alias go=noGo
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-
- unalias go
-}
-
-source shunit2/shunit2
diff --git a/test/segments/ip.spec b/test/segments/ip.spec
deleted file mode 100755
index cd9f727d..00000000
--- a/test/segments/ip.spec
+++ /dev/null
@@ -1,231 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
-}
-
-function testIpSegmentPrintsNothingOnOsxIfNotConnected() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip custom_world)
- alias networksetup='echo "not connected"'
- local POWERLEVEL9K_CUSTOM_WORLD='echo world'
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
- local OS="OSX" # Fake OSX
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-
- unalias networksetup
-}
-
-function testIpSegmentPrintsNothingOnLinuxIfNotConnected() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip custom_world)
- alias ip='echo "not connected"'
- local POWERLEVEL9K_CUSTOM_WORLD='echo world'
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
- local OS="Linux" # Fake Linux
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-
- unalias ip
-}
-
-function testIpSegmentWorksOnOsxWithNoInterfaceSpecified() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip)
- alias networksetup="echo 'An asterisk (*) denotes that a network service is disabled.
-(1) Ethernet
-(Hardware Port: Ethernet, Device: en0)
-
-(2) FireWire
-(Hardware Port: FireWire, Device: fw0)
-
-(3) Wi-Fi
-(Hardware Port: Wi-Fi, Device: en1)
-
-(4) Bluetooth PAN
-(Hardware Port: Bluetooth PAN, Device: en3)
-
-(5) Thunderbolt Bridge
-(Hardware Port: Thunderbolt Bridge, Device: bridge0)
-
-(6) Apple USB Ethernet Adapter
-(Hardware Port: Apple USB Ethernet Adapter, Device: en4)
-'"
-
- alias ipconfig="_(){ echo '1.2.3.4'; };_"
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
- local OS='OSX' # Fake OSX
-
- assertEquals "%K{006} %F{000}IP %F{000}1.2.3.4 %k%F{006}%f " "$(build_left_prompt)"
-
- unalias ipconfig
- unalias networksetup
-}
-
-# There could be more than one confiured network interfaces.
-# `networksetup -listnetworkserviceorder` lists the interfaces
-# in hierarchical order, but from outside this is not obvious
-# (implementation detail). So we need a test for this case.
-function testIpSegmentWorksOnOsxWithMultipleInterfacesSpecified() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip)
- alias networksetup="echo 'An asterisk (*) denotes that a network service is disabled.
-(1) Ethernet
-(Hardware Port: Ethernet, Device: en0)
-
-(2) FireWire
-(Hardware Port: FireWire, Device: fw0)
-
-(3) Wi-Fi
-(Hardware Port: Wi-Fi, Device: en1)
-
-(4) Bluetooth PAN
-(Hardware Port: Bluetooth PAN, Device: en3)
-
-(5) Thunderbolt Bridge
-(Hardware Port: Thunderbolt Bridge, Device: bridge0)
-
-(6) Apple USB Ethernet Adapter
-(Hardware Port: Apple USB Ethernet Adapter, Device: en4)
-'"
-
- # Return a unique IP address for every interface
- ipconfig() {
- case "${2}" {
- en0)
- echo 1.2.3.4
- ;;
- fw0)
- echo 2.3.4.5
- ;;
- en1)
- echo 3.4.5.6
- ;;
- en3)
- echo 4.5.6.7
- ;;
- }
- }
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
- local OS='OSX' # Fake OSX
-
- assertEquals "%K{006} %F{000}IP %F{000}1.2.3.4 %k%F{006}%f " "$(build_left_prompt)"
-
- unfunction ipconfig
- unalias networksetup
-}
-
-function testIpSegmentWorksOnOsxWithInterfaceSpecified() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip)
- local POWERLEVEL9K_IP_INTERFACE='xxx'
- alias ipconfig="_(){ echo '1.2.3.4'; };_"
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
- local OS='OSX' # Fake OSX
-
- assertEquals "%K{006} %F{000}IP %F{000}1.2.3.4 %k%F{006}%f " "$(build_left_prompt)"
-
- unalias ipconfig
-}
-
-function testIpSegmentWorksOnLinuxWithNoInterfaceSpecified() {
- setopt aliases
- local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip)
- # That command is harder to test, as it is used at first
- # to get all relevant network interfaces and then for
- # getting the configuration of that segment..
- ip(){
- if [[ "$*" == 'link ls up' ]]; then
- echo "1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default
- link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
-2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
- link/ether 08:00:27:7e:84:45 brd ff:ff:ff:ff:ff:ff";
- fi
-
- if [[ "$*" == '-4 a show eth0' ]]; then
- echo '2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
- inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0
- valid_lft forever preferred_lft forever';
- fi
- }
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
- local OS='Linux' # Fake Linux
-
- assertEquals "%K{006} %F{000}IP %F{000}10.0.2.15 %k%F{006}%f " "$(build_left_prompt)"
-
- unfunction ip
-}
-
-function testIpSegmentWorksOnLinuxWithMultipleInterfacesSpecified() {
- setopt aliases
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip)
- # That command is harder to test, as it is used at first
- # to get all relevant network interfaces and then for
- # getting the configuration of that segment..
- ip(){
- if [[ "$*" == 'link ls up' ]]; then
- echo "1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default
- link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
-2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
- link/ether 08:00:27:7e:84:45 brd ff:ff:ff:ff:ff:ff
-3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
- link/ether 08:00:27:7e:84:45 brd ff:ff:ff:ff:ff:ff
-4: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
- link/ether 08:00:27:7e:84:45 brd ff:ff:ff:ff:ff:ff";
- fi
-
- if [[ "$*" == '-4 a show eth1' ]]; then
- echo '3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
- inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0
- valid_lft forever preferred_lft forever';
- fi
- }
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
- local OS='Linux' # Fake Linux
-
- assertEquals "%K{006} %F{000}IP %F{000}10.0.2.15 %k%F{006}%f " "$(build_left_prompt)"
-
- unfunction ip
-}
-
-function testIpSegmentWorksOnLinuxWithInterfaceSpecified() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ip)
- local POWERLEVEL9K_IP_INTERFACE='xxx'
- ip(){
- echo '2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
-inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0
- valid_lft forever preferred_lft forever';
- }
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
- local OS='Linux' # Fake Linux
-
- assertEquals "%K{006} %F{000}IP %F{000}10.0.2.15 %k%F{006}%f " "$(build_left_prompt)"
-
- unfunction ip
-}
-
-source shunit2/shunit2 \ No newline at end of file
diff --git a/test/segments/kubecontext.spec b/test/segments/kubecontext.spec
deleted file mode 100755
index 74b05b04..00000000
--- a/test/segments/kubecontext.spec
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
-}
-
-function mockKubectl() {
- case "$1" in
- 'version')
- echo 'non-empty text'
- ;;
- 'config')
- case "$2" in
- 'view')
- case "$3" in
- '-o=jsonpath={.current-context}')
- echo 'minikube'
- ;;
- '-o=jsonpath={.contexts'*)
- echo ''
- ;;
- *)
- echo "Mock value missed"
- exit 1
- ;;
- esac
- ;;
- esac
- ;;
- esac
-}
-
-function mockKubectlOtherNamespace() {
- case "$1" in
- 'version')
- echo 'non-empty text'
- ;;
- 'config')
- case "$2" in
- 'view')
- case "$3" in
- # Get Current Context
- '-o=jsonpath={.current-context}')
- echo 'minikube'
- ;;
- # Get current namespace
- '-o=jsonpath={.contexts'*)
- echo 'kube-system'
- ;;
- *)
- echo "Mock value missed"
- exit 1
- ;;
- esac
- ;;
- esac
- ;;
- esac
-}
-
-function testKubeContext() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(kubecontext)
- alias kubectl=mockKubectl
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{005} %F{007}⎈ %F{007}minikube/default %k%F{005}%f " "$(build_left_prompt)"
-
- unalias kubectl
-}
-function testKubeContextOtherNamespace() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(kubecontext)
- alias kubectl=mockKubectlOtherNamespace
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{005} %F{007}⎈ %F{007}minikube/kube-system %k%F{005}%f " "$(build_left_prompt)"
-
- unalias kubectl
-}
-function testKubeContextPrintsNothingIfKubectlNotAvailable() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world kubecontext)
- local POWERLEVEL9K_CUSTOM_WORLD='echo world'
- alias kubectl=noKubectl
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-
- unalias kubectl
-}
-
-source shunit2/shunit2
diff --git a/test/segments/laravel_version.spec b/test/segments/laravel_version.spec
deleted file mode 100755
index 499a894d..00000000
--- a/test/segments/laravel_version.spec
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
-}
-
-function mockLaravelVersion() {
- case "$1" in
- "artisan")
- # artisan --version follows the format Laravel Framework <version>
- echo "Laravel Framework 5.4.23"
- ;;
- default)
- esac
-}
-
-function mockNoLaravelVersion() {
- # When php can't find a file it will output a message
- echo "Could not open input file: artisan"
- return 0
-}
-
-function testLaravelVersionSegment() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(laravel_version)
- local POWERLEVEL9K_LARAVEL_ICON='x'
- alias php=mockLaravelVersion
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{009} %F{007}x %F{007}5.4.23 %k%F{009}%f " "$(build_left_prompt)"
-
- unalias php
-}
-
-function testLaravelVersionSegmentIfArtisanIsNotAvailable() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world laravel_version)
- local POWERLEVEL9K_CUSTOM_WORLD='echo world'
- local POWERLEVEL9K_LARAVEL_ICON='x'
- alias php=mockNoLaravelVersion
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-
- unalias php
-}
-
-function testLaravelVersionSegmentPrintsNothingIfPhpIsNotAvailable() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world laravel_version)
- local POWERLEVEL9K_CUSTOM_WORLD='echo world'
- local POWERLEVEL9K_LARAVEL_ICON='x'
- alias php=noPhp
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-
- unalias php
-}
-
-source shunit2/shunit2
diff --git a/test/segments/load.spec b/test/segments/load.spec
deleted file mode 100755
index 5867b419..00000000
--- a/test/segments/load.spec
+++ /dev/null
@@ -1,149 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
-
- P9K_HOME=$(pwd)
- ### Test specific
- # Create default folder and git init it.
- FOLDER=/tmp/powerlevel9k-test/load-test
- mkdir -p "${FOLDER}"
- cd $FOLDER
-}
-
-function tearDown() {
- # Go back to powerlevel9k folder
- cd "${P9K_HOME}"
- # Remove eventually created test-specific folder
- rm -fr "${FOLDER}"
- # At least remove test folder completely
- rm -fr /tmp/powerlevel9k-test
-}
-
-function testLoadSegmentWorksOnOsx() {
- sysctl() {
- if [[ "$*" == 'vm.loadavg' ]]; then
- echo "vm.loadavg: { 1,38 1,45 2,16 }";
- fi
-
- if [[ "$*" == '-n hw.logicalcpu' ]]; then
- echo "4";
- fi
- }
-
- local POWERLEVEL9K_LOAD_WHICH=1
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
- local OS="OSX" # Fake OSX
-
- assertEquals "%K{002} %F{000}L %F{000}1.38 " "$(prompt_load left 1 false ${FOLDER})"
-
- unfunction sysctl
-}
-
-function testLoadSegmentWorksOnBsd() {
- sysctl() {
- if [[ "$*" == 'vm.loadavg' ]]; then
- echo "vm.loadavg: { 1,38 1,45 2,16 }";
- fi
-
- if [[ "$*" == '-n hw.ncpu' ]]; then
- echo "4";
- fi
- }
-
- local POWERLEVEL9K_LOAD_WHICH=1
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
- local OS="BSD" # Fake BSD
-
- assertEquals "%K{002} %F{000}L %F{000}1.38 " "$(prompt_load left 1 false ${FOLDER})"
-
- unfunction sysctl
-}
-
-function testLoadSegmentWorksOnLinux() {
- # Prepare loadavg
- mkdir proc
- echo "1.38 0.01 0.05 1/87 8641" > proc/loadavg
-
- alias nproc="echo 4"
- local POWERLEVEL9K_LOAD_WHICH=1
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
- local OS="Linux" # Fake Linux
-
- assertEquals "%K{002} %F{000}L %F{000}1.38 " "$(prompt_load left 1 false ${FOLDER})"
-
- unalias nproc
-}
-
-# Test normal state. This test is not OS specific.
-# We test it as the Linux version, but that
-# does not matter here.
-function testLoadSegmentNormalState() {
- # Prepare loadavg
- mkdir proc
- echo "1.00 0.01 0.05 1/87 8641" > proc/loadavg
-
- alias nproc="echo 4"
- local POWERLEVEL9K_LOAD_WHICH=1
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
- local OS="Linux" # Fake Linux
-
- assertEquals "%K{002} %F{000}L %F{000}1.00 " "$(prompt_load left 1 false ${FOLDER})"
-
- unalias nproc
-}
-
-# Test warning state. This test is not OS specific.
-# We test it as the Linux version, but that
-# does not matter here.
-function testLoadSegmentWarningState() {
- # Prepare loadavg
- mkdir proc
- echo "2.01 0.01 0.05 1/87 8641" > proc/loadavg
-
- alias nproc="echo 4"
- local POWERLEVEL9K_LOAD_WHICH=1
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
- local OS="Linux" # Fake Linux
-
- assertEquals "%K{003} %F{000}L %F{000}2.01 " "$(prompt_load left 1 false ${FOLDER})"
-
- unalias nproc
-}
-
-# Test critical state. This test is not OS specific.
-# We test it as the Linux version, but that
-# does not matter here.
-function testLoadSegmentCriticalState() {
- # Prepare loadavg
- mkdir proc
- echo "2.81 0.01 0.05 1/87 8641" > proc/loadavg
-
- alias nproc="echo 4"
- local POWERLEVEL9K_LOAD_WHICH=1
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
- local OS="Linux" # Fake Linux
-
- assertEquals "%K{001} %F{000}L %F{000}2.81 " "$(prompt_load left 1 false ${FOLDER})"
-
- unalias nproc
-}
-
-source shunit2/shunit2 \ No newline at end of file
diff --git a/test/segments/newline.spec b/test/segments/newline.spec
deleted file mode 100755
index 7cd00a89..00000000
--- a/test/segments/newline.spec
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
-
- P9K_HOME=$(pwd)
- ### Test specific
-}
-
-function testNewlineDoesNotCreateExtraSegmentSeparator() {
- local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
- local POWERLEVEL9K_CUSTOM_WORLD2="echo world2"
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1 newline newline newline custom_world2)
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
- local OS="OSX" # Fake OSX
-
- local newline=$'\n'
-
- assertEquals "%K{007} %F{000}world1 %k%F{007}%f${newline}%k%f${newline}%k%f${newline}%K{007} %F{000}world2 %k%F{007}%f " "$(build_left_prompt)"
-}
-
-function testNewlineMakesPreviousSegmentEndWell() {
- local POWERLEVEL9K_CUSTOM_WORLD1="echo world1"
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world1 newline)
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
- local OS="OSX" # Fake OSX
-
- local newline=$'\n'
-
- assertEquals "%K{007} %F{000}world1 %k%F{007}%f${newline}%k%F{none}%f " "$(build_left_prompt)"
-}
-
-source shunit2/shunit2 \ No newline at end of file
diff --git a/test/segments/node_version.spec b/test/segments/node_version.spec
deleted file mode 100755
index 764bfda2..00000000
--- a/test/segments/node_version.spec
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
-}
-
-function testNodeVersionSegmentPrintsNothingWithoutNode() {
- 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"
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-
- unalias node
-}
-
-function testNodeVersionSegmentWorks() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(node_version)
- node() {
- echo "v1.2.3"
- }
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{002} %F{007}⬢ %F{007}1.2.3 %k%F{002}%f " "$(build_left_prompt)"
-
- unfunction node
-}
-
-source shunit2/shunit2 \ No newline at end of file
diff --git a/test/segments/nodeenv.spec b/test/segments/nodeenv.spec
deleted file mode 100755
index 92de81f5..00000000
--- a/test/segments/nodeenv.spec
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
-
- # Test specfic
- # unset all possible user specified variables
- unset NODE_VIRTUAL_ENV_DISABLE_PROMPT
- unset NODE_VIRTUAL_ENV
-}
-
-function testNodeenvSegmentPrintsNothingWithoutNode() {
- 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"
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-
- unalias node
-}
-
-function testNodeenvSegmentPrintsNothingIfNodeVirtualEnvIsNotSet() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nodeenv custom_world)
- local POWERLEVEL9K_CUSTOM_WORLD='echo world'
- node() {
- echo "v1.2.3"
- }
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-
- unfunction node
-}
-
-function testNodeenvSegmentPrintsAtLeastNodeEnvWithoutNode() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nodeenv)
- alias node="nonode 2>/dev/null"
- NODE_VIRTUAL_ENV="node-env"
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{000} %F{002}⬢ %F{002}[node-env] %k%F{000}%f " "$(build_left_prompt)"
-
- unset NODE_VIRTUAL_ENV
- unalias node
-}
-
-function testNodeenvSegmentWorks() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nodeenv)
- node() {
- echo "v1.2.3"
- }
- NODE_VIRTUAL_ENV="node-env"
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{000} %F{002}⬢ %F{002}v1.2.3[node-env] %k%F{000}%f " "$(build_left_prompt)"
-
- unfunction node
- unset NODE_VIRTUAL_ENV
-}
-
-source shunit2/shunit2 \ No newline at end of file
diff --git a/test/segments/nvm.spec b/test/segments/nvm.spec
deleted file mode 100755
index b53bf22e..00000000
--- a/test/segments/nvm.spec
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
-
- P9K_HOME=$(pwd)
- ### Test specific
- # Create default folder and git init it.
- FOLDER=/tmp/powerlevel9k-test/nvm-test
- mkdir -p "${FOLDER}/bin"
- OLD_PATH=$PATH
- PATH=${FOLDER}/bin:$PATH
- cd $FOLDER
-}
-
-function tearDown() {
- # Restore old path
- PATH="${OLD_PATH}"
- # Go back to powerlevel9k folder
- cd "${P9K_HOME}"
- # Remove eventually created test-specific folder
- rm -fr "${FOLDER}"
- # At least remove test folder completely
- rm -fr /tmp/powerlevel9k-test
-}
-
-function testNvmSegmentPrintsNothingIfNvmIsNotAvailable() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nvm custom_world)
- local POWERLEVEL9K_CUSTOM_WORLD='echo world'
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-}
-
-function testNvmSegmentWorksWithoutHavingADefaultAlias() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nvm)
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- function nvm_version() {
- [[ ${1} == 'current' ]] && echo 'v4.6.0' || echo 'v1.4.0'
- }
-
- assertEquals "%K{005} %F{000}⬢ %F{000}4.6.0 %k%F{005}%f " "$(build_left_prompt)"
-}
-
-function testNvmSegmentPrintsNothingWhenOnDefaultVersion() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(nvm custom_world)
- local POWERLEVEL9K_CUSTOM_WORLD='echo world'
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- function nvm_version() {
- [[ ${1} == 'current' ]] && echo 'v4.6.0' || echo 'v4.6.0'
- }
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-}
-
-source shunit2/shunit2 \ No newline at end of file
diff --git a/test/segments/php_version.spec b/test/segments/php_version.spec
deleted file mode 100755
index 6d64c570..00000000
--- a/test/segments/php_version.spec
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
-}
-
-function testPhpVersionSegmentPrintsNothingIfPhpIsNotAvailable() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(php_version custom_world)
- local POWERLEVEL9K_CUSTOM_WORLD='echo world'
- alias php="nophp"
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-
- unalias php
-}
-
-function testPhpVersionSegmentWorks() {
- 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
-'"
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{013} %F{255}PHP 5.6.27 %k%F{013}%f " "$(build_left_prompt)"
-
- unalias php
-}
-
-source shunit2/shunit2 \ No newline at end of file
diff --git a/test/segments/public_ip.spec b/test/segments/public_ip.spec
deleted file mode 100755
index 334a6423..00000000
--- a/test/segments/public_ip.spec
+++ /dev/null
@@ -1,222 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
-
- # Test specific
- P9K_HOME=$(pwd)
- FOLDER=/tmp/powerlevel9k-test
- mkdir -p $FOLDER
- cd $FOLDER
-
- # Change cache file, so that the users environment don't
- # interfere with the tests.
- POWERLEVEL9K_PUBLIC_IP_FILE=$FOLDER/public_ip_file
-}
-
-function tearDown() {
- # Go back to powerlevel9k folder
- cd "${P9K_HOME}"
- # Remove eventually created test-specific folder
- rm -fr "${FOLDER}"
- # At least remove test folder completely
- rm -fr /tmp/powerlevel9k-test
- unset FOLDER
- unset P9K_HOME
-
- # Unset cache file
- unset POWERLEVEL9K_PUBLIC_IP_FILE
-}
-
-function testPublicIpSegmentPrintsNothingByDefaultIfHostIsNotAvailable() {
- 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
- # uses an alternative host.
- alias dig='nodig'
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-
- unalias dig
-}
-
-function testPublicIpSegmentPrintsNoticeIfNotConnected() {
- 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
- # uses an alternative host.
- alias dig='nodig'
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{000} %F{007}disconnected %k%F{000}%f " "$(build_left_prompt)"
-
- unalias dig
-}
-
-function testPublicIpSegmentWorksWithWget() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
- alias dig='nodig'
- alias curl='nocurl'
- wget() {
- echo "wget 1.2.3.4"
- }
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{000} %F{007}wget 1.2.3.4 %k%F{000}%f " "$(build_left_prompt)"
-
- unfunction wget
- unalias dig
- unalias curl
-}
-
-function testPublicIpSegmentUsesCurlAsFallbackMethodIfWgetIsNotAvailable() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
- alias dig='nodig'
- alias wget='nowget'
- curl() {
- echo "curl 1.2.3.4"
- }
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{000} %F{007}curl 1.2.3.4 %k%F{000}%f " "$(build_left_prompt)"
-
- unfunction curl
- unalias dig
- unalias wget
-}
-
-function testPublicIpSegmentUsesDigAsFallbackMethodIfWgetAndCurlAreNotAvailable() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
- alias curl='nocurl'
- alias wget='nowget'
- dig() {
- echo "dig 1.2.3.4"
- }
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{000} %F{007}dig 1.2.3.4 %k%F{000}%f " "$(build_left_prompt)"
-
- unfunction dig
- unalias curl
- unalias wget
-}
-
-function testPublicIpSegmentCachesFile() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
- dig() {
- echo "first"
- }
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{000} %F{007}first %k%F{000}%f " "$(build_left_prompt)"
-
- dig() {
- echo "second"
- }
-
- # Segment should not have changed!
- assertEquals "%K{000} %F{007}first %k%F{000}%f " "$(build_left_prompt)"
-
- unfunction dig
-}
-
-function testPublicIpSegmentRefreshesCachesFileAfterTimeout() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
- local POWERLEVEL9K_PUBLIC_IP_TIMEOUT=2
- dig() {
- echo "first"
- }
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{000} %F{007}first %k%F{000}%f " "$(build_left_prompt)"
-
- sleep 3
- dig() {
- echo "second"
- }
-
- # Segment should not have changed!
- assertEquals "%K{000} %F{007}second %k%F{000}%f " "$(build_left_prompt)"
-
- unfunction dig
-}
-
-function testPublicIpSegmentRefreshesCachesFileIfEmpty() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(public_ip)
- dig() {
- echo "first"
- }
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{000} %F{007}first %k%F{000}%f " "$(build_left_prompt)"
-
- # Truncate cache file
- echo "" >! $POWERLEVEL9K_PUBLIC_IP_FILE
-
- dig() {
- echo "second"
- }
-
- # Segment should not have changed!
- assertEquals "%K{000} %F{007}second %k%F{000}%f " "$(build_left_prompt)"
-
- unfunction dig
-}
-
-function testPublicIpSegmentWhenGoingOnline() {
- 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"
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{000} %F{007}disconnected %k%F{000}%f " "$(build_left_prompt)"
-
- unalias dig
-
- dig() {
- echo "second"
- }
-
- # Segment should not have changed!
- assertEquals "%K{000} %F{007}second %k%F{000}%f " "$(build_left_prompt)"
-
- unfunction dig
-}
-
-source shunit2/shunit2 \ No newline at end of file
diff --git a/test/segments/ram.spec b/test/segments/ram.spec
deleted file mode 100755
index 292c784b..00000000
--- a/test/segments/ram.spec
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
-
- P9K_HOME=$(pwd)
- ### Test specific
- # Create default folder and git init it.
- FOLDER=/tmp/powerlevel9k-test/ram-test
- mkdir -p "${FOLDER}"
- cd $FOLDER
-}
-
-function tearDown() {
- # Go back to powerlevel9k folder
- cd "${P9K_HOME}"
- # Remove eventually created test-specific folder
- rm -fr "${FOLDER}"
- # At least remove test folder completely
- rm -fr /tmp/powerlevel9k-test
-}
-
-function testRamSegmentWorksOnOsx() {
- alias vm_stat="echo 'Mach Virtual Memory Statistics: (page size of 4096 bytes)
-Pages free: 299687.
-Pages active: 1623792.
-Pages inactive: 1313411.
-'"
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
- local OS="OSX" # Fake OSX
-
- assertEquals "%K{003} %F{000}RAM %F{000}6.15G " "$(prompt_ram left 1 false ${FOLDER})"
-
- unalias vm_stat
-}
-
-function testRamSegmentWorksOnBsd() {
- mkdir -p var/run
- echo "avail memory 5678B 299687 4444G 299" > var/run/dmesg.boot
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
- local OS="BSD" # Fake BSD
-
- assertEquals "%K{003} %F{000}RAM %F{000}0.29M " "$(prompt_ram left 1 false ${FOLDER})"
-}
-
-function testRamSegmentWorksOnLinux() {
- mkdir proc
- echo "MemAvailable: 299687" > proc/meminfo
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
- local OS="Linux" # Fake Linux
-
- assertEquals "%K{003} %F{000}RAM %F{000}0.29G " "$(prompt_ram left 1 false ${FOLDER})"
-}
-
-source shunit2/shunit2 \ No newline at end of file
diff --git a/test/segments/rust_version.spec b/test/segments/rust_version.spec
deleted file mode 100755
index 7b6ffe7c..00000000
--- a/test/segments/rust_version.spec
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-TEST_BASE_FOLDER=/tmp/powerlevel9k-test
-RUST_TEST_FOLDER="${TEST_BASE_FOLDER}/rust-test"
-
-function setUp() {
- OLDPATH="${PATH}"
- mkdir -p "${RUST_TEST_FOLDER}"
- PATH="${RUST_TEST_FOLDER}:${PATH}"
-
- export TERM="xterm-256color"
-}
-
-function tearDown() {
- PATH="${OLDPATH}"
- rm -fr "${TEST_BASE_FOLDER}"
-}
-
-function mockRust() {
- echo "#!/bin/sh\n\necho 'rustc 0.4.1a-alpha'" > "${RUST_TEST_FOLDER}/rustc"
- chmod +x "${RUST_TEST_FOLDER}/rustc"
-}
-
-function testRust() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(rust_version)
- mockRust
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{208} %F{000}Rust %F{000}0.4.1a-alpha %k%F{208}%f " "$(build_left_prompt)"
-}
-
-function testRustPrintsNothingIfRustIsNotAvailable() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world rust_version)
- local POWERLEVEL9K_CUSTOM_WORLD='echo world'
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-}
-
-source shunit2/shunit2
diff --git a/test/segments/ssh.spec b/test/segments/ssh.spec
deleted file mode 100755
index 40723ebd..00000000
--- a/test/segments/ssh.spec
+++ /dev/null
@@ -1,80 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
-}
-
-function testSshSegmentPrintsNothingIfNoSshConnection() {
- 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
- # $SSH_CLIENT and $SSH_TTY
- unset SSH_CLIENT
- unset SSH_TTY
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-}
-
-function testSshSegmentWorksIfOnlySshClientIsSet() {
- 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
- SSH_CLIENT='ssh-client'
- unset SSH_TTY
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{000} %F{003}ssh-icon %k%F{000}%f " "$(build_left_prompt)"
-
- unset SSH_CLIENT
-}
-
-function testSshSegmentWorksIfOnlySshTtyIsSet() {
- 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
- SSH_TTY='ssh-tty'
- unset SSH_CLIENT
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{000} %F{003}ssh-icon %k%F{000}%f " "$(build_left_prompt)"
-
- unset SSH_TTY
-}
-
-function testSshSegmentWorksIfAllNecessaryVariablesAreSet() {
- 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
- SSH_CLIENT='ssh-client'
- SSH_TTY='ssh-tty'
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{000} %F{003}ssh-icon %k%F{000}%f " "$(build_left_prompt)"
-
- unset SSH_TTY
- unset SSH_CLIENT
-}
-
-source shunit2/shunit2 \ No newline at end of file
diff --git a/test/segments/status.spec b/test/segments/status.spec
deleted file mode 100755
index 839f30ab..00000000
--- a/test/segments/status.spec
+++ /dev/null
@@ -1,113 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
-
- ### Test specific
- # Resets if someone has set these in his/hers env
- unset POWERLEVEL9K_STATUS_VERBOSE
- unset POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE
-}
-
-function testStatusPrintsNothingIfReturnCodeIsZeroAndVerboseIsUnset() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status custom_world)
- local POWERLEVEL9K_CUSTOM_WORLD='echo world'
- local POWERLEVEL9K_STATUS_VERBOSE=false
- local POWERLEVEL9K_STATUS_SHOW_PIPESTATUS=false
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-}
-
-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
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{000} %F{002}✔ %k%F{000}%f " "$(build_left_prompt)"
-}
-
-function testStatusInGeneralErrorCase() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status)
- local POWERLEVEL9K_STATUS_VERBOSE=true
- local POWERLEVEL9K_STATUS_SHOW_PIPESTATUS=false
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
- local RETVAL=1
-
- assertEquals "%K{001} %F{226}↵ %F{226}1 %k%F{001}%f " "$(build_left_prompt)"
-}
-
-function testPipestatusInErrorCase() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status)
- local POWERLEVEL9K_STATUS_VERBOSE=true
- local POWERLEVEL9K_STATUS_SHOW_PIPESTATUS=true
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
- local -a RETVALS
- RETVALS=(0 0 1 0)
-
- assertEquals "%K{001} %F{226}↵ %F{226}0|0|1|0 %k%F{001}%f " "$(build_left_prompt)"
-}
-
-function testStatusCrossWinsOverVerbose() {
- 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
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
- local RETVAL=1
-
- assertEquals "%K{000} %F{001}✘ %k%F{000}%f " "$(build_left_prompt)"
-}
-
-function testStatusShowsSignalNameInErrorCase() {
- 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
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
- local RETVAL=132
-
- assertEquals "%K{001} %F{226}↵ %F{226}SIGILL(4) %k%F{001}%f " "$(build_left_prompt)"
-}
-
-function testStatusSegmentIntegrated() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(status)
- local -a POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS
- POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=()
- local POWERLEVEL9K_STATUS_CROSS=true
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- false; powerlevel9k_prepare_prompts
-
- assertEquals "%f%b%k%K{000} %F{001}✘ %k%F{000}%f " "${(e)PROMPT}"
-}
-
-source shunit2/shunit2 \ No newline at end of file
diff --git a/test/segments/swap.spec b/test/segments/swap.spec
deleted file mode 100755
index 07b254be..00000000
--- a/test/segments/swap.spec
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
-
- P9K_HOME=$(pwd)
- ### Test specific
- # Create default folder and git init it.
- FOLDER=/tmp/powerlevel9k-test/swap-test
- mkdir -p "${FOLDER}"
- cd $FOLDER
-}
-
-function tearDown() {
- # Go back to powerlevel9k folder
- cd "${P9K_HOME}"
- # Remove eventually created test-specific folder
- rm -fr "${FOLDER}"
- # At least remove test folder completely
- rm -fr /tmp/powerlevel9k-test
-}
-
-function testSwapSegmentWorksOnOsx() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(swap)
- sysctl() {
- echo "vm.swapusage: total = 3072,00M used = 1620,50M free = 1451,50M (encrypted)"
- }
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
- local OS="OSX" # Fake OSX
-
- assertEquals "%K{003} %F{000}SWP %F{000}1.58G " "$(prompt_swap left 1 false ${FOLDER})"
-
- unfunction sysctl
-}
-
-function testSwapSegmentWorksOnLinux() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(swap)
- mkdir proc
- echo "SwapTotal: 1000000" > proc/meminfo
- echo "SwapFree: 1000" >> proc/meminfo
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
- local OS="Linux" # Fake Linux
-
- assertEquals "%K{003} %F{000}SWP %F{000}0.95G " "$(prompt_swap left 1 false ${FOLDER})"
-}
-
-source shunit2/shunit2 \ No newline at end of file
diff --git a/test/segments/swift_version.spec b/test/segments/swift_version.spec
deleted file mode 100755
index 57a2ef7b..00000000
--- a/test/segments/swift_version.spec
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
-
- P9K_HOME=$(pwd)
- ### Test specific
- # Create default folder and git init it.
- FOLDER=/tmp/powerlevel9k-test
- mkdir -p "${FOLDER}"
- cd $FOLDER
-}
-
-function tearDown() {
- # Go back to powerlevel9k folder
- cd "${P9K_HOME}"
- # Remove eventually created test-specific folder
- rm -fr "${FOLDER}"
- # At least remove test folder completely
- rm -fr /tmp/powerlevel9k-test
-}
-
-function testSwiftSegmentPrintsNothingIfSwiftIsNotAvailable() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(swift_version custom_world)
- local POWERLEVEL9K_CUSTOM_WORLD='echo world'
- alias swift="noswift"
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-
- unalias swift
-}
-
-function testSwiftSegmentWorks() {
- 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"
- }
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{005} %F{007}Swift %F{007}3.0.1 %k%F{005}%f " "$(build_left_prompt)"
-
- unfunction swift
-}
-
-source shunit2/shunit2 \ No newline at end of file
diff --git a/test/segments/symfony_version.spec b/test/segments/symfony_version.spec
deleted file mode 100755
index cb480724..00000000
--- a/test/segments/symfony_version.spec
+++ /dev/null
@@ -1,117 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
-
- P9K_HOME=$(pwd)
- ### Test specific
- # Create default folder and git init it.
- FOLDER=/tmp/powerlevel9k-test
- mkdir -p "${FOLDER}"
- cd $FOLDER
-}
-
-function tearDown() {
- # Go back to powerlevel9k folder
- cd "${P9K_HOME}"
- # Remove eventually created test-specific folder
- rm -fr "${FOLDER}"
- # At least remove test folder completely
- rm -fr /tmp/powerlevel9k-test
-}
-
-function testSymfonyVersionSegmentPrintsNothingIfPhpIsNotAvailable() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(symfony2_version custom_world)
- local POWERLEVEL9K_CUSTOM_WORLD='echo world'
- alias php="nophp"
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-
- unalias php
-}
-
-function testSymfonyVersionSegmentPrintsNothingIfSymfonyIsNotAvailable() {
- 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.
- local POWERLEVEL9K_CUSTOM_WORLD='echo world'
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-}
-
-function testSymfonyVersionPrintsNothingIfPhpThrowsAnError() {
- 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
- function php() {
- echo "Warning: Unsupported declare strict_types in /Users/dr/Privat/vendor/ocramius/proxy-manager/src/ProxyManager/Configuration.php on line 19
-
- Parse error: parse error, expecting `;´ or `{´ in /Users/dr/Privat/vendor/ocramius/proxy-manager/src/ProxyManager/Configuration.php on line 97"
- }
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-
- unfunction php
-}
-
-function testSymfonyVersionSegmentWorks() {
- startSkipping # Skip test
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(symfony2_version)
- mkdir app
- touch app/AppKernel.php
-
- function php() {
- echo "Symfony version 3.1.4 - app/dev/debug"
- }
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{240} %F{000}SF %f%F{000}3.1.4 %k%F{240}%f " "$(build_left_prompt)"
-
- unfunction php
-}
-
-function testSymfonyVersionSegmentWorksInNestedFolder() {
- startSkipping # Skip test
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(symfony2_version)
- mkdir app
- touch app/AppKernel.php
-
- function php() {
- echo "Symfony version 3.1.4 - app/dev/debug"
- }
-
- mkdir -p src/P9K/AppBundle
- cd src/P9K/AppBundle
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{240} %F{000}SF %f%F{000}3.1.4 %k%F{240}%f " "$(build_left_prompt)"
-
- unfunction php
-}
-
-source shunit2/shunit2 \ No newline at end of file
diff --git a/test/segments/todo.spec b/test/segments/todo.spec
deleted file mode 100755
index 21da2a92..00000000
--- a/test/segments/todo.spec
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
-
- P9K_HOME=$(pwd)
- ### Test specific
- # Create default folder and git init it.
- FOLDER=/tmp/powerlevel9k-test
- mkdir -p "${FOLDER}"
- mkdir ${FOLDER}/bin
- OLD_PATH=$PATH
- PATH=${FOLDER}/bin:$PATH
- cd $FOLDER
-}
-
-function tearDown() {
- # Reset PATH
- PATH=$OLD_PATH
- # Go back to powerlevel9k folder
- cd "${P9K_HOME}"
- # Remove eventually created test-specific folder
- rm -fr "${FOLDER}"
- # At least remove test folder completely
- rm -fr /tmp/powerlevel9k-test
-}
-
-function testTodoSegmentPrintsNothingIfTodoShIsNotInstalled() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(todo custom_world)
- local POWERLEVEL9K_CUSTOM_WORLD='echo world'
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{000}world %k%F{007}%f " "$(build_left_prompt)"
-}
-
-function testTodoSegmentWorksAsExpected() {
- # TODO: Skript in den PATH legen!
- 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
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{244} %F{000}☑ %F{000}100 %k%F{244}%f " "$(build_left_prompt)"
-}
-
-source shunit2/shunit2 \ No newline at end of file
diff --git a/test/segments/vcs-git.spec b/test/segments/vcs-git.spec
deleted file mode 100755
index 81a934e9..00000000
--- a/test/segments/vcs-git.spec
+++ /dev/null
@@ -1,535 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
-
- P9K_HOME=$(pwd)
- ### Test specific
- # Create default folder and git init it.
- FOLDER=/tmp/powerlevel9k-test/vcs-test
- mkdir -p "${FOLDER}"
- cd $FOLDER
-
- # Set username and email
- OLD_GIT_AUTHOR_NAME=$GIT_AUTHOR_NAME
- GIT_AUTHOR_NAME="Testing Tester"
- OLD_GIT_AUTHOR_EMAIL=$GIT_AUTHOR_EMAIL
- GIT_AUTHOR_EMAIL="test@powerlevel9k.theme"
-
- # Set default username if not already set!
- if [[ -z $(git config user.name) ]]; then
- GIT_AUTHOR_NAME_SET_BY_TEST=true
- git config --global user.name "${GIT_AUTHOR_NAME}"
- fi
- # Set default email if not already set!
- if [[ -z $(git config user.email) ]]; then
- GIT_AUTHOR_EMAIL_SET_BY_TEST=true
- git config --global user.email "${GIT_AUTHOR_EMAIL}"
- fi
-
- # Initialize FOLDER as git repository
- git init 1>/dev/null
-}
-
-function tearDown() {
- if [[ -n "${OLD_GIT_AUTHOR_NAME}" ]]; then
- GIT_AUTHOR_NAME=$OLD_GIT_AUTHOR
- unset OLD_GIT_AUTHOR_NAME
- else
- unset GIT_AUTHOR_NAME
- fi
-
- if [[ -n "${OLD_GIT_AUTHOR_EMAIL}" ]]; then
- GIT_AUTHOR_EMAIL=$OLD_GIT_AUTHOR_EMAIL
- unset OLD_GIT_AUTHOR_EMAIL
- else
- unset GIT_AUTHOR_EMAIL
- fi
-
- if [[ "${GIT_AUTHOR_NAME_SET_BY_TEST}" == "true" ]]; then
- git config --global --unset user.name
- fi
- if [[ "${GIT_AUTHOR_EMAIL_SET_BY_TEST}" == "true" ]]; then
- git config --global --unset user.email
- fi
-
- # Go back to powerlevel9k folder
- cd "${P9K_HOME}"
- # Remove eventually created test-specific folder
- rm -fr "${FOLDER}"
- # At least remove test folder completely
- rm -fr /tmp/powerlevel9k-test
- unset FOLDER
-}
-
-function testColorOverridingForCleanStateWorks() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
- local POWERLEVEL9K_VCS_CLEAN_FOREGROUND='cyan'
- local POWERLEVEL9K_VCS_CLEAN_BACKGROUND='white'
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{006} master %k%F{007}%f " "$(build_left_prompt)"
-}
-
-function testColorOverridingForModifiedStateWorks() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
- local POWERLEVEL9K_VCS_MODIFIED_FOREGROUND='red'
- local POWERLEVEL9K_VCS_MODIFIED_BACKGROUND='yellow'
-
- touch testfile
- git add testfile
- git commit -m "test" 1>/dev/null
- echo "test" > testfile
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{003} %F{001} master ● %k%F{003}%f " "$(build_left_prompt)"
-}
-
-function testColorOverridingForUntrackedStateWorks() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
- local POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND='cyan'
- local POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND='yellow'
-
- touch testfile
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{003} %F{006} master ? %k%F{003}%f " "$(build_left_prompt)"
-}
-
-function testGitIconWorks() {
- local POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
- local POWERLEVEL9K_VCS_GIT_ICON='Git-Icon'
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{002} %F{000}Git-Icon %F{000} master %k%F{002}%f " "$(build_left_prompt)"
-}
-
-function testGitlabIconWorks() {
- 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
- # sufficient to show the GitLab-specific icon.
- git remote add origin https://gitlab.com/dritter/gitlab-test-project.git
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{002} %F{000}GL-Icon %F{000} master %k%F{002}%f " "$(build_left_prompt)"
-}
-
-function testBitbucketIconWorks() {
- 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
- # sufficient to show the BitBucket-specific icon.
- git remote add origin https://dritter@bitbucket.org/dritter/dr-test.git
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{002} %F{000}BB-Icon %F{000} master %k%F{002}%f " "$(build_left_prompt)"
-}
-
-function testGitHubIconWorks() {
- 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
- # sufficient to show the GitHub-specific icon.
- git remote add origin https://github.com/dritter/test.git
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{002} %F{000}GH-Icon %F{000} master %k%F{002}%f " "$(build_left_prompt)"
-}
-
-function testUntrackedFilesIconWorks() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
- local POWERLEVEL9K_VCS_UNTRACKED_ICON='?'
-
- # Create untracked file
- touch "i-am-untracked.txt"
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{002} %F{000} master ? %k%F{002}%f " "$(build_left_prompt)"
-}
-
-function testStagedFilesIconWorks() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
- local POWERLEVEL9K_VCS_STAGED_ICON='+'
-
- # Create staged file
- touch "i-am-added.txt"
- git add i-am-added.txt &>/dev/null
- git commit -m "initial commit" &>/dev/null
- echo "xx" >> i-am-added.txt
- git add i-am-added.txt &>/dev/null
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{003} %F{000} master + %k%F{003}%f " "$(build_left_prompt)"
-}
-
-function testUnstagedFilesIconWorks() {
- 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
- touch "i-am-modified.txt"
- git add i-am-modified.txt
- git commit -m "Add File" 1>/dev/null
- echo "xx" > i-am-modified.txt
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{003} %F{000} master M %k%F{003}%f " "$(build_left_prompt)"
-}
-
-function testStashIconWorks() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
- local POWERLEVEL9K_VCS_STASH_ICON='S'
-
- # Create modified file
- touch "i-am-modified.txt"
- git add i-am-modified.txt
- git commit -m "Add File" 1>/dev/null
- echo "xx" > i-am-modified.txt
- git stash 1>/dev/null
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{002} %F{000} master S1 %k%F{002}%f " "$(build_left_prompt)"
-}
-
-function testTagIconWorks() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
- local POWERLEVEL9K_VCS_TAG_ICON='T'
-
- touch "file.txt"
- git add file.txt
- git commit -m "Add File" 1>/dev/null
- git tag "v0.0.1"
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{002} %F{000} master Tv0.0.1 %k%F{002}%f " "$(build_left_prompt)"
-}
-
-function testTagIconInDetachedHeadState() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
- local POWERLEVEL9K_VCS_TAG_ICON='T'
-
- touch "file.txt"
- git add file.txt
- git commit -m "Add File" &>/dev/null
- git tag "v0.0.1"
- touch "file2.txt"
- git add file2.txt
- git commit -m "Add File2" &>/dev/null
- git checkout v0.0.1 &>/dev/null
- local hash=$(git rev-list -n 1 --abbrev-commit --abbrev=8 HEAD)
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{002} %F{000} ${hash} Tv0.0.1 %k%F{002}%f " "$(build_left_prompt)"
-}
-
-function testActionHintWorks() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
-
- touch "i-am-modified.txt"
- git add i-am-modified.txt
- git commit -m "Add File" &>/dev/null
-
- git clone . ../vcs-test2 &>/dev/null
- echo "xx" >> i-am-modified.txt
- git commit -a -m "Modified file" &>/dev/null
-
- cd ../vcs-test2
- echo "yy" >> i-am-modified.txt
- git commit -a -m "Provoke conflict" &>/dev/null
- git pull &>/dev/null
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{003} %F{000} master %F{red}| merge%f %k%F{003}%f " "$(build_left_prompt)"
-}
-
-function testIncomingHintWorks() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
- local POWERLEVEL9K_VCS_INCOMING_CHANGES_ICON='I'
-
- touch "i-am-modified.txt"
- git add i-am-modified.txt
- git commit -m "Add File" &>/dev/null
-
- git clone . ../vcs-test2 &>/dev/null
- echo "xx" >> i-am-modified.txt
- git commit -a -m "Modified file" &>/dev/null
-
- cd ../vcs-test2
- git fetch &>/dev/null
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{002} %F{000} master I1 %k%F{002}%f " "$(build_left_prompt)"
-}
-
-function testOutgoingHintWorks() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
- local POWERLEVEL9K_VCS_OUTGOING_CHANGES_ICON='o'
-
- touch "i-am-modified.txt"
- git add i-am-modified.txt
- git commit -m "Add File" &>/dev/null
-
- git clone . ../vcs-test2 &>/dev/null
-
- cd ../vcs-test2
-
- echo "xx" >> i-am-modified.txt
- git commit -a -m "Modified file" &>/dev/null
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{002} %F{000} master o1 %k%F{002}%f " "$(build_left_prompt)"
-}
-
-function testShorteningCommitHashWorks() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
- local POWERLEVEL9K_SHOW_CHANGESET=true
- local POWERLEVEL9K_CHANGESET_HASH_LENGTH='4'
-
- touch "file.txt"
- git add file.txt
- git commit -m "Add File" 1>/dev/null
- local hash=$(git rev-list -n 1 --abbrev-commit --abbrev=3 HEAD)
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- # This test needs to call powerlevel9k_vcs_init, where
- # the changeset is truncated.
- powerlevel9k_vcs_init
- assertEquals "%K{002} %F{000}${hash}  master %k%F{002}%f " "$(build_left_prompt)"
-}
-
-function testShorteningCommitHashIsNotShownIfShowChangesetIsFalse() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
- local POWERLEVEL9K_SHOW_CHANGESET=false
- local POWERLEVEL9K_CHANGESET_HASH_LENGTH='4'
-
- touch "file.txt"
- git add file.txt
- git commit -m "Add File" 1>/dev/null
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- # This test needs to call powerlevel9k_vcs_init, where
- # the changeset is truncated.
- powerlevel9k_vcs_init
- assertEquals "%K{002} %F{000} master %k%F{002}%f " "$(build_left_prompt)"
-}
-
-function testDetectingUntrackedFilesInSubmodulesWork() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
- local POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY="true"
- unset POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND
-
- mkdir ../submodule
- cd ../submodule
- git init 1>/dev/null
- touch "i-am-tracked.txt"
- git add . 1>/dev/null && git commit -m "Initial Commit" 1>/dev/null
-
- local submodulePath="${PWD}"
-
- cd -
- git submodule add "${submodulePath}" 2>/dev/null
- git commit -m "Add submodule" 1>/dev/null
-
- # Go into checked-out submodule path
- cd submodule
- # Create untracked file
- touch "i-am-untracked.txt"
- cd -
-
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{002} %F{000} master ? %k%F{002}%f " "$(build_left_prompt)"
-}
-
-function testDetectinUntrackedFilesInMainRepoWithDirtySubmodulesWork() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
- local POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY="true"
- unset POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND
-
- mkdir ../submodule
- cd ../submodule
- git init 1>/dev/null
- touch "i-am-tracked.txt"
- git add . 1>/dev/null && git commit -m "Initial Commit" 1>/dev/null
-
- local submodulePath="${PWD}"
-
- cd -
- git submodule add "${submodulePath}" 2>/dev/null
- git commit -m "Add submodule" 1>/dev/null
-
- # Create untracked file
- touch "i-am-untracked.txt"
-
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{002} %F{000} master ? %k%F{002}%f " "$(build_left_prompt)"
-}
-
-function testDetectingUntrackedFilesInNestedSubmodulesWork() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
- local POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY="true"
- unset POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND
-
- local mainRepo="${PWD}"
-
- mkdir ../submodule
- cd ../submodule
- git init 1>/dev/null
- touch "i-am-tracked.txt"
- git add . 1>/dev/null && git commit -m "Initial Commit" 1>/dev/null
-
- local submodulePath="${PWD}"
-
- mkdir ../subsubmodule
- cd ../subsubmodule
- git init 1>/dev/null
- touch "i-am-tracked-too.txt"
- git add . 1>/dev/null && git commit -m "Initial Commit" 1>/dev/null
-
- local subsubmodulePath="${PWD}"
-
- cd "${submodulePath}"
- git submodule add "${subsubmodulePath}" 2>/dev/null
- git commit -m "Add subsubmodule" 1>/dev/null
- cd "${mainRepo}"
- git submodule add "${submodulePath}" 2>/dev/null
- git commit -m "Add submodule" 1>/dev/null
-
- git submodule update --init --recursive 2>/dev/null
-
- cd submodule/subsubmodule
- # Create untracked file
- touch "i-am-untracked.txt"
- cd -
-
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{002} %F{000} master ? %k%F{002}%f " "$(build_left_prompt)"
-}
-
-function testDetectingUntrackedFilesInCleanSubdirectoryWorks() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
- local POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY="true"
- unset POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND
- mkdir clean-folder
- touch clean-folder/file.txt
- mkdir dirty-folder
- touch dirty-folder/file.txt
- git add . 2>/dev/null
- git commit -m "Initial commit" >/dev/null
- touch dirty-folder/new-file.txt
- cd clean-folder
- source ${P9K_HOME}/powerlevel9k.zsh-theme
- assertEquals "%K{002} %F{000} master ? %k%F{002}%f " "$(build_left_prompt)"
-}
-
-function testBranchNameScriptingVulnerability() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
- echo "#!/bin/sh\n\necho 'hacked'\n" > evil_script.sh
- chmod +x evil_script.sh
-
- git checkout -b '$(./evil_script.sh)' 2>/dev/null
- git add . 2>/dev/null
- git commit -m "Initial commit" >/dev/null
-
- assertEquals '%K{002} %F{000} $(./evil_script.sh) %k%F{002}%f ' "$(build_left_prompt)"
-}
-
-function testGitSubmoduleWorks() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
- local POWERLEVEL9K_VCS_SHOW_SUBMODULE_DIRTY="true"
- unset POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND
-
- mkdir ../submodule
- cd ../submodule
- git init 1>/dev/null
- touch "i-am-tracked.txt"
- git add . 1>/dev/null && git commit -m "Initial Commit" 1>/dev/null
-
- local submodulePath="${PWD}"
-
- cd -
- git submodule add "${submodulePath}" 2>/dev/null
- git commit -m "Add submodule" 1>/dev/null
-
- cd submodule
-
- source "${P9K_HOME}/powerlevel9k.zsh-theme"
-
- local result="$(build_left_prompt)"
- [[ "$result" =~ ".*(is outside repository)+" ]] && return 1
-
- assertEquals "%K{002} %F{000} master %k%F{002}%f " "$result"
-}
-
-
-source shunit2/shunit2
diff --git a/test/segments/vcs-hg.spec b/test/segments/vcs-hg.spec
deleted file mode 100755
index 8fabc21a..00000000
--- a/test/segments/vcs-hg.spec
+++ /dev/null
@@ -1,220 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
-
- P9K_HOME=$(pwd)
- ### Test specific
- # Create default folder and hg init it.
- FOLDER=/tmp/powerlevel9k-test/vcs-test
- mkdir -p "${FOLDER}"
- cd $FOLDER
-
- export HGUSER="Test bot <bot@example.com>"
-
- hg init 1>/dev/null
-}
-
-function tearDown() {
- # Go back to powerlevel9k folder
- cd "${P9K_HOME}"
- # Remove eventually created test-specific folder
- rm -fr "${FOLDER}" &>/dev/null
- # At least remove test folder completely
- rm -fr /tmp/powerlevel9k-test &>/dev/null
- unset FOLDER
- unset HGUSER
-}
-
-function testColorOverridingForCleanStateWorks() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
- local POWERLEVEL9K_VCS_CLEAN_FOREGROUND='cyan'
- local POWERLEVEL9K_VCS_CLEAN_BACKGROUND='white'
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{007} %F{006} default %k%F{007}%f " "$(build_left_prompt)"
-}
-
-function testColorOverridingForModifiedStateWorks() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
- local POWERLEVEL9K_VCS_MODIFIED_FOREGROUND='red'
- local POWERLEVEL9K_VCS_MODIFIED_BACKGROUND='yellow'
-
- touch testfile
- hg add testfile
- hg commit -m "test" 1>/dev/null
- echo "test" > testfile
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{003} %F{001} default ● %k%F{003}%f " "$(build_left_prompt)"
-}
-
-# There is no staging area in mercurial, therefore there are no "untracked"
-# files.. In case there are added files, we show the VCS segment with a
-# yellow background.
-# This may be improved in future versions, to be a bit more consistent with
-# the git part.
-function testAddedFilesIconWorks() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
- touch "myfile.txt"
- hg add myfile.txt
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{003} %F{000} default ● %k%F{003}%f " "$(build_left_prompt)"
-}
-
-# We don't support tagging in mercurial right now..
-function testTagIconWorks() {
- startSkipping # Skip test
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
- local POWERLEVEL9K_VCS_TAG_ICON='T'
-
- touch "file.txt"
- hg add file.txt
- hg commit -m "Add File" 1>/dev/null
- hg tag "v0.0.1"
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{002} %F{000} default Tv0.0.1 %k%F{002}%f " "$(build_left_prompt)"
-}
-
-function testTagIconInDetachedHeadState() {
- startSkipping # Skip test
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
- local POWERLEVEL9K_VCS_TAG_ICON='T'
-
- touch "file.txt"
- hg add file.txt
- hg commit -m "Add File" &>/dev/null
- hg tag "v0.0.1"
- touch "file2.txt"
- hg add file2.txt
- hg commit -m "Add File2" &>/dev/null
- hg checkout v0.0.1 &>/dev/null
- local hash=$(hg id)
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{002} %F{000} ${hash} Tv0.0.1 %k%F{002}%f " "$(build_left_prompt)"
-}
-
-function testActionHintWorks() {
- 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
-
- hg clone . ../vcs-test2 &>/dev/null
- echo "xx" >> i-am-modified.txt
- hg commit -m "Modified file" &>/dev/null
-
- cd ../vcs-test2
- echo "yy" >> i-am-modified.txt
- hg commit -m "Provoke conflict" 2>/dev/null
- hg pull 1>/dev/null
- hg merge --tool internal:merge >/dev/null 2>&1
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{003} %F{000} default %F{red}| merging%f %k%F{003}%f " "$(build_left_prompt)"
-}
-
-function testShorteningCommitHashWorks() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
- local POWERLEVEL9K_SHOW_CHANGESET=true
- local POWERLEVEL9K_CHANGESET_HASH_LENGTH='4'
-
- touch "file.txt"
- hg add file.txt
- hg commit -m "Add File" 1>/dev/null
- local hash=$(hg id | head -c ${POWERLEVEL9K_CHANGESET_HASH_LENGTH})
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- # This test needs to call powerlevel9k_vcs_init, where
- # the changeset is truncated.
- powerlevel9k_vcs_init
-
- assertEquals "%K{002} %F{000}${hash}  default %k%F{002}%f " "$(build_left_prompt)"
-}
-
-function testShorteningCommitHashIsNotShownIfShowChangesetIsFalse() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
- local POWERLEVEL9K_SHOW_CHANGESET=false
- local POWERLEVEL9K_CHANGESET_HASH_LENGTH='4'
-
- touch "file.txt"
- hg add file.txt
- hg commit -m "Add File" 1>/dev/null
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- # This test needs to call powerlevel9k_vcs_init, where
- # the changeset is truncated.
- powerlevel9k_vcs_init
-
- assertEquals "%K{002} %F{000} default %k%F{002}%f " "$(build_left_prompt)"
-}
-
-function testMercurialIconWorks() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
- local POWERLEVEL9K_VCS_HG_ICON='HG-Icon'
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{002} %F{000}HG-Icon %F{000} default %k%F{002}%f " "$(build_left_prompt)"
-}
-
-function testBookmarkIconWorks() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
- local POWERLEVEL9K_VCS_BOOKMARK_ICON='B'
- hg bookmark "initial"
-
- # Load Powerlevel9k
- source ${P9K_HOME}/powerlevel9k.zsh-theme
-
- assertEquals "%K{002} %F{000} default Binitial %k%F{002}%f " "$(build_left_prompt)"
-}
-
-function testBranchNameScriptingVulnerability() {
- local -a POWERLEVEL9K_LEFT_PROMPT_ELEMENTS
- POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(vcs)
- echo "#!/bin/sh\n\necho 'hacked'\n" > evil_script.sh
- chmod +x evil_script.sh
-
- hg branch '$(./evil_script.sh)' >/dev/null
- hg add . >/dev/null
- hg commit -m "Initial commit" >/dev/null
-
- assertEquals '%K{002} %F{000} $(./evil_script.sh) %k%F{002}%f ' "$(build_left_prompt)"
-}
-
-source shunit2/shunit2
diff --git a/test/segments/vi_mode.spec b/test/segments/vi_mode.spec
deleted file mode 100755
index 6a3a07b5..00000000
--- a/test/segments/vi_mode.spec
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/usr/bin/env zsh
-#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
-
-# Required for shunit2 to run correctly
-setopt shwordsplit
-SHUNIT_PARENT=$0
-
-function setUp() {
- export TERM="xterm-256color"
-}
-
-function testViInsertModeWorks() {
- local KEYMAP='viins'
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{000} %F{004}INSERT " "$(prompt_vi_mode left 1 false)"
-}
-
-function testViInsertModeWorksWhenLabeledAsMain() {
- local KEYMAP='main'
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{000} %F{004}INSERT " "$(prompt_vi_mode left 1 false)"
-}
-
-function testViCommandModeWorks() {
- local KEYMAP='vicmd'
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{000} %F{007}NORMAL " "$(prompt_vi_mode left 1 false)"
-}
-
-function testViInsertModeStringIsCustomizable() {
- local KEYMAP='viins'
-
- # Load Powerlevel9k
- source powerlevel9k.zsh-theme
-
- assertEquals "%K{000} %F{004}INSERT " "$(prompt_vi_mode left 1 false)"
-}
-
-source shunit2/shunit2 \ No newline at end of file