t4205 (log-pretty-formats): avoid using `sed`
For testing truncated log messages 'commit_msg' function uses `sed` to cut a message. On various platforms `sed` behaves differently and results of its work depend on locales installed. So, avoid using `sed`. Use predefined expected outputs instead of calculated ones. Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Alexey Shumkin committed
Jul 5, 2013 at 16:01 UTC
37eb772ef3a5da0b28d3759373d714b349306ea4
1 file changed
+10
-16
t/t4205-log-pretty-formats.sh
+10
-16
@@ -7,25 +7,19 @@
7
test_description='Test pretty formats'
8
. ./test-lib.sh
9
10
+sample_utf8_part=$(printf "f\303\244ng")
11
+
12
commit_msg () {
13
# String "initial. initial" partly in German
14
# (translated with Google Translate),
15
# encoded in UTF-8, used as a commit log message below.
14
- msg=$(printf "initial. anf\303\244nglich")
16
+ msg="initial. an${sample_utf8_part}lich\n"
17
if test -n "$1"
18
then
17
- msg=$(echo $msg | iconv -f utf-8 -t $1)
18
- fi
19
- if test -n "$2" -a -n "$3"
20
- then
21
- # cut string, replace cut part with two dots
22
- # $2 - chars count from the beginning of the string
23
- # $3 - "trailing" chars
24
- # LC_ALL is set to make `sed` interpret "." as a UTF-8 char not a byte
25
- # as it does with C locale
26
- msg=$(echo $msg | LC_ALL=en_US.UTF-8 sed -e "s/^\(.\{$2\}\)$3/\1../")
19
+ printf "$msg" | iconv -f utf-8 -t "$1"
20
+ else
21
+ printf "$msg"
22
fi
28
- echo $msg
23
}
24
25
test_expect_success 'set up basic repos' '
@@ -193,7 +187,7 @@ test_expect_success 'left alignment formatting with trunc' '
187
message ..
188
message ..
189
add bar Z
196
-$(commit_msg "" "8" "..*$")
190
+initial...
191
EOF
192
test_cmp expected actual
193
'
@@ -206,7 +200,7 @@ test_expect_success 'left alignment formatting with ltrunc' '
200
..sage two
201
..sage one
202
add bar Z
209
-$(commit_msg "" "0" ".\{11\}")
203
+..${sample_utf8_part}lich
204
EOF
205
test_cmp expected actual
206
'
@@ -219,7 +213,7 @@ test_expect_success 'left alignment formatting with mtrunc' '
213
mess.. two
214
mess.. one
215
add bar Z
222
-$(commit_msg "" "4" ".\{11\}")
216
+init..lich
217
EOF
218
test_cmp expected actual
219
'
@@ -311,7 +305,7 @@ test_expect_success 'left/right alignment formatting with stealing' '
305
short long long long
306
message .. A U Thor
307
add bar A U Thor
314
-$(commit_msg "" "8" "..*$") A U Thor
308
+initial... A U Thor
309
EOF
310
test_cmp expected actual
311
'