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