Skip to content

Commit

Permalink
Fixed unittests for Ubuntu
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudio Bandera committed Aug 30, 2015
1 parent da76c7d commit 2dbf0c2
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 33 deletions.
2 changes: 1 addition & 1 deletion radar-base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ record_timestamp() {

timestamp() {
if is_repo; then
printf '%s' "$(stat -f%m "$(dot_git)/lastupdatetime" 2>/dev/null || printf '%s' "0")"
printf '%s' "$(stat -c %Y "$(dot_git)/lastupdatetime" 2>/dev/null || printf '%s' "0")"
fi
}

Expand Down
3 changes: 2 additions & 1 deletion test-branches.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
scriptDir="$(cd "$(dirname "$0")"; pwd)"

source "$scriptDir/radar-base.sh"
Expand Down Expand Up @@ -94,7 +95,7 @@ test_remote_branch_name_quiet_when_not_in_repo() {

echo "$debug_output"

assertEquals " 0" "$usages"
assertEquals "0" "$usages"

rm_tmp
}
Expand Down
8 changes: 3 additions & 5 deletions test-commits.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
scriptDir="$(cd "$(dirname "$0")"; pwd)"

source "$scriptDir/radar-base.sh"
Expand All @@ -14,7 +15,6 @@ rm_tmp() {
cd $scriptDir
rm -rf /tmp/git-prompt-tests*
}

test_commits_with_no_commits() {
cd_to_tmp
git init --quiet
Expand Down Expand Up @@ -222,7 +222,6 @@ test_remote_branch_starts_with_local_branch_name() {

rm_tmp
}

test_remote_branch_ends_with_local_branch_name() {
cd_to_tmp "remote"
git init --bare --quiet
Expand Down Expand Up @@ -297,11 +296,10 @@ 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"
assertEquals "0" "$usages"

rm_tmp
}

test_dont_remote_if_remote_is_master() {
cd_to_tmp
git init --quiet
Expand All @@ -322,7 +320,7 @@ test_dont_remote_if_remote_is_master() {

usages="$(echo "$debug_output" | grep 'git rev-list' | wc -l )"

assertEquals " 0" "$usages"
assertEquals "0" "$usages"

rm_tmp
}
Expand Down
4 changes: 3 additions & 1 deletion test-directories.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
scriptDir="$(cd "$(dirname "$0")"; pwd)"

source "$scriptDir/radar-base.sh"
Expand Down Expand Up @@ -63,7 +64,8 @@ test_record_timestamp_in_repo() {

test_time_to_update_when_timestamp_is_old() {
cd $scriptDir
touch -A "-010000" "$(dot_git)/lastupdatetime"
newtimestamp=$(date -d "now -1 hour" +%Y%m%d%H%M)
touch -t $newtimestamp "$(dot_git)/lastupdatetime"
assertTrue time_to_update
}

Expand Down
51 changes: 26 additions & 25 deletions test-files.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
scriptDir="$(cd "$(dirname "$0")"; pwd)"

source "$scriptDir/radar-base.sh"
Expand All @@ -24,7 +25,7 @@ test_untracked_files() {
touch foo
assertEquals "1A" "$(untracked_status)"

git add .
git add --all
assertEquals "" "$(untracked_status)"

rm_tmp
Expand All @@ -38,7 +39,7 @@ test_unstaged_modified_files() {

touch foo
touch bar
git add .
git add --all
git commit -m "foo and bar" >/dev/null

echo "foo" >> foo
Expand All @@ -58,7 +59,7 @@ test_unstaged_deleted_files() {

touch foo
touch bar
git add .
git add --all
git commit -m "foo and bar" >/dev/null

rm foo
Expand All @@ -77,11 +78,11 @@ test_staged_added_files() {
assertEquals "" "$(staged_status)"

touch foo
git add .
git add --all
assertEquals "1A" "$(staged_status)"

touch bar
git add .
git add --all
assertEquals "2A" "$(staged_status)"

rm_tmp
Expand All @@ -95,15 +96,15 @@ test_staged_modified_files() {

touch foo
touch bar
git add .
git add --all
git commit -m "foo and bar" >/dev/null

echo "foo" >> foo
git add .
git add --all
assertEquals "1M" "$(staged_status)"

echo "bar" >> bar
git add .
git add --all
assertEquals "2M" "$(staged_status)"

rm_tmp
Expand All @@ -117,15 +118,15 @@ test_staged_deleted_files() {

touch foo
touch bar
git add .
git add --all
git commit -m "foo and bar" >/dev/null

rm foo
git add .
git add --all
assertEquals "1D" "$(staged_status)"

rm bar
git add .
git add --all
assertEquals "2D" "$(staged_status)"

rm_tmp
Expand All @@ -139,15 +140,15 @@ test_staged_renamed_files() {

touch foo
touch bar
git add .
git add --all
git commit -m "foo and bar" >/dev/null

mv foo foo2
git add .
git add --all
assertEquals "1R" "$(staged_status)"

mv bar bar2
git add .
git add --all
assertEquals "2R" "$(staged_status)"

rm_tmp
Expand All @@ -159,17 +160,17 @@ test_conflicted_both_changes() {

git checkout -b foo --quiet
echo "foo" >> foo
git add .
git add --all
git commit -m "foo" --quiet

git checkout -b foo2 --quiet
echo "bar" >> foo
git add .
git add --all
git commit -m "bar" --quiet

git checkout foo --quiet
echo "foo2" >> foo
git add .
git add --all
git commit -m "foo2" --quiet

assertEquals "" "$(conflicted_status)"
Expand All @@ -187,17 +188,17 @@ test_conflicted_them_changes() {

git checkout -b foo --quiet
echo "foo" >> foo
git add .
git add --all
git commit -m "foo" --quiet

git checkout -b foo2 --quiet
rm foo
git add .
git add --all
git commit -m "delete foo" --quiet

git checkout foo --quiet
echo "foo2" >> foo
git add .
git add --all
git commit -m "foo2" --quiet

assertEquals "" "$(conflicted_status)"
Expand All @@ -215,17 +216,17 @@ test_conflicted_us_changes() {

git checkout -b foo --quiet
echo "foo" >> foo
git add .
git add --all
git commit -m "foo" --quiet

git checkout -b foo2 --quiet
echo "bar" >> foo
git add .
git add --all
git commit -m "bar" --quiet

git checkout foo --quiet
rm foo
git add .
git add --all
git commit -m "delete foo" --quiet

assertEquals "" "$(conflicted_status)"
Expand Down Expand Up @@ -254,7 +255,7 @@ test_is_dirty() {

cd ../

git add .
git add --all
assertTrue "staged addition files" is_dirty

git commit -m "inital commit" --quiet
Expand All @@ -264,7 +265,7 @@ test_is_dirty() {
echo "foo" >> foo
assertTrue "modified file unstaged" is_dirty

git add .
git add --all
assertTrue "modified file staged" is_dirty

rm_tmp
Expand Down
1 change: 1 addition & 0 deletions test-status.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
scriptDir="$(cd "$(dirname "$0")"; pwd)"

source "$scriptDir/radar-base.sh"
Expand Down

0 comments on commit 2dbf0c2

Please sign in to comment.