From 4cc2298359b8e2ac4fb0c3a4f061737551e5bb1e Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Sun, 30 Aug 2015 16:59:21 +0100 Subject: Test zsh ability to override colors --- test-colors.sh | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100755 test-colors.sh (limited to 'test-colors.sh') diff --git a/test-colors.sh b/test-colors.sh new file mode 100755 index 0000000..712dad5 --- /dev/null +++ b/test-colors.sh @@ -0,0 +1,89 @@ +scriptDir="$(cd "$(dirname "$0")"; pwd)" + +source "$scriptDir/radar-base.sh" + +cd_to_tmp() { + tmpfile="/tmp/git-prompt-tests-$(time_now)$1" + mkdir -p "$tmpfile" + cd "$tmpfile" +} + +rm_tmp() { + cd $scriptDir + rm -rf /tmp/git-prompt-tests* +} + +mock_zsh_colors() { + fg_bold[green]=1 + fg_bold[red]=2 + fg_bold[yellow]=3 + fg_bold[white]=4 + + reset_color=0 +} + +test_no_rcfile_zsh() { + mock_zsh_colors + prepare_zsh_colors + + assertEquals "$COLOR_REMOTE_AHEAD" "%{$fg_bold[green]%}" + assertEquals "$COLOR_REMOTE_BEHIND" "%{$fg_bold[red]%}" + assertEquals "$COLOR_REMOTE_DIVERGED" "%{$fg_bold[yellow]%}" + assertEquals "$COLOR_REMOTE_NOT_UPSTREAM" "%{$fg_bold[red]%}" + + assertEquals "$COLOR_LOCAL_AHEAD" "%{$fg_bold[green]%}" + assertEquals "$COLOR_LOCAL_BEHIND" "%{$fg_bold[red]%}" + assertEquals "$COLOR_LOCAL_DIVERGED" "%{$fg_bold[yellow]%}" + + assertEquals "$COLOR_CHANGES_STAGED" "%{$fg_bold[green]%}" + assertEquals "$COLOR_CHANGES_UNSTAGED" "%{$fg_bold[red]%}" + assertEquals "$COLOR_CHANGES_CONFLICTED" "%{$fg_bold[yellow]%}" + assertEquals "$COLOR_CHANGES_UNTRACKED" "%{$fg_bold[white]%}" + + assertEquals "$RESET_COLOR_LOCAL" "%{$reset_color%}" + assertEquals "$RESET_COLOR_REMOTE" "%{$reset_color%}" + assertEquals "$RESET_COLOR_CHANGES" "%{$reset_color%}" +} + +test_with_env_vars_zsh() { + export GIT_RADAR_COLOR_REMOTE_AHEAD="remote-ahead" + export GIT_RADAR_COLOR_REMOTE_BEHIND="remote-behind" + export GIT_RADAR_COLOR_REMOTE_DIVERGED="remote-diverged" + export GIT_RADAR_COLOR_REMOTE_NOT_UPSTREAM="not-upstream" + + export GIT_RADAR_COLOR_LOCAL_AHEAD="local-ahead" + export GIT_RADAR_COLOR_LOCAL_BEHIND="local-behind" + export GIT_RADAR_COLOR_LOCAL_DIVERGED="local-diverged" + + export GIT_RADAR_COLOR_CHANGES_STAGED="changes-staged" + export GIT_RADAR_COLOR_CHANGES_UNSTAGED="changes-unstaged" + export GIT_RADAR_COLOR_CHANGES_CONFLICTED="changes-conflicted" + export GIT_RADAR_COLOR_CHANGES_UNTRACKED="changes-untracked" + + export GIT_RADAR_COLOR_LOCAL_RESET="local-reset" + export GIT_RADAR_COLOR_REMOTE_RESET="remote-reset" + export GIT_RADAR_COLOR_CHANGES_RESET="change-reset" + + mock_zsh_colors + prepare_zsh_colors + + assertEquals "$COLOR_REMOTE_AHEAD" "%{remote-ahead%}" + assertEquals "$COLOR_REMOTE_BEHIND" "%{remote-behind%}" + assertEquals "$COLOR_REMOTE_DIVERGED" "%{remote-diverged%}" + assertEquals "$COLOR_REMOTE_NOT_UPSTREAM" "%{not-upstream%}" + + assertEquals "$COLOR_LOCAL_AHEAD" "%{local-ahead%}" + assertEquals "$COLOR_LOCAL_BEHIND" "%{local-behind%}" + assertEquals "$COLOR_LOCAL_DIVERGED" "%{local-diverged%}" + + assertEquals "$COLOR_CHANGES_STAGED" "%{changes-staged%}" + assertEquals "$COLOR_CHANGES_UNSTAGED" "%{changes-unstaged%}" + assertEquals "$COLOR_CHANGES_CONFLICTED" "%{changes-conflicted%}" + assertEquals "$COLOR_CHANGES_UNTRACKED" "%{changes-untracked%}" + + assertEquals "$RESET_COLOR_LOCAL" "%{local-reset%}" + assertEquals "$RESET_COLOR_REMOTE" "%{remote-reset%}" + assertEquals "$RESET_COLOR_CHANGES" "%{change-reset%}" +} + +. ./shunit/shunit2 -- cgit v1.2.3 From c2dbe6f579bac9b40482970287e6a58783994257 Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Sun, 30 Aug 2015 19:22:13 +0100 Subject: Test zsh local commit colors --- test-colors.sh | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'test-colors.sh') diff --git a/test-colors.sh b/test-colors.sh index 712dad5..efcdea9 100755 --- a/test-colors.sh +++ b/test-colors.sh @@ -45,7 +45,7 @@ test_no_rcfile_zsh() { assertEquals "$RESET_COLOR_CHANGES" "%{$reset_color%}" } -test_with_env_vars_zsh() { +set_zsh_env_vars() { export GIT_RADAR_COLOR_REMOTE_AHEAD="remote-ahead" export GIT_RADAR_COLOR_REMOTE_BEHIND="remote-behind" export GIT_RADAR_COLOR_REMOTE_DIVERGED="remote-diverged" @@ -63,7 +63,10 @@ test_with_env_vars_zsh() { export GIT_RADAR_COLOR_LOCAL_RESET="local-reset" export GIT_RADAR_COLOR_REMOTE_RESET="remote-reset" export GIT_RADAR_COLOR_CHANGES_RESET="change-reset" +} +test_with_env_vars_zsh() { + set_zsh_env_vars mock_zsh_colors prepare_zsh_colors @@ -86,4 +89,42 @@ test_with_env_vars_zsh() { assertEquals "$RESET_COLOR_CHANGES" "%{change-reset%}" } +test_zsh_colors_local() { + set_zsh_env_vars + prepare_zsh_colors + + cd_to_tmp "remote" + git init --bare --quiet + remoteLocation="$(pwd)" + + cd_to_tmp "repo" + git init --quiet + git remote add origin $remoteLocation + git fetch origin --quiet + git checkout -b master --quiet + touch README + git add README + git commit -m "initial commit" --quiet + git push --quiet -u origin master >/dev/null + repoLocation="$(pwd)" + + echo "foo" > foo + git add . + git commit -m "test commit" --quiet + + assertEquals " 1%{local-ahead%}↑%{local-reset%}" "$(zsh_color_local_commits)" + + git push --quiet >/dev/null + git reset --hard head^ --quiet >/dev/null + + assertEquals " 1%{local-behind%}↓%{local-reset%}" "$(zsh_color_local_commits)" + + echo "foo" > foo + git add . + git commit -m "new commit" --quiet + + assertEquals " 1%{local-diverged%}⇵%{local-reset%}1" "$(zsh_color_local_commits)" + + rm_tmp +} . ./shunit/shunit2 -- cgit v1.2.3 From e388db84ee99641a0260767ccdd4c889b7ca4f7d Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Sun, 30 Aug 2015 19:22:50 +0100 Subject: Test zsh remote commit colors --- test-colors.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'test-colors.sh') diff --git a/test-colors.sh b/test-colors.sh index efcdea9..6b8a797 100755 --- a/test-colors.sh +++ b/test-colors.sh @@ -127,4 +127,50 @@ test_zsh_colors_local() { rm_tmp } + +test_zsh_colors_remote() { + set_zsh_env_vars + prepare_zsh_colors + + cd_to_tmp "remote" + git init --bare --quiet + remoteLocation="$(pwd)" + + cd_to_tmp "repo" + git init --quiet + git remote add origin $remoteLocation + git fetch origin --quiet + git checkout -b master --quiet + touch README + git add README + git commit -m "initial commit" --quiet + echo "foo" > foo + git add . + git commit -m "test commit" --quiet + git push --quiet -u origin master >/dev/null + repoLocation="$(pwd)" + + git reset --hard head^ --quiet >/dev/null + git checkout -b mybranch --quiet + git push --quiet -u origin mybranch >/dev/null + + printf -v m '\xF0\x9D\x98\xAE' + + assertEquals "$m 1 %{remote-behind%}→%{remote-reset%} " "$(zsh_color_remote_commits)" + + echo "bar" > bar + git add . + git commit -m "new commit" --quiet + git push --quiet >/dev/null + + assertEquals "$m 1 %{remote-diverged%}⇄%{remote-reset%} 1 " "$(zsh_color_remote_commits)" + + git pull origin master --quiet >/dev/null + git push --quiet >/dev/null + + assertEquals "$m %{remote-ahead%}←%{remote-reset%} 2 " "$(zsh_color_remote_commits)" + + rm_tmp +} + . ./shunit/shunit2 -- cgit v1.2.3 From 8f62ad94da6058ac8f66a37caac518b643ccafe3 Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Sun, 30 Aug 2015 19:54:40 +0100 Subject: Test the zsh color changes configuration --- test-colors.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test-colors.sh') diff --git a/test-colors.sh b/test-colors.sh index 6b8a797..73aac53 100755 --- a/test-colors.sh +++ b/test-colors.sh @@ -173,4 +173,22 @@ test_zsh_colors_remote() { rm_tmp } +test_zsh_colors_changes() { + set_zsh_env_vars + prepare_zsh_colors + + cd_to_tmp + git init --quiet + + touch foo + touch bar + git add bar + echo "bar" > bar + untracked="1%{changes-untracked%}A%{change-reset%}" + unstaged="1%{changes-unstaged%}M%{change-reset%}" + staged="1%{changes-staged%}A%{change-reset%}" + + assertEquals " $staged $unstaged $untracked" "$(zsh_color_changes_status)" +} + . ./shunit/shunit2 -- cgit v1.2.3 From 5241c9fa41efbc96f333a6e220d3dc0d1c6fa676 Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Mon, 31 Aug 2015 00:12:39 +0100 Subject: Duplicate color tests for bash --- test-colors.sh | 176 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 176 insertions(+) (limited to 'test-colors.sh') diff --git a/test-colors.sh b/test-colors.sh index 73aac53..d602c61 100755 --- a/test-colors.sh +++ b/test-colors.sh @@ -22,6 +22,28 @@ mock_zsh_colors() { reset_color=0 } +test_no_rcfile_bash() { + prepare_bash_colors + + assertEquals "$COLOR_REMOTE_AHEAD" "\x01\033[1;32m\x02" + assertEquals "$COLOR_REMOTE_BEHIND" "\x01\033[1;31m\x02" + assertEquals "$COLOR_REMOTE_DIVERGED" "\x01\033[1;33m\x02" + assertEquals "$COLOR_REMOTE_NOT_UPSTREAM" "\x01\033[1;31m\x02" + + assertEquals "$COLOR_LOCAL_AHEAD" "\x01\033[1;32m\x02" + assertEquals "$COLOR_LOCAL_BEHIND" "\x01\033[1;31m\x02" + assertEquals "$COLOR_LOCAL_DIVERGED" "\x01\033[1;33m\x02" + + assertEquals "$COLOR_CHANGES_STAGED" "\x01\033[1;32m\x02" + assertEquals "$COLOR_CHANGES_UNSTAGED" "\x01\033[1;31m\x02" + assertEquals "$COLOR_CHANGES_CONFLICTED" "\x01\033[1;33m\x02" + assertEquals "$COLOR_CHANGES_UNTRACKED" "\x01\033[1;37m\x02" + + assertEquals "$RESET_COLOR_LOCAL" "\x01\033[0m\x02" + assertEquals "$RESET_COLOR_REMOTE" "\x01\033[0m\x02" + assertEquals "$RESET_COLOR_CHANGES" "\x01\033[0m\x02" +} + test_no_rcfile_zsh() { mock_zsh_colors prepare_zsh_colors @@ -45,6 +67,26 @@ test_no_rcfile_zsh() { assertEquals "$RESET_COLOR_CHANGES" "%{$reset_color%}" } +set_bash_env_vars() { + export GIT_RADAR_COLOR_REMOTE_AHEAD="remote-ahead" + export GIT_RADAR_COLOR_REMOTE_BEHIND="remote-behind" + export GIT_RADAR_COLOR_REMOTE_DIVERGED="remote-diverged" + export GIT_RADAR_COLOR_REMOTE_NOT_UPSTREAM="not-upstream" + + export GIT_RADAR_COLOR_LOCAL_AHEAD="local-ahead" + export GIT_RADAR_COLOR_LOCAL_BEHIND="local-behind" + export GIT_RADAR_COLOR_LOCAL_DIVERGED="local-diverged" + + export GIT_RADAR_COLOR_CHANGES_STAGED="changes-staged" + export GIT_RADAR_COLOR_CHANGES_UNSTAGED="changes-unstaged" + export GIT_RADAR_COLOR_CHANGES_CONFLICTED="changes-conflicted" + export GIT_RADAR_COLOR_CHANGES_UNTRACKED="changes-untracked" + + export GIT_RADAR_COLOR_LOCAL_RESET="local-reset" + export GIT_RADAR_COLOR_REMOTE_RESET="remote-reset" + export GIT_RADAR_COLOR_CHANGES_RESET="change-reset" +} + set_zsh_env_vars() { export GIT_RADAR_COLOR_REMOTE_AHEAD="remote-ahead" export GIT_RADAR_COLOR_REMOTE_BEHIND="remote-behind" @@ -65,6 +107,29 @@ set_zsh_env_vars() { export GIT_RADAR_COLOR_CHANGES_RESET="change-reset" } +test_with_env_vars_bash() { + set_bash_env_vars + prepare_bash_colors + + assertEquals "$COLOR_REMOTE_AHEAD" "\x01remote-ahead\x02" + assertEquals "$COLOR_REMOTE_BEHIND" "\x01remote-behind\x02" + assertEquals "$COLOR_REMOTE_DIVERGED" "\x01remote-diverged\x02" + assertEquals "$COLOR_REMOTE_NOT_UPSTREAM" "\x01not-upstream\x02" + + assertEquals "$COLOR_LOCAL_AHEAD" "\x01local-ahead\x02" + assertEquals "$COLOR_LOCAL_BEHIND" "\x01local-behind\x02" + assertEquals "$COLOR_LOCAL_DIVERGED" "\x01local-diverged\x02" + + assertEquals "$COLOR_CHANGES_STAGED" "\x01changes-staged\x02" + assertEquals "$COLOR_CHANGES_UNSTAGED" "\x01changes-unstaged\x02" + assertEquals "$COLOR_CHANGES_CONFLICTED" "\x01changes-conflicted\x02" + assertEquals "$COLOR_CHANGES_UNTRACKED" "\x01changes-untracked\x02" + + assertEquals "$RESET_COLOR_LOCAL" "\x01local-reset\x02" + assertEquals "$RESET_COLOR_REMOTE" "\x01remote-reset\x02" + assertEquals "$RESET_COLOR_CHANGES" "\x01change-reset\x02" +} + test_with_env_vars_zsh() { set_zsh_env_vars mock_zsh_colors @@ -89,6 +154,48 @@ test_with_env_vars_zsh() { assertEquals "$RESET_COLOR_CHANGES" "%{change-reset%}" } +test_bash_colors_local() { + set_bash_env_vars + prepare_bash_colors + + cd_to_tmp "remote" + git init --bare --quiet + remoteLocation="$(pwd)" + + cd_to_tmp "repo" + git init --quiet + git remote add origin $remoteLocation + git fetch origin --quiet + git checkout -b master --quiet + touch README + git add README + git commit -m "initial commit" --quiet + git push --quiet -u origin master >/dev/null + repoLocation="$(pwd)" + + echo "foo" > foo + git add . + git commit -m "test commit" --quiet + + printf -v expected " 1\x01local-ahead\x02↑\x01local-reset\x02" + assertEquals "$expected" "$(bash_color_local_commits)" + + git push --quiet >/dev/null + git reset --hard head^ --quiet >/dev/null + + printf -v expected " 1\x01local-behind\x02↓\x01local-reset\x02" + assertEquals "$expected" "$(bash_color_local_commits)" + + echo "foo" > foo + git add . + git commit -m "new commit" --quiet + + printf -v expected " 1\x01local-diverged\x02⇵\x01local-reset\x021" + assertEquals "$expected" "$(bash_color_local_commits)" + + rm_tmp +} + test_zsh_colors_local() { set_zsh_env_vars prepare_zsh_colors @@ -128,6 +235,54 @@ test_zsh_colors_local() { rm_tmp } +test_bash_colors_remote() { + set_bash_env_vars + prepare_bash_colors + + cd_to_tmp "remote" + git init --bare --quiet + remoteLocation="$(pwd)" + + cd_to_tmp "repo" + git init --quiet + git remote add origin $remoteLocation + git fetch origin --quiet + git checkout -b master --quiet + touch README + git add README + git commit -m "initial commit" --quiet + echo "foo" > foo + git add . + git commit -m "test commit" --quiet + git push --quiet -u origin master >/dev/null + repoLocation="$(pwd)" + + git reset --hard head^ --quiet >/dev/null + git checkout -b mybranch --quiet + git push --quiet -u origin mybranch >/dev/null + + printf -v m '\xF0\x9D\x98\xAE' + + printf -v expected "$m 1 \x01remote-behind\x02→\x01remote-reset\x02 " + assertEquals "$expected" "$(bash_color_remote_commits)" + + echo "bar" > bar + git add . + git commit -m "new commit" --quiet + git push --quiet >/dev/null + + printf -v expected "$m 1 \x01remote-diverged\x02⇄\x01remote-reset\x02 1 " + assertEquals "$expected" "$(bash_color_remote_commits)" + + git pull origin master --quiet >/dev/null + git push --quiet >/dev/null + + printf -v expected "$m \x01remote-ahead\x02←\x01remote-reset\x02 2 " + assertEquals "$expected" "$(bash_color_remote_commits)" + + rm_tmp +} + test_zsh_colors_remote() { set_zsh_env_vars prepare_zsh_colors @@ -173,6 +328,26 @@ test_zsh_colors_remote() { rm_tmp } +test_bash_colors_changes() { + set_bash_env_vars + prepare_bash_colors + + cd_to_tmp + git init --quiet + + touch foo + touch bar + git add bar + echo "bar" > bar + untracked="1\x01changes-untracked\x02A\x01change-reset\x02" + unstaged="1\x01changes-unstaged\x02M\x01change-reset\x02" + staged="1\x01changes-staged\x02A\x01change-reset\x02" + + printf -v expected " $staged $unstaged $untracked" + assertEquals "$expected" "$(bash_color_changes_status)" + rm_tmp +} + test_zsh_colors_changes() { set_zsh_env_vars prepare_zsh_colors @@ -189,6 +364,7 @@ test_zsh_colors_changes() { staged="1%{changes-staged%}A%{change-reset%}" assertEquals " $staged $unstaged $untracked" "$(zsh_color_changes_status)" + rm_tmp } . ./shunit/shunit2 -- cgit v1.2.3 From 3c500ca9fe517710d75d6d09084fa7038dea39db Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Mon, 31 Aug 2015 00:46:29 +0100 Subject: Provide a way to set a .gitradarrc file --- test-colors.sh | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) (limited to 'test-colors.sh') diff --git a/test-colors.sh b/test-colors.sh index d602c61..824e748 100755 --- a/test-colors.sh +++ b/test-colors.sh @@ -23,6 +23,7 @@ mock_zsh_colors() { } test_no_rcfile_bash() { + reset_env_vars prepare_bash_colors assertEquals "$COLOR_REMOTE_AHEAD" "\x01\033[1;32m\x02" @@ -45,6 +46,7 @@ test_no_rcfile_bash() { } test_no_rcfile_zsh() { + reset_env_vars mock_zsh_colors prepare_zsh_colors @@ -87,6 +89,26 @@ set_bash_env_vars() { export GIT_RADAR_COLOR_CHANGES_RESET="change-reset" } +reset_env_vars() { + export GIT_RADAR_COLOR_REMOTE_AHEAD="" + export GIT_RADAR_COLOR_REMOTE_BEHIND="" + export GIT_RADAR_COLOR_REMOTE_DIVERGED="" + export GIT_RADAR_COLOR_REMOTE_NOT_UPSTREAM="" + + export GIT_RADAR_COLOR_LOCAL_AHEAD="" + export GIT_RADAR_COLOR_LOCAL_BEHIND="" + export GIT_RADAR_COLOR_LOCAL_DIVERGED="" + + export GIT_RADAR_COLOR_CHANGES_STAGED="" + export GIT_RADAR_COLOR_CHANGES_UNSTAGED="" + export GIT_RADAR_COLOR_CHANGES_CONFLICTED="" + export GIT_RADAR_COLOR_CHANGES_UNTRACKED="" + + export GIT_RADAR_COLOR_LOCAL_RESET="" + export GIT_RADAR_COLOR_REMOTE_RESET="" + export GIT_RADAR_COLOR_CHANGES_RESET="" +} + set_zsh_env_vars() { export GIT_RADAR_COLOR_REMOTE_AHEAD="remote-ahead" export GIT_RADAR_COLOR_REMOTE_BEHIND="remote-behind" @@ -107,7 +129,89 @@ set_zsh_env_vars() { export GIT_RADAR_COLOR_CHANGES_RESET="change-reset" } +create_rc_file() { + echo 'GIT_RADAR_COLOR_REMOTE_AHEAD="remote-ahead"' >> .gitradarrc + echo 'GIT_RADAR_COLOR_REMOTE_BEHIND="remote-behind"' >> .gitradarrc + echo 'GIT_RADAR_COLOR_REMOTE_DIVERGED="remote-diverged"' >> .gitradarrc + echo 'GIT_RADAR_COLOR_REMOTE_NOT_UPSTREAM="not-upstream"' >> .gitradarrc + + echo 'GIT_RADAR_COLOR_LOCAL_AHEAD="local-ahead"' >> .gitradarrc + echo 'GIT_RADAR_COLOR_LOCAL_BEHIND="local-behind"' >> .gitradarrc + echo 'GIT_RADAR_COLOR_LOCAL_DIVERGED="local-diverged"' >> .gitradarrc + + echo 'GIT_RADAR_COLOR_CHANGES_STAGED="changes-staged"' >> .gitradarrc + echo 'GIT_RADAR_COLOR_CHANGES_UNSTAGED="changes-unstaged"' >> .gitradarrc + echo 'GIT_RADAR_COLOR_CHANGES_CONFLICTED="changes-conflicted"' >> .gitradarrc + echo 'GIT_RADAR_COLOR_CHANGES_UNTRACKED="changes-untracked"' >> .gitradarrc + + echo 'GIT_RADAR_COLOR_LOCAL_RESET="local-reset"' >> .gitradarrc + echo 'GIT_RADAR_COLOR_REMOTE_RESET="remote-reset"' >> .gitradarrc + echo 'GIT_RADAR_COLOR_CHANGES_RESET="change-reset"' >> .gitradarrc +} + +test_with_rcfile_bash() { + reset_env_vars + cd_to_tmp + + rcfile_path="$(pwd)" + + create_rc_file + prepare_bash_colors + + assertEquals "$COLOR_REMOTE_AHEAD" "\x01remote-ahead\x02" + assertEquals "$COLOR_REMOTE_BEHIND" "\x01remote-behind\x02" + assertEquals "$COLOR_REMOTE_DIVERGED" "\x01remote-diverged\x02" + assertEquals "$COLOR_REMOTE_NOT_UPSTREAM" "\x01not-upstream\x02" + + assertEquals "$COLOR_LOCAL_AHEAD" "\x01local-ahead\x02" + assertEquals "$COLOR_LOCAL_BEHIND" "\x01local-behind\x02" + assertEquals "$COLOR_LOCAL_DIVERGED" "\x01local-diverged\x02" + + assertEquals "$COLOR_CHANGES_STAGED" "\x01changes-staged\x02" + assertEquals "$COLOR_CHANGES_UNSTAGED" "\x01changes-unstaged\x02" + assertEquals "$COLOR_CHANGES_CONFLICTED" "\x01changes-conflicted\x02" + assertEquals "$COLOR_CHANGES_UNTRACKED" "\x01changes-untracked\x02" + + assertEquals "$RESET_COLOR_LOCAL" "\x01local-reset\x02" + assertEquals "$RESET_COLOR_REMOTE" "\x01remote-reset\x02" + assertEquals "$RESET_COLOR_CHANGES" "\x01change-reset\x02" + + rm_tmp +} + +test_with_rcfile_zsh() { + reset_env_vars + cd_to_tmp + + rcfile_path="$(pwd)" + + create_rc_file + mock_zsh_colors + prepare_zsh_colors + + assertEquals "$COLOR_REMOTE_AHEAD" "%{remote-ahead%}" + assertEquals "$COLOR_REMOTE_BEHIND" "%{remote-behind%}" + assertEquals "$COLOR_REMOTE_DIVERGED" "%{remote-diverged%}" + assertEquals "$COLOR_REMOTE_NOT_UPSTREAM" "%{not-upstream%}" + + assertEquals "$COLOR_LOCAL_AHEAD" "%{local-ahead%}" + assertEquals "$COLOR_LOCAL_BEHIND" "%{local-behind%}" + assertEquals "$COLOR_LOCAL_DIVERGED" "%{local-diverged%}" + + assertEquals "$COLOR_CHANGES_STAGED" "%{changes-staged%}" + assertEquals "$COLOR_CHANGES_UNSTAGED" "%{changes-unstaged%}" + assertEquals "$COLOR_CHANGES_CONFLICTED" "%{changes-conflicted%}" + assertEquals "$COLOR_CHANGES_UNTRACKED" "%{changes-untracked%}" + + assertEquals "$RESET_COLOR_LOCAL" "%{local-reset%}" + assertEquals "$RESET_COLOR_REMOTE" "%{remote-reset%}" + assertEquals "$RESET_COLOR_CHANGES" "%{change-reset%}" + + rm_tmp +} + test_with_env_vars_bash() { + reset_env_vars set_bash_env_vars prepare_bash_colors @@ -131,6 +235,7 @@ test_with_env_vars_bash() { } test_with_env_vars_zsh() { + reset_env_vars set_zsh_env_vars mock_zsh_colors prepare_zsh_colors @@ -155,6 +260,7 @@ test_with_env_vars_zsh() { } test_bash_colors_local() { + reset_env_vars set_bash_env_vars prepare_bash_colors @@ -197,6 +303,7 @@ test_bash_colors_local() { } test_zsh_colors_local() { + reset_env_vars set_zsh_env_vars prepare_zsh_colors @@ -236,6 +343,7 @@ test_zsh_colors_local() { } test_bash_colors_remote() { + reset_env_vars set_bash_env_vars prepare_bash_colors @@ -284,6 +392,7 @@ test_bash_colors_remote() { } test_zsh_colors_remote() { + reset_env_vars set_zsh_env_vars prepare_zsh_colors @@ -329,6 +438,7 @@ test_zsh_colors_remote() { } test_bash_colors_changes() { + reset_env_vars set_bash_env_vars prepare_bash_colors @@ -349,6 +459,7 @@ test_bash_colors_changes() { } test_zsh_colors_changes() { + reset_env_vars set_zsh_env_vars prepare_zsh_colors -- cgit v1.2.3 From 3a0ae9dbded9ebf1366f2580f1cbff6de1fc2340 Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Mon, 31 Aug 2015 00:56:53 +0100 Subject: Remove unneeded zsh specific env var setup --- test-colors.sh | 38 +++++++++----------------------------- 1 file changed, 9 insertions(+), 29 deletions(-) (limited to 'test-colors.sh') diff --git a/test-colors.sh b/test-colors.sh index 824e748..0506145 100755 --- a/test-colors.sh +++ b/test-colors.sh @@ -69,7 +69,7 @@ test_no_rcfile_zsh() { assertEquals "$RESET_COLOR_CHANGES" "%{$reset_color%}" } -set_bash_env_vars() { +set_env_vars() { export GIT_RADAR_COLOR_REMOTE_AHEAD="remote-ahead" export GIT_RADAR_COLOR_REMOTE_BEHIND="remote-behind" export GIT_RADAR_COLOR_REMOTE_DIVERGED="remote-diverged" @@ -109,26 +109,6 @@ reset_env_vars() { export GIT_RADAR_COLOR_CHANGES_RESET="" } -set_zsh_env_vars() { - export GIT_RADAR_COLOR_REMOTE_AHEAD="remote-ahead" - export GIT_RADAR_COLOR_REMOTE_BEHIND="remote-behind" - export GIT_RADAR_COLOR_REMOTE_DIVERGED="remote-diverged" - export GIT_RADAR_COLOR_REMOTE_NOT_UPSTREAM="not-upstream" - - export GIT_RADAR_COLOR_LOCAL_AHEAD="local-ahead" - export GIT_RADAR_COLOR_LOCAL_BEHIND="local-behind" - export GIT_RADAR_COLOR_LOCAL_DIVERGED="local-diverged" - - export GIT_RADAR_COLOR_CHANGES_STAGED="changes-staged" - export GIT_RADAR_COLOR_CHANGES_UNSTAGED="changes-unstaged" - export GIT_RADAR_COLOR_CHANGES_CONFLICTED="changes-conflicted" - export GIT_RADAR_COLOR_CHANGES_UNTRACKED="changes-untracked" - - export GIT_RADAR_COLOR_LOCAL_RESET="local-reset" - export GIT_RADAR_COLOR_REMOTE_RESET="remote-reset" - export GIT_RADAR_COLOR_CHANGES_RESET="change-reset" -} - create_rc_file() { echo 'GIT_RADAR_COLOR_REMOTE_AHEAD="remote-ahead"' >> .gitradarrc echo 'GIT_RADAR_COLOR_REMOTE_BEHIND="remote-behind"' >> .gitradarrc @@ -212,7 +192,7 @@ test_with_rcfile_zsh() { test_with_env_vars_bash() { reset_env_vars - set_bash_env_vars + set_env_vars prepare_bash_colors assertEquals "$COLOR_REMOTE_AHEAD" "\x01remote-ahead\x02" @@ -236,7 +216,7 @@ test_with_env_vars_bash() { test_with_env_vars_zsh() { reset_env_vars - set_zsh_env_vars + set_env_vars mock_zsh_colors prepare_zsh_colors @@ -261,7 +241,7 @@ test_with_env_vars_zsh() { test_bash_colors_local() { reset_env_vars - set_bash_env_vars + set_env_vars prepare_bash_colors cd_to_tmp "remote" @@ -304,7 +284,7 @@ test_bash_colors_local() { test_zsh_colors_local() { reset_env_vars - set_zsh_env_vars + set_env_vars prepare_zsh_colors cd_to_tmp "remote" @@ -344,7 +324,7 @@ test_zsh_colors_local() { test_bash_colors_remote() { reset_env_vars - set_bash_env_vars + set_env_vars prepare_bash_colors cd_to_tmp "remote" @@ -393,7 +373,7 @@ test_bash_colors_remote() { test_zsh_colors_remote() { reset_env_vars - set_zsh_env_vars + set_env_vars prepare_zsh_colors cd_to_tmp "remote" @@ -439,7 +419,7 @@ test_zsh_colors_remote() { test_bash_colors_changes() { reset_env_vars - set_bash_env_vars + set_env_vars prepare_bash_colors cd_to_tmp @@ -460,7 +440,7 @@ test_bash_colors_changes() { test_zsh_colors_changes() { reset_env_vars - set_zsh_env_vars + set_env_vars prepare_zsh_colors cd_to_tmp -- cgit v1.2.3 From 1342bd1e5fbef270db72f302bd6c380a7fec29ac Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Tue, 1 Sep 2015 13:40:03 +0100 Subject: Make branch color and master symbol configurable --- test-colors.sh | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) (limited to 'test-colors.sh') diff --git a/test-colors.sh b/test-colors.sh index 0506145..196b60b 100755 --- a/test-colors.sh +++ b/test-colors.sh @@ -84,9 +84,13 @@ set_env_vars() { export GIT_RADAR_COLOR_CHANGES_CONFLICTED="changes-conflicted" export GIT_RADAR_COLOR_CHANGES_UNTRACKED="changes-untracked" + export GIT_RADAR_COLOR_BRANCH="branch-color" + export GIT_RADAR_MASTER_SYMBOL="m" + export GIT_RADAR_COLOR_LOCAL_RESET="local-reset" export GIT_RADAR_COLOR_REMOTE_RESET="remote-reset" export GIT_RADAR_COLOR_CHANGES_RESET="change-reset" + export GIT_RADAR_COLOR_BRANCH_RESET="branch-reset" } reset_env_vars() { @@ -104,9 +108,13 @@ reset_env_vars() { export GIT_RADAR_COLOR_CHANGES_CONFLICTED="" export GIT_RADAR_COLOR_CHANGES_UNTRACKED="" + export GIT_RADAR_COLOR_BRANCH="" + export GIT_RADAR_MASTER_SYMBOL="" + export GIT_RADAR_COLOR_LOCAL_RESET="" export GIT_RADAR_COLOR_REMOTE_RESET="" export GIT_RADAR_COLOR_CHANGES_RESET="" + export GIT_RADAR_COLOR_BRANCH_RESET="" } create_rc_file() { @@ -124,9 +132,13 @@ create_rc_file() { echo 'GIT_RADAR_COLOR_CHANGES_CONFLICTED="changes-conflicted"' >> .gitradarrc echo 'GIT_RADAR_COLOR_CHANGES_UNTRACKED="changes-untracked"' >> .gitradarrc + echo 'export GIT_RADAR_COLOR_BRANCH="branch-color"' >> .gitradarrc + echo 'export GIT_RADAR_MASTER_SYMBOL="m"' >> .gitradarrc + echo 'GIT_RADAR_COLOR_LOCAL_RESET="local-reset"' >> .gitradarrc echo 'GIT_RADAR_COLOR_REMOTE_RESET="remote-reset"' >> .gitradarrc echo 'GIT_RADAR_COLOR_CHANGES_RESET="change-reset"' >> .gitradarrc + echo 'GIT_RADAR_COLOR_BRANCH_RESET="branch-reset"' >> .gitradarrc } test_with_rcfile_bash() { @@ -152,9 +164,13 @@ test_with_rcfile_bash() { assertEquals "$COLOR_CHANGES_CONFLICTED" "\x01changes-conflicted\x02" assertEquals "$COLOR_CHANGES_UNTRACKED" "\x01changes-untracked\x02" + assertEquals "$COLOR_BRANCH" "\x01branch-color\x02" + assertEquals "$MASTER_SYMBOL" "m" + assertEquals "$RESET_COLOR_LOCAL" "\x01local-reset\x02" assertEquals "$RESET_COLOR_REMOTE" "\x01remote-reset\x02" assertEquals "$RESET_COLOR_CHANGES" "\x01change-reset\x02" + assertEquals "$RESET_COLOR_BRANCH" "\x01branch-reset\x02" rm_tmp } @@ -183,9 +199,13 @@ test_with_rcfile_zsh() { assertEquals "$COLOR_CHANGES_CONFLICTED" "%{changes-conflicted%}" assertEquals "$COLOR_CHANGES_UNTRACKED" "%{changes-untracked%}" + assertEquals "$COLOR_BRANCH" "%{branch-color%}" + assertEquals "$MASTER_SYMBOL" "m" + assertEquals "$RESET_COLOR_LOCAL" "%{local-reset%}" assertEquals "$RESET_COLOR_REMOTE" "%{remote-reset%}" assertEquals "$RESET_COLOR_CHANGES" "%{change-reset%}" + assertEquals "$RESET_COLOR_BRANCH" "%{branch-reset%}" rm_tmp } @@ -209,9 +229,13 @@ test_with_env_vars_bash() { assertEquals "$COLOR_CHANGES_CONFLICTED" "\x01changes-conflicted\x02" assertEquals "$COLOR_CHANGES_UNTRACKED" "\x01changes-untracked\x02" + assertEquals "$COLOR_BRANCH" "\x01branch-color\x02" + assertEquals "$MASTER_SYMBOL" "m" + assertEquals "$RESET_COLOR_LOCAL" "\x01local-reset\x02" assertEquals "$RESET_COLOR_REMOTE" "\x01remote-reset\x02" assertEquals "$RESET_COLOR_CHANGES" "\x01change-reset\x02" + assertEquals "$RESET_COLOR_BRANCH" "\x01branch-reset\x02" } test_with_env_vars_zsh() { @@ -234,9 +258,13 @@ test_with_env_vars_zsh() { assertEquals "$COLOR_CHANGES_CONFLICTED" "%{changes-conflicted%}" assertEquals "$COLOR_CHANGES_UNTRACKED" "%{changes-untracked%}" + assertEquals "$COLOR_BRANCH" "%{branch-color%}" + assertEquals "$MASTER_SYMBOL" "m" + assertEquals "$RESET_COLOR_LOCAL" "%{local-reset%}" assertEquals "$RESET_COLOR_REMOTE" "%{remote-reset%}" assertEquals "$RESET_COLOR_CHANGES" "%{change-reset%}" + assertEquals "$RESET_COLOR_BRANCH" "%{branch-reset%}" } test_bash_colors_local() { @@ -349,9 +377,7 @@ test_bash_colors_remote() { git checkout -b mybranch --quiet git push --quiet -u origin mybranch >/dev/null - printf -v m '\xF0\x9D\x98\xAE' - - printf -v expected "$m 1 \x01remote-behind\x02→\x01remote-reset\x02 " + printf -v expected "m 1 \x01remote-behind\x02→\x01remote-reset\x02 " assertEquals "$expected" "$(bash_color_remote_commits)" echo "bar" > bar @@ -359,13 +385,13 @@ test_bash_colors_remote() { git commit -m "new commit" --quiet git push --quiet >/dev/null - printf -v expected "$m 1 \x01remote-diverged\x02⇄\x01remote-reset\x02 1 " + printf -v expected "m 1 \x01remote-diverged\x02⇄\x01remote-reset\x02 1 " assertEquals "$expected" "$(bash_color_remote_commits)" git pull origin master --quiet >/dev/null git push --quiet >/dev/null - printf -v expected "$m \x01remote-ahead\x02←\x01remote-reset\x02 2 " + printf -v expected "m \x01remote-ahead\x02←\x01remote-reset\x02 2 " assertEquals "$expected" "$(bash_color_remote_commits)" rm_tmp @@ -398,21 +424,19 @@ test_zsh_colors_remote() { git checkout -b mybranch --quiet git push --quiet -u origin mybranch >/dev/null - printf -v m '\xF0\x9D\x98\xAE' - - assertEquals "$m 1 %{remote-behind%}→%{remote-reset%} " "$(zsh_color_remote_commits)" + assertEquals "m 1 %{remote-behind%}→%{remote-reset%} " "$(zsh_color_remote_commits)" echo "bar" > bar git add . git commit -m "new commit" --quiet git push --quiet >/dev/null - assertEquals "$m 1 %{remote-diverged%}⇄%{remote-reset%} 1 " "$(zsh_color_remote_commits)" + assertEquals "m 1 %{remote-diverged%}⇄%{remote-reset%} 1 " "$(zsh_color_remote_commits)" git pull origin master --quiet >/dev/null git push --quiet >/dev/null - assertEquals "$m %{remote-ahead%}←%{remote-reset%} 2 " "$(zsh_color_remote_commits)" + assertEquals "m %{remote-ahead%}←%{remote-reset%} 2 " "$(zsh_color_remote_commits)" rm_tmp } -- cgit v1.2.3 From 393013fba5bc7ec3402de4c1b2faf47dd7493c59 Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Wed, 2 Sep 2015 17:42:17 +0100 Subject: Allow for shell specific rc files --- test-colors.sh | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'test-colors.sh') diff --git a/test-colors.sh b/test-colors.sh index 196b60b..59a8704 100755 --- a/test-colors.sh +++ b/test-colors.sh @@ -118,27 +118,27 @@ reset_env_vars() { } create_rc_file() { - echo 'GIT_RADAR_COLOR_REMOTE_AHEAD="remote-ahead"' >> .gitradarrc - echo 'GIT_RADAR_COLOR_REMOTE_BEHIND="remote-behind"' >> .gitradarrc - echo 'GIT_RADAR_COLOR_REMOTE_DIVERGED="remote-diverged"' >> .gitradarrc - echo 'GIT_RADAR_COLOR_REMOTE_NOT_UPSTREAM="not-upstream"' >> .gitradarrc - - echo 'GIT_RADAR_COLOR_LOCAL_AHEAD="local-ahead"' >> .gitradarrc - echo 'GIT_RADAR_COLOR_LOCAL_BEHIND="local-behind"' >> .gitradarrc - echo 'GIT_RADAR_COLOR_LOCAL_DIVERGED="local-diverged"' >> .gitradarrc - - echo 'GIT_RADAR_COLOR_CHANGES_STAGED="changes-staged"' >> .gitradarrc - echo 'GIT_RADAR_COLOR_CHANGES_UNSTAGED="changes-unstaged"' >> .gitradarrc - echo 'GIT_RADAR_COLOR_CHANGES_CONFLICTED="changes-conflicted"' >> .gitradarrc - echo 'GIT_RADAR_COLOR_CHANGES_UNTRACKED="changes-untracked"' >> .gitradarrc - - echo 'export GIT_RADAR_COLOR_BRANCH="branch-color"' >> .gitradarrc - echo 'export GIT_RADAR_MASTER_SYMBOL="m"' >> .gitradarrc - - echo 'GIT_RADAR_COLOR_LOCAL_RESET="local-reset"' >> .gitradarrc - echo 'GIT_RADAR_COLOR_REMOTE_RESET="remote-reset"' >> .gitradarrc - echo 'GIT_RADAR_COLOR_CHANGES_RESET="change-reset"' >> .gitradarrc - echo 'GIT_RADAR_COLOR_BRANCH_RESET="branch-reset"' >> .gitradarrc + echo 'GIT_RADAR_COLOR_REMOTE_AHEAD="remote-ahead"' >> .gitradarrc$1 + echo 'GIT_RADAR_COLOR_REMOTE_BEHIND="remote-behind"' >> .gitradarrc$1 + echo 'GIT_RADAR_COLOR_REMOTE_DIVERGED="remote-diverged"' >> .gitradarrc$1 + echo 'GIT_RADAR_COLOR_REMOTE_NOT_UPSTREAM="not-upstream"' >> .gitradarrc$1 + + echo 'GIT_RADAR_COLOR_LOCAL_AHEAD="local-ahead"' >> .gitradarrc$1 + echo 'GIT_RADAR_COLOR_LOCAL_BEHIND="local-behind"' >> .gitradarrc$1 + echo 'GIT_RADAR_COLOR_LOCAL_DIVERGED="local-diverged"' >> .gitradarrc$1 + + echo 'GIT_RADAR_COLOR_CHANGES_STAGED="changes-staged"' >> .gitradarrc$1 + echo 'GIT_RADAR_COLOR_CHANGES_UNSTAGED="changes-unstaged"' >> .gitradarrc$1 + echo 'GIT_RADAR_COLOR_CHANGES_CONFLICTED="changes-conflicted"' >> .gitradarrc$1 + echo 'GIT_RADAR_COLOR_CHANGES_UNTRACKED="changes-untracked"' >> .gitradarrc$1 + + echo 'export GIT_RADAR_COLOR_BRANCH="branch-color"' >> .gitradarrc$1 + echo 'export GIT_RADAR_MASTER_SYMBOL="m"' >> .gitradarrc$1 + + echo 'GIT_RADAR_COLOR_LOCAL_RESET="local-reset"' >> .gitradarrc$1 + echo 'GIT_RADAR_COLOR_REMOTE_RESET="remote-reset"' >> .gitradarrc$1 + echo 'GIT_RADAR_COLOR_CHANGES_RESET="change-reset"' >> .gitradarrc$1 + echo 'GIT_RADAR_COLOR_BRANCH_RESET="branch-reset"' >> .gitradarrc$1 } test_with_rcfile_bash() { @@ -147,7 +147,7 @@ test_with_rcfile_bash() { rcfile_path="$(pwd)" - create_rc_file + create_rc_file ".bash" prepare_bash_colors assertEquals "$COLOR_REMOTE_AHEAD" "\x01remote-ahead\x02" @@ -181,7 +181,7 @@ test_with_rcfile_zsh() { rcfile_path="$(pwd)" - create_rc_file + create_rc_file ".zsh" mock_zsh_colors prepare_zsh_colors -- cgit v1.2.3