Test environment for git-remote-mediawiki
PATCH 1/1 Test environment for git-remote-mediawiki
Good evening.
We have finally took into into account all existing advices about our contribution to git-mediawiki. We are proposing, in the following of this mail, our work for the test environment of git-mediawiki.
We would like to propose you this work for git-remote-mediawiki, because we believe that, this fonctionnality needs a suitable test environment if we intend to upgrade it in the future.
We would like to have some piece of advice for improving it. We will be glad to be accepted as a viable contribution for git-remote-mediawiki :).
Have a nice evening.
Simon C.
Signature · 6 lines
CATHEBRAS Simon 2A-ENSIMAG Filière Ingéniérie des Systèmes d'Information Membre Bug-Buster
PATCH v3 1/6 Scripts to install, delete and clear a MediaWiki
From: Guillaume Sasdy <[email protected]>
Install_wiki.sh expects the first argument to be 'install' or 'delete' 'install' installs a MediaWiki on the web's server with SQLite3 'delete' deletes the previously created wiki.
Note those functionnalities are made to be used from the user command line in the directory git/contrib/mw-to-git/t/
install_wiki also defines a function wiki_reset which clear all content of the previously created wiki. Note this functionnality is made to be used only by our test function in a subdirectory of t/
--- contrib/mw-to-git/t/install-wiki.sh | 38 +++++ contrib/mw-to-git/t/install-wiki/LocalSettings.php | 129 +++++++++++++++++ contrib/mw-to-git/t/install-wiki/db_install.php | 110 +++++++++++++++ contrib/mw-to-git/t/test-gitmw-lib.sh | 154 +++++++++++++++++++++ 4 files changed, 431 insertions(+) create mode 100755 contrib/mw-to-git/t/install-wiki.sh create mode 100644 contrib/mw-to-git/t/install-wiki/LocalSettings.php create mode 100644 contrib/mw-to-git/t/install-wiki/db_install.php create mode 100755 contrib/mw-to-git/t/test-gitmw-lib.sh
contrib/mw-to-git/t/install-wiki.sh new file +38 -0
@@ -0,0 +1,38 @@ +#!/bin/sh + +# This script installs or deletes a MediaWiki on your computer. +# It requires a web server with PHP and SQLite running. In addition, if you +# do not have MediaWiki sources on your computer, the option 'install' +# downloads them for you. +# Please set the CONFIGURATION VARIABLES in ./test-gitmw-lib.sh + +. ./test-gitmw-lib.sh + +usage () { + echo "Usage: " + echo " ./install-wiki.sh <install|delete|--help|-h>" + echo " install: Install a wiki on your computer." + echo " delete: Delete the wiki and all its pages and content" +} + + +# Argument: install, delete, --help | -h +case "$1" in + "install") + wiki_install + exit 0 + ;; + "delete") + wiki_delete + exit 0 + ;; + "--help" | "-h") + usage + exit 0 + ;; + *) + usage + exit 0 + ;; +esac +
contrib/mw-to-git/t/install-wiki/LocalSettings.php new file +129 -0
129 lines not on this page · raw message
contrib/mw-to-git/t/install-wiki/db_install.php new file +110 -0
110 lines not on this page · raw message
contrib/mw-to-git/t/test-gitmw-lib.sh new file +154 -0
154 lines not on this page · raw message
Signature · 1 line
1.7.10.2.552.gaa3bb87
PATCH v3 2/6 Test environment of git-remote-mediawiki
From: Guillaume Sasdy <[email protected]>
In order to test git-remote-mediawiki, we need a package of functions to manage a MediaWiki: edit a page, remove a page, fetch a page, fetch all pages on a given wiki.
We also need functions to compare the content of directories.
This patch provide these functions in the filegit/contrib/mw-to-git/t/test-gitmw-lib.sh andgit/contrib/mw-to-git/t/test-gitmw.pl
In addition, this patch provide Makefiles to execute tests. See README file for more details.
--- contrib/mw-to-git/Makefile | 40 +++++++ contrib/mw-to-git/t/Makefile | 32 +++++ contrib/mw-to-git/t/README | 33 ++++++ contrib/mw-to-git/t/test-gitmw-lib.sh | 117 +++++++++++++++++++ contrib/mw-to-git/t/test-gitmw.pl | 213 ++++++++++++++++++++++++++++++++++ 5 files changed, 435 insertions(+) create mode 100644 contrib/mw-to-git/Makefile create mode 100644 contrib/mw-to-git/t/Makefile create mode 100644 contrib/mw-to-git/t/README create mode 100755 contrib/mw-to-git/t/test-gitmw.pl
contrib/mw-to-git/Makefile new file +40 -0
@@ -0,0 +1,40 @@ +## Build and test git-remote-mediawiki to use with git + +-include ../../config.mak.autogen +-include ../../config.mak + +ifndef PERL_PATH + PERL_PATH = /usr/bin/perl +endif +ifndef gitexecdir + gitexecdir = $(shell git --exec-path) +endif + +PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH)) +gitexecdir_SQ = $(subst ','\'',$(gitexecdir)) + +SCRIPT = git-remote-mediawiki +RM = rm -f + +.PHONY: install help doc test clean + +help: + @echo 'This is the help target of the Makefile. Current configuration:' + @echo ' gitexecdir = $(gitexecdir_SQ)' + @echo ' PERL_PATH = $(PERL_PATH_SQ)' + @echo 'Run "$(MAKE) install" to install $(SCRIPT) in gitexecdir' + +install: + sed -e '1s|#!.*/perl|#!$(PERL_PATH_SQ)|' $(SCRIPT) \ + > '$(gitexecdir_SQ)/$(SCRIPT)' + chmod +x '$(gitexecdir)/$(SCRIPT)' + +doc: + @echo 'Sorry, "make doc" is not implemented yet for $(SCRIPT)' + +test: + $(MAKE) -C t/ test + +clean: + $(RM) '$(gitexecdir)/$(SCRIPT)' + $(MAKE) -C t/ clean
contrib/mw-to-git/t/Makefile new file +32 -0
@@ -0,0 +1,32 @@ +# Run tests +# +# Copyright (c) 2005 Junio C Hamano +# + +-include ../../../config.mak.autogen +-include ../../../config.mak + +ifndef PERL_PATH + PERL_PATH = /usr/bin/perl +endif +ifndef gitexecdir + gitexecdir = $(shell git --exec-path) +endif + +PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH)) +gitexecdir_SQ = $(subst ','\'',$(gitexecdir)) +T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh) + +.PHONY: help test clean + +help: + @echo 'This is the help target of the Makefile. Current configuration:' + @echo ' gitexecdir = $(gitexecdir_SQ)' + @echo ' PERL_PATH = $(PERL_PATH_SQ)' + @echo 'Run "$(MAKE) test" to launch test scripts' + +test: + for t in $(T); do "./$$t"; done + +clean: + $(RM) -r 'trash directory'.*
contrib/mw-to-git/t/README new file +33 -0
@@ -0,0 +1,33 @@ +Tests for Mediawiki-to-Git +========================== + + +Installation +------------ +These tests require a mediawiki with admin access to work on; you can install one +on localhost/wiki simply by running: + ./install-wiki.sh install +Be aware that the tests will flush the wiki database, thus if you own a wiki at +this adress, it is strongly advised to configure another name in test-gitmw-lib.sh +before running the script. +Note that the wiki will be installed in /tmp (this can be configured too), meaning +you might have to install it again when you run tests later. + + +Running +------- +You can run these tests either individually or with make (recommended). Remember +to use make clean when you're done. You have access to all options from git core +tests. + + +Limitations +------- +This test environment does not allow you to test the behavior of git-remote-mediawiki +for name containing backslashes. + +t9360: tests git clone. + +t9361: tests git pull and git push. + +t9362: tests how UTF-8 special characters are handled.
contrib/mw-to-git/t/test-gitmw-lib.sh +117 -0
123 lines not on this page · raw message
contrib/mw-to-git/t/test-gitmw.pl new file +213 -0
213 lines not on this page · raw message
Signature · 1 line
1.7.10.2.552.gaa3bb87
PATCH v3 3/6 Test file for git-remote-mediawiki clone
In reply to Simon CathebrasFrom: Guillaume Sasdy <[email protected]>
This patch provides some tests for the clone in use by git-remote-mediawiki.
These tests are in the file:git/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh
--- contrib/mw-to-git/t/t9360-mw-to-git-clone.sh | 324 +++++++++++++++++++++++++++ 1 file changed, 324 insertions(+) create mode 100755 contrib/mw-to-git/t/t9360-mw-to-git-clone.sh
contrib/mw-to-git/t/t9360-mw-to-git-clone.sh new file +324 -0
@@ -0,0 +1,324 @@ +#!/bin/sh +# +# Copyright (C) 2012 +# Charles Roussel <[email protected]> +# Simon Cathebras <[email protected]> +# Julien Khayat <[email protected]> +# Guillaume Sasdy <[email protected]> +# Simon Perrat <[email protected]> +# +# License: GPL v2 or later + + +test_description='Test the Git Mediawiki remote helper: git clone' + +. ./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 creates the git log expected with one file' ' + wiki_reset && + cd '"$TRASH_DIR"' && + rm -rf mw_dir && + wiki_editpage foo "this is not important" false -c cat -s "this must be the same" && + git clone mediawiki::http://localhost/wiki mw_dir && + cd mw_dir && + git log --format=%s HEAD^..HEAD > log.tmp && + echo "this must be the same" > msg.tmp && + diff -b log.tmp msg.tmp && + cd .. && + rm -rf mw_dir +' + +# 2 +test_expect_success 'Git clone creates the git log expected with multiple files' ' + wiki_reset && + cd '"$TRASH_DIR"' && + rm -rf mw_dir && + wiki_editpage daddy "this is not important" false -s="this must be the same" && + wiki_editpage daddy "neither is this" true -s="this must also be the same" && + wiki_editpage daddy "neither is this" true -s="same same same" && + wiki_editpage dj "dont care" false -s="identical" && + wiki_editpage dj "dont care either" true -s="identical too" && + git clone mediawiki::http://localhost/wiki mw_dir && + cd mw_dir && + git log --format=%s Daddy.mw > logDaddy.tmp && + git log --format=%s Dj.mw > logDj.tmp && + echo "same same same" > msgDaddy.tmp && + echo "this must also be the same" >> msgDaddy.tmp && + echo "this must be the same" >> msgDaddy.tmp && + echo "identical too" > msgDj.tmp && + echo "identical" >> msgDj.tmp && + diff -b logDaddy.tmp msgDaddy.tmp && + diff -b logDj.tmp msgDj.tmp && + cd .. && + rm -rf mw_dir +' + +# 3 +test_expect_success 'Git clone creates only Main_Page.mw with an empty wiki' ' + wiki_reset && + cd '"$TRASH_DIR"' && + rm -rf mw_dir && + git clone mediawiki::http://localhost/wiki mw_dir && + test_contains_N_files mw_dir 1 && + test -e mw_dir/Main_Page.mw && + rm -rf mw_dir +' + +# 4 +test_expect_success 'Git clone does not fetch a deleted page' ' + wiki_reset && + cd '"$TRASH_DIR"' && + rm -rf mw_dir && + wiki_editpage foo "this page must be deleted before the clone" false && + wiki_delete_page foo && + git clone mediawiki::http://localhost/wiki mw_dir && + test_contains_N_files mw_dir 1 && + test -e mw_dir/Main_Page.mw && + test ! -e mw_dir/Foo.mw && + rm -rf mw_dir +' + +# 5 +test_expect_success 'Git clone works with page added' ' + wiki_reset && + cd '"$TRASH_DIR"' && + rm -rf mw_dir && + wiki_editpage foo " I will be cloned" false && + wiki_editpage bar "I will be cloned" false && + git clone mediawiki::http://localhost/wiki mw_dir && + wiki_getallpage ref_page && + test_diff_directories mw_dir ref_page && + wiki_delete_page foo && + rm -rf mw_dir && + rm -rf ref_page && + wiki_delete_page bar +' + +# 6 +test_expect_success 'Git clone works with an edited page ' ' + wiki_reset && + cd '"$TRASH_DIR"' && + rm -rf mw_dir && + rm -rf ref_page && + + wiki_editpage foo "this page will be edited" \ + false -s "first edition of page foo"&& + wiki_editpage foo "this page has been edited and must be on the clone " true && + git clone mediawiki::http://localhost/wiki mw_dir && + test -e mw_dir/Foo.mw && + test -e mw_dir/Main_Page.mw && + wiki_getallpage mw_dir/page_ref && + test_diff_directories mw_dir mw_dir/page_ref && + cd mw_dir && + git log --format=%s HEAD^ Foo.mw > ../Foo.log && + cd .. && + echo "first edition of page foo" > FooExpect.log && + rm -rf mw_dir && + diff FooExpect.log Foo.log +' + +# 7 +test_expect_success 'Git clone works with several pages and some deleted ' ' + wiki_reset && + cd '"$TRASH_DIR"' && + rm -rf mw_dir && + wiki_editpage foo "this page will not be deleted" false && + wiki_editpage bar "I must not be erased" false && + wiki_editpage namnam "I will not be there at the end" false && + wiki_editpage nyancat "nyan nyan nyan delete me" false && + wiki_delete_page namnam && + wiki_delete_page nyancat && + git clone mediawiki::http://localhost/wiki mw_dir && + test -e mw_dir/Foo.mw && + test -e mw_dir/Bar.mw && + test ! -e mw_dir/Namnam.mw && + test ! -e mw_dir/Nyancat.mw && + wiki_getallpage mw_dir/page_ref && + test_diff_directories mw_dir mw_dir/page_ref && + rm -rf mw_dir +' + +# 8 +test_expect_success 'Git clone works with one specific page cloned ' ' + wiki_reset && + cd '"$TRASH_DIR"' && + rm -rf mw_dir && + wiki_editpage foo "I will not be cloned" false && + wiki_editpage bar "Do not clone me" false && + wiki_editpage namnam "I will be cloned :)" false -s="this log must stay" && + wiki_editpage nyancat "nyan nyan nyan you cant clone me" false && + git clone -c remote.origin.pages=namnam mediawiki::http://localhost/wiki mw_dir && + test_contains_N_files mw_dir 1 && + test -e mw_dir/Namnam.mw && + test ! -e mw_dir/Main_Page.mw && + cd mw_dir && + echo "this log must stay" > msg.tmp && + git log --format=%s > log.tmp && + diff -b msg.tmp log.tmp && + cd .. && + wiki_check_content mw_dir/Namnam.mw Namnam && + rm -rf mw_dir +' + +# 9 +test_expect_success 'Git clone works with multiple specific page cloned ' ' + wiki_reset && + cd '"$TRASH_DIR"' && + rm -rf mw_dir && + wiki_editpage foo "I will be there" false && + wiki_editpage bar "I will not disapear" false && + wiki_editpage namnam "I be erased" false && + wiki_editpage nyancat "nyan nyan nyan you will not erase me" false && + wiki_delete_page namnam && + git clone -c remote.origin.pages='"'foo bar nyancat namnam'"' mediawiki::http://localhost/wiki mw_dir && + test_contains_N_files mw_dir 3 && + test ! -e mw_dir/Namnam.mw && + test -e mw_dir/Foo.mw && + test -e mw_dir/Nyancat.mw && + test -e mw_dir/Bar.mw && + wiki_check_content mw_dir/Foo.mw Foo && + wiki_check_content mw_dir/Bar.mw Bar && + wiki_check_content mw_dir/Nyancat.mw Nyancat && + rm -rf mw_dir +' + +# 10 +test_expect_success 'Mediawiki-clone of several specific pages on wiki' ' + wiki_reset && + cd '"$TRASH_DIR"' && + rm -rf mw_dir && + wiki_editpage foo "foo 1" false && + wiki_editpage bar "bar 1" false && + wiki_editpage dummy "dummy 1" false && + wiki_editpage cloned_1 "cloned_1 1" false && + wiki_editpage cloned_2 "cloned_2 2" false && + wiki_editpage cloned_3 "cloned_3 3" false && + mkdir -p ref_page && + wiki_getpage cloned_1 ref_page && + wiki_getpage cloned_2 ref_page && + wiki_getpage cloned_3 ref_page && + git clone -c remote.origin.pages="cloned_1 cloned_2 cloned_3" mediawiki::http://localhost/wiki mw_dir_spage && + test_diff_directories mw_dir_spage ref_page && + rm -rf mw_dir_spage && + rm -rf ref_page +' + +# 11 +test_expect_success 'Git clone works with the shallow option' ' + wiki_reset && + cd '"$TRASH_DIR"' && + rm -rf mw_dir_s_page && + rm -rf ref_page && + wiki_editpage foo "1st revision, should be cloned" false && + wiki_editpage bar "1st revision, should be cloned" false && + wiki_editpage nyan "1st revision, should not be cloned" false && + wiki_editpage nyan "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 4 && + test -e mw_dir/Nyan.mw && + test -e mw_dir/Foo.mw && + test -e mw_dir/Bar.mw && + test -e mw_dir/Main_Page.mw && + cd mw_dir && + test `git log --oneline Nyan.mw | wc -l` -eq 1 && + test `git log --oneline Foo.mw | wc -l` -eq 1 && + test `git log --oneline Bar.mw | wc -l` -eq 1 && + test `git log --oneline Main_Page.mw | wc -l ` -eq 1 && + cd .. && + wiki_check_content mw_dir/Nyan.mw Nyan && + wiki_check_content mw_dir/Foo.mw Foo && + wiki_check_content mw_dir/Bar.mw Bar && + wiki_check_content mw_dir/Main_Page.mw Main_Page && + rm -rf mw_dir +' + +# 12 +test_expect_success 'Git clone works with the shallow option with a delete page' ' + wiki_reset && + cd '"$TRASH_DIR"' && + rm -rf mw_dir && + wiki_editpage foo "1st revision, will be deleted" false && + wiki_editpage bar "1st revision, should be cloned" false && + wiki_editpage nyan "1st revision, should not be cloned" false && + wiki_editpage nyan "2nd revision, should be cloned" false && + wiki_delete_page foo && + git -c remote.origin.shallow=true clone mediawiki::http://localhost/wiki/ mw_dir && + test_contains_N_files mw_dir 3 && + test -e mw_dir/Nyan.mw && + test ! -e mw_dir/Foo.mw && + test -e mw_dir/Bar.mw && + test -e mw_dir/Main_Page.mw && + cd mw_dir && + test `git log --oneline Nyan.mw | wc -l` -eq 1 && + test `git log --oneline Bar.mw | wc -l` -eq 1 && + test `git log --oneline Main_Page.mw | wc -l ` -eq 1 && + cd .. && + wiki_check_content mw_dir/Nyan.mw Nyan && + wiki_check_content mw_dir/Bar.mw Bar && + wiki_check_content mw_dir/Main_Page.mw Main_Page && + rm -rf mw_dir +' + +# 13 +test_expect_success 'Test of fetching a category' ' + wiki_reset && + cd '"$TRASH_DIR"' && + rm -rf mw_dir && + wiki_editpage Foo "I will be cloned" false -c=Category && + wiki_editpage Bar "Meet me on the repository" false -c=Category && + wiki_editpage Dummy "I will not come" false && + wiki_editpage BarWrong "I will stay online only" false -c=NotCategory && + git clone -c remote.origin.categories="Category" mediawiki::http://localhost/wiki mw_dir && + wiki_getallpage ref_page Category && + test_diff_directories mw_dir ref_page + rm -rf mw_dir && + rm -rf ref_page +' + +# 14 +test_expect_success 'Test of resistance to modification of category on wiki for clone' ' + wiki_reset && + cd '"$TRASH_DIR"' && + rm -rf mw_dir && + rm -rf ref_page && + wiki_editpage Tobedeleted "this page will be deleted" false -c=Catone && + wiki_editpage Tobeedited "this page will be modified" false -c=Catone && + wiki_editpage Normalone "this page wont be modified and will be on git" false -c=Catone && + wiki_editpage Notconsidered "this page will not appear on local" false && + wiki_editpage Othercategory "this page will not appear on local" false -c=Cattwo && + wiki_editpage Tobeedited "this page have been modified" true -c=Catone && + wiki_delete_page Tobedeleted + git clone -c remote.origin.categories="Catone" mediawiki::http://localhost/wiki mw_dir && + wiki_getallpage ref_page Catone && + test_diff_directories mw_dir ref_page && + rm -rf mw_dir && + rm -rf ref_page +' + +test_done
Signature · 1 line
1.7.10.2.552.gaa3bb87
Re: [PATCHv3 3/6] Test file for git-remote-mediawiki clone
Simon Cathebras <[email protected]> a écrit :
Quoted 6 lines
contrib/mw-to-git/t/t9360-mw-to-git-clone.sh new file +5
-0+test_expect_success 'Git clone creates the git log expected with one file' ' + wiki_reset && + cd '"$TRASH_DIR"' && + rm -rf mw_dir && + wiki_editpage foo "this is not important" false -c cat -s "thismust be the same" &&
contrib/mw-to-git/t/t9360-mw-to-git-clone.sh line 56
Quoted 9 lines
contrib/mw-to-git/t/t9360-mw-to-git-clone.sh new file +9
-0+ git clone mediawiki::http://localhost/wiki mw_dir && + cd mw_dir && + git log --format=%s HEAD^..HEAD > log.tmp && + echo "this must be the same" > msg.tmp && + diff -b log.tmp msg.tmp && + cd .. && + rm -rf mw_dir +' +
It's best not to chdir around outside a subshell (same comment for all the other tests)
BTW, please be aware of the whitespaces (the first 5 parts of your patch are full of it - couldn't apply the last one because of the special characters, maybe
something that i haven't configure, i don't know).
Re: [PATCHv3 3/6] Test file for git-remote-mediawiki clone
Quoted 15 lines · On 11/06/2012 23:07, [email protected] wrote:
Quoted 11 lines · Simon Cathebras
+test_expect_success 'Git clone creates the git log expected with one file' '
contrib/mw-to-git/t/t9360-mw-to-git-clone.sh new file +4
-0+ wiki_reset && + cd '"$TRASH_DIR"' && + rm -rf mw_dir && + wiki_editpage foo "this is not important" false -c cat -s "thismust be the same" &&
contrib/mw-to-git/t/t9360-mw-to-git-clone.sh new file +4
-0+ git clone mediawiki::http://localhost/wiki mw_dir && + cd mw_dir && + git log --format=%s HEAD^..HEAD > log.tmp && + echo "this must be the same" > msg.tmp &&
Quoted 8 lines
contrib/mw-to-git/t/t9360-mw-to-git-clone.sh line 56
Quoted 5 lines
contrib/mw-to-git/t/t9360-mw-to-git-clone.sh new file +5
-0+ diff -b log.tmp msg.tmp && + cd .. && + rm -rf mw_dir +' +It's best not to chdir around outside a subshell (same comment for all the other tests)
Thanks, we managed to change these problems of chdir.
Quoted 6 lines
BTW, please be aware of the whitespaces (the first 5 parts of your patch are full of it - couldn't apply the last one because of the special characters, maybe something that i haven't configure, i don't know).
Got it. We modified this issue with whitespaces.
In addition, we know what prevented you to install the last patch: encoding problem. It will be fixed in the next update.
Simon
Signature · 6 lines
CATHEBRAS Simon 2A-ENSIMAG Filière Ingéniérie des Systèmes d'Information Membre Bug-Buster
PATCH v3 4/6 Tests for git-remote-mediawiki pull
In reply to Simon CathebrasFrom: Guillaume Sasdy <[email protected]>
This patch provides a set of tests for the pull fonctionnality of git-remote-mediawiki.
These tests are part of the filegit/contrib/mw-to-git/t/t9361-mw-to-git-pull.sh
--- contrib/mw-to-git/t/t9361-mw-to-git-pull.sh | 149 ++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100755 contrib/mw-to-git/t/t9361-mw-to-git-pull.sh
contrib/mw-to-git/t/t9361-mw-to-git-pull.sh new file +149 -0
@@ -0,0 +1,149 @@ +#!/bin/sh +# +# Copyright (C) 2012 +# Charles Roussel <[email protected]> +# Simon Cathebras <[email protected]> +# Julien Khayat <[email protected]> +# Guillaume Sasdy <[email protected]> +# Simon Perrat <[email protected]> +# +# License: GPL v2 or later + +# tests for git-remote-mediawiki + +test_description='Test the Git Mediawiki remote helper: git push and git pull simple test cases' + +. ./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 + + +test_expect_success 'Git pull works after adding a new wiki page' " + wiki_reset && + cd $TRASH_DIR && + rm -rf mw_dir && + rm -rf ref_page && + + git clone mediawiki::http://$SERVER_ADDR/$WIKI_DIR_NAME mw_dir && + wiki_editpage Foo \"page created after the git clone\" false && + + cd mw_dir && + git pull && + cd .. && + + rm -rf ref_page && + wiki_getallpage ref_page && + test_diff_directories mw_dir ref_page && + rm -rf ref_page && + rm -rf mw_dir +" + +test_expect_success 'Git pull works after editing a wiki page' " + wiki_reset && + cd $TRASH_DIR && + rm -rf mw_dir && + rm -rf ref_page && + + wiki_editpage Foo \"page created before the git clone\" false && + git clone mediawiki::http://$SERVER_ADDR/$WIKI_DIR_NAME mw_dir && + wiki_editpage Foo \"new line added on the wiki\" true && + + cd mw_dir && + git pull && + cd .. && + + rm -rf ref_page && + wiki_getallpage ref_page && + test_diff_directories mw_dir ref_page && + rm -rf ref_page && + rm -rf mw_dir +" + +test_expect_success 'git pull works on conflict handled by auto-merge' " + wiki_reset && + cd $TRASH_DIR && + rm -rf mw_dir && + rm -rf ref_page && + + wiki_editpage Foo \"1 init +3 +5 +\" false && + git clone mediawiki::http://$SERVER_ADDR/$WIKI_DIR_NAME mw_dir && + + wiki_editpage Foo \"1 init +2 content added on wiki after clone +3 +5 +\" false && + + cd mw_dir && + echo \"1 init +3 +4 content added on git after clone +5 +\" > Foo.mw && + git commit -am \"conflicting change on foo\" && + git pull && + git push && + cd .. && + + rm -rf mw_dir +" + +test_expect_success 'Merge conflict expected' " + wiki_reset && + cd $TRASH_DIR && + rm -rf mw_dir && + rm -rf ref_page && + + git clone mediawiki::http://$SERVER_ADDR/$WIKI_DIR_NAME mw_dir && + wiki_editpage Foo \"1 conflict +3 wiki +4\" false && + + cd mw_dir && + echo \"1 conflict +2 git +4\" > Foo.mw && + git add Foo.mw && + git commit -m \"conflict created\" && + test_must_fail git pull +" + +test_expect_failure 'git pull works after deleting a wiki page' " + wiki_reset && + cd $TRASH_DIR && + wiki_editpage Foo \"wiki page added before the git clone\" false && + git clone mediawiki::http://$SERVER_ADDR/$WIKI_DIR_NAME mw_dir && + + wiki_delete_page Foo && + cd mw_dir && + git pull && + test ! -f Foo.mw && + cd .. && + + rm -rf mw_dir +" + +test_done +
Signature · 1 line
1.7.10.2.552.gaa3bb87
Re: [PATCHv3 4/6] Tests for git-remote-mediawiki pull
Simon Cathebras <[email protected]> a écrit :
Quoted 9 lines
contrib/mw-to-git/t/t9361-mw-to-git-pull.sh new file +9
-0+test_expect_success 'Git pull works after adding a new wiki page' " + wiki_reset && + cd $TRASH_DIR && + rm -rf mw_dir && + rm -rf ref_page && + + git clone mediawiki::http://$SERVER_ADDR/$WIKI_DIR_NAME mw_dir && + wiki_editpage Foo \"page created after the git clone\" false && +
contrib/mw-to-git/t/t9361-mw-to-git-pull.sh line 58
Quoted 10 lines
contrib/mw-to-git/t/t9361-mw-to-git-pull.sh new file +10
-0+ cd mw_dir && + git pull && + cd .. && + + rm -rf ref_page && + wiki_getallpage ref_page && + test_diff_directories mw_dir ref_page && + rm -rf ref_page && + rm -rf mw_dir +"
Why are there dquotes here (and all the following tests) ? You used simple quote in t9360.
PATCH 1/6 Scripts to install, delete and clear a MediaWiki
From: Guillaume Sasdy <[email protected]>
Install_wiki.sh expects the first argument to be 'install' or 'delete' 'install' installs a MediaWiki on the web's server with SQLite3 'delete' deletes the previously created wiki.
Note those functionnalities are made to be used from the user command line in the directory git/contrib/mw-to-git/t/
install_wiki also defines a function wiki_reset which clear all content of the previously created wiki. Note this functionnality is made to be used only by our test function in a subdirectory of t/
--- contrib/mw-to-git/t/install-wiki.sh | 45 ++++ contrib/mw-to-git/t/install-wiki/LocalSettings.php | 128 +++++++++ contrib/mw-to-git/t/install-wiki/db_install.php | 110 ++++++++ contrib/mw-to-git/t/test-gitmw-lib.sh | 285 +++++++++++++++++++++ contrib/mw-to-git/t/test.config | 35 +++ 5 files changed, 603 insertions(+) create mode 100755 contrib/mw-to-git/t/install-wiki.sh create mode 100644 contrib/mw-to-git/t/install-wiki/LocalSettings.php create mode 100644 contrib/mw-to-git/t/install-wiki/db_install.php create mode 100755 contrib/mw-to-git/t/test-gitmw-lib.sh create mode 100644 contrib/mw-to-git/t/test.config
contrib/mw-to-git/t/install-wiki.sh new file +45 -0
@@ -0,0 +1,45 @@ +#!/bin/sh + +# This script installs or deletes a MediaWiki on your computer. +# It requires a web server with PHP and SQLite running. In addition, if you +# do not have MediaWiki sources on your computer, the option 'install' +# downloads them for you. +# Please set the CONFIGURATION VARIABLES in ./test-gitmw-lib.sh + +WIKI_TEST_DIR=$(cd "$(dirname "$0")" && pwd) + +if test -z "$WIKI_TEST_DIR" +then + WIKI_TEST_DIR=. +fi + +. "$WIKI_TEST_DIR"/test-gitmw-lib.sh +usage () { + echo "Usage: " + echo " ./install-wiki.sh <install | delete | help>" + echo " install | -i : Install a wiki on your computer." + echo " delete | -d : Delete the wiki and all its pages and " + echo " content." +} + + +# Argument: install, delete, --help | -h +case "$1" in + "install" | "-i") + wiki_install + exit 0 + ;; + "delete" | "-d") + wiki_delete + exit 0 + ;; + "--help" | "-h") + usage + exit 0 + ;; + *) + echo "Invalid argument: $1" + usage + exit 1 + ;; +esac
contrib/mw-to-git/t/install-wiki/LocalSettings.php new file +128 -0
128 lines not on this page · raw message
contrib/mw-to-git/t/install-wiki/db_install.php new file +110 -0
110 lines not on this page · raw message
contrib/mw-to-git/t/test-gitmw-lib.sh new file +285 -0
285 lines not on this page · raw message
contrib/mw-to-git/t/test.config new file +35 -0
@@ -0,0 +1,35 @@ +# Name of the web server's directory dedicated to the wiki is WIKI_DIR_NAME +WIKI_DIR_NAME=wiki + +# Login and password of the wiki's admin +WIKI_ADMIN=WikiAdmin +WIKI_PASSW=AdminPass + +# Address of the web server +SERVER_ADDR=localhost + +# SQLite database of the wiki, named DB_FILE, is located in TMP +TMP=/tmp +DB_FILE=wikidb.sqlite + +# If LIGHTTPD is not set to true, the script will use the defaut +# web server running in WIKI_DIR_INST. +WIKI_DIR_INST=/var/www + +# If LIGHTTPD is set to true, the script will use Lighttpd to run +# the wiki. +LIGHTTPD=true + +# The variables below are useful only if LIGHTTPD is set to true. +PORT=1234 +PHP_DIR=/usr/bin +LIGHTTPD_DIR=/usr/sbin +WEB=WEB +WEB_TMP=$WEB/tmp +WEB_WWW=$WEB/www + +# The variables below are used by the script to install a wiki. +# You should not modify these unless you are modifying the script itself. +MW_VERSION=mediawiki-1.19.0 +FILES_FOLDER=install-wiki +DB_INSTALL_SCRIPT=db_install.php
Signature · 1 line
1.7.10.2.552.gaa3bb87
PATCH 2/6 Test environment of git-remote-mediawiki
From: Guillaume Sasdy <[email protected]>
In order to test git-remote-mediawiki, we need a package of functions to manage a MediaWiki: edit a page, remove a page, fetch a page, fetch all pages on a given wiki.
We also need functions to compare the content of directories.
This patch provide these functions in the filegit/contrib/mw-to-git/t/test-gitmw-lib.sh andgit/contrib/mw-to-git/t/test-gitmw.pl
In addition, this patch provide Makefiles to execute tests. See README file for more details.
--- contrib/mw-to-git/Makefile | 48 +++++++ contrib/mw-to-git/t/Makefile | 27 ++++ contrib/mw-to-git/t/README | 33 +++++ contrib/mw-to-git/t/test-gitmw-lib.sh | 137 ++++++++++++++++++++ contrib/mw-to-git/t/test-gitmw.pl | 230 ++++++++++++++++++++++++++++++++++ 5 files changed, 475 insertions(+) create mode 100644 contrib/mw-to-git/Makefile create mode 100644 contrib/mw-to-git/t/Makefile create mode 100644 contrib/mw-to-git/t/README create mode 100755 contrib/mw-to-git/t/test-gitmw.pl
contrib/mw-to-git/Makefile new file +48 -0
@@ -0,0 +1,48 @@ +# +# Copyright (C) 2012 +# Charles Roussel <[email protected]> +# Simon Cathebras <[email protected]> +# Julien Khayat <[email protected]> +# Guillaume Sasdy <[email protected]> +# Simon Perrat <[email protected]> +# +## Build git-remote-mediawiki + +-include ../../config.mak.autogen +-include ../../config.mak + +ifndef PERL_PATH + PERL_PATH = /usr/bin/perl +endif +ifndef gitexecdir + gitexecdir = $(shell git --exec-path) +endif + +PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH)) +gitexecdir_SQ = $(subst ','\'',$(gitexecdir)) +SCRIPT = git-remote-mediawiki + +.PHONY: install help doc test clean + +help: + @echo 'This is the help target of the Makefile. Current configuration:' + @echo ' gitexecdir = $(gitexecdir_SQ)' + @echo ' PERL_PATH = $(PERL_PATH_SQ)' + @echo 'Run "$(MAKE) install" to install $(SCRIPT) in gitexecdir' + @echo 'Run "$(MAKE) test" to run the testsuite' + +install: + sed -e '1s|#!.*/perl|#!$(PERL_PATH_SQ)|' $(SCRIPT) \ + > '$(gitexecdir_SQ)/$(SCRIPT)' + chmod +x '$(gitexecdir)/$(SCRIPT)' + +doc: + @echo 'Sorry, "make doc" is not implemented yet for $(SCRIPT)' + +test: + $(MAKE) -C t/ test + +clean: + $(RM) '$(gitexecdir)/$(SCRIPT)' + $(MAKE) -C t/ clean +
contrib/mw-to-git/t/Makefile new file +27 -0
@@ -0,0 +1,27 @@ +# +# Copyright (C) 2012 +# Charles Roussel <[email protected]> +# Simon Cathebras <[email protected]> +# Julien Khayat <[email protected]> +# Guillaume Sasdy <[email protected]> +# Simon Perrat <[email protected]> +# +## Test git-remote-mediawiki + +-include ../../../config.mak.autogen +-include ../../../config.mak + +T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh) + +.PHONY: help test clean + +help: + @echo 'Run "$(MAKE) test" to launch test scripts' + @echo 'Run "$(MAKE)" clean to remove trash folders' + +test: + for t in $(T); do "./$$t"; done + +clean: + $(RM) -r 'trash directory'.* +
contrib/mw-to-git/t/README new file +33 -0
@@ -0,0 +1,33 @@ +Tests for Mediawiki-to-Git +========================== + + +Installation +------------ +These tests require a mediawiki with admin access to work on; you can install one +on localhost/wiki simply by running: + ./install-wiki.sh install +Be aware that the tests will flush the wiki database, thus if you own a wiki at +this adress, it is strongly advised to configure another name in test-gitmw-lib.sh +before running the script. +Note that the wiki will be installed in /tmp (this can be configured too), meaning +you might have to install it again when you run tests later. + + +Running +------- +You can run these tests either individually or with make (recommended). Remember +to use make clean when you're done. You have access to all options from git core +tests. + + +Limitations +------- +This test environment does not allow you to test the behavior of git-remote-mediawiki +for name containing backslashes. + +t9360: tests git clone. + +t9361: tests git pull and git push. + +t9362: tests how UTF-8 special characters are handled.
contrib/mw-to-git/t/test-gitmw-lib.sh +137 -0
143 lines not on this page · raw message
contrib/mw-to-git/t/test-gitmw.pl new file +230 -0
230 lines not on this page · raw message
Signature · 1 line
1.7.10.2.552.gaa3bb87
Re: [PATCH 2/6] Test environment of git-remote-mediawiki
On Tue, Jun 12, 2012 at 11:12 PM, Simon Cathebras
<[email protected]> wrote:
Some comments on your perl style:
contrib/mw-to-git/t/test-gitmw.pl line 38
Quoted 12 lines
contrib/mw-to-git/t/test-gitmw.pl new file +12
-0+use Switch; +use encoding 'utf8'; +use DateTime::Format::ISO8601; +use open ':encoding(utf8)'; +use constant SLASH_REPLACEMENT => "%2F"; + +#Parsing of the config file + +my $configfile = "$ENV{'CURR_DIR'}/test.config"; +my %config; +open (CONFIG,"< $configfile") || die "can't open $configfile: $!"; +while (<CONFIG>)
You probably want to use lexical filehandles instead:
open my $config, "<", $configfile or die "...";
while (<$config>)And also note the three-arg open I'm using, might want to change the rest to use that.
contrib/mw-to-git/t/test-gitmw.pl line 49
Quoted 11 lines
contrib/mw-to-git/t/test-gitmw.pl new file +11
-0+{ + chomp; + s/#.*//; + s/^\s+//; + s/\s+$//; + next unless length; + my ($key, $value) = split (/\s*=\s*/,$_, 2); + $config{$key} = $value; + last if ($key eq 'LIGHTTPD' and $value eq 'false'); + last if ($key eq 'PORT'); +}
And add:
close $config or die "can't close $configfile: $!";
Also you can do:
while (my $line = <$config>) {
chomp $line;Which IMO makes any code that's more than 2-3 lines long less confusing as there's no doubt what $_ refers to.
Quoted 19 lines
contrib/mw-to-git/t/test-gitmw.pl new file +19
-0+my $wiki_address = "http://$config{'SERVER_ADDR'}".":"."$config{'PORT'}"; +my $wiki_url = "$wiki_address/$config{'WIKI_DIR_NAME'}/api.php"; +my $wiki_admin = "$config{'WIKI_ADMIN'}"; +my $wiki_admin_pass = "$config{'WIKI_PASSW'}"; +my $mw = MediaWiki::API->new; +$mw->{config}->{api_url} = $wiki_url; + +sub mediawiki_clean_filename { + my $filename = shift; + $filename =~ s/@{[SLASH_REPLACEMENT]}/\//g; + # [, ], |, {, and } are forbidden by MediaWiki, even URL-encoded. + # Do a variant of URL-encoding, i.e. looks like URL-encoding, + # but with _ added to prevent MediaWiki from thinking this is + # an actual special character. + $filename =~ s/[\[\]\{\}\|]/sprintf("_%%_%x", ord($&))/ge; + # If we use the uri escape before + # we should unescape here, before anything + + return $filename;
contrib/mw-to-git/t/test-gitmw.pl line 79
Quoted 10 lines
contrib/mw-to-git/t/test-gitmw.pl new file +10
-0+} + +sub mediawiki_smudge_filename { + my $filename = shift; + $filename =~ s/\//@{[SLASH_REPLACEMENT]}/g; + $filename =~ s/ /_/g; + # Decode forbidden characters encoded in mediawiki_clean_filename + $filename =~ s/_%_([0-9a-fA-F][0-9a-fA-F])/sprintf("%c", hex($1))/ge; + return $filename; +}
I don't how in the big picture you're aiming to encode article names as filenames but if you can at all avoid doing so (i.e. the user doesn't need to be exposed to those files) it's much simpler just to take the article name, sha1sum it and use the first 5-10 bytes of that as the filename.
With all the filesystems and OS's out there and their odd rules it can be tricky to write code that takes an arbitrary string and attempts to cast it to a valid filename or path.
Quoted 139 lines
contrib/mw-to-git/t/test-gitmw.pl new file +139
-0+# wiki_login <name> <password> +# +# Logs the user with <name> and <password> in the global variable +# of the mediawiki $mw +sub wiki_login { + $mw->login( { lgname => "$_[0]",lgpassword => "$_[1]" } ) + || die "getpage: login failed"; +} + +# wiki_getpage <wiki_page> <dest_path> +# +# fetch a page <wiki_page> from the wiki referenced in the global variable +# $mw and copies its content in directory dest_path +sub wiki_getpage { + my $pagename = $_[0]; + my $destdir = $_[1]; + + my $page = $mw->get_page( { title => $pagename } ); + if (!defined($page)) { + die "getpage: wiki does not exist"; + } + + my $content = $page->{'*'}; + if (!defined($content)) { + die "getpage: page does not exist"; + } + + # Replace spaces by underscore in the page name + $pagename=$page->{'title'}; + $pagename = mediawiki_smudge_filename $pagename; + open(my $file, ">$destdir/$pagename.mw"); + print $file "$content"; + close ($file); + +} + +# wiki_delete_page <page_name> +# +# delete the page with name <page_name> from the wiki referenced +# in the global variable $mw +sub wiki_delete_page { + my $pagename = $_[0]; + + my $exist=$mw->get_page({title => $pagename}); + + if (defined($exist->{'*'})){ + $mw->edit({ action => 'delete', + title => $pagename}) + || die $mw->{error}->{code} . ": " . $mw->{error}->{details}; + } else { + die "no page with such name found: $pagename\n"; + } +} + +# wiki_editpage <wiki_page> <wiki_content> <wiki_append> [-c=<category>] [-s=<summary>] +# +# Edit a page named <wiki_page> with content <wiki_content> on the wiki +# referenced with the global variable $mw +# If <wiki_append> == true : append <wiki_content> at the end of the actual +# content of the page <wiki_page> +# If <wik_page> doesn't exist, that page is created with the <wiki_content> +sub wiki_editpage { + my $wiki_page = mediawiki_clean_filename $_[0]; + my $wiki_content = $_[1]; + my $wiki_append = $_[2]; + my $summary = ""; + my ($summ, $cat) = (); + GetOptions('s=s' => \$summ, 'c=s' => \$cat); + + my $append = 0; + if (defined($wiki_append) && $wiki_append eq 'true') { + $append=1; + } + + my $previous_text =""; + + if ($append) { + my $ref = $mw->get_page( { title => $wiki_page } ); + $previous_text = $ref->{'*'}; + } + + my $text = $wiki_content; + if (defined($previous_text)) { + $text="$previous_text$text"; + } + + # Eventually, add this page to a category. + if (defined($cat)) { + my $category_name="[[Category:$cat]]"; + $text="$text\n $category_name"; + } + if(defined($summ)){ + $summary=$summ; + } + + $mw->edit( { action => 'edit', title => $wiki_page, summary => $summary, text => "$text"} ); +} + +# wiki_getallpagename [<category>] +# +# Fetch all pages of the wiki referenced by the global variable $mw +# and print the names of each one in the file all.txt with a new line +# ("\n") between these. +# If the argument <category> is defined, then this function get only the pages +# belonging to <category>. +sub wiki_getallpagename { + # fetch the pages of the wiki + if (defined($_[0])) { + my $mw_pages = $mw->list ( { action => 'query', + list => 'categorymembers', + cmtitle => "Category:$_[0]", + cmnamespace => 0, + cmlimit=> 500 }, + ) + || die $mw->{error}->{code}.": ".$mw->{error}->{details}; + open(my $file, ">all.txt"); + foreach my $page (@{$mw_pages}) { + print $file "$page->{title}\n"; + } + close ($file); + + } else { + my $mw_pages = $mw->list({ + action => 'query', + list => 'allpages', + aplimit => 500, + }) + || die $mw->{error}->{code}.": ".$mw->{error}->{details}; + open(my $file, ">all.txt"); + foreach my $page (@{$mw_pages}) { + print $file "$page->{title}\n"; + } + close ($file); + } +} + +# Main part of this script: parse the command line arguments +# and select which function to execute +my $fct_to_call = shift;
contrib/mw-to-git/t/test-gitmw.pl line 230
Quoted 10 lines
contrib/mw-to-git/t/test-gitmw.pl new file +10
-0+ +&wiki_login($wiki_admin,$wiki_admin_pass); + +switch ($fct_to_call) { + case "get_page" { &wiki_getpage(@ARGV)} + case "delete_page" { &wiki_delete_page(@ARGV)} + case "edit_page" { &wiki_editpage(@ARGV)} + case "getallpagename" { &wiki_getallpagename(@ARGV)} + else { die("test-gitmw.pl ERROR: wrong argument")} +}
When you're calling bareword functions you can just call them as as wiki_login(..) not &wiki_login(..).
Also please don't use Switch.pm at all, it's a source filter, is deprecated from the Perl core, and it's much better to write this as:
my %functions_to_call = qw(
get_page wiki_getpage
delete_page wiki_delete_page
edit_page wiki_editpage getallpagename wiki_getallpagename
);
die "$0 ERROR: wrong argument" unless exists $functions_to_call{$fct_to_call}; &{$functions_to_call{$fct_to_call}}(@ARGV);
Re: [PATCH 2/6] Test environment of git-remote-mediawiki
Quoted 19 lines · Ævar Arnfjörð Bjarmason
On Tue, Jun 12, 2012 at 11:12 PM, Simon Cathebras
<[email protected]> wrote:Some comments on your perl style:
contrib/mw-to-git/t/test-gitmw.pl line 38
Quoted 12 lines
contrib/mw-to-git/t/test-gitmw.pl new file +12
-0+use Switch; +use encoding 'utf8'; +use DateTime::Format::ISO8601; +use open ':encoding(utf8)'; +use constant SLASH_REPLACEMENT => "%2F"; + +#Parsing of the config file + +my $configfile = "$ENV{'CURR_DIR'}/test.config"; +my %config; +open (CONFIG,"< $configfile") || die "can't open $configfile: $!"; +while (<CONFIG>)You probably want to use lexical filehandles instead:
Quoted 5 lines
open my $config, "<", $configfile or die "..."; while (<$config>)And also note the three-arg open I'm using, might want to change the rest to use that.
We corrected it. The correction will appears in our next patch.
Quoted 15 lines
contrib/mw-to-git/t/test-gitmw.pl line 49
Quoted 11 lines
contrib/mw-to-git/t/test-gitmw.pl new file +11
-0+{ + chomp; + s/#.*//; + s/^\s+//; + s/\s+$//; + next unless length; + my ($key, $value) = split (/\s*=\s*/,$_, 2); + $config{$key} = $value; + last if ($key eq 'LIGHTTPD' and $value eq 'false'); + last if ($key eq 'PORT'); +}And add:
close $config or die "can't close $configfile: $!";
Quoted 7 lines
Also you can do:
while (my $line =<$config>) { chomp $line;Which IMO makes any code that's more than 2-3 lines long less confusing as there's no doubt what $_ refers to.
Same.
Quoted 35 lines
Quoted 19 lines
contrib/mw-to-git/t/test-gitmw.pl new file +19
-0+my $wiki_address = "http://$config{'SERVER_ADDR'}".":"."$config{'PORT'}"; +my $wiki_url = "$wiki_address/$config{'WIKI_DIR_NAME'}/api.php"; +my $wiki_admin = "$config{'WIKI_ADMIN'}"; +my $wiki_admin_pass = "$config{'WIKI_PASSW'}"; +my $mw = MediaWiki::API->new; +$mw->{config}->{api_url} = $wiki_url; + +sub mediawiki_clean_filename { + my $filename = shift; + $filename =~ s/@{[SLASH_REPLACEMENT]}/\//g; + # [, ], |, {, and } are forbidden by MediaWiki, even URL-encoded. + # Do a variant of URL-encoding, i.e. looks like URL-encoding, + # but with _ added to prevent MediaWiki from thinking this is + # an actual special character. + $filename =~ s/[\[\]\{\}\|]/sprintf("_%%_%x", ord($&))/ge; + # If we use the uri escape before + # we should unescape here, before anything + + return $filename;contrib/mw-to-git/t/test-gitmw.pl line 79
Quoted 10 lines
contrib/mw-to-git/t/test-gitmw.pl new file +10
-0+} + +sub mediawiki_smudge_filename { + my $filename = shift; + $filename =~ s/\//@{[SLASH_REPLACEMENT]}/g; + $filename =~ s/ /_/g; + # Decode forbidden characters encoded in mediawiki_clean_filename + $filename =~ s/_%_([0-9a-fA-F][0-9a-fA-F])/sprintf("%c", hex($1))/ge; + return $filename; +}I don't how in the big picture you're aiming to encode article names as filenames but if you can at all avoid doing so (i.e. the user doesn't need to be exposed to those files) it's much simpler just to take the article name, sha1sum it and use the first 5-10 bytes of that as the filename.
Quoted 3 lines
With all the filesystems and OS's out there and their odd rules it can be tricky to write code that takes an arbitrary string and attempts to cast it to a valid filename or path.
Actually, we copy paste this code from git-remote-mediawiki. As a test environment, this strategy appears to be a bad one (in addition of the copy paste itself...). Anyway, we decided to remove this code and modify our tests.
As a matter this code's purpose in git-remote-mediawiki is to change the forbidden character in page name for wiki's, into understandable ones. So, in my opinion, using sha1sum would be useless.
Quoted 155 lines
Quoted 139 lines
contrib/mw-to-git/t/test-gitmw.pl new file +139
-0+# wiki_login<name> <password> +# +# Logs the user with<name> and<password> in the global variable +# of the mediawiki $mw +sub wiki_login { + $mw->login( { lgname => "$_[0]",lgpassword => "$_[1]" } ) + || die "getpage: login failed"; +} + +# wiki_getpage<wiki_page> <dest_path> +# +# fetch a page<wiki_page> from the wiki referenced in the global variable +# $mw and copies its content in directory dest_path +sub wiki_getpage { + my $pagename = $_[0]; + my $destdir = $_[1]; + + my $page = $mw->get_page( { title => $pagename } ); + if (!defined($page)) { + die "getpage: wiki does not exist"; + } + + my $content = $page->{'*'}; + if (!defined($content)) { + die "getpage: page does not exist"; + } + + # Replace spaces by underscore in the page name + $pagename=$page->{'title'}; + $pagename = mediawiki_smudge_filename $pagename; + open(my $file, ">$destdir/$pagename.mw"); + print $file "$content"; + close ($file); + +} + +# wiki_delete_page<page_name> +# +# delete the page with name<page_name> from the wiki referenced +# in the global variable $mw +sub wiki_delete_page { + my $pagename = $_[0]; + + my $exist=$mw->get_page({title => $pagename}); + + if (defined($exist->{'*'})){ + $mw->edit({ action => 'delete', + title => $pagename}) + || die $mw->{error}->{code} . ": " . $mw->{error}->{details}; + } else { + die "no page with such name found: $pagename\n"; + } +} + +# wiki_editpage<wiki_page> <wiki_content> <wiki_append> [-c=<category>] [-s=<summary>] +# +# Edit a page named<wiki_page> with content<wiki_content> on the wiki +# referenced with the global variable $mw +# If<wiki_append> == true : append<wiki_content> at the end of the actual +# content of the page<wiki_page> +# If<wik_page> doesn't exist, that page is created with the<wiki_content> +sub wiki_editpage { + my $wiki_page = mediawiki_clean_filename $_[0]; + my $wiki_content = $_[1]; + my $wiki_append = $_[2]; + my $summary = ""; + my ($summ, $cat) = (); + GetOptions('s=s' => \$summ, 'c=s' => \$cat); + + my $append = 0; + if (defined($wiki_append)&& $wiki_append eq 'true') { + $append=1; + } + + my $previous_text =""; + + if ($append) { + my $ref = $mw->get_page( { title => $wiki_page } ); + $previous_text = $ref->{'*'}; + } + + my $text = $wiki_content; + if (defined($previous_text)) { + $text="$previous_text$text"; + } + + # Eventually, add this page to a category. + if (defined($cat)) { + my $category_name="[[Category:$cat]]"; + $text="$text\n $category_name"; + } + if(defined($summ)){ + $summary=$summ; + } + + $mw->edit( { action => 'edit', title => $wiki_page, summary => $summary, text => "$text"} ); +} + +# wiki_getallpagename [<category>] +# +# Fetch all pages of the wiki referenced by the global variable $mw +# and print the names of each one in the file all.txt with a new line +# ("\n") between these. +# If the argument<category> is defined, then this function get only the pages +# belonging to<category>. +sub wiki_getallpagename { + # fetch the pages of the wiki + if (defined($_[0])) { + my $mw_pages = $mw->list ( { action => 'query', + list => 'categorymembers', + cmtitle => "Category:$_[0]", + cmnamespace => 0, + cmlimit=> 500 }, + ) + || die $mw->{error}->{code}.": ".$mw->{error}->{details}; + open(my $file, ">all.txt"); + foreach my $page (@{$mw_pages}) { + print $file "$page->{title}\n"; + } + close ($file); + + } else { + my $mw_pages = $mw->list({ + action => 'query', + list => 'allpages', + aplimit => 500, + }) + || die $mw->{error}->{code}.": ".$mw->{error}->{details}; + open(my $file, ">all.txt"); + foreach my $page (@{$mw_pages}) { + print $file "$page->{title}\n"; + } + close ($file); + } +} + +# Main part of this script: parse the command line arguments +# and select which function to execute +my $fct_to_call = shift;contrib/mw-to-git/t/test-gitmw.pl line 230
Quoted 10 lines
contrib/mw-to-git/t/test-gitmw.pl new file +10
-0+ +&wiki_login($wiki_admin,$wiki_admin_pass); + +switch ($fct_to_call) { + case "get_page" {&wiki_getpage(@ARGV)} + case "delete_page" {&wiki_delete_page(@ARGV)} + case "edit_page" {&wiki_editpage(@ARGV)} + case "getallpagename" {&wiki_getallpagename(@ARGV)} + else { die("test-gitmw.pl ERROR: wrong argument")} +}When you're calling bareword functions you can just call them as as
wiki_login(..)not&wiki_login(..).Also please don't use Switch.pm at all, it's a source filter, is deprecated from the Perl core, and it's much better to write this as:
Quoted 8 lines
my %functions_to_call = qw(
get_page wiki_getpage delete_page wiki_delete_page edit_page wiki_editpagegetallpagename
wiki_getallpagename
);
die "$0 ERROR: wrong argument" unless exists $functions_to_call{$fct_to_call}; &{$functions_to_call{$fct_to_call}}(@ARGV);
Corrected
Thanks ! :)
Signature · 6 lines
CATHEBRAS Simon 2A-ENSIMAG Filière Ingéniérie des Systèmes d'Information Membre Bug-Buster
PATCH v5 1/5 Scripts to install, delete and clear a MediaWiki
From: Guillaume Sasdy <[email protected]>
Install_wiki.sh expects the first argument to be 'install' or 'delete' 'install' installs a MediaWiki on the web's server with SQLite3 'delete' deletes the previously created wiki.
Note those functionnalities are made to be used from the user command line in the directory git/contrib/mw-to-git/t/
install_wiki also defines a function wiki_reset which clear all content of the previously created wiki. Note this functionnality is made to be used only by our test function in a subdirectory of t/
--- contrib/mw-to-git/t/install-wiki.sh | 45 ++++ contrib/mw-to-git/t/install-wiki/LocalSettings.php | 128 +++++++++ contrib/mw-to-git/t/install-wiki/db_install.php | 110 ++++++++ contrib/mw-to-git/t/test-gitmw-lib.sh | 288 +++++++++++++++++++++ contrib/mw-to-git/t/test.config | 35 +++ 5 files changed, 606 insertions(+) create mode 100755 contrib/mw-to-git/t/install-wiki.sh create mode 100644 contrib/mw-to-git/t/install-wiki/LocalSettings.php create mode 100644 contrib/mw-to-git/t/install-wiki/db_install.php create mode 100755 contrib/mw-to-git/t/test-gitmw-lib.sh create mode 100644 contrib/mw-to-git/t/test.config
contrib/mw-to-git/t/install-wiki.sh new file +45 -0
@@ -0,0 +1,45 @@ +#!/bin/sh + +# This script installs or deletes a MediaWiki on your computer. +# It requires a web server with PHP and SQLite running. In addition, if you +# do not have MediaWiki sources on your computer, the option 'install' +# downloads them for you. +# Please set the CONFIGURATION VARIABLES in ./test-gitmw-lib.sh + +WIKI_TEST_DIR=$(cd "$(dirname "$0")" && pwd) + +if test -z "$WIKI_TEST_DIR" +then + WIKI_TEST_DIR=. +fi + +. "$WIKI_TEST_DIR"/test-gitmw-lib.sh +usage () { + echo "Usage: " + echo " ./install-wiki.sh <install | delete | help>" + echo " install | -i : Install a wiki on your computer." + echo " delete | -d : Delete the wiki and all its pages and " + echo " content." +} + + +# Argument: install, delete, --help | -h +case "$1" in + "install" | "-i") + wiki_install + exit 0 + ;; + "delete" | "-d") + wiki_delete + exit 0 + ;; + "--help" | "-h") + usage + exit 0 + ;; + *) + echo "Invalid argument: $1" + usage + exit 1 + ;; +esac
contrib/mw-to-git/t/install-wiki/LocalSettings.php new file +128 -0
128 lines not on this page · raw message
contrib/mw-to-git/t/install-wiki/db_install.php new file +110 -0
110 lines not on this page · raw message
contrib/mw-to-git/t/test-gitmw-lib.sh new file +288 -0
288 lines not on this page · raw message
contrib/mw-to-git/t/test.config new file +35 -0
@@ -0,0 +1,35 @@ +# Name of the web server's directory dedicated to the wiki is WIKI_DIR_NAME +WIKI_DIR_NAME=wiki + +# Login and password of the wiki's admin +WIKI_ADMIN=WikiAdmin +WIKI_PASSW=AdminPass + +# Address of the web server +SERVER_ADDR=localhost + +# SQLite database of the wiki, named DB_FILE, is located in TMP +TMP=/tmp +DB_FILE=wikidb.sqlite + +# If LIGHTTPD is not set to true, the script will use the defaut +# web server running in WIKI_DIR_INST. +WIKI_DIR_INST=/var/www + +# If LIGHTTPD is set to true, the script will use Lighttpd to run +# the wiki. +LIGHTTPD=true + +# The variables below are useful only if LIGHTTPD is set to true. +PORT=1234 +PHP_DIR=/usr/bin +LIGHTTPD_DIR=/usr/sbin +WEB=WEB +WEB_TMP=$WEB/tmp +WEB_WWW=$WEB/www + +# The variables below are used by the script to install a wiki. +# You should not modify these unless you are modifying the script itself. +MW_VERSION=mediawiki-1.19.0 +FILES_FOLDER=install-wiki +DB_INSTALL_SCRIPT=db_install.php
Signature · 1 line
1.7.10.2.552.gaa3bb87
PATCH v5 2/5 Test environment of git-remote-mediawiki
From: Guillaume Sasdy <[email protected]>
In order to test git-remote-mediawiki, we need a package of functions to manage a MediaWiki: edit a page, remove a page, fetch a page, fetch all pages on a given wiki.
We also need functions to compare the content of directories.
This patch provide these functions in the filegit/contrib/mw-to-git/t/test-gitmw-lib.sh andgit/contrib/mw-to-git/t/test-gitmw.pl
In addition, this patch provide Makefiles to execute tests. See README file for more details.
--- contrib/mw-to-git/Makefile | 48 ++++++++ contrib/mw-to-git/t/Makefile | 27 +++++ contrib/mw-to-git/t/README | 33 ++++++ contrib/mw-to-git/t/test-gitmw-lib.sh | 141 ++++++++++++++++++++++- contrib/mw-to-git/t/test-gitmw.pl | 209 ++++++++++++++++++++++++++++++++++ 5 files changed, 456 insertions(+), 2 deletions(-) create mode 100644 contrib/mw-to-git/Makefile create mode 100644 contrib/mw-to-git/t/Makefile create mode 100644 contrib/mw-to-git/t/README create mode 100755 contrib/mw-to-git/t/test-gitmw.pl
contrib/mw-to-git/Makefile new file +48 -0
@@ -0,0 +1,48 @@ +# +# Copyright (C) 2012 +# Charles Roussel <[email protected]> +# Simon Cathebras <[email protected]> +# Julien Khayat <[email protected]> +# Guillaume Sasdy <[email protected]> +# Simon Perrat <[email protected]> +# +## Build git-remote-mediawiki + +-include ../../config.mak.autogen +-include ../../config.mak + +ifndef PERL_PATH + PERL_PATH = /usr/bin/perl +endif +ifndef gitexecdir + gitexecdir = $(shell git --exec-path) +endif + +PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH)) +gitexecdir_SQ = $(subst ','\'',$(gitexecdir)) +SCRIPT = git-remote-mediawiki + +.PHONY: install help doc test clean + +help: + @echo 'This is the help target of the Makefile. Current configuration:' + @echo ' gitexecdir = $(gitexecdir_SQ)' + @echo ' PERL_PATH = $(PERL_PATH_SQ)' + @echo 'Run "$(MAKE) install" to install $(SCRIPT) in gitexecdir' + @echo 'Run "$(MAKE) test" to run the testsuite' + +install: + sed -e '1s|#!.*/perl|#!$(PERL_PATH_SQ)|' $(SCRIPT) \ + > '$(gitexecdir_SQ)/$(SCRIPT)' + chmod +x '$(gitexecdir)/$(SCRIPT)' + +doc: + @echo 'Sorry, "make doc" is not implemented yet for $(SCRIPT)' + +test: + $(MAKE) -C t/ test + +clean: + $(RM) '$(gitexecdir)/$(SCRIPT)' + $(MAKE) -C t/ clean +
contrib/mw-to-git/t/Makefile new file +27 -0
@@ -0,0 +1,27 @@ +# +# Copyright (C) 2012 +# Charles Roussel <[email protected]> +# Simon Cathebras <[email protected]> +# Julien Khayat <[email protected]> +# Guillaume Sasdy <[email protected]> +# Simon Perrat <[email protected]> +# +## Test git-remote-mediawiki + +-include ../../../config.mak.autogen +-include ../../../config.mak + +T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh) + +.PHONY: help test clean + +help: + @echo 'Run "$(MAKE) test" to launch test scripts' + @echo 'Run "$(MAKE)" clean to remove trash folders' + +test: + for t in $(T); do "./$$t"; done + +clean: + $(RM) -r 'trash directory'.* +
contrib/mw-to-git/t/README new file +33 -0
@@ -0,0 +1,33 @@ +Tests for Mediawiki-to-Git +========================== + + +Installation +------------ +These tests require a mediawiki with admin access to work on; you can install one +on localhost/wiki simply by running: + ./install-wiki.sh install +Be aware that the tests will flush the wiki database, thus if you own a wiki at +this adress, it is strongly advised to configure another name in test-gitmw-lib.sh +before running the script. +Note that the wiki will be installed in /tmp (this can be configured too), meaning +you might have to install it again when you run tests later. + + +Running +------- +You can run these tests either individually or with make (recommended). Remember +to use make clean when you're done. You have access to all options from git core +tests. + + +Limitations +------- +This test environment does not allow you to test the behavior of git-remote-mediawiki +for name containing backslashes. + +t9360: tests git clone. + +t9361: tests git pull and git push. + +t9362: tests how UTF-8 special characters are handled.
contrib/mw-to-git/t/test-gitmw-lib.sh +139 -2
153 lines not on this page · raw message
contrib/mw-to-git/t/test-gitmw.pl new file +209 -0
209 lines not on this page · raw message
Signature · 1 line
1.7.10.2.552.gaa3bb87
PATCH v5 3/5 Test file for git-remote-mediawiki clone
In reply to Simon CathebrasFrom: Guillaume Sasdy <[email protected]>
This patch provides some tests for the clone in use by git-remote-mediawiki.
--- contrib/mw-to-git/t/t9360-mw-to-git-clone.sh | 250 +++++++++++++++++++++++++++ 1 file changed, 250 insertions(+) create mode 100755 contrib/mw-to-git/t/t9360-mw-to-git-clone.sh
contrib/mw-to-git/t/t9360-mw-to-git-clone.sh new file +250 -0
@@ -0,0 +1,250 @@ +#!/bin/sh +# +# Copyright (C) 2012 +# Charles Roussel <[email protected]> +# Simon Cathebras <[email protected]> +# Julien Khayat <[email protected]> +# Guillaume Sasdy <[email protected]> +# Simon Perrat <[email protected]> +# +# License: GPL v2 or later + + +test_description='Test the Git Mediawiki remote helper: git clone' + +. ./test-gitmw-lib.sh +. $TEST_DIRECTORY/test-lib.sh + + +test_check_precond + + +test_expect_success 'Git clone creates the git log expected with one file' ' + wiki_reset && + wiki_editpage foo "this is not important" false -c cat -s "this must be the same" && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_1 && + ( + cd mw_dir_1 && + git log --format=%s HEAD^..HEAD >log.tmp + ) && + echo "this must be the same" >msg.tmp && + diff -b mw_dir_1/log.tmp msg.tmp +' + + +test_expect_success 'Git clone creates the git log expected with multiple files' ' + wiki_reset && + wiki_editpage daddy "this is not important" false -s="this must be the same" && + wiki_editpage daddy "neither is this" true -s="this must also be the same" && + wiki_editpage daddy "neither is this" true -s="same same same" && + wiki_editpage dj "dont care" false -s="identical" && + wiki_editpage dj "dont care either" true -s="identical too" && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_2 && + ( + cd mw_dir_2 && + git log --format=%s Daddy.mw >logDaddy.tmp && + git log --format=%s Dj.mw >logDj.tmp + ) && + echo "same same same" >msgDaddy.tmp && + echo "this must also be the same" >>msgDaddy.tmp && + echo "this must be the same" >>msgDaddy.tmp && + echo "identical too" >msgDj.tmp && + echo "identical" >>msgDj.tmp && + diff -b mw_dir_2/logDaddy.tmp msgDaddy.tmp && + diff -b mw_dir_2/logDj.tmp msgDj.tmp +' + + +test_expect_success 'Git clone creates only Main_Page.mw with an empty wiki' ' + wiki_reset && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_3 && + test_contains_N_files mw_dir_3 1 && + test -e mw_dir_3/Main_Page.mw +' + +test_expect_success 'Git clone does not fetch a deleted page' ' + wiki_reset && + wiki_editpage foo "this page must be deleted before the clone" false && + wiki_delete_page foo && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_4 && + test_contains_N_files mw_dir_4 1 && + test -e mw_dir_4/Main_Page.mw && + test ! -e mw_dir_4/Foo.mw +' + +test_expect_success 'Git clone works with page added' ' + wiki_reset && + wiki_editpage foo " I will be cloned" false && + wiki_editpage bar "I will be cloned" false && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_5 && + wiki_getallpage ref_page_5 && + test_diff_directories mw_dir_5 ref_page_5 && + wiki_delete_page foo && + wiki_delete_page bar +' + +test_expect_success 'Git clone works with an edited page ' ' + wiki_reset && + wiki_editpage foo "this page will be edited" \ + false -s "first edition of page foo"&& + wiki_editpage foo "this page has been edited and must be on the clone " true && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_6 && + test -e mw_dir_6/Foo.mw && + test -e mw_dir_6/Main_Page.mw && + wiki_getallpage mw_dir_6/page_ref_6 && + test_diff_directories mw_dir_6 mw_dir_6/page_ref_6 && + ( + cd mw_dir_6 && + git log --format=%s HEAD^ Foo.mw > ../Foo.log + ) && + echo "first edition of page foo" > FooExpect.log && + diff FooExpect.log Foo.log +' + + +test_expect_success 'Git clone works with several pages and some deleted ' ' + wiki_reset && + wiki_editpage foo "this page will not be deleted" false && + wiki_editpage bar "I must not be erased" false && + wiki_editpage namnam "I will not be there at the end" false && + wiki_editpage nyancat "nyan nyan nyan delete me" false && + wiki_delete_page namnam && + wiki_delete_page nyancat && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_7 && + test -e mw_dir_7/Foo.mw && + test -e mw_dir_7/Bar.mw && + test ! -e mw_dir_7/Namnam.mw && + test ! -e mw_dir_7/Nyancat.mw && + wiki_getallpage mw_dir_7/page_ref_7 && + test_diff_directories mw_dir_7 mw_dir_7/page_ref_7 +' + + +test_expect_success 'Git clone works with one specific page cloned ' ' + wiki_reset && + wiki_editpage foo "I will not be cloned" false && + wiki_editpage bar "Do not clone me" false && + wiki_editpage namnam "I will be cloned :)" false -s="this log must stay" && + wiki_editpage nyancat "nyan nyan nyan you cant clone me" false && + git clone -c remote.origin.pages=namnam mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_8 && + test_contains_N_files mw_dir_8 1 && + test -e mw_dir_8/Namnam.mw && + test ! -e mw_dir_8/Main_Page.mw && + ( + cd mw_dir_8 && + echo "this log must stay" >msg.tmp && + git log --format=%s >log.tmp && + diff -b msg.tmp log.tmp + ) && + wiki_check_content mw_dir_8/Namnam.mw Namnam +' + +test_expect_success 'Git clone works with multiple specific page cloned ' ' + wiki_reset && + wiki_editpage foo "I will be there" false && + wiki_editpage bar "I will not disapear" false && + wiki_editpage namnam "I be erased" false && + wiki_editpage nyancat "nyan nyan nyan you will not erase me" false && + wiki_delete_page namnam && + git clone -c remote.origin.pages='"'foo bar nyancat namnam'"' mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_9 && + test_contains_N_files mw_dir_9 3 && + test ! -e mw_dir_9/Namnam.mw && + test -e mw_dir_9/Foo.mw && + test -e mw_dir_9/Nyancat.mw && + test -e mw_dir_9/Bar.mw && + wiki_check_content mw_dir_9/Foo.mw Foo && + wiki_check_content mw_dir_9/Bar.mw Bar && + wiki_check_content mw_dir_9/Nyancat.mw Nyancat +' + +test_expect_success 'Mediawiki-clone of several specific pages on wiki' ' + wiki_reset && + wiki_editpage foo "foo 1" false && + wiki_editpage bar "bar 1" false && + wiki_editpage dummy "dummy 1" false && + wiki_editpage cloned_1 "cloned_1 1" false && + wiki_editpage cloned_2 "cloned_2 2" false && + wiki_editpage cloned_3 "cloned_3 3" false && + mkdir -p ref_page_10 && + wiki_getpage cloned_1 ref_page_10 && + wiki_getpage cloned_2 ref_page_10 && + wiki_getpage cloned_3 ref_page_10 && + git clone -c remote.origin.pages="cloned_1 cloned_2 cloned_3" mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_10 && + test_diff_directories mw_dir_10 ref_page_10 +' + +test_expect_success 'Git clone works with the shallow option' ' + wiki_reset && + wiki_editpage foo "1st revision, should be cloned" false && + wiki_editpage bar "1st revision, should be cloned" false && + wiki_editpage nyan "1st revision, should not be cloned" false && + wiki_editpage nyan "2nd revision, should be cloned" false && + git -c remote.origin.shallow=true clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_11 && + test_contains_N_files mw_dir_11 4 && + test -e mw_dir_11/Nyan.mw && + test -e mw_dir_11/Foo.mw && + test -e mw_dir_11/Bar.mw && + test -e mw_dir_11/Main_Page.mw && + ( + cd mw_dir_11 && + test `git log --oneline Nyan.mw | wc -l` -eq 1 && + test `git log --oneline Foo.mw | wc -l` -eq 1 && + test `git log --oneline Bar.mw | wc -l` -eq 1 && + test `git log --oneline Main_Page.mw | wc -l ` -eq 1 + ) && + wiki_check_content mw_dir_11/Nyan.mw Nyan && + wiki_check_content mw_dir_11/Foo.mw Foo && + wiki_check_content mw_dir_11/Bar.mw Bar && + wiki_check_content mw_dir_11/Main_Page.mw Main_Page +' + +test_expect_success 'Git clone works with the shallow option with a delete page' ' + wiki_reset && + wiki_editpage foo "1st revision, will be deleted" false && + wiki_editpage bar "1st revision, should be cloned" false && + wiki_editpage nyan "1st revision, should not be cloned" false && + wiki_editpage nyan "2nd revision, should be cloned" false && + wiki_delete_page foo && + git -c remote.origin.shallow=true clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_12 && + test_contains_N_files mw_dir_12 3 && + test -e mw_dir_12/Nyan.mw && + test ! -e mw_dir_12/Foo.mw && + test -e mw_dir_12/Bar.mw && + test -e mw_dir_12/Main_Page.mw && + ( + cd mw_dir_12 && + test `git log --oneline Nyan.mw | wc -l` -eq 1 && + test `git log --oneline Bar.mw | wc -l` -eq 1 && + test `git log --oneline Main_Page.mw | wc -l ` -eq 1 + ) && + wiki_check_content mw_dir_12/Nyan.mw Nyan && + wiki_check_content mw_dir_12/Bar.mw Bar && + wiki_check_content mw_dir_12/Main_Page.mw Main_Page +' + +test_expect_success 'Test of fetching a category' ' + wiki_reset && + wiki_editpage Foo "I will be cloned" false -c=Category && + wiki_editpage Bar "Meet me on the repository" false -c=Category && + wiki_editpage Dummy "I will not come" false && + wiki_editpage BarWrong "I will stay online only" false -c=NotCategory && + git clone -c remote.origin.categories="Category" mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_13 && + wiki_getallpage ref_page_13 Category && + test_diff_directories mw_dir_13 ref_page_13 +' + +test_expect_success 'Test of resistance to modification of category on wiki for clone' ' + wiki_reset && + wiki_editpage Tobedeleted "this page will be deleted" false -c=Catone && + wiki_editpage Tobeedited "this page will be modified" false -c=Catone && + wiki_editpage Normalone "this page wont be modified and will be on git" false -c=Catone && + wiki_editpage Notconsidered "this page will not appear on local" false && + wiki_editpage Othercategory "this page will not appear on local" false -c=Cattwo && + wiki_editpage Tobeedited "this page have been modified" true -c=Catone && + wiki_delete_page Tobedeleted + git clone -c remote.origin.categories="Catone" mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_14 && + wiki_getallpage ref_page_14 Catone && + test_diff_directories mw_dir_14 ref_page_14 +' + +test_done
Signature · 1 line
1.7.10.2.552.gaa3bb87
PATCH v5 4/5 Tests for git-remote-mediawiki pull and push
In reply to Simon CathebrasFrom: Guillaume Sasdy <[email protected]>
This patch provides a set of tests for the pull and push fonctionnality of git-remote-mediawiki.
--- contrib/mw-to-git/t/t9361-mw-to-git-push-pull.sh | 167 +++++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100755 contrib/mw-to-git/t/t9361-mw-to-git-push-pull.sh
contrib/mw-to-git/t/t9361-mw-to-git-push-pull.sh new file +167 -0
@@ -0,0 +1,167 @@ +#!/bin/sh +# +# Copyright (C) 2012 +# Charles Roussel <[email protected]> +# Simon Cathebras <[email protected]> +# Julien Khayat <[email protected]> +# Guillaume Sasdy <[email protected]> +# Simon Perrat <[email protected]> +# +# License: GPL v2 or later + +# tests for git-remote-mediawiki + +test_description='Test the Git Mediawiki remote helper: git push and git pull simple test cases' + +. ./test-gitmw-lib.sh +. $TEST_DIRECTORY/test-lib.sh + + +test_check_precond + + +test_expect_success 'Git pull works after adding a new wiki page' ' + wiki_reset && + + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_1 && + wiki_editpage Foo "page created after the git clone" false && + + ( + cd mw_dir_1 && + git pull + ) && + + wiki_getallpage ref_page_1 && + test_diff_directories mw_dir_1 ref_page_1 +' + +test_expect_success 'Git pull works after editing a wiki page' ' + wiki_reset && + + wiki_editpage Foo "page created before the git clone" false && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_2 && + wiki_editpage Foo "new line added on the wiki" true && + + ( + cd mw_dir_2 && + git pull + ) && + + wiki_getallpage ref_page_2 && + test_diff_directories mw_dir_2 ref_page_2 +' + +test_expect_success 'git pull works on conflict handled by auto-merge' ' + wiki_reset && + + wiki_editpage Foo "1 init +3 +5 +" false && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_3 && + + wiki_editpage Foo "1 init +2 content added on wiki after clone +3 +5 +" false && + + ( + cd mw_dir_3 && + echo "1 init +3 +4 content added on git after clone +5 +" >Foo.mw && + git commit -am "conflicting change on foo" && + git pull && + git push + ) +' + +test_expect_success 'Git push works after adding a file .mw' ' + wiki_reset && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_4 && + wiki_getallpage ref_page_4 && + ( + cd mw_dir_4 && + test ! -f Foo.mw && + touch Foo.mw && + echo "hello world" >>Foo.mw && + git add Foo.mw && + git commit -m "Foo" && + git push + ) && + wiki_getallpage ref_page_4 && + test_diff_directories mw_dir_4 ref_page_4 +' + +test_expect_success 'Git push works after editing a file .mw' ' + wiki_reset && + wiki_editpage "Foo" "page created before the git clone" false && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_5 && + + ( + cd mw_dir_5 && + echo "new line added in the file Foo.mw" >>Foo.mw && + git commit -am "edit file Foo.mw" && + git push + ) && + + wiki_getallpage ref_page_5 && + test_diff_directories mw_dir_5 ref_page_5 +' + +test_expect_failure 'Git push works after deleting a file' ' + wiki_reset && + wiki_editpage Foo "wiki page added before git clone" false && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_6 && + + ( + cd mw_dir_6 && + git rm Foo.mw && + git commit -am "page Foo.mw deleted" && + git push + ) && + + test ! wiki_page_exist Foo +' + + + +test_expect_success 'Merge conflict expected and solving it' ' + wiki_reset && + + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_7 && + wiki_editpage Foo "1 conflict +3 wiki +4" false && + + ( + cd mw_dir_7 && + echo "1 conflict +2 git +4" >Foo.mw && + git add Foo.mw && + git commit -m "conflict created" && + test_must_fail git pull && + perl -pi -e "s/[<=>].*//g" Foo.mw && + git commit -am "merge conflict solved" && + git push + ) +' + +test_expect_failure 'git pull works after deleting a wiki page' ' + wiki_reset && + wiki_editpage Foo "wiki page added before the git clone" false && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_8 && + + wiki_delete_page Foo && + ( + cd mw_dir_8 && + git pull && + test ! -f Foo.mw + ) +' + +test_done
Signature · 1 line
1.7.10.2.552.gaa3bb87
PATCH v5 5/5 Tests of UTF8 character with git-remote-mediawiki
In reply to Simon CathebrasThis patch provides a sample of tests for git-remote-mediawiki's resistance, concerning utf8 special characters.
--- contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh | 298 ++++++++++++++++++++++++++++ 1 file changed, 298 insertions(+) create mode 100755 contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh
contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh new file +298 -0
@@ -0,0 +1,298 @@ +#!/bin/sh +# +# Copyright (C) 2012 +# Charles Roussel <[email protected]> +# Simon Cathebras <[email protected]> +# Julien Khayat <[email protected]> +# Guillaume Sasdy <[email protected]> +# Simon Perrat <[email protected]> +# +# 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 + + +test_check_precond + + +test_expect_success 'Git clone works for a wiki with accents in the page names' ' + wiki_reset && + 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://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_1 && + wiki_getallpage ref_page_1 && + test_diff_directories mw_dir_1 ref_page_1 +' + + +test_expect_success 'Git pull works with a wiki with accents in the pages names' ' + wiki_reset && + wiki_editpage kîî "this page must be cloned" false && + wiki_editpage foo "this page must be cloned" false && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_2 && + wiki_editpage éàîôû "This page must be pulled" false && + ( + cd mw_dir_2 && + git pull + ) && + wiki_getallpage ref_page_2 && + test_diff_directories mw_dir_2 ref_page_2 +' + +# 3 +test_expect_success 'Cloning a chosen page works with accents' ' + wiki_reset && + wiki_editpage kîî "this page must be cloned" false && + git clone -c remote.origin.pages=kîî mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_3 && + wiki_check_content mw_dir_3/Kîî.mw Kîî && + test -e mw_dir_3/Kîî.mw && + rm -rf mw_dir_3 +' + + +test_expect_success 'The shallow option works with accents' ' + wiki_reset && + 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://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_4 && + test_contains_N_files mw_dir_4 2 && + test -e mw_dir_4/Néoà.mw && + test -e mw_dir_4/Main_Page.mw && + ( + cd mw_dir_4 && + test `git log --oneline Néoà.mw | wc -l` -eq 1 && + test `git log --oneline Main_Page.mw | wc -l ` -eq 1 + ) && + wiki_check_content mw_dir_4/Néoà.mw Néoà && + wiki_check_content mw_dir_4/Main_Page.mw Main_Page +' + + +test_expect_success 'Cloning works when page name first letter has an accent' ' + wiki_reset && + wiki_editpage îî "this page must be cloned" false && + git clone -c remote.origin.pages=îî mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_5 && + test -e mw_dir_5/Îî.mw && + wiki_check_content mw_dir_5/Îî.mw Îî +' + + +test_expect_success 'Git push works with a wiki with accents' ' + wiki_reset && + wiki_editpage féé "lots of accents : éèàÖ" false && + wiki_editpage foo "this page must be cloned" false && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_6 && + ( + cd mw_dir_6 && + 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 + ) && + wiki_getallpage ref_page_6 && + test_diff_directories mw_dir_6 ref_page_6 +' + +test_expect_success 'Git clone works with accentsand spaces' ' + wiki_reset && + wiki_editpage "é à î" "this page must be délété before the clone" false && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_7 && + wiki_getallpage ref_page_7 && + test_diff_directories mw_dir_7 ref_page_7 +' + +test_expect_success 'character $ in page name (mw -> git)' ' + wiki_reset && + wiki_editpage file_\$_foo "expect to be called file_$_foo" false && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_8 && + test -f mw_dir_8/File_\$_foo.mw && + wiki_getallpage ref_page_8 && + test_diff_directories mw_dir_8 ref_page_8 +' + + + +test_expect_success 'character $ in file name (git -> mw) ' ' + wiki_reset && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_9 && + ( + cd mw_dir_9 && + echo "this file is called File_\$_foo.mw" >File_\$_foo.mw && + git add . && + git commit -am "file File_\$_foo.mw" && + git pull && + git push + ) && + wiki_getallpage ref_page_9 && + test_diff_directories mw_dir_9 ref_page_9 +' + + +test_expect_failure 'capital at the begining of file names' ' + wiki_reset && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_10 && + ( + cd mw_dir_10 && + 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 + ) && + wiki_getallpage ref_page_10 && + test_diff_directories mw_dir_10 ref_page_10 +' + + +test_expect_failure 'special character at the begining of file name from mw to git' ' + wiki_reset && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_11 && + 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_11 && + git pull + ) && + test -f mw_dir_11/{char_1 && + test -f mw_dir_11/[char_2 +' + +test_expect_success 'test of correct formating for file name from mw to git' ' + wiki_reset && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_12 && + wiki_editpage char_%_7b_1 "expect to be renamed char{_1" false && + wiki_editpage char_%_5b_2 "expect to be renamed char{_2" false && + ( + cd mw_dir_12 && + git pull + ) && + test -f mw_dir_12/Char\{_1.mw && + test -f mw_dir_12/Char\[_2.mw && + wiki_getallpage ref_page_12 && + mv ref_page_12/Char_%_7b_1.mw ref_page_12/Char\{_1.mw && + mv ref_page_12/Char_%_5b_2.mw ref_page_12/Char\[_2.mw && + test_diff_directories mw_dir_12 ref_page_12 +' + + +test_expect_failure 'test of correct formating for file name begining with special character' ' + wiki_reset && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_13 && + ( + cd mw_dir_13 && + 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 + ) && + wiki_getallpage ref_page_13 && + test -f ref_page_13/{char_1.mw && + test -f ref_page_13/[char_2.mw && + test_diff_directories mw_dir_13 ref_page_13 +' + + +test_expect_success 'test of correct formating for file name from git to mw' ' + wiki_reset && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_14 && + ( + cd mw_dir_14 && + 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 + ) && + wiki_getallpage ref_page_14 && + mv mw_dir_14/Char\{_1.mw mw_dir_14/Char_%_7b_1.mw && + mv mw_dir_14/Char\[_2.mw mw_dir_14/Char_%_5b_2.mw && + test_diff_directories mw_dir_14 ref_page_14 +' + + +test_expect_success 'git clone with /' ' + wiki_reset && + wiki_editpage \/fo\/o "this is not important" false -c=Deleted && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_15 && + test -f mw_dir_15/%2Ffo%2Fo.mw && + wiki_check_content mw_dir_15/%2Ffo%2Fo.mw \/fo\/o +' + + +test_expect_success 'git push with /' ' + wiki_reset && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_16 && + echo "I will be on the wiki" >mw_dir_16/%2Ffo%2Fo.mw && + ( + cd mw_dir_16 && + git add %2Ffo%2Fo.mw && + git commit -m " %2Ffo%2Fo added" && + git push + ) && + wiki_page_exist \/fo\/o && + wiki_check_content mw_dir_16/%2Ffo%2Fo.mw \/fo\/o + +' + + +test_expect_success 'git clone with \' ' + wiki_reset && + wiki_editpage \\ko\\o "this is not important" false -c=Deleted && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_17 && + test -f mw_dir_17/\\ko\\o.mw && + wiki_check_content mw_dir_17/\\ko\\o.mw \\ko\\o +' + + +test_expect_success 'git push with \' ' + wiki_reset && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_18 && + echo "I will be on the wiki" >mw_dir_18/\\ko\\o.mw && + ( + cd mw_dir_18 && + git add \\ko\\o.mw && + git commit -m " \\ko\\o added" && + git push + )&& + wiki_page_exist \\ko\\o && + wiki_check_content mw_dir_18/\\ko\\o.mw \\ko\\o + +' + +test_expect_success 'git clone with \ in format control' ' + wiki_reset && + wiki_editpage \\no\\o "this is not important" false && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_19 && + test -f mw_dir_19/\\no\\o.mw && + wiki_check_content mw_dir_19/\\no\\o.mw \\no\\o +' + + +test_expect_success 'git push with \ in format control' ' + wiki_reset && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_20 && + echo "I will be on the wiki" >mw_dir_20/\\fo\\o.mw && + ( + cd mw_dir_20 && + git add \\fo\\o.mw && + git commit -m " \\fo\\o added" && + git push + )&& + wiki_page_exist \\fo\\o && + wiki_check_content mw_dir_20/\\fo\\o.mw \\fo\\o + +' + + +test_done
Signature · 1 line
1.7.10.2.552.gaa3bb87
Re: [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki
In reply to Simon CathebrasThe script didn't work for me. I first applied the patches below (essentially style, but also a clearer error message). I get:
$ ./install-wiki.sh install Instance already running. Restarting... kill: 45: No such process
2012-06-14 10:53:21: (log.c.166) server started
mediawiki-1.19.0.tar.gz downloaded in /tmp. You can delete it later if you want. Generating the SQLite database file. It can take some time ... Could not get page: http://localhost:1234/wiki/mw-config/index.php
Can't create database file in TODO. Try to run ./install-wiki.sh delete first.
Indeed:
$ ps -u moy | grep light $ telnet localhost 1234 Trying 127.0.0.1... telnet: Unable to connect to remote host: Connection refused
Matthieu Moy (3):
chmod -x test-gitmw-lib.sh
Coding style
Explicit error when curl_exec() fails
contrib/mw-to-git/t/install-wiki/db_install.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) mode change 100755 => 100644 contrib/mw-to-git/t/test-gitmw-lib.sh
Signature · 1 line
1.7.11.rc0.57.g84a04c7
PATCH 1/3 chmod -x test-gitmw-lib.sh
---
0 files changed mode change 100755 => 100644 contrib/mw-to-git/t/test-gitmw-lib.sh
contrib/mw-to-git/t/test-gitmw-lib.sh +0 -0
Signature · 1 line
1.7.11.rc0.57.g84a04c7
PATCH 2/3 Coding style
In reply to Matthieu Moy--- contrib/mw-to-git/t/install-wiki/db_install.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
contrib/mw-to-git/t/install-wiki/db_install.php +3 -5
@@ -10,7 +10,6 @@ * In order to generate a SQLite database file, MediaWiki ask the user * to submit some forms in its web browser. This script simulates this * behavior though the functions <get> and <submit> - * */ $argc = $_SERVER['argc']; $argv = $_SERVER['argv'];
@@ -22,7 +21,7 @@ $port = $argv[5]; $url = 'http://localhost:'.$port.'/wiki/mw-config/index.php'; $db_dir = urlencode($tmp); -$tmp_cookie = tempnam($tmp,"COOKIE_"); +$tmp_cookie = tempnam($tmp, "COOKIE_"); /* * Fetchs a page with cURL. */
@@ -33,13 +32,13 @@ function get ($page_name = "") { $page_name_add = '?page='.$page_name; } $url = $GLOBALS['url'].$page_name_add; - $tmp_cookie=$GLOBALS['tmp_cookie']; + $tmp_cookie = $GLOBALS['tmp_cookie']; curl_setopt($curl, CURLOPT_COOKIEJAR, $tmp_cookie); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_COOKIEFILE, $tmp_cookie); curl_setopt($curl, CURLOPT_HEADER, true); - curl_setopt($curl, CURLOPT_URL,$url); + curl_setopt($curl, CURLOPT_URL, $url); $page = curl_exec($curl); curl_close($curl);
@@ -75,7 +74,6 @@ function submit($page_name, $option = "") { * submitting forms to generates the database file. * Note this simulation was made for the MediaWiki version 1.19.0, * we can't assume it works with other versions. - * */ $page = get();
Signature · 1 line
1.7.11.rc0.57.g84a04c7
PATCH 3/3 Explicit error when curl_exec() fails
In reply to Matthieu Moy--- contrib/mw-to-git/t/install-wiki/db_install.php | 3 +++ 1 file changed, 3 insertions(+)
contrib/mw-to-git/t/install-wiki/db_install.php +3 -0
@@ -41,6 +41,9 @@ function get ($page_name = "") { curl_setopt($curl, CURLOPT_URL, $url); $page = curl_exec($curl); + if (!$page) { + die ("Could not get page: $url\n"); + } curl_close($curl); return $page; }
Signature · 1 line
1.7.11.rc0.57.g84a04c7
Re: [PATCH 3/3] Explicit error when curl_exec() fails
Quoted 10 lines · Matthieu Moy
Signed-off-by Matthieu Moy<[email protected]>--- contrib/mw-to-git/t/install-wiki/db_install.php | 3 +++ 1 file changed, 3 insertions(+)contrib/mw-to-git/t/install-wiki/db_install.php +0
-0
contrib/mw-to-git/t/install-wiki/db_install.php function get ($page_name = "") { · line 49
Quoted 9 lines
contrib/mw-to-git/t/install-wiki/db_install.php +3
-0@@ -41,6 +41,9 @@ function get ($page_name = "") { curl_setopt($curl, CURLOPT_URL, $url); $page = curl_exec($curl); + if (!$page) { + die ("Could not get page: $url\n"); + } curl_close($curl); return $page; }
Seems legitimate.
But there is a whitespace/indentation problem isn't it ?
Signature · 6 lines
CATHEBRAS Simon 2A-ENSIMAG Filière Ingéniérie des Systèmes d'Information Membre Bug-Buster
Re: [PATCH 3/3] Explicit error when curl_exec() fails
Quoted 1 line · Simon.Cathebras
But there is a whitespace/indentation problem isn't it ?
Yes: your code is indented with spaces.
(my code has an extra space between die and "(" that said)
Signature · 2 lines
Matthieu Moy http://www-verimag.imag.fr/~moy/
Re: [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki
In reply to Matthieu MoyQuoted 13 lines · Matthieu Moy
The script didn't work for me. I first applied the patches below (essentially style, but also a clearer error message). I get:
$ ./install-wiki.sh install Instance already running. Restarting... kill: 45: No such process2012-06-14 10:53:21: (log.c.166) server startedmediawiki-1.19.0.tar.gz downloaded in /tmp. You can delete it later if you want. Generating the SQLite database file. It can take some time ... Could not get page: http://localhost:1234/wiki/mw-config/index.php
Can't create database file in TODO. Try to run ./install-wiki.sh delete first.
Quoted 6 lines
Indeed:
$ ps -u moy | grep light $ telnet localhost 1234 Trying 127.0.0.1... telnet: Unable to connect to remote host: Connection refused
Appears to be a local problem. Did you managed to run the script when this was fixed ?
Anyway, please check out with the following wiki page if you have all required package.
url: https://github.com/Fafinou/git/wiki
Quoted 9 lines
Matthieu Moy (3):
chmod -xtest-gitmw-lib.sh
Coding style
Explicit error whencurl_exec()failscontrib/mw-to-git/t/install-wiki/db_install.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)mode change 100755 => 100644
contrib/mw-to-git/t/test-gitmw-lib.sh
Signature · 6 lines
CATHEBRAS Simon 2A-ENSIMAG Filière Ingéniérie des Systèmes d'Information Membre Bug-Buster
Re: [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki
Quoted 5 lines · Simon.Cathebras
Appears to be a local problem. Did you managed to run the script when this was fixed ?
Anyway, please check out with the following wiki page if you have all required package.
Indeed, installing php5-cgi did it. I can now run the testsuite. But that would have been nice to get explicit error messages about this.
Quoted 1 line
This documentation should actually appear in the README file of your test environment. Wikis are nice to work collaboratively on a draft, but this kind of doc should really end up as close to the code as possible (currently, the code doesn't give a way to find the page above ...).
While testing/reviewing, I fixed a few more issues (patch below).
One thing I wanted to do was to let "install-wiki.sh" be launched from any directory, like "./t/install-wiki.sh install", but it's still not there, there are relative paths here and there that break it. Maybe we should just run cd "$WIKI_TEST_DIR" at the top. Or error out asking the user to cd himself.
From 084babd650376437d0fb4697d680d3c325316b7c Mon Sep 17 00:00:00 2001
From: Matthieu Moy <[email protected]>
Date: Thu, 14 Jun 2012 18:13:20 +0200
Subject: [PATCH] More fixups
--- contrib/mw-to-git/t/Makefile | 7 +++++-- contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh | 8 ++++---- contrib/mw-to-git/t/test-gitmw-lib.sh | 20 +++++++++++--------- 3 files changed, 20 insertions(+), 15 deletions(-)
contrib/mw-to-git/t/Makefile +5 -2
@@ -17,10 +17,13 @@ T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh) help: @echo 'Run "$(MAKE) test" to launch test scripts' - @echo 'Run "$(MAKE)" clean to remove trash folders' + @echo 'Run "$(MAKE) clean" to remove trash folders' test: - for t in $(T); do "./$$t"; done + @for t in $(T); do \ + echo "$$t"; \ + "./$$t" || { echo "$$t failed"; exit 1; } \ + done clean: $(RM) -r 'trash directory'.*
contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh +4 -4
@@ -101,7 +101,7 @@ test_expect_success 'Git push works with a wiki with accents' ' test_diff_directories mw_dir_6 ref_page_6 ' -test_expect_success 'Git clone works with accentsand spaces' ' +test_expect_success 'Git clone works with accents and spaces' ' wiki_reset && wiki_editpage "é à î" "this page must be délété before the clone" false && git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_7 &&
@@ -166,7 +166,7 @@ test_expect_failure 'special character at the begining of file name from mw to g test -f mw_dir_11/[char_2 ' -test_expect_success 'test of correct formating for file name from mw to git' ' +test_expect_success 'correct formating for file name from mw to git' ' wiki_reset && git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_12 && wiki_editpage char_%_7b_1 "expect to be renamed char{_1" false &&
@@ -184,7 +184,7 @@ test_expect_success 'test of correct formating for file name from mw to git' ' ' -test_expect_failure 'test of correct formating for file name begining with special character' ' +test_expect_failure 'correct formating for file name begining with special character' ' wiki_reset && git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_13 && (
@@ -203,7 +203,7 @@ test_expect_failure 'test of correct formating for file name begining with speci ' -test_expect_success 'test of correct formating for file name from git to mw' ' +test_expect_success 'correct formating for file name from git to mw' ' wiki_reset && git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_14 && (
contrib/mw-to-git/t/test-gitmw-lib.sh +11 -9
@@ -10,8 +10,12 @@ # CONFIGURATION VARIABLES # You might want to change these ones # +if test -z "$WIKI_TEST_DIR" +then + WIKI_TEST_DIR=. +fi -. ./test.config +. "$WIKI_TEST_DIR"/test.config export CURR_DIR=$(pwd) export TEST_DIRECTORY="$CURR_DIR"/../../../t
@@ -87,7 +91,7 @@ test_diff_directories () { # # Check that <dir> contains exactly <N> files test_contains_N_files () { - test `ls "$1" | wc -l` -eq "$2"; + test `ls -- "$1" | wc -l` -eq "$2" }
@@ -101,8 +105,7 @@ wiki_check_content () { #replacement of forbidden character in file name page_name=$(printf "%s\n" "$2" | sed -e "s/\//%2F/g") - diff -b "$1" wiki_tmp/"$page_name".mw - if test $? -ne 0 + if ! diff -b "$1" wiki_tmp/"$page_name".mw then rm -rf wiki_tmp error "ERROR: file $2 not found on wiki"
@@ -268,9 +271,9 @@ start_lighttpd() { stop_lighttpd fi config_lighttpd - $LIGHTTPD_DIR/lighttpd -f $WEB/lighttpd.conf - - if test $? -ne 0 ; then + + if ! $LIGHTTPD_DIR/lighttpd -f $WEB/lighttpd.conf + then echo "Could not execute http deamon lighttpd" exit 1 fi
@@ -280,9 +283,8 @@ start_lighttpd() { # # Kill daemon lighttpd and removes files and folders associated. stop_lighttpd () { - test -f "$WEB_TMP/pid" && kill $(cat "$WEB_TMP/pid") - rm -rf $WEB + rm -rf "$WEB" } # Create the SQLite database of the MediaWiki. If the database file already
Signature · 5 lines
1.7.11.rc0.57.g84a04c7 -- Matthieu Moy http://www-verimag.imag.fr/~moy/
Re: [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki
In reply to Simon CathebrasQuoted 9 lines · Simon Cathebras
contrib/mw-to-git/t/install-wiki/db_install.php new file +9
-0+function get ($page_name = "") { + $curl = curl_init(); + $page_name_add = ""; + if ($page_name != "") { + $page_name_add = '?page='.$page_name; + } + $url = $GLOBALS['url'].$page_name_add; + $tmp_cookie=$GLOBALS['tmp_cookie']; + curl_setopt($curl, CURLOPT_COOKIEJAR, $tmp_cookie);
contrib/mw-to-git/t/install-wiki/db_install.php line 47
Quoted 10 lines
contrib/mw-to-git/t/install-wiki/db_install.php new file +10
-0+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); + curl_setopt($curl, CURLOPT_COOKIEFILE, $tmp_cookie); + curl_setopt($curl, CURLOPT_HEADER, true); + curl_setopt($curl, CURLOPT_URL,$url); + + $page = curl_exec($curl); + curl_close($curl); + return $page; +}
Mixed tab/space indentation.
Signature · 2 lines
Matthieu Moy http://www-verimag.imag.fr/~moy/
Re: [PATCH 2/6] Test environment of git-remote-mediawiki
In reply to Simon Cathebrascontrib/mw-to-git/t/test-gitmw-lib.sh else · line 51
Quoted 2 lines · Simon Cathebras
contrib/mw-to-git/t/test-gitmw-lib.sh +2
-0+# Check the preconditions to run git-remote-mediawiki's tests +test_check_precond () {
This is a very generic name (with risk of name clash in future versions of test-lib.sh). This checks the git-mediawiki preconditions, so how about test_check_wiki_precond?
contrib/mw-to-git/t/test-gitmw-lib.sh else · line 58
Quoted 7 lines
contrib/mw-to-git/t/test-gitmw-lib.sh +7
-0+ 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 ];
"" around $GIT_BUILD_DIR
But why $GIT_BUILD_DIR ? git-remote-mediawiki usually doesn't go there, it is either as source in contrib/, or installed in the $PATH.
contrib/mw-to-git/t/test-gitmw-lib.sh else · line 61
Quoted 3 lines
contrib/mw-to-git/t/test-gitmw-lib.sh +3
-0+ then + skip_all='skipping gateway git-mw tests, no remote mediawiki for git found' \ + 'please try: cp git/contrib/mw-to-git/git-remote-mediawiki git/'
Don't you have a "make install" target for that now?
+ $CURR_DIR/test-gitmw.pl getallpagename
Here and elsewhere, "" around "$CURR_DIR"
Signature · 2 lines
Matthieu Moy http://www-verimag.imag.fr/~moy/
Re: [PATCH 2/6] Test environment of git-remote-mediawiki
Quoted 7 lines · Matthieu Moy
contrib/mw-to-git/t/test-gitmw-lib.sh else · line 51
Quoted 2 lines · Simon Cathebras
contrib/mw-to-git/t/test-gitmw-lib.sh +2
-0+# Check the preconditions to run git-remote-mediawiki's tests +test_check_precond () {This is a very generic name (with risk of name clash in future versions of
test-lib.sh). This checks the git-mediawiki preconditions, so how abouttest_check_wiki_precond?
I agree with that.
Quoted 11 lines
contrib/mw-to-git/t/test-gitmw-lib.sh else · line 58
Quoted 7 lines
contrib/mw-to-git/t/test-gitmw-lib.sh +7
-0+ 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 ];"" around $GIT_BUILD_DIR
But why $GIT_BUILD_DIR ? git-remote-mediawiki usually doesn't go there, it is either as source in contrib/, or installed in the $PATH.
Indeed, I developped this code and I have missunderstood the behavior of contrib. It will be fix in the next patch by tonight.
Quoted 4 lines
contrib/mw-to-git/t/test-gitmw-lib.sh else · line 61
Quoted 3 lines
contrib/mw-to-git/t/test-gitmw-lib.sh +3
-0+ then + skip_all='skipping gateway git-mw tests, no remote mediawiki for git found' \ + 'please try: cp git/contrib/mw-to-git/git-remote-mediawiki git/'Don't you have a "make install" target for that now?
Yes we have. We shall correct it by tonight.
Quoted 5 lines
contrib/mw-to-git/t/test-gitmw-lib.sh +1
-0+ $CURR_DIR/test-gitmw.pl getallpagenameHere and elsewhere, "" around "$CURR_DIR"
Got it, thanks =).
Simon C
Signature · 6 lines
CATHEBRAS Simon 2A-ENSIMAG Filière Ingéniérie des Systèmes d'Information Membre Bug-Buster
PATCH 3/6 Test file for git-remote-mediawiki clone
In reply to Simon CathebrasFrom: Guillaume Sasdy <[email protected]>
This patch provides some tests for the clone in use by git-remote-mediawiki.
--- contrib/mw-to-git/t/t9360-mw-to-git-clone.sh | 238 +++++++++++++++++++++++++++ 1 file changed, 238 insertions(+) create mode 100755 contrib/mw-to-git/t/t9360-mw-to-git-clone.sh
contrib/mw-to-git/t/t9360-mw-to-git-clone.sh new file +238 -0
@@ -0,0 +1,238 @@ +#!/bin/sh +# +# Copyright (C) 2012 +# Charles Roussel <[email protected]> +# Simon Cathebras <[email protected]> +# Julien Khayat <[email protected]> +# Guillaume Sasdy <[email protected]> +# Simon Perrat <[email protected]> +# +# License: GPL v2 or later + + +test_description='Test the Git Mediawiki remote helper: git clone' + +. ./test-gitmw-lib.sh +. $TEST_DIRECTORY/test-lib.sh + + +test_check_precond + + +test_expect_success 'Git clone creates the git log expected with one file' ' + wiki_reset && + wiki_editpage foo "this is not important" false -c cat -s "this must be the same" && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_1 && + (cd mw_dir_1 && + git log --format=%s HEAD^..HEAD > log.tmp ) && + echo "this must be the same" > msg.tmp && + diff -b mw_dir_1/log.tmp msg.tmp +' + + +test_expect_success 'Git clone creates the git log expected with multiple files' ' + wiki_reset && + wiki_editpage daddy "this is not important" false -s="this must be the same" && + wiki_editpage daddy "neither is this" true -s="this must also be the same" && + wiki_editpage daddy "neither is this" true -s="same same same" && + wiki_editpage dj "dont care" false -s="identical" && + wiki_editpage dj "dont care either" true -s="identical too" && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_2 && + (cd mw_dir_2 && + git log --format=%s Daddy.mw > logDaddy.tmp && + git log --format=%s Dj.mw > logDj.tmp ) && + echo "same same same" > msgDaddy.tmp && + echo "this must also be the same" >> msgDaddy.tmp && + echo "this must be the same" >> msgDaddy.tmp && + echo "identical too" > msgDj.tmp && + echo "identical" >> msgDj.tmp && + diff -b mw_dir_2/logDaddy.tmp msgDaddy.tmp && + diff -b mw_dir_2/logDj.tmp msgDj.tmp +' + + +test_expect_success 'Git clone creates only Main_Page.mw with an empty wiki' ' + wiki_reset && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_3 && + test_contains_N_files mw_dir_3 1 && + test -e mw_dir_3/Main_Page.mw +' + +test_expect_success 'Git clone does not fetch a deleted page' ' + wiki_reset && + wiki_editpage foo "this page must be deleted before the clone" false && + wiki_delete_page foo && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_4 && + test_contains_N_files mw_dir_4 1 && + test -e mw_dir_4/Main_Page.mw && + test ! -e mw_dir_4/Foo.mw +' + +test_expect_success 'Git clone works with page added' ' + wiki_reset && + wiki_editpage foo " I will be cloned" false && + wiki_editpage bar "I will be cloned" false && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_5 && + wiki_getallpage ref_page_5 && + test_diff_directories mw_dir_5 ref_page_5 && + wiki_delete_page foo && + wiki_delete_page bar +' + +test_expect_success 'Git clone works with an edited page ' ' + wiki_reset && + wiki_editpage foo "this page will be edited" \ + false -s "first edition of page foo"&& + wiki_editpage foo "this page has been edited and must be on the clone " true && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_6 && + test -e mw_dir_6/Foo.mw && + test -e mw_dir_6/Main_Page.mw && + wiki_getallpage mw_dir_6/page_ref_6 && + test_diff_directories mw_dir_6 mw_dir_6/page_ref_6 && + (cd mw_dir_6 && + git log --format=%s HEAD^ Foo.mw > ../Foo.log ) && + echo "first edition of page foo" > FooExpect.log && + diff FooExpect.log Foo.log +' + + +test_expect_success 'Git clone works with several pages and some deleted ' ' + wiki_reset && + wiki_editpage foo "this page will not be deleted" false && + wiki_editpage bar "I must not be erased" false && + wiki_editpage namnam "I will not be there at the end" false && + wiki_editpage nyancat "nyan nyan nyan delete me" false && + wiki_delete_page namnam && + wiki_delete_page nyancat && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_7 && + test -e mw_dir_7/Foo.mw && + test -e mw_dir_7/Bar.mw && + test ! -e mw_dir_7/Namnam.mw && + test ! -e mw_dir_7/Nyancat.mw && + wiki_getallpage mw_dir_7/page_ref_7 && + test_diff_directories mw_dir_7 mw_dir_7/page_ref_7 +' + + +test_expect_success 'Git clone works with one specific page cloned ' ' + wiki_reset && + wiki_editpage foo "I will not be cloned" false && + wiki_editpage bar "Do not clone me" false && + wiki_editpage namnam "I will be cloned :)" false -s="this log must stay" && + wiki_editpage nyancat "nyan nyan nyan you cant clone me" false && + git clone -c remote.origin.pages=namnam mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_8 && + test_contains_N_files mw_dir_8 1 && + test -e mw_dir_8/Namnam.mw && + test ! -e mw_dir_8/Main_Page.mw && + (cd mw_dir_8 && + echo "this log must stay" > msg.tmp && + git log --format=%s > log.tmp && + diff -b msg.tmp log.tmp ) && + wiki_check_content mw_dir_8/Namnam.mw Namnam +' + +test_expect_success 'Git clone works with multiple specific page cloned ' ' + wiki_reset && + wiki_editpage foo "I will be there" false && + wiki_editpage bar "I will not disapear" false && + wiki_editpage namnam "I be erased" false && + wiki_editpage nyancat "nyan nyan nyan you will not erase me" false && + wiki_delete_page namnam && + git clone -c remote.origin.pages='"'foo bar nyancat namnam'"' mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_9 && + test_contains_N_files mw_dir_9 3 && + test ! -e mw_dir_9/Namnam.mw && + test -e mw_dir_9/Foo.mw && + test -e mw_dir_9/Nyancat.mw && + test -e mw_dir_9/Bar.mw && + wiki_check_content mw_dir_9/Foo.mw Foo && + wiki_check_content mw_dir_9/Bar.mw Bar && + wiki_check_content mw_dir_9/Nyancat.mw Nyancat +' + +test_expect_success 'Mediawiki-clone of several specific pages on wiki' ' + wiki_reset && + wiki_editpage foo "foo 1" false && + wiki_editpage bar "bar 1" false && + wiki_editpage dummy "dummy 1" false && + wiki_editpage cloned_1 "cloned_1 1" false && + wiki_editpage cloned_2 "cloned_2 2" false && + wiki_editpage cloned_3 "cloned_3 3" false && + mkdir -p ref_page_10 && + wiki_getpage cloned_1 ref_page_10 && + wiki_getpage cloned_2 ref_page_10 && + wiki_getpage cloned_3 ref_page_10 && + git clone -c remote.origin.pages="cloned_1 cloned_2 cloned_3" mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_10 && + test_diff_directories mw_dir_10 ref_page_10 +' + +test_expect_success 'Git clone works with the shallow option' ' + wiki_reset && + wiki_editpage foo "1st revision, should be cloned" false && + wiki_editpage bar "1st revision, should be cloned" false && + wiki_editpage nyan "1st revision, should not be cloned" false && + wiki_editpage nyan "2nd revision, should be cloned" false && + git -c remote.origin.shallow=true clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_11 && + test_contains_N_files mw_dir_11 4 && + test -e mw_dir_11/Nyan.mw && + test -e mw_dir_11/Foo.mw && + test -e mw_dir_11/Bar.mw && + test -e mw_dir_11/Main_Page.mw && + (cd mw_dir_11 && + test `git log --oneline Nyan.mw | wc -l` -eq 1 && + test `git log --oneline Foo.mw | wc -l` -eq 1 && + test `git log --oneline Bar.mw | wc -l` -eq 1 && + test `git log --oneline Main_Page.mw | wc -l ` -eq 1 ) && + wiki_check_content mw_dir_11/Nyan.mw Nyan && + wiki_check_content mw_dir_11/Foo.mw Foo && + wiki_check_content mw_dir_11/Bar.mw Bar && + wiki_check_content mw_dir_11/Main_Page.mw Main_Page +' + +test_expect_success 'Git clone works with the shallow option with a delete page' ' + wiki_reset && + wiki_editpage foo "1st revision, will be deleted" false && + wiki_editpage bar "1st revision, should be cloned" false && + wiki_editpage nyan "1st revision, should not be cloned" false && + wiki_editpage nyan "2nd revision, should be cloned" false && + wiki_delete_page foo && + git -c remote.origin.shallow=true clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_12 && + test_contains_N_files mw_dir_12 3 && + test -e mw_dir_12/Nyan.mw && + test ! -e mw_dir_12/Foo.mw && + test -e mw_dir_12/Bar.mw && + test -e mw_dir_12/Main_Page.mw && + (cd mw_dir_12 && + test `git log --oneline Nyan.mw | wc -l` -eq 1 && + test `git log --oneline Bar.mw | wc -l` -eq 1 && + test `git log --oneline Main_Page.mw | wc -l ` -eq 1 ) && + wiki_check_content mw_dir_12/Nyan.mw Nyan && + wiki_check_content mw_dir_12/Bar.mw Bar && + wiki_check_content mw_dir_12/Main_Page.mw Main_Page +' + +test_expect_success 'Test of fetching a category' ' + wiki_reset && + wiki_editpage Foo "I will be cloned" false -c=Category && + wiki_editpage Bar "Meet me on the repository" false -c=Category && + wiki_editpage Dummy "I will not come" false && + wiki_editpage BarWrong "I will stay online only" false -c=NotCategory && + git clone -c remote.origin.categories="Category" mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_13 && + wiki_getallpage ref_page_13 Category && + test_diff_directories mw_dir_13 ref_page_13 +' + +test_expect_success 'Test of resistance to modification of category on wiki for clone' ' + wiki_reset && + wiki_editpage Tobedeleted "this page will be deleted" false -c=Catone && + wiki_editpage Tobeedited "this page will be modified" false -c=Catone && + wiki_editpage Normalone "this page wont be modified and will be on git" false -c=Catone && + wiki_editpage Notconsidered "this page will not appear on local" false && + wiki_editpage Othercategory "this page will not appear on local" false -c=Cattwo && + wiki_editpage Tobeedited "this page have been modified" true -c=Catone && + wiki_delete_page Tobedeleted + git clone -c remote.origin.categories="Catone" mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_14 && + wiki_getallpage ref_page_14 Catone && + test_diff_directories mw_dir_14 ref_page_14 +' + +test_done
Signature · 1 line
1.7.10.2.552.gaa3bb87
Re: [PATCH 3/6] Test file for git-remote-mediawiki clone
Simon Cathebras <[email protected]> a écrit :
Quoted 51 lines
From: Guillaume Sasdy <[email protected]>
This patch provides some tests for the clone in use by git-remote-mediawiki.
Signed-off-by Simon Cathebras <[email protected]>Signed-off-by Simon Perrat <[email protected]>Signed-off-by Guillaume Sasdy <[email protected]>Signed-off-by Charles Roussel <[email protected]>Signed-off-by Julien Khayat <[email protected]>Signed-off-by Matthieu Moy <[email protected]>--- contrib/mw-to-git/t/t9360-mw-to-git-clone.sh | 238 +++++++++++++++++++++++++++ 1 file changed, 238 insertions(+) create mode 100755 contrib/mw-to-git/t/t9360-mw-to-git-clone.shcontrib/mw-to-git/t/t9360-mw-to-git-clone.sh new file +24
-0@@ -0,0 +1,238 @@ +#!/bin/sh +# +# Copyright (C) 2012 +# Charles Roussel <[email protected]> +# Simon Cathebras <[email protected]> +# Julien Khayat <[email protected]> +# Guillaume Sasdy <[email protected]> +# Simon Perrat <[email protected]> +# +# License: GPL v2 or later + + +test_description='Test the Git Mediawiki remote helper: git clone' + +. ./test-gitmw-lib.sh +. $TEST_DIRECTORY/test-lib.sh + + +test_check_precond + + +test_expect_success 'Git clone creates the git log expected with one file' ' + wiki_reset && + wiki_editpage foo "this is not important" false -c cat -s "thismust be the same" &&
contrib/mw-to-git/t/t9360-mw-to-git-clone.sh new file +1
-0+ git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"'
mw_dir_1&&
contrib/mw-to-git/t/t9360-mw-to-git-clone.sh line 30
Quoted 5 lines
contrib/mw-to-git/t/t9360-mw-to-git-clone.sh new file +5
-0+ (cd mw_dir_1 && + git log --format=%s HEAD^..HEAD > log.tmp ) && + echo "this must be the same" > msg.tmp && + diff -b mw_dir_1/log.tmp msg.tmp +'
It's clearer to put it this way:
git clone [...] &&
(
cd ... &&
....
) &&
....And, about style:
"echo one >one" and not "echo one > one"
Re: [PATCH 3/6] Test file for git-remote-mediawiki clone
Quoted 62 lines · On 12/06/2012 23:34, [email protected] wrote:
Quoted 51 lines · Simon Cathebras
From: Guillaume Sasdy <[email protected]>
This patch provides some tests for the clone in use by git-remote-mediawiki.
Signed-off-by Simon Cathebras <[email protected]>Signed-off-by Simon Perrat <[email protected]>Signed-off-by Guillaume Sasdy <[email protected]>Signed-off-by Charles Roussel <[email protected]>Signed-off-by Julien Khayat <[email protected]>Signed-off-by Matthieu Moy <[email protected]>--- contrib/mw-to-git/t/t9360-mw-to-git-clone.sh | 238 +++++++++++++++++++++++++++ 1 file changed, 238 insertions(+) create mode 100755 contrib/mw-to-git/t/t9360-mw-to-git-clone.shcontrib/mw-to-git/t/t9360-mw-to-git-clone.sh new file +22
-0@@ -0,0 +1,238 @@ +#!/bin/sh +# +# Copyright (C) 2012 +# Charles Roussel <[email protected]> +# Simon Cathebras <[email protected]> +# Julien Khayat <[email protected]> +# Guillaume Sasdy <[email protected]> +# Simon Perrat <[email protected]> +# +# License: GPL v2 or later + + +test_description='Test the Git Mediawiki remote helper: git clone' + +. ./test-gitmw-lib.sh +. $TEST_DIRECTORY/test-lib.sh + + +test_check_precond + + +test_expect_success 'Git clone creates the git log expected with onefile' '
contrib/mw-to-git/t/t9360-mw-to-git-clone.sh new file +2
-0+ wiki_reset && + wiki_editpage foo "this is not important" false -c cat -s "thismust be the same" &&
+ git clone
mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"'mw_dir_1&&contrib/mw-to-git/t/t9360-mw-to-git-clone.sh line 30
Quoted 5 lines
contrib/mw-to-git/t/t9360-mw-to-git-clone.sh new file +5
-0+ (cd mw_dir_1 && + git log --format=%s HEAD^..HEAD > log.tmp ) && + echo "this must be the same" > msg.tmp && + diff -b mw_dir_1/log.tmp msg.tmp +'It's clearer to put it this way:
Quoted 7 lines
git clone [...] &&
(
cd ... &&
....
) &&
....Okay, we are modifiying it right now.
Quoted 5 lines
And, about style:
"echo one >one" and not "echo one > one"
same.
Simon C.
Signature · 6 lines
CATHEBRAS Simon 2A-ENSIMAG Filière Ingéniérie des Systèmes d'Information Membre Bug-Buster
PATCH 4/6 Tests for git-remote-mediawiki pull and push
In reply to Simon CathebrasFrom: Guillaume Sasdy <[email protected]>
This patch provides a set of tests for the pull and push fonctionnality of git-remote-mediawiki.
--- contrib/mw-to-git/t/t9361-mw-to-git-push-pull.sh | 151 +++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100755 contrib/mw-to-git/t/t9361-mw-to-git-push-pull.sh
contrib/mw-to-git/t/t9361-mw-to-git-push-pull.sh new file +151 -0
@@ -0,0 +1,151 @@ +#!/bin/sh +# +# Copyright (C) 2012 +# Charles Roussel <[email protected]> +# Simon Cathebras <[email protected]> +# Julien Khayat <[email protected]> +# Guillaume Sasdy <[email protected]> +# Simon Perrat <[email protected]> +# +# License: GPL v2 or later + +# tests for git-remote-mediawiki + +test_description='Test the Git Mediawiki remote helper: git push and git pull simple test cases' + +. ./test-gitmw-lib.sh +. $TEST_DIRECTORY/test-lib.sh + + +test_check_precond + + +test_expect_success 'Git pull works after adding a new wiki page' ' + wiki_reset && + + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_1 && + wiki_editpage Foo "page created after the git clone" false && + + (cd mw_dir_1 && + git pull) && + + wiki_getallpage ref_page_1 && + test_diff_directories mw_dir_1 ref_page_1 +' + +test_expect_success 'Git pull works after editing a wiki page' ' + wiki_reset && + + wiki_editpage Foo "page created before the git clone" false && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_2 && + wiki_editpage Foo "new line added on the wiki" true && + + (cd mw_dir_2 && + git pull) && + + wiki_getallpage ref_page_2 && + test_diff_directories mw_dir_2 ref_page_2 +' + +test_expect_success 'git pull works on conflict handled by auto-merge' ' + wiki_reset && + + wiki_editpage Foo "1 init +3 +5 +" false && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_3 && + + wiki_editpage Foo "1 init +2 content added on wiki after clone +3 +5 +" false && + + (cd mw_dir_3 && + echo "1 init +3 +4 content added on git after clone +5 +" > Foo.mw && + git commit -am "conflicting change on foo" && + git pull && + git push) +' + +test_expect_success 'Git push works after adding a file .mw' ' + wiki_reset && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_4 && + wiki_getallpage ref_page_4 && + (cd mw_dir_4 && + test ! -f Foo.mw && + touch Foo.mw && + echo "hello world" >> Foo.mw && + git add Foo.mw && + git commit -m "Foo" && + git push) && + wiki_getallpage ref_page_4 && + test_diff_directories mw_dir_4 ref_page_4 +' + +test_expect_success 'Git push works after editing a file .mw' ' + wiki_reset && + wiki_editpage "Foo" "page created before the git clone" false && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_5 && + + (cd mw_dir_5 && + echo "new line added in the file Foo.mw" >> Foo.mw && + git commit -am "edit file Foo.mw" && + git push) && + + wiki_getallpage ref_page_5 && + test_diff_directories mw_dir_5 ref_page_5 +' + +test_expect_failure 'Git push works after deleting a file' ' + wiki_reset && + wiki_editpage Foo "wiki page added before git clone" false && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_6 && + + (cd mw_dir_6 && + git rm Foo.mw && + git commit -am "page Foo.mw deleted" && + git push) && + + test ! wiki_page_exist Foo +' + + + +test_expect_success 'Merge conflict expected and solving it' ' + wiki_reset && + + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_7 && + wiki_editpage Foo "1 conflict +3 wiki +4" false && + + (cd mw_dir_7 && + echo "1 conflict +2 git +4" > Foo.mw && + git add Foo.mw && + git commit -m "conflict created" && + test_must_fail git pull && + perl -pi -e "s/[<=>].*//g" Foo.mw && + git commit -am "merge conflict solved" && + git push) +' + +test_expect_failure 'git pull works after deleting a wiki page' ' + wiki_reset && + wiki_editpage Foo "wiki page added before the git clone" false && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_8 && + + wiki_delete_page Foo && + (cd mw_dir_8 && + git pull && + test ! -f Foo.mw) +' + +test_done
Signature · 1 line
1.7.10.2.552.gaa3bb87
PATCH 5/6 Tests of UTF8 character with git-remote-mediawiki
In reply to Simon CathebrasThis patch provides a sample of tests for git-remote-mediawiki's resistance, concerning utf8 special characters.
--- contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh | 271 ++++++++++++++++++++++++++++ 1 file changed, 271 insertions(+) create mode 100755 contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh
contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh new file +271 -0
@@ -0,0 +1,271 @@ +#!/bin/sh +# +# Copyright (C) 2012 +# Charles Roussel <[email protected]> +# Simon Cathebras <[email protected]> +# Julien Khayat <[email protected]> +# Guillaume Sasdy <[email protected]> +# Simon Perrat <[email protected]> +# +# 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 + + +test_check_precond + + +test_expect_success 'Git clone works for a wiki with accents in the page names' ' + wiki_reset && + 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://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_1 && + wiki_getallpage ref_page_1 && + test_diff_directories mw_dir_1 ref_page_1 +' + + +test_expect_success 'Git pull works with a wiki with accents in the pages names' ' + wiki_reset && + wiki_editpage kîî "this page must be cloned" false && + wiki_editpage foo "this page must be cloned" false && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_2 && + wiki_editpage éàîôû "This page must be pulled" false && + (cd mw_dir_2 && + git pull ) && + wiki_getallpage ref_page_2 && + test_diff_directories mw_dir_2 ref_page_2 +' + +# 3 +test_expect_success 'Cloning a chosen page works with accents' ' + wiki_reset && + wiki_editpage kîî "this page must be cloned" false && + git clone -c remote.origin.pages=kîî mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_3 && + wiki_check_content mw_dir_3/Kîî.mw Kîî && + test -e mw_dir_3/Kîî.mw && + rm -rf mw_dir_3 +' + + +test_expect_success 'The shallow option works with accents' ' + wiki_reset && + 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://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_4 && + test_contains_N_files mw_dir_4 2 && + test -e mw_dir_4/Néoà.mw && + test -e mw_dir_4/Main_Page.mw && + (cd mw_dir_4 && + test `git log --oneline Néoà.mw | wc -l` -eq 1 && + test `git log --oneline Main_Page.mw | wc -l ` -eq 1 ) && + wiki_check_content mw_dir_4/Néoà.mw Néoà && + wiki_check_content mw_dir_4/Main_Page.mw Main_Page +' + + +test_expect_success 'Cloning works when page name first letter has an accent' ' + wiki_reset && + wiki_editpage îî "this page must be cloned" false && + git clone -c remote.origin.pages=îî mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_5 && + test -e mw_dir_5/Îî.mw && + wiki_check_content mw_dir_5/Îî.mw Îî +' + + +test_expect_success 'Git push works with a wiki with accents' ' + wiki_reset && + wiki_editpage féé "lots of accents : éèàÖ" false && + wiki_editpage foo "this page must be cloned" false && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_6 && + (cd mw_dir_6 && + 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 ) && + wiki_getallpage ref_page_6 && + test_diff_directories mw_dir_6 ref_page_6 +' + +test_expect_success 'Git clone works with accentsand spaces' ' + wiki_reset && + wiki_editpage "é à î" "this page must be délété before the clone" false && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_7 && + wiki_getallpage ref_page_7 && + test_diff_directories mw_dir_7 ref_page_7 +' + +test_expect_success 'character $ in page name (mw -> git)' ' + wiki_reset && + wiki_editpage file_\$_foo "expect to be called file_$_foo" false && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_8 && + test -f mw_dir_8/File_\$_foo.mw && + wiki_getallpage ref_page_8 && + test_diff_directories mw_dir_8 ref_page_8 +' + + + +test_expect_success 'character $ in file name (git -> mw) ' ' + wiki_reset && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_9 && + (cd mw_dir_9 && + echo "this file is called File_\$_foo.mw" > File_\$_foo.mw && + git add . && + git commit -am "file File_\$_foo.mw" && + git pull && + git push ) && + wiki_getallpage ref_page_9 && + test_diff_directories mw_dir_9 ref_page_9 +' + + +test_expect_failure 'capital at the begining of file names' ' + wiki_reset && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_10 && + (cd mw_dir_10 && + 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 ) && + wiki_getallpage ref_page_10 && + test_diff_directories mw_dir_10 ref_page_10 +' + + +test_expect_failure 'special character at the begining of file name from mw to git' ' + wiki_reset && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_11 && + 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_11 && + git pull ) && + test -f mw_dir_11/{char_1 && + test -f mw_dir_11/[char_2 +' + + +test_expect_success 'test of correct formating for file name from mw to git' ' + wiki_reset && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_12 && + 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_12 && + git pull ) && + test -f mw_dir_12/Char\{_1.mw && + test -f mw_dir_12/Char\[_2.mw && + wiki_getallpage ref_page_12 && + test_diff_directories mw_dir_12 ref_page_12 +' + + +test_expect_failure 'test of correct formating for file name begining with special character' ' + wiki_reset && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_13 && + (cd mw_dir_13 && + 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) && + wiki_getallpage ref_page_13 && + test -f ref_page_13/{char_1.mw && + test -f ref_page_13/[char_2.mw && + test_diff_directories mw_dir_13 ref_page_13 +' + + +test_expect_success 'test of correct formating for file name from git to mw' ' + wiki_reset && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_14 && + (cd mw_dir_14 && + 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 ) && + wiki_getallpage ref_page_14 && + test_diff_directories mw_dir_14 ref_page_14 +' + + +test_expect_success 'git clone with /' ' + wiki_reset && + wiki_editpage \/fo\/o "this is not important" false -c=Deleted && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_15 && + test -f mw_dir_15/%2Ffo%2Fo.mw && + wiki_check_content mw_dir_15/%2Ffo%2Fo.mw \/fo\/o +' + + +test_expect_success 'git push with /' ' + wiki_reset && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_16 && + echo "I will be on the wiki" > mw_dir_16/%2Ffo%2Fo.mw && + (cd mw_dir_16 && + git add %2Ffo%2Fo.mw && + git commit -m " %2Ffo%2Fo added" && + git push) && + wiki_page_exist \/fo\/o && + wiki_check_content mw_dir_16/%2Ffo%2Fo.mw \/fo\/o + +' + + +test_expect_success 'git clone with \' ' + wiki_reset && + wiki_editpage \\ko\\o "this is not important" false -c=Deleted && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_17 && + test -f mw_dir_17/\\ko\\o.mw && + wiki_check_content mw_dir_17/\\ko\\o.mw \\ko\\o +' + + +test_expect_success 'git push with \' ' + wiki_reset && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_18 && + echo "I will be on the wiki" > mw_dir_18/\\ko\\o.mw && + (cd mw_dir_18 && + git add \\ko\\o.mw && + git commit -m " \\ko\\o added" && + git push )&& + wiki_page_exist \\ko\\o && + wiki_check_content mw_dir_18/\\ko\\o.mw \\ko\\o + +' + +test_expect_success 'git clone with \ in format control' ' + wiki_reset && + wiki_editpage \\no\\o "this is not important" false && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_19 && + test -f mw_dir_19/\\no\\o.mw && + wiki_check_content mw_dir_19/\\no\\o.mw \\no\\o +' + + +test_expect_success 'git push with \ in format control' ' + wiki_reset && + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_20 && + echo "I will be on the wiki" > mw_dir_20/\\fo\\o.mw && + (cd mw_dir_20 && + git add \\fo\\o.mw && + git commit -m " \\fo\\o added" && + git push )&& + wiki_page_exist \\fo\\o && + wiki_check_content mw_dir_20/\\fo\\o.mw \\fo\\o + +' + + +test_done
Signature · 1 line
1.7.10.2.552.gaa3bb87
Re: [PATCH 5/6] Tests of UTF8 character with git-remote-mediawiki
Simon Cathebras <[email protected]> a écrit :
Quoted 9 lines
This patch provides a sample of tests for git-remote-mediawiki's resistance, concerning utf8 special characters.
Signed-off-by Simon Cathebras <[email protected]>Signed-off-by Simon Perrat <[email protected]>Signed-off-by Guillaume Sasdy <[email protected]>Signed-off-by Charles Roussel <[email protected]>Signed-off-by Julien Khayat <[email protected]>Signed-off-by Matthieu Moy <[email protected]>
Quoted 5 lines
--- contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh | 271 ++++++++++++++++++++++++++++ 1 file changed, 271 insertions(+) create mode 100755 contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh
Thanks, it applies correctly now :)
Re: [PATCH 5/6] Tests of UTF8 character with git-remote-mediawiki
In reply to Simon CathebrasPlease accept our appologize for the bad tag for patches.
The PATCH 5 is actually the last one...
Regards.
Simon C
Quoted 291 lines · Simon Cathebras
This patch provides a sample of tests for git-remote-mediawiki's resistance, concerning utf8 special characters.
Signed-off-by Simon Cathebras<[email protected]>Signed-off-by Simon Perrat<[email protected]>Signed-off-by Guillaume Sasdy<[email protected]>Signed-off-by Charles Roussel<[email protected]>Signed-off-by Julien Khayat<[email protected]>Signed-off-by Matthieu Moy<[email protected]>--- contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh | 271 ++++++++++++++++++++++++++++ 1 file changed, 271 insertions(+)create mode 100755
contrib/mw-to-git/t/t9362-mw-to-git-utf8.shcontrib/mw-to-git/t/t9362-mw-to-git-utf8.sh new file +271
-0@@ -0,0 +1,271 @@ +#!/bin/sh +# +# Copyright (C) 2012 +# Charles Roussel<[email protected]> +# Simon Cathebras<[email protected]> +# Julien Khayat<[email protected]> +# Guillaume Sasdy<[email protected]> +# Simon Perrat<[email protected]> +# +# 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 + + +test_check_precond + + +test_expect_success 'Git clone works for a wiki with accents in the page names' ' + wiki_reset&& + 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://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_1&& + wiki_getallpage ref_page_1&& + test_diff_directories mw_dir_1 ref_page_1 +' + + +test_expect_success 'Git pull works with a wiki with accents in the pages names' ' + wiki_reset&& + wiki_editpage kîî "this page must be cloned" false&& + wiki_editpage foo "this page must be cloned" false&& + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_2&& + wiki_editpage éàîôû "This page must be pulled" false&& + (cd mw_dir_2&& + git pull )&& + wiki_getallpage ref_page_2&& + test_diff_directories mw_dir_2 ref_page_2 +' + +# 3 +test_expect_success 'Cloning a chosen page works with accents' ' + wiki_reset&& + wiki_editpage kîî "this page must be cloned" false&& + git clone -c remote.origin.pages=kîî mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_3&& + wiki_check_content mw_dir_3/Kîî.mw Kîî&& + test -e mw_dir_3/Kîî.mw&& + rm -rf mw_dir_3 +' + + +test_expect_success 'The shallow option works with accents' ' + wiki_reset&& + 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://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_4&& + test_contains_N_files mw_dir_4 2&& + test -e mw_dir_4/Néoà.mw&& + test -e mw_dir_4/Main_Page.mw&& + (cd mw_dir_4&& + test `git log --oneline Néoà.mw | wc -l` -eq 1&& + test `git log --oneline Main_Page.mw | wc -l ` -eq 1 )&& + wiki_check_content mw_dir_4/Néoà.mw Néoà&& + wiki_check_content mw_dir_4/Main_Page.mw Main_Page +' + + +test_expect_success 'Cloning works when page name first letter has an accent' ' + wiki_reset&& + wiki_editpage îî "this page must be cloned" false&& + git clone -c remote.origin.pages=îî mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_5&& + test -e mw_dir_5/Îî.mw&& + wiki_check_content mw_dir_5/Îî.mw Îî +' + + +test_expect_success 'Git push works with a wiki with accents' ' + wiki_reset&& + wiki_editpage féé "lots of accents : éèàÖ" false&& + wiki_editpage foo "this page must be cloned" false&& + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_6&& + (cd mw_dir_6&& + 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 )&& + wiki_getallpage ref_page_6&& + test_diff_directories mw_dir_6 ref_page_6 +' + +test_expect_success 'Git clone works with accentsand spaces' ' + wiki_reset&& + wiki_editpage "é à î" "this page must be délété before the clone" false&& + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_7&& + wiki_getallpage ref_page_7&& + test_diff_directories mw_dir_7 ref_page_7 +' + +test_expect_success 'character $ in page name (mw -> git)' ' + wiki_reset&& + wiki_editpage file_\$_foo "expect to be called file_$_foo" false&& + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_8&& + test -f mw_dir_8/File_\$_foo.mw&& + wiki_getallpage ref_page_8&& + test_diff_directories mw_dir_8 ref_page_8 +' + + + +test_expect_success 'character $ in file name (git -> mw) ' ' + wiki_reset&& + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_9&& + (cd mw_dir_9&& + echo "this file is called File_\$_foo.mw"> File_\$_foo.mw&& + git add .&& + git commit -am "file File_\$_foo.mw"&& + git pull&& + git push )&& + wiki_getallpage ref_page_9&& + test_diff_directories mw_dir_9 ref_page_9 +' + + +test_expect_failure 'capital at the begining of file names' ' + wiki_reset&& + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_10&& + (cd mw_dir_10&& + 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 )&& + wiki_getallpage ref_page_10&& + test_diff_directories mw_dir_10 ref_page_10 +' + + +test_expect_failure 'special character at the begining of file name from mw to git' ' + wiki_reset&& + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_11&& + 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_11&& + git pull )&& + test -f mw_dir_11/{char_1&& + test -f mw_dir_11/[char_2 +' + + +test_expect_success 'test of correct formating for file name from mw to git' ' + wiki_reset&& + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_12&& + 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_12&& + git pull )&& + test -f mw_dir_12/Char\{_1.mw&& + test -f mw_dir_12/Char\[_2.mw&& + wiki_getallpage ref_page_12&& + test_diff_directories mw_dir_12 ref_page_12 +' + + +test_expect_failure 'test of correct formating for file name begining with special character' ' + wiki_reset&& + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_13&& + (cd mw_dir_13&& + 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)&& + wiki_getallpage ref_page_13&& + test -f ref_page_13/{char_1.mw&& + test -f ref_page_13/[char_2.mw&& + test_diff_directories mw_dir_13 ref_page_13 +' + + +test_expect_success 'test of correct formating for file name from git to mw' ' + wiki_reset&& + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_14&& + (cd mw_dir_14&& + 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 )&& + wiki_getallpage ref_page_14&& + test_diff_directories mw_dir_14 ref_page_14 +' + + +test_expect_success 'git clone with /' ' + wiki_reset&& + wiki_editpage \/fo\/o "this is not important" false -c=Deleted&& + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_15&& + test -f mw_dir_15/%2Ffo%2Fo.mw&& + wiki_check_content mw_dir_15/%2Ffo%2Fo.mw \/fo\/o +' + + +test_expect_success 'git push with /' ' + wiki_reset&& + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_16&& + echo "I will be on the wiki"> mw_dir_16/%2Ffo%2Fo.mw&& + (cd mw_dir_16&& + git add %2Ffo%2Fo.mw&& + git commit -m " %2Ffo%2Fo added"&& + git push)&& + wiki_page_exist \/fo\/o&& + wiki_check_content mw_dir_16/%2Ffo%2Fo.mw \/fo\/o + +' + + +test_expect_success 'git clone with \' ' + wiki_reset&& + wiki_editpage \\ko\\o "this is not important" false -c=Deleted&& + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_17&& + test -f mw_dir_17/\\ko\\o.mw&& + wiki_check_content mw_dir_17/\\ko\\o.mw \\ko\\o +' + + +test_expect_success 'git push with \' ' + wiki_reset&& + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_18&& + echo "I will be on the wiki"> mw_dir_18/\\ko\\o.mw&& + (cd mw_dir_18&& + git add \\ko\\o.mw&& + git commit -m " \\ko\\o added"&& + git push )&& + wiki_page_exist \\ko\\o&& + wiki_check_content mw_dir_18/\\ko\\o.mw \\ko\\o + +' + +test_expect_success 'git clone with \ in format control' ' + wiki_reset&& + wiki_editpage \\no\\o "this is not important" false&& + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_19&& + test -f mw_dir_19/\\no\\o.mw&& + wiki_check_content mw_dir_19/\\no\\o.mw \\no\\o +' + + +test_expect_success 'git push with \ in format control' ' + wiki_reset&& + git clone mediawiki::http://'"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME"' mw_dir_20&& + echo "I will be on the wiki"> mw_dir_20/\\fo\\o.mw&& + (cd mw_dir_20&& + git add \\fo\\o.mw&& + git commit -m " \\fo\\o added"&& + git push )&& + wiki_page_exist \\fo\\o&& + wiki_check_content mw_dir_20/\\fo\\o.mw \\fo\\o + +' + + +test_done
Signature · 6 lines
CATHEBRAS Simon 2A-ENSIMAG Filière Ingéniérie des Systèmes d'Information Membre Bug-Buster
Re: [PATCH 5/6] Tests of UTF8 character with git-remote-mediawiki
"Simon.Cathebras" <[email protected]> a écrit :
Quoted 3 lines
Please accept our appologize for the bad tag for patches.
The PATCH 5 is actually the last one...
Shouldn't it also be the version 4 ?
Thanks,
Lucien Kong
Re: [PATCH 5/6] Tests of UTF8 character with git-remote-mediawiki
Quoted 9 lines · On 12/06/2012 23:52, [email protected] wrote:
Quoted 3 lines · Simon.Cathebras
Please accept our appologize for the bad tag for patches.
The PATCH 5 is actually the last one...
Shouldn't it also be the version 4 ?
Actually, yes.
Thanks.
Quoted 4 lines
Thanks,
Lucien Kong
Signature · 6 lines
CATHEBRAS Simon 2A-ENSIMAG Filière Ingéniérie des Systèmes d'Information Membre Bug-Buster
Re: [PATCHv3 4/6] Tests for git-remote-mediawiki pull
In reply to [email protected]2012/6/11 <[email protected]>:
Quoted 29 lines
Simon Cathebras <[email protected]> a écrit :
Quoted 9 lines
contrib/mw-to-git/t/t9361-mw-to-git-pull.sh new file +9
-0+test_expect_success 'Git pull works after adding a new wiki page' " + wiki_reset && + cd $TRASH_DIR && + rm -rf mw_dir && + rm -rf ref_page && + + git clone mediawiki::http://$SERVER_ADDR/$WIKI_DIR_NAME mw_dir && + wiki_editpage Foo \"page created after the git clone\" false && +contrib/mw-to-git/t/t9361-mw-to-git-pull.sh line 58
Quoted 10 lines
contrib/mw-to-git/t/t9361-mw-to-git-pull.sh new file +10
-0+ cd mw_dir && + git pull && + cd .. && + + rm -rf ref_page && + wiki_getallpage ref_page && + test_diff_directories mw_dir ref_page && + rm -rf ref_page && + rm -rf mw_dir +"Why are there dquotes here (and all the following tests) ? You used simple quote in t9360.
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
We corrected this to use simple quotes in all our tests; originally we used double quotes because of $ in the scripts, now we're escaping them.
PATCH v3 5/6 Test file for git-remote-mediawiki push
In reply to Simon CathebrasFrom: Guillaume Sasdy <[email protected]>
This patch provides a set of tests for the push function of git-remote-mediawiki.
These tests are part of the filegit/contrib/mw-to-git/t/t9361-mw-to-git-push.sh.
--- contrib/mw-to-git/t/t9361-mw-to-git-push.sh | 110 ++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100755 contrib/mw-to-git/t/t9361-mw-to-git-push.sh
contrib/mw-to-git/t/t9361-mw-to-git-push.sh new file +110 -0
@@ -0,0 +1,110 @@ +#!/bin/sh +# +# Copyright (C) 2012 +# Charles Roussel <[email protected]> +# Simon Cathebras <[email protected]> +# Julien Khayat <[email protected]> +# Guillaume Sasdy <[email protected]> +# Simon Perrat <[email protected]> +# +# License: GPL v2 or later + +# tests for git-remote-mediawiki + +test_description='Test the Git Mediawiki remote helper: git push and git pull simple test cases' + +. ./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 + +test_expect_success 'Git push works after adding a file .mw' " + wiki_reset && + cd $TRASH_DIR && + git clone mediawiki::http://$SERVER_ADDR/$WIKI_DIR_NAME mw_dir && + wiki_getallpage ref_page && + cd mw_dir && + test ! -f Foo.mw && + touch Foo.mw && + echo \"hello world\" >> Foo.mw && + git add Foo.mw && + git commit -m \"Foo\" && + git push && + cd .. && + + rm -rf ref_page && + wiki_getallpage ref_page && + test_diff_directories mw_dir ref_page && + rm -rf ref_page && + rm -rf mw_dir +" + +test_expect_success 'Git push works after editing a file .mw' " + wiki_reset && + cd $TRASH_DIR && + rm -rf mw_dir && + rm -rf ref_page && + wiki_editpage \"Foo\" \"page created before the git clone\" false && + git clone mediawiki::http://$SERVER_ADDR/$WIKI_DIR_NAME mw_dir && + + cd mw_dir && + echo \"new line added in the file Foo.mw\" >> Foo.mw && + git commit -am \"edit file Foo.mw\" && + git push && + cd .. && + + rm -rf ref_page && + wiki_getallpage ref_page && + test_diff_directories mw_dir ref_page && + rm -rf ref_page && + rm -rf mw_dir +" + +test_expect_failure 'Git push works after deleting a file' " + wiki_reset && + cd $TRASH_DIR && + rm -rf mw_dir && + rm -rf ref_page && + wiki_editpage Foo \"wiki page added before git clone\" false && + git clone mediawiki::http://$SERVER_ADDR/$WIKI_DIR_NAME mw_dir && + + cd mw_dir && + git rm Foo.mw && + git commit -am \"page Foo.mw deleted\" && + git push && + cd .. && + + rm -rf mw_dir && + test ! wiki_page_exist Foo +" + +test_expect_success 'Conflict solved manually' " + cat Foo.mw | sed '/[<=>][^$]*/ d' > Foo.mw~ && + cat Foo.mw~ > Foo.mw && + git commit -am \"merge conflict solved\" && + git push && + + cd .. && + rm -rf mw_dir +" + +test_done +
Signature · 1 line
1.7.10.2.552.gaa3bb87
=?y?q?=5BPATCHv3=206/6=5D=20Tests=20of=20UTF8=20character=20with=20git-remote-mediawiki?=
In reply to Simon CathebrasFrom: Guillaume Sasdy <[email protected]>
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 filegit/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh
--- 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
contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh new file +377 -0
@@ -0,0 +1,377 @@ +#!/bin/sh +# +# Copyright (C) 2012 +# Charles Roussel <[email protected]> +# Simon Cathebras <[email protected]> +# Julien Khayat <[email protected]> +# Guillaume Sasdy <[email protected]> +# Simon Perrat <[email protected]> +# +# 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
Signature · 1 line
1.7.10.2.552.gaa3bb87