Update tests to use test-chmtime
test-lib: Make sure test-chmtime has been built before starting. t4200-rerere: Removed non-portable date dependency and avoid touch Avoid "test -a" which isn't portable, either lib-git-svn: Use test-chmtime instead of Perl one-liner to poke Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
Eric Wong committed
Feb 24, 2007 at 16:59 UTC
56cf9806a97f5fe9a91c38aa3eb8cec0c76480e6
3 files changed
+27
-34
t/lib-git-svn.sh
+1
-1
@@ -46,5 +46,5 @@ rawsvnrepo="$svnrepo"
46
svnrepo="file://$svnrepo"
47
48
poke() {
49
- perl -e '@x = stat($ARGV[0]); utime($x[8], $x[9] + 1, $ARGV[0])' "$1"
49
+ test-chmtime +1 "$1"
50
}
t/t4200-rerere.sh
+20
-33
@@ -112,39 +112,26 @@ rr2=.git/rr-cache/$sha2
112
mkdir $rr2
113
echo Hello > $rr2/preimage
114
115
-case "$(date -d @11111111 +%s 2>/dev/null)" in
116
-11111111)
117
- # 'date' must be able to take arbitrary input with @11111111 notation.
118
- # for this test to succeed. We should fix this part using more
119
- # portable script someday.
120
-
121
- now=$(date +%s)
122
- almost_15_days_ago=$(($now+60-15*86400))
123
- just_over_15_days_ago=$(($now-1-15*86400))
124
- almost_60_days_ago=$(($now+60-60*86400))
125
- just_over_60_days_ago=$(($now-1-60*86400))
126
- predate1="$(date -d "@$almost_60_days_ago" +%Y%m%d%H%M.%S)"
127
- predate2="$(date -d "@$almost_15_days_ago" +%Y%m%d%H%M.%S)"
128
- postdate1="$(date -d "@$just_over_60_days_ago" +%Y%m%d%H%M.%S)"
129
- postdate2="$(date -d "@$just_over_15_days_ago" +%Y%m%d%H%M.%S)"
130
-
131
- touch -m -t "$predate1" $rr/preimage
132
- touch -m -t "$predate2" $rr2/preimage
133
-
134
- test_expect_success 'garbage collection (part1)' 'git rerere gc'
135
-
136
- test_expect_success 'young records still live' \
137
- "test -f $rr/preimage -a -f $rr2/preimage"
138
-
139
- touch -m -t "$postdate1" $rr/preimage
140
- touch -m -t "$postdate2" $rr2/preimage
141
-
142
- test_expect_success 'garbage collection (part2)' 'git rerere gc'
143
-
144
- test_expect_success 'old records rest in peace' \
145
- "test ! -f $rr/preimage -a ! -f $rr2/preimage"
146
- ;;
147
-esac
115
+almost_15_days_ago=$((60-15*86400))
116
+just_over_15_days_ago=$((-1-15*86400))
117
+almost_60_days_ago=$((60-60*86400))
118
+just_over_60_days_ago=$((-1-60*86400))
119
+
120
+test-chmtime =$almost_60_days_ago $rr/preimage
121
+test-chmtime =$almost_15_days_ago $rr2/preimage
122
+
123
+test_expect_success 'garbage collection (part1)' 'git rerere gc'
124
+
125
+test_expect_success 'young records still live' \
126
+ "test -f $rr/preimage && test -f $rr2/preimage"
127
+
128
+test-chmtime =$just_over_60_days_ago $rr/preimage
129
+test-chmtime =$just_over_15_days_ago $rr2/preimage
130
+
131
+test_expect_success 'garbage collection (part2)' 'git rerere gc'
132
+
133
+test_expect_success 'old records rest in peace' \
134
+ "test ! -f $rr/preimage && test ! -f $rr2/preimage"
135
136
test_done
137
t/test-lib.sh
+6
@@ -264,6 +264,12 @@ test -d ../templates/blt || {
264
error "You haven't built things yet, have you?"
265
}
266
267
+if ! test -x ../test-chmtime; then
268
+ echo >&2 'You need to build test-chmtime:'
269
+ echo >&2 'Run "make test-chmtime" in the source (toplevel) directory'
270
+ exit 1
271
+fi
272
+
273
# Test repository
274
test=trash
275
rm -fr "$test"