aboutsummaryrefslogtreecommitdiff
path: root/t/lib-t6000.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-06-21 10:29:59 -0700
committerJunio C Hamano <gitster@pobox.com>2013-06-21 11:15:32 -0700
commit841dc6935ea0f2ecfc778501edc66dc2c828d333 (patch)
treea3fe8a66cd3db9d4dfbaaac651affff412fc69f9 /t/lib-t6000.sh
parent50e5a252225137f0fbb18a0ff72a0ae052e09d24 (diff)
downloadgit-841dc6935ea0f2ecfc778501edc66dc2c828d333.tar.gz
git-841dc6935ea0f2ecfc778501edc66dc2c828d333.tar.xz
topology tests: teach a helper to take abbreviated timestamps
The on_committer_date helper in t/lib-t6000 is used in t6002 and t6003 with timestamps on a single day within a single minute (i.e. 1971-08-16 00:00) and the tests repeat this over and over. The actual value of the timestamp, however, does not matter very much; only their relative ordering does. Introduce another helper to expand only the suffix of the timestamp to a full timestamp to make the lines shorter, and use it in this helper. Also, because all the commits in the test are made with specific GIT_COMMITTER_DATE, stop unsetting it at the end of the helper. We'll be specifying the author timestamp to these test commits in a later patch, which will be helped with this change. Also remove a test that was commented-out from t6003; it used to test a commit with the same parent listed twice, which was allowed by mistake but was fixed long time ago. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/lib-t6000.sh')
-rw-r--r--t/lib-t6000.sh17
1 files changed, 13 insertions, 4 deletions
diff --git a/t/lib-t6000.sh b/t/lib-t6000.sh
index 102d56781..e2c361563 100644
--- a/t/lib-t6000.sh
+++ b/t/lib-t6000.sh
@@ -64,13 +64,22 @@ commit_date () {
sed -n "s/^committer .*> \([0-9]*\) .*/\1/p"
}
+# Assign the value of fake date to a variable, but
+# allow fairly common "1971-08-16 00:00" to be omittd
+assign_fake_date () {
+ case "$2" in
+ ??:??:??) eval "$1='1971-08-16 $2'" ;;
+ ??:??) eval "$1='1971-08-16 00:$2'" ;;
+ ??) eval "$1='1971-08-16 00:00:$2'" ;;
+ *) eval "$1='$2'" ;;
+ esac
+}
+
on_committer_date () {
- _date=$1
- shift 1
- GIT_COMMITTER_DATE="$_date"
+ assign_fake_date GIT_COMMITTER_DATE "$1"
export GIT_COMMITTER_DATE
+ shift 1
"$@"
- unset GIT_COMMITTER_DATE
}
# Execute a command and suppress any error output.