From 5657fe6ac7d75cac48a386f55e429b716f8d7623 Mon Sep 17 00:00:00 2001 From: Chris Chou Date: Fri, 6 Oct 2017 09:47:37 +1300 Subject: #632: Indicate `Rust` or `(rust)` for rust_version segment only if icon is unavailable --- test/segments/rust_version.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/segments/rust_version.spec') diff --git a/test/segments/rust_version.spec b/test/segments/rust_version.spec index 49b06bcf..c945f8ae 100755 --- a/test/segments/rust_version.spec +++ b/test/segments/rust_version.spec @@ -19,7 +19,7 @@ function testRust() { alias rustc=mockRust POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(rust_version) - assertEquals "%K{208} %F{black}Rust 0.4.1a-alpha %k%F{208}%f " "$(build_left_prompt)" + assertEquals "%K{208} %F{black%}Rust%f %F{black}0.4.1a-alpha %k%F{208}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unalias rustc -- cgit v1.2.3 From 9b0e0c786af71048c3f615e99de079d7ff86266e Mon Sep 17 00:00:00 2001 From: Daniel Kolsoi Date: Wed, 9 May 2018 23:37:32 -0400 Subject: Removed 'Rust' text from test; Silenced missing rustc warning --- powerlevel9k.zsh-theme | 2 +- test/segments/rust_version.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'test/segments/rust_version.spec') diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index c901103d..530b0d9a 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1104,7 +1104,7 @@ prompt_root_indicator() { # Print Rust version number prompt_rust_version() { local rust_version - rust_version=$(command rustc --version 2>&1) + rust_version=$(command rustc --version 2>/dev/null) # Remove "rustc " (including the whitespace) from the beginning # of the version string and remove everything after the next # whitespace. This way we'll end up with only the version. diff --git a/test/segments/rust_version.spec b/test/segments/rust_version.spec index 49b06bcf..8274789f 100755 --- a/test/segments/rust_version.spec +++ b/test/segments/rust_version.spec @@ -19,7 +19,7 @@ function testRust() { alias rustc=mockRust POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(rust_version) - assertEquals "%K{208} %F{black}Rust 0.4.1a-alpha %k%F{208}%f " "$(build_left_prompt)" + assertEquals "%K{208} %F{black}0.4.1a-alpha %k%F{208}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unalias rustc -- cgit v1.2.3 From 27bd1cd65df8878812adefcf1ab6974660c2714d Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Sat, 12 May 2018 23:17:49 +0200 Subject: Fix test for rust segment --- powerlevel9k.zsh-theme | 1 + test/segments/rust_version.spec | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'test/segments/rust_version.spec') diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 530b0d9a..2b21b3de 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1114,6 +1114,7 @@ prompt_rust_version() { "$1_prompt_segment" "$0" "$2" "208" "$DEFAULT_COLOR" "$rust_version" 'RUST_ICON' fi } + # RSpec test ratio prompt_rspec_stats() { if [[ (-d app && -d spec) ]]; then diff --git a/test/segments/rust_version.spec b/test/segments/rust_version.spec index 8274789f..85b4ec69 100755 --- a/test/segments/rust_version.spec +++ b/test/segments/rust_version.spec @@ -5,28 +5,39 @@ 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" # Load Powerlevel9k source powerlevel9k.zsh-theme } +function tearDown() { + PATH="${OLDPATH}" + rm -fr "${TEST_BASE_FOLDER}" +} + function mockRust() { - echo 'rustc 0.4.1a-alpha' + echo "#!/bin/sh\n\necho 'rustc 0.4.1a-alpha'" > "${RUST_TEST_FOLDER}/rustc" + chmod +x "${RUST_TEST_FOLDER}/rustc" } function testRust() { - alias rustc=mockRust + mockRust POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(rust_version) assertEquals "%K{208} %F{black}0.4.1a-alpha %k%F{208}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS - unalias rustc } function testRustPrintsNothingIfRustIsNotAvailable() { - alias rustc=noRust POWERLEVEL9K_CUSTOM_WORLD='echo world' POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(custom_world rust_version) @@ -34,7 +45,6 @@ function testRustPrintsNothingIfRustIsNotAvailable() { unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset POWERLEVEL9K_CUSTOM_WORLD - unalias rustc } source shunit2/source/2.1/src/shunit2 -- cgit v1.2.3 From dc21b973350a1ebc0a6ff1699e2d8439a9f8820c Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Thu, 7 Jun 2018 02:01:36 +0200 Subject: Fix travis build --- powerlevel9k.zsh-theme | 3 ++- test/segments/laravel_version.spec | 2 +- test/segments/rust_version.spec | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'test/segments/rust_version.spec') diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index dde838d9..59178708 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1307,7 +1307,8 @@ prompt_root_indicator() { ################################################################ # Segment to display Rust version number prompt_rust_version() { - local rust_version=$(command rustc --version 2>/dev/null) + local rust_version + rust_version=$(command rustc --version 2>/dev/null) # Remove "rustc " (including the whitespace) from the beginning # of the version string and remove everything after the next # whitespace. This way we'll end up with only the version. diff --git a/test/segments/laravel_version.spec b/test/segments/laravel_version.spec index bebbfcfc..40b130d2 100755 --- a/test/segments/laravel_version.spec +++ b/test/segments/laravel_version.spec @@ -31,7 +31,7 @@ function testLaravelVersionSegment() { POWERLEVEL9K_LARAVEL_ICON='x' POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(laravel_version) - assertEquals "%K{001} %F{white%}x%f %F{white}5.4.23 %k%F{maroon}%f " "$(build_left_prompt)" + assertEquals "%K{001} %F{white%}x %f%F{white}5.4.23 %k%F{maroon}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS unset POWERLEVEL9K_LARAVEL_ICON diff --git a/test/segments/rust_version.spec b/test/segments/rust_version.spec index 2a344f64..34883a10 100755 --- a/test/segments/rust_version.spec +++ b/test/segments/rust_version.spec @@ -32,7 +32,7 @@ function testRust() { mockRust POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(rust_version) - assertEquals "%K{208} %F{black%}Rust%f %F{black}0.4.1a-alpha %k%F{darkorange}%f " "$(build_left_prompt)" + assertEquals "%K{208} %F{black%}Rust %f%F{black}0.4.1a-alpha %k%F{darkorange}%f " "$(build_left_prompt)" unset POWERLEVEL9K_LEFT_PROMPT_ELEMENTS } -- cgit v1.2.3