contrib / mw-to-git / t / t9362-mw-to-git-utf8.shon commit Merge branch 'pw/git-p4-jobs' (7bdb748)
   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 begining 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 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 &&
 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 'test of correct formating for file name from mw to git' '
 173        wiki_reset &&
 174        git clone mediawiki::'"$WIKI_URL"' mw_dir_12 &&
 175        wiki_editpage char_%_7b_1 "expect to be renamed char{_1" false &&
 176        wiki_editpage char_%_5b_2 "expect to be renamed char{_2" false &&
 177        (
 178                cd mw_dir_12 &&
 179                git pull
 180        ) &&
 181        test_path_is_file mw_dir_12/Char\{_1.mw &&
 182        test_path_is_file mw_dir_12/Char\[_2.mw &&
 183        wiki_getallpage ref_page_12 &&
 184        mv ref_page_12/Char_%_7b_1.mw ref_page_12/Char\{_1.mw &&
 185        mv ref_page_12/Char_%_5b_2.mw ref_page_12/Char\[_2.mw &&
 186        test_diff_directories mw_dir_12 ref_page_12
 187'
 188
 189
 190test_expect_failure 'test of correct formating for file name begining with special character' '
 191        wiki_reset &&
 192        git clone mediawiki::'"$WIKI_URL"' mw_dir_13 &&
 193        (
 194                cd mw_dir_13 &&
 195                echo "my new file {char_1" >\{char_1.mw &&
 196                echo "my new file [char_2" >\[char_2.mw &&
 197                git add . &&
 198                git commit -am "commiting some exotic file name..." &&
 199                git push &&
 200                git pull
 201        ) &&
 202        wiki_getallpage ref_page_13 &&
 203        test_path_is_file ref_page_13/{char_1.mw &&
 204        test_path_is_file ref_page_13/[char_2.mw &&
 205        test_diff_directories mw_dir_13 ref_page_13
 206'
 207
 208
 209test_expect_success 'test of correct formating for file name from git to mw' '
 210        wiki_reset &&
 211        git clone mediawiki::'"$WIKI_URL"' mw_dir_14 &&
 212        (
 213                cd mw_dir_14 &&
 214                echo "my new file char{_1" >Char\{_1.mw &&
 215                echo "my new file char[_2" >Char\[_2.mw &&
 216                git add . &&
 217                git commit -m "commiting some exotic file name..." &&
 218                git push
 219        ) &&
 220        wiki_getallpage ref_page_14 &&
 221        mv mw_dir_14/Char\{_1.mw mw_dir_14/Char_%_7b_1.mw &&
 222        mv mw_dir_14/Char\[_2.mw mw_dir_14/Char_%_5b_2.mw &&
 223        test_diff_directories mw_dir_14 ref_page_14
 224'
 225
 226
 227test_expect_success 'git clone with /' '
 228        wiki_reset &&
 229        wiki_editpage \/fo\/o "this is not important" false -c=Deleted &&
 230        git clone mediawiki::'"$WIKI_URL"' mw_dir_15 &&
 231        test_path_is_file mw_dir_15/%2Ffo%2Fo.mw &&
 232        wiki_check_content mw_dir_15/%2Ffo%2Fo.mw \/fo\/o
 233'
 234
 235
 236test_expect_success 'git push with /' '
 237        wiki_reset &&
 238        git clone mediawiki::'"$WIKI_URL"' mw_dir_16 &&
 239        echo "I will be on the wiki" >mw_dir_16/%2Ffo%2Fo.mw &&
 240        (
 241                cd mw_dir_16 &&
 242                git add %2Ffo%2Fo.mw &&
 243                git commit -m " %2Ffo%2Fo added" &&
 244                git push
 245        ) &&
 246        wiki_page_exist \/fo\/o &&
 247        wiki_check_content mw_dir_16/%2Ffo%2Fo.mw \/fo\/o
 248
 249'
 250
 251
 252test_expect_success 'git clone with \' '
 253        wiki_reset &&
 254        wiki_editpage \\ko\\o "this is not important" false -c=Deleted &&
 255        git clone mediawiki::'"$WIKI_URL"' mw_dir_17 &&
 256        test_path_is_file mw_dir_17/\\ko\\o.mw &&
 257        wiki_check_content mw_dir_17/\\ko\\o.mw \\ko\\o
 258'
 259
 260
 261test_expect_success 'git push with \' '
 262        wiki_reset &&
 263        git clone mediawiki::'"$WIKI_URL"' mw_dir_18 &&
 264        echo "I will be on the wiki" >mw_dir_18/\\ko\\o.mw &&
 265        (
 266                cd mw_dir_18 &&
 267                git add \\ko\\o.mw &&
 268                git commit -m " \\ko\\o added" &&
 269                git push
 270        )&&
 271        wiki_page_exist \\ko\\o &&
 272        wiki_check_content mw_dir_18/\\ko\\o.mw \\ko\\o
 273
 274'
 275
 276test_expect_success 'git clone with \ in format control' '
 277        wiki_reset &&
 278        wiki_editpage \\no\\o "this is not important" false &&
 279        git clone mediawiki::'"$WIKI_URL"' mw_dir_19 &&
 280        test_path_is_file mw_dir_19/\\no\\o.mw &&
 281        wiki_check_content mw_dir_19/\\no\\o.mw \\no\\o
 282'
 283
 284
 285test_expect_success 'git push with \ in format control' '
 286        wiki_reset &&
 287        git clone mediawiki::'"$WIKI_URL"' mw_dir_20 &&
 288        echo "I will be on the wiki" >mw_dir_20/\\fo\\o.mw &&
 289        (
 290                cd mw_dir_20 &&
 291                git add \\fo\\o.mw &&
 292                git commit -m " \\fo\\o added" &&
 293                git push
 294        )&&
 295        wiki_page_exist \\fo\\o &&
 296        wiki_check_content mw_dir_20/\\fo\\o.mw \\fo\\o
 297
 298'
 299
 300
 301test_done