git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Git-MediaWiki] Test environment for Git-MediaWiki
@ 2012-06-05 13:20 Simon.Cathebras
  2012-06-05 13:25 ` [PATCH 1/3] Script to install, delete and clear a MediaWiki Simon Cathebras
  0 siblings, 1 reply; 13+ messages in thread
From: Simon.Cathebras @ 2012-06-05 13:20 UTC (permalink / raw)
  To: git
  Cc: Matthieu Moy, julien.khayat, Simon PERRAT, Guillaume Sasdy,
	Charles Roussel, peff, gitster

Good afternoon,

This test environment is created to test the previously implemented 
git-remote-mediawiki, which was developped last year.
We created in this environment some functions to manipulate a MediaWiki. 
This way, it will be easier to build some tests for the Git-MediaWiki 
contribution.

This is our third version for this test environment. We have removed 
several errors in our code since the V1. Plus, we added some tests using 
our environment. We are now presenting our code for an inclusion into 
the P.U branch.

If you want to test our code, please have a look in this wiki : 
https://github.com/Fafinou/git/wiki .
And follow the instructions.

If you have any correction(s) proposal, please let us know, and we will 
fix them as soon as possible.
Thank you in advance for your attention ;).

Have a nice day.

Simon C, for the Team

--
CATHEBRAS Simon

2A-ENSIMAG

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

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

* [PATCH 1/3] Script to install, delete and clear a MediaWiki
  2012-06-05 13:20 [Git-MediaWiki] Test environment for Git-MediaWiki Simon.Cathebras
@ 2012-06-05 13:25 ` Simon Cathebras
  2012-06-05 13:25   ` [PATCH 2/3] Test environment of git-remote-mw Simon Cathebras
                     ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Simon Cathebras @ 2012-06-05 13:25 UTC (permalink / raw)
  To: git
  Cc: Matthieu.Moy, simon.cathebras, charles.roussel, Guillaume.Sasdy,
	Julien.Khayat, Simon.Perrat, peff, gitster, Guillaume Sasdy,
	Julien Khayat, Simon Perrat, 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 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: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
Signed-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>
Signed-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>
Signed-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@imag.fr>
---
 t/install-wiki.sh                |  38 ++++++++++
 t/install-wiki/LocalSettings.php | 129 ++++++++++++++++++++++++++++++++
 t/install-wiki/db_install.php    | 110 ++++++++++++++++++++++++++++
 t/test-gitmw-lib.sh              | 154 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 431 insertions(+)
 create mode 100755 t/install-wiki.sh
 create mode 100644 t/install-wiki/LocalSettings.php
 create mode 100644 t/install-wiki/db_install.php
 create mode 100755 t/test-gitmw-lib.sh
 mode change 100644 => 100755 t/test-lib-functions.sh
 mode change 100644 => 100755 t/test-lib.sh

diff --git a/t/install-wiki.sh b/t/install-wiki.sh
new file mode 100755
index 0000000..322f46d
--- /dev/null
+++ b/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/t/install-wiki/LocalSettings.php b/t/install-wiki/LocalSettings.php
new file mode 100644
index 0000000..c2fe3d5
--- /dev/null
+++ b/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/t/install-wiki/db_install.php b/t/install-wiki/db_install.php
new file mode 100644
index 0000000..bd7a075
--- /dev/null
+++ b/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/t/test-gitmw-lib.sh b/t/test-gitmw-lib.sh
new file mode 100755
index 0000000..cebef24
--- /dev/null
+++ b/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
+                die "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" ||
+                die "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
+                die "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" ||
+                        die "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/" ||
+                die "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
+                die "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" ||
+                die "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" ||
+                die "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
+                die "Can't find ../$FILES_FOLDER/$DB_FILE in the current folder."
+        fi
+        cp "../$FILES_FOLDER/$DB_FILE" "$TMP" ||
+                die "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" ||
+		die "Wiki's directory $WIKI_DIR_INST/" \
+		"$WIKI_DIR_NAME could not be deleted"
+
+	# Delete the wiki's SQLite database
+	rm -f "$TMP/$DB_FILE" || die "Database $TMP/$DB_FILE could not be deleted."
+}
+
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
old mode 100644
new mode 100755
diff --git a/t/test-lib.sh b/t/test-lib.sh
old mode 100644
new mode 100755
-- 
1.7.10.2.552.gaa3bb87

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

* [PATCH 2/3] Test environment of git-remote-mw
  2012-06-05 13:25 ` [PATCH 1/3] Script to install, delete and clear a MediaWiki Simon Cathebras
@ 2012-06-05 13:25   ` Simon Cathebras
  2012-06-05 13:25   ` [PATCH 3/3] Tests file for git-remote-mediawiki Simon Cathebras
  2012-06-05 16:48   ` [PATCH 1/3] Script to install, delete and clear a MediaWiki Junio C Hamano
  2 siblings, 0 replies; 13+ messages in thread
From: Simon Cathebras @ 2012-06-05 13:25 UTC (permalink / raw)
  To: git
  Cc: Matthieu.Moy, simon.cathebras, charles.roussel, Guillaume.Sasdy,
	Julien.Khayat, Simon.Perrat, peff, gitster, Guillaume Sasdy,
	Julien Khayat, Simon Perrat, 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.

Signed-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>
Signed-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
Signed-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>
Signed-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>
Signed-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@imag.fr>
---
 t/test-gitmw-lib.sh | 105 +++++++++++++++++++++++++++++++
 t/test-gitmw.pl     | 176 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 281 insertions(+)
 create mode 100755 t/test-gitmw.pl

diff --git a/t/test-gitmw-lib.sh b/t/test-gitmw-lib.sh
index cebef24..cb5ba19 100755
--- a/t/test-gitmw-lib.sh
+++ b/t/test-gitmw-lib.sh
@@ -26,6 +26,111 @@ DB_INSTALL_SCRIPT="db_install.php"
 WIKI_ADMIN="WikiAdmin"
 WIKI_PASSW="AdminPass"
 
+wiki_getpage () {
+	$GIT_BUILD_DIR/t/test-gitmw.pl get_page "$@"
+}
+
+wiki_delete_page () {
+	$GIT_BUILD_DIR/t/test-gitmw.pl delete_page "$@"
+}
+
+wiki_editpage () {
+	$GIT_BUILD_DIR/t/test-gitmw.pl edit_page "$@"
+}
+
+die () {
+	die_with_status 1 "$@"
+}
+
+die_with_status () {
+	status=$1
+	shift
+	echo >&2 "$*"
+	exit "$status"
+}
+
+# git_diff_directories <dir_git> <dir_wiki>
+#
+# Compare the contents of directories <dir_git> and <dir_wiki> with diff
+# and dies 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
+git_diff_directories () {
+	mkdir -p "$1_tmp"
+	cp "$1"/*.mw "$1_tmp"
+
+	diff -r -b "$1_tmp" "$2"
+
+	if test $? -ne 0
+	then
+		rm -rf "$1_tmp"
+		die "test failed: directories $1 and $2 do not match"
+	fi
+	rm -rf "$1_tmp"
+}
+
+
+# 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
+	diff -b "$1" wiki_tmp/"$2".mw
+	if test $? -ne 0
+	then
+		rm -rf wiki_tmp
+		die "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 () {
+	wiki_getpage "$1" .
+
+	if test -f "$1".mw ; then
+		rm "$1".mw
+	else
+		die "test failed: file $1 not found on wiki"
+	fi
+}
+
+# wiki_getallpagename
+# 
+# Fetch the name of each page on the wiki.
+wiki_getallpagename () {
+	$GIT_BUILD_DIR/t/test-gitmw.pl getallpagename
+}
+
+# wiki_getallpagecategory <category>
+# 
+# Fetch the name of each page belonging to <category> on the wiki.
+wiki_getallpagecategory () {
+	$GIT_BUILD_DIR/t/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/t/test-gitmw.pl b/t/test-gitmw.pl
new file mode 100755
index 0000000..ff7f63e
--- /dev/null
+++ b/t/test-gitmw.pl
@@ -0,0 +1,176 @@
+#!/usr/bin/perl -w
+# 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 Switch;
+# 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;
+
+# 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=~s/\ /_/;
+	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> [<category>]
+#
+# 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 $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($_[3])) {
+		my $category_name="[[Category:$_[3]]]";
+		$text="$text\n $category_name"
+	}
+	$mw->edit( { action => 'edit', title => $wiki_page, 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])) {
+		$mw->list ( { action => 'query',
+				list => 'categorymembers',
+				cmtitle => "Category:$_[0]",
+				cmnamespace => 0,
+				cmlimit=> 500 },
+			{ max => 4, hook => \&cat_names } )
+			|| die $mw->{error}->{code}.": ".$mw->{error}->{details};
+	} else {
+		$mw->list ( { action => 'query',
+				list => 'allpages',
+				#cmnamespace => 0,
+				cmlimit=> 500 },
+			{ max => 4, hook => \&cat_names } )
+			|| die $mw->{error}->{code}.": ".$mw->{error}->{details};
+	}
+	# print the name of each page
+	sub cat_names {
+		my ($ref) = @_;
+
+		open(my $file, ">all.txt");
+		foreach (@$ref) {
+			print $file "$_->{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] 13+ messages in thread

* [PATCH 3/3] Tests file for git-remote-mediawiki
  2012-06-05 13:25 ` [PATCH 1/3] Script to install, delete and clear a MediaWiki Simon Cathebras
  2012-06-05 13:25   ` [PATCH 2/3] Test environment of git-remote-mw Simon Cathebras
@ 2012-06-05 13:25   ` Simon Cathebras
  2012-06-06 20:18     ` Matthieu Moy
  2012-06-05 16:48   ` [PATCH 1/3] Script to install, delete and clear a MediaWiki Junio C Hamano
  2 siblings, 1 reply; 13+ messages in thread
From: Simon Cathebras @ 2012-06-05 13:25 UTC (permalink / raw)
  To: git
  Cc: Matthieu.Moy, simon.cathebras, charles.roussel, Guillaume.Sasdy,
	Julien.Khayat, Simon.Perrat, peff, gitster, Charles Roussel,
	Guillaume Sasdy, Julien Khayat, Simon Perrat, Matthieu Moy

From: Charles Roussel <charles.roussel@ensimag.fr>

Those scripts test the functions of git-remote-mediawiki.
t9360: test cases for git clone. Including tests of cloning just a category, just a precise set of page and a classical use of clone on the whole wiki.
In addition, this file provide now some fonction du manipulate sections on wiki.
We can now create a page or edit it, to put it in a given category of the wiki.
t9361: test cases for git pull (add page, edit page, delete page) and git push (add file, edit file, delete file).

Signed-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>
Signed-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
Signed-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>
Signed-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>
Signed-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>
Signed-off-by: Matthieu Moy <matthieu.moy@imag.fr>
---
 t/t9360-git-mediawiki.sh | 265 +++++++++++++++++++++++++++++++++++++++++++++++
 t/t9361-git-mediawiki.sh | 213 +++++++++++++++++++++++++++++++++++++
 2 files changed, 478 insertions(+)
 create mode 100755 t/t9360-git-mediawiki.sh
 create mode 100755 t/t9361-git-mediawiki.sh

diff --git a/t/t9360-git-mediawiki.sh b/t/t9360-git-mediawiki.sh
new file mode 100755
index 0000000..c13d63b
--- /dev/null
+++ b/t/t9360-git-mediawiki.sh
@@ -0,0 +1,265 @@
+#!/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 clone'
+
+. ./test-gitmw-lib.sh
+. ./test-lib.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
+
+
+# clone a empty wiki and check that the repository contains only Main_Page.mw
+test_expect_success 'git clone only create  Main_Page.mw with an empty wiki' '
+        wiki_reset &&
+        git clone mediawiki::http://localhost/wiki mw_dir &&
+        test_expect_code 0 ls mw_dir | wc -l | grep 1 &&
+        test_expect_code 0 test -e mw_dir/Main_Page.mw &&
+        rm -rf mw_dir
+'          
+
+# clone a wiki where a page has been added and then deleted
+# check that the page no longer exists
+test_expect_success 'git clone only create Main_Page.mw with a wiki with no other pages ' '
+        wiki_reset &&
+        wiki_editpage foo "this page must be delete before the clone" false &&
+        wiki_delete_page foo &&
+        git clone mediawiki::http://localhost/wiki mw_dir &&
+        test `ls mw_dir | wc -l` -eq 1 &&
+        test -e mw_dir/Main_Page.mw &&
+        test ! -e mw_dir/Foo.mw &&
+        rm -rf mw_dir
+'
+
+# clone a wiki with a new page on it
+# check that the file corresponding to the page is in the repository
+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://localhost/wiki mw_dir &&
+	wiki_getallpage ref_page &&
+	git_diff_directories mw_dir ref_page &&
+	wiki_delete_page foo &&
+	rm -rf mw_dir &&
+	rm -rf ref_page &&
+	wiki_delete_page bar
+'
+
+
+# clone a wiki after a page has been added then edited once
+# check that the content is correct
+test_expect_success 'git clone works with an edited page ' '
+        wiki_reset &&
+        wiki_editpage foo "this page will be edited" false &&
+        wiki_editpage foo "this page has been edited and must be on the clone " false &&
+        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 &&
+        git_diff_directories mw_dir mw_dir/page_ref &&
+        rm -rf mw_dir
+'          
+
+# clone a wiki with several pages where some were delete
+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://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 &&
+        git_diff_directories mw_dir mw_dir/page_ref &&
+        rm -rf mw_dir
+'          
+
+
+
+
+# clone only one page of the wiki
+# check that it is the only page cloned
+# check that the page and the clone a identical
+test_expect_success 'git clone works 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 &&
+        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 `ls mw_dir | wc -l` -eq 1 &&
+        test -e mw_dir/Namnam.mw &&
+        test ! -e mw_dir/Main_Page.mw &&
+        wiki_check_content mw_dir/Namnam.mw Namnam &&
+        rm -rf mw_dir
+'   
+
+
+# clone multiple specific pages of the wiki
+# check that there are the only page cloned
+# check that the pages and the clone a identical
+test_expect_success 'git clone works 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://localhost/wiki mw_dir &&
+        test `ls mw_dir | wc -l` -eq 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
+'  
+
+# Tests that cloning some specific pages from a larger wiki works properly
+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 &&
+	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 &&
+	git_diff_directories mw_dir_spage ref_page &&
+	rm -rf mw_dir_spage &&
+	rm -rf ref_page
+'
+
+
+# use git clone with the shallow option
+# check that only the last revisions are cloned
+# i.e the log only contains 1 commit per page
+test_expect_success 'git clone works with the shallow option' '
+        wiki_reset &&
+        wiki_editpage foo "1st revision, should be cloned" &&
+        wiki_editpage bar "1st revision, should be cloned" &&
+        wiki_editpage nyan "1st revision, should not be cloned" &&
+        wiki_editpage nyan "2nd revision, should be cloned" &&
+        git -c remote.origin.shallow=true clone mediawiki::http://localhost/wiki/ mw_dir &&
+        test `ls mw_dir | wc -l` -eq 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
+'
+
+# use git clone with the shallow option
+# check that only the last revisions are cloned
+# i.e the log only contains 1 commit per page
+# in this case we have a delete 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" &&
+        wiki_editpage bar "1st revision, should be cloned" &&
+        wiki_editpage nyan "1st revision, should not be cloned" &&
+        wiki_editpage nyan "2nd revision, should be cloned" &&
+        wiki_delete_page foo &&
+        git -c remote.origin.shallow=true clone mediawiki::http://localhost/wiki/ mw_dir &&
+        test `ls mw_dir | wc -l` -eq 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
+'
+
+
+# clone a category
+# check that only this category has been cloned
+test_expect_success 'test of fetching a category' '
+	wiki_reset &&
+	wiki_editpage Foo "I will be cloned" false Category &&
+	wiki_editpage Bar "Meet me on the repository" false Category &&
+	wiki_editpage Dummy "I will not come" false &&
+	wiki_editpage BarWrong "I will stay online only" false NotCategory &&
+	git clone -c remote.origin.categories="Category" mediawiki::http://localhost/wiki mw_dir &&
+	wiki_getallpage ref_page Category &&
+	git_diff_directories mw_dir ref_page
+        rm -rf mw_dir &&
+        rm -rf ref_page
+'
+
+# Test of cloning a category on wiki. 
+# This category has been previously edited in some ways
+# like edition of a given page and deletion of another.
+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 Catone &&
+	wiki_editpage Tobeedited "this page will be modified" false Catone &&
+	wiki_editpage Normalone "this page wont be modified and will be on git" false Catone &&
+	wiki_editpage Notconsidered "this page will not appears on local" false &&
+	wiki_editpage Othercategory "this page will not appears on local" false Cattwo &&
+	wiki_editpage Tobeedited "this page have been modified" true Catone &&
+	wiki_delete_page Tobedeleted
+	git clone -c remote.origin.categories="Catone" mediawiki::http://localhost/wiki mw_dir &&
+	wiki_getallpage ref_page Catone &&
+	git_diff_directories mw_dir ref_page &&
+	rm -rf mw_dir &&
+	rm -rf ref_page 
+'
+
+test_done
diff --git a/t/t9361-git-mediawiki.sh b/t/t9361-git-mediawiki.sh
new file mode 100755
index 0000000..a44978c
--- /dev/null
+++ b/t/t9361-git-mediawiki.sh
@@ -0,0 +1,213 @@
+#!/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-lib.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
+
+# Create a new file foo.mw in a freshly cloned wiki. Commit and push
+# this file and then check that all files of the repository are similar to
+# the wiki pages.
+test_expect_success 'git push works after adding a file .mw' "
+        wiki_reset &&
+        git clone mediawiki::http://$SERVER_ADDR/$WIKI_DIR_NAME mw_dir &&
+        wiki_getallpage ref_page &&
+
+        cd mw_dir &&
+        test ! -f Foo.mw && # Foo.mw should not exist after wiki_reset &&
+        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 &&
+        git_diff_directories mw_dir ref_page &&
+        rm -rf ref_page &&
+        rm -rf mw_dir
+"
+
+# Create a new page Foo in an empty wiki. Clone the wiki and edit
+# the file foo.mw corresponding to the page Foo. Commit and push
+# then check that all files of the repository are similar to the wiki
+# pages.
+test_expect_success 'git push works after editing a file .mw' "
+        # clone an empty wiki and add a Foo page
+        wiki_reset &&
+        wiki_editpage \"Foo\" \"page just 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 &&
+        git_diff_directories mw_dir ref_page &&
+        rm -rf ref_page &&
+        rm -rf mw_dir
+"
+
+# Clone a wiki with a page Foo. Remove the corresponding file from the
+# repository. Check that the wiki page has been actually removed.
+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/$WIKI_DIR_NAME mw_dir &&
+
+        cd mw_dir &&
+        git rm Foo.mw &&
+        git commit -am \"git rm delete the wiki page Foo.mw\" &&
+        git push &&
+        cd .. &&
+
+        rm -rf mw_dir &&
+        test ! wiki_page_exist Foo
+"
+
+# Clone an empty wiki. Add a page on the wiki and pull. Check 
+# all files of the repository are similar to the wiki pages.
+test_expect_success 'git pull works after adding a new wiki page' "
+        wiki_reset &&
+        git clone mediawiki::http://$SERVER_ADDR/$WIKI_DIR_NAME mw_dir &&
+        wiki_editpage Foo \"page just created after the git clone\" false &&
+
+        cd mw_dir &&
+        git pull &&
+        cd .. &&
+
+        rm -rf ref_page &&
+        wiki_getallpage ref_page &&
+        git_diff_directories mw_dir ref_page &&
+        rm -rf ref_page &&
+        rm -rf mw_dir
+"
+
+# Clone a wiki with a page Foo. Edit the page foo on the wiki and pull.
+# Check that all files of the repository are similar to the wiki pages.
+test_expect_success 'git pull works after editing a wiki page' "
+        wiki_reset &&
+        wiki_editpage Foo \"page just 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 &&
+        git_diff_directories mw_dir ref_page &&
+        rm -rf ref_page &&
+        rm -rf mw_dir
+"
+
+# Clone a wiki with a page Foo. Edit both the page Foo on the wiki and the file
+# Foo.mw on git, then check that merge conflict is properly coped with.
+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/$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
+"
+
+# The two following tests generate a merge conflict, and then handle it
+# manually
+test_expect_success 'Merge conflict expected' "
+        wiki_reset &&
+        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\" &&
+        test_must_fail git pull
+"
+
+test_expect_success 'Conflict solved manually' "
+        cat Foo.mw | sed '/[<=>][^$]*/ d' > Foo.mw~ &&
+        cat Foo.mw~ > Foo.mw &&
+        git commit -am \"merge conflict\" &&
+        git push &&
+
+        cd .. &&
+        rm -rf mw_dir
+"
+
+# Clone a wiki with a page Foo. Remove the wiki page and pull.
+# Check that the corresponding file in the repository has been actually removed.
+test_expect_failure 'git pull works after deleting a wiki page' "
+        wiki_reset &&
+        wiki_editpage Foo \"wiki page added before 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] 13+ messages in thread

* Re: [PATCH 1/3] Script to install, delete and clear a MediaWiki
  2012-06-05 13:25 ` [PATCH 1/3] Script to install, delete and clear a MediaWiki Simon Cathebras
  2012-06-05 13:25   ` [PATCH 2/3] Test environment of git-remote-mw Simon Cathebras
  2012-06-05 13:25   ` [PATCH 3/3] Tests file for git-remote-mediawiki Simon Cathebras
@ 2012-06-05 16:48   ` Junio C Hamano
  2012-06-06 13:49     ` Simon.Cathebras
  2 siblings, 1 reply; 13+ messages in thread
From: Junio C Hamano @ 2012-06-05 16:48 UTC (permalink / raw)
  To: Simon Cathebras
  Cc: git, Matthieu.Moy, charles.roussel, Guillaume.Sasdy,
	Julien.Khayat, Simon.Perrat, peff

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

> 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 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: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
> Signed-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>
> Signed-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>
> Signed-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>
> Signed-off-by: Matthieu Moy <matthieu.moy@imag.fr>
> ---
>  t/install-wiki.sh                |  38 ++++++++++
>  t/install-wiki/LocalSettings.php | 129 ++++++++++++++++++++++++++++++++
>  t/install-wiki/db_install.php    | 110 ++++++++++++++++++++++++++++
>  t/test-gitmw-lib.sh              | 154 +++++++++++++++++++++++++++++++++++++++

Hrm, I see my name on the Cc: list, but is this meant to go into my tree?

The t/ directory is a very strange place to put an installation
procedure for anything.  Is this because later test scripts that
test mw-to-git gateway need to have a mediawiki instance that runs
locally?

I am wondering why it is not sufficient to structure the MediaWiki
related tests more like existing tests that require a running HTTP
server, namely, t/lib-httpd.sh that allows such tests to proceed
only if a suitable server is available, but we do not ship a script
to install Apache for that.

>  mode change 100644 => 100755 t/test-lib-functions.sh
>  mode change 100644 => 100755 t/test-lib.sh

Why?

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

* Re: [PATCH 1/3] Script to install, delete and clear a MediaWiki
  2012-06-05 16:48   ` [PATCH 1/3] Script to install, delete and clear a MediaWiki Junio C Hamano
@ 2012-06-06 13:49     ` Simon.Cathebras
  0 siblings, 0 replies; 13+ messages in thread
From: Simon.Cathebras @ 2012-06-06 13:49 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: git, Matthieu.Moy, charles.roussel, Guillaume.Sasdy,
	Julien.Khayat, Simon.Perrat, peff



On 05/06/2012 18:48, Junio C Hamano wrote:
> Simon Cathebras<simon.cathebras@ensimag.imag.fr>  writes:
>
>> 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 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: Guillaume Sasdy<guillaume.sasdy@ensimag.imag.fr>
>> Signed-off-by: Julien Khayat<julien.khayat@ensimag.imag.fr>
>> Signed-off-by: Simon Perrat<simon.perrat@ensimag.imag.fr>
>> Signed-off-by: Charles Roussel<charles.roussel@ensimag.imag.fr>
>> Signed-off-by: Matthieu Moy<matthieu.moy@imag.fr>
>> ---
>>   t/install-wiki.sh                |  38 ++++++++++
>>   t/install-wiki/LocalSettings.php | 129 ++++++++++++++++++++++++++++++++
>>   t/install-wiki/db_install.php    | 110 ++++++++++++++++++++++++++++
>>   t/test-gitmw-lib.sh              | 154 +++++++++++++++++++++++++++++++++++++++
> Hrm, I see my name on the Cc: list, but is this meant to go into my tree?

Yes, but we would like to apologize for the poor choice of word. It would
be more correct to say that we are proposing to you an improvement for
git-remote-mediawiki, currently in git/contrib/mw-to-git/t.
This improvement is actually a test environment for git-remote-mediawiki.



> The t/ directory is a very strange place to put an installation
> procedure for anything.

Sorry again, we intended to move our test environment from t/ to *PATH*.
Unfortunately, we made a wrong manipulation and we couldn't solve this
issue. But it will be fixed in the next patch.



>    Is this because later test scripts that
> test mw-to-git gateway need to have a mediawiki instance that runs
> locally?

Exactly.


>
> I am wondering why it is not sufficient to structure the MediaWiki
> related tests more like existing tests that require a running HTTP
> server, namely, t/lib-httpd.sh that allows such tests to proceed
> only if a suitable server is available, but we do not ship a script
> to install Apache for that.

Actually, we are providing an install script for a MediaWiki, because we
need some specific configurations on it to run all the tests correctly. Without forget to mention that our test are creating several page on the wiki used for the tests, and reset it several times... It wouldn't be realy smart to use a real and realy used wiki to test git-mw. As a
matter of fact, it is easier to create a script than providing a complex
documentation on "how to install our specific mediawiki" for the user.
In addition, we are providing function of reset and deletion on the
mediawiki, for purpose of tests. And it is impossible to do if we do not
install it ourselves.
Anyway, it is possible to skip those tests if a wiki is not intalled.
For all those reason, we believe that we must keep this script to install a wiki in our code.



>>   mode change 100644 =>  100755 t/test-lib-functions.sh
>>   mode change 100644 =>  100755 t/test-lib.sh
> Why?


A wrong manipulation during the development: chmod +x on those file... We
have forgotten to correct it. Correction in the next patch.

-- 
CATHEBRAS Simon

2A-ENSIMAG

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

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

* Re: [PATCH 3/3] Tests file for git-remote-mediawiki
  2012-06-05 13:25   ` [PATCH 3/3] Tests file for git-remote-mediawiki Simon Cathebras
@ 2012-06-06 20:18     ` Matthieu Moy
  2012-06-08  8:04       ` Simon.Cathebras
  0 siblings, 1 reply; 13+ messages in thread
From: Matthieu Moy @ 2012-06-06 20:18 UTC (permalink / raw)
  To: Simon Cathebras
  Cc: git, charles.roussel, Guillaume.Sasdy, Julien.Khayat,
	Simon.Perrat, peff, gitster, Charles Roussel

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

> From: Charles Roussel <charles.roussel@ensimag.fr>
>
> Those scripts test the functions of git-remote-mediawiki.
> t9360: test cases for git clone. Including tests of cloning just a category, just a precise set of page and a classical use of clone on the whole wiki.

Avoid long lines in code and commit messages (80 columns max)

> In addition, this file provide now some fonction du manipulate sections on wiki.

s/du/to/

> t9361: test cases for git pull (add page, edit page, delete page) and git push (add file, edit file, delete file).

When commis messages start looking like an enumeration, it usually means
that either you read the GNU recommandation for ChangeLogs too much, or
that you should split your commit (not mandatory here I think, but short
patches are easier to review).

> +# tests for git-remote-mediawiki
> +
> +test_description='Test the Git Mediawiki remote helper: git clone'

Why do you need a comment if you have the test_description right below?

> +if [ ! -f /$GIT_BUILD_DIR/git-remote-mediawiki ];

Why / in front of $GIT_BUILD_DIR/ ?

> +        test_expect_code 0 ls mw_dir | wc -l | grep 1 &&
> +        test_expect_code 0 test -e mw_dir/Main_Page.mw &&

Why "test_expect_code 0"? You already have && right?

Doesn't a directory containing 10 files pass the tests?

You probably want a helper function test_contains_N_files <dir> <N> that
does test `ls mw_dir | wc -l` -eq 1 as you did below, but may give a
diagnosis when the test fails.

> +test_expect_success 'git clone only create Main_Page.mw with a wiki with no other pages ' '
> +        wiki_reset &&
> +        wiki_editpage foo "this page must be delete before the clone" false &&

s/delete/deleted/

> +	git_diff_directories mw_dir ref_page &&

functions in tests are usually prefixed with test_ instead.

> +# clone a wiki after a page has been added then edited once
> +# check that the content is correct

It's not sufficient. You should check also that the history is correct.

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

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

* Re: [PATCH 3/3] Tests file for git-remote-mediawiki
  2012-06-06 20:18     ` Matthieu Moy
@ 2012-06-08  8:04       ` Simon.Cathebras
  2012-06-08  8:57         ` Matthieu Moy
  0 siblings, 1 reply; 13+ messages in thread
From: Simon.Cathebras @ 2012-06-08  8:04 UTC (permalink / raw)
  To: Matthieu Moy
  Cc: git, charles.roussel, Guillaume.Sasdy, Julien.Khayat,
	Simon.Perrat, peff, gitster, Charles Roussel



On 06/06/2012 22:18, Matthieu Moy wrote:
> Simon Cathebras<simon.cathebras@ensimag.imag.fr>  writes:
>
>> From: Charles Roussel<charles.roussel@ensimag.fr>
>>
>> Those scripts test the functions of git-remote-mediawiki.
>> t9360: test cases for git clone. Including tests of cloning just a category, just a precise set of page and a classical use of clone on the whole wiki.
> Avoid long lines in code and commit messages (80 columns max)
Understood, it will be corrected in the next patch.
>
>> In addition, this file provide now some fonction du manipulate sections on wiki.
> s/du/to/
>
>> t9361: test cases for git pull (add page, edit page, delete page) and git push (add file, edit file, delete file).
> When commis messages start looking like an enumeration, it usually means
> that either you read the GNU recommandation for ChangeLogs too much, or
> that you should split your commit (not mandatory here I think, but short
> patches are easier to review).
Do you mean that we should split the third patch into two patches ? For 
instance::
     Patch 3/4: tests for git pull
     Patch 4/4: tests for git push
>
>> +# tests for git-remote-mediawiki
>> +
>> +test_description='Test the Git Mediawiki remote helper: git clone'
> Why do you need a comment if you have the test_description right below?
Deleted.
>
>> +if [ ! -f /$GIT_BUILD_DIR/git-remote-mediawiki ];
> Why / in front of $GIT_BUILD_DIR/ ?
Good point, we didn't noticed it ...
>> +        test_expect_code 0 ls mw_dir | wc -l | grep 1&&
>> +        test_expect_code 0 test -e mw_dir/Main_Page.mw&&
> Why "test_expect_code 0"? You already have&&  right?
Yes, we haven't realised it wasn't necessary.
We have corrected other errors like this one in our tests.
> Doesn't a directory containing 10 files pass the tests?
>
> You probably want a helper function test_contains_N_files<dir>  <N>  that
> does test `ls mw_dir | wc -l` -eq 1 as you did below, but may give a
> diagnosis when the test fails.
Done, and replace within the existing code.
>> +test_expect_success 'git clone only create Main_Page.mw with a wiki with no other pages ' '
>> +        wiki_reset&&
>> +        wiki_editpage foo "this page must be delete before the clone" false&&
> s/delete/deleted/
>> +	git_diff_directories mw_dir ref_page&&
> functions in tests are usually prefixed with test_ instead.
Fair enough. We have changed the function's name. Should we add such 
prefix on functions like wiki_reset or wiki_delete page ?
>> +# clone a wiki after a page has been added then edited once
>> +# check that the content is correct
> It's not sufficient. You should check also that the history is correct.
>
Test is now correct.

Thanks for the advices ;).

-- 
CATHEBRAS Simon

2A-ENSIMAG

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

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

* Re: [PATCH 3/3] Tests file for git-remote-mediawiki
  2012-06-08  8:04       ` Simon.Cathebras
@ 2012-06-08  8:57         ` Matthieu Moy
  2012-06-08  9:04           ` Simon Perrat
  0 siblings, 1 reply; 13+ messages in thread
From: Matthieu Moy @ 2012-06-08  8:57 UTC (permalink / raw)
  To: Simon.Cathebras
  Cc: git, charles.roussel, Guillaume.Sasdy, Julien.Khayat,
	Simon.Perrat, peff, gitster, Charles Roussel

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

> On 06/06/2012 22:18, Matthieu Moy wrote:
>> Simon Cathebras<simon.cathebras@ensimag.imag.fr>  writes:
>>
>>> From: Charles Roussel<charles.roussel@ensimag.fr>
>>>
>>> Those scripts test the functions of git-remote-mediawiki.
>>> t9360: test cases for git clone. Including tests of cloning just a category, just a precise set of page and a classical use of clone on the whole wiki.
>> Avoid long lines in code and commit messages (80 columns max)
> Understood, it will be corrected in the next patch.

Detail: in emails, people generally leave blank lines to separate
paragraphs, and in particular to separate one's own text from citation.
Compare my response

  http://thread.gmane.org/gmane.comp.version-control.git/199238/focus=199349

to yours to see what I mean

  http://thread.gmane.org/gmane.comp.version-control.git/199238/focus=199468

> Do you mean that we should split the third patch into two patches ?
> For instance::
>     Patch 3/4: tests for git pull
>     Patch 4/4: tests for git push

Yes, except the title should mention git-remote-mediawiki, of course.

>>> +test_expect_success 'git clone only create Main_Page.mw with a wiki with no other pages ' '
>>> +        wiki_reset&&
>>> +        wiki_editpage foo "this page must be delete before the clone" false&&
>> s/delete/deleted/
>>> +	git_diff_directories mw_dir ref_page&&
>> functions in tests are usually prefixed with test_ instead.
> Fair enough. We have changed the function's name. Should we add such
> prefix on functions like wiki_reset or wiki_delete page ?

I don't think so. They're not very specific to testing indeed, and
really are specific to the wiki OTOH.

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

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

* Re: [PATCH 3/3] Tests file for git-remote-mediawiki
  2012-06-08  8:57         ` Matthieu Moy
@ 2012-06-08  9:04           ` Simon Perrat
  2012-06-08  9:08             ` Matthieu Moy
  0 siblings, 1 reply; 13+ messages in thread
From: Simon Perrat @ 2012-06-08  9:04 UTC (permalink / raw)
  To: Matthieu Moy
  Cc: Simon.Cathebras, git, charles.roussel, Guillaume.Sasdy,
	Julien.Khayat, peff, gitster, Charles Roussel

2012/6/8 Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
>
> "Simon.Cathebras" <Simon.Cathebras@ensimag.imag.fr> writes:
> > Do you mean that we should split the third patch into two patches ?
> > For instance::
> >     Patch 3/4: tests for git pull
> >     Patch 4/4: tests for git push
>
> Yes, except the title should mention git-remote-mediawiki, of course.
>

Should we split our test file in two then ? Currently they're all in t9361.

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

* Re: [PATCH 3/3] Tests file for git-remote-mediawiki
  2012-06-08  9:04           ` Simon Perrat
@ 2012-06-08  9:08             ` Matthieu Moy
  0 siblings, 0 replies; 13+ messages in thread
From: Matthieu Moy @ 2012-06-08  9:08 UTC (permalink / raw)
  To: Simon Perrat
  Cc: Simon.Cathebras, git, charles.roussel, Guillaume.Sasdy,
	Julien.Khayat, peff, gitster, Charles Roussel

Simon Perrat <simon.perrat@ensimag.imag.fr> writes:

> 2012/6/8 Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
>>
>> "Simon.Cathebras" <Simon.Cathebras@ensimag.imag.fr> writes:
>> > Do you mean that we should split the third patch into two patches ?
>> > For instance::
>> >     Patch 3/4: tests for git pull
>> >     Patch 4/4: tests for git push
>>
>> Yes, except the title should mention git-remote-mediawiki, of course.
>>
>
> Should we split our test file in two then ? Currently they're all in t9361.

The patch I was commenting does

 t/t9360-git-mediawiki.sh | 265 +++++++++++++++++++++++++++++++++++++++++++++++
 t/t9361-git-mediawiki.sh | 213 +++++++++++++++++++++++++++++++++++++

(BTW, you can find a better naming for the files, if one tests clone,
then clone should appear in the title, same for push/pull).

There's nothing wrong with touching several files in the same commit,
but when your commit messages looks like

- first file: does this
- second file: does that

and there's no dependencies, it's usually better to split the commit.

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

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

* [PATCH 3/3] Tests file for git-remote-mediawiki
  2012-06-01 10:41 ` [PATCH 1/3] Script to install, delete and clear a MediaWiki Guillaume Sasdy
@ 2012-06-01 10:41   ` Guillaume Sasdy
  0 siblings, 0 replies; 13+ messages in thread
From: Guillaume Sasdy @ 2012-06-01 10:41 UTC (permalink / raw)
  To: git
  Cc: Matthieu.Moy, Charles Roussel, Guillaume Sasdy, Simon Cathebras,
	Simon Perrat, Charles Roussel, Julien Khayat

From: Charles Roussel <charles.roussel@ensimag.fr>

Those scripts test the functions of git-remote-mediawiki.
t9360: simple test case for git clone.
t9361: simple test cases for git pull (add page, edit page, delete page) and git push (add file, edit file, delete file).

Signed-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>
Signed-off-by: Simon Cathebras <Simon.Cathebras@ensimag.imag.fr>
Signed-off-by: Simon Perrat <Simon.Perrat@ensimag.imag.fr>
Signed-off-by: Charles Roussel <Charles.Roussel@ensimag.imag.fr>
Signed-off-by: Julien Khayat <Julien.Khayat@ensimag.imag.fr>
---
 t/t9360-git-mediawiki.sh |  49 +++++++++++++++
 t/t9361-git-mediawiki.sh | 156 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 205 insertions(+)
 create mode 100755 t/t9360-git-mediawiki.sh
 create mode 100755 t/t9361-git-mediawiki.sh

diff --git a/t/t9360-git-mediawiki.sh b/t/t9360-git-mediawiki.sh
new file mode 100755
index 0000000..57e05d8
--- /dev/null
+++ b/t/t9360-git-mediawiki.sh
@@ -0,0 +1,49 @@
+#!/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>
+#     Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
+#
+# License: GPL v2 or later
+
+# tests for git-remote-mediawiki
+
+test_description='Test the Git Mediawiki remote helper: git clone'
+
+. ./test-gitmw-lib.sh
+. ./test-lib.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 clone works with page added' '
+	wiki_reset &&
+	wiki_editpage foo "hello_world" false &&
+	wiki_editpage bar "hi everybody !" false &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	wiki_getallpage ref_page &&
+	git_content mw_dir ref_page &&
+	wiki_delete_page foo &&
+	wiki_delete_page bar
+'
+
+test_done
diff --git a/t/t9361-git-mediawiki.sh b/t/t9361-git-mediawiki.sh
new file mode 100755
index 0000000..9dd7274
--- /dev/null
+++ b/t/t9361-git-mediawiki.sh
@@ -0,0 +1,156 @@
+#!/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>
+#     Matthieu Moy <Matthieu.Moy@grenoble-inp.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-lib.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
+
+# Create a new file foo.mw in a freshly cloned wiki. Commit and push
+# this file and then check that all files of the repository are similar to
+# the wiki pages.
+test_expect_success 'git push works after adding a file .mw' "
+        wiki_reset &&
+        git clone mediawiki::http://$SERVER_ADDR/$WIKI_DIR_NAME mw_dir &&
+        wiki_getallpage ref_page &&
+
+        cd mw_dir &&
+        test ! -f foo.mw && # foo.mw should not exist after wiki_reset &&
+        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 &&
+        git_content mw_dir ref_page &&
+        rm -rf ref_page &&
+        rm -rf mw_dir
+"
+
+# Create a new page Foo in an empty wiki. Clone the wiki and edit
+# the file foo.mw corresponding to the page Foo. Commit and push
+# then check that all files of the repository are similar to the wiki
+# pages.
+test_expect_success 'git push works after editing a file .mw' "
+        # clone an empty wiki and add a Foo page
+        wiki_reset &&
+        wiki_editpage \"foo\" \"page just 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 &&
+        git_content mw_dir ref_page &&
+        rm -rf ref_page &&
+        rm -rf mw_dir
+"
+
+# Clone a wiki with a page Foo. Remove the corresponding file from the
+# repository. Check that the wiki page has been actually removed.
+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/$WIKI_DIR_NAME mw_dir &&
+
+        cd mw_dir &&
+        git rm Foo.mw &&
+        git commit -am \"git rm delete the wiki page Foo.mw\" &&
+        git push &&
+        cd .. &&
+
+        rm -rf mw_dir &&
+        test ! wiki_page_exist Foo
+"
+
+# Clone an empty wiki. Add a page on the wiki and pull. Check 
+# all files of the repository are similar to the wiki pages.
+test_expect_success 'git pull works after adding a new wiki page' "
+        wiki_reset &&
+        git clone mediawiki::http://$SERVER_ADDR/$WIKI_DIR_NAME mw_dir &&
+        wiki_editpage foo \"page just created after the git clone\" false &&
+
+        cd mw_dir &&
+        git pull &&
+        cd .. &&
+
+        rm -rf ref_page &&
+        wiki_getallpage ref_page &&
+        git_content mw_dir ref_page &&
+        rm -rf ref_page &&
+        rm -rf mw_dir
+"
+
+# Clone a wiki with a page Foo. Edit the page foo on the wiki and pull.
+# Check that all files of the repository are similar to the wiki pages.
+test_expect_success 'git pull works after editing a wiki page' "
+        wiki_reset &&
+        wiki_editpage foo \"page just 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 &&
+        git_content mw_dir ref_page &&
+        rm -rf ref_page
+        rm -rf mw_dir
+"
+
+# Clone a wiki with a page Foo. Remove the wiki page and pull.
+# Check that the corresponding file in the repository has been actually removed.
+test_expect_failure 'git pull works after deleting a wiki page' "
+        wiki_reset &&
+        wiki_editpage foo \"wiki page added before git clone\" false &&
+        git clone mediawiki::http://$SERVER_ADDR/$WIKI_DIR_NAME mw_dir &&
+
+        cd mw_dir &&
+        wiki_delete_page foo
+        git pull &&
+        test ! -f Foo.mw &&
+        cd .. &&
+
+        rm -rf mw_dir
+"
+
+test_done
+
-- 
1.7.10.2.568.g4c26a3a

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

* [PATCH 3/3] Tests file for git-remote-mediawiki
  2012-05-30 17:04 ` [PATCH 1/3] Script to install, delete and clear a MediaWiki Simon Cathebras
@ 2012-05-30 17:04   ` Simon Cathebras
  0 siblings, 0 replies; 13+ messages in thread
From: Simon Cathebras @ 2012-05-30 17:04 UTC (permalink / raw)
  To: git
  Cc: Matthieu.Moy, simon.cathebras, charles.roussel, Guillaume.Sasdy,
	Julien.Khayat, Simon.Perrat, Charles Roussel, Julien Khayat,
	Simon Perrat, Guillaume Sasdy

From: Charles Roussel <charles.roussel@ensimag.fr>

This file (will) contains all tests for git-remote-mediawiki.
For now, we have one test of git-clone on a wiki with one page.

Signed-off-by: Simon Cathebras <simon.cathebras@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: Simon Perrat <simon.perrat@ensimag.imag.fr>
Signed-off-by: Guillaume Sasdy <guillaume.sasdy@gmail.com>
---
 t/t9360-git-mediawiki.sh | 49 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100755 t/t9360-git-mediawiki.sh

diff --git a/t/t9360-git-mediawiki.sh b/t/t9360-git-mediawiki.sh
new file mode 100755
index 0000000..8de56c5
--- /dev/null
+++ b/t/t9360-git-mediawiki.sh
@@ -0,0 +1,49 @@
+#!/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>
+#     Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
+#
+# License: GPL v2 or later
+
+# tests for git-remote-mediawiki
+
+test_description='Test the Git Mediawiki remote helper'
+
+. ./test-gitmw-lib.sh
+. ./test-lib.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 clone works with page added' '
+	cmd_reset &&
+	wiki_editpage foo "hello_world" false &&
+	wiki_editpage bar "hi everybody !" false &&
+	git clone mediawiki::http://localhost/wiki mw_dir &&
+	wiki_getallpage ref_page &&
+	git_content mw_dir ref_page &&
+	wiki_delete_page foo &&
+	wiki_delete_page bar
+'
+
+test_done
-- 
1.7.10.2.552.gaa3bb87

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

end of thread, other threads:[~2012-06-08  9:09 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-05 13:20 [Git-MediaWiki] Test environment for Git-MediaWiki Simon.Cathebras
2012-06-05 13:25 ` [PATCH 1/3] Script to install, delete and clear a MediaWiki Simon Cathebras
2012-06-05 13:25   ` [PATCH 2/3] Test environment of git-remote-mw Simon Cathebras
2012-06-05 13:25   ` [PATCH 3/3] Tests file for git-remote-mediawiki Simon Cathebras
2012-06-06 20:18     ` Matthieu Moy
2012-06-08  8:04       ` Simon.Cathebras
2012-06-08  8:57         ` Matthieu Moy
2012-06-08  9:04           ` Simon Perrat
2012-06-08  9:08             ` Matthieu Moy
2012-06-05 16:48   ` [PATCH 1/3] Script to install, delete and clear a MediaWiki Junio C Hamano
2012-06-06 13:49     ` Simon.Cathebras
  -- strict thread matches above, loose matches on Subject: below --
2012-05-30 16:30 [PATCH/RFC]Test environment for Git-MediaWiki Simon.Cathebras
2012-05-30 17:04 ` [PATCH 1/3] Script to install, delete and clear a MediaWiki Simon Cathebras
2012-05-30 17:04   ` [PATCH 3/3] Tests file for git-remote-mediawiki Simon Cathebras
2012-06-01 10:41 ` [PATCH 1/3] Script to install, delete and clear a MediaWiki Guillaume Sasdy
2012-06-01 10:41   ` [PATCH 3/3] Tests file for git-remote-mediawiki Guillaume Sasdy

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