1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-12-23 15:41:57 +00:00

speed up symfony2_tests and rspec_stats

This commit is contained in:
romkatv 2019-05-21 14:55:55 +02:00
parent edc4e1375a
commit ee8a1b940f

View file

@ -1401,11 +1401,10 @@ prompt_rust_version() {
# RSpec test ratio # RSpec test ratio
prompt_rspec_stats() { prompt_rspec_stats() {
if [[ -d app && -d spec ]]; then if [[ -d app && -d spec ]]; then
local code_amount tests_amount local -a code=(app/**/*.rb(N))
code_amount=$(ls -1 app/**/*.rb | wc -l) (( $#code )) || return
tests_amount=$(ls -1 spec/**/*.rb | wc -l) local tests=(spec/**/*.rb(N))
build_test_stats "$1" "$0" "$2" "$#code" "$#tests" "RSpec" 'TEST_ICON'
build_test_stats "$1" "$0" "$2" "$code_amount" "$tests_amount" "RSpec" 'TEST_ICON'
fi fi
} }
@ -1531,11 +1530,10 @@ prompt_swap() {
# Symfony2-PHPUnit test ratio # Symfony2-PHPUnit test ratio
prompt_symfony2_tests() { prompt_symfony2_tests() {
if [[ -d src && -d app && -f app/AppKernel.php ]]; then if [[ -d src && -d app && -f app/AppKernel.php ]]; then
local code_amount tests_amount local -a all=(src/**/*.php(N))
code_amount=$(ls -1 src/**/*.php | grep -vc Tests) local -a code=(${(@)all##*Tests*})
tests_amount=$(ls -1 src/**/*.php | grep -c Tests) (( $#code )) || return
build_test_stats "$1" "$0" "$2" "$#code" "$(($#all - $#code))" "SF2" 'TEST_ICON'
build_test_stats "$1" "$0" "$2" "$code_amount" "$tests_amount" "SF2" 'TEST_ICON'
fi fi
} }
@ -1553,11 +1551,11 @@ prompt_symfony2_version() {
# Show a ratio of tests vs code # Show a ratio of tests vs code
build_test_stats() { build_test_stats() {
local code_amount="$4" local code_amount="$4"
local tests_amount="$5"+0.00001 local tests_amount="$5"
local headline="$6" local headline="$6"
# Set float precision to 2 digits: (( code_amount > 0 )) || return
local -F 2 ratio=$(( (tests_amount/code_amount) * 100 )) local -F 2 ratio=$(( 100. * tests_amount / code_amount ))
(( ratio >= 75 )) && "$1_prompt_segment" "${2}_GOOD" "$3" "cyan" "$DEFAULT_COLOR" "$6" 0 '' "$headline: $ratio%%" (( ratio >= 75 )) && "$1_prompt_segment" "${2}_GOOD" "$3" "cyan" "$DEFAULT_COLOR" "$6" 0 '' "$headline: $ratio%%"
(( ratio >= 50 && ratio < 75 )) && "$1_prompt_segment" "$2_AVG" "$3" "yellow" "$DEFAULT_COLOR" "$6" 0 '' "$headline: $ratio%%" (( ratio >= 50 && ratio < 75 )) && "$1_prompt_segment" "$2_AVG" "$3" "yellow" "$DEFAULT_COLOR" "$6" 0 '' "$headline: $ratio%%"