contrib / mw-to-git / t / t9362-mw-to-git-utf8.shon commit Merge branch 'sb/diff-color-move' (91ccfb8)
   1#!/bin/sh
   2#
   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>
   9#
  10# License: GPL v2 or later
  11
  12# tests for git-remote-mediawiki
  13
  14test_description='Test git-mediawiki with special characters in filenames'
  15
  16. ./test-gitmw-lib.sh
  17. $TEST_DIRECTORY/test-lib.sh
  18
  19
  20test_check_precond
  21
  22
  23test_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
  33'
  34
  35
  36test_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 &&
  42        (
  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
  48'
  49
  50
  51test_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
  59'
  60
  61
  62test_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 &&
  71        (
  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
  78'
  79
  80
  81test_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 Îî
  88'
  89
  90
  91test_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 &&
  96        (
  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
 105'
 106
 107test_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
 113'
 114
 115test_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
 122'
 123
 124
 125
 126test_expect_success 'character $ in file name (git -> mw) ' '
 127        wiki_reset &&
 128        git clone mediawiki::'"$WIKI_URL"' mw_dir_9 &&
 129        (
 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
 139'
 140
 141
 142test_expect_failure 'capital at the beginning of file names' '
 143        wiki_reset &&
 144        git clone mediawiki::'"$WIKI_URL"' mw_dir_10 &&
 145        (
 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
 156'
 157
 158
 159test_expect_failure 'special character at the beginning 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 &&
 164        (
 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
 170'
 171
 172test_expect_success 'Pull page with title containing ":" other than namespace separator' '
 173        wiki_editpage Foo:Bar content false &&
 174        (
 175                cd mw_dir_11 &&
 176                git pull
 177        ) &&
 178        test_path_is_file mw_dir_11/Foo:Bar.mw
 179'
 180
 181test_expect_success 'Push page with title containing ":" other than namespace separator' '
 182        (
 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
 190'
 191
 192test_expect_success 'test of correct formatting 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 &&
 197        (
 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
 207'
 208
 209
 210test_expect_failure 'test of correct formatting for file name beginning with special character' '
 211        wiki_reset &&
 212        git clone mediawiki::'"$WIKI_URL"' mw_dir_13 &&
 213        (
 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 "committing 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
 226'
 227
 228
 229test_expect_success 'test of correct formatting for file name from git to mw' '
 230        wiki_reset &&
 231        git clone mediawiki::'"$WIKI_URL"' mw_dir_14 &&
 232        (
 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 "committing 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
 244'
 245
 246
 247test_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
 253'
 254
 255
 256test_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 &&
 260        (
 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
 268
 269'
 270
 271
 272test_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
 278'
 279
 280
 281test_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 &&
 285        (
 286                cd mw_dir_18 &&
 287                git add \\ko\\o.mw &&
 288                git commit -m " \\ko\\o added" &&
 289                git push
 290        )&&
 291        wiki_page_exist \\ko\\o &&
 292        wiki_check_content mw_dir_18/\\ko\\o.mw \\ko\\o
 293
 294'
 295
 296test_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
 302'
 303
 304
 305test_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 &&
 309        (
 310                cd mw_dir_20 &&
 311                git add \\fo\\o.mw &&
 312                git commit -m " \\fo\\o added" &&
 313                git push
 314        )&&
 315        wiki_page_exist \\fo\\o &&
 316        wiki_check_content mw_dir_20/\\fo\\o.mw \\fo\\o
 317
 318'
 319
 320
 321test_expect_success 'fast-import meta-characters in page name (mw -> git)' '
 322        wiki_reset &&
 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
 328'
 329
 330
 331test_expect_success 'fast-import meta-characters in page name (git -> mw) ' '
 332        wiki_reset &&
 333        git clone mediawiki::'"$WIKI_URL"' mw_dir_22 &&
 334        (
 335                cd mw_dir_22 &&
 336                echo "this file is called \"file\"_\\_foo.mw" >\"file\"_\\_foo &&
 337                git add . &&
 338                git commit -am "file \"file\"_\\_foo" &&
 339                git pull &&
 340                git push
 341        ) &&
 342        wiki_getallpage ref_page_22 &&
 343        test_diff_directories mw_dir_22 ref_page_22
 344'
 345
 346
 347test_done