##// END OF EJS Templates
tests: unify test-encoding-align
Matt Mackall -
r12418:09c6dd12 default
parent child Browse files
Show More
@@ -1,127 +1,137 b''
1 #!/bin/sh
2
3 ########################################
4
5 HGENCODING=utf-8
6 export HGENCODING
7
8 hg init t
9 cd t
10
11 python << EOF
12 # (byte, width) = (6, 4)
13 s = "\xe7\x9f\xad\xe5\x90\x8d"
14 # (byte, width) = (7, 7): odd width is good for alignment test
15 m = "MIDDLE_"
16 # (byte, width) = (18, 12)
17 l = "\xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d"
18
19 f = file('s', 'w'); f.write(s); f.close()
20 f = file('m', 'w'); f.write(m); f.close()
21 f = file('l', 'w'); f.write(l); f.close()
22
23 # instant extension to show list of options
24 f = file('showoptlist.py', 'w'); f.write("""# encoding: utf-8
25 def showoptlist(ui, repo, *pats, **opts):
26 '''dummy command to show option descriptions'''
27 return 0
1 Test alignment of multibyte characters
28 2
29 cmdtable = {
30 'showoptlist':
31 (showoptlist,
32 [('s', 'opt1', '', 'short width', '""" + s + """'),
33 ('m', 'opt2', '', 'middle width', '""" + m + """'),
34 ('l', 'opt3', '', 'long width', '""" + l + """')
35 ],
36 ""
37 )
38 }
39 """)
40 f.close()
41 EOF
3 $ HGENCODING=utf-8
4 $ export HGENCODING
5 $ hg init t
6 $ cd t
7 $ python << EOF
8 > # (byte, width) = (6, 4)
9 > s = "\xe7\x9f\xad\xe5\x90\x8d"
10 > # (byte, width) = (7, 7): odd width is good for alignment test
11 > m = "MIDDLE_"
12 > # (byte, width) = (18, 12)
13 > l = "\xe9\x95\xb7\xe3\x81\x84\xe9\x95\xb7\xe3\x81\x84\xe5\x90\x8d\xe5\x89\x8d"
14 > f = file('s', 'w'); f.write(s); f.close()
15 > f = file('m', 'w'); f.write(m); f.close()
16 > f = file('l', 'w'); f.write(l); f.close()
17 > # instant extension to show list of options
18 > f = file('showoptlist.py', 'w'); f.write("""# encoding: utf-8
19 > def showoptlist(ui, repo, *pats, **opts):
20 > '''dummy command to show option descriptions'''
21 > return 0
22 > cmdtable = {
23 > 'showoptlist':
24 > (showoptlist,
25 > [('s', 'opt1', '', 'short width', '""" + s + """'),
26 > ('m', 'opt2', '', 'middle width', '""" + m + """'),
27 > ('l', 'opt3', '', 'long width', '""" + l + """')
28 > ],
29 > ""
30 > )
31 > }
32 > """)
33 > f.close()
34 > EOF
35 $ S=`cat s`
36 $ M=`cat m`
37 $ L=`cat l`
42 38
43 S=`cat s`
44 M=`cat m`
45 L=`cat l`
39 alignment of option descriptions in help
46 40
47 ########################################
48 #### alignment of:
49 #### - option descriptions in help
41 $ cat <<EOF > .hg/hgrc
42 > [extensions]
43 > ja_ext = `pwd`/showoptlist.py
44 > EOF
45
46 check alignment of option descriptions in help
50 47
51 cat <<EOF > .hg/hgrc
52 [extensions]
53 ja_ext = `pwd`/showoptlist.py
54 EOF
55 echo '% check alignment of option descriptions in help'
56 hg help showoptlist
48 $ hg help showoptlist
49 hg showoptlist
50
51 dummy command to show option descriptions
52
53 options:
54
55 -s --opt1 短名 short width
56 -m --opt2 MIDDLE_ middle width
57 -l --opt3 長い長い名前 long width
58
59 use "hg -v help showoptlist" to show global options
57 60
58 ########################################
59 #### alignment of:
60 #### - user names in annotate
61 #### - file names in diffstat
61
62 $ rm -f s; touch s
63 $ rm -f m; touch m
64 $ rm -f l; touch l
65
66 add files
62 67
63 rm -f s; touch s
64 rm -f m; touch m
65 rm -f l; touch l
66
67 #### add files
68 $ cp s $S
69 $ hg add $S
70 $ cp m $M
71 $ hg add $M
72 $ cp l $L
73 $ hg add $L
68 74
69 cp s $S
70 hg add $S
71 cp m $M
72 hg add $M
73 cp l $L
74 hg add $L
75 commit(1)
76
77 $ echo 'first line(1)' >> s; cp s $S
78 $ echo 'first line(2)' >> m; cp m $M
79 $ echo 'first line(3)' >> l; cp l $L
80 $ hg commit -m 'first commit' -u $S
81
82 commit(2)
75 83
76 #### commit(1)
84 $ echo 'second line(1)' >> s; cp s $S
85 $ echo 'second line(2)' >> m; cp m $M
86 $ echo 'second line(3)' >> l; cp l $L
87 $ hg commit -m 'second commit' -u $M
77 88
78 echo 'first line(1)' >> s; cp s $S
79 echo 'first line(2)' >> m; cp m $M
80 echo 'first line(3)' >> l; cp l $L
81 hg commit -m 'first commit' -u $S
89 commit(3)
82 90
83 #### commit(2)
91 $ echo 'third line(1)' >> s; cp s $S
92 $ echo 'third line(2)' >> m; cp m $M
93 $ echo 'third line(3)' >> l; cp l $L
94 $ hg commit -m 'third commit' -u $L
84 95
85 echo 'second line(1)' >> s; cp s $S
86 echo 'second line(2)' >> m; cp m $M
87 echo 'second line(3)' >> l; cp l $L
88 hg commit -m 'second commit' -u $M
96 check alignment of user names in annotate
89 97
90 #### commit(3)
98 $ hg annotate -u $M
99 短名: first line(2)
100 MIDDLE_: second line(2)
101 長い長い名前: third line(2)
91 102
92 echo 'third line(1)' >> s; cp s $S
93 echo 'third line(2)' >> m; cp m $M
94 echo 'third line(3)' >> l; cp l $L
95 hg commit -m 'third commit' -u $L
96
97 #### check
103 check alignment of filenames in diffstat
98 104
99 echo '% check alignment of user names in annotate'
100 hg annotate -u $M
101 echo '% check alignment of filenames in diffstat'
102 hg diff -c tip --stat
105 $ hg diff -c tip --stat
106 MIDDLE_ | 1 +
107 短名 | 1 +
108 長い長い名前 | 1 +
109 3 files changed, 3 insertions(+), 0 deletions(-)
103 110
104 ########################################
105 #### alignment of:
106 #### - branch names in list
107 #### - tag names in list
111 add branches/tags
108 112
109 #### add branches/tags
113 $ hg branch $S
114 marked working directory as branch 短名
115 $ hg tag $S
116 $ hg branch $M
117 marked working directory as branch MIDDLE_
118 $ hg tag $M
119 $ hg branch $L
120 marked working directory as branch 長い長い名前
121 $ hg tag $L
110 122
111 hg branch $S
112 hg tag $S
113 hg branch $M
114 hg tag $M
115 hg branch $L
116 hg tag $L
123 check alignment of branches
117 124
118 #### check
125 $ hg tags
126 tip 5:d745ff46155b
127 長い長い名前 4:9259be597f19
128 MIDDLE_ 3:b06c5b6def9e
129 短名 2:64a70663cee8
119 130
120 echo '% check alignment of branches'
121 hg tags
122 echo '% check alignment of tags'
123 hg tags
131 check alignment of tags
124 132
125 ########################################
126
127 exit 0
133 $ hg tags
134 tip 5:d745ff46155b
135 長い長い名前 4:9259be597f19
136 MIDDLE_ 3:b06c5b6def9e
137 短名 2:64a70663cee8
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now