git/list[1] front-page[2] threads[3] people[4] search[5] about
 

=?y?q?=5BPATCHv3=206/6=5D=20Tests=20of=20UTF8=20character=20with=20git-remote-mediawiki?=

From
Simon Cathebras <simon.cathebras@ensimag.imag.fr>
Date
Jun 11, 2012, 20:28 UTC
Message-ID
<1339446526-22397-6-git-send-email-simon.cathebras@ensimag.imag.fr>
In-Reply-To
<1339446526-22397-1-git-send-email-simon.cathebras@ensimag.imag.fr>
From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>

This patch provides a sample of tests for git-remote-mediawiki's resistance, concerning utf8 special characters.

The sample of tests is located in the file git/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh

Signed-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>
Signed-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>
Signed-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>
Signed-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
Signed-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@imag.fr>
---
 contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh | 377 ++++++++++++++++++++++++++++
 1 file changed, 377 insertions(+)
 create mode 100755 contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh
diff --git a/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh b/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh
new file mode 100755
index 0000000..57431da
--- /dev/null
+++ b/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh
@@ -0,0 +1,377 @@
+#!/bin/sh
+#
+# Copyright (C) 2012
+#     Charles Roussel <charles.roussel@ensimag.imag.fr>
+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>
+#     Julien Khayat <julien.khayat@ensimag.imag.fr>
+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
+#     Simon Perrat <simon.perrat@ensimag.imag.fr>
+#
+# License: GPL v2 or later
+
+# tests for git-remote-mediawiki
+
+test_description='Test git-mediawiki with special characters in filenames'
+
+. ./test-gitmw-lib.sh
+. $TEST_DIRECTORY/test-lib.sh
+
+TRASH_DIR="$CURR_DIR/trash\ directory.$(basename $0 .sh)"
+
+if ! test_have_prereq PERL
+then
+	skip_all='skipping gateway git-mw tests, '\
+		'perl not available'
+	test_done
+fi
+
+if [ ! -f $GIT_BUILD_DIR/git-remote-mediawiki ];
+then
+	skip_all='skipping gateway git-mw tests,' \
+		' no remote mediawiki for git found'
+	test_done
+fi
+
+if [ ! -d "$WIKI_DIR_INST/$WIKI_DIR_NAME" ] ;
+then
+	skip_all='skipping gateway git-mw tests, no mediawiki found'
+	test_done
+fi
+
+
+# 1
+test_expect_success 'Git clone works for a wiki with accents in the page names' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	rm -rf ref_page &&
+	wiki_editpage féé "This page must be délétéd before clone" false &&
+	wiki_editpage kèè "This page must be deleted before clone" false &&
+	wiki_editpage hàà "This page must be deleted before clone" false &&
+	wiki_editpage kîî "This page must be deleted before clone" false &&
+	wiki_editpage foo "This page must be deleted before clone" false &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	wiki_getallpage ref_page &&
+	test_diff_directories mw_dir ref_page
+'
+
+# 2
+test_expect_success 'Git pull works with a wiki with accents in the pages names' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	rm -rf ref_page &&
+	wiki_editpage kîî "this page must be cloned" false &&
+	wiki_editpage foo "this page must be cloned" false &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	wiki_editpage éàîôû "This page must be pulled" false &&
+	cd mw_dir &&
+	git pull &&
+	cd .. && 
+	wiki_getallpage ref_page &&
+	test_diff_directories mw_dir ref_page &&
+	rm -rf mw_dir &&
+	rm -rf ref_page
+'
+
+# 3
+test_expect_success 'Cloning a chosen page works with accents' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	rm -rf ref_page &&
+	wiki_editpage kîî "this page must be cloned" false &&
+	git clone -c remote.origin.pages=kîî mediawiki::http://localhost/wiki mw_dir &&
+	wiki_check_content mw_dir/Kîî.mw Kîî &&
+	test -e mw_dir/Kîî.mw &&
+	rm -rf mw_dir
+'
+
+# 4
+test_expect_success 'The shallow option works with accents' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	rm -rf ref_page &&
+	wiki_editpage néoà "1st revision, should not be cloned" false &&
+	wiki_editpage néoà "2nd revision, should be cloned" false &&
+	git -c remote.origin.shallow=true clone mediawiki::http://localhost/wiki/ mw_dir &&
+	test_contains_N_files mw_dir 2 &&
+	test -e mw_dir/Néoà.mw &&
+	test -e mw_dir/Main_Page.mw &&
+	cd mw_dir &&
+	test `git log --oneline Néoà.mw | wc -l` -eq 1 &&
+	test `git log --oneline Main_Page.mw | wc -l ` -eq 1 &&
+	cd .. &&
+	wiki_check_content mw_dir/Néoà.mw Néoà &&
+	wiki_check_content mw_dir/Main_Page.mw Main_Page &&
+	rm -rf mw_dir
+'
+
+# 5
+test_expect_success 'Cloning works when page name first letter has an accent' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	rm -rf ref_page &&
+	wiki_editpage îî "this page must be cloned" false &&
+	git clone -c remote.origin.pages=îî mediawiki::http://localhost/wiki mw_dir &&
+	test -e mw_dir/Îî.mw &&
+	wiki_check_content mw_dir/Îî.mw Îî &&
+	rm -rf mw_dir
+'
+
+# 6
+test_expect_success 'Git push works with a wiki with accents' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	rm -rf ref_page &&
+	wiki_editpage féé "lots of accents : éèàÖ" false &&
+	wiki_editpage foo "this page must be cloned" false &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	cd mw_dir &&
+	echo "A wild Pîkächû appears on the wiki" > Pîkächû.mw &&
+	git add Pîkächû.mw &&
+	git commit -m "A new page appears" &&
+	git push &&
+	cd .. &&
+	wiki_getallpage ref_page &&
+	test_diff_directories mw_dir ref_page &&
+	rm -rf mw_dir &&
+	rm -rf ref_page
+'
+
+# 7
+test_expect_success 'Git clone works with accentsand spaces' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	rm -rf ref_page &&
+	wiki_editpage "é à î" "this page must be délété before the clone" false &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	wiki_getallpage ref_page &&
+	test_diff_directories mw_dir ref_page &&
+	rm -rf mw_dir &&
+	rm -rf ref_page
+'
+# 8
+test_expect_success 'character $ in page name (mw -> git)' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	rm -rf ref_page &&
+	wiki_editpage file_\$_foo "expect to be called file_$_foo" false &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	test -f mw_dir/File_\$_foo.mw &&
+	wiki_getallpage ref_page &&
+	test_diff_directories mw_dir ref_page
+'
+
+
+# 9
+test_expect_success 'character $ in file name (git -> mw) ' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	rm -rf ref_page &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	cd mw_dir &&
+	echo "this file is called File_\$_foo.mw" > File_\$_foo.mw &&
+	git add . &&
+	git commit -am "file File_\$_foo.mw" &&
+	git pull &&
+	git push &&
+	cd .. &&
+	wiki_getallpage ref_page &&
+	test_diff_directories mw_dir ref_page
+'
+
+# 10
+test_expect_failure 'capital at the begining of file names' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	rm -rf ref_page &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	cd mw_dir &&
+	echo "my new file foo" > foo.mw &&
+	echo "my new file Foo... Finger crossed" > Foo.mw &&
+	git add . &&
+	git commit -am "file foo.mw" &&
+	git pull &&
+	git push &&
+	cd .. &&
+	wiki_getallpage ref_page &&
+	test_diff_directories mw_dir ref_page
+'
+
+
+# 11
+test_expect_failure 'special character at the begining of file name from mw to git' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	rm -rf ref_page &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	wiki_editpage {char_1 "expect to be renamed {char_1" false &&
+	wiki_editpage [char_2 "expect to be renamed [char_2" false &&
+	cd mw_dir &&
+	git pull &&
+	cd .. &&
+	test -f mw_dir/{char_1 &&
+	test -f mw_dir/[char_2
+'
+
+# 12
+test_expect_success 'test of correct formating for file name from mw to git' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	rm -rf ref_page &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	wiki_editpage char{_1 "expect to be renamed char{_1" false &&
+	wiki_editpage char[_2 "expect to be renamed char{_2" false &&
+	cd mw_dir &&
+	git pull &&
+	cd .. &&
+	test -f mw_dir/Char\{_1.mw &&
+	test -f mw_dir/Char\[_2.mw &&
+	wiki_getallpage ref_page &&
+	test_diff_directories mw_dir ref_page
+'
+
+# 13
+test_expect_failure 'test of correct formating for file name begining with special character' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	rm -rf ref_page &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	cd mw_dir &&
+	echo "my new file {char_1" > \{char_1.mw &&
+	echo "my new file [char_2" > \[char_2.mw &&
+	git add . &&
+	git commit -am "commiting some exotic file name..." &&
+	git push &&
+	git pull &&
+	cd .. &&
+	wiki_getallpage ref_page &&
+	test -f ref_page/{char_1.mw &&
+	test -f ref_page/[char_2.mw &&
+	test_diff_directories mw_dir ref_page
+'
+
+# 14
+
+test_expect_success 'test of correct formating for file name from git to mw' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	rm -rf ref_page &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	cd mw_dir &&
+	echo "my new file char{_1" > Char\{_1.mw &&
+	echo "my new file char[_2" > Char\[_2.mw &&
+	git add . &&
+	git commit -m "commiting some exotic file name..." &&
+	git push &&
+	cd .. &&
+	wiki_getallpage ref_page &&
+	test_diff_directories mw_dir ref_page
+'
+
+
+# 15
+test_expect_success 'git clone with /' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	wiki_editpage \/fo\/o "this is not important" false -c=Deleted &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	test -f mw_dir/%2Ffo%2Fo.mw &&
+	wiki_check_content mw_dir/%2Ffo%2Fo.mw \/fo\/o &&
+	rm -rf mw_dir
+'
+
+# 16
+test_expect_success 'git push with /' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	echo "I will be on the wiki" > mw_dir/%2Ffo%2Fo.mw &&
+	cd mw_dir &&
+	git add %2Ffo%2Fo.mw &&
+	git commit -m " %2Ffo%2Fo added" &&
+	git push &&
+	cd .. &&
+	wiki_page_exist \/fo\/o &&
+	wiki_check_content mw_dir/%2Ffo%2Fo.mw \/fo\/o &&
+	rm -rf mw_dir 
+
+'
+
+# 17
+test_expect_success 'git clone with \' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	wiki_editpage \\ko\\o "this is not important" false -c=Deleted &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	test -f mw_dir/\\ko\\o.mw &&
+	wiki_check_content mw_dir/\\ko\\o.mw \\ko\\o &&
+	rm -rf mw_dir
+'
+
+# 18
+test_expect_success 'git push with \' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	echo "I will be on the wiki" > mw_dir/\\ko\\o.mw &&
+	cd mw_dir &&
+	git add \\ko\\o.mw &&
+	git commit -m " \\ko\\o added" &&
+	git push &&
+	cd .. &&
+	wiki_page_exist \\ko\\o &&
+	wiki_check_content mw_dir/\\ko\\o.mw \\ko\\o &&
+	rm -rf mw_dir
+
+'
+
+# 19
+test_expect_success 'git clone with \ in format control' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	wiki_editpage \\no\\o "this is not important" false &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	test -f mw_dir/\\no\\o.mw &&
+	wiki_check_content mw_dir/\\no\\o.mw \\no\\o  
+	
+'
+
+
+# 20
+test_expect_success 'git push with \ in format contraol' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	echo "I will be on the wiki" > mw_dir/\\fo\\o.mw &&
+	cd mw_dir &&
+	git add \\fo\\o.mw &&
+	git commit -m " \\fo\\o added" &&
+	git push &&
+	cd .. &&
+	wiki_page_exist \\fo\\o &&
+	wiki_check_content mw_dir/\\fo\\o.mw \\fo\\o && 
+	rm -rf mw_dir
+
+'
+
+
+ test_done
-- 
1.7.10.2.552.gaa3bb87
Previous: Simon Cathebras
Message 40 of 40 in “Test environment for git-remote-mediawiki”
  1. Test environment for git-remote-mediawikiSimon.Cathebras, Jun 11, 2012
  2. 1/6 Scripts to install, delete and clear a MediaWikiSimon Cathebras, Jun 11, 2012
  3. 2/6 Test environment of git-remote-mediawikiSimon Cathebras, Jun 11, 2012
  4. 3/6 Test file for git-remote-mediawiki cloneSimon Cathebras, Jun 11, 2012
  5. konglu@minatec.inpg.frJun 11, 2012
  6. Simon.CathebrasJun 12, 2012
  7. 4/6 Tests for git-remote-mediawiki pullSimon Cathebras, Jun 11, 2012
  8. konglu@minatec.inpg.frJun 11, 2012
  9. Simon PerratJun 12, 2012
  10. 1/6 Scripts to install, delete and clear a MediaWikiSimon Cathebras, Jun 12, 2012
  11. 2/6 Test environment of git-remote-mediawikiSimon Cathebras, Jun 12, 2012
  12. Matthieu MoyJun 13, 2012
  13. Simon.CathebrasJun 13, 2012
  14. Ævar Arnfjörð BjarmasonJun 13, 2012
  15. Simon.CathebrasJun 13, 2012
  16. 1/5 Scripts to install, delete and clear a MediaWikiSimon Cathebras, Jun 13, 2012
  17. 2/5 Test environment of git-remote-mediawikiSimon Cathebras, Jun 13, 2012
  18. 3/5 Test file for git-remote-mediawiki cloneSimon Cathebras, Jun 13, 2012
  19. 4/5 Tests for git-remote-mediawiki pull and pushSimon Cathebras, Jun 13, 2012
  20. 5/5 Tests of UTF8 character with git-remote-mediawikiSimon Cathebras, Jun 13, 2012
  21. Matthieu MoyJun 14, 2012
  22. 1/3 chmod -x test-gitmw-lib.shMatthieu Moy, Jun 14, 2012
  23. 2/3 Coding styleMatthieu Moy, Jun 14, 2012
  24. 3/3 Explicit error when curl_exec() failsMatthieu Moy, Jun 14, 2012
  25. Simon.CathebrasJun 14, 2012
  26. Matthieu MoyJun 14, 2012
  27. Simon.CathebrasJun 14, 2012
  28. Matthieu MoyJun 14, 2012
  29. Matthieu MoyJun 14, 2012
  30. 3/6 Test file for git-remote-mediawiki cloneSimon Cathebras, Jun 12, 2012
  31. konglu@minatec.inpg.frJun 12, 2012
  32. Simon.CathebrasJun 13, 2012
  33. 4/6 Tests for git-remote-mediawiki pull and pushSimon Cathebras, Jun 12, 2012
  34. 5/6 Tests of UTF8 character with git-remote-mediawikiSimon Cathebras, Jun 12, 2012
  35. Simon.CathebrasJun 12, 2012
  36. konglu@minatec.inpg.frJun 12, 2012
  37. Simon.CathebrasJun 13, 2012
  38. konglu@minatec.inpg.frJun 12, 2012
  39. 5/6 Test file for git-remote-mediawiki pushSimon Cathebras, Jun 11, 2012
  40. =?y?q?=5BPATCHv3=206/6=5D=20Tests=20of=20UTF8=20character=20with=20git-remote-mediawiki?=Simon Cathebras, Jun 11, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.