2 test_description
='Test diffs with alternate encodings'
5 test_expect_success
'Initialize empty repo' '
6 git config stgit.sender "A U Thor <author@example.com>" &&
9 git commit -m "Add glass.txt" &&
13 test_expect_success
'Add utf-8 encoded text' '
14 echo "Я могу есть стекло, это мне не вредит." >> glass.txt &&
15 stg new -m "I can eat glass, it does not harm me." UTF-8 &&
19 test_expect_success
'Add more encodings' '
20 for e in ISO8859-5 KOI8-R UTF-16 UTF-32BE CP866; do
21 iconv -f UTF-8 -t $e glass.txt > $e.txt &&
22 stg new -m "Add $e.txt" $e &&
26 stg show | grep -e "Add $e.txt" || return 1
30 for e in ISO8859-5 KOI8-R UTF-16 UTF-32BE CP866; do
31 iconv -f $e -t UTF-8 $e.txt > glass-from-$e.txt &&
32 diff -q glass.txt glass-from-$e.txt || return 1
36 test_expect_success
'Test export and import' '
37 stg export --dir export-dir &&
39 stg import -s export-dir/series &&
40 for e in ISO8859-5 KOI8-R UTF-16 UTF-32BE CP866; do
41 iconv -f $e -t UTF-8 $e.txt > glass-from-$e.txt &&
42 diff -q glass.txt glass-from-$e.txt || return 1
46 test_expect_success
'Squash' '
47 stg squash -n UTF -m "Squash UTF patches" -- UTF-16 UTF-32BE &&
48 stg show UTF | grep -e "Squash UTF patches" &&
49 for e in UTF-16 UTF-32BE; do
50 iconv -f $e -t UTF-8 $e.txt > glass-from-$e.txt &&
51 diff -q glass.txt glass-from-$e.txt || return 1
55 test_expect_success
'Test stg commit' '
59 desc
='Test mail export and import'
61 stg mail --all --mbox > export.mbox &&
63 stg import --mbox export.mbox &&
64 for e in ISO8859-5 KOI8-R UTF-16 UTF-32BE CP866; do
65 iconv -f $e -t UTF-8 $e.txt > glass-from-$e.txt &&
66 diff -q glass.txt glass-from-$e.txt || return 1
69 if ! (python
--version 2>&1 |
grep -q -e 'Python 3\.3'); then
70 test_expect_success
"$desc" "$body"
72 test_expect_failure
"$desc" "$body"