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'
17 .
$TEST_DIRECTORY/test-lib.sh
23 test_expect_success
'Git clone works for a wiki with accents in the page names' '
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' '
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 &&
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' '
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 &&
62 test_expect_success
'The shallow option works with accents' '
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 &&
73 test $(git log --oneline Néoà.mw | wc -l) -eq 1 &&
74 test $(git log --oneline Main_Page.mw | wc -l ) -eq 1
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' '
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' '
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 &&
98 echo "A wild Pîkächû appears on the wiki" >Pîkächû.mw &&
100 git commit -m "A new page appears" &&
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' '
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)' '
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) ' '
128 git clone mediawiki::'"$WIKI_URL"' mw_dir_9 &&
131 echo "this file is called File_\$_foo.mw" >File_\$_foo.mw &&
133 git commit -am "file File_\$_foo.mw" &&
137 wiki_getallpage ref_page_9 &&
138 test_diff_directories mw_dir_9 ref_page_9
142 test_expect_failure
'capital at the beginning of file names' '
144 git clone mediawiki::'"$WIKI_URL"' mw_dir_10 &&
147 echo "my new file foo" >foo.mw &&
148 echo "my new file Foo... Finger crossed" >Foo.mw &&
150 git commit -am "file foo.mw" &&
154 wiki_getallpage ref_page_10 &&
155 test_diff_directories mw_dir_10 ref_page_10
159 test_expect_failure
'special character at the beginning of file name from mw to git' '
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 &&
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 &&
178 test_path_is_file mw_dir_11/Foo:Bar.mw
181 test_expect_success
'Push page with title containing ":" other than namespace separator' '
184 echo content >NotANameSpace:Page.mw &&
185 git add NotANameSpace:Page.mw &&
186 git commit -m "add page with colon" &&
189 wiki_page_exist NotANameSpace:Page
192 test_expect_success
'test of correct formatting for file name from mw to git' '
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 &&
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 formatting for file name beginning with special character' '
212 git clone mediawiki::'"$WIKI_URL"' mw_dir_13 &&
215 echo "my new file {char_1" >\{char_1.mw &&
216 echo "my new file [char_2" >\[char_2.mw &&
218 git commit -am "committing some exotic file name..." &&
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 formatting for file name from git to mw' '
231 git clone mediawiki::'"$WIKI_URL"' mw_dir_14 &&
234 echo "my new file char{_1" >Char\{_1.mw &&
235 echo "my new file char[_2" >Char\[_2.mw &&
237 git commit -m "committing some exotic file name..." &&
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 /' '
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 /' '
258 git clone mediawiki::'"$WIKI_URL"' mw_dir_16 &&
259 echo "I will be on the wiki" >mw_dir_16/%2Ffo%2Fo.mw &&
262 git add %2Ffo%2Fo.mw &&
263 git commit -m " %2Ffo%2Fo added" &&
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 \' '
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
\' '
283 git clone mediawiki::'"$WIKI_URL"' mw_dir_18 &&
284 echo "I will be on the wiki" >mw_dir_18/\\ko\\o.mw &&
287 git add \\ko\\o.mw &&
288 git commit -m " \\ko\\o added" &&
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' '
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' '
307 git clone mediawiki::'"$WIKI_URL"' mw_dir_20 &&
308 echo "I will be on the wiki" >mw_dir_20/\\fo\\o.mw &&
311 git add \\fo\\o.mw &&
312 git commit -m " \\fo\\o added" &&
315 wiki_page_exist \\fo\\o &&
316 wiki_check_content mw_dir_20/\\fo\\o.mw \\fo\\o
321 test_expect_success
'fast-import meta-characters in page name (mw -> git)' '
323 wiki_editpage \"file\"_\\_foo "expect to be called \"file\"_\\_foo" false &&
324 git clone mediawiki::'"$WIKI_URL"' mw_dir_21 &&
325 test_path_is_file mw_dir_21/\"file\"_\\_foo.mw &&
326 wiki_getallpage ref_page_21 &&
327 test_diff_directories mw_dir_21 ref_page_21
331 test_expect_success
'fast-import meta-characters in page name (git -> mw) ' '
333 git clone mediawiki::'"$WIKI_URL"' mw_dir_22 &&
336 echo "this file is called \"file\"_\\_foo.mw" >\"file\"_\\_foo &&
338 git commit -am "file \"file\"_\\_foo" &&
342 wiki_getallpage ref_page_22 &&
343 test_diff_directories mw_dir_22 ref_page_22