git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]Test environment for git-remote-mediawiki
@ 2012-06-11 20:27 Simon.Cathebras
  2012-06-11 20:28 ` [PATCHv3 1/6] Scripts to install, delete and clear a MediaWiki Simon Cathebras
  0 siblings, 1 reply; 40+ messages in thread
From: Simon.Cathebras @ 2012-06-11 20:27 UTC (permalink / raw)
  To: git
  Cc: Matthieu Moy, charles.roussel, Guillaume Sasdy, Simon PERRAT,
	Julien Khayat, Junio C Hamano, peff

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.

-- 
CATHEBRAS Simon

2A-ENSIMAG

Filière Ingéniérie des Systèmes d'Information
Membre Bug-Buster

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCHv3 1/6] Scripts to install, delete and clear a MediaWiki
  2012-06-11 20:27 [PATCH]Test environment for git-remote-mediawiki Simon.Cathebras
@ 2012-06-11 20:28 ` Simon Cathebras
  2012-06-11 20:28   ` [PATCHv3 2/6] Test environment of git-remote-mediawiki Simon Cathebras
                     ` (4 more replies)
  0 siblings, 5 replies; 40+ messages in thread
From: Simon Cathebras @ 2012-06-11 20:28 UTC (permalink / raw)
  To: git
  Cc: simon.cathebras, Matthieu.Moy, Guillaume.Sasdy, Julien.Khayat,
	charles.roussel, gitster, peff, Simon.Perrat, Guillaume Sasdy,
	Simon Perrat, Julien Khayat, Matthieu Moy

From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>

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/

Signed-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>
Signed-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>
Signed-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>
Signed-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
Signed-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@imag.fr>

---
 contrib/mw-to-git/t/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

diff --git a/contrib/mw-to-git/t/install-wiki.sh b/contrib/mw-to-git/t/install-wiki.sh
new file mode 100755
index 0000000..322f46d
--- /dev/null
+++ b/contrib/mw-to-git/t/install-wiki.sh
@@ -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
+
diff --git a/contrib/mw-to-git/t/install-wiki/LocalSettings.php b/contrib/mw-to-git/t/install-wiki/LocalSettings.php
new file mode 100644
index 0000000..c2fe3d5
--- /dev/null
+++ b/contrib/mw-to-git/t/install-wiki/LocalSettings.php
@@ -0,0 +1,129 @@
+<?php
+# This file was automatically generated by the MediaWiki 1.19.0
+# installer. If you make manual changes, please keep track in case you
+# need to recreate them later.
+#
+# See includes/DefaultSettings.php for all configurable settings
+# and their default values, but don't forget to make changes in _this_
+# file, not there.
+#
+# Further documentation for configuration settings may be found at:
+# http://www.mediawiki.org/wiki/Manual:Configuration_settings
+
+# Protect against web entry
+if ( !defined( 'MEDIAWIKI' ) ) {
+	exit;
+}
+
+## Uncomment this to disable output compression
+# $wgDisableOutputCompression = true;
+
+$wgSitename      = "Git-MediaWiki-Test";
+$wgMetaNamespace = "Git-MediaWiki-Test";
+
+## The URL base path to the directory containing the wiki;
+## defaults for all runtime URL paths are based off of this.
+## For more information on customizing the URLs please see:
+## http://www.mediawiki.org/wiki/Manual:Short_URL
+$wgScriptPath       = "@WG_SCRIPT_PATH@";
+$wgScriptExtension  = ".php";
+
+## The protocol and server name to use in fully-qualified URLs
+$wgServer           = "@WG_SERVER@";
+
+## The relative URL path to the skins directory
+$wgStylePath        = "$wgScriptPath/skins";
+
+## The relative URL path to the logo.  Make sure you change this from the default,
+## or else you'll overwrite your logo when you upgrade!
+$wgLogo             = "$wgStylePath/common/images/wiki.png";
+
+## UPO means: this is also a user preference option
+
+$wgEnableEmail      = true;
+$wgEnableUserEmail  = true; # UPO
+
+$wgEmergencyContact = "apache@localhost";
+$wgPasswordSender   = "apache@localhost";
+
+$wgEnotifUserTalk      = false; # UPO
+$wgEnotifWatchlist     = false; # UPO
+$wgEmailAuthentication = true;
+
+## Database settings
+$wgDBtype           = "sqlite";
+$wgDBserver         = "";
+$wgDBname           = "wikidb";
+$wgDBuser           = "";
+$wgDBpassword       = "";
+
+# SQLite-specific settings
+$wgSQLiteDataDir    = "@WG_SQLITE_DATADIR@";
+
+
+## Shared memory settings
+$wgMainCacheType    = CACHE_NONE;
+$wgMemCachedServers = array();
+
+## To enable image uploads, make sure the 'images' directory
+## is writable, then set this to true:
+$wgEnableUploads  = false;
+$wgUseImageMagick = true;
+$wgImageMagickConvertCommand ="@CONVERT@";
+
+# InstantCommons allows wiki to use images from http://commons.wikimedia.org
+$wgUseInstantCommons  = false;
+
+## If you use ImageMagick (or any other shell command) on a
+## Linux server, this will need to be set to the name of an
+## available UTF-8 locale
+$wgShellLocale = "en_US.utf8";
+
+## If you want to use image uploads under safe mode,
+## create the directories images/archive, images/thumb and
+## images/temp, and make them all writable. Then uncomment
+## this, if it's not already uncommented:
+#$wgHashedUploadDirectory = false;
+
+## Set $wgCacheDirectory to a writable directory on the web server
+## to make your wiki go slightly faster. The directory should not
+## be publically accessible from the web.
+#$wgCacheDirectory = "$IP/cache";
+
+# Site language code, should be one of the list in ./languages/Names.php
+$wgLanguageCode = "en";
+
+$wgSecretKey = "1c912bfe3519fb70f5dc523ecc698111cd43d81a11c585b3eefb28f29c2699b7";
+#$wgSecretKey = "@SECRETKEY@";
+
+
+# Site upgrade key. Must be set to a string (default provided) to turn on the
+# web installer while LocalSettings.php is in place
+$wgUpgradeKey = "ddae7dc87cd0a645";
+
+## Default skin: you can change the default skin. Use the internal symbolic
+## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook', 'vector':
+$wgDefaultSkin = "vector";
+
+## For attaching licensing metadata to pages, and displaying an
+## appropriate copyright notice / icon. GNU Free Documentation
+## License and Creative Commons licenses are supported so far.
+$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright
+$wgRightsUrl  = "";
+$wgRightsText = "";
+$wgRightsIcon = "";
+
+# Path to the GNU diff3 utility. Used for conflict resolution.
+$wgDiff3 = "/usr/bin/diff3";
+
+# Query string length limit for ResourceLoader. You should only set this if
+# your web server has a query string length limit (then set it to that limit),
+# or if you have suhosin.get.max_value_length set in php.ini (then set it to
+# that value)
+$wgResourceLoaderMaxQueryLength = -1;
+
+
+
+# End of automatically generated settings.
+# Add more configuration options below.
+
diff --git a/contrib/mw-to-git/t/install-wiki/db_install.php b/contrib/mw-to-git/t/install-wiki/db_install.php
new file mode 100644
index 0000000..bd7a075
--- /dev/null
+++ b/contrib/mw-to-git/t/install-wiki/db_install.php
@@ -0,0 +1,110 @@
+<?php
+/**
+ * This script generates a SQLite database for a MediaWiki version 1.19.0
+ * You must specify the login of the admin (argument 1) and its
+ * password (argument 2) and the folder where the database file
+ * is located (absolute path in argument 3).
+ * It is used by the script install-wiki.sh in order to make easy the
+ * installation of a MediaWiki.
+ *
+ * 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'];
+
+$login = $argv[2];
+$pass = $argv[3];
+$tmp = $argv[4];
+
+$db_dir = urlencode($tmp);
+$tmp_cookie = tempnam($tmp,"COOKIE_");
+
+/*
+ * Fetchs a page with cURL.
+ */
+function get ($page_name = "") {
+        $curl = curl_init();
+        $page_name_add = "";
+        if ($page_name != "") {
+                $page_name_add = '?page='.$page_name;
+        }
+        $url = 'http://localhost/wiki/mw-config/index.php'.$page_name_add;
+        $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,
+                'http://localhost/wiki/mw-config/index.php'.$page_name_add);
+
+        $page = curl_exec($curl);
+        curl_close($curl);
+        return $page;
+}
+
+/*
+ * Submits a form with cURL.
+ */
+function submit($page_name, $option = "") {
+        $curl = curl_init();
+        $datapost = 'submit-continue=Continue+%E2%86%92';
+        if ($option != "") {
+                $datapost = $option.'&'.$datapost;
+        }
+        $url = 'http://localhost/wiki/mw-config/index.php?page='.$page_name;
+        $tmp_cookie = $GLOBALS['tmp_cookie'];
+        curl_setopt($curl, CURLOPT_URL, $url);
+        curl_setopt($curl, CURLOPT_POST, true);
+        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
+        curl_setopt($curl, CURLOPT_POSTFIELDS, $datapost);
+        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
+        curl_setopt($curl, CURLOPT_COOKIEJAR, $tmp_cookie);
+        curl_setopt($curl, CURLOPT_COOKIEFILE, $tmp_cookie);
+
+        $page = curl_exec($curl);
+        curl_close($curl);
+        return "$page";
+}
+
+/*
+ * Here starts this script: simulates the behavior of the user
+ * 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();
+preg_match('/input type="hidden" value="([0-9]+)" name="LanguageRequestTime"/',
+        $page, $matches);
+$timestamp = $matches[1];
+$language = "LanguageRequestTime=$timestamp&uselang=en&ContLang=en";
+$page = submit('Language', $language);
+
+submit('Welcome');
+
+$db_config = 'DBType=sqlite';
+$db_config = $db_config.'&sqlite_wgSQLiteDataDir='.$db_dir;
+$db_config = $db_config.'&sqlite_wgDBname='.$argv[1];
+submit('DBConnect', $db_config);
+
+$wiki_config = 'config_wgSitename=TEST';
+$wiki_config = $wiki_config.'&config__NamespaceType=site-name';
+$wiki_config = $wiki_config.'&config_wgMetaNamespace=MyWiki';
+$wiki_config = $wiki_config.'&config__AdminName='.$login;
+
+$wiki_config = $wiki_config.'&config__AdminPassword='.$pass;
+$wiki_config = $wiki_config.'&config__AdminPassword2='.$pass;
+
+$wiki_config = $wiki_config.'&wiki__configEmail=email%40email.org';
+$wiki_config = $wiki_config.'&config__SkipOptional=skip';
+submit('Name', $wiki_config);
+submit('Install');
+submit('Install');
+
+unlink($tmp_cookie);
+?>
diff --git a/contrib/mw-to-git/t/test-gitmw-lib.sh b/contrib/mw-to-git/t/test-gitmw-lib.sh
new file mode 100755
index 0000000..80b4f4f
--- /dev/null
+++ b/contrib/mw-to-git/t/test-gitmw-lib.sh
@@ -0,0 +1,154 @@
+# Copyright (C) 2012
+#     Charles Roussel <charles.roussel@ensimag.imag.fr>
+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>
+#     Julien Khayat <julien.khayat@ensimag.imag.fr>
+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
+#     Simon Perrat <simon.perrat@ensimag.imag.fr>
+# License: GPL v2 or later
+
+#
+# CONFIGURATION VARIABLES
+# You might want to change these ones
+#
+WIKI_DIR_NAME="wiki"            # Name of the wiki's directory
+WIKI_DIR_INST="/var/www"        # Directory of the web server
+TMP="/tmp"                      # Temporary directory for downloads
+                                # Absolute path required!
+SERVER_ADDR="localhost"         # Web server's address
+
+# CONFIGURATION
+# You should not change these ones unless you know what you do
+#
+MW_VERSION="mediawiki-1.19.0"
+DB_FILE="wikidb.sqlite"
+FILES_FOLDER="install-wiki"
+DB_INSTALL_SCRIPT="db_install.php"
+WIKI_ADMIN="WikiAdmin"
+WIKI_PASSW="AdminPass"
+
+}
+
+# Create the SQLite database of the MediaWiki. If the database file already
+# exists, it will be deleted.
+# This script should be runned from the directory where $FILES_FOLDER is
+# located.
+create_db () {
+        rm -f "$TMP/$DB_FILE"
+
+        echo "Generating the SQLite database file. It can take some time ..."
+        # Run the php script to generate the SQLite database file
+        # with cURL calls.
+        php "$FILES_FOLDER/$DB_INSTALL_SCRIPT" $(basename "$DB_FILE" .sqlite) \
+                "$WIKI_ADMIN" "$WIKI_PASSW" "$TMP"
+
+        if [ ! -f "$TMP/$DB_FILE" ] ; then
+                error "Can't create database file in TODO. Try to run ./install-wiki.sh delete first."
+        fi
+        chmod 666 "$TMP/$DB_FILE"
+
+        # Copy the generated database file into the directory the
+        # user indicated.
+        cp --preserve=mode,ownership "$TMP/$DB_FILE" "$FILES_FOLDER" ||
+                error "Unable to copy $TMP/$DB_FILE to $FILES_FOLDER"
+}
+
+# Install a wiki in your web server directory.
+wiki_install () {
+
+        # In this part, we change directory to $TMP in order to download,
+        # unpack and copy the files of MediaWiki
+        (
+        mkdir -p "$WIKI_DIR_INST/$WIKI_DIR_NAME"
+        if [ ! -d "$WIKI_DIR_INST/$WIKI_DIR_NAME" ] ; then
+                error "Folder $WIKI_DIR_INST/$WIKI_DIR_NAME doesn't exist.
+                Please create it and launch the script again."
+        fi
+
+        # Fetch MediaWiki's archive if not already present in the TMP directory
+        cd "$TMP"
+        if [ ! -f "$MW_VERSION.tar.gz" ] ; then
+                echo "Downloading $MW_VERSION sources ..."
+                wget "http://download.wikimedia.org/mediawiki/1.19/mediawiki-1.19.0.tar.gz" ||
+                        error "Unable to download "\
+                        "http://download.wikimedia.org/mediawiki/1.19/"\
+                        "mediawiki-1.19.0.tar.gz. "\
+                        "Please fix your connection and launch the script again."
+        fi
+        tar xfz "$MW_VERSION.tar.gz"
+        echo "$MW_VERSION.tar.gz downloaded in `pwd`."\
+                "You can delete it later if you want."
+
+        # Copy the files of MediaWiki wiki in the web server's directory.
+        cd "$MW_VERSION"
+        cp -Rf * "$WIKI_DIR_INST/$WIKI_DIR_NAME/" ||
+                error "Unable to copy WikiMedia's files from `pwd` to "\
+                        "$WIKI_DIR_INST/$WIKI_DIR_NAME"
+        )
+
+        create_db
+
+        # Copy the generic LocalSettings.php in the web server's directory
+        # And modify parameters according to the ones set at the top
+        # of this script.
+        # Note that LocalSettings.php is never modified.
+        if [ ! -f "$FILES_FOLDER/LocalSettings.php" ] ; then
+                error "Can't find $FILES_FOLDER/LocalSettings.php " \
+                        "in the current folder. "\
+                "Please run the script inside its folder."
+        fi
+        cp "$FILES_FOLDER/LocalSettings.php" \
+                "$FILES_FOLDER/LocalSettings-tmp.php" ||
+                error "Unable to copy $FILES_FOLDER/LocalSettings.php " \
+                "to $FILES_FOLDER/LocalSettings-tmp.php"
+
+        # Parse and set the LocalSettings file of the user according to the
+        # CONFIGURATION VARIABLES section at the beginning of this script
+        file_swap="$FILES_FOLDER/LocalSettings-swap.php"
+        sed "s,@WG_SCRIPT_PATH@,/$WIKI_DIR_NAME," \
+                "$FILES_FOLDER/LocalSettings-tmp.php" > "$file_swap"
+        mv "$file_swap" "$FILES_FOLDER/LocalSettings-tmp.php"
+        sed "s,@WG_SERVER@,http://$SERVER_ADDR," \
+                "$FILES_FOLDER/LocalSettings-tmp.php" > "$file_swap"
+        mv "$file_swap" "$FILES_FOLDER/LocalSettings-tmp.php"
+        sed "s,@WG_SQLITE_DATADIR@,$TMP," \
+                "$FILES_FOLDER/LocalSettings-tmp.php" > "$file_swap"
+        mv "$file_swap" "$FILES_FOLDER/LocalSettings-tmp.php"
+
+        mv "$FILES_FOLDER/LocalSettings-tmp.php" \
+                "$WIKI_DIR_INST/$WIKI_DIR_NAME/LocalSettings.php" ||
+                error "Unable to move $FILES_FOLDER/LocalSettings-tmp.php" \
+                "in $WIKI_DIR_INST/$WIKI_DIR_NAME"
+        echo "File $FILES_FOLDER/LocalSettings.php is set in" \
+                " $WIKI_DIR_INST/$WIKI_DIR_NAME"
+
+        chmod ugo+w "$FILES_FOLDER/$DB_FILE"
+
+        echo "Your wiki has been installed. You can check it at
+                http://$SERVER_ADDR/$WIKI_DIR_NAME"
+}
+
+# Reset the database of the wiki and the password of the admin
+#
+# Warning: This function must be called only in a subdirectory of t/ directory
+wiki_reset () {
+        # Copy initial database of the wiki
+        if [ ! -f "../$FILES_FOLDER/$DB_FILE" ] ; then
+                error "Can't find ../$FILES_FOLDER/$DB_FILE in the current folder."
+        fi
+        cp "../$FILES_FOLDER/$DB_FILE" "$TMP" ||
+                error "Can't copy ../$FILES_FOLDER/$DB_FILE in $TMP"
+        echo "File $FILES_FOLDER/$DB_FILE is set in $TMP"
+}
+
+# Delete the wiki created in the web server's directory and all its content
+# saved in the database.
+wiki_delete () {
+	# Delete the wiki's directory.
+	rm -rf "$WIKI_DIR_INST/$WIKI_DIR_NAME" ||
+		error "Wiki's directory $WIKI_DIR_INST/" \
+		"$WIKI_DIR_NAME could not be deleted"
+
+	# Delete the wiki's SQLite database
+	rm -f "$TMP/$DB_FILE" || error "Database $TMP/$DB_FILE could not be deleted."
+}
+
-- 
1.7.10.2.552.gaa3bb87

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv3 2/6] Test environment of git-remote-mediawiki
  2012-06-11 20:28 ` [PATCHv3 1/6] Scripts to install, delete and clear a MediaWiki Simon Cathebras
@ 2012-06-11 20:28   ` Simon Cathebras
  2012-06-11 20:28   ` [PATCHv3 3/6] Test file for git-remote-mediawiki clone Simon Cathebras
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 40+ messages in thread
From: Simon Cathebras @ 2012-06-11 20:28 UTC (permalink / raw)
  To: git
  Cc: simon.cathebras, Matthieu.Moy, Guillaume.Sasdy, Julien.Khayat,
	charles.roussel, gitster, peff, Simon.Perrat, Guillaume Sasdy,
	Simon Perrat, Julien Khayat, Matthieu Moy

From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>

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 file
git/contrib/mw-to-git/t/test-gitmw-lib.sh and
git/contrib/mw-to-git/t/test-gitmw.pl

In addition, this patch provide Makefiles to execute tests.
See README file for more details.

Signed-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>
Signed-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>
Signed-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>
Signed-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
Signed-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@imag.fr>
---
 contrib/mw-to-git/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

diff --git a/contrib/mw-to-git/Makefile b/contrib/mw-to-git/Makefile
new file mode 100644
index 0000000..7d55a51
--- /dev/null
+++ b/contrib/mw-to-git/Makefile
@@ -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
\ No newline at end of file
diff --git a/contrib/mw-to-git/t/Makefile b/contrib/mw-to-git/t/Makefile
new file mode 100644
index 0000000..9429907
--- /dev/null
+++ b/contrib/mw-to-git/t/Makefile
@@ -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'.*
\ No newline at end of file
diff --git a/contrib/mw-to-git/t/README b/contrib/mw-to-git/t/README
new file mode 100644
index 0000000..b68147b
--- /dev/null
+++ b/contrib/mw-to-git/t/README
@@ -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.
diff --git a/contrib/mw-to-git/t/test-gitmw-lib.sh b/contrib/mw-to-git/t/test-gitmw-lib.sh
index 80b4f4f..d073b46 100755
--- a/contrib/mw-to-git/t/test-gitmw-lib.sh
+++ b/contrib/mw-to-git/t/test-gitmw-lib.sh
@@ -26,6 +26,123 @@ DB_INSTALL_SCRIPT="db_install.php"
 WIKI_ADMIN="WikiAdmin"
 WIKI_PASSW="AdminPass"
 
+export CURR_DIR=$(pwd)
+export TEST_DIRECTORY=$CURR_DIR/../../../t
+
+wiki_getpage () {
+	$CURR_DIR/test-gitmw.pl get_page "$@"
+}
+
+wiki_delete_page () {
+	$CURR_DIR/test-gitmw.pl delete_page "$@"
+}
+
+wiki_editpage () {
+	$CURR_DIR/test-gitmw.pl edit_page "$@"
+}
+
+die () {
+	die_with_status 1 "$@"
+}
+
+die_with_status () {
+	status=$1
+	shift
+	echo >&2 "$*"
+	exit "$status"
+}
+
+# test_diff_directories <dir_git> <dir_wiki>
+#
+# Compare the contents of directories <dir_git> and <dir_wiki> with diff
+# and errors if they do not match. The program will
+# not look into .git in the process.
+# Warning: the first argument MUST be the directory containing the git data
+test_diff_directories () {
+	rm -rf "$1_tmp"
+	mkdir -p "$1_tmp"
+	cp "$1"/*.mw "$1_tmp"
+	diff -r -b "$1_tmp" "$2"
+}
+
+# $1=<dir>
+# $2=<N>
+#
+# Check that <dir> contains exactly <N> files
+test_contains_N_files () {
+	test `ls "$1" | wc -l` -eq "$2";
+}
+
+
+# wiki_check_content <file_name> <page_name> 
+#
+# Compares the contents of the file <file_name> and the wiki page
+# <page_name> and exits with error 1 if they do not match.
+wiki_check_content () {
+	mkdir -p wiki_tmp
+	wiki_getpage "$2" wiki_tmp
+        
+	#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
+	then
+		rm -rf wiki_tmp
+		error "ERROR: file $2 not found on wiki"
+	fi
+	rm -rf wiki_tmp
+}
+
+# wiki_page_exist <page_name>
+#
+# Check the existence of the page <page_name> on the wiki and exits
+# with error if it is absent from it.
+wiki_page_exist () {
+        mkdir -p wiki_tmp
+	wiki_getpage "$1" wiki_tmp
+
+	page_name=$(printf "%s\n" "$1" | sed "s/\//%2F/g")
+
+	if test -f wiki_tmp/"$page_name".mw ; then
+		rm -rf wiki_tmp
+	else
+	        rm -rf wiki_tmp
+		error "test failed: file $1 not found on wiki"
+	fi
+}
+
+# wiki_getallpagename
+# 
+# Fetch the name of each page on the wiki.
+wiki_getallpagename () {
+	$CURR_DIR/test-gitmw.pl getallpagename
+}
+
+# wiki_getallpagecategory <category>
+# 
+# Fetch the name of each page belonging to <category> on the wiki.
+wiki_getallpagecategory () {
+	$CURR_DIR/test-gitmw.pl getallpagename "$@"
+}
+
+# wiki_getallpage <dest_dir> [<category>]
+#
+# Fetch all the pages from the wiki and place them in the directory
+# <dest_dir>.
+# If <category> is define, then wiki_getallpage fetch the pages included
+# in <category>.
+wiki_getallpage () {
+	if test -z "$2";
+	then
+		wiki_getallpagename
+	else
+		wiki_getallpagecategory "$2"
+	fi
+	mkdir -p "$1"
+	while read -r line; do
+		wiki_getpage "$line" $1;
+	done < all.txt
 }
 
 # Create the SQLite database of the MediaWiki. If the database file already
diff --git a/contrib/mw-to-git/t/test-gitmw.pl b/contrib/mw-to-git/t/test-gitmw.pl
new file mode 100755
index 0000000..fd3c798
--- /dev/null
+++ b/contrib/mw-to-git/t/test-gitmw.pl
@@ -0,0 +1,213 @@
+#!/usr/bin/perl -w -s
+# Copyright (C) 2012
+#     Charles Roussel <charles.roussel@ensimag.imag.fr>
+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>
+#     Julien Khayat <julien.khayat@ensimag.imag.fr>
+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
+#     Simon Perrat <simon.perrat@ensimag.imag.fr>
+# License: GPL v2 or later
+
+# Usage:
+#       ./test-gitmw.pl <command> [argument]*
+# Execute in terminal using the name of the function to call as first
+# parameter, and the function's arguments as following parameters
+#
+# Example:
+#     ./test-gitmw.pl "get_page" foo .
+# will call <wiki_getpage> with arguments <foo> and <.>
+#
+# Available functions are:
+#     "get_page"
+#     "delete_page"
+#     "edit_page"
+#     "getallpagename"
+
+use MediaWiki::API;
+use Getopt::Long;
+use Switch;
+use encoding 'utf8';
+use DateTime::Format::ISO8601;
+use open ':encoding(utf8)';
+use constant SLASH_REPLACEMENT => "%2F";
+
+# URL of the wiki used for the tests
+my $wiki_url="http://localhost/wiki/api.php";
+my $wiki_admin='WikiAdmin';
+my $wiki_admin_pass='AdminPass';
+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;
+}
+
+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;
+}
+
+
+# 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;
+
+&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")}
+}
+
-- 
1.7.10.2.552.gaa3bb87

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv3 3/6] Test file for git-remote-mediawiki clone
  2012-06-11 20:28 ` [PATCHv3 1/6] Scripts to install, delete and clear a MediaWiki Simon Cathebras
  2012-06-11 20:28   ` [PATCHv3 2/6] Test environment of git-remote-mediawiki Simon Cathebras
@ 2012-06-11 20:28   ` Simon Cathebras
  2012-06-11 21:07     ` konglu
  2012-06-11 20:28   ` [PATCHv3 4/6] Tests for git-remote-mediawiki pull Simon Cathebras
                     ` (2 subsequent siblings)
  4 siblings, 1 reply; 40+ messages in thread
From: Simon Cathebras @ 2012-06-11 20:28 UTC (permalink / raw)
  To: git
  Cc: simon.cathebras, Matthieu.Moy, Guillaume.Sasdy, Julien.Khayat,
	charles.roussel, gitster, peff, Simon.Perrat, Guillaume Sasdy,
	Simon Perrat, Julien Khayat, Matthieu Moy

From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>

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

Signed-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>
Signed-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>
Signed-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>
Signed-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
Signed-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@imag.fr>
---
 contrib/mw-to-git/t/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

diff --git a/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh b/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh
new file mode 100755
index 0000000..2b3df3f
--- /dev/null
+++ b/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh
@@ -0,0 +1,324 @@
+#!/bin/sh
+#
+# Copyright (C) 2012
+#     Charles Roussel <charles.roussel@ensimag.imag.fr>
+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>
+#     Julien Khayat <julien.khayat@ensimag.imag.fr>
+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
+#     Simon Perrat <simon.perrat@ensimag.imag.fr>
+#
+# License: GPL v2 or later
+
+
+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
-- 
1.7.10.2.552.gaa3bb87

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv3 4/6] Tests for git-remote-mediawiki pull
  2012-06-11 20:28 ` [PATCHv3 1/6] Scripts to install, delete and clear a MediaWiki Simon Cathebras
  2012-06-11 20:28   ` [PATCHv3 2/6] Test environment of git-remote-mediawiki Simon Cathebras
  2012-06-11 20:28   ` [PATCHv3 3/6] Test file for git-remote-mediawiki clone Simon Cathebras
@ 2012-06-11 20:28   ` Simon Cathebras
  2012-06-11 21:09     ` konglu
  2012-06-11 20:28   ` [PATCHv3 5/6] Test file for git-remote-mediawiki push Simon Cathebras
  2012-06-11 20:28   ` =?y?q?=5BPATCHv3=206/6=5D=20Tests=20of=20UTF8=20character=20with=20git-remote-mediawiki?= Simon Cathebras
  4 siblings, 1 reply; 40+ messages in thread
From: Simon Cathebras @ 2012-06-11 20:28 UTC (permalink / raw)
  To: git
  Cc: simon.cathebras, Matthieu.Moy, Guillaume.Sasdy, Julien.Khayat,
	charles.roussel, gitster, peff, Simon.Perrat, Guillaume Sasdy,
	Simon Perrat, Julien Khayat, Matthieu Moy

From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>

This patch provides a set of tests for the pull fonctionnality of
git-remote-mediawiki.

These tests are part of the file
git/contrib/mw-to-git/t/t9361-mw-to-git-pull.sh

Signed-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>
Signed-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>
Signed-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>
Signed-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
Signed-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@imag.fr>
---
 contrib/mw-to-git/t/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

diff --git a/contrib/mw-to-git/t/t9361-mw-to-git-pull.sh b/contrib/mw-to-git/t/t9361-mw-to-git-pull.sh
new file mode 100755
index 0000000..5f26cf5
--- /dev/null
+++ b/contrib/mw-to-git/t/t9361-mw-to-git-pull.sh
@@ -0,0 +1,149 @@
+#!/bin/sh
+#
+# Copyright (C) 2012
+#     Charles Roussel <charles.roussel@ensimag.imag.fr>
+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>
+#     Julien Khayat <julien.khayat@ensimag.imag.fr>
+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
+#     Simon Perrat <simon.perrat@ensimag.imag.fr>
+#
+# License: GPL v2 or later
+
+# tests for git-remote-mediawiki
+
+test_description='Test 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
+
-- 
1.7.10.2.552.gaa3bb87

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv3 5/6] Test file for git-remote-mediawiki push
  2012-06-11 20:28 ` [PATCHv3 1/6] Scripts to install, delete and clear a MediaWiki Simon Cathebras
                     ` (2 preceding siblings ...)
  2012-06-11 20:28   ` [PATCHv3 4/6] Tests for git-remote-mediawiki pull Simon Cathebras
@ 2012-06-11 20:28   ` Simon Cathebras
  2012-06-11 20:28   ` =?y?q?=5BPATCHv3=206/6=5D=20Tests=20of=20UTF8=20character=20with=20git-remote-mediawiki?= Simon Cathebras
  4 siblings, 0 replies; 40+ messages in thread
From: Simon Cathebras @ 2012-06-11 20:28 UTC (permalink / raw)
  To: git
  Cc: simon.cathebras, Matthieu.Moy, Guillaume.Sasdy, Julien.Khayat,
	charles.roussel, gitster, peff, Simon.Perrat, Guillaume Sasdy,
	Simon Perrat, Julien Khayat, Matthieu Moy

From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>

This patch provides a set of tests for the push function of
git-remote-mediawiki.

These tests are part of the file
git/contrib/mw-to-git/t/t9361-mw-to-git-push.sh.

Signed-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>
Signed-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>
Signed-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>
Signed-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
Signed-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@imag.fr>
---
 contrib/mw-to-git/t/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

diff --git a/contrib/mw-to-git/t/t9361-mw-to-git-push.sh b/contrib/mw-to-git/t/t9361-mw-to-git-push.sh
new file mode 100755
index 0000000..447a337
--- /dev/null
+++ b/contrib/mw-to-git/t/t9361-mw-to-git-push.sh
@@ -0,0 +1,110 @@
+#!/bin/sh
+#
+# Copyright (C) 2012
+#     Charles Roussel <charles.roussel@ensimag.imag.fr>
+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>
+#     Julien Khayat <julien.khayat@ensimag.imag.fr>
+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
+#     Simon Perrat <simon.perrat@ensimag.imag.fr>
+#
+# License: GPL v2 or later
+
+# tests for git-remote-mediawiki
+
+test_description='Test 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
+
-- 
1.7.10.2.552.gaa3bb87

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* =?y?q?=5BPATCHv3=206/6=5D=20Tests=20of=20UTF8=20character=20with=20git-remote-mediawiki?=
  2012-06-11 20:28 ` [PATCHv3 1/6] Scripts to install, delete and clear a MediaWiki Simon Cathebras
                     ` (3 preceding siblings ...)
  2012-06-11 20:28   ` [PATCHv3 5/6] Test file for git-remote-mediawiki push Simon Cathebras
@ 2012-06-11 20:28   ` Simon Cathebras
  4 siblings, 0 replies; 40+ messages in thread
From: Simon Cathebras @ 2012-06-11 20:28 UTC (permalink / raw)
  To: git
  Cc: simon.cathebras, Matthieu.Moy, Guillaume.Sasdy, Julien.Khayat,
	charles.roussel, gitster, peff, Simon.Perrat, Guillaume Sasdy,
	Simon Perrat, Julien Khayat, Matthieu Moy

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=y, Size: 11870 bytes --]

From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>

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

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

Signed-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>
Signed-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>
Signed-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>
Signed-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
Signed-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@imag.fr>
---
 contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh | 377 ++++++++++++++++++++++++++++
 1 file changed, 377 insertions(+)
 create mode 100755 contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh

diff --git a/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh b/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh
new file mode 100755
index 0000000..57431da
--- /dev/null
+++ b/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh
@@ -0,0 +1,377 @@
+#!/bin/sh
+#
+# Copyright (C) 2012
+#     Charles Roussel <charles.roussel@ensimag.imag.fr>
+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>
+#     Julien Khayat <julien.khayat@ensimag.imag.fr>
+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
+#     Simon Perrat <simon.perrat@ensimag.imag.fr>
+#
+# License: GPL v2 or later
+
+# tests for git-remote-mediawiki
+
+test_description='Test git-mediawiki with special characters in filenames'
+
+. ./test-gitmw-lib.sh
+. $TEST_DIRECTORY/test-lib.sh
+
+TRASH_DIR="$CURR_DIR/trash\ directory.$(basename $0 .sh)"
+
+if ! test_have_prereq PERL
+then
+	skip_all='skipping gateway git-mw tests, '\
+		'perl not available'
+	test_done
+fi
+
+if [ ! -f $GIT_BUILD_DIR/git-remote-mediawiki ];
+then
+	skip_all='skipping gateway git-mw tests,' \
+		' no remote mediawiki for git found'
+	test_done
+fi
+
+if [ ! -d "$WIKI_DIR_INST/$WIKI_DIR_NAME" ] ;
+then
+	skip_all='skipping gateway git-mw tests, no mediawiki found'
+	test_done
+fi
+
+
+# 1
+test_expect_success 'Git clone works for a wiki with accents in the page names' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	rm -rf ref_page &&
+	wiki_editpage féé "This page must be délétéd before clone" false &&
+	wiki_editpage kèè "This page must be deleted before clone" false &&
+	wiki_editpage hàà "This page must be deleted before clone" false &&
+	wiki_editpage kîî "This page must be deleted before clone" false &&
+	wiki_editpage foo "This page must be deleted before clone" false &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	wiki_getallpage ref_page &&
+	test_diff_directories mw_dir ref_page
+'
+
+# 2
+test_expect_success 'Git pull works with a wiki with accents in the pages names' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	rm -rf ref_page &&
+	wiki_editpage kîî "this page must be cloned" false &&
+	wiki_editpage foo "this page must be cloned" false &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	wiki_editpage éàîôû "This page must be pulled" false &&
+	cd mw_dir &&
+	git pull &&
+	cd .. && 
+	wiki_getallpage ref_page &&
+	test_diff_directories mw_dir ref_page &&
+	rm -rf mw_dir &&
+	rm -rf ref_page
+'
+
+# 3
+test_expect_success 'Cloning a chosen page works with accents' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	rm -rf ref_page &&
+	wiki_editpage kîî "this page must be cloned" false &&
+	git clone -c remote.origin.pages=kîî mediawiki::http://localhost/wiki mw_dir &&
+	wiki_check_content mw_dir/Kîî.mw Kîî &&
+	test -e mw_dir/Kîî.mw &&
+	rm -rf mw_dir
+'
+
+# 4
+test_expect_success 'The shallow option works with accents' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	rm -rf ref_page &&
+	wiki_editpage néoà "1st revision, should not be cloned" false &&
+	wiki_editpage néoà "2nd revision, should be cloned" false &&
+	git -c remote.origin.shallow=true clone mediawiki::http://localhost/wiki/ mw_dir &&
+	test_contains_N_files mw_dir 2 &&
+	test -e mw_dir/Néoà.mw &&
+	test -e mw_dir/Main_Page.mw &&
+	cd mw_dir &&
+	test `git log --oneline Néoà.mw | wc -l` -eq 1 &&
+	test `git log --oneline Main_Page.mw | wc -l ` -eq 1 &&
+	cd .. &&
+	wiki_check_content mw_dir/Néoà.mw Néoà &&
+	wiki_check_content mw_dir/Main_Page.mw Main_Page &&
+	rm -rf mw_dir
+'
+
+# 5
+test_expect_success 'Cloning works when page name first letter has an accent' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	rm -rf ref_page &&
+	wiki_editpage îî "this page must be cloned" false &&
+	git clone -c remote.origin.pages=îî mediawiki::http://localhost/wiki mw_dir &&
+	test -e mw_dir/Îî.mw &&
+	wiki_check_content mw_dir/Îî.mw Îî &&
+	rm -rf mw_dir
+'
+
+# 6
+test_expect_success 'Git push works with a wiki with accents' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	rm -rf ref_page &&
+	wiki_editpage féé "lots of accents : éèàÖ" false &&
+	wiki_editpage foo "this page must be cloned" false &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	cd mw_dir &&
+	echo "A wild Pîkächû appears on the wiki" > Pîkächû.mw &&
+	git add Pîkächû.mw &&
+	git commit -m "A new page appears" &&
+	git push &&
+	cd .. &&
+	wiki_getallpage ref_page &&
+	test_diff_directories mw_dir ref_page &&
+	rm -rf mw_dir &&
+	rm -rf ref_page
+'
+
+# 7
+test_expect_success 'Git clone works with accentsand spaces' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	rm -rf ref_page &&
+	wiki_editpage "é à î" "this page must be délété before the clone" false &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	wiki_getallpage ref_page &&
+	test_diff_directories mw_dir ref_page &&
+	rm -rf mw_dir &&
+	rm -rf ref_page
+'
+# 8
+test_expect_success 'character $ in page name (mw -> git)' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	rm -rf ref_page &&
+	wiki_editpage file_\$_foo "expect to be called file_$_foo" false &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	test -f mw_dir/File_\$_foo.mw &&
+	wiki_getallpage ref_page &&
+	test_diff_directories mw_dir ref_page
+'
+
+
+# 9
+test_expect_success 'character $ in file name (git -> mw) ' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	rm -rf ref_page &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	cd mw_dir &&
+	echo "this file is called File_\$_foo.mw" > File_\$_foo.mw &&
+	git add . &&
+	git commit -am "file File_\$_foo.mw" &&
+	git pull &&
+	git push &&
+	cd .. &&
+	wiki_getallpage ref_page &&
+	test_diff_directories mw_dir ref_page
+'
+
+# 10
+test_expect_failure 'capital at the begining of file names' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	rm -rf ref_page &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	cd mw_dir &&
+	echo "my new file foo" > foo.mw &&
+	echo "my new file Foo... Finger crossed" > Foo.mw &&
+	git add . &&
+	git commit -am "file foo.mw" &&
+	git pull &&
+	git push &&
+	cd .. &&
+	wiki_getallpage ref_page &&
+	test_diff_directories mw_dir ref_page
+'
+
+
+# 11
+test_expect_failure 'special character at the begining of file name from mw to git' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	rm -rf ref_page &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	wiki_editpage {char_1 "expect to be renamed {char_1" false &&
+	wiki_editpage [char_2 "expect to be renamed [char_2" false &&
+	cd mw_dir &&
+	git pull &&
+	cd .. &&
+	test -f mw_dir/{char_1 &&
+	test -f mw_dir/[char_2
+'
+
+# 12
+test_expect_success 'test of correct formating for file name from mw to git' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	rm -rf ref_page &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	wiki_editpage char{_1 "expect to be renamed char{_1" false &&
+	wiki_editpage char[_2 "expect to be renamed char{_2" false &&
+	cd mw_dir &&
+	git pull &&
+	cd .. &&
+	test -f mw_dir/Char\{_1.mw &&
+	test -f mw_dir/Char\[_2.mw &&
+	wiki_getallpage ref_page &&
+	test_diff_directories mw_dir ref_page
+'
+
+# 13
+test_expect_failure 'test of correct formating for file name begining with special character' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	rm -rf ref_page &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	cd mw_dir &&
+	echo "my new file {char_1" > \{char_1.mw &&
+	echo "my new file [char_2" > \[char_2.mw &&
+	git add . &&
+	git commit -am "commiting some exotic file name..." &&
+	git push &&
+	git pull &&
+	cd .. &&
+	wiki_getallpage ref_page &&
+	test -f ref_page/{char_1.mw &&
+	test -f ref_page/[char_2.mw &&
+	test_diff_directories mw_dir ref_page
+'
+
+# 14
+
+test_expect_success 'test of correct formating for file name from git to mw' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	rm -rf ref_page &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	cd mw_dir &&
+	echo "my new file char{_1" > Char\{_1.mw &&
+	echo "my new file char[_2" > Char\[_2.mw &&
+	git add . &&
+	git commit -m "commiting some exotic file name..." &&
+	git push &&
+	cd .. &&
+	wiki_getallpage ref_page &&
+	test_diff_directories mw_dir ref_page
+'
+
+
+# 15
+test_expect_success 'git clone with /' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	wiki_editpage \/fo\/o "this is not important" false -c=Deleted &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	test -f mw_dir/%2Ffo%2Fo.mw &&
+	wiki_check_content mw_dir/%2Ffo%2Fo.mw \/fo\/o &&
+	rm -rf mw_dir
+'
+
+# 16
+test_expect_success 'git push with /' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	echo "I will be on the wiki" > mw_dir/%2Ffo%2Fo.mw &&
+	cd mw_dir &&
+	git add %2Ffo%2Fo.mw &&
+	git commit -m " %2Ffo%2Fo added" &&
+	git push &&
+	cd .. &&
+	wiki_page_exist \/fo\/o &&
+	wiki_check_content mw_dir/%2Ffo%2Fo.mw \/fo\/o &&
+	rm -rf mw_dir 
+
+'
+
+# 17
+test_expect_success 'git clone with \' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	wiki_editpage \\ko\\o "this is not important" false -c=Deleted &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	test -f mw_dir/\\ko\\o.mw &&
+	wiki_check_content mw_dir/\\ko\\o.mw \\ko\\o &&
+	rm -rf mw_dir
+'
+
+# 18
+test_expect_success 'git push with \' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	echo "I will be on the wiki" > mw_dir/\\ko\\o.mw &&
+	cd mw_dir &&
+	git add \\ko\\o.mw &&
+	git commit -m " \\ko\\o added" &&
+	git push &&
+	cd .. &&
+	wiki_page_exist \\ko\\o &&
+	wiki_check_content mw_dir/\\ko\\o.mw \\ko\\o &&
+	rm -rf mw_dir
+
+'
+
+# 19
+test_expect_success 'git clone with \ in format control' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	wiki_editpage \\no\\o "this is not important" false &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	test -f mw_dir/\\no\\o.mw &&
+	wiki_check_content mw_dir/\\no\\o.mw \\no\\o  
+	
+'
+
+
+# 20
+test_expect_success 'git push with \ in format contraol' '
+	wiki_reset &&
+	cd '"$TRASH_DIR"' &&
+	rm -rf mw_dir &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	echo "I will be on the wiki" > mw_dir/\\fo\\o.mw &&
+	cd mw_dir &&
+	git add \\fo\\o.mw &&
+	git commit -m " \\fo\\o added" &&
+	git push &&
+	cd .. &&
+	wiki_page_exist \\fo\\o &&
+	wiki_check_content mw_dir/\\fo\\o.mw \\fo\\o && 
+	rm -rf mw_dir
+
+'
+
+
+ test_done
-- 
1.7.10.2.552.gaa3bb87

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [PATCHv3 3/6] Test file for git-remote-mediawiki clone
  2012-06-11 20:28   ` [PATCHv3 3/6] Test file for git-remote-mediawiki clone Simon Cathebras
@ 2012-06-11 21:07     ` konglu
  2012-06-12 13:58       ` Simon.Cathebras
  0 siblings, 1 reply; 40+ messages in thread
From: konglu @ 2012-06-11 21:07 UTC (permalink / raw)
  To: Simon Cathebras
  Cc: git, Matthieu Moy, Guillaume Sasdy, Julien Khayat,
	charles.roussel, gitster, peff, Simon Perrat


Simon Cathebras <simon.cathebras@ensimag.imag.fr> a écrit :


> +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
> +'
> +

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).

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCHv3 4/6] Tests for git-remote-mediawiki pull
  2012-06-11 20:28   ` [PATCHv3 4/6] Tests for git-remote-mediawiki pull Simon Cathebras
@ 2012-06-11 21:09     ` konglu
  2012-06-12 13:58       ` Simon Perrat
  2012-06-12 21:12       ` [PATCH 1/6] Scripts to install, delete and clear a MediaWiki Simon Cathebras
  0 siblings, 2 replies; 40+ messages in thread
From: konglu @ 2012-06-11 21:09 UTC (permalink / raw)
  To: Simon Cathebras
  Cc: git, Matthieu Moy, Guillaume Sasdy, Julien Khayat,
	charles.roussel, gitster, peff, Simon Perrat


Simon Cathebras <simon.cathebras@ensimag.imag.fr> a écrit :

> +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
> +"

Why are there dquotes here (and all the following tests) ? You used
simple quote in t9360.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCHv3 3/6] Test file for git-remote-mediawiki clone
  2012-06-11 21:07     ` konglu
@ 2012-06-12 13:58       ` Simon.Cathebras
  0 siblings, 0 replies; 40+ messages in thread
From: Simon.Cathebras @ 2012-06-12 13:58 UTC (permalink / raw)
  To: konglu
  Cc: git, Matthieu Moy, Guillaume Sasdy, Julien Khayat,
	charles.roussel, gitster, peff, Simon Perrat



On 11/06/2012 23:07, konglu@minatec.inpg.fr wrote:
>
> Simon Cathebras <simon.cathebras@ensimag.imag.fr> a écrit :
>
>
>> +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
>> +'
>> +
>
> 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.

>
> 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


-- 
CATHEBRAS Simon

2A-ENSIMAG

Filière Ingéniérie des Systèmes d'Information
Membre Bug-Buster

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCHv3 4/6] Tests for git-remote-mediawiki pull
  2012-06-11 21:09     ` konglu
@ 2012-06-12 13:58       ` Simon Perrat
  2012-06-12 21:12       ` [PATCH 1/6] Scripts to install, delete and clear a MediaWiki Simon Cathebras
  1 sibling, 0 replies; 40+ messages in thread
From: Simon Perrat @ 2012-06-12 13:58 UTC (permalink / raw)
  To: konglu
  Cc: Simon Cathebras, git, Matthieu Moy, Guillaume Sasdy,
	Julien Khayat, charles.roussel, gitster, peff

2012/6/11  <konglu@minatec.inpg.fr>:
>
> Simon Cathebras <simon.cathebras@ensimag.imag.fr> a écrit :
>
>
>> +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
>> +"
>
>
> Why are there dquotes here (and all the following tests) ? You used
> simple quote in t9360.
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> 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.

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH 1/6] Scripts to install, delete and clear a MediaWiki
  2012-06-11 21:09     ` konglu
  2012-06-12 13:58       ` Simon Perrat
@ 2012-06-12 21:12       ` Simon Cathebras
  2012-06-12 21:12         ` [PATCH 2/6] Test environment of git-remote-mediawiki Simon Cathebras
                           ` (3 more replies)
  1 sibling, 4 replies; 40+ messages in thread
From: Simon Cathebras @ 2012-06-12 21:12 UTC (permalink / raw)
  To: git
  Cc: gitster, peff, Guillaume Sasdy, Simon Cathebras, Simon Perrat,
	Charles Roussel, Julien Khayat, Matthieu Moy

From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>

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/

Signed-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>
Signed-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>
Signed-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
Signed-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>
Signed-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@imag.fr>

---
 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

diff --git a/contrib/mw-to-git/t/install-wiki.sh b/contrib/mw-to-git/t/install-wiki.sh
new file mode 100755
index 0000000..17a1fc8
--- /dev/null
+++ b/contrib/mw-to-git/t/install-wiki.sh
@@ -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
diff --git a/contrib/mw-to-git/t/install-wiki/LocalSettings.php b/contrib/mw-to-git/t/install-wiki/LocalSettings.php
new file mode 100644
index 0000000..78d505c
--- /dev/null
+++ b/contrib/mw-to-git/t/install-wiki/LocalSettings.php
@@ -0,0 +1,128 @@
+<?php
+# This file was automatically generated by the MediaWiki 1.19.0
+# installer. If you make manual changes, please keep track in case you
+# need to recreate them later.
+#
+# See includes/DefaultSettings.php for all configurable settings
+# and their default values, but don't forget to make changes in _this_
+# file, not there.
+#
+# Further documentation for configuration settings may be found at:
+# http://www.mediawiki.org/wiki/Manual:Configuration_settings
+
+# Protect against web entry
+if ( !defined( 'MEDIAWIKI' ) ) {
+	exit;
+}
+
+## Uncomment this to disable output compression
+# $wgDisableOutputCompression = true;
+
+$wgSitename      = "Git-MediaWiki-Test";
+$wgMetaNamespace = "Git-MediaWiki-Test";
+
+## The URL base path to the directory containing the wiki;
+## defaults for all runtime URL paths are based off of this.
+## For more information on customizing the URLs please see:
+## http://www.mediawiki.org/wiki/Manual:Short_URL
+$wgScriptPath       = "@WG_SCRIPT_PATH@";
+$wgScriptExtension  = ".php";
+
+## The protocol and server name to use in fully-qualified URLs
+$wgServer           = "@WG_SERVER@";
+
+## The relative URL path to the skins directory
+$wgStylePath        = "$wgScriptPath/skins";
+
+## The relative URL path to the logo.  Make sure you change this from the default,
+## or else you'll overwrite your logo when you upgrade!
+$wgLogo             = "$wgStylePath/common/images/wiki.png";
+
+## UPO means: this is also a user preference option
+
+$wgEnableEmail      = true;
+$wgEnableUserEmail  = true; # UPO
+
+$wgEmergencyContact = "apache@localhost";
+$wgPasswordSender   = "apache@localhost";
+
+$wgEnotifUserTalk      = false; # UPO
+$wgEnotifWatchlist     = false; # UPO
+$wgEmailAuthentication = true;
+
+## Database settings
+$wgDBtype           = "sqlite";
+$wgDBserver         = "";
+$wgDBname           = "wikidb";
+$wgDBuser           = "";
+$wgDBpassword       = "";
+
+# SQLite-specific settings
+$wgSQLiteDataDir    = "@WG_SQLITE_DATADIR@";
+
+
+## Shared memory settings
+$wgMainCacheType    = CACHE_NONE;
+$wgMemCachedServers = array();
+
+## To enable image uploads, make sure the 'images' directory
+## is writable, then set this to true:
+$wgEnableUploads  = false;
+$wgUseImageMagick = true;
+$wgImageMagickConvertCommand ="@CONVERT@";
+
+# InstantCommons allows wiki to use images from http://commons.wikimedia.org
+$wgUseInstantCommons  = false;
+
+## If you use ImageMagick (or any other shell command) on a
+## Linux server, this will need to be set to the name of an
+## available UTF-8 locale
+$wgShellLocale = "en_US.utf8";
+
+## If you want to use image uploads under safe mode,
+## create the directories images/archive, images/thumb and
+## images/temp, and make them all writable. Then uncomment
+## this, if it's not already uncommented:
+#$wgHashedUploadDirectory = false;
+
+## Set $wgCacheDirectory to a writable directory on the web server
+## to make your wiki go slightly faster. The directory should not
+## be publically accessible from the web.
+#$wgCacheDirectory = "$IP/cache";
+
+# Site language code, should be one of the list in ./languages/Names.php
+$wgLanguageCode = "en";
+
+$wgSecretKey = "1c912bfe3519fb70f5dc523ecc698111cd43d81a11c585b3eefb28f29c2699b7";
+#$wgSecretKey = "@SECRETKEY@";
+
+
+# Site upgrade key. Must be set to a string (default provided) to turn on the
+# web installer while LocalSettings.php is in place
+$wgUpgradeKey = "ddae7dc87cd0a645";
+
+## Default skin: you can change the default skin. Use the internal symbolic
+## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook', 'vector':
+$wgDefaultSkin = "vector";
+
+## For attaching licensing metadata to pages, and displaying an
+## appropriate copyright notice / icon. GNU Free Documentation
+## License and Creative Commons licenses are supported so far.
+$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright
+$wgRightsUrl  = "";
+$wgRightsText = "";
+$wgRightsIcon = "";
+
+# Path to the GNU diff3 utility. Used for conflict resolution.
+$wgDiff3 = "/usr/bin/diff3";
+
+# Query string length limit for ResourceLoader. You should only set this if
+# your web server has a query string length limit (then set it to that limit),
+# or if you have suhosin.get.max_value_length set in php.ini (then set it to
+# that value)
+$wgResourceLoaderMaxQueryLength = -1;
+
+
+
+# End of automatically generated settings.
+# Add more configuration options below.
diff --git a/contrib/mw-to-git/t/install-wiki/db_install.php b/contrib/mw-to-git/t/install-wiki/db_install.php
new file mode 100644
index 0000000..3111c73
--- /dev/null
+++ b/contrib/mw-to-git/t/install-wiki/db_install.php
@@ -0,0 +1,110 @@
+<?php
+/**
+ * This script generates a SQLite database for a MediaWiki version 1.19.0
+ * You must specify the login of the admin (argument 1) and its
+ * password (argument 2) and the folder where the database file
+ * is located (absolute path in argument 3).
+ * It is used by the script install-wiki.sh in order to make easy the
+ * installation of a MediaWiki.
+ *
+ * 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'];
+
+$login = $argv[2];
+$pass = $argv[3];
+$tmp = $argv[4];
+$port = $argv[5];
+
+$url = 'http://localhost:'.$port.'/wiki/mw-config/index.php';
+$db_dir = urlencode($tmp);
+$tmp_cookie = tempnam($tmp,"COOKIE_");
+/*
+ * Fetchs a page with cURL.
+ */
+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);
+        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;
+}
+
+/*
+ * Submits a form with cURL.
+ */
+function submit($page_name, $option = "") {
+        $curl = curl_init();
+        $datapost = 'submit-continue=Continue+%E2%86%92';
+        if ($option != "") {
+                $datapost = $option.'&'.$datapost;
+        }
+	$url = $GLOBALS['url'].'?page='.$page_name;
+        $tmp_cookie = $GLOBALS['tmp_cookie'];
+        curl_setopt($curl, CURLOPT_URL, $url);
+        curl_setopt($curl, CURLOPT_POST, true);
+        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
+        curl_setopt($curl, CURLOPT_POSTFIELDS, $datapost);
+        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
+        curl_setopt($curl, CURLOPT_COOKIEJAR, $tmp_cookie);
+        curl_setopt($curl, CURLOPT_COOKIEFILE, $tmp_cookie);
+
+        $page = curl_exec($curl);
+        curl_close($curl);
+        return "$page";
+}
+
+/*
+ * Here starts this script: simulates the behavior of the user
+ * 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();
+preg_match('/input type="hidden" value="([0-9]+)" name="LanguageRequestTime"/',
+        $page, $matches);
+$timestamp = $matches[1];
+$language = "LanguageRequestTime=$timestamp&uselang=en&ContLang=en";
+$page = submit('Language', $language);
+
+submit('Welcome');
+
+$db_config = 'DBType=sqlite';
+$db_config = $db_config.'&sqlite_wgSQLiteDataDir='.$db_dir;
+$db_config = $db_config.'&sqlite_wgDBname='.$argv[1];
+submit('DBConnect', $db_config);
+
+$wiki_config = 'config_wgSitename=TEST';
+$wiki_config = $wiki_config.'&config__NamespaceType=site-name';
+$wiki_config = $wiki_config.'&config_wgMetaNamespace=MyWiki';
+$wiki_config = $wiki_config.'&config__AdminName='.$login;
+
+$wiki_config = $wiki_config.'&config__AdminPassword='.$pass;
+$wiki_config = $wiki_config.'&config__AdminPassword2='.$pass;
+
+$wiki_config = $wiki_config.'&wiki__configEmail=email%40email.org';
+$wiki_config = $wiki_config.'&config__SkipOptional=skip';
+submit('Name', $wiki_config);
+submit('Install');
+submit('Install');
+
+unlink($tmp_cookie);
+?>
diff --git a/contrib/mw-to-git/t/test-gitmw-lib.sh b/contrib/mw-to-git/t/test-gitmw-lib.sh
new file mode 100755
index 0000000..160f97b
--- /dev/null
+++ b/contrib/mw-to-git/t/test-gitmw-lib.sh
@@ -0,0 +1,285 @@
+# Copyright (C) 2012
+#     Charles Roussel <charles.roussel@ensimag.imag.fr>
+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>
+#     Julien Khayat <julien.khayat@ensimag.imag.fr>
+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
+#     Simon Perrat <simon.perrat@ensimag.imag.fr>
+# License: GPL v2 or later
+
+#
+# CONFIGURATION VARIABLES
+# You might want to change these ones
+#
+
+. ./test.config
+
+export CURR_DIR=$(pwd)
+export TEST_DIRECTORY=$CURR_DIR/../../../t
+
+if test $LIGHTTPD = "false" ; then
+	PORT=80
+else
+	WIKI_DIR_INST="$CURR_DIR/$WEB_WWW"
+fi
+
+# ================= Install part =================
+
+error () {
+	echo "$@" >&2
+	exit 1
+}
+
+# config_lighttpd
+#
+# Create the configuration files and the folders necessary to start lighttpd.
+# Overwrite any existing file.
+config_lighttpd() {
+	mkdir -p $WEB
+	mkdir -p $WEB_TMP
+	mkdir -p $WEB_WWW
+	cat > $WEB/lighttpd.conf <<EOF
+	server.document-root = "$CURR_DIR/$WEB_WWW"
+	server.port = $PORT
+	server.pid-file = "$CURR_DIR/$WEB_TMP/pid"
+
+	server.modules = (
+	"mod_rewrite",
+	"mod_redirect",
+	"mod_access",
+	"mod_accesslog",
+	"mod_fastcgi"
+	)
+
+	index-file.names = ("index.php" , "index.html")
+
+	mimetype.assign		    = (
+	".pdf"		=>	"application/pdf",
+	".sig"		=>	"application/pgp-signature",
+	".spl"		=>	"application/futuresplash",
+	".class"	=>	"application/octet-stream",
+	".ps"		=>	"application/postscript",
+	".torrent"	=>	"application/x-bittorrent",
+	".dvi"		=>	"application/x-dvi",
+	".gz"		=>	"application/x-gzip",
+	".pac"		=>	"application/x-ns-proxy-autoconfig",
+	".swf"		=>	"application/x-shockwave-flash",
+	".tar.gz"	=>	"application/x-tgz",
+	".tgz"		=>	"application/x-tgz",
+	".tar"		=>	"application/x-tar",
+	".zip"		=>	"application/zip",
+	".mp3"		=>	"audio/mpeg",
+	".m3u"		=>	"audio/x-mpegurl",
+	".wma"		=>	"audio/x-ms-wma",
+	".wax"		=>	"audio/x-ms-wax",
+	".ogg"		=>	"application/ogg",
+	".wav"		=>	"audio/x-wav",
+	".gif"		=>	"image/gif",
+	".jpg"		=>	"image/jpeg",
+	".jpeg"		=>	"image/jpeg",
+	".png"		=>	"image/png",
+	".xbm"		=>	"image/x-xbitmap",
+	".xpm"		=>	"image/x-xpixmap",
+	".xwd"		=>	"image/x-xwindowdump",
+	".css"		=>	"text/css",
+	".html"		=>	"text/html",
+	".htm"		=>	"text/html",
+	".js"		=>	"text/javascript",
+	".asc"		=>	"text/plain",
+	".c"		=>	"text/plain",
+	".cpp"		=>	"text/plain",
+	".log"		=>	"text/plain",
+	".conf"		=>	"text/plain",
+	".text"		=>	"text/plain",
+	".txt"		=>	"text/plain",
+	".dtd"		=>	"text/xml",
+	".xml"		=>	"text/xml",
+	".mpeg"		=>	"video/mpeg",
+	".mpg"		=>	"video/mpeg",
+	".mov"		=>	"video/quicktime",
+	".qt"		=>	"video/quicktime",
+	".avi"		=>	"video/x-msvideo",
+	".asf"		=>	"video/x-ms-asf",
+	".asx"		=>	"video/x-ms-asf",
+	".wmv"		=>	"video/x-ms-wmv",
+	".bz2"		=>	"application/x-bzip",
+	".tbz"		=>	"application/x-bzip-compressed-tar",
+	".tar.bz2"	=>	"application/x-bzip-compressed-tar",
+	""		=>	"text/plain"
+	)
+
+	fastcgi.server = ( ".php" =>
+	("localhost" =>
+	( "socket" => "$CURR_DIR/$WEB_TMP/php.socket",
+	"bin-path" => "$PHP_DIR/php-cgi -c $CURR_DIR/$WEB/php.ini"
+
+	)
+	)
+	)
+EOF
+
+	cat > $WEB/php.ini <<EOF
+	session.save_path ='$CURR_DIR/$WEB_TMP'
+EOF
+}
+
+# start_lighttpd
+#
+# Start or restart daemon lighttpd. If restart, rewrite configuration files.
+start_lighttpd() {
+	if test -f "$WEB_TMP/pid"; then
+		echo "Instance already running. Restarting..."
+		stop_lighttpd
+	fi
+	config_lighttpd
+	$LIGHTTPD_DIR/lighttpd -f $WEB/lighttpd.conf
+
+	if test $? -ne 0 ; then
+		echo "Could not execute http deamon lighttpd"
+		exit 1
+	fi
+}
+
+# stop_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
+}
+
+# Create the SQLite database of the MediaWiki. If the database file already
+# exists, it will be deleted.
+# This script should be runned from the directory where $FILES_FOLDER is
+# located.
+create_db () {
+	rm -f "$TMP/$DB_FILE"
+
+	echo "Generating the SQLite database file. It can take some time ..."
+	# Run the php script to generate the SQLite database file
+	# with cURL calls.
+	php "$FILES_FOLDER/$DB_INSTALL_SCRIPT" $(basename "$DB_FILE" .sqlite) \
+		"$WIKI_ADMIN" "$WIKI_PASSW" "$TMP" "$PORT"
+
+	if [ ! -f "$TMP/$DB_FILE" ] ; then
+		error "Can't create database file in TODO. Try to run ./install-wiki.sh delete first."
+	fi
+	chmod 666 "$TMP/$DB_FILE"
+
+	# Copy the generated database file into the directory the
+	# user indicated.
+	cp --preserve=mode,ownership "$TMP/$DB_FILE" "$FILES_FOLDER" ||
+		error "Unable to copy $TMP/$DB_FILE to $FILES_FOLDER"
+}
+
+# Install a wiki in your web server directory.
+wiki_install () {
+	if test $LIGHTTPD = "true" ; then
+		start_lighttpd
+	fi
+
+	SERVER_ADDR=$SERVER_ADDR:$PORT
+	# In this part, we change directory to $TMP in order to download,
+	# unpack and copy the files of MediaWiki
+	(
+	mkdir -p "$WIKI_DIR_INST/$WIKI_DIR_NAME"
+	if [ ! -d "$WIKI_DIR_INST/$WIKI_DIR_NAME" ] ; then
+		error "Folder $WIKI_DIR_INST/$WIKI_DIR_NAME doesn't exist.
+		Please create it and launch the script again."
+	fi
+
+	# Fetch MediaWiki's archive if not already present in the TMP directory
+	cd "$TMP"
+	if [ ! -f "$MW_VERSION.tar.gz" ] ; then
+		echo "Downloading $MW_VERSION sources ..."
+		wget "http://download.wikimedia.org/mediawiki/1.19/mediawiki-1.19.0.tar.gz" ||
+			error "Unable to download "\
+			"http://download.wikimedia.org/mediawiki/1.19/"\
+			"mediawiki-1.19.0.tar.gz. "\
+			"Please fix your connection and launch the script again."
+	fi
+	tar xfz "$MW_VERSION.tar.gz"
+	echo "$MW_VERSION.tar.gz downloaded in `pwd`."\
+		"You can delete it later if you want."
+
+	# Copy the files of MediaWiki wiki in the web server's directory.
+	cd "$MW_VERSION"
+	cp -Rf * "$WIKI_DIR_INST/$WIKI_DIR_NAME/" ||
+		error "Unable to copy WikiMedia's files from `pwd` to "\
+			"$WIKI_DIR_INST/$WIKI_DIR_NAME"
+	)
+
+	create_db
+
+	# Copy the generic LocalSettings.php in the web server's directory
+	# And modify parameters according to the ones set at the top
+	# of this script.
+	# Note that LocalSettings.php is never modified.
+	if [ ! -f "$FILES_FOLDER/LocalSettings.php" ] ; then
+		error "Can't find $FILES_FOLDER/LocalSettings.php " \
+			"in the current folder. "\
+		"Please run the script inside its folder."
+	fi
+	cp "$FILES_FOLDER/LocalSettings.php" \
+		"$FILES_FOLDER/LocalSettings-tmp.php" ||
+		error "Unable to copy $FILES_FOLDER/LocalSettings.php " \
+		"to $FILES_FOLDER/LocalSettings-tmp.php"
+
+	# Parse and set the LocalSettings file of the user according to the
+	# CONFIGURATION VARIABLES section at the beginning of this script
+	file_swap="$FILES_FOLDER/LocalSettings-swap.php"
+	sed "s,@WG_SCRIPT_PATH@,/$WIKI_DIR_NAME," \
+		"$FILES_FOLDER/LocalSettings-tmp.php" > "$file_swap"
+	mv "$file_swap" "$FILES_FOLDER/LocalSettings-tmp.php"
+	sed "s,@WG_SERVER@,http://$SERVER_ADDR," \
+		"$FILES_FOLDER/LocalSettings-tmp.php" > "$file_swap"
+	mv "$file_swap" "$FILES_FOLDER/LocalSettings-tmp.php"
+	sed "s,@WG_SQLITE_DATADIR@,$TMP," \
+		"$FILES_FOLDER/LocalSettings-tmp.php" > "$file_swap"
+	mv "$file_swap" "$FILES_FOLDER/LocalSettings-tmp.php"
+
+	mv "$FILES_FOLDER/LocalSettings-tmp.php" \
+		"$WIKI_DIR_INST/$WIKI_DIR_NAME/LocalSettings.php" ||
+		error "Unable to move $FILES_FOLDER/LocalSettings-tmp.php" \
+		"in $WIKI_DIR_INST/$WIKI_DIR_NAME"
+	echo "File $FILES_FOLDER/LocalSettings.php is set in" \
+		" $WIKI_DIR_INST/$WIKI_DIR_NAME"
+
+	chmod ugo+w "$FILES_FOLDER/$DB_FILE"
+
+	echo "Your wiki has been installed. You can check it at
+		http://$SERVER_ADDR/$WIKI_DIR_NAME"
+}
+
+# Reset the database of the wiki and the password of the admin
+#
+# Warning: This function must be called only in a subdirectory of t/ directory
+wiki_reset () {
+	# Copy initial database of the wiki
+	if [ ! -f "../$FILES_FOLDER/$DB_FILE" ] ; then
+		error "Can't find ../$FILES_FOLDER/$DB_FILE in the current folder."
+	fi
+	cp "../$FILES_FOLDER/$DB_FILE" "$TMP" ||
+		error "Can't copy ../$FILES_FOLDER/$DB_FILE in $TMP"
+	echo "File $FILES_FOLDER/$DB_FILE is set in $TMP"
+}
+
+# Delete the wiki created in the web server's directory and all its content
+# saved in the database.
+wiki_delete () {
+	if test $LIGHTTPD = "true"; then
+		stop_lighttpd
+	else
+		# Delete the wiki's directory.
+		rm -rf "$WIKI_DIR_INST/$WIKI_DIR_NAME" ||
+			error "Wiki's directory $WIKI_DIR_INST/" \
+			"$WIKI_DIR_NAME could not be deleted"
+		# Delete the wiki's SQLite database.
+		rm -f "$TMP/$DB_FILE" || error "Database $TMP/$DB_FILE could not be deleted."
+	fi
+
+	# Delete the wiki's SQLite database
+	rm -f "$TMP/$DB_FILE" || error "Database $TMP/$DB_FILE could not be deleted."
+	rm -f "$FILES_FOLDER/$DB_FILE"
+	rm -rf "$TMP/$MW_VERSION"
+}
diff --git a/contrib/mw-to-git/t/test.config b/contrib/mw-to-git/t/test.config
new file mode 100644
index 0000000..958b37b
--- /dev/null
+++ b/contrib/mw-to-git/t/test.config
@@ -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
-- 
1.7.10.2.552.gaa3bb87

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 2/6] Test environment of git-remote-mediawiki
  2012-06-12 21:12       ` [PATCH 1/6] Scripts to install, delete and clear a MediaWiki Simon Cathebras
@ 2012-06-12 21:12         ` Simon Cathebras
  2012-06-13  7:56           ` Matthieu Moy
  2012-06-13 10:14           ` Ævar Arnfjörð Bjarmason
  2012-06-12 21:12         ` [PATCH 3/6] Test file for git-remote-mediawiki clone Simon Cathebras
                           ` (2 subsequent siblings)
  3 siblings, 2 replies; 40+ messages in thread
From: Simon Cathebras @ 2012-06-12 21:12 UTC (permalink / raw)
  To: git
  Cc: gitster, peff, Guillaume Sasdy, Simon Cathebras, Simon Perrat,
	Charles Roussel, Julien Khayat, Matthieu Moy

From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>

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 file
git/contrib/mw-to-git/t/test-gitmw-lib.sh and
git/contrib/mw-to-git/t/test-gitmw.pl

In addition, this patch provide Makefiles to execute tests.
See README file for more details.

Signed-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>
Signed-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>
Signed-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
Signed-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>
Signed-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@imag.fr>
---
 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

diff --git a/contrib/mw-to-git/Makefile b/contrib/mw-to-git/Makefile
new file mode 100644
index 0000000..c9b1795
--- /dev/null
+++ b/contrib/mw-to-git/Makefile
@@ -0,0 +1,48 @@
+#
+# Copyright (C) 2012
+#     Charles Roussel <charles.roussel@ensimag.imag.fr>
+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>
+#     Julien Khayat <julien.khayat@ensimag.imag.fr>
+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
+#     Simon Perrat <simon.perrat@ensimag.imag.fr>
+#
+## 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
+
diff --git a/contrib/mw-to-git/t/Makefile b/contrib/mw-to-git/t/Makefile
new file mode 100644
index 0000000..752fd1f
--- /dev/null
+++ b/contrib/mw-to-git/t/Makefile
@@ -0,0 +1,27 @@
+#
+# Copyright (C) 2012
+#     Charles Roussel <charles.roussel@ensimag.imag.fr>
+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>
+#     Julien Khayat <julien.khayat@ensimag.imag.fr>
+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
+#     Simon Perrat <simon.perrat@ensimag.imag.fr>
+#
+## 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'.*
+
diff --git a/contrib/mw-to-git/t/README b/contrib/mw-to-git/t/README
new file mode 100644
index 0000000..b68147b
--- /dev/null
+++ b/contrib/mw-to-git/t/README
@@ -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.
diff --git a/contrib/mw-to-git/t/test-gitmw-lib.sh b/contrib/mw-to-git/t/test-gitmw-lib.sh
index 160f97b..30be380 100755
--- a/contrib/mw-to-git/t/test-gitmw-lib.sh
+++ b/contrib/mw-to-git/t/test-gitmw-lib.sh
@@ -22,6 +22,143 @@ else
 	WIKI_DIR_INST="$CURR_DIR/$WEB_WWW"
 fi
 
+
+wiki_getpage () {
+	"$CURR_DIR"/test-gitmw.pl get_page "$@"
+}
+
+wiki_delete_page () {
+	"$CURR_DIR"/test-gitmw.pl delete_page "$@"
+}
+
+wiki_editpage () {
+	"$CURR_DIR"/test-gitmw.pl edit_page "$@"
+}
+
+die () {
+	die_with_status 1 "$@"
+}
+
+die_with_status () {
+	status=$1
+	shift
+	echo >&2 "$*"
+	exit "$status"
+}
+
+
+# Check the preconditions to run git-remote-mediawiki's tests
+test_check_precond () {
+	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' \
+		'please try: cp git/contrib/mw-to-git/git-remote-mediawiki git/'
+		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_diff_directories <dir_git> <dir_wiki>
+#
+# Compare the contents of directories <dir_git> and <dir_wiki> with diff
+# and errors if they do not match. The program will
+# not look into .git in the process.
+# Warning: the first argument MUST be the directory containing the git data
+test_diff_directories () {
+	rm -rf "$1_tmp"
+	mkdir -p "$1_tmp"
+	cp "$1"/*.mw "$1_tmp"
+	diff -r -b "$1_tmp" "$2"
+}
+
+# $1=<dir>
+# $2=<N>
+#
+# Check that <dir> contains exactly <N> files
+test_contains_N_files () {
+	test `ls "$1" | wc -l` -eq "$2";
+}
+
+
+# wiki_check_content <file_name> <page_name>
+#
+# Compares the contents of the file <file_name> and the wiki page
+# <page_name> and exits with error 1 if they do not match.
+wiki_check_content () {
+	mkdir -p wiki_tmp
+	wiki_getpage "$2" wiki_tmp
+	#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
+	then
+		rm -rf wiki_tmp
+		error "ERROR: file $2 not found on wiki"
+	fi
+	rm -rf wiki_tmp
+}
+
+# wiki_page_exist <page_name>
+#
+# Check the existence of the page <page_name> on the wiki and exits
+# with error if it is absent from it.
+wiki_page_exist () {
+	mkdir -p wiki_tmp
+	wiki_getpage "$1" wiki_tmp
+	page_name=$(printf "%s\n" "$1" | sed "s/\//%2F/g")
+	if test -f wiki_tmp/"$page_name".mw ; then
+		rm -rf wiki_tmp
+	else
+		rm -rf wiki_tmp
+		error "test failed: file $1 not found on wiki"
+	fi
+}
+
+# wiki_getallpagename
+#
+# Fetch the name of each page on the wiki.
+wiki_getallpagename () {
+	$CURR_DIR/test-gitmw.pl getallpagename
+}
+
+# wiki_getallpagecategory <category>
+#
+# Fetch the name of each page belonging to <category> on the wiki.
+wiki_getallpagecategory () {
+	$CURR_DIR/test-gitmw.pl getallpagename "$@"
+}
+
+# wiki_getallpage <dest_dir> [<category>]
+#
+# Fetch all the pages from the wiki and place them in the directory
+# <dest_dir>.
+# If <category> is define, then wiki_getallpage fetch the pages included
+# in <category>.
+wiki_getallpage () {
+	if test -z "$2";
+	then
+		wiki_getallpagename
+	else
+		wiki_getallpagecategory "$2"
+	fi
+	mkdir -p "$1"
+	while read -r line; do
+		wiki_getpage "$line" $1;
+	done < all.txt
+}
+
 # ================= Install part =================
 
 error () {
diff --git a/contrib/mw-to-git/t/test-gitmw.pl b/contrib/mw-to-git/t/test-gitmw.pl
new file mode 100755
index 0000000..43faee5
--- /dev/null
+++ b/contrib/mw-to-git/t/test-gitmw.pl
@@ -0,0 +1,230 @@
+#!/usr/bin/perl -w -s
+# Copyright (C) 2012
+#     Charles Roussel <charles.roussel@ensimag.imag.fr>
+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>
+#     Julien Khayat <julien.khayat@ensimag.imag.fr>
+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
+#     Simon Perrat <simon.perrat@ensimag.imag.fr>
+# License: GPL v2 or later
+
+# Usage:
+#       ./test-gitmw.pl <command> [argument]*
+# Execute in terminal using the name of the function to call as first
+# parameter, and the function's arguments as following parameters
+#
+# Example:
+#     ./test-gitmw.pl "get_page" foo .
+# will call <wiki_getpage> with arguments <foo> and <.>
+#
+# Available functions are:
+#     "get_page"
+#     "delete_page"
+#     "edit_page"
+#     "getallpagename"
+
+use MediaWiki::API;
+use Getopt::Long;
+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>)
+{
+        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');
+}
+
+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;
+}
+
+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;
+}
+
+
+# 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;
+
+&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")}
+}
-- 
1.7.10.2.552.gaa3bb87

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 3/6] Test file for git-remote-mediawiki clone
  2012-06-12 21:12       ` [PATCH 1/6] Scripts to install, delete and clear a MediaWiki Simon Cathebras
  2012-06-12 21:12         ` [PATCH 2/6] Test environment of git-remote-mediawiki Simon Cathebras
@ 2012-06-12 21:12         ` Simon Cathebras
  2012-06-12 21:34           ` konglu
  2012-06-12 21:12         ` [PATCH 4/6] Tests for git-remote-mediawiki pull and push Simon Cathebras
  2012-06-12 21:12         ` [PATCH 5/6] Tests of UTF8 character with git-remote-mediawiki Simon Cathebras
  3 siblings, 1 reply; 40+ messages in thread
From: Simon Cathebras @ 2012-06-12 21:12 UTC (permalink / raw)
  To: git
  Cc: gitster, peff, Guillaume Sasdy, Simon Cathebras, Simon Perrat,
	Charles Roussel, Julien Khayat, Matthieu Moy

From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>

This patch provides some tests for the clone in use by
git-remote-mediawiki.

Signed-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>
Signed-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>
Signed-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
Signed-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>
Signed-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@imag.fr>
---
 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

diff --git a/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh b/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh
new file mode 100755
index 0000000..07e1270
--- /dev/null
+++ b/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh
@@ -0,0 +1,238 @@
+#!/bin/sh
+#
+# Copyright (C) 2012
+#     Charles Roussel <charles.roussel@ensimag.imag.fr>
+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>
+#     Julien Khayat <julien.khayat@ensimag.imag.fr>
+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
+#     Simon Perrat <simon.perrat@ensimag.imag.fr>
+#
+# License: GPL v2 or later
+
+
+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
-- 
1.7.10.2.552.gaa3bb87

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 4/6] Tests for git-remote-mediawiki pull and push
  2012-06-12 21:12       ` [PATCH 1/6] Scripts to install, delete and clear a MediaWiki Simon Cathebras
  2012-06-12 21:12         ` [PATCH 2/6] Test environment of git-remote-mediawiki Simon Cathebras
  2012-06-12 21:12         ` [PATCH 3/6] Test file for git-remote-mediawiki clone Simon Cathebras
@ 2012-06-12 21:12         ` Simon Cathebras
  2012-06-12 21:12         ` [PATCH 5/6] Tests of UTF8 character with git-remote-mediawiki Simon Cathebras
  3 siblings, 0 replies; 40+ messages in thread
From: Simon Cathebras @ 2012-06-12 21:12 UTC (permalink / raw)
  To: git
  Cc: gitster, peff, Guillaume Sasdy, Simon Cathebras, Simon Perrat,
	Charles Roussel, Julien Khayat, Matthieu Moy

From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>

This patch provides a set of tests for the pull and push fonctionnality of
git-remote-mediawiki.

Signed-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>
Signed-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>
Signed-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
Signed-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>
Signed-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@imag.fr>
---
 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

diff --git a/contrib/mw-to-git/t/t9361-mw-to-git-push-pull.sh b/contrib/mw-to-git/t/t9361-mw-to-git-push-pull.sh
new file mode 100755
index 0000000..add7c79
--- /dev/null
+++ b/contrib/mw-to-git/t/t9361-mw-to-git-push-pull.sh
@@ -0,0 +1,151 @@
+#!/bin/sh
+#
+# Copyright (C) 2012
+#     Charles Roussel <charles.roussel@ensimag.imag.fr>
+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>
+#     Julien Khayat <julien.khayat@ensimag.imag.fr>
+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
+#     Simon Perrat <simon.perrat@ensimag.imag.fr>
+#
+# License: GPL v2 or later
+
+# tests for git-remote-mediawiki
+
+test_description='Test 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
-- 
1.7.10.2.552.gaa3bb87

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 5/6] Tests of UTF8 character with git-remote-mediawiki
  2012-06-12 21:12       ` [PATCH 1/6] Scripts to install, delete and clear a MediaWiki Simon Cathebras
                           ` (2 preceding siblings ...)
  2012-06-12 21:12         ` [PATCH 4/6] Tests for git-remote-mediawiki pull and push Simon Cathebras
@ 2012-06-12 21:12         ` Simon Cathebras
  2012-06-12 21:18           ` Simon.Cathebras
  2012-06-12 21:45           ` konglu
  3 siblings, 2 replies; 40+ messages in thread
From: Simon Cathebras @ 2012-06-12 21:12 UTC (permalink / raw)
  To: git
  Cc: gitster, peff, Simon Cathebras, Simon Perrat, Guillaume Sasdy,
	Charles Roussel, Julien Khayat, Matthieu Moy

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

Signed-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>
Signed-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>
Signed-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
Signed-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>
Signed-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@imag.fr>
---
 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

diff --git a/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh b/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh
new file mode 100755
index 0000000..9227c6f
--- /dev/null
+++ b/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh
@@ -0,0 +1,271 @@
+#!/bin/sh
+#
+# Copyright (C) 2012
+#     Charles Roussel <charles.roussel@ensimag.imag.fr>
+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>
+#     Julien Khayat <julien.khayat@ensimag.imag.fr>
+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
+#     Simon Perrat <simon.perrat@ensimag.imag.fr>
+#
+# License: GPL v2 or later
+
+# tests for git-remote-mediawiki
+
+test_description='Test git-mediawiki with special characters in filenames'
+
+. ./test-gitmw-lib.sh
+. $TEST_DIRECTORY/test-lib.sh
+
+
+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
-- 
1.7.10.2.552.gaa3bb87

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [PATCH 5/6] Tests of UTF8 character with git-remote-mediawiki
  2012-06-12 21:12         ` [PATCH 5/6] Tests of UTF8 character with git-remote-mediawiki Simon Cathebras
@ 2012-06-12 21:18           ` Simon.Cathebras
  2012-06-12 21:52             ` konglu
  2012-06-12 21:45           ` konglu
  1 sibling, 1 reply; 40+ messages in thread
From: Simon.Cathebras @ 2012-06-12 21:18 UTC (permalink / raw)
  To: Simon Cathebras
  Cc: git, gitster, peff, Simon Perrat, Guillaume Sasdy,
	Charles Roussel, Julien Khayat, Matthieu Moy

Please accept our appologize for the bad tag for patches.

The PATCH 5 is actually the last one...

Regards.

Simon C

On 12/06/2012 23:12, Simon Cathebras wrote:
> This patch provides a sample of tests for git-remote-mediawiki's
> resistance, concerning utf8 special characters.
>
> Signed-off-by: Simon Cathebras<simon.cathebras@ensimag.imag.fr>
> Signed-off-by: Simon Perrat<simon.perrat@ensimag.imag.fr>
> Signed-off-by: Guillaume Sasdy<guillaume.sasdy@ensimag.imag.fr>
> Signed-off-by: Charles Roussel<charles.roussel@ensimag.imag.fr>
> Signed-off-by: Julien Khayat<julien.khayat@ensimag.imag.fr>
> Signed-off-by: Matthieu Moy<matthieu.moy@imag.fr>
> ---
>   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
>
> diff --git a/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh b/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh
> new file mode 100755
> index 0000000..9227c6f
> --- /dev/null
> +++ b/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh
> @@ -0,0 +1,271 @@
> +#!/bin/sh
> +#
> +# Copyright (C) 2012
> +#     Charles Roussel<charles.roussel@ensimag.imag.fr>
> +#     Simon Cathebras<simon.cathebras@ensimag.imag.fr>
> +#     Julien Khayat<julien.khayat@ensimag.imag.fr>
> +#     Guillaume Sasdy<guillaume.sasdy@ensimag.imag.fr>
> +#     Simon Perrat<simon.perrat@ensimag.imag.fr>
> +#
> +# License: GPL v2 or later
> +
> +# tests for git-remote-mediawiki
> +
> +test_description='Test git-mediawiki with special characters in filenames'
> +
> +. ./test-gitmw-lib.sh
> +. $TEST_DIRECTORY/test-lib.sh
> +
> +
> +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

-- 
CATHEBRAS Simon

2A-ENSIMAG

Filière Ingéniérie des Systèmes d'Information
Membre Bug-Buster

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 3/6] Test file for git-remote-mediawiki clone
  2012-06-12 21:12         ` [PATCH 3/6] Test file for git-remote-mediawiki clone Simon Cathebras
@ 2012-06-12 21:34           ` konglu
  2012-06-13  7:20             ` Simon.Cathebras
  0 siblings, 1 reply; 40+ messages in thread
From: konglu @ 2012-06-12 21:34 UTC (permalink / raw)
  To: Simon Cathebras
  Cc: git, gitster, peff, Guillaume Sasdy, Simon Perrat,
	Charles Roussel, Julien Khayat, Matthieu Moy


Simon Cathebras <simon.cathebras@ensimag.imag.fr> a écrit :

> From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
>
> This patch provides some tests for the clone in use by
> git-remote-mediawiki.
>
> Signed-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>
> Signed-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>
> Signed-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
> Signed-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>
> Signed-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>
> Signed-off-by: Matthieu Moy <matthieu.moy@imag.fr>
> ---
>  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
>
> diff --git a/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh  
> b/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh
> new file mode 100755
> index 0000000..07e1270
> --- /dev/null
> +++ b/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh
> @@ -0,0 +1,238 @@
> +#!/bin/sh
> +#
> +# Copyright (C) 2012
> +#     Charles Roussel <charles.roussel@ensimag.imag.fr>
> +#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>
> +#     Julien Khayat <julien.khayat@ensimag.imag.fr>
> +#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
> +#     Simon Perrat <simon.perrat@ensimag.imag.fr>
> +#
> +# License: GPL v2 or later
> +
> +
> +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
> +'

It's clearer to put it this way:

         git clone [...] &&
         (
                 cd ... &&
                 ....
         ) &&
         ....

And, about style:
     "echo one >one" and not "echo one > one"

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 5/6] Tests of UTF8 character with git-remote-mediawiki
  2012-06-12 21:12         ` [PATCH 5/6] Tests of UTF8 character with git-remote-mediawiki Simon Cathebras
  2012-06-12 21:18           ` Simon.Cathebras
@ 2012-06-12 21:45           ` konglu
  1 sibling, 0 replies; 40+ messages in thread
From: konglu @ 2012-06-12 21:45 UTC (permalink / raw)
  To: Simon Cathebras
  Cc: git, gitster, peff, Simon Perrat, Guillaume Sasdy,
	Charles Roussel, Julien Khayat, Matthieu Moy


Simon Cathebras <simon.cathebras@ensimag.imag.fr> a écrit :

> This patch provides a sample of tests for git-remote-mediawiki's
> resistance, concerning utf8 special characters.
>
> Signed-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>
> Signed-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>
> Signed-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
> Signed-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>
> Signed-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>
> Signed-off-by: Matthieu Moy <matthieu.moy@imag.fr>
> ---
>  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 :)

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 5/6] Tests of UTF8 character with git-remote-mediawiki
  2012-06-12 21:18           ` Simon.Cathebras
@ 2012-06-12 21:52             ` konglu
  2012-06-13  7:30               ` Simon.Cathebras
  0 siblings, 1 reply; 40+ messages in thread
From: konglu @ 2012-06-12 21:52 UTC (permalink / raw)
  To: Simon.Cathebras
  Cc: git, gitster, peff, Simon Perrat, Guillaume Sasdy,
	Charles Roussel, Julien Khayat, Matthieu Moy


"Simon.Cathebras" <Simon.Cathebras@ensimag.imag.fr> a écrit :

> 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

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 3/6] Test file for git-remote-mediawiki clone
  2012-06-12 21:34           ` konglu
@ 2012-06-13  7:20             ` Simon.Cathebras
  0 siblings, 0 replies; 40+ messages in thread
From: Simon.Cathebras @ 2012-06-13  7:20 UTC (permalink / raw)
  To: konglu
  Cc: git, gitster, peff, Guillaume Sasdy, Simon Perrat,
	Charles Roussel, Julien Khayat, Matthieu Moy



On 12/06/2012 23:34, konglu@minatec.inpg.fr wrote:
>
> Simon Cathebras <simon.cathebras@ensimag.imag.fr> a écrit :
>
>> From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
>>
>> This patch provides some tests for the clone in use by
>> git-remote-mediawiki.
>>
>> Signed-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>
>> Signed-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>
>> Signed-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
>> Signed-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>
>> Signed-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>
>> Signed-off-by: Matthieu Moy <matthieu.moy@imag.fr>
>> ---
>>  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
>>
>> diff --git a/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh 
>> b/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh
>> new file mode 100755
>> index 0000000..07e1270
>> --- /dev/null
>> +++ b/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh
>> @@ -0,0 +1,238 @@
>> +#!/bin/sh
>> +#
>> +# Copyright (C) 2012
>> +#     Charles Roussel <charles.roussel@ensimag.imag.fr>
>> +#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>
>> +#     Julien Khayat <julien.khayat@ensimag.imag.fr>
>> +#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
>> +#     Simon Perrat <simon.perrat@ensimag.imag.fr>
>> +#
>> +# License: GPL v2 or later
>> +
>> +
>> +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
>> +'
>
> It's clearer to put it this way:
>
>         git clone [...] &&
>         (
>                 cd ... &&
>                 ....
>         ) &&
>         ....
>

Okay, we are modifiying it right now.

> And, about style:
>     "echo one >one" and not "echo one > one"
>
>
>
same.


Simon C.

-- 
CATHEBRAS Simon

2A-ENSIMAG

Filière Ingéniérie des Systèmes d'Information
Membre Bug-Buster

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 5/6] Tests of UTF8 character with git-remote-mediawiki
  2012-06-12 21:52             ` konglu
@ 2012-06-13  7:30               ` Simon.Cathebras
  0 siblings, 0 replies; 40+ messages in thread
From: Simon.Cathebras @ 2012-06-13  7:30 UTC (permalink / raw)
  To: konglu
  Cc: git, gitster, peff, Simon Perrat, Guillaume Sasdy,
	Charles Roussel, Julien Khayat, Matthieu Moy



On 12/06/2012 23:52, konglu@minatec.inpg.fr wrote:
>
> "Simon.Cathebras" <Simon.Cathebras@ensimag.imag.fr> a écrit :
>
>> 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.

> Thanks,
>
> Lucien Kong
>


-- 
CATHEBRAS Simon

2A-ENSIMAG

Filière Ingéniérie des Systèmes d'Information
Membre Bug-Buster

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 2/6] Test environment of git-remote-mediawiki
  2012-06-12 21:12         ` [PATCH 2/6] Test environment of git-remote-mediawiki Simon Cathebras
@ 2012-06-13  7:56           ` Matthieu Moy
  2012-06-13  8:10             ` Simon.Cathebras
  2012-06-13 10:14           ` Ævar Arnfjörð Bjarmason
  1 sibling, 1 reply; 40+ messages in thread
From: Matthieu Moy @ 2012-06-13  7:56 UTC (permalink / raw)
  To: Simon Cathebras
  Cc: git, gitster, peff, Guillaume Sasdy, Simon Perrat,
	Charles Roussel, Julien Khayat

Simon Cathebras <simon.cathebras@ensimag.imag.fr> writes:

> +# 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?

> +	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.

> +	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"

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 2/6] Test environment of git-remote-mediawiki
  2012-06-13  7:56           ` Matthieu Moy
@ 2012-06-13  8:10             ` Simon.Cathebras
  0 siblings, 0 replies; 40+ messages in thread
From: Simon.Cathebras @ 2012-06-13  8:10 UTC (permalink / raw)
  To: Matthieu Moy
  Cc: git, gitster, peff, Guillaume Sasdy, Simon Perrat,
	Charles Roussel, Julien Khayat



On 13/06/2012 09:56, Matthieu Moy wrote:
> Simon Cathebras<simon.cathebras@ensimag.imag.fr>  writes:
>
>> +# 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?

I agree with that.

>> +	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.

>> +	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.

>
> +	$CURR_DIR/test-gitmw.pl getallpagename
>
> Here and elsewhere, "" around "$CURR_DIR"
>
Got it, thanks =).

Simon C

-- 
CATHEBRAS Simon

2A-ENSIMAG

Filière Ingéniérie des Systèmes d'Information
Membre Bug-Buster

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 2/6] Test environment of git-remote-mediawiki
  2012-06-12 21:12         ` [PATCH 2/6] Test environment of git-remote-mediawiki Simon Cathebras
  2012-06-13  7:56           ` Matthieu Moy
@ 2012-06-13 10:14           ` Ævar Arnfjörð Bjarmason
  2012-06-13 17:00             ` Simon.Cathebras
  1 sibling, 1 reply; 40+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2012-06-13 10:14 UTC (permalink / raw)
  To: Simon Cathebras
  Cc: git, gitster, peff, Guillaume Sasdy, Simon Perrat,
	Charles Roussel, Julien Khayat, Matthieu Moy

On Tue, Jun 12, 2012 at 11:12 PM, Simon Cathebras
<simon.cathebras@ensimag.imag.fr> wrote:

Some comments on your perl style:

> +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.

> +{
> +        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.

> +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;
> +}
> +
> +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.

> +# 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;
> +
> +&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);

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 2/6] Test environment of git-remote-mediawiki
  2012-06-13 10:14           ` Ævar Arnfjörð Bjarmason
@ 2012-06-13 17:00             ` Simon.Cathebras
  2012-06-13 17:03               ` [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki Simon Cathebras
  0 siblings, 1 reply; 40+ messages in thread
From: Simon.Cathebras @ 2012-06-13 17:00 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: git, gitster, peff, Guillaume Sasdy, Simon Perrat,
	Charles Roussel, Julien Khayat, Matthieu Moy



On 13/06/2012 12:14, Ævar Arnfjörð Bjarmason wrote:
> On Tue, Jun 12, 2012 at 11:12 PM, Simon Cathebras
> <simon.cathebras@ensimag.imag.fr>  wrote:
>
> Some comments on your perl style:
>
>> +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.

We corrected it. The correction will appears in our next patch.

>> +{
>> +        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.

Same.

>> +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;
>> +}
>> +
>> +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.

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.

>> +# 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;
>> +
>> +&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);
Corrected

Thanks ! :)

-- 
CATHEBRAS Simon

2A-ENSIMAG

Filière Ingéniérie des Systèmes d'Information
Membre Bug-Buster

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki
  2012-06-13 17:00             ` Simon.Cathebras
@ 2012-06-13 17:03               ` Simon Cathebras
  2012-06-13 17:03                 ` [PATCHv5 2/5] Test environment of git-remote-mediawiki Simon Cathebras
                                   ` (5 more replies)
  0 siblings, 6 replies; 40+ messages in thread
From: Simon Cathebras @ 2012-06-13 17:03 UTC (permalink / raw)
  To: git
  Cc: gitster, peff, Guillaume Sasdy, Simon Cathebras, Simon Perrat,
	Charles Roussel, Julien Khayat, Matthieu Moy

From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>

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/

Signed-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>
Signed-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>
Signed-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
Signed-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>
Signed-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@imag.fr>

---
 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

diff --git a/contrib/mw-to-git/t/install-wiki.sh b/contrib/mw-to-git/t/install-wiki.sh
new file mode 100755
index 0000000..17a1fc8
--- /dev/null
+++ b/contrib/mw-to-git/t/install-wiki.sh
@@ -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
diff --git a/contrib/mw-to-git/t/install-wiki/LocalSettings.php b/contrib/mw-to-git/t/install-wiki/LocalSettings.php
new file mode 100644
index 0000000..aa72518
--- /dev/null
+++ b/contrib/mw-to-git/t/install-wiki/LocalSettings.php
@@ -0,0 +1,128 @@
+<?php
+# This file was automatically generated by the MediaWiki 1.19.0
+# installer. If you make manual changes, please keep track in case you
+# need to recreate them later.
+#
+# See includes/DefaultSettings.php for all configurable settings
+# and their default values, but don't forget to make changes in _this_
+# file, not there.
+#
+# Further documentation for configuration settings may be found at:
+# http://www.mediawiki.org/wiki/Manual:Configuration_settings
+
+# Protect against web entry
+if ( !defined( 'MEDIAWIKI' ) ) {
+	exit;
+}
+
+## Uncomment this to disable output compression
+# $wgDisableOutputCompression = true;
+
+$wgSitename      = "Git-MediaWiki-Test";
+$wgMetaNamespace = "Git-MediaWiki-Test";
+
+## The URL base path to the directory containing the wiki;
+## defaults for all runtime URL paths are based off of this.
+## For more information on customizing the URLs please see:
+## http://www.mediawiki.org/wiki/Manual:Short_URL
+$wgScriptPath       = "@WG_SCRIPT_PATH@";
+$wgScriptExtension  = ".php";
+
+## The protocol and server name to use in fully-qualified URLs
+$wgServer           = "@WG_SERVER@";
+
+## The relative URL path to the skins directory
+$wgStylePath        = "$wgScriptPath/skins";
+
+## The relative URL path to the logo.  Make sure you change this from the default,
+## or else you'll overwrite your logo when you upgrade!
+$wgLogo             = "$wgStylePath/common/images/wiki.png";
+
+## UPO means: this is also a user preference option
+
+$wgEnableEmail      = true;
+$wgEnableUserEmail  = true; # UPO
+
+$wgEmergencyContact = "apache@localhost";
+$wgPasswordSender   = "apache@localhost";
+
+$wgEnotifUserTalk      = false; # UPO
+$wgEnotifWatchlist     = false; # UPO
+$wgEmailAuthentication = true;
+
+## Database settings
+$wgDBtype           = "sqlite";
+$wgDBserver         = "";
+$wgDBname           = "@WG_SQLITE_DATAFILE@";
+$wgDBuser           = "";
+$wgDBpassword       = "";
+
+# SQLite-specific settings
+$wgSQLiteDataDir    = "@WG_SQLITE_DATADIR@";
+
+
+## Shared memory settings
+$wgMainCacheType    = CACHE_NONE;
+$wgMemCachedServers = array();
+
+## To enable image uploads, make sure the 'images' directory
+## is writable, then set this to true:
+$wgEnableUploads  = false;
+$wgUseImageMagick = true;
+$wgImageMagickConvertCommand ="@CONVERT@";
+
+# InstantCommons allows wiki to use images from http://commons.wikimedia.org
+$wgUseInstantCommons  = false;
+
+## If you use ImageMagick (or any other shell command) on a
+## Linux server, this will need to be set to the name of an
+## available UTF-8 locale
+$wgShellLocale = "en_US.utf8";
+
+## If you want to use image uploads under safe mode,
+## create the directories images/archive, images/thumb and
+## images/temp, and make them all writable. Then uncomment
+## this, if it's not already uncommented:
+#$wgHashedUploadDirectory = false;
+
+## Set $wgCacheDirectory to a writable directory on the web server
+## to make your wiki go slightly faster. The directory should not
+## be publically accessible from the web.
+#$wgCacheDirectory = "$IP/cache";
+
+# Site language code, should be one of the list in ./languages/Names.php
+$wgLanguageCode = "en";
+
+$wgSecretKey = "1c912bfe3519fb70f5dc523ecc698111cd43d81a11c585b3eefb28f29c2699b7";
+#$wgSecretKey = "@SECRETKEY@";
+
+
+# Site upgrade key. Must be set to a string (default provided) to turn on the
+# web installer while LocalSettings.php is in place
+$wgUpgradeKey = "ddae7dc87cd0a645";
+
+## Default skin: you can change the default skin. Use the internal symbolic
+## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook', 'vector':
+$wgDefaultSkin = "vector";
+
+## For attaching licensing metadata to pages, and displaying an
+## appropriate copyright notice / icon. GNU Free Documentation
+## License and Creative Commons licenses are supported so far.
+$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright
+$wgRightsUrl  = "";
+$wgRightsText = "";
+$wgRightsIcon = "";
+
+# Path to the GNU diff3 utility. Used for conflict resolution.
+$wgDiff3 = "/usr/bin/diff3";
+
+# Query string length limit for ResourceLoader. You should only set this if
+# your web server has a query string length limit (then set it to that limit),
+# or if you have suhosin.get.max_value_length set in php.ini (then set it to
+# that value)
+$wgResourceLoaderMaxQueryLength = -1;
+
+
+
+# End of automatically generated settings.
+# Add more configuration options below.
diff --git a/contrib/mw-to-git/t/install-wiki/db_install.php b/contrib/mw-to-git/t/install-wiki/db_install.php
new file mode 100644
index 0000000..3111c73
--- /dev/null
+++ b/contrib/mw-to-git/t/install-wiki/db_install.php
@@ -0,0 +1,110 @@
+<?php
+/**
+ * This script generates a SQLite database for a MediaWiki version 1.19.0
+ * You must specify the login of the admin (argument 1) and its
+ * password (argument 2) and the folder where the database file
+ * is located (absolute path in argument 3).
+ * It is used by the script install-wiki.sh in order to make easy the
+ * installation of a MediaWiki.
+ *
+ * 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'];
+
+$login = $argv[2];
+$pass = $argv[3];
+$tmp = $argv[4];
+$port = $argv[5];
+
+$url = 'http://localhost:'.$port.'/wiki/mw-config/index.php';
+$db_dir = urlencode($tmp);
+$tmp_cookie = tempnam($tmp,"COOKIE_");
+/*
+ * Fetchs a page with cURL.
+ */
+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);
+        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;
+}
+
+/*
+ * Submits a form with cURL.
+ */
+function submit($page_name, $option = "") {
+        $curl = curl_init();
+        $datapost = 'submit-continue=Continue+%E2%86%92';
+        if ($option != "") {
+                $datapost = $option.'&'.$datapost;
+        }
+	$url = $GLOBALS['url'].'?page='.$page_name;
+        $tmp_cookie = $GLOBALS['tmp_cookie'];
+        curl_setopt($curl, CURLOPT_URL, $url);
+        curl_setopt($curl, CURLOPT_POST, true);
+        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
+        curl_setopt($curl, CURLOPT_POSTFIELDS, $datapost);
+        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
+        curl_setopt($curl, CURLOPT_COOKIEJAR, $tmp_cookie);
+        curl_setopt($curl, CURLOPT_COOKIEFILE, $tmp_cookie);
+
+        $page = curl_exec($curl);
+        curl_close($curl);
+        return "$page";
+}
+
+/*
+ * Here starts this script: simulates the behavior of the user
+ * 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();
+preg_match('/input type="hidden" value="([0-9]+)" name="LanguageRequestTime"/',
+        $page, $matches);
+$timestamp = $matches[1];
+$language = "LanguageRequestTime=$timestamp&uselang=en&ContLang=en";
+$page = submit('Language', $language);
+
+submit('Welcome');
+
+$db_config = 'DBType=sqlite';
+$db_config = $db_config.'&sqlite_wgSQLiteDataDir='.$db_dir;
+$db_config = $db_config.'&sqlite_wgDBname='.$argv[1];
+submit('DBConnect', $db_config);
+
+$wiki_config = 'config_wgSitename=TEST';
+$wiki_config = $wiki_config.'&config__NamespaceType=site-name';
+$wiki_config = $wiki_config.'&config_wgMetaNamespace=MyWiki';
+$wiki_config = $wiki_config.'&config__AdminName='.$login;
+
+$wiki_config = $wiki_config.'&config__AdminPassword='.$pass;
+$wiki_config = $wiki_config.'&config__AdminPassword2='.$pass;
+
+$wiki_config = $wiki_config.'&wiki__configEmail=email%40email.org';
+$wiki_config = $wiki_config.'&config__SkipOptional=skip';
+submit('Name', $wiki_config);
+submit('Install');
+submit('Install');
+
+unlink($tmp_cookie);
+?>
diff --git a/contrib/mw-to-git/t/test-gitmw-lib.sh b/contrib/mw-to-git/t/test-gitmw-lib.sh
new file mode 100755
index 0000000..a948f0c
--- /dev/null
+++ b/contrib/mw-to-git/t/test-gitmw-lib.sh
@@ -0,0 +1,288 @@
+# Copyright (C) 2012
+#     Charles Roussel <charles.roussel@ensimag.imag.fr>
+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>
+#     Julien Khayat <julien.khayat@ensimag.imag.fr>
+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
+#     Simon Perrat <simon.perrat@ensimag.imag.fr>
+# License: GPL v2 or later
+
+#
+# CONFIGURATION VARIABLES
+# You might want to change these ones
+#
+
+. ./test.config
+
+export CURR_DIR=$(pwd)
+export TEST_DIRECTORY=$CURR_DIR/../../../t
+
+if test $LIGHTTPD = "false" ; then
+	PORT=80
+else
+	WIKI_DIR_INST="$CURR_DIR/$WEB_WWW"
+fi
+
+# ================= Install part =================
+
+error () {
+	echo "$@" >&2
+	exit 1
+}
+
+# config_lighttpd
+#
+# Create the configuration files and the folders necessary to start lighttpd.
+# Overwrite any existing file.
+config_lighttpd() {
+	mkdir -p $WEB
+	mkdir -p $WEB_TMP
+	mkdir -p $WEB_WWW
+	cat > $WEB/lighttpd.conf <<EOF
+	server.document-root = "$CURR_DIR/$WEB_WWW"
+	server.port = $PORT
+	server.pid-file = "$CURR_DIR/$WEB_TMP/pid"
+
+	server.modules = (
+	"mod_rewrite",
+	"mod_redirect",
+	"mod_access",
+	"mod_accesslog",
+	"mod_fastcgi"
+	)
+
+	index-file.names = ("index.php" , "index.html")
+
+	mimetype.assign		    = (
+	".pdf"		=>	"application/pdf",
+	".sig"		=>	"application/pgp-signature",
+	".spl"		=>	"application/futuresplash",
+	".class"	=>	"application/octet-stream",
+	".ps"		=>	"application/postscript",
+	".torrent"	=>	"application/x-bittorrent",
+	".dvi"		=>	"application/x-dvi",
+	".gz"		=>	"application/x-gzip",
+	".pac"		=>	"application/x-ns-proxy-autoconfig",
+	".swf"		=>	"application/x-shockwave-flash",
+	".tar.gz"	=>	"application/x-tgz",
+	".tgz"		=>	"application/x-tgz",
+	".tar"		=>	"application/x-tar",
+	".zip"		=>	"application/zip",
+	".mp3"		=>	"audio/mpeg",
+	".m3u"		=>	"audio/x-mpegurl",
+	".wma"		=>	"audio/x-ms-wma",
+	".wax"		=>	"audio/x-ms-wax",
+	".ogg"		=>	"application/ogg",
+	".wav"		=>	"audio/x-wav",
+	".gif"		=>	"image/gif",
+	".jpg"		=>	"image/jpeg",
+	".jpeg"		=>	"image/jpeg",
+	".png"		=>	"image/png",
+	".xbm"		=>	"image/x-xbitmap",
+	".xpm"		=>	"image/x-xpixmap",
+	".xwd"		=>	"image/x-xwindowdump",
+	".css"		=>	"text/css",
+	".html"		=>	"text/html",
+	".htm"		=>	"text/html",
+	".js"		=>	"text/javascript",
+	".asc"		=>	"text/plain",
+	".c"		=>	"text/plain",
+	".cpp"		=>	"text/plain",
+	".log"		=>	"text/plain",
+	".conf"		=>	"text/plain",
+	".text"		=>	"text/plain",
+	".txt"		=>	"text/plain",
+	".dtd"		=>	"text/xml",
+	".xml"		=>	"text/xml",
+	".mpeg"		=>	"video/mpeg",
+	".mpg"		=>	"video/mpeg",
+	".mov"		=>	"video/quicktime",
+	".qt"		=>	"video/quicktime",
+	".avi"		=>	"video/x-msvideo",
+	".asf"		=>	"video/x-ms-asf",
+	".asx"		=>	"video/x-ms-asf",
+	".wmv"		=>	"video/x-ms-wmv",
+	".bz2"		=>	"application/x-bzip",
+	".tbz"		=>	"application/x-bzip-compressed-tar",
+	".tar.bz2"	=>	"application/x-bzip-compressed-tar",
+	""		=>	"text/plain"
+	)
+
+	fastcgi.server = ( ".php" =>
+	("localhost" =>
+	( "socket" => "$CURR_DIR/$WEB_TMP/php.socket",
+	"bin-path" => "$PHP_DIR/php-cgi -c $CURR_DIR/$WEB/php.ini"
+
+	)
+	)
+	)
+EOF
+
+	cat > $WEB/php.ini <<EOF
+	session.save_path ='$CURR_DIR/$WEB_TMP'
+EOF
+}
+
+# start_lighttpd
+#
+# Start or restart daemon lighttpd. If restart, rewrite configuration files.
+start_lighttpd() {
+	if test -f "$WEB_TMP/pid"; then
+		echo "Instance already running. Restarting..."
+		stop_lighttpd
+	fi
+	config_lighttpd
+	$LIGHTTPD_DIR/lighttpd -f $WEB/lighttpd.conf
+
+	if test $? -ne 0 ; then
+		echo "Could not execute http deamon lighttpd"
+		exit 1
+	fi
+}
+
+# stop_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
+}
+
+# Create the SQLite database of the MediaWiki. If the database file already
+# exists, it will be deleted.
+# This script should be runned from the directory where $FILES_FOLDER is
+# located.
+create_db () {
+	rm -f "$TMP/$DB_FILE"
+
+	echo "Generating the SQLite database file. It can take some time ..."
+	# Run the php script to generate the SQLite database file
+	# with cURL calls.
+	php "$FILES_FOLDER/$DB_INSTALL_SCRIPT" $(basename "$DB_FILE" .sqlite) \
+		"$WIKI_ADMIN" "$WIKI_PASSW" "$TMP" "$PORT"
+
+	if [ ! -f "$TMP/$DB_FILE" ] ; then
+		error "Can't create database file in TODO. Try to run ./install-wiki.sh delete first."
+	fi
+	chmod 666 "$TMP/$DB_FILE"
+
+	# Copy the generated database file into the directory the
+	# user indicated.
+	cp --preserve=mode,ownership "$TMP/$DB_FILE" "$FILES_FOLDER" ||
+		error "Unable to copy $TMP/$DB_FILE to $FILES_FOLDER"
+}
+
+# Install a wiki in your web server directory.
+wiki_install () {
+	if test $LIGHTTPD = "true" ; then
+		start_lighttpd
+	fi
+
+	SERVER_ADDR=$SERVER_ADDR:$PORT
+	# In this part, we change directory to $TMP in order to download,
+	# unpack and copy the files of MediaWiki
+	(
+	mkdir -p "$WIKI_DIR_INST/$WIKI_DIR_NAME"
+	if [ ! -d "$WIKI_DIR_INST/$WIKI_DIR_NAME" ] ; then
+		error "Folder $WIKI_DIR_INST/$WIKI_DIR_NAME doesn't exist.
+		Please create it and launch the script again."
+	fi
+
+	# Fetch MediaWiki's archive if not already present in the TMP directory
+	cd "$TMP"
+	if [ ! -f "$MW_VERSION.tar.gz" ] ; then
+		echo "Downloading $MW_VERSION sources ..."
+		wget "http://download.wikimedia.org/mediawiki/1.19/mediawiki-1.19.0.tar.gz" ||
+			error "Unable to download "\
+			"http://download.wikimedia.org/mediawiki/1.19/"\
+			"mediawiki-1.19.0.tar.gz. "\
+			"Please fix your connection and launch the script again."
+	fi
+	tar xfz "$MW_VERSION.tar.gz"
+	echo "$MW_VERSION.tar.gz downloaded in `pwd`."\
+		"You can delete it later if you want."
+
+	# Copy the files of MediaWiki wiki in the web server's directory.
+	cd "$MW_VERSION"
+	cp -Rf * "$WIKI_DIR_INST/$WIKI_DIR_NAME/" ||
+		error "Unable to copy WikiMedia's files from `pwd` to "\
+			"$WIKI_DIR_INST/$WIKI_DIR_NAME"
+	)
+
+	create_db
+
+	# Copy the generic LocalSettings.php in the web server's directory
+	# And modify parameters according to the ones set at the top
+	# of this script.
+	# Note that LocalSettings.php is never modified.
+	if [ ! -f "$FILES_FOLDER/LocalSettings.php" ] ; then
+		error "Can't find $FILES_FOLDER/LocalSettings.php " \
+			"in the current folder. "\
+		"Please run the script inside its folder."
+	fi
+	cp "$FILES_FOLDER/LocalSettings.php" \
+		"$FILES_FOLDER/LocalSettings-tmp.php" ||
+		error "Unable to copy $FILES_FOLDER/LocalSettings.php " \
+		"to $FILES_FOLDER/LocalSettings-tmp.php"
+
+	# Parse and set the LocalSettings file of the user according to the
+	# CONFIGURATION VARIABLES section at the beginning of this script
+	file_swap="$FILES_FOLDER/LocalSettings-swap.php"
+	sed "s,@WG_SCRIPT_PATH@,/$WIKI_DIR_NAME," \
+		"$FILES_FOLDER/LocalSettings-tmp.php" > "$file_swap"
+	mv "$file_swap" "$FILES_FOLDER/LocalSettings-tmp.php"
+	sed "s,@WG_SERVER@,http://$SERVER_ADDR," \
+		"$FILES_FOLDER/LocalSettings-tmp.php" > "$file_swap"
+	mv "$file_swap" "$FILES_FOLDER/LocalSettings-tmp.php"
+	sed "s,@WG_SQLITE_DATADIR@,$TMP," \
+		"$FILES_FOLDER/LocalSettings-tmp.php" > "$file_swap"
+	mv "$file_swap" "$FILES_FOLDER/LocalSettings-tmp.php"
+	sed "s,@WG_SQLITE_DATAFILE@,$( basename $DB_FILE .sqlite)," \
+		"$FILES_FOLDER/LocalSettings-tmp.php" > "$file_swap"
+	mv "$file_swap" "$FILES_FOLDER/LocalSettings-tmp.php"
+
+	mv "$FILES_FOLDER/LocalSettings-tmp.php" \
+		"$WIKI_DIR_INST/$WIKI_DIR_NAME/LocalSettings.php" ||
+		error "Unable to move $FILES_FOLDER/LocalSettings-tmp.php" \
+		"in $WIKI_DIR_INST/$WIKI_DIR_NAME"
+	echo "File $FILES_FOLDER/LocalSettings.php is set in" \
+		" $WIKI_DIR_INST/$WIKI_DIR_NAME"
+
+	chmod ugo+w "$FILES_FOLDER/$DB_FILE"
+
+	echo "Your wiki has been installed. You can check it at
+		http://$SERVER_ADDR/$WIKI_DIR_NAME"
+}
+
+# Reset the database of the wiki and the password of the admin
+#
+# Warning: This function must be called only in a subdirectory of t/ directory
+wiki_reset () {
+	# Copy initial database of the wiki
+	if [ ! -f "../$FILES_FOLDER/$DB_FILE" ] ; then
+		error "Can't find ../$FILES_FOLDER/$DB_FILE in the current folder."
+	fi
+	cp "../$FILES_FOLDER/$DB_FILE" "$TMP" ||
+		error "Can't copy ../$FILES_FOLDER/$DB_FILE in $TMP"
+	echo "File $FILES_FOLDER/$DB_FILE is set in $TMP"
+}
+
+# Delete the wiki created in the web server's directory and all its content
+# saved in the database.
+wiki_delete () {
+	if test $LIGHTTPD = "true"; then
+		stop_lighttpd
+	else
+		# Delete the wiki's directory.
+		rm -rf "$WIKI_DIR_INST/$WIKI_DIR_NAME" ||
+			error "Wiki's directory $WIKI_DIR_INST/" \
+			"$WIKI_DIR_NAME could not be deleted"
+		# Delete the wiki's SQLite database.
+		rm -f "$TMP/$DB_FILE" || error "Database $TMP/$DB_FILE could not be deleted."
+	fi
+
+	# Delete the wiki's SQLite database
+	rm -f "$TMP/$DB_FILE" || error "Database $TMP/$DB_FILE could not be deleted."
+	rm -f "$FILES_FOLDER/$DB_FILE"
+	rm -rf "$TMP/$MW_VERSION"
+}
diff --git a/contrib/mw-to-git/t/test.config b/contrib/mw-to-git/t/test.config
new file mode 100644
index 0000000..958b37b
--- /dev/null
+++ b/contrib/mw-to-git/t/test.config
@@ -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
-- 
1.7.10.2.552.gaa3bb87

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv5 2/5] Test environment of git-remote-mediawiki
  2012-06-13 17:03               ` [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki Simon Cathebras
@ 2012-06-13 17:03                 ` Simon Cathebras
  2012-06-13 17:03                 ` [PATCHv5 3/5] Test file for git-remote-mediawiki clone Simon Cathebras
                                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 40+ messages in thread
From: Simon Cathebras @ 2012-06-13 17:03 UTC (permalink / raw)
  To: git
  Cc: gitster, peff, Guillaume Sasdy, Simon Cathebras, Simon Perrat,
	Charles Roussel, Julien Khayat, Matthieu Moy

From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>

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 file
git/contrib/mw-to-git/t/test-gitmw-lib.sh and
git/contrib/mw-to-git/t/test-gitmw.pl

In addition, this patch provide Makefiles to execute tests.
See README file for more details.

Signed-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>
Signed-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>
Signed-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
Signed-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>
Signed-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@imag.fr>
---
 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

diff --git a/contrib/mw-to-git/Makefile b/contrib/mw-to-git/Makefile
new file mode 100644
index 0000000..c9b1795
--- /dev/null
+++ b/contrib/mw-to-git/Makefile
@@ -0,0 +1,48 @@
+#
+# Copyright (C) 2012
+#     Charles Roussel <charles.roussel@ensimag.imag.fr>
+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>
+#     Julien Khayat <julien.khayat@ensimag.imag.fr>
+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
+#     Simon Perrat <simon.perrat@ensimag.imag.fr>
+#
+## 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
+
diff --git a/contrib/mw-to-git/t/Makefile b/contrib/mw-to-git/t/Makefile
new file mode 100644
index 0000000..752fd1f
--- /dev/null
+++ b/contrib/mw-to-git/t/Makefile
@@ -0,0 +1,27 @@
+#
+# Copyright (C) 2012
+#     Charles Roussel <charles.roussel@ensimag.imag.fr>
+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>
+#     Julien Khayat <julien.khayat@ensimag.imag.fr>
+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
+#     Simon Perrat <simon.perrat@ensimag.imag.fr>
+#
+## 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'.*
+
diff --git a/contrib/mw-to-git/t/README b/contrib/mw-to-git/t/README
new file mode 100644
index 0000000..b68147b
--- /dev/null
+++ b/contrib/mw-to-git/t/README
@@ -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.
diff --git a/contrib/mw-to-git/t/test-gitmw-lib.sh b/contrib/mw-to-git/t/test-gitmw-lib.sh
index a948f0c..36ac654 100755
--- a/contrib/mw-to-git/t/test-gitmw-lib.sh
+++ b/contrib/mw-to-git/t/test-gitmw-lib.sh
@@ -14,14 +14,151 @@
 . ./test.config
 
 export CURR_DIR=$(pwd)
-export TEST_DIRECTORY=$CURR_DIR/../../../t
+export TEST_DIRECTORY="$CURR_DIR"/../../../t
 
-if test $LIGHTTPD = "false" ; then
+if test "$LIGHTTPD" = "false" ; then
 	PORT=80
 else
 	WIKI_DIR_INST="$CURR_DIR/$WEB_WWW"
 fi
 
+
+wiki_getpage () {
+	"$CURR_DIR"/test-gitmw.pl get_page "$@"
+}
+
+wiki_delete_page () {
+	"$CURR_DIR"/test-gitmw.pl delete_page "$@"
+}
+
+wiki_editpage () {
+	"$CURR_DIR"/test-gitmw.pl edit_page "$@"
+}
+
+die () {
+	die_with_status 1 "$@"
+}
+
+die_with_status () {
+	status=$1
+	shift
+	echo >&2 "$*"
+	exit "$status"
+}
+
+
+# Check the preconditions to run git-remote-mediawiki's tests
+test_check_precond () {
+	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
+		echo "No remote mediawiki for git found. Copying it in git"
+		echo "cp $GIT_BUILD_DIR/contrib/mw-to-git/git-remote-mediawiki $GIT_BUILD_DIR/"
+		cp "$GIT_BUILD_DIR"/contrib/mw-to-git/git-remote-mediawiki "$GIT_BUILD_DIR"
+	fi
+
+	if [ ! -d "$WIKI_DIR_INST/$WIKI_DIR_NAME" ];
+	then
+		skip_all='skipping gateway git-mw tests, no mediawiki found'
+		test_done
+	fi
+}
+
+# test_diff_directories <dir_git> <dir_wiki>
+#
+# Compare the contents of directories <dir_git> and <dir_wiki> with diff
+# and errors if they do not match. The program will
+# not look into .git in the process.
+# Warning: the first argument MUST be the directory containing the git data
+test_diff_directories () {
+	rm -rf "$1_tmp"
+	mkdir -p "$1_tmp"
+	cp "$1"/*.mw "$1_tmp"
+	diff -r -b "$1_tmp" "$2"
+}
+
+# $1=<dir>
+# $2=<N>
+#
+# Check that <dir> contains exactly <N> files
+test_contains_N_files () {
+	test `ls "$1" | wc -l` -eq "$2";
+}
+
+
+# wiki_check_content <file_name> <page_name>
+#
+# Compares the contents of the file <file_name> and the wiki page
+# <page_name> and exits with error 1 if they do not match.
+wiki_check_content () {
+	mkdir -p wiki_tmp
+	wiki_getpage "$2" wiki_tmp
+	#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
+	then
+		rm -rf wiki_tmp
+		error "ERROR: file $2 not found on wiki"
+	fi
+	rm -rf wiki_tmp
+}
+
+# wiki_page_exist <page_name>
+#
+# Check the existence of the page <page_name> on the wiki and exits
+# with error if it is absent from it.
+wiki_page_exist () {
+	mkdir -p wiki_tmp
+	wiki_getpage "$1" wiki_tmp
+	page_name=$(printf "%s\n" "$1" | sed "s/\//%2F/g")
+	if test -f wiki_tmp/"$page_name".mw ; then
+		rm -rf wiki_tmp
+	else
+		rm -rf wiki_tmp
+		error "test failed: file $1 not found on wiki"
+	fi
+}
+
+# wiki_getallpagename
+#
+# Fetch the name of each page on the wiki.
+wiki_getallpagename () {
+	$CURR_DIR/test-gitmw.pl getallpagename
+}
+
+# wiki_getallpagecategory <category>
+#
+# Fetch the name of each page belonging to <category> on the wiki.
+wiki_getallpagecategory () {
+	$CURR_DIR/test-gitmw.pl getallpagename "$@"
+}
+
+# wiki_getallpage <dest_dir> [<category>]
+#
+# Fetch all the pages from the wiki and place them in the directory
+# <dest_dir>.
+# If <category> is define, then wiki_getallpage fetch the pages included
+# in <category>.
+wiki_getallpage () {
+	if test -z "$2";
+	then
+		wiki_getallpagename
+	else
+		wiki_getallpagecategory "$2"
+	fi
+	mkdir -p "$1"
+	while read -r line; do
+		wiki_getpage "$line" $1;
+	done < all.txt
+}
+
 # ================= Install part =================
 
 error () {
diff --git a/contrib/mw-to-git/t/test-gitmw.pl b/contrib/mw-to-git/t/test-gitmw.pl
new file mode 100755
index 0000000..e6c4adf
--- /dev/null
+++ b/contrib/mw-to-git/t/test-gitmw.pl
@@ -0,0 +1,209 @@
+#!/usr/bin/perl -w -s
+# Copyright (C) 2012
+#     Charles Roussel <charles.roussel@ensimag.imag.fr>
+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>
+#     Julien Khayat <julien.khayat@ensimag.imag.fr>
+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
+#     Simon Perrat <simon.perrat@ensimag.imag.fr>
+# License: GPL v2 or later
+
+# Usage:
+#       ./test-gitmw.pl <command> [argument]*
+# Execute in terminal using the name of the function to call as first
+# parameter, and the function's arguments as following parameters
+#
+# Example:
+#     ./test-gitmw.pl "get_page" foo .
+# will call <wiki_getpage> with arguments <foo> and <.>
+#
+# Available functions are:
+#     "get_page"
+#     "delete_page"
+#     "edit_page"
+#     "getallpagename"
+
+use MediaWiki::API;
+use Getopt::Long;
+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 my $CONFIG, "<",  $configfile or die "can't open $configfile: $!";
+while (<$CONFIG>)
+{
+        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');
+}
+close $CONFIG or die "can't close $configfile: $!";
+
+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;
+
+
+# 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";
+	}
+
+	$pagename=$page->{'title'};
+	# Replace spaces by underscore in the page name
+	$pagename =~ s/ /_/g;
+	$pagename =~ s/\//%2F/g;
+	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 = $_[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;
+
+wiki_login($wiki_admin,$wiki_admin_pass);
+
+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);
-- 
1.7.10.2.552.gaa3bb87

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv5 3/5] Test file for git-remote-mediawiki clone
  2012-06-13 17:03               ` [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki Simon Cathebras
  2012-06-13 17:03                 ` [PATCHv5 2/5] Test environment of git-remote-mediawiki Simon Cathebras
@ 2012-06-13 17:03                 ` Simon Cathebras
  2012-06-13 17:03                 ` [PATCHv5 4/5] Tests for git-remote-mediawiki pull and push Simon Cathebras
                                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 40+ messages in thread
From: Simon Cathebras @ 2012-06-13 17:03 UTC (permalink / raw)
  To: git
  Cc: gitster, peff, Guillaume Sasdy, Simon Cathebras, Simon Perrat,
	Charles Roussel, Julien Khayat, Matthieu Moy

From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>

This patch provides some tests for the clone in use by
git-remote-mediawiki.

Signed-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>
Signed-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>
Signed-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
Signed-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>
Signed-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@imag.fr>
---
 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

diff --git a/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh b/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh
new file mode 100755
index 0000000..4ab46f2
--- /dev/null
+++ b/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh
@@ -0,0 +1,250 @@
+#!/bin/sh
+#
+# Copyright (C) 2012
+#     Charles Roussel <charles.roussel@ensimag.imag.fr>
+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>
+#     Julien Khayat <julien.khayat@ensimag.imag.fr>
+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
+#     Simon Perrat <simon.perrat@ensimag.imag.fr>
+#
+# License: GPL v2 or later
+
+
+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
-- 
1.7.10.2.552.gaa3bb87

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv5 4/5] Tests for git-remote-mediawiki pull and push
  2012-06-13 17:03               ` [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki Simon Cathebras
  2012-06-13 17:03                 ` [PATCHv5 2/5] Test environment of git-remote-mediawiki Simon Cathebras
  2012-06-13 17:03                 ` [PATCHv5 3/5] Test file for git-remote-mediawiki clone Simon Cathebras
@ 2012-06-13 17:03                 ` Simon Cathebras
  2012-06-13 17:03                 ` [PATCHv5 5/5] Tests of UTF8 character with git-remote-mediawiki Simon Cathebras
                                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 40+ messages in thread
From: Simon Cathebras @ 2012-06-13 17:03 UTC (permalink / raw)
  To: git
  Cc: gitster, peff, Guillaume Sasdy, Simon Cathebras, Simon Perrat,
	Charles Roussel, Julien Khayat, Matthieu Moy

From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>

This patch provides a set of tests for the pull and push fonctionnality of
git-remote-mediawiki.

Signed-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>
Signed-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>
Signed-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
Signed-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>
Signed-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@imag.fr>
---
 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

diff --git a/contrib/mw-to-git/t/t9361-mw-to-git-push-pull.sh b/contrib/mw-to-git/t/t9361-mw-to-git-push-pull.sh
new file mode 100755
index 0000000..8cef764
--- /dev/null
+++ b/contrib/mw-to-git/t/t9361-mw-to-git-push-pull.sh
@@ -0,0 +1,167 @@
+#!/bin/sh
+#
+# Copyright (C) 2012
+#     Charles Roussel <charles.roussel@ensimag.imag.fr>
+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>
+#     Julien Khayat <julien.khayat@ensimag.imag.fr>
+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
+#     Simon Perrat <simon.perrat@ensimag.imag.fr>
+#
+# License: GPL v2 or later
+
+# tests for git-remote-mediawiki
+
+test_description='Test 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
-- 
1.7.10.2.552.gaa3bb87

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCHv5 5/5] Tests of UTF8 character with git-remote-mediawiki
  2012-06-13 17:03               ` [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki Simon Cathebras
                                   ` (2 preceding siblings ...)
  2012-06-13 17:03                 ` [PATCHv5 4/5] Tests for git-remote-mediawiki pull and push Simon Cathebras
@ 2012-06-13 17:03                 ` Simon Cathebras
  2012-06-14  8:57                 ` [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki Matthieu Moy
  2012-06-14  8:58                 ` Matthieu Moy
  5 siblings, 0 replies; 40+ messages in thread
From: Simon Cathebras @ 2012-06-13 17:03 UTC (permalink / raw)
  To: git
  Cc: gitster, peff, Simon Cathebras, Simon Perrat, Guillaume Sasdy,
	Charles Roussel, Julien Khayat, Matthieu Moy

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

Signed-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>
Signed-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>
Signed-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
Signed-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>
Signed-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@imag.fr>
---
 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

diff --git a/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh b/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh
new file mode 100755
index 0000000..ee7cc9e
--- /dev/null
+++ b/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh
@@ -0,0 +1,298 @@
+#!/bin/sh
+#
+# Copyright (C) 2012
+#     Charles Roussel <charles.roussel@ensimag.imag.fr>
+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>
+#     Julien Khayat <julien.khayat@ensimag.imag.fr>
+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
+#     Simon Perrat <simon.perrat@ensimag.imag.fr>
+#
+# License: GPL v2 or later
+
+# tests for git-remote-mediawiki
+
+test_description='Test git-mediawiki with special characters in filenames'
+
+. ./test-gitmw-lib.sh
+. $TEST_DIRECTORY/test-lib.sh
+
+
+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
-- 
1.7.10.2.552.gaa3bb87

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki
  2012-06-13 17:03               ` [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki Simon Cathebras
                                   ` (3 preceding siblings ...)
  2012-06-13 17:03                 ` [PATCHv5 5/5] Tests of UTF8 character with git-remote-mediawiki Simon Cathebras
@ 2012-06-14  8:57                 ` Matthieu Moy
  2012-06-14  8:57                   ` [PATCH 1/3] chmod -x test-gitmw-lib.sh Matthieu Moy
                                     ` (3 more replies)
  2012-06-14  8:58                 ` Matthieu Moy
  5 siblings, 4 replies; 40+ messages in thread
From: Matthieu Moy @ 2012-06-14  8:57 UTC (permalink / raw)
  To: git
  Cc: Simon.Cathebras, Julien.Khayat, Simon.Perrat, Charles.Roussel,
	Guillaume.Sasdy, 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 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

-- 
1.7.11.rc0.57.g84a04c7

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH 1/3] chmod -x test-gitmw-lib.sh
  2012-06-14  8:57                 ` [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki Matthieu Moy
@ 2012-06-14  8:57                   ` Matthieu Moy
  2012-06-14  8:57                   ` [PATCH 2/3] Coding style Matthieu Moy
                                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 40+ messages in thread
From: Matthieu Moy @ 2012-06-14  8:57 UTC (permalink / raw)
  To: git
  Cc: Simon.Cathebras, Julien.Khayat, Simon.Perrat, Charles.Roussel,
	Guillaume.Sasdy, Matthieu Moy


Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
 0 files changed
 mode change 100755 => 100644 contrib/mw-to-git/t/test-gitmw-lib.sh

diff --git a/contrib/mw-to-git/t/test-gitmw-lib.sh b/contrib/mw-to-git/t/test-gitmw-lib.sh
old mode 100755
new mode 100644
-- 
1.7.11.rc0.57.g84a04c7

^ permalink raw reply	[flat|nested] 40+ messages in thread

* [PATCH 2/3] Coding style
  2012-06-14  8:57                 ` [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki Matthieu Moy
  2012-06-14  8:57                   ` [PATCH 1/3] chmod -x test-gitmw-lib.sh Matthieu Moy
@ 2012-06-14  8:57                   ` Matthieu Moy
  2012-06-14  8:57                   ` [PATCH 3/3] Explicit error when curl_exec() fails Matthieu Moy
  2012-06-14  9:20                   ` [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki Simon.Cathebras
  3 siblings, 0 replies; 40+ messages in thread
From: Matthieu Moy @ 2012-06-14  8:57 UTC (permalink / raw)
  To: git
  Cc: Simon.Cathebras, Julien.Khayat, Simon.Perrat, Charles.Roussel,
	Guillaume.Sasdy, Matthieu Moy


Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
 contrib/mw-to-git/t/install-wiki/db_install.php | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/contrib/mw-to-git/t/install-wiki/db_install.php b/contrib/mw-to-git/t/install-wiki/db_install.php
index 3111c73..b34772a 100644
--- a/contrib/mw-to-git/t/install-wiki/db_install.php
+++ b/contrib/mw-to-git/t/install-wiki/db_install.php
@@ -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();
-- 
1.7.11.rc0.57.g84a04c7

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* [PATCH 3/3] Explicit error when curl_exec() fails
  2012-06-14  8:57                 ` [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki Matthieu Moy
  2012-06-14  8:57                   ` [PATCH 1/3] chmod -x test-gitmw-lib.sh Matthieu Moy
  2012-06-14  8:57                   ` [PATCH 2/3] Coding style Matthieu Moy
@ 2012-06-14  8:57                   ` Matthieu Moy
  2012-06-14  9:23                     ` Simon.Cathebras
  2012-06-14  9:20                   ` [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki Simon.Cathebras
  3 siblings, 1 reply; 40+ messages in thread
From: Matthieu Moy @ 2012-06-14  8:57 UTC (permalink / raw)
  To: git
  Cc: Simon.Cathebras, Julien.Khayat, Simon.Perrat, Charles.Roussel,
	Guillaume.Sasdy, Matthieu Moy


Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
 contrib/mw-to-git/t/install-wiki/db_install.php | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/contrib/mw-to-git/t/install-wiki/db_install.php b/contrib/mw-to-git/t/install-wiki/db_install.php
index b34772a..99d24e0 100644
--- a/contrib/mw-to-git/t/install-wiki/db_install.php
+++ b/contrib/mw-to-git/t/install-wiki/db_install.php
@@ -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;
 }
-- 
1.7.11.rc0.57.g84a04c7

^ permalink raw reply related	[flat|nested] 40+ messages in thread

* Re: [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki
  2012-06-13 17:03               ` [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki Simon Cathebras
                                   ` (4 preceding siblings ...)
  2012-06-14  8:57                 ` [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki Matthieu Moy
@ 2012-06-14  8:58                 ` Matthieu Moy
  5 siblings, 0 replies; 40+ messages in thread
From: Matthieu Moy @ 2012-06-14  8:58 UTC (permalink / raw)
  To: Simon Cathebras
  Cc: git, gitster, peff, Guillaume Sasdy, Simon Perrat,
	Charles Roussel, Julien Khayat

Simon Cathebras <simon.cathebras@ensimag.imag.fr> writes:

> +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);
> +        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.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki
  2012-06-14  8:57                 ` [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki Matthieu Moy
                                     ` (2 preceding siblings ...)
  2012-06-14  8:57                   ` [PATCH 3/3] Explicit error when curl_exec() fails Matthieu Moy
@ 2012-06-14  9:20                   ` Simon.Cathebras
  2012-06-14 16:17                     ` Matthieu Moy
  3 siblings, 1 reply; 40+ messages in thread
From: Simon.Cathebras @ 2012-06-14  9:20 UTC (permalink / raw)
  To: Matthieu Moy
  Cc: git, Julien.Khayat, Simon.Perrat, Charles.Roussel, Guillaume.Sasdy



On 14/06/2012 10:57, Matthieu Moy wrote:
> 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 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

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

> 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
>

-- 
CATHEBRAS Simon

2A-ENSIMAG

Filière Ingéniérie des Systèmes d'Information
Membre Bug-Buster

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 3/3] Explicit error when curl_exec() fails
  2012-06-14  8:57                   ` [PATCH 3/3] Explicit error when curl_exec() fails Matthieu Moy
@ 2012-06-14  9:23                     ` Simon.Cathebras
  2012-06-14 12:45                       ` Matthieu Moy
  0 siblings, 1 reply; 40+ messages in thread
From: Simon.Cathebras @ 2012-06-14  9:23 UTC (permalink / raw)
  To: Matthieu Moy
  Cc: git, Julien.Khayat, Simon.Perrat, Charles.Roussel, Guillaume.Sasdy



On 14/06/2012 10:57, Matthieu Moy wrote:
> Signed-off-by: Matthieu Moy<Matthieu.Moy@imag.fr>
> ---
>   contrib/mw-to-git/t/install-wiki/db_install.php | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/contrib/mw-to-git/t/install-wiki/db_install.php b/contrib/mw-to-git/t/install-wiki/db_install.php
> index b34772a..99d24e0 100644
> --- a/contrib/mw-to-git/t/install-wiki/db_install.php
> +++ b/contrib/mw-to-git/t/install-wiki/db_install.php
> @@ -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 ?

-- 
CATHEBRAS Simon

2A-ENSIMAG

Filière Ingéniérie des Systèmes d'Information
Membre Bug-Buster

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCH 3/3] Explicit error when curl_exec() fails
  2012-06-14  9:23                     ` Simon.Cathebras
@ 2012-06-14 12:45                       ` Matthieu Moy
  0 siblings, 0 replies; 40+ messages in thread
From: Matthieu Moy @ 2012-06-14 12:45 UTC (permalink / raw)
  To: Simon.Cathebras
  Cc: git, Julien.Khayat, Simon.Perrat, Charles.Roussel, Guillaume.Sasdy

"Simon.Cathebras" <Simon.Cathebras@ensimag.imag.fr> writes:

> 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)

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 40+ messages in thread

* Re: [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki
  2012-06-14  9:20                   ` [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki Simon.Cathebras
@ 2012-06-14 16:17                     ` Matthieu Moy
  0 siblings, 0 replies; 40+ messages in thread
From: Matthieu Moy @ 2012-06-14 16:17 UTC (permalink / raw)
  To: Simon.Cathebras
  Cc: git, Julien.Khayat, Simon.Perrat, Charles.Roussel, Guillaume.Sasdy

"Simon.Cathebras" <Simon.Cathebras@ensimag.imag.fr> writes:

> 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.

> url: https://github.com/Fafinou/git/wiki

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 <Matthieu.Moy@imag.fr>
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(-)

diff --git a/contrib/mw-to-git/t/Makefile b/contrib/mw-to-git/t/Makefile
index 752fd1f..0212b85 100644
--- a/contrib/mw-to-git/t/Makefile
+++ b/contrib/mw-to-git/t/Makefile
@@ -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'.*
diff --git a/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh b/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh
index ee7cc9e..0add2d5 100755
--- a/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh
+++ b/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh
@@ -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 &&
 	(
diff --git a/contrib/mw-to-git/t/test-gitmw-lib.sh b/contrib/mw-to-git/t/test-gitmw-lib.sh
index 36ac654..f444d1f 100644
--- a/contrib/mw-to-git/t/test-gitmw-lib.sh
+++ b/contrib/mw-to-git/t/test-gitmw-lib.sh
@@ -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
-- 
1.7.11.rc0.57.g84a04c7

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply related	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2012-06-14 16:17 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-11 20:27 [PATCH]Test environment for git-remote-mediawiki Simon.Cathebras
2012-06-11 20:28 ` [PATCHv3 1/6] Scripts to install, delete and clear a MediaWiki Simon Cathebras
2012-06-11 20:28   ` [PATCHv3 2/6] Test environment of git-remote-mediawiki Simon Cathebras
2012-06-11 20:28   ` [PATCHv3 3/6] Test file for git-remote-mediawiki clone Simon Cathebras
2012-06-11 21:07     ` konglu
2012-06-12 13:58       ` Simon.Cathebras
2012-06-11 20:28   ` [PATCHv3 4/6] Tests for git-remote-mediawiki pull Simon Cathebras
2012-06-11 21:09     ` konglu
2012-06-12 13:58       ` Simon Perrat
2012-06-12 21:12       ` [PATCH 1/6] Scripts to install, delete and clear a MediaWiki Simon Cathebras
2012-06-12 21:12         ` [PATCH 2/6] Test environment of git-remote-mediawiki Simon Cathebras
2012-06-13  7:56           ` Matthieu Moy
2012-06-13  8:10             ` Simon.Cathebras
2012-06-13 10:14           ` Ævar Arnfjörð Bjarmason
2012-06-13 17:00             ` Simon.Cathebras
2012-06-13 17:03               ` [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki Simon Cathebras
2012-06-13 17:03                 ` [PATCHv5 2/5] Test environment of git-remote-mediawiki Simon Cathebras
2012-06-13 17:03                 ` [PATCHv5 3/5] Test file for git-remote-mediawiki clone Simon Cathebras
2012-06-13 17:03                 ` [PATCHv5 4/5] Tests for git-remote-mediawiki pull and push Simon Cathebras
2012-06-13 17:03                 ` [PATCHv5 5/5] Tests of UTF8 character with git-remote-mediawiki Simon Cathebras
2012-06-14  8:57                 ` [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki Matthieu Moy
2012-06-14  8:57                   ` [PATCH 1/3] chmod -x test-gitmw-lib.sh Matthieu Moy
2012-06-14  8:57                   ` [PATCH 2/3] Coding style Matthieu Moy
2012-06-14  8:57                   ` [PATCH 3/3] Explicit error when curl_exec() fails Matthieu Moy
2012-06-14  9:23                     ` Simon.Cathebras
2012-06-14 12:45                       ` Matthieu Moy
2012-06-14  9:20                   ` [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki Simon.Cathebras
2012-06-14 16:17                     ` Matthieu Moy
2012-06-14  8:58                 ` Matthieu Moy
2012-06-12 21:12         ` [PATCH 3/6] Test file for git-remote-mediawiki clone Simon Cathebras
2012-06-12 21:34           ` konglu
2012-06-13  7:20             ` Simon.Cathebras
2012-06-12 21:12         ` [PATCH 4/6] Tests for git-remote-mediawiki pull and push Simon Cathebras
2012-06-12 21:12         ` [PATCH 5/6] Tests of UTF8 character with git-remote-mediawiki Simon Cathebras
2012-06-12 21:18           ` Simon.Cathebras
2012-06-12 21:52             ` konglu
2012-06-13  7:30               ` Simon.Cathebras
2012-06-12 21:45           ` konglu
2012-06-11 20:28   ` [PATCHv3 5/6] Test file for git-remote-mediawiki push Simon Cathebras
2012-06-11 20:28   ` =?y?q?=5BPATCHv3=206/6=5D=20Tests=20of=20UTF8=20character=20with=20git-remote-mediawiki?= Simon Cathebras

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).