summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaudio Bandera <claudio.bandera@kit.edu>2015-09-17 20:35:34 +0200
committerClaudio Bandera <claudio.bandera@kit.edu>2015-09-17 20:35:34 +0200
commite692cbc483f8ee4b4666143fe1b3cfbd86e7681f (patch)
tree7a34df331cf3495d585ab94080a953b66e823efe
parent92c2e869763dcc25c840c2e6cfcd9863abf201dd (diff)
downloadgit-sonar-e692cbc483f8ee4b4666143fe1b3cfbd86e7681f.tar.gz
git-sonar-e692cbc483f8ee4b4666143fe1b3cfbd86e7681f.zip
Added switch case for OS type in tests
-rwxr-xr-xtest-branches.sh9
-rwxr-xr-xtest-colors.sh11
-rwxr-xr-xtest-commits.sh14
-rwxr-xr-xtest-directories.sh8
4 files changed, 31 insertions, 11 deletions
diff --git a/test-branches.sh b/test-branches.sh
index b3f0ac2..891a819 100755
--- a/test-branches.sh
+++ b/test-branches.sh
@@ -97,8 +97,13 @@ test_remote_branch_name_quiet_when_not_in_repo() {
echo "$debug_output"
- assertEquals "0" "$usages"
-
+ if [[ $OSTYPE == darwin* ]];then
+ expected=" 0"
+ else
+ expected="0"
+ fi;
+ assertEquals "$expected" "$usages"
+
rm_tmp
}
diff --git a/test-colors.sh b/test-colors.sh
index 73c20f7..116e09d 100755
--- a/test-colors.sh
+++ b/test-colors.sh
@@ -1,3 +1,4 @@
+#!/bin/bash
scriptDir="$(cd "$(dirname "$0")"; pwd)"
source "$scriptDir/radar-base.sh"
@@ -296,7 +297,7 @@ test_bash_colors_local() {
assertEquals "$expected" "$(color_local_commits)"
git push --quiet >/dev/null
- git reset --hard head^ --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)"
@@ -340,7 +341,7 @@ test_zsh_colors_local() {
assertEquals " 1%{local-ahead%}↑%{local-reset%}" "$(zsh_color_local_commits)"
git push --quiet >/dev/null
- git reset --hard head^ --quiet >/dev/null
+ git reset --hard HEAD^ --quiet >/dev/null
assertEquals " 1%{local-behind%}↓%{local-reset%}" "$(zsh_color_local_commits)"
@@ -376,7 +377,7 @@ test_bash_colors_remote() {
git push --quiet -u origin master >/dev/null
repoLocation="$(pwd)"
- git reset --hard head^ --quiet >/dev/null
+ git reset --hard HEAD^ --quiet >/dev/null
git checkout -b mybranch --quiet
git push --quiet -u origin mybranch >/dev/null
@@ -387,7 +388,7 @@ test_bash_colors_remote() {
echo "bar" > bar
git add .
git commit -m "new commit" --quiet
- git push --quiet >/dev/null
+ git push --quiet origin mybranch >/dev/null
printf -v expected "m 1 \x01remote-diverged\x02⇄\x01remote-reset\x02 1 "
assertEquals "$expected" "$(bash_color_remote_commits)"
@@ -426,7 +427,7 @@ test_zsh_colors_remote() {
git push --quiet -u origin master >/dev/null
repoLocation="$(pwd)"
- git reset --hard head^ --quiet >/dev/null
+ git reset --hard HEAD^ --quiet >/dev/null
git checkout -b mybranch --quiet
git push --quiet -u origin mybranch >/dev/null
diff --git a/test-commits.sh b/test-commits.sh
index 8eecffc..c97c56a 100755
--- a/test-commits.sh
+++ b/test-commits.sh
@@ -296,7 +296,12 @@ test_dont_call_remote_branch_name() {
usages="$(echo "$debug_output" | grep 'remote_branch_name' | wc -l )"
#wc -l has a weird output
- assertEquals "0" "$usages"
+ if [[ $OSTYPE == darwin* ]];then
+ expected=" 0"
+ else
+ expected="0"
+ fi;
+ assertEquals "$expected" "$usages"
rm_tmp
}
@@ -320,7 +325,12 @@ test_dont_remote_if_remote_is_master() {
usages="$(echo "$debug_output" | grep 'git rev-list' | wc -l )"
- assertEquals "0" "$usages"
+ if [[ $OSTYPE == darwin* ]];then
+ expected=" 0"
+ else
+ expected="0"
+ fi;
+ assertEquals "$expected" "$usages"
rm_tmp
}
diff --git a/test-directories.sh b/test-directories.sh
index 83c408f..1777e69 100755
--- a/test-directories.sh
+++ b/test-directories.sh
@@ -64,8 +64,12 @@ test_record_timestamp_in_repo() {
test_time_to_update_when_timestamp_is_old() {
cd $scriptDir
- newtimestamp=$(date -d "now -1 hour" +%Y%m%d%H%M)
- touch -t $newtimestamp "$(dot_git)/lastupdatetime"
+ if [[ $OSTYPE == darwin* ]];then
+ touch -A "-010000" "$(dot_git)/lastupdatetime"
+ else
+ newtimestamp=$(date -d "now -1 hour" +%Y%m%d%H%M)
+ touch -t $newtimestamp "$(dot_git)/lastupdatetime"
+ fi;
assertTrue time_to_update
}