git-svn: introduce add_path_to_url function
[alt-git.git] / contrib / mw-to-git / t / t9362-mw-to-git-utf8.sh
blob246d47d8fb4e6aa141e1aa5b10b63bbb179fd73e
1 #!/bin/sh
3 # Copyright (C) 2012
4 # Charles Roussel <charles.roussel@ensimag.imag.fr>
5 # Simon Cathebras <simon.cathebras@ensimag.imag.fr>
6 # Julien Khayat <julien.khayat@ensimag.imag.fr>
7 # Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
8 # Simon Perrat <simon.perrat@ensimag.imag.fr>
10 # License: GPL v2 or later
12 # tests for git-remote-mediawiki
14 test_description='Test git-mediawiki with special characters in filenames'
16 . ./test-gitmw-lib.sh
17 . $TEST_DIRECTORY/test-lib.sh
20 test_check_precond
23 test_expect_success 'Git clone works for a wiki with accents in the page names' '
24 wiki_reset &&
25 wiki_editpage féé "This page must be délétéd before clone" false &&
26 wiki_editpage kèè "This page must be deleted before clone" false &&
27 wiki_editpage hàà "This page must be deleted before clone" false &&
28 wiki_editpage kîî "This page must be deleted before clone" false &&
29 wiki_editpage foo "This page must be deleted before clone" false &&
30 git clone mediawiki::'"$WIKI_URL"' mw_dir_1 &&
31 wiki_getallpage ref_page_1 &&
32 test_diff_directories mw_dir_1 ref_page_1
36 test_expect_success 'Git pull works with a wiki with accents in the pages names' '
37 wiki_reset &&
38 wiki_editpage kîî "this page must be cloned" false &&
39 wiki_editpage foo "this page must be cloned" false &&
40 git clone mediawiki::'"$WIKI_URL"' mw_dir_2 &&
41 wiki_editpage éàîôû "This page must be pulled" false &&
43 cd mw_dir_2 &&
44 git pull
45 ) &&
46 wiki_getallpage ref_page_2 &&
47 test_diff_directories mw_dir_2 ref_page_2
51 test_expect_success 'Cloning a chosen page works with accents' '
52 wiki_reset &&
53 wiki_editpage kîî "this page must be cloned" false &&
54 git clone -c remote.origin.pages=kîî \
55 mediawiki::'"$WIKI_URL"' mw_dir_3 &&
56 wiki_check_content mw_dir_3/Kîî.mw Kîî &&
57 test_path_is_file mw_dir_3/Kîî.mw &&
58 rm -rf mw_dir_3
62 test_expect_success 'The shallow option works with accents' '
63 wiki_reset &&
64 wiki_editpage néoà "1st revision, should not be cloned" false &&
65 wiki_editpage néoà "2nd revision, should be cloned" false &&
66 git -c remote.origin.shallow=true clone \
67 mediawiki::'"$WIKI_URL"' mw_dir_4 &&
68 test_contains_N_files mw_dir_4 2 &&
69 test_path_is_file mw_dir_4/Néoà.mw &&
70 test_path_is_file mw_dir_4/Main_Page.mw &&
72 cd mw_dir_4 &&
73 test `git log --oneline Néoà.mw | wc -l` -eq 1 &&
74 test `git log --oneline Main_Page.mw | wc -l ` -eq 1
75 ) &&
76 wiki_check_content mw_dir_4/Néoà.mw Néoà &&
77 wiki_check_content mw_dir_4/Main_Page.mw Main_Page
81 test_expect_success 'Cloning works when page name first letter has an accent' '
82 wiki_reset &&
83 wiki_editpage îî "this page must be cloned" false &&
84 git clone -c remote.origin.pages=îî \
85 mediawiki::'"$WIKI_URL"' mw_dir_5 &&
86 test_path_is_file mw_dir_5/Îî.mw &&
87 wiki_check_content mw_dir_5/Îî.mw Îî
91 test_expect_success 'Git push works with a wiki with accents' '
92 wiki_reset &&
93 wiki_editpage féé "lots of accents : éèàÖ" false &&
94 wiki_editpage foo "this page must be cloned" false &&
95 git clone mediawiki::'"$WIKI_URL"' mw_dir_6 &&
97 cd mw_dir_6 &&
98 echo "A wild Pîkächû appears on the wiki" >Pîkächû.mw &&
99 git add Pîkächû.mw &&
100 git commit -m "A new page appears" &&
101 git push
102 ) &&
103 wiki_getallpage ref_page_6 &&
104 test_diff_directories mw_dir_6 ref_page_6
107 test_expect_success 'Git clone works with accentsand spaces' '
108 wiki_reset &&
109 wiki_editpage "é à î" "this page must be délété before the clone" false &&
110 git clone mediawiki::'"$WIKI_URL"' mw_dir_7 &&
111 wiki_getallpage ref_page_7 &&
112 test_diff_directories mw_dir_7 ref_page_7
115 test_expect_success 'character $ in page name (mw -> git)' '
116 wiki_reset &&
117 wiki_editpage file_\$_foo "expect to be called file_$_foo" false &&
118 git clone mediawiki::'"$WIKI_URL"' mw_dir_8 &&
119 test_path_is_file mw_dir_8/File_\$_foo.mw &&
120 wiki_getallpage ref_page_8 &&
121 test_diff_directories mw_dir_8 ref_page_8
126 test_expect_success 'character $ in file name (git -> mw) ' '
127 wiki_reset &&
128 git clone mediawiki::'"$WIKI_URL"' mw_dir_9 &&
130 cd mw_dir_9 &&
131 echo "this file is called File_\$_foo.mw" >File_\$_foo.mw &&
132 git add . &&
133 git commit -am "file File_\$_foo.mw" &&
134 git pull &&
135 git push
136 ) &&
137 wiki_getallpage ref_page_9 &&
138 test_diff_directories mw_dir_9 ref_page_9
142 test_expect_failure 'capital at the begining of file names' '
143 wiki_reset &&
144 git clone mediawiki::'"$WIKI_URL"' mw_dir_10 &&
146 cd mw_dir_10 &&
147 echo "my new file foo" >foo.mw &&
148 echo "my new file Foo... Finger crossed" >Foo.mw &&
149 git add . &&
150 git commit -am "file foo.mw" &&
151 git pull &&
152 git push
153 ) &&
154 wiki_getallpage ref_page_10 &&
155 test_diff_directories mw_dir_10 ref_page_10
159 test_expect_failure 'special character at the begining of file name from mw to git' '
160 wiki_reset &&
161 git clone mediawiki::'"$WIKI_URL"' mw_dir_11 &&
162 wiki_editpage {char_1 "expect to be renamed {char_1" false &&
163 wiki_editpage [char_2 "expect to be renamed [char_2" false &&
165 cd mw_dir_11 &&
166 git pull
167 ) &&
168 test_path_is_file mw_dir_11/{char_1 &&
169 test_path_is_file mw_dir_11/[char_2
172 test_expect_success 'Pull page with title containing ":" other than namespace separator' '
173 wiki_editpage Foo:Bar content false &&
175 cd mw_dir_11 &&
176 git pull
177 ) &&
178 test_path_is_file mw_dir_11/Foo:Bar.mw
181 test_expect_success 'Push page with title containing ":" other than namespace separator' '
183 cd mw_dir_11 &&
184 echo content >NotANameSpace:Page.mw &&
185 git add NotANameSpace:Page.mw &&
186 git commit -m "add page with colon" &&
187 git push
188 ) &&
189 wiki_page_exist NotANameSpace:Page
192 test_expect_success 'test of correct formating for file name from mw to git' '
193 wiki_reset &&
194 git clone mediawiki::'"$WIKI_URL"' mw_dir_12 &&
195 wiki_editpage char_%_7b_1 "expect to be renamed char{_1" false &&
196 wiki_editpage char_%_5b_2 "expect to be renamed char{_2" false &&
198 cd mw_dir_12 &&
199 git pull
200 ) &&
201 test_path_is_file mw_dir_12/Char\{_1.mw &&
202 test_path_is_file mw_dir_12/Char\[_2.mw &&
203 wiki_getallpage ref_page_12 &&
204 mv ref_page_12/Char_%_7b_1.mw ref_page_12/Char\{_1.mw &&
205 mv ref_page_12/Char_%_5b_2.mw ref_page_12/Char\[_2.mw &&
206 test_diff_directories mw_dir_12 ref_page_12
210 test_expect_failure 'test of correct formating for file name begining with special character' '
211 wiki_reset &&
212 git clone mediawiki::'"$WIKI_URL"' mw_dir_13 &&
214 cd mw_dir_13 &&
215 echo "my new file {char_1" >\{char_1.mw &&
216 echo "my new file [char_2" >\[char_2.mw &&
217 git add . &&
218 git commit -am "commiting some exotic file name..." &&
219 git push &&
220 git pull
221 ) &&
222 wiki_getallpage ref_page_13 &&
223 test_path_is_file ref_page_13/{char_1.mw &&
224 test_path_is_file ref_page_13/[char_2.mw &&
225 test_diff_directories mw_dir_13 ref_page_13
229 test_expect_success 'test of correct formating for file name from git to mw' '
230 wiki_reset &&
231 git clone mediawiki::'"$WIKI_URL"' mw_dir_14 &&
233 cd mw_dir_14 &&
234 echo "my new file char{_1" >Char\{_1.mw &&
235 echo "my new file char[_2" >Char\[_2.mw &&
236 git add . &&
237 git commit -m "commiting some exotic file name..." &&
238 git push
239 ) &&
240 wiki_getallpage ref_page_14 &&
241 mv mw_dir_14/Char\{_1.mw mw_dir_14/Char_%_7b_1.mw &&
242 mv mw_dir_14/Char\[_2.mw mw_dir_14/Char_%_5b_2.mw &&
243 test_diff_directories mw_dir_14 ref_page_14
247 test_expect_success 'git clone with /' '
248 wiki_reset &&
249 wiki_editpage \/fo\/o "this is not important" false -c=Deleted &&
250 git clone mediawiki::'"$WIKI_URL"' mw_dir_15 &&
251 test_path_is_file mw_dir_15/%2Ffo%2Fo.mw &&
252 wiki_check_content mw_dir_15/%2Ffo%2Fo.mw \/fo\/o
256 test_expect_success 'git push with /' '
257 wiki_reset &&
258 git clone mediawiki::'"$WIKI_URL"' mw_dir_16 &&
259 echo "I will be on the wiki" >mw_dir_16/%2Ffo%2Fo.mw &&
261 cd mw_dir_16 &&
262 git add %2Ffo%2Fo.mw &&
263 git commit -m " %2Ffo%2Fo added" &&
264 git push
265 ) &&
266 wiki_page_exist \/fo\/o &&
267 wiki_check_content mw_dir_16/%2Ffo%2Fo.mw \/fo\/o
272 test_expect_success 'git clone with \' '
273 wiki_reset &&
274 wiki_editpage \\ko\\o "this is not important" false -c=Deleted &&
275 git clone mediawiki::'"$WIKI_URL"' mw_dir_17 &&
276 test_path_is_file mw_dir_17/\\ko\\o.mw &&
277 wiki_check_content mw_dir_17/\\ko\\o.mw \\ko\\o
281 test_expect_success 'git push with \' '
282 wiki_reset &&
283 git clone mediawiki::'"$WIKI_URL"' mw_dir_18 &&
284 echo "I will be on the wiki" >mw_dir_18/\\ko\\o.mw &&
286 cd mw_dir_18 &&
287 git add \\ko\\o.mw &&
288 git commit -m " \\ko\\o added" &&
289 git push
291 wiki_page_exist \\ko\\o &&
292 wiki_check_content mw_dir_18/\\ko\\o.mw \\ko\\o
296 test_expect_success 'git clone with \ in format control' '
297 wiki_reset &&
298 wiki_editpage \\no\\o "this is not important" false &&
299 git clone mediawiki::'"$WIKI_URL"' mw_dir_19 &&
300 test_path_is_file mw_dir_19/\\no\\o.mw &&
301 wiki_check_content mw_dir_19/\\no\\o.mw \\no\\o
305 test_expect_success 'git push with \ in format control' '
306 wiki_reset &&
307 git clone mediawiki::'"$WIKI_URL"' mw_dir_20 &&
308 echo "I will be on the wiki" >mw_dir_20/\\fo\\o.mw &&
310 cd mw_dir_20 &&
311 git add \\fo\\o.mw &&
312 git commit -m " \\fo\\o added" &&
313 git push
315 wiki_page_exist \\fo\\o &&
316 wiki_check_content mw_dir_20/\\fo\\o.mw \\fo\\o
321 test_done