{"thread":{"id":"30773","subject":"[PATCH]Test environment for git-remote-mediawiki","startedAt":"2012-06-11T20:27:52Z","lastAt":"2012-06-14T16:17:39Z","messageCount":40,"participants":["Simon.Cathebras","Simon Cathebras","konglu@minatec.inpg.fr","Simon Perrat","Matthieu Moy","Ævar Arnfjörð Bjarmason"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"193370","messageId":"4FD654C8.6040208@ensimag.imag.fr","threadId":"30773","inReplyTo":null,"subject":"[PATCH]Test environment for git-remote-mediawiki","fromName":"Simon.Cathebras","fromEmail":"simon.cathebras@ensimag.imag.fr","sentAt":"2012-06-11T20:27:52Z","receivedAt":"2012-06-11T20:27:52Z","isPatch":true,"sender":{"key":"simon.cathebras@ensimag.imag.fr","avatar":"https://avatars.githubusercontent.com/u/1764010?v=4"},"body":"Good evening.\n\nWe have finally took into into account all existing advices about our \ncontribution to git-mediawiki.\nWe are proposing, in the following of this mail, our work for the test \nenvironment of git-mediawiki.\n\nWe would like to propose you this work for git-remote-mediawiki, because \nwe believe that, this fonctionnality needs a suitable test environment \nif we intend to upgrade it in the future.\n\nWe would like to have some piece of advice for improving it. We will be \nglad to be accepted as a viable contribution for git-remote-mediawiki :).\n\nHave a nice evening.\n\nSimon C.\n\n-- \nCATHEBRAS Simon\n\n2A-ENSIMAG\n\nFilière Ingéniérie des Systèmes d'Information\nMembre Bug-Buster\n"},{"id":"193371","messageId":"1339446526-22397-1-git-send-email-simon.cathebras@ensimag.imag.fr","threadId":"30773","inReplyTo":"4FD654C8.6040208@ensimag.imag.fr","subject":"[PATCHv3 1/6] Scripts to install, delete and clear a MediaWiki","fromName":"Simon Cathebras","fromEmail":"simon.cathebras@ensimag.imag.fr","sentAt":"2012-06-11T20:28:41Z","receivedAt":"2012-06-11T20:28:41Z","isPatch":false,"sender":{"key":"simon.cathebras@ensimag.imag.fr","avatar":"https://avatars.githubusercontent.com/u/1764010?v=4"},"body":"From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n\nInstall_wiki.sh expects the first argument to be 'install' or 'delete'\n'install' installs a MediaWiki on the web's server with SQLite3\n'delete' deletes the previously created wiki.\nNote those functionnalities are made to be used from the user command line in\nthe directory git/contrib/mw-to-git/t/\n\ninstall_wiki also defines a function wiki_reset which clear all content\nof the previously created wiki. Note this functionnality is made to be\nused only by our test function in a subdirectory of t/\n\nSigned-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>\nSigned-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>\nSigned-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>\nSigned-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\nSigned-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@imag.fr>\n\n---\n contrib/mw-to-git/t/install-wiki.sh                |  38 +++++\n contrib/mw-to-git/t/install-wiki/LocalSettings.php | 129 +++++++++++++++++\n contrib/mw-to-git/t/install-wiki/db_install.php    | 110 +++++++++++++++\n contrib/mw-to-git/t/test-gitmw-lib.sh              | 154 +++++++++++++++++++++\n 4 files changed, 431 insertions(+)\n create mode 100755 contrib/mw-to-git/t/install-wiki.sh\n create mode 100644 contrib/mw-to-git/t/install-wiki/LocalSettings.php\n create mode 100644 contrib/mw-to-git/t/install-wiki/db_install.php\n create mode 100755 contrib/mw-to-git/t/test-gitmw-lib.sh\n\ndiff --git a/contrib/mw-to-git/t/install-wiki.sh b/contrib/mw-to-git/t/install-wiki.sh\nnew file mode 100755\nindex 0000000..322f46d\n--- /dev/null\n+++ b/contrib/mw-to-git/t/install-wiki.sh\n@@ -0,0 +1,38 @@\n+#!/bin/sh\n+\n+# This script installs or deletes a MediaWiki on your computer.\n+# It requires a web server with PHP and SQLite running. In addition, if you \n+# do not have MediaWiki sources on your computer, the option 'install' \n+# downloads them for you.\n+# Please set the CONFIGURATION VARIABLES in ./test-gitmw-lib.sh\n+\n+. ./test-gitmw-lib.sh\n+\n+usage () {\n+        echo \"Usage: \"\n+        echo \"  ./install-wiki.sh <install|delete|--help|-h>\"\n+        echo \"          install: Install a wiki on your computer.\"\n+        echo \"          delete: Delete the wiki and all its pages and      content\"\n+}\n+\n+\n+# Argument: install, delete, --help | -h\n+case \"$1\" in\n+\t\"install\")\n+\t\twiki_install\n+\t\texit 0\n+\t\t;;\n+\t\"delete\")\n+\t\twiki_delete\n+\t\texit 0\n+\t\t;;\n+\t\"--help\" | \"-h\")\n+\t\tusage\n+\t\texit 0\n+\t\t;;\n+\t*)\n+\t\tusage\n+\t\texit 0\n+\t\t;;\n+esac\n+\ndiff --git a/contrib/mw-to-git/t/install-wiki/LocalSettings.php b/contrib/mw-to-git/t/install-wiki/LocalSettings.php\nnew file mode 100644\nindex 0000000..c2fe3d5\n--- /dev/null\n+++ b/contrib/mw-to-git/t/install-wiki/LocalSettings.php\n@@ -0,0 +1,129 @@\n+<?php\n+# This file was automatically generated by the MediaWiki 1.19.0\n+# installer. If you make manual changes, please keep track in case you\n+# need to recreate them later.\n+#\n+# See includes/DefaultSettings.php for all configurable settings\n+# and their default values, but don't forget to make changes in _this_\n+# file, not there.\n+#\n+# Further documentation for configuration settings may be found at:\n+# http://www.mediawiki.org/wiki/Manual:Configuration_settings\n+\n+# Protect against web entry\n+if ( !defined( 'MEDIAWIKI' ) ) {\n+\texit;\n+}\n+\n+## Uncomment this to disable output compression\n+# $wgDisableOutputCompression = true;\n+\n+$wgSitename      = \"Git-MediaWiki-Test\";\n+$wgMetaNamespace = \"Git-MediaWiki-Test\";\n+\n+## The URL base path to the directory containing the wiki;\n+## defaults for all runtime URL paths are based off of this.\n+## For more information on customizing the URLs please see:\n+## http://www.mediawiki.org/wiki/Manual:Short_URL\n+$wgScriptPath       = \"@WG_SCRIPT_PATH@\";\n+$wgScriptExtension  = \".php\";\n+\n+## The protocol and server name to use in fully-qualified URLs\n+$wgServer           = \"@WG_SERVER@\";\n+\n+## The relative URL path to the skins directory\n+$wgStylePath        = \"$wgScriptPath/skins\";\n+\n+## The relative URL path to the logo.  Make sure you change this from the default,\n+## or else you'll overwrite your logo when you upgrade!\n+$wgLogo             = \"$wgStylePath/common/images/wiki.png\";\n+\n+## UPO means: this is also a user preference option\n+\n+$wgEnableEmail      = true;\n+$wgEnableUserEmail  = true; # UPO\n+\n+$wgEmergencyContact = \"apache@localhost\";\n+$wgPasswordSender   = \"apache@localhost\";\n+\n+$wgEnotifUserTalk      = false; # UPO\n+$wgEnotifWatchlist     = false; # UPO\n+$wgEmailAuthentication = true;\n+\n+## Database settings\n+$wgDBtype           = \"sqlite\";\n+$wgDBserver         = \"\";\n+$wgDBname           = \"wikidb\";\n+$wgDBuser           = \"\";\n+$wgDBpassword       = \"\";\n+\n+# SQLite-specific settings\n+$wgSQLiteDataDir    = \"@WG_SQLITE_DATADIR@\";\n+\n+\n+## Shared memory settings\n+$wgMainCacheType    = CACHE_NONE;\n+$wgMemCachedServers = array();\n+\n+## To enable image uploads, make sure the 'images' directory\n+## is writable, then set this to true:\n+$wgEnableUploads  = false;\n+$wgUseImageMagick = true;\n+$wgImageMagickConvertCommand =\"@CONVERT@\";\n+\n+# InstantCommons allows wiki to use images from http://commons.wikimedia.org\n+$wgUseInstantCommons  = false;\n+\n+## If you use ImageMagick (or any other shell command) on a\n+## Linux server, this will need to be set to the name of an\n+## available UTF-8 locale\n+$wgShellLocale = \"en_US.utf8\";\n+\n+## If you want to use image uploads under safe mode,\n+## create the directories images/archive, images/thumb and\n+## images/temp, and make them all writable. Then uncomment\n+## this, if it's not already uncommented:\n+#$wgHashedUploadDirectory = false;\n+\n+## Set $wgCacheDirectory to a writable directory on the web server\n+## to make your wiki go slightly faster. The directory should not\n+## be publically accessible from the web.\n+#$wgCacheDirectory = \"$IP/cache\";\n+\n+# Site language code, should be one of the list in ./languages/Names.php\n+$wgLanguageCode = \"en\";\n+\n+$wgSecretKey = \"1c912bfe3519fb70f5dc523ecc698111cd43d81a11c585b3eefb28f29c2699b7\";\n+#$wgSecretKey = \"@SECRETKEY@\";\n+\n+\n+# Site upgrade key. Must be set to a string (default provided) to turn on the\n+# web installer while LocalSettings.php is in place\n+$wgUpgradeKey = \"ddae7dc87cd0a645\";\n+\n+## Default skin: you can change the default skin. Use the internal symbolic\n+## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook', 'vector':\n+$wgDefaultSkin = \"vector\";\n+\n+## For attaching licensing metadata to pages, and displaying an\n+## appropriate copyright notice / icon. GNU Free Documentation\n+## License and Creative Commons licenses are supported so far.\n+$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright\n+$wgRightsUrl  = \"\";\n+$wgRightsText = \"\";\n+$wgRightsIcon = \"\";\n+\n+# Path to the GNU diff3 utility. Used for conflict resolution.\n+$wgDiff3 = \"/usr/bin/diff3\";\n+\n+# Query string length limit for ResourceLoader. You should only set this if\n+# your web server has a query string length limit (then set it to that limit),\n+# or if you have suhosin.get.max_value_length set in php.ini (then set it to\n+# that value)\n+$wgResourceLoaderMaxQueryLength = -1;\n+\n+\n+\n+# End of automatically generated settings.\n+# Add more configuration options below.\n+\ndiff --git a/contrib/mw-to-git/t/install-wiki/db_install.php b/contrib/mw-to-git/t/install-wiki/db_install.php\nnew file mode 100644\nindex 0000000..bd7a075\n--- /dev/null\n+++ b/contrib/mw-to-git/t/install-wiki/db_install.php\n@@ -0,0 +1,110 @@\n+<?php\n+/**\n+ * This script generates a SQLite database for a MediaWiki version 1.19.0\n+ * You must specify the login of the admin (argument 1) and its\n+ * password (argument 2) and the folder where the database file\n+ * is located (absolute path in argument 3).\n+ * It is used by the script install-wiki.sh in order to make easy the\n+ * installation of a MediaWiki.\n+ *\n+ * In order to generate a SQLite database file, MediaWiki ask the user\n+ * to submit some forms in its web browser. This script simulates this\n+ * behavior though the functions <get> and <submit>\n+ *\n+ */\n+$argc = $_SERVER['argc'];\n+$argv = $_SERVER['argv'];\n+\n+$login = $argv[2];\n+$pass = $argv[3];\n+$tmp = $argv[4];\n+\n+$db_dir = urlencode($tmp);\n+$tmp_cookie = tempnam($tmp,\"COOKIE_\");\n+\n+/*\n+ * Fetchs a page with cURL.\n+ */\n+function get ($page_name = \"\") {\n+        $curl = curl_init();\n+        $page_name_add = \"\";\n+        if ($page_name != \"\") {\n+                $page_name_add = '?page='.$page_name;\n+        }\n+        $url = 'http://localhost/wiki/mw-config/index.php'.$page_name_add;\n+        $tmp_cookie=$GLOBALS['tmp_cookie'];\n+        curl_setopt($curl, CURLOPT_COOKIEJAR, $tmp_cookie);\n+        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);\n+        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);\n+        curl_setopt($curl, CURLOPT_COOKIEFILE, $tmp_cookie);\n+        curl_setopt($curl, CURLOPT_HEADER, true);\n+        curl_setopt($curl, CURLOPT_URL,\n+                'http://localhost/wiki/mw-config/index.php'.$page_name_add);\n+\n+        $page = curl_exec($curl);\n+        curl_close($curl);\n+        return $page;\n+}\n+\n+/*\n+ * Submits a form with cURL.\n+ */\n+function submit($page_name, $option = \"\") {\n+        $curl = curl_init();\n+        $datapost = 'submit-continue=Continue+%E2%86%92';\n+        if ($option != \"\") {\n+                $datapost = $option.'&'.$datapost;\n+        }\n+        $url = 'http://localhost/wiki/mw-config/index.php?page='.$page_name;\n+        $tmp_cookie = $GLOBALS['tmp_cookie'];\n+        curl_setopt($curl, CURLOPT_URL, $url);\n+        curl_setopt($curl, CURLOPT_POST, true);\n+        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);\n+        curl_setopt($curl, CURLOPT_POSTFIELDS, $datapost);\n+        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);\n+        curl_setopt($curl, CURLOPT_COOKIEJAR, $tmp_cookie);\n+        curl_setopt($curl, CURLOPT_COOKIEFILE, $tmp_cookie);\n+\n+        $page = curl_exec($curl);\n+        curl_close($curl);\n+        return \"$page\";\n+}\n+\n+/*\n+ * Here starts this script: simulates the behavior of the user\n+ * submitting forms to generates the database file.\n+ * Note this simulation was made for the MediaWiki version 1.19.0,\n+ * we can't assume it works with other versions.\n+ *\n+ */\n+\n+$page = get();\n+preg_match('/input type=\"hidden\" value=\"([0-9]+)\" name=\"LanguageRequestTime\"/',\n+        $page, $matches);\n+$timestamp = $matches[1];\n+$language = \"LanguageRequestTime=$timestamp&uselang=en&ContLang=en\";\n+$page = submit('Language', $language);\n+\n+submit('Welcome');\n+\n+$db_config = 'DBType=sqlite';\n+$db_config = $db_config.'&sqlite_wgSQLiteDataDir='.$db_dir;\n+$db_config = $db_config.'&sqlite_wgDBname='.$argv[1];\n+submit('DBConnect', $db_config);\n+\n+$wiki_config = 'config_wgSitename=TEST';\n+$wiki_config = $wiki_config.'&config__NamespaceType=site-name';\n+$wiki_config = $wiki_config.'&config_wgMetaNamespace=MyWiki';\n+$wiki_config = $wiki_config.'&config__AdminName='.$login;\n+\n+$wiki_config = $wiki_config.'&config__AdminPassword='.$pass;\n+$wiki_config = $wiki_config.'&config__AdminPassword2='.$pass;\n+\n+$wiki_config = $wiki_config.'&wiki__configEmail=email%40email.org';\n+$wiki_config = $wiki_config.'&config__SkipOptional=skip';\n+submit('Name', $wiki_config);\n+submit('Install');\n+submit('Install');\n+\n+unlink($tmp_cookie);\n+?>\ndiff --git a/contrib/mw-to-git/t/test-gitmw-lib.sh b/contrib/mw-to-git/t/test-gitmw-lib.sh\nnew file mode 100755\nindex 0000000..80b4f4f\n--- /dev/null\n+++ b/contrib/mw-to-git/t/test-gitmw-lib.sh\n@@ -0,0 +1,154 @@\n+# Copyright (C) 2012\n+#     Charles Roussel <charles.roussel@ensimag.imag.fr>\n+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>\n+#     Julien Khayat <julien.khayat@ensimag.imag.fr>\n+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n+#     Simon Perrat <simon.perrat@ensimag.imag.fr>\n+# License: GPL v2 or later\n+\n+#\n+# CONFIGURATION VARIABLES\n+# You might want to change these ones\n+#\n+WIKI_DIR_NAME=\"wiki\"            # Name of the wiki's directory\n+WIKI_DIR_INST=\"/var/www\"        # Directory of the web server\n+TMP=\"/tmp\"                      # Temporary directory for downloads\n+                                # Absolute path required!\n+SERVER_ADDR=\"localhost\"         # Web server's address\n+\n+# CONFIGURATION\n+# You should not change these ones unless you know what you do\n+#\n+MW_VERSION=\"mediawiki-1.19.0\"\n+DB_FILE=\"wikidb.sqlite\"\n+FILES_FOLDER=\"install-wiki\"\n+DB_INSTALL_SCRIPT=\"db_install.php\"\n+WIKI_ADMIN=\"WikiAdmin\"\n+WIKI_PASSW=\"AdminPass\"\n+\n+}\n+\n+# Create the SQLite database of the MediaWiki. If the database file already\n+# exists, it will be deleted.\n+# This script should be runned from the directory where $FILES_FOLDER is\n+# located.\n+create_db () {\n+        rm -f \"$TMP/$DB_FILE\"\n+\n+        echo \"Generating the SQLite database file. It can take some time ...\"\n+        # Run the php script to generate the SQLite database file\n+        # with cURL calls.\n+        php \"$FILES_FOLDER/$DB_INSTALL_SCRIPT\" $(basename \"$DB_FILE\" .sqlite) \\\n+                \"$WIKI_ADMIN\" \"$WIKI_PASSW\" \"$TMP\"\n+\n+        if [ ! -f \"$TMP/$DB_FILE\" ] ; then\n+                error \"Can't create database file in TODO. Try to run ./install-wiki.sh delete first.\"\n+        fi\n+        chmod 666 \"$TMP/$DB_FILE\"\n+\n+        # Copy the generated database file into the directory the\n+        # user indicated.\n+        cp --preserve=mode,ownership \"$TMP/$DB_FILE\" \"$FILES_FOLDER\" ||\n+                error \"Unable to copy $TMP/$DB_FILE to $FILES_FOLDER\"\n+}\n+\n+# Install a wiki in your web server directory.\n+wiki_install () {\n+\n+        # In this part, we change directory to $TMP in order to download,\n+        # unpack and copy the files of MediaWiki\n+        (\n+        mkdir -p \"$WIKI_DIR_INST/$WIKI_DIR_NAME\"\n+        if [ ! -d \"$WIKI_DIR_INST/$WIKI_DIR_NAME\" ] ; then\n+                error \"Folder $WIKI_DIR_INST/$WIKI_DIR_NAME doesn't exist.\n+                Please create it and launch the script again.\"\n+        fi\n+\n+        # Fetch MediaWiki's archive if not already present in the TMP directory\n+        cd \"$TMP\"\n+        if [ ! -f \"$MW_VERSION.tar.gz\" ] ; then\n+                echo \"Downloading $MW_VERSION sources ...\"\n+                wget \"http://download.wikimedia.org/mediawiki/1.19/mediawiki-1.19.0.tar.gz\" ||\n+                        error \"Unable to download \"\\\n+                        \"http://download.wikimedia.org/mediawiki/1.19/\"\\\n+                        \"mediawiki-1.19.0.tar.gz. \"\\\n+                        \"Please fix your connection and launch the script again.\"\n+        fi\n+        tar xfz \"$MW_VERSION.tar.gz\"\n+        echo \"$MW_VERSION.tar.gz downloaded in `pwd`.\"\\\n+                \"You can delete it later if you want.\"\n+\n+        # Copy the files of MediaWiki wiki in the web server's directory.\n+        cd \"$MW_VERSION\"\n+        cp -Rf * \"$WIKI_DIR_INST/$WIKI_DIR_NAME/\" ||\n+                error \"Unable to copy WikiMedia's files from `pwd` to \"\\\n+                        \"$WIKI_DIR_INST/$WIKI_DIR_NAME\"\n+        )\n+\n+        create_db\n+\n+        # Copy the generic LocalSettings.php in the web server's directory\n+        # And modify parameters according to the ones set at the top\n+        # of this script.\n+        # Note that LocalSettings.php is never modified.\n+        if [ ! -f \"$FILES_FOLDER/LocalSettings.php\" ] ; then\n+                error \"Can't find $FILES_FOLDER/LocalSettings.php \" \\\n+                        \"in the current folder. \"\\\n+                \"Please run the script inside its folder.\"\n+        fi\n+        cp \"$FILES_FOLDER/LocalSettings.php\" \\\n+                \"$FILES_FOLDER/LocalSettings-tmp.php\" ||\n+                error \"Unable to copy $FILES_FOLDER/LocalSettings.php \" \\\n+                \"to $FILES_FOLDER/LocalSettings-tmp.php\"\n+\n+        # Parse and set the LocalSettings file of the user according to the\n+        # CONFIGURATION VARIABLES section at the beginning of this script\n+        file_swap=\"$FILES_FOLDER/LocalSettings-swap.php\"\n+        sed \"s,@WG_SCRIPT_PATH@,/$WIKI_DIR_NAME,\" \\\n+                \"$FILES_FOLDER/LocalSettings-tmp.php\" > \"$file_swap\"\n+        mv \"$file_swap\" \"$FILES_FOLDER/LocalSettings-tmp.php\"\n+        sed \"s,@WG_SERVER@,http://$SERVER_ADDR,\" \\\n+                \"$FILES_FOLDER/LocalSettings-tmp.php\" > \"$file_swap\"\n+        mv \"$file_swap\" \"$FILES_FOLDER/LocalSettings-tmp.php\"\n+        sed \"s,@WG_SQLITE_DATADIR@,$TMP,\" \\\n+                \"$FILES_FOLDER/LocalSettings-tmp.php\" > \"$file_swap\"\n+        mv \"$file_swap\" \"$FILES_FOLDER/LocalSettings-tmp.php\"\n+\n+        mv \"$FILES_FOLDER/LocalSettings-tmp.php\" \\\n+                \"$WIKI_DIR_INST/$WIKI_DIR_NAME/LocalSettings.php\" ||\n+                error \"Unable to move $FILES_FOLDER/LocalSettings-tmp.php\" \\\n+                \"in $WIKI_DIR_INST/$WIKI_DIR_NAME\"\n+        echo \"File $FILES_FOLDER/LocalSettings.php is set in\" \\\n+                \" $WIKI_DIR_INST/$WIKI_DIR_NAME\"\n+\n+        chmod ugo+w \"$FILES_FOLDER/$DB_FILE\"\n+\n+        echo \"Your wiki has been installed. You can check it at\n+                http://$SERVER_ADDR/$WIKI_DIR_NAME\"\n+}\n+\n+# Reset the database of the wiki and the password of the admin\n+#\n+# Warning: This function must be called only in a subdirectory of t/ directory\n+wiki_reset () {\n+        # Copy initial database of the wiki\n+        if [ ! -f \"../$FILES_FOLDER/$DB_FILE\" ] ; then\n+                error \"Can't find ../$FILES_FOLDER/$DB_FILE in the current folder.\"\n+        fi\n+        cp \"../$FILES_FOLDER/$DB_FILE\" \"$TMP\" ||\n+                error \"Can't copy ../$FILES_FOLDER/$DB_FILE in $TMP\"\n+        echo \"File $FILES_FOLDER/$DB_FILE is set in $TMP\"\n+}\n+\n+# Delete the wiki created in the web server's directory and all its content\n+# saved in the database.\n+wiki_delete () {\n+\t# Delete the wiki's directory.\n+\trm -rf \"$WIKI_DIR_INST/$WIKI_DIR_NAME\" ||\n+\t\terror \"Wiki's directory $WIKI_DIR_INST/\" \\\n+\t\t\"$WIKI_DIR_NAME could not be deleted\"\n+\n+\t# Delete the wiki's SQLite database\n+\trm -f \"$TMP/$DB_FILE\" || error \"Database $TMP/$DB_FILE could not be deleted.\"\n+}\n+\n-- \n1.7.10.2.552.gaa3bb87\n"},{"id":"193373","messageId":"1339446526-22397-2-git-send-email-simon.cathebras@ensimag.imag.fr","threadId":"30773","inReplyTo":"1339446526-22397-1-git-send-email-simon.cathebras@ensimag.imag.fr","subject":"[PATCHv3 2/6] Test environment of git-remote-mediawiki","fromName":"Simon Cathebras","fromEmail":"simon.cathebras@ensimag.imag.fr","sentAt":"2012-06-11T20:28:42Z","receivedAt":"2012-06-11T20:28:42Z","isPatch":false,"sender":{"key":"simon.cathebras@ensimag.imag.fr","avatar":"https://avatars.githubusercontent.com/u/1764010?v=4"},"body":"From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n\nIn order to test git-remote-mediawiki, we need a package of functions\nto manage a MediaWiki: edit a page, remove a page, fetch a page,\nfetch all pages on a given wiki.\n\nWe also need functions to compare the content of directories.\n\nThis patch provide these functions in the file\ngit/contrib/mw-to-git/t/test-gitmw-lib.sh and\ngit/contrib/mw-to-git/t/test-gitmw.pl\n\nIn addition, this patch provide Makefiles to execute tests.\nSee README file for more details.\n\nSigned-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>\nSigned-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>\nSigned-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>\nSigned-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\nSigned-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@imag.fr>\n---\n contrib/mw-to-git/Makefile            |  40 +++++++\n contrib/mw-to-git/t/Makefile          |  32 +++++\n contrib/mw-to-git/t/README            |  33 ++++++\n contrib/mw-to-git/t/test-gitmw-lib.sh | 117 +++++++++++++++++++\n contrib/mw-to-git/t/test-gitmw.pl     | 213 ++++++++++++++++++++++++++++++++++\n 5 files changed, 435 insertions(+)\n create mode 100644 contrib/mw-to-git/Makefile\n create mode 100644 contrib/mw-to-git/t/Makefile\n create mode 100644 contrib/mw-to-git/t/README\n create mode 100755 contrib/mw-to-git/t/test-gitmw.pl\n\ndiff --git a/contrib/mw-to-git/Makefile b/contrib/mw-to-git/Makefile\nnew file mode 100644\nindex 0000000..7d55a51\n--- /dev/null\n+++ b/contrib/mw-to-git/Makefile\n@@ -0,0 +1,40 @@\n+## Build and test git-remote-mediawiki to use with git \n+\n+-include ../../config.mak.autogen\n+-include ../../config.mak\n+\n+ifndef PERL_PATH\n+\tPERL_PATH = /usr/bin/perl\n+endif\n+ifndef gitexecdir\n+\tgitexecdir = $(shell git --exec-path)\n+endif\n+\n+PERL_PATH_SQ = $(subst ','\\'',$(PERL_PATH))\n+gitexecdir_SQ = $(subst ','\\'',$(gitexecdir))\n+\n+SCRIPT = git-remote-mediawiki\n+RM = rm -f\n+\n+.PHONY: install help doc test clean\n+\n+help:\n+\t@echo 'This is the help target of the Makefile. Current configuration:'\n+\t@echo '  gitexecdir = $(gitexecdir_SQ)'\n+\t@echo '  PERL_PATH = $(PERL_PATH_SQ)'\n+\t@echo 'Run \"$(MAKE) install\" to install $(SCRIPT) in gitexecdir'\n+\n+install:\n+\tsed -e '1s|#!.*/perl|#!$(PERL_PATH_SQ)|' $(SCRIPT) \\\n+            > '$(gitexecdir_SQ)/$(SCRIPT)'\n+\tchmod +x '$(gitexecdir)/$(SCRIPT)'\n+\n+doc:\n+\t@echo 'Sorry, \"make doc\" is not implemented yet for $(SCRIPT)'\n+\n+test:\n+\t$(MAKE) -C t/ test\n+\n+clean:\n+\t$(RM) '$(gitexecdir)/$(SCRIPT)'\n+\t$(MAKE) -C t/ clean\n\\ No newline at end of file\ndiff --git a/contrib/mw-to-git/t/Makefile b/contrib/mw-to-git/t/Makefile\nnew file mode 100644\nindex 0000000..9429907\n--- /dev/null\n+++ b/contrib/mw-to-git/t/Makefile\n@@ -0,0 +1,32 @@\n+# Run tests\n+#\n+# Copyright (c) 2005 Junio C Hamano\n+#\n+\n+-include ../../../config.mak.autogen\n+-include ../../../config.mak\n+\n+ifndef PERL_PATH\n+\tPERL_PATH = /usr/bin/perl\n+endif\n+ifndef gitexecdir\n+\tgitexecdir = $(shell git --exec-path)\n+endif\n+\n+PERL_PATH_SQ = $(subst ','\\'',$(PERL_PATH))\n+gitexecdir_SQ = $(subst ','\\'',$(gitexecdir))\n+T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)\n+\n+.PHONY: help test clean\n+\n+help:\n+\t@echo 'This is the help target of the Makefile. Current configuration:'\n+\t@echo '  gitexecdir = $(gitexecdir_SQ)'\n+\t@echo '  PERL_PATH = $(PERL_PATH_SQ)'\n+\t@echo 'Run \"$(MAKE) test\" to launch test scripts'\n+\n+test:\n+\tfor t in $(T); do \"./$$t\"; done\n+\n+clean:\n+\t$(RM) -r 'trash directory'.*\n\\ No newline at end of file\ndiff --git a/contrib/mw-to-git/t/README b/contrib/mw-to-git/t/README\nnew file mode 100644\nindex 0000000..b68147b\n--- /dev/null\n+++ b/contrib/mw-to-git/t/README\n@@ -0,0 +1,33 @@\n+Tests for Mediawiki-to-Git\n+==========================\n+\n+\n+Installation\n+------------\n+These tests require a mediawiki with admin access to work on; you can install one\n+on localhost/wiki simply by running:\n+\t./install-wiki.sh install\n+Be aware that the tests will flush the wiki database, thus if you own a wiki at\n+this adress, it is strongly advised to configure another name in test-gitmw-lib.sh\n+before running the script.\n+Note that the wiki will be installed in /tmp (this can be configured too), meaning\n+you might have to install it again when you run tests later.\n+\n+\n+Running\n+-------\n+You can run these tests either individually or with make (recommended). Remember\n+to use make clean when you're done. You have access to all options from git core\n+tests.\n+\n+\n+Limitations\n+-------\n+This test environment does not allow you to test the behavior of git-remote-mediawiki\n+for name containing backslashes.\n+\n+t9360: tests git clone.\n+\n+t9361: tests git pull and git push.\n+\n+t9362: tests how UTF-8 special characters are handled.\ndiff --git a/contrib/mw-to-git/t/test-gitmw-lib.sh b/contrib/mw-to-git/t/test-gitmw-lib.sh\nindex 80b4f4f..d073b46 100755\n--- a/contrib/mw-to-git/t/test-gitmw-lib.sh\n+++ b/contrib/mw-to-git/t/test-gitmw-lib.sh\n@@ -26,6 +26,123 @@ DB_INSTALL_SCRIPT=\"db_install.php\"\n WIKI_ADMIN=\"WikiAdmin\"\n WIKI_PASSW=\"AdminPass\"\n \n+export CURR_DIR=$(pwd)\n+export TEST_DIRECTORY=$CURR_DIR/../../../t\n+\n+wiki_getpage () {\n+\t$CURR_DIR/test-gitmw.pl get_page \"$@\"\n+}\n+\n+wiki_delete_page () {\n+\t$CURR_DIR/test-gitmw.pl delete_page \"$@\"\n+}\n+\n+wiki_editpage () {\n+\t$CURR_DIR/test-gitmw.pl edit_page \"$@\"\n+}\n+\n+die () {\n+\tdie_with_status 1 \"$@\"\n+}\n+\n+die_with_status () {\n+\tstatus=$1\n+\tshift\n+\techo >&2 \"$*\"\n+\texit \"$status\"\n+}\n+\n+# test_diff_directories <dir_git> <dir_wiki>\n+#\n+# Compare the contents of directories <dir_git> and <dir_wiki> with diff\n+# and errors if they do not match. The program will\n+# not look into .git in the process.\n+# Warning: the first argument MUST be the directory containing the git data\n+test_diff_directories () {\n+\trm -rf \"$1_tmp\"\n+\tmkdir -p \"$1_tmp\"\n+\tcp \"$1\"/*.mw \"$1_tmp\"\n+\tdiff -r -b \"$1_tmp\" \"$2\"\n+}\n+\n+# $1=<dir>\n+# $2=<N>\n+#\n+# Check that <dir> contains exactly <N> files\n+test_contains_N_files () {\n+\ttest `ls \"$1\" | wc -l` -eq \"$2\";\n+}\n+\n+\n+# wiki_check_content <file_name> <page_name> \n+#\n+# Compares the contents of the file <file_name> and the wiki page\n+# <page_name> and exits with error 1 if they do not match.\n+wiki_check_content () {\n+\tmkdir -p wiki_tmp\n+\twiki_getpage \"$2\" wiki_tmp\n+        \n+\t#replacement of forbidden character in file name\n+\tpage_name=$(printf \"%s\\n\" \"$2\" | sed -e \"s/\\//%2F/g\")        \n+\n+\tdiff -b \"$1\" wiki_tmp/\"$page_name\".mw\n+\tif test $? -ne 0\n+\tthen\n+\t\trm -rf wiki_tmp\n+\t\terror \"ERROR: file $2 not found on wiki\"\n+\tfi\n+\trm -rf wiki_tmp\n+}\n+\n+# wiki_page_exist <page_name>\n+#\n+# Check the existence of the page <page_name> on the wiki and exits\n+# with error if it is absent from it.\n+wiki_page_exist () {\n+        mkdir -p wiki_tmp\n+\twiki_getpage \"$1\" wiki_tmp\n+\n+\tpage_name=$(printf \"%s\\n\" \"$1\" | sed \"s/\\//%2F/g\")\n+\n+\tif test -f wiki_tmp/\"$page_name\".mw ; then\n+\t\trm -rf wiki_tmp\n+\telse\n+\t        rm -rf wiki_tmp\n+\t\terror \"test failed: file $1 not found on wiki\"\n+\tfi\n+}\n+\n+# wiki_getallpagename\n+# \n+# Fetch the name of each page on the wiki.\n+wiki_getallpagename () {\n+\t$CURR_DIR/test-gitmw.pl getallpagename\n+}\n+\n+# wiki_getallpagecategory <category>\n+# \n+# Fetch the name of each page belonging to <category> on the wiki.\n+wiki_getallpagecategory () {\n+\t$CURR_DIR/test-gitmw.pl getallpagename \"$@\"\n+}\n+\n+# wiki_getallpage <dest_dir> [<category>]\n+#\n+# Fetch all the pages from the wiki and place them in the directory\n+# <dest_dir>.\n+# If <category> is define, then wiki_getallpage fetch the pages included\n+# in <category>.\n+wiki_getallpage () {\n+\tif test -z \"$2\";\n+\tthen\n+\t\twiki_getallpagename\n+\telse\n+\t\twiki_getallpagecategory \"$2\"\n+\tfi\n+\tmkdir -p \"$1\"\n+\twhile read -r line; do\n+\t\twiki_getpage \"$line\" $1;\n+\tdone < all.txt\n }\n \n # Create the SQLite database of the MediaWiki. If the database file already\ndiff --git a/contrib/mw-to-git/t/test-gitmw.pl b/contrib/mw-to-git/t/test-gitmw.pl\nnew file mode 100755\nindex 0000000..fd3c798\n--- /dev/null\n+++ b/contrib/mw-to-git/t/test-gitmw.pl\n@@ -0,0 +1,213 @@\n+#!/usr/bin/perl -w -s\n+# Copyright (C) 2012\n+#     Charles Roussel <charles.roussel@ensimag.imag.fr>\n+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>\n+#     Julien Khayat <julien.khayat@ensimag.imag.fr>\n+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n+#     Simon Perrat <simon.perrat@ensimag.imag.fr>\n+# License: GPL v2 or later\n+\n+# Usage:\n+#       ./test-gitmw.pl <command> [argument]*\n+# Execute in terminal using the name of the function to call as first\n+# parameter, and the function's arguments as following parameters\n+#\n+# Example:\n+#     ./test-gitmw.pl \"get_page\" foo .\n+# will call <wiki_getpage> with arguments <foo> and <.>\n+#\n+# Available functions are:\n+#     \"get_page\"\n+#     \"delete_page\"\n+#     \"edit_page\"\n+#     \"getallpagename\"\n+\n+use MediaWiki::API;\n+use Getopt::Long;\n+use Switch;\n+use encoding 'utf8';\n+use DateTime::Format::ISO8601;\n+use open ':encoding(utf8)';\n+use constant SLASH_REPLACEMENT => \"%2F\";\n+\n+# URL of the wiki used for the tests\n+my $wiki_url=\"http://localhost/wiki/api.php\";\n+my $wiki_admin='WikiAdmin';\n+my $wiki_admin_pass='AdminPass';\n+my $mw = MediaWiki::API->new;\n+$mw->{config}->{api_url} = $wiki_url;\n+\n+sub mediawiki_clean_filename {\n+\tmy $filename = shift;\n+\t$filename =~ s/@{[SLASH_REPLACEMENT]}/\\//g;\n+\t# [, ], |, {, and } are forbidden by MediaWiki, even URL-encoded.\n+\t# Do a variant of URL-encoding, i.e. looks like URL-encoding,\n+\t# but with _ added to prevent MediaWiki from thinking this is\n+\t# an actual special character.\n+\t$filename =~ s/[\\[\\]\\{\\}\\|]/sprintf(\"_%%_%x\", ord($&))/ge;\n+\t# If we use the uri escape before\n+\t# we should unescape here, before anything\n+\n+\treturn $filename;\n+}\n+\n+sub mediawiki_smudge_filename {\n+\tmy $filename = shift;\n+\t$filename =~ s/\\//@{[SLASH_REPLACEMENT]}/g;\n+\t$filename =~ s/ /_/g;\n+\t# Decode forbidden characters encoded in mediawiki_clean_filename\n+\t$filename =~ s/_%_([0-9a-fA-F][0-9a-fA-F])/sprintf(\"%c\", hex($1))/ge;\n+\treturn $filename;\n+}\n+\n+\n+# wiki_login <name> <password>\n+#\n+# Logs the user with <name> and <password> in the global variable\n+# of the mediawiki $mw\n+sub wiki_login {\n+\t$mw->login( { lgname => \"$_[0]\",lgpassword => \"$_[1]\" } )\n+\t|| die \"getpage: login failed\";\n+}\n+\n+# wiki_getpage <wiki_page> <dest_path>\n+#\n+# fetch a page <wiki_page> from the wiki referenced in the global variable\n+# $mw and copies its content in directory dest_path\n+sub wiki_getpage {\n+\tmy $pagename = $_[0];\n+\tmy $destdir = $_[1];\n+\n+\tmy $page = $mw->get_page( { title => $pagename } );\n+\tif (!defined($page)) {\n+\t\tdie \"getpage: wiki does not exist\";\n+\t}\n+\n+\tmy $content = $page->{'*'};\n+\tif (!defined($content)) {\n+\t\tdie \"getpage: page does not exist\";\n+\t}\n+\n+\t# Replace spaces by underscore in the page name\n+\t$pagename=$page->{'title'};\n+\t$pagename = mediawiki_smudge_filename $pagename;\n+\topen(my $file, \">$destdir/$pagename.mw\");\n+\tprint $file \"$content\";\n+\tclose ($file);\n+\n+}\n+\n+# wiki_delete_page <page_name>\n+#\n+# delete the page with name <page_name> from the wiki referenced\n+# in the global variable $mw\n+sub wiki_delete_page {\n+\tmy $pagename = $_[0];\n+\n+\tmy $exist=$mw->get_page({title => $pagename});\n+\n+\tif (defined($exist->{'*'})){\n+\t\t$mw->edit({ action => 'delete',\n+\t\t\t\ttitle => $pagename})\n+\t\t|| die $mw->{error}->{code} . \": \" . $mw->{error}->{details};\n+\t} else {\n+\t\tdie \"no page with such name found: $pagename\\n\";\n+\t}\n+}\n+\n+# wiki_editpage <wiki_page> <wiki_content> <wiki_append> [-c=<category>] [-s=<summary>]\n+#\n+# Edit a page named <wiki_page> with content <wiki_content> on the wiki\n+# referenced with the global variable $mw\n+# If <wiki_append> == true : append <wiki_content> at the end of the actual\n+# content of the page <wiki_page>\n+# If <wik_page> doesn't exist, that page is created with the <wiki_content>\n+sub wiki_editpage {\n+\tmy $wiki_page = mediawiki_clean_filename $_[0];\n+\tmy $wiki_content = $_[1];\n+\tmy $wiki_append = $_[2];\n+\tmy $summary = \"\";\n+\tmy ($summ, $cat) = ();\n+\tGetOptions('s=s' => \\$summ, 'c=s' => \\$cat);\n+\n+\tmy $append = 0;\n+\tif (defined($wiki_append) && $wiki_append eq 'true') {\n+\t\t$append=1;\n+\t}\n+\n+\tmy $previous_text =\"\";\n+\n+\tif ($append) {\n+\t\tmy $ref = $mw->get_page( { title => $wiki_page } );\n+\t\t$previous_text = $ref->{'*'};\n+\t}\n+\n+\tmy $text = $wiki_content;\n+\tif (defined($previous_text)) {\n+\t\t$text=\"$previous_text$text\";\n+\t}\n+\n+\t# Eventually, add this page to a category.\n+\tif (defined($cat)) {\n+\t\tmy $category_name=\"[[Category:$cat]]\";\n+\t\t$text=\"$text\\n $category_name\";\n+\t}\n+\tif(defined($summ)){\n+\t\t$summary=$summ;\n+\t}\n+\n+\t$mw->edit( { action => 'edit', title => $wiki_page, summary => $summary, text => \"$text\"} );\n+}\n+\n+# wiki_getallpagename [<category>]\n+#\n+# Fetch all pages of the wiki referenced by the global variable $mw\n+# and print the names of each one in the file all.txt with a new line\n+# (\"\\n\") between these.\n+# If the argument <category> is defined, then this function get only the pages \n+# belonging to <category>.\n+sub wiki_getallpagename {\n+\t# fetch the pages of the wiki\n+\tif (defined($_[0])) {\n+\t\tmy $mw_pages = $mw->list ( { action => 'query',\n+\t\t\t\tlist => 'categorymembers',\n+\t\t\t\tcmtitle => \"Category:$_[0]\",\n+\t\t\t\tcmnamespace => 0,\n+\t\t\t\tcmlimit=> 500 },\n+\t\t)\n+\t\t|| die $mw->{error}->{code}.\": \".$mw->{error}->{details};\n+\t\topen(my $file, \">all.txt\");\n+\t\tforeach my $page (@{$mw_pages}) {\n+\t\t\tprint $file \"$page->{title}\\n\";\n+\t\t}\n+\t\tclose ($file);\n+\n+\t} else {\n+\t\tmy $mw_pages = $mw->list({\n+\t\t\t\taction => 'query',\n+\t\t\t\tlist => 'allpages',\n+\t\t\t\taplimit => 500,\n+\t\t\t})\n+\t\t|| die $mw->{error}->{code}.\": \".$mw->{error}->{details};\n+\t\topen(my $file, \">all.txt\");\n+\t\tforeach my $page (@{$mw_pages}) {\n+\t\t\tprint $file \"$page->{title}\\n\";\n+\t\t}\n+\t\tclose ($file);\n+\t}\n+}\n+\n+# Main part of this script: parse the command line arguments\n+# and select which function to execute\n+my $fct_to_call = shift;\n+\n+&wiki_login($wiki_admin,$wiki_admin_pass);\n+\n+switch ($fct_to_call) {\n+\tcase \"get_page\" { &wiki_getpage(@ARGV)}\n+\tcase \"delete_page\" { &wiki_delete_page(@ARGV)}\n+\tcase \"edit_page\" { &wiki_editpage(@ARGV)}\n+\tcase \"getallpagename\" { &wiki_getallpagename(@ARGV)}\n+\telse { die(\"test-gitmw.pl ERROR: wrong argument\")}\n+}\n+\n-- \n1.7.10.2.552.gaa3bb87\n"},{"id":"193374","messageId":"1339446526-22397-3-git-send-email-simon.cathebras@ensimag.imag.fr","threadId":"30773","inReplyTo":"1339446526-22397-1-git-send-email-simon.cathebras@ensimag.imag.fr","subject":"[PATCHv3 3/6] Test file for git-remote-mediawiki clone","fromName":"Simon Cathebras","fromEmail":"simon.cathebras@ensimag.imag.fr","sentAt":"2012-06-11T20:28:43Z","receivedAt":"2012-06-11T20:28:43Z","isPatch":false,"sender":{"key":"simon.cathebras@ensimag.imag.fr","avatar":"https://avatars.githubusercontent.com/u/1764010?v=4"},"body":"From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n\nThis patch provides some tests for the clone in use by\ngit-remote-mediawiki.\nThese tests are in the file:\ngit/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh\n\nSigned-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>\nSigned-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>\nSigned-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>\nSigned-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\nSigned-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@imag.fr>\n---\n contrib/mw-to-git/t/t9360-mw-to-git-clone.sh | 324 +++++++++++++++++++++++++++\n 1 file changed, 324 insertions(+)\n create mode 100755 contrib/mw-to-git/t/t9360-mw-to-git-clone.sh\n\ndiff --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\nnew file mode 100755\nindex 0000000..2b3df3f\n--- /dev/null\n+++ b/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh\n@@ -0,0 +1,324 @@\n+#!/bin/sh\n+#\n+# Copyright (C) 2012\n+#     Charles Roussel <charles.roussel@ensimag.imag.fr>\n+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>\n+#     Julien Khayat <julien.khayat@ensimag.imag.fr>\n+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n+#     Simon Perrat <simon.perrat@ensimag.imag.fr>\n+#\n+# License: GPL v2 or later\n+\n+\n+test_description='Test the Git Mediawiki remote helper: git clone'\n+\n+. ./test-gitmw-lib.sh\n+. $TEST_DIRECTORY/test-lib.sh\n+\n+TRASH_DIR=\"$CURR_DIR/trash\\ directory.$(basename $0 .sh)\"\n+\n+\n+if ! test_have_prereq PERL\n+then\n+\tskip_all='skipping gateway git-mw tests, '\\\n+\t\t'perl not available'\n+\ttest_done\n+fi\n+\n+if [ ! -f $GIT_BUILD_DIR/git-remote-mediawiki ];\n+then\n+\tskip_all='skipping gateway git-mw tests,' \\\n+\t\t' no remote mediawiki for git found'\n+\ttest_done\n+fi\n+\n+if [ ! -d \"$WIKI_DIR_INST/$WIKI_DIR_NAME\" ] ;\n+then\n+\tskip_all='skipping gateway git-mw tests, no mediawiki found'\n+\ttest_done\n+fi\n+\n+\n+# 1\n+test_expect_success 'Git clone creates the git log expected with one file' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\twiki_editpage foo \"this is not important\" false -c cat -s \"this must be the same\" &&\n+\tgit clone mediawiki::http://localhost/wiki mw_dir &&\n+\tcd mw_dir &&\n+\tgit log --format=%s HEAD^..HEAD > log.tmp &&\n+\techo \"this must be the same\" > msg.tmp &&\n+\tdiff -b log.tmp msg.tmp &&\n+\tcd .. &&\n+\trm -rf mw_dir\n+'\n+\n+# 2\n+test_expect_success 'Git clone creates the git log expected with multiple files' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\twiki_editpage daddy \"this is not important\" false -s=\"this must be the same\" &&\n+\twiki_editpage daddy \"neither is this\" true -s=\"this must also be the same\" &&\n+\twiki_editpage daddy \"neither is this\" true -s=\"same same same\" &&\n+\twiki_editpage dj \"dont care\" false -s=\"identical\" &&\n+\twiki_editpage dj \"dont care either\" true -s=\"identical too\" &&\n+\tgit clone mediawiki::http://localhost/wiki mw_dir &&\n+\tcd mw_dir &&\n+\tgit log --format=%s Daddy.mw  > logDaddy.tmp &&\n+\tgit log --format=%s Dj.mw > logDj.tmp &&\n+\techo \"same same same\" > msgDaddy.tmp &&\n+\techo \"this must also be the same\" >> msgDaddy.tmp &&\n+\techo \"this must be the same\" >> msgDaddy.tmp &&\n+\techo \"identical too\" > msgDj.tmp &&\n+\techo \"identical\" >> msgDj.tmp &&\n+\tdiff -b logDaddy.tmp msgDaddy.tmp &&\n+\tdiff -b logDj.tmp msgDj.tmp &&\n+\tcd .. &&\n+\trm -rf mw_dir\n+'\n+\n+# 3\n+test_expect_success 'Git clone creates only Main_Page.mw with an empty wiki' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\tgit clone mediawiki::http://localhost/wiki mw_dir &&\n+\ttest_contains_N_files mw_dir 1 &&\n+\ttest -e mw_dir/Main_Page.mw &&\n+\trm -rf mw_dir\n+'\n+\n+# 4\n+test_expect_success 'Git clone does not fetch a deleted page' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\twiki_editpage foo \"this page must be deleted before the clone\" false &&\n+\twiki_delete_page foo &&\n+\tgit clone mediawiki::http://localhost/wiki mw_dir &&\n+\ttest_contains_N_files mw_dir 1 &&\n+\ttest -e mw_dir/Main_Page.mw &&\n+\ttest ! -e mw_dir/Foo.mw &&\n+\trm -rf mw_dir\n+'\n+\n+# 5\n+test_expect_success 'Git clone works with page added' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\twiki_editpage foo \" I will be cloned\" false &&\n+\twiki_editpage bar \"I will be cloned\" false &&\n+\tgit clone mediawiki::http://localhost/wiki mw_dir &&\n+\twiki_getallpage ref_page &&\n+\ttest_diff_directories mw_dir ref_page &&\n+\twiki_delete_page foo &&\n+\trm -rf mw_dir &&\n+\trm -rf ref_page &&\n+\twiki_delete_page bar\n+'\n+\n+# 6\n+test_expect_success 'Git clone works with an edited page ' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\trm -rf ref_page &&\n+\n+\twiki_editpage foo \"this page will be edited\" \\\n+\t\tfalse -s \"first edition of page foo\"&&\n+\twiki_editpage foo \"this page has been edited and must be on the clone \" true &&\n+\tgit clone mediawiki::http://localhost/wiki mw_dir &&\n+\ttest -e mw_dir/Foo.mw &&\n+\ttest -e mw_dir/Main_Page.mw &&\n+\twiki_getallpage mw_dir/page_ref &&\n+\ttest_diff_directories mw_dir mw_dir/page_ref &&\n+\tcd mw_dir &&\n+\tgit log --format=%s HEAD^ Foo.mw > ../Foo.log &&\n+\tcd .. &&\n+\techo \"first edition of page foo\" > FooExpect.log &&\n+\trm -rf mw_dir &&\n+\tdiff FooExpect.log Foo.log\n+'\n+\n+# 7\n+test_expect_success 'Git clone works with several pages and some deleted ' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\twiki_editpage foo \"this page will not be deleted\" false &&\n+\twiki_editpage bar \"I must not be erased\" false &&\n+\twiki_editpage namnam \"I will not be there at the end\" false &&\n+\twiki_editpage nyancat \"nyan nyan nyan delete me\" false &&\n+\twiki_delete_page namnam &&\n+\twiki_delete_page nyancat &&\n+\tgit clone mediawiki::http://localhost/wiki mw_dir &&\n+\ttest -e mw_dir/Foo.mw &&\n+\ttest -e mw_dir/Bar.mw &&\n+\ttest ! -e mw_dir/Namnam.mw &&\n+\ttest ! -e mw_dir/Nyancat.mw &&\n+\twiki_getallpage mw_dir/page_ref &&\n+\ttest_diff_directories mw_dir mw_dir/page_ref &&\n+\trm -rf mw_dir\n+'\n+\n+# 8\n+test_expect_success 'Git clone works with one specific page cloned ' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\twiki_editpage foo \"I will not be cloned\" false &&\n+\twiki_editpage bar \"Do not clone me\" false &&\n+\twiki_editpage namnam \"I will be cloned :)\" false  -s=\"this log must stay\" &&\n+\twiki_editpage nyancat \"nyan nyan nyan you cant clone me\" false &&\n+\tgit clone -c remote.origin.pages=namnam mediawiki::http://localhost/wiki mw_dir &&\n+\ttest_contains_N_files mw_dir 1 &&\n+\ttest -e mw_dir/Namnam.mw &&\n+\ttest ! -e mw_dir/Main_Page.mw &&\n+\tcd mw_dir &&\n+\techo \"this log must stay\" > msg.tmp &&\n+\tgit log --format=%s > log.tmp &&\n+\tdiff -b msg.tmp log.tmp &&\n+\tcd .. &&\n+\twiki_check_content mw_dir/Namnam.mw Namnam &&\n+\trm -rf mw_dir\n+'\n+\n+# 9\n+test_expect_success 'Git clone works with multiple specific page cloned ' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\twiki_editpage foo \"I will be there\" false &&\n+\twiki_editpage bar \"I will not disapear\" false &&\n+\twiki_editpage namnam \"I be erased\" false &&\n+\twiki_editpage nyancat \"nyan nyan nyan you will not erase me\" false &&\n+\twiki_delete_page namnam &&\n+\tgit clone -c remote.origin.pages='\"'foo bar nyancat namnam'\"' mediawiki::http://localhost/wiki mw_dir &&\n+\ttest_contains_N_files mw_dir 3 &&\n+\ttest ! -e mw_dir/Namnam.mw &&\n+\ttest -e mw_dir/Foo.mw &&\n+\ttest -e mw_dir/Nyancat.mw &&\n+\ttest -e mw_dir/Bar.mw &&\n+\twiki_check_content mw_dir/Foo.mw Foo &&\n+\twiki_check_content mw_dir/Bar.mw Bar &&\n+\twiki_check_content mw_dir/Nyancat.mw Nyancat &&\n+\trm -rf mw_dir\n+'  \n+\n+# 10\n+test_expect_success 'Mediawiki-clone of several specific pages on wiki' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\twiki_editpage foo \"foo 1\" false &&\n+\twiki_editpage bar \"bar 1\" false &&\n+\twiki_editpage dummy \"dummy 1\" false &&\n+\twiki_editpage cloned_1 \"cloned_1 1\" false &&\n+\twiki_editpage cloned_2 \"cloned_2 2\" false &&\n+\twiki_editpage cloned_3 \"cloned_3 3\" false &&\n+\tmkdir -p ref_page &&\n+\twiki_getpage cloned_1 ref_page &&\n+\twiki_getpage cloned_2 ref_page &&\n+\twiki_getpage cloned_3 ref_page &&\n+\tgit clone -c remote.origin.pages=\"cloned_1 cloned_2 cloned_3\" mediawiki::http://localhost/wiki mw_dir_spage &&\n+\ttest_diff_directories mw_dir_spage ref_page &&\n+\trm -rf mw_dir_spage &&\n+\trm -rf ref_page\n+'\n+\n+# 11\n+test_expect_success 'Git clone works with the shallow option' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir_s_page &&\n+\trm -rf ref_page &&\n+\twiki_editpage foo \"1st revision, should be cloned\" false &&\n+\twiki_editpage bar \"1st revision, should be cloned\" false &&\n+\twiki_editpage nyan \"1st revision, should not be cloned\" false &&\n+\twiki_editpage nyan \"2nd revision, should be cloned\" false &&\n+\tgit -c remote.origin.shallow=true clone mediawiki::http://localhost/wiki/ mw_dir &&\n+\ttest_contains_N_files mw_dir 4 &&\n+\ttest -e mw_dir/Nyan.mw &&\n+\ttest -e mw_dir/Foo.mw &&\n+\ttest -e mw_dir/Bar.mw &&\n+\ttest -e mw_dir/Main_Page.mw &&\n+\tcd mw_dir &&\n+\ttest `git log --oneline Nyan.mw | wc -l` -eq 1 &&\n+\ttest `git log --oneline Foo.mw | wc -l` -eq 1 &&\n+\ttest `git log --oneline Bar.mw | wc -l` -eq 1 &&\n+\ttest `git log --oneline Main_Page.mw | wc -l ` -eq 1 &&\n+\tcd .. &&\n+\twiki_check_content mw_dir/Nyan.mw Nyan &&\n+\twiki_check_content mw_dir/Foo.mw Foo &&\n+\twiki_check_content mw_dir/Bar.mw Bar &&\n+\twiki_check_content mw_dir/Main_Page.mw Main_Page &&\n+\trm -rf mw_dir\n+'\n+\n+# 12\n+test_expect_success 'Git clone works with the shallow option with a delete page' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\twiki_editpage foo \"1st revision, will be deleted\" false &&\n+\twiki_editpage bar \"1st revision, should be cloned\" false &&\n+\twiki_editpage nyan \"1st revision, should not be cloned\" false &&\n+\twiki_editpage nyan \"2nd revision, should be cloned\" false &&\n+\twiki_delete_page foo &&\n+\tgit -c remote.origin.shallow=true clone mediawiki::http://localhost/wiki/ mw_dir &&\n+\ttest_contains_N_files mw_dir 3 &&\n+\ttest -e mw_dir/Nyan.mw &&\n+\ttest ! -e mw_dir/Foo.mw &&\n+\ttest -e mw_dir/Bar.mw &&\n+\ttest -e mw_dir/Main_Page.mw &&\n+\tcd mw_dir &&\n+\ttest `git log --oneline Nyan.mw | wc -l` -eq 1 &&\n+\ttest `git log --oneline Bar.mw | wc -l` -eq 1 &&\n+\ttest `git log --oneline Main_Page.mw | wc -l ` -eq 1 &&\n+\tcd .. &&\n+\twiki_check_content mw_dir/Nyan.mw Nyan &&\n+\twiki_check_content mw_dir/Bar.mw Bar &&\n+\twiki_check_content mw_dir/Main_Page.mw Main_Page &&\n+\trm -rf mw_dir\n+'\n+\n+# 13\n+test_expect_success 'Test of fetching a category' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\twiki_editpage Foo \"I will be cloned\" false -c=Category &&\n+\twiki_editpage Bar \"Meet me on the repository\" false -c=Category &&\n+\twiki_editpage Dummy \"I will not come\" false &&\n+\twiki_editpage BarWrong \"I will stay online only\" false -c=NotCategory &&\n+\tgit clone -c remote.origin.categories=\"Category\" mediawiki::http://localhost/wiki mw_dir &&\n+\twiki_getallpage ref_page Category &&\n+\ttest_diff_directories mw_dir ref_page\n+\trm -rf mw_dir &&\n+\trm -rf ref_page\n+'\n+\n+# 14\n+test_expect_success 'Test of resistance to modification of category on wiki for clone' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\trm -rf ref_page &&\n+\twiki_editpage Tobedeleted \"this page will be deleted\" false -c=Catone &&\n+\twiki_editpage Tobeedited \"this page will be modified\" false -c=Catone &&\n+\twiki_editpage Normalone \"this page wont be modified and will be on git\" false -c=Catone &&\n+\twiki_editpage Notconsidered \"this page will not appear on local\" false &&\n+\twiki_editpage Othercategory \"this page will not appear on local\" false -c=Cattwo &&\n+\twiki_editpage Tobeedited \"this page have been modified\" true -c=Catone &&\n+\twiki_delete_page Tobedeleted\n+\tgit clone -c remote.origin.categories=\"Catone\" mediawiki::http://localhost/wiki mw_dir &&\n+\twiki_getallpage ref_page Catone &&\n+\ttest_diff_directories mw_dir ref_page &&\n+\trm -rf mw_dir &&\n+\trm -rf ref_page \n+'\n+\n+test_done\n-- \n1.7.10.2.552.gaa3bb87\n"},{"id":"193375","messageId":"1339446526-22397-4-git-send-email-simon.cathebras@ensimag.imag.fr","threadId":"30773","inReplyTo":"1339446526-22397-1-git-send-email-simon.cathebras@ensimag.imag.fr","subject":"[PATCHv3 4/6] Tests for git-remote-mediawiki pull","fromName":"Simon Cathebras","fromEmail":"simon.cathebras@ensimag.imag.fr","sentAt":"2012-06-11T20:28:44Z","receivedAt":"2012-06-11T20:28:44Z","isPatch":false,"sender":{"key":"simon.cathebras@ensimag.imag.fr","avatar":"https://avatars.githubusercontent.com/u/1764010?v=4"},"body":"From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n\nThis patch provides a set of tests for the pull fonctionnality of\ngit-remote-mediawiki.\n\nThese tests are part of the file\ngit/contrib/mw-to-git/t/t9361-mw-to-git-pull.sh\n\nSigned-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>\nSigned-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>\nSigned-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>\nSigned-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\nSigned-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@imag.fr>\n---\n contrib/mw-to-git/t/t9361-mw-to-git-pull.sh | 149 ++++++++++++++++++++++++++++\n 1 file changed, 149 insertions(+)\n create mode 100755 contrib/mw-to-git/t/t9361-mw-to-git-pull.sh\n\ndiff --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\nnew file mode 100755\nindex 0000000..5f26cf5\n--- /dev/null\n+++ b/contrib/mw-to-git/t/t9361-mw-to-git-pull.sh\n@@ -0,0 +1,149 @@\n+#!/bin/sh\n+#\n+# Copyright (C) 2012\n+#     Charles Roussel <charles.roussel@ensimag.imag.fr>\n+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>\n+#     Julien Khayat <julien.khayat@ensimag.imag.fr>\n+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n+#     Simon Perrat <simon.perrat@ensimag.imag.fr>\n+#\n+# License: GPL v2 or later\n+\n+# tests for git-remote-mediawiki\n+\n+test_description='Test the Git Mediawiki remote helper: git push and git pull simple test cases'\n+\n+. ./test-gitmw-lib.sh\n+. $TEST_DIRECTORY/test-lib.sh\n+\n+TRASH_DIR=\"$CURR_DIR/trash\\ directory.$(basename $0 .sh)\"\n+\n+if ! test_have_prereq PERL\n+then\n+\tskip_all='skipping gateway git-mw tests, perl not available'\n+\ttest_done\n+fi\n+\n+if [ ! -f $GIT_BUILD_DIR/git-remote-mediawiki ];\n+then\n+\tskip_all='skipping gateway git-mw tests, no remote mediawiki for git found'\n+\ttest_done\n+fi\n+\n+if [ ! -d \"$WIKI_DIR_INST/$WIKI_DIR_NAME\" ] ;\n+then\n+\tskip_all='skipping gateway git-mw tests, no mediawiki found'\n+\ttest_done\n+fi\n+\n+\n+test_expect_success 'Git pull works after adding a new wiki page' \"\n+        wiki_reset &&\n+\tcd $TRASH_DIR &&\n+\trm -rf mw_dir &&\n+\trm -rf ref_page &&\n+\n+        git clone mediawiki::http://$SERVER_ADDR/$WIKI_DIR_NAME mw_dir &&\n+        wiki_editpage Foo \\\"page created after the git clone\\\" false &&\n+\n+        cd mw_dir &&\n+        git pull &&\n+        cd .. &&\n+\n+        rm -rf ref_page &&\n+        wiki_getallpage ref_page &&\n+        test_diff_directories mw_dir ref_page &&\n+        rm -rf ref_page &&\n+        rm -rf mw_dir\n+\"\n+\n+test_expect_success 'Git pull works after editing a wiki page' \"\n+        wiki_reset &&\n+\tcd $TRASH_DIR &&\n+\trm -rf mw_dir &&\n+\trm -rf ref_page &&\n+\n+        wiki_editpage Foo \\\"page created before the git clone\\\" false &&\n+        git clone mediawiki::http://$SERVER_ADDR/$WIKI_DIR_NAME mw_dir &&\n+        wiki_editpage Foo \\\"new line added on the wiki\\\" true &&\n+\n+        cd mw_dir &&\n+        git pull &&\n+        cd .. &&\n+\n+        rm -rf ref_page &&\n+        wiki_getallpage ref_page &&\n+        test_diff_directories mw_dir ref_page &&\n+        rm -rf ref_page &&\n+        rm -rf mw_dir\n+\"\n+\n+test_expect_success 'git pull works on conflict handled by auto-merge' \"\n+        wiki_reset &&\n+\tcd $TRASH_DIR &&\n+\trm -rf mw_dir &&\n+\trm -rf ref_page &&\n+\n+        wiki_editpage Foo \\\"1 init\n+3\n+5\n+\\\" false &&\n+        git clone mediawiki::http://$SERVER_ADDR/$WIKI_DIR_NAME mw_dir &&\n+\n+        wiki_editpage Foo \\\"1 init\n+2 content added on wiki after clone\n+3\n+5\n+\\\" false &&\n+\n+        cd mw_dir &&\n+        echo \\\"1 init\n+3\n+4 content added on git after clone\n+5\n+\\\" > Foo.mw &&\n+        git commit -am \\\"conflicting change on foo\\\" &&\n+        git pull &&\n+        git push &&\n+        cd .. &&\n+\n+        rm -rf mw_dir\n+\"\n+\n+test_expect_success 'Merge conflict expected' \"\n+        wiki_reset &&\n+\tcd $TRASH_DIR &&\n+\trm -rf mw_dir &&\n+\trm -rf ref_page &&\n+\n+        git clone mediawiki::http://$SERVER_ADDR/$WIKI_DIR_NAME mw_dir &&\n+        wiki_editpage Foo \\\"1 conflict\n+3 wiki\n+4\\\" false &&\n+\n+        cd mw_dir &&\n+        echo \\\"1 conflict\n+2 git\n+4\\\" > Foo.mw &&\n+        git add Foo.mw &&\n+        git commit -m \\\"conflict created\\\" &&\n+        test_must_fail git pull\n+\"\n+\n+test_expect_failure 'git pull works after deleting a wiki page' \"\n+        wiki_reset &&\n+\tcd $TRASH_DIR &&\n+        wiki_editpage Foo \\\"wiki page added before the git clone\\\" false &&\n+        git clone mediawiki::http://$SERVER_ADDR/$WIKI_DIR_NAME mw_dir &&\n+\n+        wiki_delete_page Foo &&\n+        cd mw_dir &&\n+        git pull &&\n+        test ! -f Foo.mw &&\n+        cd .. &&\n+\n+        rm -rf mw_dir\n+\"\n+\n+test_done\n+\n-- \n1.7.10.2.552.gaa3bb87\n"},{"id":"193372","messageId":"1339446526-22397-5-git-send-email-simon.cathebras@ensimag.imag.fr","threadId":"30773","inReplyTo":"1339446526-22397-1-git-send-email-simon.cathebras@ensimag.imag.fr","subject":"[PATCHv3 5/6] Test file for git-remote-mediawiki push","fromName":"Simon Cathebras","fromEmail":"simon.cathebras@ensimag.imag.fr","sentAt":"2012-06-11T20:28:45Z","receivedAt":"2012-06-11T20:28:45Z","isPatch":false,"sender":{"key":"simon.cathebras@ensimag.imag.fr","avatar":"https://avatars.githubusercontent.com/u/1764010?v=4"},"body":"From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n\nThis patch provides a set of tests for the push function of\ngit-remote-mediawiki.\n\nThese tests are part of the file\ngit/contrib/mw-to-git/t/t9361-mw-to-git-push.sh.\n\nSigned-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>\nSigned-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>\nSigned-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>\nSigned-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\nSigned-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@imag.fr>\n---\n contrib/mw-to-git/t/t9361-mw-to-git-push.sh | 110 ++++++++++++++++++++++++++++\n 1 file changed, 110 insertions(+)\n create mode 100755 contrib/mw-to-git/t/t9361-mw-to-git-push.sh\n\ndiff --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\nnew file mode 100755\nindex 0000000..447a337\n--- /dev/null\n+++ b/contrib/mw-to-git/t/t9361-mw-to-git-push.sh\n@@ -0,0 +1,110 @@\n+#!/bin/sh\n+#\n+# Copyright (C) 2012\n+#     Charles Roussel <charles.roussel@ensimag.imag.fr>\n+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>\n+#     Julien Khayat <julien.khayat@ensimag.imag.fr>\n+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n+#     Simon Perrat <simon.perrat@ensimag.imag.fr>\n+#\n+# License: GPL v2 or later\n+\n+# tests for git-remote-mediawiki\n+\n+test_description='Test the Git Mediawiki remote helper: git push and git pull simple test cases'\n+\n+. ./test-gitmw-lib.sh\n+. $TEST_DIRECTORY/test-lib.sh\n+\n+TRASH_DIR=\"$CURR_DIR/trash\\ directory.$(basename $0 .sh)\"\n+\n+if ! test_have_prereq PERL\n+then\n+\tskip_all='skipping gateway git-mw tests, perl not available'\n+\ttest_done\n+fi\n+\n+if [ ! -f $GIT_BUILD_DIR/git-remote-mediawiki ];\n+then\n+\tskip_all='skipping gateway git-mw tests, no remote mediawiki for git found'\n+\ttest_done\n+fi\n+\n+if [ ! -d \"$WIKI_DIR_INST/$WIKI_DIR_NAME\" ] ;\n+then\n+\tskip_all='skipping gateway git-mw tests, no mediawiki found'\n+\ttest_done\n+fi\n+\n+test_expect_success 'Git push works after adding a file .mw' \"\n+\twiki_reset &&\n+\tcd $TRASH_DIR &&\n+\tgit clone mediawiki::http://$SERVER_ADDR/$WIKI_DIR_NAME mw_dir &&\n+        wiki_getallpage ref_page &&\n+        cd mw_dir &&\n+        test ! -f Foo.mw &&\n+        touch Foo.mw &&\n+        echo \\\"hello world\\\" >> Foo.mw &&\n+        git add Foo.mw &&\n+        git commit -m \\\"Foo\\\" &&\n+        git push &&\n+        cd .. &&\n+\n+        rm -rf ref_page &&\n+        wiki_getallpage ref_page &&\n+        test_diff_directories mw_dir ref_page &&\n+        rm -rf ref_page &&\n+        rm -rf mw_dir\n+\"\n+\n+test_expect_success 'Git push works after editing a file .mw' \"\n+        wiki_reset &&\n+\tcd $TRASH_DIR &&\n+\trm -rf mw_dir &&\n+\trm -rf ref_page &&\n+        wiki_editpage \\\"Foo\\\" \\\"page created before the git clone\\\" false &&\n+        git clone mediawiki::http://$SERVER_ADDR/$WIKI_DIR_NAME mw_dir &&\n+\n+        cd mw_dir &&\n+        echo \\\"new line added in the file Foo.mw\\\" >> Foo.mw &&\n+        git commit -am \\\"edit file Foo.mw\\\" &&\n+        git push &&\n+        cd .. &&\n+\n+        rm -rf ref_page &&\n+        wiki_getallpage ref_page &&\n+        test_diff_directories mw_dir ref_page &&\n+        rm -rf ref_page &&\n+        rm -rf mw_dir\n+\"\n+\n+test_expect_failure 'Git push works after deleting a file' \"\n+        wiki_reset &&\n+\tcd $TRASH_DIR &&\n+\trm -rf mw_dir &&\n+\trm -rf ref_page &&\n+        wiki_editpage Foo \\\"wiki page added before git clone\\\" false &&\n+        git clone mediawiki::http://$SERVER_ADDR/$WIKI_DIR_NAME mw_dir &&\n+\n+        cd mw_dir &&\n+        git rm Foo.mw &&\n+        git commit -am \\\"page Foo.mw deleted\\\" &&\n+        git push &&\n+        cd .. &&\n+\n+        rm -rf mw_dir &&\n+        test ! wiki_page_exist Foo\n+\"\n+\n+test_expect_success 'Conflict solved manually' \"\n+        cat Foo.mw | sed '/[<=>][^$]*/ d' > Foo.mw~ &&\n+        cat Foo.mw~ > Foo.mw &&\n+        git commit -am \\\"merge conflict solved\\\" &&\n+        git push &&\n+\n+        cd .. &&\n+        rm -rf mw_dir\n+\"\n+\n+test_done\n+\n-- \n1.7.10.2.552.gaa3bb87\n"},{"id":"193376","messageId":"1339446526-22397-6-git-send-email-simon.cathebras@ensimag.imag.fr","threadId":"30773","inReplyTo":"1339446526-22397-1-git-send-email-simon.cathebras@ensimag.imag.fr","subject":"=?y?q?=5BPATCHv3=206/6=5D=20Tests=20of=20UTF8=20character=20with=20git-remote-mediawiki?=","fromName":"Simon Cathebras","fromEmail":"simon.cathebras@ensimag.imag.fr","sentAt":"2012-06-11T20:28:46Z","receivedAt":"2012-06-11T20:28:46Z","isPatch":false,"sender":{"key":"simon.cathebras@ensimag.imag.fr","avatar":"https://avatars.githubusercontent.com/u/1764010?v=4"},"body":"From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n\nThis patch provides a sample of tests for git-remote-mediawiki's\nresistance, concerning utf8 special characters.\n\nThe sample of tests is located in the file\ngit/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh\n\nSigned-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>\nSigned-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>\nSigned-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>\nSigned-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\nSigned-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@imag.fr>\n---\n contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh | 377 ++++++++++++++++++++++++++++\n 1 file changed, 377 insertions(+)\n create mode 100755 contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh\n\ndiff --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\nnew file mode 100755\nindex 0000000..57431da\n--- /dev/null\n+++ b/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh\n@@ -0,0 +1,377 @@\n+#!/bin/sh\n+#\n+# Copyright (C) 2012\n+#     Charles Roussel <charles.roussel@ensimag.imag.fr>\n+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>\n+#     Julien Khayat <julien.khayat@ensimag.imag.fr>\n+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n+#     Simon Perrat <simon.perrat@ensimag.imag.fr>\n+#\n+# License: GPL v2 or later\n+\n+# tests for git-remote-mediawiki\n+\n+test_description='Test git-mediawiki with special characters in filenames'\n+\n+. ./test-gitmw-lib.sh\n+. $TEST_DIRECTORY/test-lib.sh\n+\n+TRASH_DIR=\"$CURR_DIR/trash\\ directory.$(basename $0 .sh)\"\n+\n+if ! test_have_prereq PERL\n+then\n+\tskip_all='skipping gateway git-mw tests, '\\\n+\t\t'perl not available'\n+\ttest_done\n+fi\n+\n+if [ ! -f $GIT_BUILD_DIR/git-remote-mediawiki ];\n+then\n+\tskip_all='skipping gateway git-mw tests,' \\\n+\t\t' no remote mediawiki for git found'\n+\ttest_done\n+fi\n+\n+if [ ! -d \"$WIKI_DIR_INST/$WIKI_DIR_NAME\" ] ;\n+then\n+\tskip_all='skipping gateway git-mw tests, no mediawiki found'\n+\ttest_done\n+fi\n+\n+\n+# 1\n+test_expect_success 'Git clone works for a wiki with accents in the page names' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\trm -rf ref_page &&\n+\twiki_editpage féé \"This page must be délétéd before clone\" false &&\n+\twiki_editpage kèè \"This page must be deleted before clone\" false &&\n+\twiki_editpage hàà \"This page must be deleted before clone\" false &&\n+\twiki_editpage kîî \"This page must be deleted before clone\" false &&\n+\twiki_editpage foo \"This page must be deleted before clone\" false &&\n+\tgit clone mediawiki::http://localhost/wiki mw_dir &&\n+\twiki_getallpage ref_page &&\n+\ttest_diff_directories mw_dir ref_page\n+'\n+\n+# 2\n+test_expect_success 'Git pull works with a wiki with accents in the pages names' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\trm -rf ref_page &&\n+\twiki_editpage kîî \"this page must be cloned\" false &&\n+\twiki_editpage foo \"this page must be cloned\" false &&\n+\tgit clone mediawiki::http://localhost/wiki mw_dir &&\n+\twiki_editpage éàîôû \"This page must be pulled\" false &&\n+\tcd mw_dir &&\n+\tgit pull &&\n+\tcd .. && \n+\twiki_getallpage ref_page &&\n+\ttest_diff_directories mw_dir ref_page &&\n+\trm -rf mw_dir &&\n+\trm -rf ref_page\n+'\n+\n+# 3\n+test_expect_success 'Cloning a chosen page works with accents' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\trm -rf ref_page &&\n+\twiki_editpage kîî \"this page must be cloned\" false &&\n+\tgit clone -c remote.origin.pages=kîî mediawiki::http://localhost/wiki mw_dir &&\n+\twiki_check_content mw_dir/Kîî.mw Kîî &&\n+\ttest -e mw_dir/Kîî.mw &&\n+\trm -rf mw_dir\n+'\n+\n+# 4\n+test_expect_success 'The shallow option works with accents' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\trm -rf ref_page &&\n+\twiki_editpage néoà \"1st revision, should not be cloned\" false &&\n+\twiki_editpage néoà \"2nd revision, should be cloned\" false &&\n+\tgit -c remote.origin.shallow=true clone mediawiki::http://localhost/wiki/ mw_dir &&\n+\ttest_contains_N_files mw_dir 2 &&\n+\ttest -e mw_dir/Néoà.mw &&\n+\ttest -e mw_dir/Main_Page.mw &&\n+\tcd mw_dir &&\n+\ttest `git log --oneline Néoà.mw | wc -l` -eq 1 &&\n+\ttest `git log --oneline Main_Page.mw | wc -l ` -eq 1 &&\n+\tcd .. &&\n+\twiki_check_content mw_dir/Néoà.mw Néoà &&\n+\twiki_check_content mw_dir/Main_Page.mw Main_Page &&\n+\trm -rf mw_dir\n+'\n+\n+# 5\n+test_expect_success 'Cloning works when page name first letter has an accent' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\trm -rf ref_page &&\n+\twiki_editpage îî \"this page must be cloned\" false &&\n+\tgit clone -c remote.origin.pages=îî mediawiki::http://localhost/wiki mw_dir &&\n+\ttest -e mw_dir/Îî.mw &&\n+\twiki_check_content mw_dir/Îî.mw Îî &&\n+\trm -rf mw_dir\n+'\n+\n+# 6\n+test_expect_success 'Git push works with a wiki with accents' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\trm -rf ref_page &&\n+\twiki_editpage féé \"lots of accents : éèàÖ\" false &&\n+\twiki_editpage foo \"this page must be cloned\" false &&\n+\tgit clone mediawiki::http://localhost/wiki mw_dir &&\n+\tcd mw_dir &&\n+\techo \"A wild Pîkächû appears on the wiki\" > Pîkächû.mw &&\n+\tgit add Pîkächû.mw &&\n+\tgit commit -m \"A new page appears\" &&\n+\tgit push &&\n+\tcd .. &&\n+\twiki_getallpage ref_page &&\n+\ttest_diff_directories mw_dir ref_page &&\n+\trm -rf mw_dir &&\n+\trm -rf ref_page\n+'\n+\n+# 7\n+test_expect_success 'Git clone works with accentsand spaces' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\trm -rf ref_page &&\n+\twiki_editpage \"é à î\" \"this page must be délété before the clone\" false &&\n+\tgit clone mediawiki::http://localhost/wiki mw_dir &&\n+\twiki_getallpage ref_page &&\n+\ttest_diff_directories mw_dir ref_page &&\n+\trm -rf mw_dir &&\n+\trm -rf ref_page\n+'\n+# 8\n+test_expect_success 'character $ in page name (mw -> git)' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\trm -rf ref_page &&\n+\twiki_editpage file_\\$_foo \"expect to be called file_$_foo\" false &&\n+\tgit clone mediawiki::http://localhost/wiki mw_dir &&\n+\ttest -f mw_dir/File_\\$_foo.mw &&\n+\twiki_getallpage ref_page &&\n+\ttest_diff_directories mw_dir ref_page\n+'\n+\n+\n+# 9\n+test_expect_success 'character $ in file name (git -> mw) ' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\trm -rf ref_page &&\n+\tgit clone mediawiki::http://localhost/wiki mw_dir &&\n+\tcd mw_dir &&\n+\techo \"this file is called File_\\$_foo.mw\" > File_\\$_foo.mw &&\n+\tgit add . &&\n+\tgit commit -am \"file File_\\$_foo.mw\" &&\n+\tgit pull &&\n+\tgit push &&\n+\tcd .. &&\n+\twiki_getallpage ref_page &&\n+\ttest_diff_directories mw_dir ref_page\n+'\n+\n+# 10\n+test_expect_failure 'capital at the begining of file names' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\trm -rf ref_page &&\n+\tgit clone mediawiki::http://localhost/wiki mw_dir &&\n+\tcd mw_dir &&\n+\techo \"my new file foo\" > foo.mw &&\n+\techo \"my new file Foo... Finger crossed\" > Foo.mw &&\n+\tgit add . &&\n+\tgit commit -am \"file foo.mw\" &&\n+\tgit pull &&\n+\tgit push &&\n+\tcd .. &&\n+\twiki_getallpage ref_page &&\n+\ttest_diff_directories mw_dir ref_page\n+'\n+\n+\n+# 11\n+test_expect_failure 'special character at the begining of file name from mw to git' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\trm -rf ref_page &&\n+\tgit clone mediawiki::http://localhost/wiki mw_dir &&\n+\twiki_editpage {char_1 \"expect to be renamed {char_1\" false &&\n+\twiki_editpage [char_2 \"expect to be renamed [char_2\" false &&\n+\tcd mw_dir &&\n+\tgit pull &&\n+\tcd .. &&\n+\ttest -f mw_dir/{char_1 &&\n+\ttest -f mw_dir/[char_2\n+'\n+\n+# 12\n+test_expect_success 'test of correct formating for file name from mw to git' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\trm -rf ref_page &&\n+\tgit clone mediawiki::http://localhost/wiki mw_dir &&\n+\twiki_editpage char{_1 \"expect to be renamed char{_1\" false &&\n+\twiki_editpage char[_2 \"expect to be renamed char{_2\" false &&\n+\tcd mw_dir &&\n+\tgit pull &&\n+\tcd .. &&\n+\ttest -f mw_dir/Char\\{_1.mw &&\n+\ttest -f mw_dir/Char\\[_2.mw &&\n+\twiki_getallpage ref_page &&\n+\ttest_diff_directories mw_dir ref_page\n+'\n+\n+# 13\n+test_expect_failure 'test of correct formating for file name begining with special character' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\trm -rf ref_page &&\n+\tgit clone mediawiki::http://localhost/wiki mw_dir &&\n+\tcd mw_dir &&\n+\techo \"my new file {char_1\" > \\{char_1.mw &&\n+\techo \"my new file [char_2\" > \\[char_2.mw &&\n+\tgit add . &&\n+\tgit commit -am \"commiting some exotic file name...\" &&\n+\tgit push &&\n+\tgit pull &&\n+\tcd .. &&\n+\twiki_getallpage ref_page &&\n+\ttest -f ref_page/{char_1.mw &&\n+\ttest -f ref_page/[char_2.mw &&\n+\ttest_diff_directories mw_dir ref_page\n+'\n+\n+# 14\n+\n+test_expect_success 'test of correct formating for file name from git to mw' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\trm -rf ref_page &&\n+\tgit clone mediawiki::http://localhost/wiki mw_dir &&\n+\tcd mw_dir &&\n+\techo \"my new file char{_1\" > Char\\{_1.mw &&\n+\techo \"my new file char[_2\" > Char\\[_2.mw &&\n+\tgit add . &&\n+\tgit commit -m \"commiting some exotic file name...\" &&\n+\tgit push &&\n+\tcd .. &&\n+\twiki_getallpage ref_page &&\n+\ttest_diff_directories mw_dir ref_page\n+'\n+\n+\n+# 15\n+test_expect_success 'git clone with /' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\twiki_editpage \\/fo\\/o \"this is not important\" false -c=Deleted &&\n+\tgit clone mediawiki::http://localhost/wiki mw_dir &&\n+\ttest -f mw_dir/%2Ffo%2Fo.mw &&\n+\twiki_check_content mw_dir/%2Ffo%2Fo.mw \\/fo\\/o &&\n+\trm -rf mw_dir\n+'\n+\n+# 16\n+test_expect_success 'git push with /' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\tgit clone mediawiki::http://localhost/wiki mw_dir &&\n+\techo \"I will be on the wiki\" > mw_dir/%2Ffo%2Fo.mw &&\n+\tcd mw_dir &&\n+\tgit add %2Ffo%2Fo.mw &&\n+\tgit commit -m \" %2Ffo%2Fo added\" &&\n+\tgit push &&\n+\tcd .. &&\n+\twiki_page_exist \\/fo\\/o &&\n+\twiki_check_content mw_dir/%2Ffo%2Fo.mw \\/fo\\/o &&\n+\trm -rf mw_dir \n+\n+'\n+\n+# 17\n+test_expect_success 'git clone with \\' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\twiki_editpage \\\\ko\\\\o \"this is not important\" false -c=Deleted &&\n+\tgit clone mediawiki::http://localhost/wiki mw_dir &&\n+\ttest -f mw_dir/\\\\ko\\\\o.mw &&\n+\twiki_check_content mw_dir/\\\\ko\\\\o.mw \\\\ko\\\\o &&\n+\trm -rf mw_dir\n+'\n+\n+# 18\n+test_expect_success 'git push with \\' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\tgit clone mediawiki::http://localhost/wiki mw_dir &&\n+\techo \"I will be on the wiki\" > mw_dir/\\\\ko\\\\o.mw &&\n+\tcd mw_dir &&\n+\tgit add \\\\ko\\\\o.mw &&\n+\tgit commit -m \" \\\\ko\\\\o added\" &&\n+\tgit push &&\n+\tcd .. &&\n+\twiki_page_exist \\\\ko\\\\o &&\n+\twiki_check_content mw_dir/\\\\ko\\\\o.mw \\\\ko\\\\o &&\n+\trm -rf mw_dir\n+\n+'\n+\n+# 19\n+test_expect_success 'git clone with \\ in format control' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\twiki_editpage \\\\no\\\\o \"this is not important\" false &&\n+\tgit clone mediawiki::http://localhost/wiki mw_dir &&\n+\ttest -f mw_dir/\\\\no\\\\o.mw &&\n+\twiki_check_content mw_dir/\\\\no\\\\o.mw \\\\no\\\\o  \n+\t\n+'\n+\n+\n+# 20\n+test_expect_success 'git push with \\ in format contraol' '\n+\twiki_reset &&\n+\tcd '\"$TRASH_DIR\"' &&\n+\trm -rf mw_dir &&\n+\tgit clone mediawiki::http://localhost/wiki mw_dir &&\n+\techo \"I will be on the wiki\" > mw_dir/\\\\fo\\\\o.mw &&\n+\tcd mw_dir &&\n+\tgit add \\\\fo\\\\o.mw &&\n+\tgit commit -m \" \\\\fo\\\\o added\" &&\n+\tgit push &&\n+\tcd .. &&\n+\twiki_page_exist \\\\fo\\\\o &&\n+\twiki_check_content mw_dir/\\\\fo\\\\o.mw \\\\fo\\\\o && \n+\trm -rf mw_dir\n+\n+'\n+\n+\n+ test_done\n-- \n1.7.10.2.552.gaa3bb87\n"},{"id":"193382","messageId":"20120611230720.Horde.Xx4mVHwdC4BP1l4IcI6RWrA@webmail.minatec.grenoble-inp.fr","threadId":"30773","inReplyTo":"1339446526-22397-3-git-send-email-simon.cathebras@ensimag.imag.fr","subject":"Re: [PATCHv3 3/6] Test file for git-remote-mediawiki clone","fromName":"","fromEmail":"konglu@minatec.inpg.fr","sentAt":"2012-06-11T21:07:20Z","receivedAt":"2012-06-11T21:07:20Z","isPatch":false,"sender":{"key":"konglu@minatec.inpg.fr","avatar":null},"body":"\nSimon Cathebras <simon.cathebras@ensimag.imag.fr> a écrit :\n\n\n> +test_expect_success 'Git clone creates the git log expected with one file' '\n> +\twiki_reset &&\n> +\tcd '\"$TRASH_DIR\"' &&\n> +\trm -rf mw_dir &&\n> +\twiki_editpage foo \"this is not important\" false -c cat -s \"this  \n> must be the same\" &&\n> +\tgit clone mediawiki::http://localhost/wiki mw_dir &&\n> +\tcd mw_dir &&\n> +\tgit log --format=%s HEAD^..HEAD > log.tmp &&\n> +\techo \"this must be the same\" > msg.tmp &&\n> +\tdiff -b log.tmp msg.tmp &&\n> +\tcd .. &&\n> +\trm -rf mw_dir\n> +'\n> +\n\nIt's best not to chdir around outside a subshell (same comment for all the\nother tests)\n\nBTW, please be aware of the whitespaces (the first 5 parts of your patch are\nfull of it - couldn't apply the last one because of the special  \ncharacters, maybe\nsomething that i haven't configure, i don't know).\n"},{"id":"193383","messageId":"20120611230954.Horde.inb-aHwdC4BP1l6iLlHhZgA@webmail.minatec.grenoble-inp.fr","threadId":"30773","inReplyTo":"1339446526-22397-4-git-send-email-simon.cathebras@ensimag.imag.fr","subject":"Re: [PATCHv3 4/6] Tests for git-remote-mediawiki pull","fromName":"","fromEmail":"konglu@minatec.inpg.fr","sentAt":"2012-06-11T21:09:54Z","receivedAt":"2012-06-11T21:09:54Z","isPatch":false,"sender":{"key":"konglu@minatec.inpg.fr","avatar":null},"body":"\nSimon Cathebras <simon.cathebras@ensimag.imag.fr> a écrit :\n\n> +test_expect_success 'Git pull works after adding a new wiki page' \"\n> +        wiki_reset &&\n> +\tcd $TRASH_DIR &&\n> +\trm -rf mw_dir &&\n> +\trm -rf ref_page &&\n> +\n> +        git clone mediawiki::http://$SERVER_ADDR/$WIKI_DIR_NAME mw_dir &&\n> +        wiki_editpage Foo \\\"page created after the git clone\\\" false &&\n> +\n> +        cd mw_dir &&\n> +        git pull &&\n> +        cd .. &&\n> +\n> +        rm -rf ref_page &&\n> +        wiki_getallpage ref_page &&\n> +        test_diff_directories mw_dir ref_page &&\n> +        rm -rf ref_page &&\n> +        rm -rf mw_dir\n> +\"\n\nWhy are there dquotes here (and all the following tests) ? You used\nsimple quote in t9360.\n"},{"id":"193435","messageId":"4FD74B18.7080205@ensimag.imag.fr","threadId":"30773","inReplyTo":"20120611230720.Horde.Xx4mVHwdC4BP1l4IcI6RWrA@webmail.minatec.grenoble-inp.fr","subject":"Re: [PATCHv3 3/6] Test file for git-remote-mediawiki clone","fromName":"Simon.Cathebras","fromEmail":"simon.cathebras@ensimag.imag.fr","sentAt":"2012-06-12T13:58:48Z","receivedAt":"2012-06-12T13:58:48Z","isPatch":false,"sender":{"key":"simon.cathebras@ensimag.imag.fr","avatar":"https://avatars.githubusercontent.com/u/1764010?v=4"},"body":"\n\nOn 11/06/2012 23:07, konglu@minatec.inpg.fr wrote:\n>\n> Simon Cathebras <simon.cathebras@ensimag.imag.fr> a écrit :\n>\n>\n>> +test_expect_success 'Git clone creates the git log expected with one \n>> file' '\n>> +    wiki_reset &&\n>> +    cd '\"$TRASH_DIR\"' &&\n>> +    rm -rf mw_dir &&\n>> +    wiki_editpage foo \"this is not important\" false -c cat -s \"this \n>> must be the same\" &&\n>> +    git clone mediawiki::http://localhost/wiki mw_dir &&\n>> +    cd mw_dir &&\n>> +    git log --format=%s HEAD^..HEAD > log.tmp &&\n>> +    echo \"this must be the same\" > msg.tmp &&\n>> +    diff -b log.tmp msg.tmp &&\n>> +    cd .. &&\n>> +    rm -rf mw_dir\n>> +'\n>> +\n>\n> It's best not to chdir around outside a subshell (same comment for all \n> the\n> other tests)\n\nThanks, we managed to change these problems of chdir.\n\n>\n> BTW, please be aware of the whitespaces (the first 5 parts of your \n> patch are\n> full of it - couldn't apply the last one because of the special \n> characters, maybe\n> something that i haven't configure, i don't know).\n>\n>\nGot it. We modified this issue with whitespaces.\nIn addition, we know what prevented you to install the last patch: \nencoding problem. It will be fixed in the next update.\n\nSimon\n\n\n-- \nCATHEBRAS Simon\n\n2A-ENSIMAG\n\nFilière Ingéniérie des Systèmes d'Information\nMembre Bug-Buster\n"},{"id":"193436","messageId":"CA+hdvHgz0EFXMk2C9SA2AnDeeh9i8Eo7WPdYvkotLEN8og892A@mail.gmail.com","threadId":"30773","inReplyTo":"20120611230954.Horde.inb-aHwdC4BP1l6iLlHhZgA@webmail.minatec.grenoble-inp.fr","subject":"Re: [PATCHv3 4/6] Tests for git-remote-mediawiki pull","fromName":"Simon Perrat","fromEmail":"simon.perrat@ensimag.imag.fr","sentAt":"2012-06-12T13:58:51Z","receivedAt":"2012-06-12T13:58:51Z","isPatch":false,"sender":{"key":"simon.perrat@ensimag.imag.fr","avatar":null},"body":"2012/6/11  <konglu@minatec.inpg.fr>:\n>\n> Simon Cathebras <simon.cathebras@ensimag.imag.fr> a écrit :\n>\n>\n>> +test_expect_success 'Git pull works after adding a new wiki page' \"\n>> +        wiki_reset &&\n>> +       cd $TRASH_DIR &&\n>> +       rm -rf mw_dir &&\n>> +       rm -rf ref_page &&\n>> +\n>> +        git clone mediawiki::http://$SERVER_ADDR/$WIKI_DIR_NAME mw_dir &&\n>> +        wiki_editpage Foo \\\"page created after the git clone\\\" false &&\n>> +\n>> +        cd mw_dir &&\n>> +        git pull &&\n>> +        cd .. &&\n>> +\n>> +        rm -rf ref_page &&\n>> +        wiki_getallpage ref_page &&\n>> +        test_diff_directories mw_dir ref_page &&\n>> +        rm -rf ref_page &&\n>> +        rm -rf mw_dir\n>> +\"\n>\n>\n> Why are there dquotes here (and all the following tests) ? You used\n> simple quote in t9360.\n>\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n\nWe corrected this to use simple quotes in all our tests; originally we\nused double quotes because of $ in the scripts, now we're escaping\nthem.\n"},{"id":"193507","messageId":"1339535563-18958-1-git-send-email-simon.cathebras@ensimag.imag.fr","threadId":"30773","inReplyTo":"20120611230954.Horde.inb-aHwdC4BP1l6iLlHhZgA@webmail.minatec.grenoble-inp.fr","subject":"[PATCH 1/6] Scripts to install, delete and clear a MediaWiki","fromName":"Simon Cathebras","fromEmail":"simon.cathebras@ensimag.imag.fr","sentAt":"2012-06-12T21:12:39Z","receivedAt":"2012-06-12T21:12:39Z","isPatch":true,"sender":{"key":"simon.cathebras@ensimag.imag.fr","avatar":"https://avatars.githubusercontent.com/u/1764010?v=4"},"body":"From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n\nInstall_wiki.sh expects the first argument to be 'install' or 'delete'\n'install' installs a MediaWiki on the web's server with SQLite3\n'delete' deletes the previously created wiki.\nNote those functionnalities are made to be used from the user command line in\nthe directory git/contrib/mw-to-git/t/\n\ninstall_wiki also defines a function wiki_reset which clear all content\nof the previously created wiki. Note this functionnality is made to be\nused only by our test function in a subdirectory of t/\n\nSigned-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>\nSigned-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>\nSigned-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\nSigned-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>\nSigned-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@imag.fr>\n\n---\n contrib/mw-to-git/t/install-wiki.sh                |  45 ++++\n contrib/mw-to-git/t/install-wiki/LocalSettings.php | 128 +++++++++\n contrib/mw-to-git/t/install-wiki/db_install.php    | 110 ++++++++\n contrib/mw-to-git/t/test-gitmw-lib.sh              | 285 +++++++++++++++++++++\n contrib/mw-to-git/t/test.config                    |  35 +++\n 5 files changed, 603 insertions(+)\n create mode 100755 contrib/mw-to-git/t/install-wiki.sh\n create mode 100644 contrib/mw-to-git/t/install-wiki/LocalSettings.php\n create mode 100644 contrib/mw-to-git/t/install-wiki/db_install.php\n create mode 100755 contrib/mw-to-git/t/test-gitmw-lib.sh\n create mode 100644 contrib/mw-to-git/t/test.config\n\ndiff --git a/contrib/mw-to-git/t/install-wiki.sh b/contrib/mw-to-git/t/install-wiki.sh\nnew file mode 100755\nindex 0000000..17a1fc8\n--- /dev/null\n+++ b/contrib/mw-to-git/t/install-wiki.sh\n@@ -0,0 +1,45 @@\n+#!/bin/sh\n+\n+# This script installs or deletes a MediaWiki on your computer.\n+# It requires a web server with PHP and SQLite running. In addition, if you\n+# do not have MediaWiki sources on your computer, the option 'install'\n+# downloads them for you.\n+# Please set the CONFIGURATION VARIABLES in ./test-gitmw-lib.sh\n+\n+WIKI_TEST_DIR=$(cd \"$(dirname \"$0\")\" && pwd)\n+\n+if test -z \"$WIKI_TEST_DIR\"\n+then\n+\tWIKI_TEST_DIR=.\n+fi\n+\n+. \"$WIKI_TEST_DIR\"/test-gitmw-lib.sh\n+usage () {\n+\techo \"Usage: \"\n+\techo \"\t./install-wiki.sh <install | delete | help>\"\n+\techo \"\t\tinstall | -i :\tInstall a wiki on your computer.\"\n+\techo \"\t\tdelete | -d : Delete the wiki and all its pages and \"\n+\techo \"\t\t\tcontent.\"\n+}\n+\n+\n+# Argument: install, delete, --help | -h\n+case \"$1\" in\n+\t\"install\" | \"-i\")\n+\t\twiki_install\n+\t\texit 0\n+\t\t;;\n+\t\"delete\" | \"-d\")\n+\t\twiki_delete\n+\t\texit 0\n+\t\t;;\n+\t\"--help\" | \"-h\")\n+\t\tusage\n+\t\texit 0\n+\t\t;;\n+\t*)\n+\t\techo \"Invalid argument: $1\"\n+\t\tusage\n+\t\texit 1\n+\t\t;;\n+esac\ndiff --git a/contrib/mw-to-git/t/install-wiki/LocalSettings.php b/contrib/mw-to-git/t/install-wiki/LocalSettings.php\nnew file mode 100644\nindex 0000000..78d505c\n--- /dev/null\n+++ b/contrib/mw-to-git/t/install-wiki/LocalSettings.php\n@@ -0,0 +1,128 @@\n+<?php\n+# This file was automatically generated by the MediaWiki 1.19.0\n+# installer. If you make manual changes, please keep track in case you\n+# need to recreate them later.\n+#\n+# See includes/DefaultSettings.php for all configurable settings\n+# and their default values, but don't forget to make changes in _this_\n+# file, not there.\n+#\n+# Further documentation for configuration settings may be found at:\n+# http://www.mediawiki.org/wiki/Manual:Configuration_settings\n+\n+# Protect against web entry\n+if ( !defined( 'MEDIAWIKI' ) ) {\n+\texit;\n+}\n+\n+## Uncomment this to disable output compression\n+# $wgDisableOutputCompression = true;\n+\n+$wgSitename      = \"Git-MediaWiki-Test\";\n+$wgMetaNamespace = \"Git-MediaWiki-Test\";\n+\n+## The URL base path to the directory containing the wiki;\n+## defaults for all runtime URL paths are based off of this.\n+## For more information on customizing the URLs please see:\n+## http://www.mediawiki.org/wiki/Manual:Short_URL\n+$wgScriptPath       = \"@WG_SCRIPT_PATH@\";\n+$wgScriptExtension  = \".php\";\n+\n+## The protocol and server name to use in fully-qualified URLs\n+$wgServer           = \"@WG_SERVER@\";\n+\n+## The relative URL path to the skins directory\n+$wgStylePath        = \"$wgScriptPath/skins\";\n+\n+## The relative URL path to the logo.  Make sure you change this from the default,\n+## or else you'll overwrite your logo when you upgrade!\n+$wgLogo             = \"$wgStylePath/common/images/wiki.png\";\n+\n+## UPO means: this is also a user preference option\n+\n+$wgEnableEmail      = true;\n+$wgEnableUserEmail  = true; # UPO\n+\n+$wgEmergencyContact = \"apache@localhost\";\n+$wgPasswordSender   = \"apache@localhost\";\n+\n+$wgEnotifUserTalk      = false; # UPO\n+$wgEnotifWatchlist     = false; # UPO\n+$wgEmailAuthentication = true;\n+\n+## Database settings\n+$wgDBtype           = \"sqlite\";\n+$wgDBserver         = \"\";\n+$wgDBname           = \"wikidb\";\n+$wgDBuser           = \"\";\n+$wgDBpassword       = \"\";\n+\n+# SQLite-specific settings\n+$wgSQLiteDataDir    = \"@WG_SQLITE_DATADIR@\";\n+\n+\n+## Shared memory settings\n+$wgMainCacheType    = CACHE_NONE;\n+$wgMemCachedServers = array();\n+\n+## To enable image uploads, make sure the 'images' directory\n+## is writable, then set this to true:\n+$wgEnableUploads  = false;\n+$wgUseImageMagick = true;\n+$wgImageMagickConvertCommand =\"@CONVERT@\";\n+\n+# InstantCommons allows wiki to use images from http://commons.wikimedia.org\n+$wgUseInstantCommons  = false;\n+\n+## If you use ImageMagick (or any other shell command) on a\n+## Linux server, this will need to be set to the name of an\n+## available UTF-8 locale\n+$wgShellLocale = \"en_US.utf8\";\n+\n+## If you want to use image uploads under safe mode,\n+## create the directories images/archive, images/thumb and\n+## images/temp, and make them all writable. Then uncomment\n+## this, if it's not already uncommented:\n+#$wgHashedUploadDirectory = false;\n+\n+## Set $wgCacheDirectory to a writable directory on the web server\n+## to make your wiki go slightly faster. The directory should not\n+## be publically accessible from the web.\n+#$wgCacheDirectory = \"$IP/cache\";\n+\n+# Site language code, should be one of the list in ./languages/Names.php\n+$wgLanguageCode = \"en\";\n+\n+$wgSecretKey = \"1c912bfe3519fb70f5dc523ecc698111cd43d81a11c585b3eefb28f29c2699b7\";\n+#$wgSecretKey = \"@SECRETKEY@\";\n+\n+\n+# Site upgrade key. Must be set to a string (default provided) to turn on the\n+# web installer while LocalSettings.php is in place\n+$wgUpgradeKey = \"ddae7dc87cd0a645\";\n+\n+## Default skin: you can change the default skin. Use the internal symbolic\n+## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook', 'vector':\n+$wgDefaultSkin = \"vector\";\n+\n+## For attaching licensing metadata to pages, and displaying an\n+## appropriate copyright notice / icon. GNU Free Documentation\n+## License and Creative Commons licenses are supported so far.\n+$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright\n+$wgRightsUrl  = \"\";\n+$wgRightsText = \"\";\n+$wgRightsIcon = \"\";\n+\n+# Path to the GNU diff3 utility. Used for conflict resolution.\n+$wgDiff3 = \"/usr/bin/diff3\";\n+\n+# Query string length limit for ResourceLoader. You should only set this if\n+# your web server has a query string length limit (then set it to that limit),\n+# or if you have suhosin.get.max_value_length set in php.ini (then set it to\n+# that value)\n+$wgResourceLoaderMaxQueryLength = -1;\n+\n+\n+\n+# End of automatically generated settings.\n+# Add more configuration options below.\ndiff --git a/contrib/mw-to-git/t/install-wiki/db_install.php b/contrib/mw-to-git/t/install-wiki/db_install.php\nnew file mode 100644\nindex 0000000..3111c73\n--- /dev/null\n+++ b/contrib/mw-to-git/t/install-wiki/db_install.php\n@@ -0,0 +1,110 @@\n+<?php\n+/**\n+ * This script generates a SQLite database for a MediaWiki version 1.19.0\n+ * You must specify the login of the admin (argument 1) and its\n+ * password (argument 2) and the folder where the database file\n+ * is located (absolute path in argument 3).\n+ * It is used by the script install-wiki.sh in order to make easy the\n+ * installation of a MediaWiki.\n+ *\n+ * In order to generate a SQLite database file, MediaWiki ask the user\n+ * to submit some forms in its web browser. This script simulates this\n+ * behavior though the functions <get> and <submit>\n+ *\n+ */\n+$argc = $_SERVER['argc'];\n+$argv = $_SERVER['argv'];\n+\n+$login = $argv[2];\n+$pass = $argv[3];\n+$tmp = $argv[4];\n+$port = $argv[5];\n+\n+$url = 'http://localhost:'.$port.'/wiki/mw-config/index.php';\n+$db_dir = urlencode($tmp);\n+$tmp_cookie = tempnam($tmp,\"COOKIE_\");\n+/*\n+ * Fetchs a page with cURL.\n+ */\n+function get ($page_name = \"\") {\n+        $curl = curl_init();\n+        $page_name_add = \"\";\n+        if ($page_name != \"\") {\n+                $page_name_add = '?page='.$page_name;\n+        }\n+\t$url = $GLOBALS['url'].$page_name_add;\n+        $tmp_cookie=$GLOBALS['tmp_cookie'];\n+        curl_setopt($curl, CURLOPT_COOKIEJAR, $tmp_cookie);\n+        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);\n+        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);\n+        curl_setopt($curl, CURLOPT_COOKIEFILE, $tmp_cookie);\n+        curl_setopt($curl, CURLOPT_HEADER, true);\n+        curl_setopt($curl, CURLOPT_URL,$url);\n+\n+        $page = curl_exec($curl);\n+        curl_close($curl);\n+        return $page;\n+}\n+\n+/*\n+ * Submits a form with cURL.\n+ */\n+function submit($page_name, $option = \"\") {\n+        $curl = curl_init();\n+        $datapost = 'submit-continue=Continue+%E2%86%92';\n+        if ($option != \"\") {\n+                $datapost = $option.'&'.$datapost;\n+        }\n+\t$url = $GLOBALS['url'].'?page='.$page_name;\n+        $tmp_cookie = $GLOBALS['tmp_cookie'];\n+        curl_setopt($curl, CURLOPT_URL, $url);\n+        curl_setopt($curl, CURLOPT_POST, true);\n+        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);\n+        curl_setopt($curl, CURLOPT_POSTFIELDS, $datapost);\n+        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);\n+        curl_setopt($curl, CURLOPT_COOKIEJAR, $tmp_cookie);\n+        curl_setopt($curl, CURLOPT_COOKIEFILE, $tmp_cookie);\n+\n+        $page = curl_exec($curl);\n+        curl_close($curl);\n+        return \"$page\";\n+}\n+\n+/*\n+ * Here starts this script: simulates the behavior of the user\n+ * submitting forms to generates the database file.\n+ * Note this simulation was made for the MediaWiki version 1.19.0,\n+ * we can't assume it works with other versions.\n+ *\n+ */\n+\n+$page = get();\n+preg_match('/input type=\"hidden\" value=\"([0-9]+)\" name=\"LanguageRequestTime\"/',\n+        $page, $matches);\n+$timestamp = $matches[1];\n+$language = \"LanguageRequestTime=$timestamp&uselang=en&ContLang=en\";\n+$page = submit('Language', $language);\n+\n+submit('Welcome');\n+\n+$db_config = 'DBType=sqlite';\n+$db_config = $db_config.'&sqlite_wgSQLiteDataDir='.$db_dir;\n+$db_config = $db_config.'&sqlite_wgDBname='.$argv[1];\n+submit('DBConnect', $db_config);\n+\n+$wiki_config = 'config_wgSitename=TEST';\n+$wiki_config = $wiki_config.'&config__NamespaceType=site-name';\n+$wiki_config = $wiki_config.'&config_wgMetaNamespace=MyWiki';\n+$wiki_config = $wiki_config.'&config__AdminName='.$login;\n+\n+$wiki_config = $wiki_config.'&config__AdminPassword='.$pass;\n+$wiki_config = $wiki_config.'&config__AdminPassword2='.$pass;\n+\n+$wiki_config = $wiki_config.'&wiki__configEmail=email%40email.org';\n+$wiki_config = $wiki_config.'&config__SkipOptional=skip';\n+submit('Name', $wiki_config);\n+submit('Install');\n+submit('Install');\n+\n+unlink($tmp_cookie);\n+?>\ndiff --git a/contrib/mw-to-git/t/test-gitmw-lib.sh b/contrib/mw-to-git/t/test-gitmw-lib.sh\nnew file mode 100755\nindex 0000000..160f97b\n--- /dev/null\n+++ b/contrib/mw-to-git/t/test-gitmw-lib.sh\n@@ -0,0 +1,285 @@\n+# Copyright (C) 2012\n+#     Charles Roussel <charles.roussel@ensimag.imag.fr>\n+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>\n+#     Julien Khayat <julien.khayat@ensimag.imag.fr>\n+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n+#     Simon Perrat <simon.perrat@ensimag.imag.fr>\n+# License: GPL v2 or later\n+\n+#\n+# CONFIGURATION VARIABLES\n+# You might want to change these ones\n+#\n+\n+. ./test.config\n+\n+export CURR_DIR=$(pwd)\n+export TEST_DIRECTORY=$CURR_DIR/../../../t\n+\n+if test $LIGHTTPD = \"false\" ; then\n+\tPORT=80\n+else\n+\tWIKI_DIR_INST=\"$CURR_DIR/$WEB_WWW\"\n+fi\n+\n+# ================= Install part =================\n+\n+error () {\n+\techo \"$@\" >&2\n+\texit 1\n+}\n+\n+# config_lighttpd\n+#\n+# Create the configuration files and the folders necessary to start lighttpd.\n+# Overwrite any existing file.\n+config_lighttpd() {\n+\tmkdir -p $WEB\n+\tmkdir -p $WEB_TMP\n+\tmkdir -p $WEB_WWW\n+\tcat > $WEB/lighttpd.conf <<EOF\n+\tserver.document-root = \"$CURR_DIR/$WEB_WWW\"\n+\tserver.port = $PORT\n+\tserver.pid-file = \"$CURR_DIR/$WEB_TMP/pid\"\n+\n+\tserver.modules = (\n+\t\"mod_rewrite\",\n+\t\"mod_redirect\",\n+\t\"mod_access\",\n+\t\"mod_accesslog\",\n+\t\"mod_fastcgi\"\n+\t)\n+\n+\tindex-file.names = (\"index.php\" , \"index.html\")\n+\n+\tmimetype.assign\t\t    = (\n+\t\".pdf\"\t\t=>\t\"application/pdf\",\n+\t\".sig\"\t\t=>\t\"application/pgp-signature\",\n+\t\".spl\"\t\t=>\t\"application/futuresplash\",\n+\t\".class\"\t=>\t\"application/octet-stream\",\n+\t\".ps\"\t\t=>\t\"application/postscript\",\n+\t\".torrent\"\t=>\t\"application/x-bittorrent\",\n+\t\".dvi\"\t\t=>\t\"application/x-dvi\",\n+\t\".gz\"\t\t=>\t\"application/x-gzip\",\n+\t\".pac\"\t\t=>\t\"application/x-ns-proxy-autoconfig\",\n+\t\".swf\"\t\t=>\t\"application/x-shockwave-flash\",\n+\t\".tar.gz\"\t=>\t\"application/x-tgz\",\n+\t\".tgz\"\t\t=>\t\"application/x-tgz\",\n+\t\".tar\"\t\t=>\t\"application/x-tar\",\n+\t\".zip\"\t\t=>\t\"application/zip\",\n+\t\".mp3\"\t\t=>\t\"audio/mpeg\",\n+\t\".m3u\"\t\t=>\t\"audio/x-mpegurl\",\n+\t\".wma\"\t\t=>\t\"audio/x-ms-wma\",\n+\t\".wax\"\t\t=>\t\"audio/x-ms-wax\",\n+\t\".ogg\"\t\t=>\t\"application/ogg\",\n+\t\".wav\"\t\t=>\t\"audio/x-wav\",\n+\t\".gif\"\t\t=>\t\"image/gif\",\n+\t\".jpg\"\t\t=>\t\"image/jpeg\",\n+\t\".jpeg\"\t\t=>\t\"image/jpeg\",\n+\t\".png\"\t\t=>\t\"image/png\",\n+\t\".xbm\"\t\t=>\t\"image/x-xbitmap\",\n+\t\".xpm\"\t\t=>\t\"image/x-xpixmap\",\n+\t\".xwd\"\t\t=>\t\"image/x-xwindowdump\",\n+\t\".css\"\t\t=>\t\"text/css\",\n+\t\".html\"\t\t=>\t\"text/html\",\n+\t\".htm\"\t\t=>\t\"text/html\",\n+\t\".js\"\t\t=>\t\"text/javascript\",\n+\t\".asc\"\t\t=>\t\"text/plain\",\n+\t\".c\"\t\t=>\t\"text/plain\",\n+\t\".cpp\"\t\t=>\t\"text/plain\",\n+\t\".log\"\t\t=>\t\"text/plain\",\n+\t\".conf\"\t\t=>\t\"text/plain\",\n+\t\".text\"\t\t=>\t\"text/plain\",\n+\t\".txt\"\t\t=>\t\"text/plain\",\n+\t\".dtd\"\t\t=>\t\"text/xml\",\n+\t\".xml\"\t\t=>\t\"text/xml\",\n+\t\".mpeg\"\t\t=>\t\"video/mpeg\",\n+\t\".mpg\"\t\t=>\t\"video/mpeg\",\n+\t\".mov\"\t\t=>\t\"video/quicktime\",\n+\t\".qt\"\t\t=>\t\"video/quicktime\",\n+\t\".avi\"\t\t=>\t\"video/x-msvideo\",\n+\t\".asf\"\t\t=>\t\"video/x-ms-asf\",\n+\t\".asx\"\t\t=>\t\"video/x-ms-asf\",\n+\t\".wmv\"\t\t=>\t\"video/x-ms-wmv\",\n+\t\".bz2\"\t\t=>\t\"application/x-bzip\",\n+\t\".tbz\"\t\t=>\t\"application/x-bzip-compressed-tar\",\n+\t\".tar.bz2\"\t=>\t\"application/x-bzip-compressed-tar\",\n+\t\"\"\t\t=>\t\"text/plain\"\n+\t)\n+\n+\tfastcgi.server = ( \".php\" =>\n+\t(\"localhost\" =>\n+\t( \"socket\" => \"$CURR_DIR/$WEB_TMP/php.socket\",\n+\t\"bin-path\" => \"$PHP_DIR/php-cgi -c $CURR_DIR/$WEB/php.ini\"\n+\n+\t)\n+\t)\n+\t)\n+EOF\n+\n+\tcat > $WEB/php.ini <<EOF\n+\tsession.save_path ='$CURR_DIR/$WEB_TMP'\n+EOF\n+}\n+\n+# start_lighttpd\n+#\n+# Start or restart daemon lighttpd. If restart, rewrite configuration files.\n+start_lighttpd() {\n+\tif test -f \"$WEB_TMP/pid\"; then\n+\t\techo \"Instance already running. Restarting...\"\n+\t\tstop_lighttpd\n+\tfi\n+\tconfig_lighttpd\n+\t$LIGHTTPD_DIR/lighttpd -f $WEB/lighttpd.conf\n+\n+\tif test $? -ne 0 ; then\n+\t\techo \"Could not execute http deamon lighttpd\"\n+\t\texit 1\n+\tfi\n+}\n+\n+# stop_lighttpd\n+#\n+# Kill daemon lighttpd and removes files and folders associated.\n+stop_lighttpd () {\n+\n+\ttest -f \"$WEB_TMP/pid\" && kill $(cat \"$WEB_TMP/pid\")\n+\trm -rf $WEB\n+}\n+\n+# Create the SQLite database of the MediaWiki. If the database file already\n+# exists, it will be deleted.\n+# This script should be runned from the directory where $FILES_FOLDER is\n+# located.\n+create_db () {\n+\trm -f \"$TMP/$DB_FILE\"\n+\n+\techo \"Generating the SQLite database file. It can take some time ...\"\n+\t# Run the php script to generate the SQLite database file\n+\t# with cURL calls.\n+\tphp \"$FILES_FOLDER/$DB_INSTALL_SCRIPT\" $(basename \"$DB_FILE\" .sqlite) \\\n+\t\t\"$WIKI_ADMIN\" \"$WIKI_PASSW\" \"$TMP\" \"$PORT\"\n+\n+\tif [ ! -f \"$TMP/$DB_FILE\" ] ; then\n+\t\terror \"Can't create database file in TODO. Try to run ./install-wiki.sh delete first.\"\n+\tfi\n+\tchmod 666 \"$TMP/$DB_FILE\"\n+\n+\t# Copy the generated database file into the directory the\n+\t# user indicated.\n+\tcp --preserve=mode,ownership \"$TMP/$DB_FILE\" \"$FILES_FOLDER\" ||\n+\t\terror \"Unable to copy $TMP/$DB_FILE to $FILES_FOLDER\"\n+}\n+\n+# Install a wiki in your web server directory.\n+wiki_install () {\n+\tif test $LIGHTTPD = \"true\" ; then\n+\t\tstart_lighttpd\n+\tfi\n+\n+\tSERVER_ADDR=$SERVER_ADDR:$PORT\n+\t# In this part, we change directory to $TMP in order to download,\n+\t# unpack and copy the files of MediaWiki\n+\t(\n+\tmkdir -p \"$WIKI_DIR_INST/$WIKI_DIR_NAME\"\n+\tif [ ! -d \"$WIKI_DIR_INST/$WIKI_DIR_NAME\" ] ; then\n+\t\terror \"Folder $WIKI_DIR_INST/$WIKI_DIR_NAME doesn't exist.\n+\t\tPlease create it and launch the script again.\"\n+\tfi\n+\n+\t# Fetch MediaWiki's archive if not already present in the TMP directory\n+\tcd \"$TMP\"\n+\tif [ ! -f \"$MW_VERSION.tar.gz\" ] ; then\n+\t\techo \"Downloading $MW_VERSION sources ...\"\n+\t\twget \"http://download.wikimedia.org/mediawiki/1.19/mediawiki-1.19.0.tar.gz\" ||\n+\t\t\terror \"Unable to download \"\\\n+\t\t\t\"http://download.wikimedia.org/mediawiki/1.19/\"\\\n+\t\t\t\"mediawiki-1.19.0.tar.gz. \"\\\n+\t\t\t\"Please fix your connection and launch the script again.\"\n+\tfi\n+\ttar xfz \"$MW_VERSION.tar.gz\"\n+\techo \"$MW_VERSION.tar.gz downloaded in `pwd`.\"\\\n+\t\t\"You can delete it later if you want.\"\n+\n+\t# Copy the files of MediaWiki wiki in the web server's directory.\n+\tcd \"$MW_VERSION\"\n+\tcp -Rf * \"$WIKI_DIR_INST/$WIKI_DIR_NAME/\" ||\n+\t\terror \"Unable to copy WikiMedia's files from `pwd` to \"\\\n+\t\t\t\"$WIKI_DIR_INST/$WIKI_DIR_NAME\"\n+\t)\n+\n+\tcreate_db\n+\n+\t# Copy the generic LocalSettings.php in the web server's directory\n+\t# And modify parameters according to the ones set at the top\n+\t# of this script.\n+\t# Note that LocalSettings.php is never modified.\n+\tif [ ! -f \"$FILES_FOLDER/LocalSettings.php\" ] ; then\n+\t\terror \"Can't find $FILES_FOLDER/LocalSettings.php \" \\\n+\t\t\t\"in the current folder. \"\\\n+\t\t\"Please run the script inside its folder.\"\n+\tfi\n+\tcp \"$FILES_FOLDER/LocalSettings.php\" \\\n+\t\t\"$FILES_FOLDER/LocalSettings-tmp.php\" ||\n+\t\terror \"Unable to copy $FILES_FOLDER/LocalSettings.php \" \\\n+\t\t\"to $FILES_FOLDER/LocalSettings-tmp.php\"\n+\n+\t# Parse and set the LocalSettings file of the user according to the\n+\t# CONFIGURATION VARIABLES section at the beginning of this script\n+\tfile_swap=\"$FILES_FOLDER/LocalSettings-swap.php\"\n+\tsed \"s,@WG_SCRIPT_PATH@,/$WIKI_DIR_NAME,\" \\\n+\t\t\"$FILES_FOLDER/LocalSettings-tmp.php\" > \"$file_swap\"\n+\tmv \"$file_swap\" \"$FILES_FOLDER/LocalSettings-tmp.php\"\n+\tsed \"s,@WG_SERVER@,http://$SERVER_ADDR,\" \\\n+\t\t\"$FILES_FOLDER/LocalSettings-tmp.php\" > \"$file_swap\"\n+\tmv \"$file_swap\" \"$FILES_FOLDER/LocalSettings-tmp.php\"\n+\tsed \"s,@WG_SQLITE_DATADIR@,$TMP,\" \\\n+\t\t\"$FILES_FOLDER/LocalSettings-tmp.php\" > \"$file_swap\"\n+\tmv \"$file_swap\" \"$FILES_FOLDER/LocalSettings-tmp.php\"\n+\n+\tmv \"$FILES_FOLDER/LocalSettings-tmp.php\" \\\n+\t\t\"$WIKI_DIR_INST/$WIKI_DIR_NAME/LocalSettings.php\" ||\n+\t\terror \"Unable to move $FILES_FOLDER/LocalSettings-tmp.php\" \\\n+\t\t\"in $WIKI_DIR_INST/$WIKI_DIR_NAME\"\n+\techo \"File $FILES_FOLDER/LocalSettings.php is set in\" \\\n+\t\t\" $WIKI_DIR_INST/$WIKI_DIR_NAME\"\n+\n+\tchmod ugo+w \"$FILES_FOLDER/$DB_FILE\"\n+\n+\techo \"Your wiki has been installed. You can check it at\n+\t\thttp://$SERVER_ADDR/$WIKI_DIR_NAME\"\n+}\n+\n+# Reset the database of the wiki and the password of the admin\n+#\n+# Warning: This function must be called only in a subdirectory of t/ directory\n+wiki_reset () {\n+\t# Copy initial database of the wiki\n+\tif [ ! -f \"../$FILES_FOLDER/$DB_FILE\" ] ; then\n+\t\terror \"Can't find ../$FILES_FOLDER/$DB_FILE in the current folder.\"\n+\tfi\n+\tcp \"../$FILES_FOLDER/$DB_FILE\" \"$TMP\" ||\n+\t\terror \"Can't copy ../$FILES_FOLDER/$DB_FILE in $TMP\"\n+\techo \"File $FILES_FOLDER/$DB_FILE is set in $TMP\"\n+}\n+\n+# Delete the wiki created in the web server's directory and all its content\n+# saved in the database.\n+wiki_delete () {\n+\tif test $LIGHTTPD = \"true\"; then\n+\t\tstop_lighttpd\n+\telse\n+\t\t# Delete the wiki's directory.\n+\t\trm -rf \"$WIKI_DIR_INST/$WIKI_DIR_NAME\" ||\n+\t\t\terror \"Wiki's directory $WIKI_DIR_INST/\" \\\n+\t\t\t\"$WIKI_DIR_NAME could not be deleted\"\n+\t\t# Delete the wiki's SQLite database.\n+\t\trm -f \"$TMP/$DB_FILE\" || error \"Database $TMP/$DB_FILE could not be deleted.\"\n+\tfi\n+\n+\t# Delete the wiki's SQLite database\n+\trm -f \"$TMP/$DB_FILE\" || error \"Database $TMP/$DB_FILE could not be deleted.\"\n+\trm -f \"$FILES_FOLDER/$DB_FILE\"\n+\trm -rf \"$TMP/$MW_VERSION\"\n+}\ndiff --git a/contrib/mw-to-git/t/test.config b/contrib/mw-to-git/t/test.config\nnew file mode 100644\nindex 0000000..958b37b\n--- /dev/null\n+++ b/contrib/mw-to-git/t/test.config\n@@ -0,0 +1,35 @@\n+# Name of the web server's directory dedicated to the wiki is WIKI_DIR_NAME\n+WIKI_DIR_NAME=wiki\n+\n+# Login and password of the wiki's admin\n+WIKI_ADMIN=WikiAdmin\n+WIKI_PASSW=AdminPass\n+\n+# Address of the web server\n+SERVER_ADDR=localhost\n+\n+# SQLite database of the wiki, named DB_FILE, is located in TMP\n+TMP=/tmp\n+DB_FILE=wikidb.sqlite\n+\n+# If LIGHTTPD is not set to true, the script will use the defaut\n+# web server running in WIKI_DIR_INST.\n+WIKI_DIR_INST=/var/www\n+\n+# If LIGHTTPD is set to true, the script will use Lighttpd to run\n+# the wiki.\n+LIGHTTPD=true\n+\n+# The variables below are useful only if LIGHTTPD is set to true.\n+PORT=1234\n+PHP_DIR=/usr/bin\n+LIGHTTPD_DIR=/usr/sbin\n+WEB=WEB\n+WEB_TMP=$WEB/tmp\n+WEB_WWW=$WEB/www\n+\n+# The variables below are used by the script to install a wiki.\n+# You should not modify these unless you are modifying the script itself.\n+MW_VERSION=mediawiki-1.19.0\n+FILES_FOLDER=install-wiki\n+DB_INSTALL_SCRIPT=db_install.php\n-- \n1.7.10.2.552.gaa3bb87\n"},{"id":"193506","messageId":"1339535563-18958-2-git-send-email-simon.cathebras@ensimag.imag.fr","threadId":"30773","inReplyTo":"1339535563-18958-1-git-send-email-simon.cathebras@ensimag.imag.fr","subject":"[PATCH 2/6] Test environment of git-remote-mediawiki","fromName":"Simon Cathebras","fromEmail":"simon.cathebras@ensimag.imag.fr","sentAt":"2012-06-12T21:12:40Z","receivedAt":"2012-06-12T21:12:40Z","isPatch":true,"sender":{"key":"simon.cathebras@ensimag.imag.fr","avatar":"https://avatars.githubusercontent.com/u/1764010?v=4"},"body":"From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n\nIn order to test git-remote-mediawiki, we need a package of functions\nto manage a MediaWiki: edit a page, remove a page, fetch a page,\nfetch all pages on a given wiki.\n\nWe also need functions to compare the content of directories.\n\nThis patch provide these functions in the file\ngit/contrib/mw-to-git/t/test-gitmw-lib.sh and\ngit/contrib/mw-to-git/t/test-gitmw.pl\n\nIn addition, this patch provide Makefiles to execute tests.\nSee README file for more details.\n\nSigned-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>\nSigned-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>\nSigned-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\nSigned-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>\nSigned-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@imag.fr>\n---\n contrib/mw-to-git/Makefile            |  48 +++++++\n contrib/mw-to-git/t/Makefile          |  27 ++++\n contrib/mw-to-git/t/README            |  33 +++++\n contrib/mw-to-git/t/test-gitmw-lib.sh | 137 ++++++++++++++++++++\n contrib/mw-to-git/t/test-gitmw.pl     | 230 ++++++++++++++++++++++++++++++++++\n 5 files changed, 475 insertions(+)\n create mode 100644 contrib/mw-to-git/Makefile\n create mode 100644 contrib/mw-to-git/t/Makefile\n create mode 100644 contrib/mw-to-git/t/README\n create mode 100755 contrib/mw-to-git/t/test-gitmw.pl\n\ndiff --git a/contrib/mw-to-git/Makefile b/contrib/mw-to-git/Makefile\nnew file mode 100644\nindex 0000000..c9b1795\n--- /dev/null\n+++ b/contrib/mw-to-git/Makefile\n@@ -0,0 +1,48 @@\n+#\n+# Copyright (C) 2012\n+#     Charles Roussel <charles.roussel@ensimag.imag.fr>\n+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>\n+#     Julien Khayat <julien.khayat@ensimag.imag.fr>\n+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n+#     Simon Perrat <simon.perrat@ensimag.imag.fr>\n+#\n+## Build git-remote-mediawiki\n+\n+-include ../../config.mak.autogen\n+-include ../../config.mak\n+\n+ifndef PERL_PATH\n+\tPERL_PATH = /usr/bin/perl\n+endif\n+ifndef gitexecdir\n+\tgitexecdir = $(shell git --exec-path)\n+endif\n+\n+PERL_PATH_SQ = $(subst ','\\'',$(PERL_PATH))\n+gitexecdir_SQ = $(subst ','\\'',$(gitexecdir))\n+SCRIPT = git-remote-mediawiki\n+\n+.PHONY: install help doc test clean\n+\n+help:\n+\t@echo 'This is the help target of the Makefile. Current configuration:'\n+\t@echo '  gitexecdir = $(gitexecdir_SQ)'\n+\t@echo '  PERL_PATH = $(PERL_PATH_SQ)'\n+\t@echo 'Run \"$(MAKE) install\" to install $(SCRIPT) in gitexecdir'\n+\t@echo 'Run \"$(MAKE) test\" to run the testsuite'\n+\n+install:\n+\tsed -e '1s|#!.*/perl|#!$(PERL_PATH_SQ)|' $(SCRIPT) \\\n+            > '$(gitexecdir_SQ)/$(SCRIPT)'\n+\tchmod +x '$(gitexecdir)/$(SCRIPT)'\n+\n+doc:\n+\t@echo 'Sorry, \"make doc\" is not implemented yet for $(SCRIPT)'\n+\n+test:\n+\t$(MAKE) -C t/ test\n+\n+clean:\n+\t$(RM) '$(gitexecdir)/$(SCRIPT)'\n+\t$(MAKE) -C t/ clean\n+\ndiff --git a/contrib/mw-to-git/t/Makefile b/contrib/mw-to-git/t/Makefile\nnew file mode 100644\nindex 0000000..752fd1f\n--- /dev/null\n+++ b/contrib/mw-to-git/t/Makefile\n@@ -0,0 +1,27 @@\n+#\n+# Copyright (C) 2012\n+#     Charles Roussel <charles.roussel@ensimag.imag.fr>\n+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>\n+#     Julien Khayat <julien.khayat@ensimag.imag.fr>\n+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n+#     Simon Perrat <simon.perrat@ensimag.imag.fr>\n+#\n+## Test git-remote-mediawiki\n+\n+-include ../../../config.mak.autogen\n+-include ../../../config.mak\n+\n+T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)\n+\n+.PHONY: help test clean\n+\n+help:\n+\t@echo 'Run \"$(MAKE) test\" to launch test scripts'\n+\t@echo 'Run \"$(MAKE)\" clean to remove trash folders'\n+\n+test:\n+\tfor t in $(T); do \"./$$t\"; done\n+\n+clean:\n+\t$(RM) -r 'trash directory'.*\n+\ndiff --git a/contrib/mw-to-git/t/README b/contrib/mw-to-git/t/README\nnew file mode 100644\nindex 0000000..b68147b\n--- /dev/null\n+++ b/contrib/mw-to-git/t/README\n@@ -0,0 +1,33 @@\n+Tests for Mediawiki-to-Git\n+==========================\n+\n+\n+Installation\n+------------\n+These tests require a mediawiki with admin access to work on; you can install one\n+on localhost/wiki simply by running:\n+\t./install-wiki.sh install\n+Be aware that the tests will flush the wiki database, thus if you own a wiki at\n+this adress, it is strongly advised to configure another name in test-gitmw-lib.sh\n+before running the script.\n+Note that the wiki will be installed in /tmp (this can be configured too), meaning\n+you might have to install it again when you run tests later.\n+\n+\n+Running\n+-------\n+You can run these tests either individually or with make (recommended). Remember\n+to use make clean when you're done. You have access to all options from git core\n+tests.\n+\n+\n+Limitations\n+-------\n+This test environment does not allow you to test the behavior of git-remote-mediawiki\n+for name containing backslashes.\n+\n+t9360: tests git clone.\n+\n+t9361: tests git pull and git push.\n+\n+t9362: tests how UTF-8 special characters are handled.\ndiff --git a/contrib/mw-to-git/t/test-gitmw-lib.sh b/contrib/mw-to-git/t/test-gitmw-lib.sh\nindex 160f97b..30be380 100755\n--- a/contrib/mw-to-git/t/test-gitmw-lib.sh\n+++ b/contrib/mw-to-git/t/test-gitmw-lib.sh\n@@ -22,6 +22,143 @@ else\n \tWIKI_DIR_INST=\"$CURR_DIR/$WEB_WWW\"\n fi\n \n+\n+wiki_getpage () {\n+\t\"$CURR_DIR\"/test-gitmw.pl get_page \"$@\"\n+}\n+\n+wiki_delete_page () {\n+\t\"$CURR_DIR\"/test-gitmw.pl delete_page \"$@\"\n+}\n+\n+wiki_editpage () {\n+\t\"$CURR_DIR\"/test-gitmw.pl edit_page \"$@\"\n+}\n+\n+die () {\n+\tdie_with_status 1 \"$@\"\n+}\n+\n+die_with_status () {\n+\tstatus=$1\n+\tshift\n+\techo >&2 \"$*\"\n+\texit \"$status\"\n+}\n+\n+\n+# Check the preconditions to run git-remote-mediawiki's tests\n+test_check_precond () {\n+\tif ! test_have_prereq PERL\n+\tthen\n+\t\tskip_all='skipping gateway git-mw tests, perl not available'\n+\t\ttest_done\n+\tfi\n+\n+\tif [ ! -f $GIT_BUILD_DIR/git-remote-mediawiki ];\n+\tthen\n+\t\tskip_all='skipping gateway git-mw tests, no remote mediawiki for git found' \\\n+\t\t'please try: cp git/contrib/mw-to-git/git-remote-mediawiki git/'\n+\t\ttest_done\n+\tfi\n+\n+\tif [ ! -d \"$WIKI_DIR_INST/$WIKI_DIR_NAME\" ] ;\n+\tthen\n+\t\tskip_all='skipping gateway git-mw tests, no mediawiki found'\n+\t\ttest_done\n+\tfi\n+}\n+\n+# test_diff_directories <dir_git> <dir_wiki>\n+#\n+# Compare the contents of directories <dir_git> and <dir_wiki> with diff\n+# and errors if they do not match. The program will\n+# not look into .git in the process.\n+# Warning: the first argument MUST be the directory containing the git data\n+test_diff_directories () {\n+\trm -rf \"$1_tmp\"\n+\tmkdir -p \"$1_tmp\"\n+\tcp \"$1\"/*.mw \"$1_tmp\"\n+\tdiff -r -b \"$1_tmp\" \"$2\"\n+}\n+\n+# $1=<dir>\n+# $2=<N>\n+#\n+# Check that <dir> contains exactly <N> files\n+test_contains_N_files () {\n+\ttest `ls \"$1\" | wc -l` -eq \"$2\";\n+}\n+\n+\n+# wiki_check_content <file_name> <page_name>\n+#\n+# Compares the contents of the file <file_name> and the wiki page\n+# <page_name> and exits with error 1 if they do not match.\n+wiki_check_content () {\n+\tmkdir -p wiki_tmp\n+\twiki_getpage \"$2\" wiki_tmp\n+\t#replacement of forbidden character in file name\n+\tpage_name=$(printf \"%s\\n\" \"$2\" | sed -e \"s/\\//%2F/g\")\n+\n+\tdiff -b \"$1\" wiki_tmp/\"$page_name\".mw\n+\tif test $? -ne 0\n+\tthen\n+\t\trm -rf wiki_tmp\n+\t\terror \"ERROR: file $2 not found on wiki\"\n+\tfi\n+\trm -rf wiki_tmp\n+}\n+\n+# wiki_page_exist <page_name>\n+#\n+# Check the existence of the page <page_name> on the wiki and exits\n+# with error if it is absent from it.\n+wiki_page_exist () {\n+\tmkdir -p wiki_tmp\n+\twiki_getpage \"$1\" wiki_tmp\n+\tpage_name=$(printf \"%s\\n\" \"$1\" | sed \"s/\\//%2F/g\")\n+\tif test -f wiki_tmp/\"$page_name\".mw ; then\n+\t\trm -rf wiki_tmp\n+\telse\n+\t\trm -rf wiki_tmp\n+\t\terror \"test failed: file $1 not found on wiki\"\n+\tfi\n+}\n+\n+# wiki_getallpagename\n+#\n+# Fetch the name of each page on the wiki.\n+wiki_getallpagename () {\n+\t$CURR_DIR/test-gitmw.pl getallpagename\n+}\n+\n+# wiki_getallpagecategory <category>\n+#\n+# Fetch the name of each page belonging to <category> on the wiki.\n+wiki_getallpagecategory () {\n+\t$CURR_DIR/test-gitmw.pl getallpagename \"$@\"\n+}\n+\n+# wiki_getallpage <dest_dir> [<category>]\n+#\n+# Fetch all the pages from the wiki and place them in the directory\n+# <dest_dir>.\n+# If <category> is define, then wiki_getallpage fetch the pages included\n+# in <category>.\n+wiki_getallpage () {\n+\tif test -z \"$2\";\n+\tthen\n+\t\twiki_getallpagename\n+\telse\n+\t\twiki_getallpagecategory \"$2\"\n+\tfi\n+\tmkdir -p \"$1\"\n+\twhile read -r line; do\n+\t\twiki_getpage \"$line\" $1;\n+\tdone < all.txt\n+}\n+\n # ================= Install part =================\n \n error () {\ndiff --git a/contrib/mw-to-git/t/test-gitmw.pl b/contrib/mw-to-git/t/test-gitmw.pl\nnew file mode 100755\nindex 0000000..43faee5\n--- /dev/null\n+++ b/contrib/mw-to-git/t/test-gitmw.pl\n@@ -0,0 +1,230 @@\n+#!/usr/bin/perl -w -s\n+# Copyright (C) 2012\n+#     Charles Roussel <charles.roussel@ensimag.imag.fr>\n+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>\n+#     Julien Khayat <julien.khayat@ensimag.imag.fr>\n+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n+#     Simon Perrat <simon.perrat@ensimag.imag.fr>\n+# License: GPL v2 or later\n+\n+# Usage:\n+#       ./test-gitmw.pl <command> [argument]*\n+# Execute in terminal using the name of the function to call as first\n+# parameter, and the function's arguments as following parameters\n+#\n+# Example:\n+#     ./test-gitmw.pl \"get_page\" foo .\n+# will call <wiki_getpage> with arguments <foo> and <.>\n+#\n+# Available functions are:\n+#     \"get_page\"\n+#     \"delete_page\"\n+#     \"edit_page\"\n+#     \"getallpagename\"\n+\n+use MediaWiki::API;\n+use Getopt::Long;\n+use Switch;\n+use encoding 'utf8';\n+use DateTime::Format::ISO8601;\n+use open ':encoding(utf8)';\n+use constant SLASH_REPLACEMENT => \"%2F\";\n+\n+#Parsing of the config file\n+\n+my $configfile = \"$ENV{'CURR_DIR'}/test.config\";\n+my %config;\n+open (CONFIG,\"< $configfile\") || die \"can't open $configfile: $!\";\n+while (<CONFIG>)\n+{\n+        chomp;\n+        s/#.*//;\n+        s/^\\s+//;\n+        s/\\s+$//;\n+        next unless length;\n+        my ($key, $value) = split (/\\s*=\\s*/,$_, 2);\n+        $config{$key} = $value;\n+\tlast if ($key eq 'LIGHTTPD' and $value eq 'false');\n+\tlast if ($key eq 'PORT');\n+}\n+\n+my $wiki_address = \"http://$config{'SERVER_ADDR'}\".\":\".\"$config{'PORT'}\";\n+my $wiki_url = \"$wiki_address/$config{'WIKI_DIR_NAME'}/api.php\";\n+my $wiki_admin = \"$config{'WIKI_ADMIN'}\";\n+my $wiki_admin_pass = \"$config{'WIKI_PASSW'}\";\n+my $mw = MediaWiki::API->new;\n+$mw->{config}->{api_url} = $wiki_url;\n+\n+sub mediawiki_clean_filename {\n+\tmy $filename = shift;\n+\t$filename =~ s/@{[SLASH_REPLACEMENT]}/\\//g;\n+\t# [, ], |, {, and } are forbidden by MediaWiki, even URL-encoded.\n+\t# Do a variant of URL-encoding, i.e. looks like URL-encoding,\n+\t# but with _ added to prevent MediaWiki from thinking this is\n+\t# an actual special character.\n+\t$filename =~ s/[\\[\\]\\{\\}\\|]/sprintf(\"_%%_%x\", ord($&))/ge;\n+\t# If we use the uri escape before\n+\t# we should unescape here, before anything\n+\n+\treturn $filename;\n+}\n+\n+sub mediawiki_smudge_filename {\n+\tmy $filename = shift;\n+\t$filename =~ s/\\//@{[SLASH_REPLACEMENT]}/g;\n+\t$filename =~ s/ /_/g;\n+\t# Decode forbidden characters encoded in mediawiki_clean_filename\n+\t$filename =~ s/_%_([0-9a-fA-F][0-9a-fA-F])/sprintf(\"%c\", hex($1))/ge;\n+\treturn $filename;\n+}\n+\n+\n+# wiki_login <name> <password>\n+#\n+# Logs the user with <name> and <password> in the global variable\n+# of the mediawiki $mw\n+sub wiki_login {\n+\t$mw->login( { lgname => \"$_[0]\",lgpassword => \"$_[1]\" } )\n+\t|| die \"getpage: login failed\";\n+}\n+\n+# wiki_getpage <wiki_page> <dest_path>\n+#\n+# fetch a page <wiki_page> from the wiki referenced in the global variable\n+# $mw and copies its content in directory dest_path\n+sub wiki_getpage {\n+\tmy $pagename = $_[0];\n+\tmy $destdir = $_[1];\n+\n+\tmy $page = $mw->get_page( { title => $pagename } );\n+\tif (!defined($page)) {\n+\t\tdie \"getpage: wiki does not exist\";\n+\t}\n+\n+\tmy $content = $page->{'*'};\n+\tif (!defined($content)) {\n+\t\tdie \"getpage: page does not exist\";\n+\t}\n+\n+\t# Replace spaces by underscore in the page name\n+\t$pagename=$page->{'title'};\n+\t$pagename = mediawiki_smudge_filename $pagename;\n+\topen(my $file, \">$destdir/$pagename.mw\");\n+\tprint $file \"$content\";\n+\tclose ($file);\n+\n+}\n+\n+# wiki_delete_page <page_name>\n+#\n+# delete the page with name <page_name> from the wiki referenced\n+# in the global variable $mw\n+sub wiki_delete_page {\n+\tmy $pagename = $_[0];\n+\n+\tmy $exist=$mw->get_page({title => $pagename});\n+\n+\tif (defined($exist->{'*'})){\n+\t\t$mw->edit({ action => 'delete',\n+\t\t\t\ttitle => $pagename})\n+\t\t|| die $mw->{error}->{code} . \": \" . $mw->{error}->{details};\n+\t} else {\n+\t\tdie \"no page with such name found: $pagename\\n\";\n+\t}\n+}\n+\n+# wiki_editpage <wiki_page> <wiki_content> <wiki_append> [-c=<category>] [-s=<summary>]\n+#\n+# Edit a page named <wiki_page> with content <wiki_content> on the wiki\n+# referenced with the global variable $mw\n+# If <wiki_append> == true : append <wiki_content> at the end of the actual\n+# content of the page <wiki_page>\n+# If <wik_page> doesn't exist, that page is created with the <wiki_content>\n+sub wiki_editpage {\n+\tmy $wiki_page = mediawiki_clean_filename $_[0];\n+\tmy $wiki_content = $_[1];\n+\tmy $wiki_append = $_[2];\n+\tmy $summary = \"\";\n+\tmy ($summ, $cat) = ();\n+\tGetOptions('s=s' => \\$summ, 'c=s' => \\$cat);\n+\n+\tmy $append = 0;\n+\tif (defined($wiki_append) && $wiki_append eq 'true') {\n+\t\t$append=1;\n+\t}\n+\n+\tmy $previous_text =\"\";\n+\n+\tif ($append) {\n+\t\tmy $ref = $mw->get_page( { title => $wiki_page } );\n+\t\t$previous_text = $ref->{'*'};\n+\t}\n+\n+\tmy $text = $wiki_content;\n+\tif (defined($previous_text)) {\n+\t\t$text=\"$previous_text$text\";\n+\t}\n+\n+\t# Eventually, add this page to a category.\n+\tif (defined($cat)) {\n+\t\tmy $category_name=\"[[Category:$cat]]\";\n+\t\t$text=\"$text\\n $category_name\";\n+\t}\n+\tif(defined($summ)){\n+\t\t$summary=$summ;\n+\t}\n+\n+\t$mw->edit( { action => 'edit', title => $wiki_page, summary => $summary, text => \"$text\"} );\n+}\n+\n+# wiki_getallpagename [<category>]\n+#\n+# Fetch all pages of the wiki referenced by the global variable $mw\n+# and print the names of each one in the file all.txt with a new line\n+# (\"\\n\") between these.\n+# If the argument <category> is defined, then this function get only the pages\n+# belonging to <category>.\n+sub wiki_getallpagename {\n+\t# fetch the pages of the wiki\n+\tif (defined($_[0])) {\n+\t\tmy $mw_pages = $mw->list ( { action => 'query',\n+\t\t\t\tlist => 'categorymembers',\n+\t\t\t\tcmtitle => \"Category:$_[0]\",\n+\t\t\t\tcmnamespace => 0,\n+\t\t\t\tcmlimit=> 500 },\n+\t\t)\n+\t\t|| die $mw->{error}->{code}.\": \".$mw->{error}->{details};\n+\t\topen(my $file, \">all.txt\");\n+\t\tforeach my $page (@{$mw_pages}) {\n+\t\t\tprint $file \"$page->{title}\\n\";\n+\t\t}\n+\t\tclose ($file);\n+\n+\t} else {\n+\t\tmy $mw_pages = $mw->list({\n+\t\t\t\taction => 'query',\n+\t\t\t\tlist => 'allpages',\n+\t\t\t\taplimit => 500,\n+\t\t\t})\n+\t\t|| die $mw->{error}->{code}.\": \".$mw->{error}->{details};\n+\t\topen(my $file, \">all.txt\");\n+\t\tforeach my $page (@{$mw_pages}) {\n+\t\t\tprint $file \"$page->{title}\\n\";\n+\t\t}\n+\t\tclose ($file);\n+\t}\n+}\n+\n+# Main part of this script: parse the command line arguments\n+# and select which function to execute\n+my $fct_to_call = shift;\n+\n+&wiki_login($wiki_admin,$wiki_admin_pass);\n+\n+switch ($fct_to_call) {\n+\tcase \"get_page\" { &wiki_getpage(@ARGV)}\n+\tcase \"delete_page\" { &wiki_delete_page(@ARGV)}\n+\tcase \"edit_page\" { &wiki_editpage(@ARGV)}\n+\tcase \"getallpagename\" { &wiki_getallpagename(@ARGV)}\n+\telse { die(\"test-gitmw.pl ERROR: wrong argument\")}\n+}\n-- \n1.7.10.2.552.gaa3bb87\n"},{"id":"193510","messageId":"1339535563-18958-3-git-send-email-simon.cathebras@ensimag.imag.fr","threadId":"30773","inReplyTo":"1339535563-18958-1-git-send-email-simon.cathebras@ensimag.imag.fr","subject":"[PATCH 3/6] Test file for git-remote-mediawiki clone","fromName":"Simon Cathebras","fromEmail":"simon.cathebras@ensimag.imag.fr","sentAt":"2012-06-12T21:12:41Z","receivedAt":"2012-06-12T21:12:41Z","isPatch":true,"sender":{"key":"simon.cathebras@ensimag.imag.fr","avatar":"https://avatars.githubusercontent.com/u/1764010?v=4"},"body":"From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n\nThis patch provides some tests for the clone in use by\ngit-remote-mediawiki.\n\nSigned-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>\nSigned-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>\nSigned-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\nSigned-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>\nSigned-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@imag.fr>\n---\n contrib/mw-to-git/t/t9360-mw-to-git-clone.sh | 238 +++++++++++++++++++++++++++\n 1 file changed, 238 insertions(+)\n create mode 100755 contrib/mw-to-git/t/t9360-mw-to-git-clone.sh\n\ndiff --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\nnew file mode 100755\nindex 0000000..07e1270\n--- /dev/null\n+++ b/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh\n@@ -0,0 +1,238 @@\n+#!/bin/sh\n+#\n+# Copyright (C) 2012\n+#     Charles Roussel <charles.roussel@ensimag.imag.fr>\n+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>\n+#     Julien Khayat <julien.khayat@ensimag.imag.fr>\n+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n+#     Simon Perrat <simon.perrat@ensimag.imag.fr>\n+#\n+# License: GPL v2 or later\n+\n+\n+test_description='Test the Git Mediawiki remote helper: git clone'\n+\n+. ./test-gitmw-lib.sh\n+. $TEST_DIRECTORY/test-lib.sh\n+\n+\n+test_check_precond\n+\n+\n+test_expect_success 'Git clone creates the git log expected with one file' '\n+\twiki_reset &&\n+\twiki_editpage foo \"this is not important\" false -c cat -s \"this must be the same\" &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_1 &&\n+\t(cd mw_dir_1 &&\n+\tgit log --format=%s HEAD^..HEAD > log.tmp ) &&\n+\techo \"this must be the same\" > msg.tmp &&\n+\tdiff -b mw_dir_1/log.tmp msg.tmp\n+'\n+\n+\n+test_expect_success 'Git clone creates the git log expected with multiple files' '\n+\twiki_reset &&\n+\twiki_editpage daddy \"this is not important\" false -s=\"this must be the same\" &&\n+\twiki_editpage daddy \"neither is this\" true -s=\"this must also be the same\" &&\n+\twiki_editpage daddy \"neither is this\" true -s=\"same same same\" &&\n+\twiki_editpage dj \"dont care\" false -s=\"identical\" &&\n+\twiki_editpage dj \"dont care either\" true -s=\"identical too\" &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_2 &&\n+\t(cd mw_dir_2 &&\n+\tgit log --format=%s Daddy.mw  > logDaddy.tmp &&\n+\tgit log --format=%s Dj.mw > logDj.tmp ) &&\n+\techo \"same same same\" > msgDaddy.tmp &&\n+\techo \"this must also be the same\" >> msgDaddy.tmp &&\n+\techo \"this must be the same\" >> msgDaddy.tmp &&\n+\techo \"identical too\" > msgDj.tmp &&\n+\techo \"identical\" >> msgDj.tmp &&\n+\tdiff -b mw_dir_2/logDaddy.tmp msgDaddy.tmp &&\n+\tdiff -b mw_dir_2/logDj.tmp msgDj.tmp\n+'\n+\n+\n+test_expect_success 'Git clone creates only Main_Page.mw with an empty wiki' '\n+\twiki_reset &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_3 &&\n+\ttest_contains_N_files mw_dir_3 1 &&\n+\ttest -e mw_dir_3/Main_Page.mw\n+'\n+\n+test_expect_success 'Git clone does not fetch a deleted page' '\n+\twiki_reset &&\n+\twiki_editpage foo \"this page must be deleted before the clone\" false &&\n+\twiki_delete_page foo &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_4 &&\n+\ttest_contains_N_files mw_dir_4 1 &&\n+\ttest -e mw_dir_4/Main_Page.mw &&\n+\ttest ! -e mw_dir_4/Foo.mw\n+'\n+\n+test_expect_success 'Git clone works with page added' '\n+\twiki_reset &&\n+\twiki_editpage foo \" I will be cloned\" false &&\n+\twiki_editpage bar \"I will be cloned\" false &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_5 &&\n+\twiki_getallpage ref_page_5 &&\n+\ttest_diff_directories mw_dir_5 ref_page_5 &&\n+\twiki_delete_page foo &&\n+\twiki_delete_page bar\n+'\n+\n+test_expect_success 'Git clone works with an edited page ' '\n+\twiki_reset &&\n+\twiki_editpage foo \"this page will be edited\" \\\n+\t\tfalse -s \"first edition of page foo\"&&\n+\twiki_editpage foo \"this page has been edited and must be on the clone \" true &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_6 &&\n+\ttest -e mw_dir_6/Foo.mw &&\n+\ttest -e mw_dir_6/Main_Page.mw &&\n+\twiki_getallpage mw_dir_6/page_ref_6 &&\n+\ttest_diff_directories mw_dir_6 mw_dir_6/page_ref_6 &&\n+\t(cd mw_dir_6 &&\n+\tgit log --format=%s HEAD^ Foo.mw > ../Foo.log ) &&\n+\techo \"first edition of page foo\" > FooExpect.log &&\n+\tdiff FooExpect.log Foo.log\n+'\n+\n+\n+test_expect_success 'Git clone works with several pages and some deleted ' '\n+\twiki_reset &&\n+\twiki_editpage foo \"this page will not be deleted\" false &&\n+\twiki_editpage bar \"I must not be erased\" false &&\n+\twiki_editpage namnam \"I will not be there at the end\" false &&\n+\twiki_editpage nyancat \"nyan nyan nyan delete me\" false &&\n+\twiki_delete_page namnam &&\n+\twiki_delete_page nyancat &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_7 &&\n+\ttest -e mw_dir_7/Foo.mw &&\n+\ttest -e mw_dir_7/Bar.mw &&\n+\ttest ! -e mw_dir_7/Namnam.mw &&\n+\ttest ! -e mw_dir_7/Nyancat.mw &&\n+\twiki_getallpage mw_dir_7/page_ref_7 &&\n+\ttest_diff_directories mw_dir_7 mw_dir_7/page_ref_7\n+'\n+\n+\n+test_expect_success 'Git clone works with one specific page cloned ' '\n+\twiki_reset &&\n+\twiki_editpage foo \"I will not be cloned\" false &&\n+\twiki_editpage bar \"Do not clone me\" false &&\n+\twiki_editpage namnam \"I will be cloned :)\" false  -s=\"this log must stay\" &&\n+\twiki_editpage nyancat \"nyan nyan nyan you cant clone me\" false &&\n+\tgit clone -c remote.origin.pages=namnam mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_8 &&\n+\ttest_contains_N_files mw_dir_8 1 &&\n+\ttest -e mw_dir_8/Namnam.mw &&\n+\ttest ! -e mw_dir_8/Main_Page.mw &&\n+\t(cd mw_dir_8 &&\n+\techo \"this log must stay\" > msg.tmp &&\n+\tgit log --format=%s > log.tmp &&\n+\tdiff -b msg.tmp log.tmp ) &&\n+\twiki_check_content mw_dir_8/Namnam.mw Namnam\n+'\n+\n+test_expect_success 'Git clone works with multiple specific page cloned ' '\n+\twiki_reset &&\n+\twiki_editpage foo \"I will be there\" false &&\n+\twiki_editpage bar \"I will not disapear\" false &&\n+\twiki_editpage namnam \"I be erased\" false &&\n+\twiki_editpage nyancat \"nyan nyan nyan you will not erase me\" false &&\n+\twiki_delete_page namnam &&\n+\tgit clone -c remote.origin.pages='\"'foo bar nyancat namnam'\"' mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_9 &&\n+\ttest_contains_N_files mw_dir_9 3 &&\n+\ttest ! -e mw_dir_9/Namnam.mw &&\n+\ttest -e mw_dir_9/Foo.mw &&\n+\ttest -e mw_dir_9/Nyancat.mw &&\n+\ttest -e mw_dir_9/Bar.mw &&\n+\twiki_check_content mw_dir_9/Foo.mw Foo &&\n+\twiki_check_content mw_dir_9/Bar.mw Bar &&\n+\twiki_check_content mw_dir_9/Nyancat.mw Nyancat\n+'\n+\n+test_expect_success 'Mediawiki-clone of several specific pages on wiki' '\n+\twiki_reset &&\n+\twiki_editpage foo \"foo 1\" false &&\n+\twiki_editpage bar \"bar 1\" false &&\n+\twiki_editpage dummy \"dummy 1\" false &&\n+\twiki_editpage cloned_1 \"cloned_1 1\" false &&\n+\twiki_editpage cloned_2 \"cloned_2 2\" false &&\n+\twiki_editpage cloned_3 \"cloned_3 3\" false &&\n+\tmkdir -p ref_page_10 &&\n+\twiki_getpage cloned_1 ref_page_10 &&\n+\twiki_getpage cloned_2 ref_page_10 &&\n+\twiki_getpage cloned_3 ref_page_10 &&\n+\tgit clone -c remote.origin.pages=\"cloned_1 cloned_2 cloned_3\" mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_10 &&\n+\ttest_diff_directories mw_dir_10 ref_page_10\n+'\n+\n+test_expect_success 'Git clone works with the shallow option' '\n+\twiki_reset &&\n+\twiki_editpage foo \"1st revision, should be cloned\" false &&\n+\twiki_editpage bar \"1st revision, should be cloned\" false &&\n+\twiki_editpage nyan \"1st revision, should not be cloned\" false &&\n+\twiki_editpage nyan \"2nd revision, should be cloned\" false &&\n+\tgit -c remote.origin.shallow=true clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_11 &&\n+\ttest_contains_N_files mw_dir_11 4 &&\n+\ttest -e mw_dir_11/Nyan.mw &&\n+\ttest -e mw_dir_11/Foo.mw &&\n+\ttest -e mw_dir_11/Bar.mw &&\n+\ttest -e mw_dir_11/Main_Page.mw &&\n+\t(cd mw_dir_11 &&\n+\ttest `git log --oneline Nyan.mw | wc -l` -eq 1 &&\n+\ttest `git log --oneline Foo.mw | wc -l` -eq 1 &&\n+\ttest `git log --oneline Bar.mw | wc -l` -eq 1 &&\n+\ttest `git log --oneline Main_Page.mw | wc -l ` -eq 1 ) &&\n+\twiki_check_content mw_dir_11/Nyan.mw Nyan &&\n+\twiki_check_content mw_dir_11/Foo.mw Foo &&\n+\twiki_check_content mw_dir_11/Bar.mw Bar &&\n+\twiki_check_content mw_dir_11/Main_Page.mw Main_Page\n+'\n+\n+test_expect_success 'Git clone works with the shallow option with a delete page' '\n+\twiki_reset &&\n+\twiki_editpage foo \"1st revision, will be deleted\" false &&\n+\twiki_editpage bar \"1st revision, should be cloned\" false &&\n+\twiki_editpage nyan \"1st revision, should not be cloned\" false &&\n+\twiki_editpage nyan \"2nd revision, should be cloned\" false &&\n+\twiki_delete_page foo &&\n+\tgit -c remote.origin.shallow=true clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_12 &&\n+\ttest_contains_N_files mw_dir_12 3 &&\n+\ttest -e mw_dir_12/Nyan.mw &&\n+\ttest ! -e mw_dir_12/Foo.mw &&\n+\ttest -e mw_dir_12/Bar.mw &&\n+\ttest -e mw_dir_12/Main_Page.mw &&\n+\t(cd mw_dir_12 &&\n+\ttest `git log --oneline Nyan.mw | wc -l` -eq 1 &&\n+\ttest `git log --oneline Bar.mw | wc -l` -eq 1 &&\n+\ttest `git log --oneline Main_Page.mw | wc -l ` -eq 1 ) &&\n+\twiki_check_content mw_dir_12/Nyan.mw Nyan &&\n+\twiki_check_content mw_dir_12/Bar.mw Bar &&\n+\twiki_check_content mw_dir_12/Main_Page.mw Main_Page\n+'\n+\n+test_expect_success 'Test of fetching a category' '\n+\twiki_reset &&\n+\twiki_editpage Foo \"I will be cloned\" false -c=Category &&\n+\twiki_editpage Bar \"Meet me on the repository\" false -c=Category &&\n+\twiki_editpage Dummy \"I will not come\" false &&\n+\twiki_editpage BarWrong \"I will stay online only\" false -c=NotCategory &&\n+\tgit clone -c remote.origin.categories=\"Category\" mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_13 &&\n+\twiki_getallpage ref_page_13 Category &&\n+\ttest_diff_directories mw_dir_13 ref_page_13\n+'\n+\n+test_expect_success 'Test of resistance to modification of category on wiki for clone' '\n+\twiki_reset &&\n+\twiki_editpage Tobedeleted \"this page will be deleted\" false -c=Catone &&\n+\twiki_editpage Tobeedited \"this page will be modified\" false -c=Catone &&\n+\twiki_editpage Normalone \"this page wont be modified and will be on git\" false -c=Catone &&\n+\twiki_editpage Notconsidered \"this page will not appear on local\" false &&\n+\twiki_editpage Othercategory \"this page will not appear on local\" false -c=Cattwo &&\n+\twiki_editpage Tobeedited \"this page have been modified\" true -c=Catone &&\n+\twiki_delete_page Tobedeleted\n+\tgit clone -c remote.origin.categories=\"Catone\" mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_14 &&\n+\twiki_getallpage ref_page_14 Catone &&\n+\ttest_diff_directories mw_dir_14 ref_page_14\n+'\n+\n+test_done\n-- \n1.7.10.2.552.gaa3bb87\n"},{"id":"193508","messageId":"1339535563-18958-4-git-send-email-simon.cathebras@ensimag.imag.fr","threadId":"30773","inReplyTo":"1339535563-18958-1-git-send-email-simon.cathebras@ensimag.imag.fr","subject":"[PATCH 4/6] Tests for git-remote-mediawiki pull and push","fromName":"Simon Cathebras","fromEmail":"simon.cathebras@ensimag.imag.fr","sentAt":"2012-06-12T21:12:42Z","receivedAt":"2012-06-12T21:12:42Z","isPatch":true,"sender":{"key":"simon.cathebras@ensimag.imag.fr","avatar":"https://avatars.githubusercontent.com/u/1764010?v=4"},"body":"From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n\nThis patch provides a set of tests for the pull and push fonctionnality of\ngit-remote-mediawiki.\n\nSigned-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>\nSigned-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>\nSigned-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\nSigned-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>\nSigned-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@imag.fr>\n---\n contrib/mw-to-git/t/t9361-mw-to-git-push-pull.sh | 151 +++++++++++++++++++++++\n 1 file changed, 151 insertions(+)\n create mode 100755 contrib/mw-to-git/t/t9361-mw-to-git-push-pull.sh\n\ndiff --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\nnew file mode 100755\nindex 0000000..add7c79\n--- /dev/null\n+++ b/contrib/mw-to-git/t/t9361-mw-to-git-push-pull.sh\n@@ -0,0 +1,151 @@\n+#!/bin/sh\n+#\n+# Copyright (C) 2012\n+#     Charles Roussel <charles.roussel@ensimag.imag.fr>\n+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>\n+#     Julien Khayat <julien.khayat@ensimag.imag.fr>\n+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n+#     Simon Perrat <simon.perrat@ensimag.imag.fr>\n+#\n+# License: GPL v2 or later\n+\n+# tests for git-remote-mediawiki\n+\n+test_description='Test the Git Mediawiki remote helper: git push and git pull simple test cases'\n+\n+. ./test-gitmw-lib.sh\n+. $TEST_DIRECTORY/test-lib.sh\n+\n+\n+test_check_precond\n+\n+\n+test_expect_success 'Git pull works after adding a new wiki page' '\n+\twiki_reset &&\n+\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_1 &&\n+\twiki_editpage Foo \"page created after the git clone\" false &&\n+\n+\t(cd mw_dir_1 &&\n+\tgit pull) &&\n+\n+\twiki_getallpage ref_page_1 &&\n+\ttest_diff_directories mw_dir_1 ref_page_1\n+'\n+\n+test_expect_success 'Git pull works after editing a wiki page' '\n+\twiki_reset &&\n+\n+\twiki_editpage Foo \"page created before the git clone\" false &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_2 &&\n+\twiki_editpage Foo \"new line added on the wiki\" true &&\n+\n+\t(cd mw_dir_2 &&\n+\tgit pull) &&\n+\n+\twiki_getallpage ref_page_2 &&\n+\ttest_diff_directories mw_dir_2 ref_page_2\n+'\n+\n+test_expect_success 'git pull works on conflict handled by auto-merge' '\n+\twiki_reset &&\n+\n+\twiki_editpage Foo \"1 init\n+3\n+5\n+\" false &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_3 &&\n+\n+\twiki_editpage Foo \"1 init\n+2 content added on wiki after clone\n+3\n+5\n+\" false &&\n+\n+\t(cd mw_dir_3 &&\n+\techo \"1 init\n+3\n+4 content added on git after clone\n+5\n+\" > Foo.mw &&\n+\tgit commit -am \"conflicting change on foo\" &&\n+\tgit pull &&\n+\tgit push)\n+'\n+\n+test_expect_success 'Git push works after adding a file .mw' '\n+\twiki_reset &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_4 &&\n+\twiki_getallpage ref_page_4 &&\n+\t(cd mw_dir_4 &&\n+\ttest ! -f Foo.mw &&\n+\ttouch Foo.mw &&\n+\techo \"hello world\" >> Foo.mw &&\n+\tgit add Foo.mw &&\n+\tgit commit -m \"Foo\" &&\n+\tgit push) &&\n+\twiki_getallpage ref_page_4 &&\n+\ttest_diff_directories mw_dir_4 ref_page_4\n+'\n+\n+test_expect_success 'Git push works after editing a file .mw' '\n+\twiki_reset &&\n+\twiki_editpage \"Foo\" \"page created before the git clone\" false &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_5 &&\n+\n+\t(cd mw_dir_5 &&\n+\techo \"new line added in the file Foo.mw\" >> Foo.mw &&\n+\tgit commit -am \"edit file Foo.mw\" &&\n+\tgit push) &&\n+\n+\twiki_getallpage ref_page_5 &&\n+\ttest_diff_directories mw_dir_5 ref_page_5\n+'\n+\n+test_expect_failure 'Git push works after deleting a file' '\n+\twiki_reset &&\n+\twiki_editpage Foo \"wiki page added before git clone\" false &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_6 &&\n+\n+\t(cd mw_dir_6 &&\n+\tgit rm Foo.mw &&\n+\tgit commit -am \"page Foo.mw deleted\" &&\n+\tgit push) &&\n+\n+\ttest ! wiki_page_exist Foo\n+'\n+\n+\n+\n+test_expect_success 'Merge conflict expected and solving it' '\n+\twiki_reset &&\n+\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_7 &&\n+\twiki_editpage Foo \"1 conflict\n+3 wiki\n+4\" false &&\n+\n+\t(cd mw_dir_7 &&\n+\techo \"1 conflict\n+2 git\n+4\" > Foo.mw &&\n+\tgit add Foo.mw &&\n+\tgit commit -m \"conflict created\" &&\n+\ttest_must_fail git pull &&\n+\tperl -pi -e \"s/[<=>].*//g\" Foo.mw &&\n+\tgit commit -am \"merge conflict solved\" &&\n+\tgit push)\n+'\n+\n+test_expect_failure 'git pull works after deleting a wiki page' '\n+\twiki_reset &&\n+\twiki_editpage Foo \"wiki page added before the git clone\" false &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_8 &&\n+\n+\twiki_delete_page Foo &&\n+\t(cd mw_dir_8 &&\n+\tgit pull &&\n+\ttest ! -f Foo.mw)\n+'\n+\n+test_done\n-- \n1.7.10.2.552.gaa3bb87\n"},{"id":"193509","messageId":"1339535563-18958-5-git-send-email-simon.cathebras@ensimag.imag.fr","threadId":"30773","inReplyTo":"1339535563-18958-1-git-send-email-simon.cathebras@ensimag.imag.fr","subject":"[PATCH 5/6] Tests of UTF8 character with git-remote-mediawiki","fromName":"Simon Cathebras","fromEmail":"simon.cathebras@ensimag.imag.fr","sentAt":"2012-06-12T21:12:43Z","receivedAt":"2012-06-12T21:12:43Z","isPatch":true,"sender":{"key":"simon.cathebras@ensimag.imag.fr","avatar":"https://avatars.githubusercontent.com/u/1764010?v=4"},"body":"This patch provides a sample of tests for git-remote-mediawiki's\nresistance, concerning utf8 special characters.\n\nSigned-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>\nSigned-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>\nSigned-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\nSigned-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>\nSigned-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@imag.fr>\n---\n contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh | 271 ++++++++++++++++++++++++++++\n 1 file changed, 271 insertions(+)\n create mode 100755 contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh\n\ndiff --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\nnew file mode 100755\nindex 0000000..9227c6f\n--- /dev/null\n+++ b/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh\n@@ -0,0 +1,271 @@\n+#!/bin/sh\n+#\n+# Copyright (C) 2012\n+#     Charles Roussel <charles.roussel@ensimag.imag.fr>\n+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>\n+#     Julien Khayat <julien.khayat@ensimag.imag.fr>\n+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n+#     Simon Perrat <simon.perrat@ensimag.imag.fr>\n+#\n+# License: GPL v2 or later\n+\n+# tests for git-remote-mediawiki\n+\n+test_description='Test git-mediawiki with special characters in filenames'\n+\n+. ./test-gitmw-lib.sh\n+. $TEST_DIRECTORY/test-lib.sh\n+\n+\n+test_check_precond\n+\n+\n+test_expect_success 'Git clone works for a wiki with accents in the page names' '\n+\twiki_reset &&\n+\twiki_editpage féé \"This page must be délétéd before clone\" false &&\n+\twiki_editpage kèè \"This page must be deleted before clone\" false &&\n+\twiki_editpage hàà \"This page must be deleted before clone\" false &&\n+\twiki_editpage kîî \"This page must be deleted before clone\" false &&\n+\twiki_editpage foo \"This page must be deleted before clone\" false &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_1 &&\n+\twiki_getallpage ref_page_1 &&\n+\ttest_diff_directories mw_dir_1 ref_page_1\n+'\n+\n+\n+test_expect_success 'Git pull works with a wiki with accents in the pages names' '\n+\twiki_reset &&\n+\twiki_editpage kîî \"this page must be cloned\" false &&\n+\twiki_editpage foo \"this page must be cloned\" false &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_2 &&\n+\twiki_editpage éàîôû \"This page must be pulled\" false &&\n+\t(cd mw_dir_2 &&\n+\tgit pull ) &&\n+\twiki_getallpage ref_page_2 &&\n+\ttest_diff_directories mw_dir_2 ref_page_2\n+'\n+\n+# 3\n+test_expect_success 'Cloning a chosen page works with accents' '\n+\twiki_reset &&\n+\twiki_editpage kîî \"this page must be cloned\" false &&\n+\tgit clone -c remote.origin.pages=kîî mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_3 &&\n+\twiki_check_content mw_dir_3/Kîî.mw Kîî &&\n+\ttest -e mw_dir_3/Kîî.mw &&\n+\trm -rf mw_dir_3\n+'\n+\n+\n+test_expect_success 'The shallow option works with accents' '\n+\twiki_reset &&\n+\twiki_editpage néoà \"1st revision, should not be cloned\" false &&\n+\twiki_editpage néoà \"2nd revision, should be cloned\" false &&\n+\tgit -c remote.origin.shallow=true clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_4 &&\n+\ttest_contains_N_files mw_dir_4 2 &&\n+\ttest -e mw_dir_4/Néoà.mw &&\n+\ttest -e mw_dir_4/Main_Page.mw &&\n+\t(cd mw_dir_4 &&\n+\ttest `git log --oneline Néoà.mw | wc -l` -eq 1 &&\n+\ttest `git log --oneline Main_Page.mw | wc -l ` -eq 1 ) &&\n+\twiki_check_content mw_dir_4/Néoà.mw Néoà &&\n+\twiki_check_content mw_dir_4/Main_Page.mw Main_Page\n+'\n+\n+\n+test_expect_success 'Cloning works when page name first letter has an accent' '\n+\twiki_reset &&\n+\twiki_editpage îî \"this page must be cloned\" false &&\n+\tgit clone -c remote.origin.pages=îî mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_5 &&\n+\ttest -e mw_dir_5/Îî.mw &&\n+\twiki_check_content mw_dir_5/Îî.mw Îî\n+'\n+\n+\n+test_expect_success 'Git push works with a wiki with accents' '\n+\twiki_reset &&\n+\twiki_editpage féé \"lots of accents : éèàÖ\" false &&\n+\twiki_editpage foo \"this page must be cloned\" false &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_6 &&\n+\t(cd mw_dir_6 &&\n+\techo \"A wild Pîkächû appears on the wiki\" > Pîkächû.mw &&\n+\tgit add Pîkächû.mw &&\n+\tgit commit -m \"A new page appears\" &&\n+\tgit push ) &&\n+\twiki_getallpage ref_page_6 &&\n+\ttest_diff_directories mw_dir_6 ref_page_6\n+'\n+\n+test_expect_success 'Git clone works with accentsand spaces' '\n+\twiki_reset &&\n+\twiki_editpage \"é à î\" \"this page must be délété before the clone\" false &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_7 &&\n+\twiki_getallpage ref_page_7 &&\n+\ttest_diff_directories mw_dir_7 ref_page_7\n+'\n+\n+test_expect_success 'character $ in page name (mw -> git)' '\n+\twiki_reset &&\n+\twiki_editpage file_\\$_foo \"expect to be called file_$_foo\" false &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_8 &&\n+\ttest -f mw_dir_8/File_\\$_foo.mw &&\n+\twiki_getallpage ref_page_8 &&\n+\ttest_diff_directories mw_dir_8 ref_page_8\n+'\n+\n+\n+\n+test_expect_success 'character $ in file name (git -> mw) ' '\n+\twiki_reset &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_9 &&\n+\t(cd mw_dir_9 &&\n+\techo \"this file is called File_\\$_foo.mw\" > File_\\$_foo.mw &&\n+\tgit add . &&\n+\tgit commit -am \"file File_\\$_foo.mw\" &&\n+\tgit pull &&\n+\tgit push ) &&\n+\twiki_getallpage ref_page_9 &&\n+\ttest_diff_directories mw_dir_9 ref_page_9\n+'\n+\n+\n+test_expect_failure 'capital at the begining of file names' '\n+\twiki_reset &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_10 &&\n+\t(cd mw_dir_10 &&\n+\techo \"my new file foo\" > foo.mw &&\n+\techo \"my new file Foo... Finger crossed\" > Foo.mw &&\n+\tgit add . &&\n+\tgit commit -am \"file foo.mw\" &&\n+\tgit pull &&\n+\tgit push ) &&\n+\twiki_getallpage ref_page_10 &&\n+\ttest_diff_directories mw_dir_10 ref_page_10\n+'\n+\n+\n+test_expect_failure 'special character at the begining of file name from mw to git' '\n+\twiki_reset &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_11 &&\n+\twiki_editpage {char_1 \"expect to be renamed {char_1\" false &&\n+\twiki_editpage [char_2 \"expect to be renamed [char_2\" false &&\n+\t(cd mw_dir_11 &&\n+\tgit pull ) &&\n+\ttest -f mw_dir_11/{char_1 &&\n+\ttest -f mw_dir_11/[char_2\n+'\n+\n+\n+test_expect_success 'test of correct formating for file name from mw to git' '\n+\twiki_reset &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_12 &&\n+\twiki_editpage char{_1 \"expect to be renamed char{_1\" false &&\n+\twiki_editpage char[_2 \"expect to be renamed char{_2\" false &&\n+\t(cd mw_dir_12 &&\n+\tgit pull ) &&\n+\ttest -f mw_dir_12/Char\\{_1.mw &&\n+\ttest -f mw_dir_12/Char\\[_2.mw &&\n+\twiki_getallpage ref_page_12 &&\n+\ttest_diff_directories mw_dir_12 ref_page_12\n+'\n+\n+\n+test_expect_failure 'test of correct formating for file name begining with special character' '\n+\twiki_reset &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_13 &&\n+\t(cd mw_dir_13 &&\n+\techo \"my new file {char_1\" > \\{char_1.mw &&\n+\techo \"my new file [char_2\" > \\[char_2.mw &&\n+\tgit add . &&\n+\tgit commit -am \"commiting some exotic file name...\" &&\n+\tgit push &&\n+\tgit pull) &&\n+\twiki_getallpage ref_page_13 &&\n+\ttest -f ref_page_13/{char_1.mw &&\n+\ttest -f ref_page_13/[char_2.mw &&\n+\ttest_diff_directories mw_dir_13 ref_page_13\n+'\n+\n+\n+test_expect_success 'test of correct formating for file name from git to mw' '\n+\twiki_reset &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_14 &&\n+\t(cd mw_dir_14 &&\n+\techo \"my new file char{_1\" > Char\\{_1.mw &&\n+\techo \"my new file char[_2\" > Char\\[_2.mw &&\n+\tgit add . &&\n+\tgit commit -m \"commiting some exotic file name...\" &&\n+\tgit push ) &&\n+\twiki_getallpage ref_page_14 &&\n+\ttest_diff_directories mw_dir_14 ref_page_14\n+'\n+\n+\n+test_expect_success 'git clone with /' '\n+\twiki_reset &&\n+\twiki_editpage \\/fo\\/o \"this is not important\" false -c=Deleted &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_15 &&\n+\ttest -f mw_dir_15/%2Ffo%2Fo.mw &&\n+\twiki_check_content mw_dir_15/%2Ffo%2Fo.mw \\/fo\\/o\n+'\n+\n+\n+test_expect_success 'git push with /' '\n+\twiki_reset &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_16 &&\n+\techo \"I will be on the wiki\" > mw_dir_16/%2Ffo%2Fo.mw &&\n+\t(cd mw_dir_16 &&\n+\tgit add %2Ffo%2Fo.mw &&\n+\tgit commit -m \" %2Ffo%2Fo added\" &&\n+\tgit push) &&\n+\twiki_page_exist \\/fo\\/o &&\n+\twiki_check_content mw_dir_16/%2Ffo%2Fo.mw \\/fo\\/o\n+\n+'\n+\n+\n+test_expect_success 'git clone with \\' '\n+\twiki_reset &&\n+\twiki_editpage \\\\ko\\\\o \"this is not important\" false -c=Deleted &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_17 &&\n+\ttest -f mw_dir_17/\\\\ko\\\\o.mw &&\n+\twiki_check_content mw_dir_17/\\\\ko\\\\o.mw \\\\ko\\\\o\n+'\n+\n+\n+test_expect_success 'git push with \\' '\n+\twiki_reset &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_18 &&\n+\techo \"I will be on the wiki\" > mw_dir_18/\\\\ko\\\\o.mw &&\n+\t(cd mw_dir_18 &&\n+\tgit add \\\\ko\\\\o.mw &&\n+\tgit commit -m \" \\\\ko\\\\o added\" &&\n+\tgit push )&&\n+\twiki_page_exist \\\\ko\\\\o &&\n+\twiki_check_content mw_dir_18/\\\\ko\\\\o.mw \\\\ko\\\\o\n+\n+'\n+\n+test_expect_success 'git clone with \\ in format control' '\n+\twiki_reset &&\n+\twiki_editpage \\\\no\\\\o \"this is not important\" false &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_19 &&\n+\ttest -f mw_dir_19/\\\\no\\\\o.mw &&\n+\twiki_check_content mw_dir_19/\\\\no\\\\o.mw \\\\no\\\\o\n+'\n+\n+\n+test_expect_success 'git push with \\ in format control' '\n+\twiki_reset &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_20 &&\n+\techo \"I will be on the wiki\" > mw_dir_20/\\\\fo\\\\o.mw &&\n+\t(cd mw_dir_20 &&\n+\tgit add \\\\fo\\\\o.mw &&\n+\tgit commit -m \" \\\\fo\\\\o added\" &&\n+\tgit push )&&\n+\twiki_page_exist \\\\fo\\\\o &&\n+\twiki_check_content mw_dir_20/\\\\fo\\\\o.mw \\\\fo\\\\o\n+\n+'\n+\n+\n+test_done\n-- \n1.7.10.2.552.gaa3bb87\n"},{"id":"193512","messageId":"4FD7B242.9020005@ensimag.imag.fr","threadId":"30773","inReplyTo":"1339535563-18958-5-git-send-email-simon.cathebras@ensimag.imag.fr","subject":"Re: [PATCH 5/6] Tests of UTF8 character with git-remote-mediawiki","fromName":"Simon.Cathebras","fromEmail":"simon.cathebras@ensimag.imag.fr","sentAt":"2012-06-12T21:18:58Z","receivedAt":"2012-06-12T21:18:58Z","isPatch":true,"sender":{"key":"simon.cathebras@ensimag.imag.fr","avatar":"https://avatars.githubusercontent.com/u/1764010?v=4"},"body":"Please accept our appologize for the bad tag for patches.\n\nThe PATCH 5 is actually the last one...\n\nRegards.\n\nSimon C\n\nOn 12/06/2012 23:12, Simon Cathebras wrote:\n> This patch provides a sample of tests for git-remote-mediawiki's\n> resistance, concerning utf8 special characters.\n>\n> Signed-off-by: Simon Cathebras<simon.cathebras@ensimag.imag.fr>\n> Signed-off-by: Simon Perrat<simon.perrat@ensimag.imag.fr>\n> Signed-off-by: Guillaume Sasdy<guillaume.sasdy@ensimag.imag.fr>\n> Signed-off-by: Charles Roussel<charles.roussel@ensimag.imag.fr>\n> Signed-off-by: Julien Khayat<julien.khayat@ensimag.imag.fr>\n> Signed-off-by: Matthieu Moy<matthieu.moy@imag.fr>\n> ---\n>   contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh | 271 ++++++++++++++++++++++++++++\n>   1 file changed, 271 insertions(+)\n>   create mode 100755 contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh\n>\n> 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\n> new file mode 100755\n> index 0000000..9227c6f\n> --- /dev/null\n> +++ b/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh\n> @@ -0,0 +1,271 @@\n> +#!/bin/sh\n> +#\n> +# Copyright (C) 2012\n> +#     Charles Roussel<charles.roussel@ensimag.imag.fr>\n> +#     Simon Cathebras<simon.cathebras@ensimag.imag.fr>\n> +#     Julien Khayat<julien.khayat@ensimag.imag.fr>\n> +#     Guillaume Sasdy<guillaume.sasdy@ensimag.imag.fr>\n> +#     Simon Perrat<simon.perrat@ensimag.imag.fr>\n> +#\n> +# License: GPL v2 or later\n> +\n> +# tests for git-remote-mediawiki\n> +\n> +test_description='Test git-mediawiki with special characters in filenames'\n> +\n> +. ./test-gitmw-lib.sh\n> +. $TEST_DIRECTORY/test-lib.sh\n> +\n> +\n> +test_check_precond\n> +\n> +\n> +test_expect_success 'Git clone works for a wiki with accents in the page names' '\n> +\twiki_reset&&\n> +\twiki_editpage féé \"This page must be délétéd before clone\" false&&\n> +\twiki_editpage kèè \"This page must be deleted before clone\" false&&\n> +\twiki_editpage hàà \"This page must be deleted before clone\" false&&\n> +\twiki_editpage kîî \"This page must be deleted before clone\" false&&\n> +\twiki_editpage foo \"This page must be deleted before clone\" false&&\n> +\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_1&&\n> +\twiki_getallpage ref_page_1&&\n> +\ttest_diff_directories mw_dir_1 ref_page_1\n> +'\n> +\n> +\n> +test_expect_success 'Git pull works with a wiki with accents in the pages names' '\n> +\twiki_reset&&\n> +\twiki_editpage kîî \"this page must be cloned\" false&&\n> +\twiki_editpage foo \"this page must be cloned\" false&&\n> +\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_2&&\n> +\twiki_editpage éàîôû \"This page must be pulled\" false&&\n> +\t(cd mw_dir_2&&\n> +\tgit pull )&&\n> +\twiki_getallpage ref_page_2&&\n> +\ttest_diff_directories mw_dir_2 ref_page_2\n> +'\n> +\n> +# 3\n> +test_expect_success 'Cloning a chosen page works with accents' '\n> +\twiki_reset&&\n> +\twiki_editpage kîî \"this page must be cloned\" false&&\n> +\tgit clone -c remote.origin.pages=kîî mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_3&&\n> +\twiki_check_content mw_dir_3/Kîî.mw Kîî&&\n> +\ttest -e mw_dir_3/Kîî.mw&&\n> +\trm -rf mw_dir_3\n> +'\n> +\n> +\n> +test_expect_success 'The shallow option works with accents' '\n> +\twiki_reset&&\n> +\twiki_editpage néoà \"1st revision, should not be cloned\" false&&\n> +\twiki_editpage néoà \"2nd revision, should be cloned\" false&&\n> +\tgit -c remote.origin.shallow=true clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_4&&\n> +\ttest_contains_N_files mw_dir_4 2&&\n> +\ttest -e mw_dir_4/Néoà.mw&&\n> +\ttest -e mw_dir_4/Main_Page.mw&&\n> +\t(cd mw_dir_4&&\n> +\ttest `git log --oneline Néoà.mw | wc -l` -eq 1&&\n> +\ttest `git log --oneline Main_Page.mw | wc -l ` -eq 1 )&&\n> +\twiki_check_content mw_dir_4/Néoà.mw Néoà&&\n> +\twiki_check_content mw_dir_4/Main_Page.mw Main_Page\n> +'\n> +\n> +\n> +test_expect_success 'Cloning works when page name first letter has an accent' '\n> +\twiki_reset&&\n> +\twiki_editpage îî \"this page must be cloned\" false&&\n> +\tgit clone -c remote.origin.pages=îî mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_5&&\n> +\ttest -e mw_dir_5/Îî.mw&&\n> +\twiki_check_content mw_dir_5/Îî.mw Îî\n> +'\n> +\n> +\n> +test_expect_success 'Git push works with a wiki with accents' '\n> +\twiki_reset&&\n> +\twiki_editpage féé \"lots of accents : éèàÖ\" false&&\n> +\twiki_editpage foo \"this page must be cloned\" false&&\n> +\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_6&&\n> +\t(cd mw_dir_6&&\n> +\techo \"A wild Pîkächû appears on the wiki\">  Pîkächû.mw&&\n> +\tgit add Pîkächû.mw&&\n> +\tgit commit -m \"A new page appears\"&&\n> +\tgit push )&&\n> +\twiki_getallpage ref_page_6&&\n> +\ttest_diff_directories mw_dir_6 ref_page_6\n> +'\n> +\n> +test_expect_success 'Git clone works with accentsand spaces' '\n> +\twiki_reset&&\n> +\twiki_editpage \"é à î\" \"this page must be délété before the clone\" false&&\n> +\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_7&&\n> +\twiki_getallpage ref_page_7&&\n> +\ttest_diff_directories mw_dir_7 ref_page_7\n> +'\n> +\n> +test_expect_success 'character $ in page name (mw ->  git)' '\n> +\twiki_reset&&\n> +\twiki_editpage file_\\$_foo \"expect to be called file_$_foo\" false&&\n> +\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_8&&\n> +\ttest -f mw_dir_8/File_\\$_foo.mw&&\n> +\twiki_getallpage ref_page_8&&\n> +\ttest_diff_directories mw_dir_8 ref_page_8\n> +'\n> +\n> +\n> +\n> +test_expect_success 'character $ in file name (git ->  mw) ' '\n> +\twiki_reset&&\n> +\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_9&&\n> +\t(cd mw_dir_9&&\n> +\techo \"this file is called File_\\$_foo.mw\">  File_\\$_foo.mw&&\n> +\tgit add .&&\n> +\tgit commit -am \"file File_\\$_foo.mw\"&&\n> +\tgit pull&&\n> +\tgit push )&&\n> +\twiki_getallpage ref_page_9&&\n> +\ttest_diff_directories mw_dir_9 ref_page_9\n> +'\n> +\n> +\n> +test_expect_failure 'capital at the begining of file names' '\n> +\twiki_reset&&\n> +\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_10&&\n> +\t(cd mw_dir_10&&\n> +\techo \"my new file foo\">  foo.mw&&\n> +\techo \"my new file Foo... Finger crossed\">  Foo.mw&&\n> +\tgit add .&&\n> +\tgit commit -am \"file foo.mw\"&&\n> +\tgit pull&&\n> +\tgit push )&&\n> +\twiki_getallpage ref_page_10&&\n> +\ttest_diff_directories mw_dir_10 ref_page_10\n> +'\n> +\n> +\n> +test_expect_failure 'special character at the begining of file name from mw to git' '\n> +\twiki_reset&&\n> +\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_11&&\n> +\twiki_editpage {char_1 \"expect to be renamed {char_1\" false&&\n> +\twiki_editpage [char_2 \"expect to be renamed [char_2\" false&&\n> +\t(cd mw_dir_11&&\n> +\tgit pull )&&\n> +\ttest -f mw_dir_11/{char_1&&\n> +\ttest -f mw_dir_11/[char_2\n> +'\n> +\n> +\n> +test_expect_success 'test of correct formating for file name from mw to git' '\n> +\twiki_reset&&\n> +\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_12&&\n> +\twiki_editpage char{_1 \"expect to be renamed char{_1\" false&&\n> +\twiki_editpage char[_2 \"expect to be renamed char{_2\" false&&\n> +\t(cd mw_dir_12&&\n> +\tgit pull )&&\n> +\ttest -f mw_dir_12/Char\\{_1.mw&&\n> +\ttest -f mw_dir_12/Char\\[_2.mw&&\n> +\twiki_getallpage ref_page_12&&\n> +\ttest_diff_directories mw_dir_12 ref_page_12\n> +'\n> +\n> +\n> +test_expect_failure 'test of correct formating for file name begining with special character' '\n> +\twiki_reset&&\n> +\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_13&&\n> +\t(cd mw_dir_13&&\n> +\techo \"my new file {char_1\">  \\{char_1.mw&&\n> +\techo \"my new file [char_2\">  \\[char_2.mw&&\n> +\tgit add .&&\n> +\tgit commit -am \"commiting some exotic file name...\"&&\n> +\tgit push&&\n> +\tgit pull)&&\n> +\twiki_getallpage ref_page_13&&\n> +\ttest -f ref_page_13/{char_1.mw&&\n> +\ttest -f ref_page_13/[char_2.mw&&\n> +\ttest_diff_directories mw_dir_13 ref_page_13\n> +'\n> +\n> +\n> +test_expect_success 'test of correct formating for file name from git to mw' '\n> +\twiki_reset&&\n> +\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_14&&\n> +\t(cd mw_dir_14&&\n> +\techo \"my new file char{_1\">  Char\\{_1.mw&&\n> +\techo \"my new file char[_2\">  Char\\[_2.mw&&\n> +\tgit add .&&\n> +\tgit commit -m \"commiting some exotic file name...\"&&\n> +\tgit push )&&\n> +\twiki_getallpage ref_page_14&&\n> +\ttest_diff_directories mw_dir_14 ref_page_14\n> +'\n> +\n> +\n> +test_expect_success 'git clone with /' '\n> +\twiki_reset&&\n> +\twiki_editpage \\/fo\\/o \"this is not important\" false -c=Deleted&&\n> +\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_15&&\n> +\ttest -f mw_dir_15/%2Ffo%2Fo.mw&&\n> +\twiki_check_content mw_dir_15/%2Ffo%2Fo.mw \\/fo\\/o\n> +'\n> +\n> +\n> +test_expect_success 'git push with /' '\n> +\twiki_reset&&\n> +\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_16&&\n> +\techo \"I will be on the wiki\">  mw_dir_16/%2Ffo%2Fo.mw&&\n> +\t(cd mw_dir_16&&\n> +\tgit add %2Ffo%2Fo.mw&&\n> +\tgit commit -m \" %2Ffo%2Fo added\"&&\n> +\tgit push)&&\n> +\twiki_page_exist \\/fo\\/o&&\n> +\twiki_check_content mw_dir_16/%2Ffo%2Fo.mw \\/fo\\/o\n> +\n> +'\n> +\n> +\n> +test_expect_success 'git clone with \\' '\n> +\twiki_reset&&\n> +\twiki_editpage \\\\ko\\\\o \"this is not important\" false -c=Deleted&&\n> +\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_17&&\n> +\ttest -f mw_dir_17/\\\\ko\\\\o.mw&&\n> +\twiki_check_content mw_dir_17/\\\\ko\\\\o.mw \\\\ko\\\\o\n> +'\n> +\n> +\n> +test_expect_success 'git push with \\' '\n> +\twiki_reset&&\n> +\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_18&&\n> +\techo \"I will be on the wiki\">  mw_dir_18/\\\\ko\\\\o.mw&&\n> +\t(cd mw_dir_18&&\n> +\tgit add \\\\ko\\\\o.mw&&\n> +\tgit commit -m \" \\\\ko\\\\o added\"&&\n> +\tgit push )&&\n> +\twiki_page_exist \\\\ko\\\\o&&\n> +\twiki_check_content mw_dir_18/\\\\ko\\\\o.mw \\\\ko\\\\o\n> +\n> +'\n> +\n> +test_expect_success 'git clone with \\ in format control' '\n> +\twiki_reset&&\n> +\twiki_editpage \\\\no\\\\o \"this is not important\" false&&\n> +\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_19&&\n> +\ttest -f mw_dir_19/\\\\no\\\\o.mw&&\n> +\twiki_check_content mw_dir_19/\\\\no\\\\o.mw \\\\no\\\\o\n> +'\n> +\n> +\n> +test_expect_success 'git push with \\ in format control' '\n> +\twiki_reset&&\n> +\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_20&&\n> +\techo \"I will be on the wiki\">  mw_dir_20/\\\\fo\\\\o.mw&&\n> +\t(cd mw_dir_20&&\n> +\tgit add \\\\fo\\\\o.mw&&\n> +\tgit commit -m \" \\\\fo\\\\o added\"&&\n> +\tgit push )&&\n> +\twiki_page_exist \\\\fo\\\\o&&\n> +\twiki_check_content mw_dir_20/\\\\fo\\\\o.mw \\\\fo\\\\o\n> +\n> +'\n> +\n> +\n> +test_done\n\n-- \nCATHEBRAS Simon\n\n2A-ENSIMAG\n\nFilière Ingéniérie des Systèmes d'Information\nMembre Bug-Buster\n"},{"id":"193513","messageId":"20120612233448.Horde.yFmTWnwdC4BP17X4iOBVZrA@webmail.minatec.grenoble-inp.fr","threadId":"30773","inReplyTo":"1339535563-18958-3-git-send-email-simon.cathebras@ensimag.imag.fr","subject":"Re: [PATCH 3/6] Test file for git-remote-mediawiki clone","fromName":"","fromEmail":"konglu@minatec.inpg.fr","sentAt":"2012-06-12T21:34:48Z","receivedAt":"2012-06-12T21:34:48Z","isPatch":true,"sender":{"key":"konglu@minatec.inpg.fr","avatar":null},"body":"\nSimon Cathebras <simon.cathebras@ensimag.imag.fr> a écrit :\n\n> From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n>\n> This patch provides some tests for the clone in use by\n> git-remote-mediawiki.\n>\n> Signed-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>\n> Signed-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>\n> Signed-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n> Signed-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>\n> Signed-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>\n> Signed-off-by: Matthieu Moy <matthieu.moy@imag.fr>\n> ---\n>  contrib/mw-to-git/t/t9360-mw-to-git-clone.sh | 238  \n> +++++++++++++++++++++++++++\n>  1 file changed, 238 insertions(+)\n>  create mode 100755 contrib/mw-to-git/t/t9360-mw-to-git-clone.sh\n>\n> diff --git a/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh  \n> b/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh\n> new file mode 100755\n> index 0000000..07e1270\n> --- /dev/null\n> +++ b/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh\n> @@ -0,0 +1,238 @@\n> +#!/bin/sh\n> +#\n> +# Copyright (C) 2012\n> +#     Charles Roussel <charles.roussel@ensimag.imag.fr>\n> +#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>\n> +#     Julien Khayat <julien.khayat@ensimag.imag.fr>\n> +#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n> +#     Simon Perrat <simon.perrat@ensimag.imag.fr>\n> +#\n> +# License: GPL v2 or later\n> +\n> +\n> +test_description='Test the Git Mediawiki remote helper: git clone'\n> +\n> +. ./test-gitmw-lib.sh\n> +. $TEST_DIRECTORY/test-lib.sh\n> +\n> +\n> +test_check_precond\n> +\n> +\n> +test_expect_success 'Git clone creates the git log expected with one file' '\n> +\twiki_reset &&\n> +\twiki_editpage foo \"this is not important\" false -c cat -s \"this  \n> must be the same\" &&\n> +\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"'  \n> mw_dir_1 &&\n> +\t(cd mw_dir_1 &&\n> +\tgit log --format=%s HEAD^..HEAD > log.tmp ) &&\n> +\techo \"this must be the same\" > msg.tmp &&\n> +\tdiff -b mw_dir_1/log.tmp msg.tmp\n> +'\n\nIt's clearer to put it this way:\n\n         git clone [...] &&\n         (\n                 cd ... &&\n                 ....\n         ) &&\n         ....\n\nAnd, about style:\n     \"echo one >one\" and not \"echo one > one\"\n"},{"id":"193515","messageId":"20120612234518.Horde.MC1TTXwdC4BP17hurbfVZrA@webmail.minatec.grenoble-inp.fr","threadId":"30773","inReplyTo":"1339535563-18958-5-git-send-email-simon.cathebras@ensimag.imag.fr","subject":"Re: [PATCH 5/6] Tests of UTF8 character with git-remote-mediawiki","fromName":"","fromEmail":"konglu@minatec.inpg.fr","sentAt":"2012-06-12T21:45:18Z","receivedAt":"2012-06-12T21:45:18Z","isPatch":true,"sender":{"key":"konglu@minatec.inpg.fr","avatar":null},"body":"\nSimon Cathebras <simon.cathebras@ensimag.imag.fr> a écrit :\n\n> This patch provides a sample of tests for git-remote-mediawiki's\n> resistance, concerning utf8 special characters.\n>\n> Signed-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>\n> Signed-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>\n> Signed-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n> Signed-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>\n> Signed-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>\n> Signed-off-by: Matthieu Moy <matthieu.moy@imag.fr>\n> ---\n>  contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh | 271  \n> ++++++++++++++++++++++++++++\n>  1 file changed, 271 insertions(+)\n>  create mode 100755 contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh\n\nThanks, it applies correctly now :)\n"},{"id":"193516","messageId":"20120612235214.Horde.b7SrP3wdC4BP17oOhzt0vgA@webmail.minatec.grenoble-inp.fr","threadId":"30773","inReplyTo":"4FD7B242.9020005@ensimag.imag.fr","subject":"Re: [PATCH 5/6] Tests of UTF8 character with git-remote-mediawiki","fromName":"","fromEmail":"konglu@minatec.inpg.fr","sentAt":"2012-06-12T21:52:14Z","receivedAt":"2012-06-12T21:52:14Z","isPatch":true,"sender":{"key":"konglu@minatec.inpg.fr","avatar":null},"body":"\n\"Simon.Cathebras\" <Simon.Cathebras@ensimag.imag.fr> a écrit :\n\n> Please accept our appologize for the bad tag for patches.\n>\n> The PATCH 5 is actually the last one...\n\nShouldn't it also be the version 4 ?\n\nThanks,\n\nLucien Kong\n"},{"id":"193524","messageId":"4FD83F41.3050101@ensimag.imag.fr","threadId":"30773","inReplyTo":"20120612233448.Horde.yFmTWnwdC4BP17X4iOBVZrA@webmail.minatec.grenoble-inp.fr","subject":"Re: [PATCH 3/6] Test file for git-remote-mediawiki clone","fromName":"Simon.Cathebras","fromEmail":"simon.cathebras@ensimag.imag.fr","sentAt":"2012-06-13T07:20:33Z","receivedAt":"2012-06-13T07:20:33Z","isPatch":true,"sender":{"key":"simon.cathebras@ensimag.imag.fr","avatar":"https://avatars.githubusercontent.com/u/1764010?v=4"},"body":"\n\nOn 12/06/2012 23:34, konglu@minatec.inpg.fr wrote:\n>\n> Simon Cathebras <simon.cathebras@ensimag.imag.fr> a écrit :\n>\n>> From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n>>\n>> This patch provides some tests for the clone in use by\n>> git-remote-mediawiki.\n>>\n>> Signed-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>\n>> Signed-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>\n>> Signed-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n>> Signed-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>\n>> Signed-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>\n>> Signed-off-by: Matthieu Moy <matthieu.moy@imag.fr>\n>> ---\n>>  contrib/mw-to-git/t/t9360-mw-to-git-clone.sh | 238 \n>> +++++++++++++++++++++++++++\n>>  1 file changed, 238 insertions(+)\n>>  create mode 100755 contrib/mw-to-git/t/t9360-mw-to-git-clone.sh\n>>\n>> diff --git a/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh \n>> b/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh\n>> new file mode 100755\n>> index 0000000..07e1270\n>> --- /dev/null\n>> +++ b/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh\n>> @@ -0,0 +1,238 @@\n>> +#!/bin/sh\n>> +#\n>> +# Copyright (C) 2012\n>> +#     Charles Roussel <charles.roussel@ensimag.imag.fr>\n>> +#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>\n>> +#     Julien Khayat <julien.khayat@ensimag.imag.fr>\n>> +#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n>> +#     Simon Perrat <simon.perrat@ensimag.imag.fr>\n>> +#\n>> +# License: GPL v2 or later\n>> +\n>> +\n>> +test_description='Test the Git Mediawiki remote helper: git clone'\n>> +\n>> +. ./test-gitmw-lib.sh\n>> +. $TEST_DIRECTORY/test-lib.sh\n>> +\n>> +\n>> +test_check_precond\n>> +\n>> +\n>> +test_expect_success 'Git clone creates the git log expected with one \n>> file' '\n>> +    wiki_reset &&\n>> +    wiki_editpage foo \"this is not important\" false -c cat -s \"this \n>> must be the same\" &&\n>> +    git clone \n>> mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_1 &&\n>> +    (cd mw_dir_1 &&\n>> +    git log --format=%s HEAD^..HEAD > log.tmp ) &&\n>> +    echo \"this must be the same\" > msg.tmp &&\n>> +    diff -b mw_dir_1/log.tmp msg.tmp\n>> +'\n>\n> It's clearer to put it this way:\n>\n>         git clone [...] &&\n>         (\n>                 cd ... &&\n>                 ....\n>         ) &&\n>         ....\n>\n\nOkay, we are modifiying it right now.\n\n> And, about style:\n>     \"echo one >one\" and not \"echo one > one\"\n>\n>\n>\nsame.\n\n\nSimon C.\n\n-- \nCATHEBRAS Simon\n\n2A-ENSIMAG\n\nFilière Ingéniérie des Systèmes d'Information\nMembre Bug-Buster\n"},{"id":"193525","messageId":"4FD841A9.2010507@ensimag.imag.fr","threadId":"30773","inReplyTo":"20120612235214.Horde.b7SrP3wdC4BP17oOhzt0vgA@webmail.minatec.grenoble-inp.fr","subject":"Re: [PATCH 5/6] Tests of UTF8 character with git-remote-mediawiki","fromName":"Simon.Cathebras","fromEmail":"simon.cathebras@ensimag.imag.fr","sentAt":"2012-06-13T07:30:49Z","receivedAt":"2012-06-13T07:30:49Z","isPatch":true,"sender":{"key":"simon.cathebras@ensimag.imag.fr","avatar":"https://avatars.githubusercontent.com/u/1764010?v=4"},"body":"\n\nOn 12/06/2012 23:52, konglu@minatec.inpg.fr wrote:\n>\n> \"Simon.Cathebras\" <Simon.Cathebras@ensimag.imag.fr> a écrit :\n>\n>> Please accept our appologize for the bad tag for patches.\n>>\n>> The PATCH 5 is actually the last one...\n>\n> Shouldn't it also be the version 4 ?\n>\n\nActually, yes.\nThanks.\n\n> Thanks,\n>\n> Lucien Kong\n>\n\n\n-- \nCATHEBRAS Simon\n\n2A-ENSIMAG\n\nFilière Ingéniérie des Systèmes d'Information\nMembre Bug-Buster\n"},{"id":"193527","messageId":"vpqtxyfk5l8.fsf@bauges.imag.fr","threadId":"30773","inReplyTo":"1339535563-18958-2-git-send-email-simon.cathebras@ensimag.imag.fr","subject":"Re: [PATCH 2/6] Test environment of git-remote-mediawiki","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2012-06-13T07:56:35Z","receivedAt":"2012-06-13T07:56:35Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Simon Cathebras <simon.cathebras@ensimag.imag.fr> writes:\n\n> +# Check the preconditions to run git-remote-mediawiki's tests\n> +test_check_precond () {\n\nThis is a very generic name (with risk of name clash in future versions\nof test-lib.sh). This checks the git-mediawiki preconditions, so how\nabout test_check_wiki_precond?\n\n> +\tif ! test_have_prereq PERL\n> +\tthen\n> +\t\tskip_all='skipping gateway git-mw tests, perl not available'\n> +\t\ttest_done\n> +\tfi\n> +\n> +\tif [ ! -f $GIT_BUILD_DIR/git-remote-mediawiki ];\n\n\"\" around $GIT_BUILD_DIR\n\nBut why $GIT_BUILD_DIR ? git-remote-mediawiki usually doesn't go there,\nit is either as source in contrib/, or installed in the $PATH.\n\n> +\tthen\n> +\t\tskip_all='skipping gateway git-mw tests, no remote mediawiki for git found' \\\n> +\t\t'please try: cp git/contrib/mw-to-git/git-remote-mediawiki git/'\n\nDon't you have a \"make install\" target for that now?\n\n+\t$CURR_DIR/test-gitmw.pl getallpagename\n\nHere and elsewhere, \"\" around \"$CURR_DIR\"\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"193529","messageId":"4FD84AF7.20105@ensimag.imag.fr","threadId":"30773","inReplyTo":"vpqtxyfk5l8.fsf@bauges.imag.fr","subject":"Re: [PATCH 2/6] Test environment of git-remote-mediawiki","fromName":"Simon.Cathebras","fromEmail":"simon.cathebras@ensimag.imag.fr","sentAt":"2012-06-13T08:10:31Z","receivedAt":"2012-06-13T08:10:31Z","isPatch":true,"sender":{"key":"simon.cathebras@ensimag.imag.fr","avatar":"https://avatars.githubusercontent.com/u/1764010?v=4"},"body":"\n\nOn 13/06/2012 09:56, Matthieu Moy wrote:\n> Simon Cathebras<simon.cathebras@ensimag.imag.fr>  writes:\n>\n>> +# Check the preconditions to run git-remote-mediawiki's tests\n>> +test_check_precond () {\n> This is a very generic name (with risk of name clash in future versions\n> of test-lib.sh). This checks the git-mediawiki preconditions, so how\n> about test_check_wiki_precond?\n\nI agree with that.\n\n>> +\tif ! test_have_prereq PERL\n>> +\tthen\n>> +\t\tskip_all='skipping gateway git-mw tests, perl not available'\n>> +\t\ttest_done\n>> +\tfi\n>> +\n>> +\tif [ ! -f $GIT_BUILD_DIR/git-remote-mediawiki ];\n> \"\" around $GIT_BUILD_DIR\n>\n> But why $GIT_BUILD_DIR ? git-remote-mediawiki usually doesn't go there,\n> it is either as source in contrib/, or installed in the $PATH.\n\nIndeed, I developped this code and I have missunderstood the behavior of \ncontrib. It will be fix in the next patch by tonight.\n\n>> +\tthen\n>> +\t\tskip_all='skipping gateway git-mw tests, no remote mediawiki for git found' \\\n>> +\t\t'please try: cp git/contrib/mw-to-git/git-remote-mediawiki git/'\n> Don't you have a \"make install\" target for that now?\n\nYes we have. We shall correct it by tonight.\n\n>\n> +\t$CURR_DIR/test-gitmw.pl getallpagename\n>\n> Here and elsewhere, \"\" around \"$CURR_DIR\"\n>\nGot it, thanks =).\n\nSimon C\n\n-- \nCATHEBRAS Simon\n\n2A-ENSIMAG\n\nFilière Ingéniérie des Systèmes d'Information\nMembre Bug-Buster\n"},{"id":"193535","messageId":"CACBZZX5v_cZTddWB3vPsepL2LPzP8zd+pOC5w+=SV8aYJpL3HA@mail.gmail.com","threadId":"30773","inReplyTo":"1339535563-18958-2-git-send-email-simon.cathebras@ensimag.imag.fr","subject":"Re: [PATCH 2/6] Test environment of git-remote-mediawiki","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2012-06-13T10:14:49Z","receivedAt":"2012-06-13T10:14:49Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Tue, Jun 12, 2012 at 11:12 PM, Simon Cathebras\n<simon.cathebras@ensimag.imag.fr> wrote:\n\nSome comments on your perl style:\n\n> +use Switch;\n> +use encoding 'utf8';\n> +use DateTime::Format::ISO8601;\n> +use open ':encoding(utf8)';\n> +use constant SLASH_REPLACEMENT => \"%2F\";\n> +\n> +#Parsing of the config file\n> +\n> +my $configfile = \"$ENV{'CURR_DIR'}/test.config\";\n> +my %config;\n> +open (CONFIG,\"< $configfile\") || die \"can't open $configfile: $!\";\n> +while (<CONFIG>)\n\nYou probably want to use lexical filehandles instead:\n\n    open my $config, \"<\", $configfile or die \"...\";\n    while (<$config>)\n\nAnd also note the three-arg open I'm using, might want to change the\nrest to use that.\n\n> +{\n> +        chomp;\n> +        s/#.*//;\n> +        s/^\\s+//;\n> +        s/\\s+$//;\n> +        next unless length;\n> +        my ($key, $value) = split (/\\s*=\\s*/,$_, 2);\n> +        $config{$key} = $value;\n> +       last if ($key eq 'LIGHTTPD' and $value eq 'false');\n> +       last if ($key eq 'PORT');\n> +}\n\nAnd add:\n\n    close $config or die \"can't close $configfile: $!\";\n\nAlso you can do:\n\n    while (my $line = <$config>) {\n        chomp $line;\n\nWhich IMO makes any code that's more than 2-3 lines long less\nconfusing as there's no doubt what $_ refers to.\n\n> +my $wiki_address = \"http://$config{'SERVER_ADDR'}\".\":\".\"$config{'PORT'}\";\n> +my $wiki_url = \"$wiki_address/$config{'WIKI_DIR_NAME'}/api.php\";\n> +my $wiki_admin = \"$config{'WIKI_ADMIN'}\";\n> +my $wiki_admin_pass = \"$config{'WIKI_PASSW'}\";\n> +my $mw = MediaWiki::API->new;\n> +$mw->{config}->{api_url} = $wiki_url;\n> +\n> +sub mediawiki_clean_filename {\n> +       my $filename = shift;\n> +       $filename =~ s/@{[SLASH_REPLACEMENT]}/\\//g;\n> +       # [, ], |, {, and } are forbidden by MediaWiki, even URL-encoded.\n> +       # Do a variant of URL-encoding, i.e. looks like URL-encoding,\n> +       # but with _ added to prevent MediaWiki from thinking this is\n> +       # an actual special character.\n> +       $filename =~ s/[\\[\\]\\{\\}\\|]/sprintf(\"_%%_%x\", ord($&))/ge;\n> +       # If we use the uri escape before\n> +       # we should unescape here, before anything\n> +\n> +       return $filename;\n> +}\n> +\n> +sub mediawiki_smudge_filename {\n> +       my $filename = shift;\n> +       $filename =~ s/\\//@{[SLASH_REPLACEMENT]}/g;\n> +       $filename =~ s/ /_/g;\n> +       # Decode forbidden characters encoded in mediawiki_clean_filename\n> +       $filename =~ s/_%_([0-9a-fA-F][0-9a-fA-F])/sprintf(\"%c\", hex($1))/ge;\n> +       return $filename;\n> +}\n\nI don't how in the big picture you're aiming to encode article names\nas filenames but if you can at all avoid doing so (i.e. the user\ndoesn't need to be exposed to those files) it's much simpler just to\ntake the article name, sha1sum it and use the first 5-10 bytes of that\nas the filename.\n\nWith all the filesystems and OS's out there and their odd rules it can\nbe tricky to write code that takes an arbitrary string and attempts to\ncast it to a valid filename or path.\n\n> +# wiki_login <name> <password>\n> +#\n> +# Logs the user with <name> and <password> in the global variable\n> +# of the mediawiki $mw\n> +sub wiki_login {\n> +       $mw->login( { lgname => \"$_[0]\",lgpassword => \"$_[1]\" } )\n> +       || die \"getpage: login failed\";\n> +}\n> +\n> +# wiki_getpage <wiki_page> <dest_path>\n> +#\n> +# fetch a page <wiki_page> from the wiki referenced in the global variable\n> +# $mw and copies its content in directory dest_path\n> +sub wiki_getpage {\n> +       my $pagename = $_[0];\n> +       my $destdir = $_[1];\n> +\n> +       my $page = $mw->get_page( { title => $pagename } );\n> +       if (!defined($page)) {\n> +               die \"getpage: wiki does not exist\";\n> +       }\n> +\n> +       my $content = $page->{'*'};\n> +       if (!defined($content)) {\n> +               die \"getpage: page does not exist\";\n> +       }\n> +\n> +       # Replace spaces by underscore in the page name\n> +       $pagename=$page->{'title'};\n> +       $pagename = mediawiki_smudge_filename $pagename;\n> +       open(my $file, \">$destdir/$pagename.mw\");\n> +       print $file \"$content\";\n> +       close ($file);\n> +\n> +}\n> +\n> +# wiki_delete_page <page_name>\n> +#\n> +# delete the page with name <page_name> from the wiki referenced\n> +# in the global variable $mw\n> +sub wiki_delete_page {\n> +       my $pagename = $_[0];\n> +\n> +       my $exist=$mw->get_page({title => $pagename});\n> +\n> +       if (defined($exist->{'*'})){\n> +               $mw->edit({ action => 'delete',\n> +                               title => $pagename})\n> +               || die $mw->{error}->{code} . \": \" . $mw->{error}->{details};\n> +       } else {\n> +               die \"no page with such name found: $pagename\\n\";\n> +       }\n> +}\n> +\n> +# wiki_editpage <wiki_page> <wiki_content> <wiki_append> [-c=<category>] [-s=<summary>]\n> +#\n> +# Edit a page named <wiki_page> with content <wiki_content> on the wiki\n> +# referenced with the global variable $mw\n> +# If <wiki_append> == true : append <wiki_content> at the end of the actual\n> +# content of the page <wiki_page>\n> +# If <wik_page> doesn't exist, that page is created with the <wiki_content>\n> +sub wiki_editpage {\n> +       my $wiki_page = mediawiki_clean_filename $_[0];\n> +       my $wiki_content = $_[1];\n> +       my $wiki_append = $_[2];\n> +       my $summary = \"\";\n> +       my ($summ, $cat) = ();\n> +       GetOptions('s=s' => \\$summ, 'c=s' => \\$cat);\n> +\n> +       my $append = 0;\n> +       if (defined($wiki_append) && $wiki_append eq 'true') {\n> +               $append=1;\n> +       }\n> +\n> +       my $previous_text =\"\";\n> +\n> +       if ($append) {\n> +               my $ref = $mw->get_page( { title => $wiki_page } );\n> +               $previous_text = $ref->{'*'};\n> +       }\n> +\n> +       my $text = $wiki_content;\n> +       if (defined($previous_text)) {\n> +               $text=\"$previous_text$text\";\n> +       }\n> +\n> +       # Eventually, add this page to a category.\n> +       if (defined($cat)) {\n> +               my $category_name=\"[[Category:$cat]]\";\n> +               $text=\"$text\\n $category_name\";\n> +       }\n> +       if(defined($summ)){\n> +               $summary=$summ;\n> +       }\n> +\n> +       $mw->edit( { action => 'edit', title => $wiki_page, summary => $summary, text => \"$text\"} );\n> +}\n> +\n> +# wiki_getallpagename [<category>]\n> +#\n> +# Fetch all pages of the wiki referenced by the global variable $mw\n> +# and print the names of each one in the file all.txt with a new line\n> +# (\"\\n\") between these.\n> +# If the argument <category> is defined, then this function get only the pages\n> +# belonging to <category>.\n> +sub wiki_getallpagename {\n> +       # fetch the pages of the wiki\n> +       if (defined($_[0])) {\n> +               my $mw_pages = $mw->list ( { action => 'query',\n> +                               list => 'categorymembers',\n> +                               cmtitle => \"Category:$_[0]\",\n> +                               cmnamespace => 0,\n> +                               cmlimit=> 500 },\n> +               )\n> +               || die $mw->{error}->{code}.\": \".$mw->{error}->{details};\n> +               open(my $file, \">all.txt\");\n> +               foreach my $page (@{$mw_pages}) {\n> +                       print $file \"$page->{title}\\n\";\n> +               }\n> +               close ($file);\n> +\n> +       } else {\n> +               my $mw_pages = $mw->list({\n> +                               action => 'query',\n> +                               list => 'allpages',\n> +                               aplimit => 500,\n> +                       })\n> +               || die $mw->{error}->{code}.\": \".$mw->{error}->{details};\n> +               open(my $file, \">all.txt\");\n> +               foreach my $page (@{$mw_pages}) {\n> +                       print $file \"$page->{title}\\n\";\n> +               }\n> +               close ($file);\n> +       }\n> +}\n> +\n> +# Main part of this script: parse the command line arguments\n> +# and select which function to execute\n> +my $fct_to_call = shift;\n> +\n> +&wiki_login($wiki_admin,$wiki_admin_pass);\n> +\n> +switch ($fct_to_call) {\n> +       case \"get_page\" { &wiki_getpage(@ARGV)}\n> +       case \"delete_page\" { &wiki_delete_page(@ARGV)}\n> +       case \"edit_page\" { &wiki_editpage(@ARGV)}\n> +       case \"getallpagename\" { &wiki_getallpagename(@ARGV)}\n> +       else { die(\"test-gitmw.pl ERROR: wrong argument\")}\n> +}\n\nWhen you're calling bareword functions you can just call them as as\nwiki_login(..) not &wiki_login(..).\n\nAlso please don't use Switch.pm at all, it's a source filter, is\ndeprecated from the Perl core, and it's much better to write this as:\n\nmy %functions_to_call = qw(\n    get_page       wiki_getpage\n    delete_page    wiki_delete_page\n    edit_page      wiki_editpage\n    getallpagename wiki_getallpagename\n);\ndie \"$0 ERROR: wrong argument\" unless exists $functions_to_call{$fct_to_call};\n&{$functions_to_call{$fct_to_call}}(@ARGV);\n"},{"id":"193548","messageId":"4FD8C71F.1070508@ensimag.imag.fr","threadId":"30773","inReplyTo":"CACBZZX5v_cZTddWB3vPsepL2LPzP8zd+pOC5w+=SV8aYJpL3HA@mail.gmail.com","subject":"Re: [PATCH 2/6] Test environment of git-remote-mediawiki","fromName":"Simon.Cathebras","fromEmail":"simon.cathebras@ensimag.imag.fr","sentAt":"2012-06-13T17:00:15Z","receivedAt":"2012-06-13T17:00:15Z","isPatch":true,"sender":{"key":"simon.cathebras@ensimag.imag.fr","avatar":"https://avatars.githubusercontent.com/u/1764010?v=4"},"body":"\n\nOn 13/06/2012 12:14, Ævar Arnfjörð Bjarmason wrote:\n> On Tue, Jun 12, 2012 at 11:12 PM, Simon Cathebras\n> <simon.cathebras@ensimag.imag.fr>  wrote:\n>\n> Some comments on your perl style:\n>\n>> +use Switch;\n>> +use encoding 'utf8';\n>> +use DateTime::Format::ISO8601;\n>> +use open ':encoding(utf8)';\n>> +use constant SLASH_REPLACEMENT =>  \"%2F\";\n>> +\n>> +#Parsing of the config file\n>> +\n>> +my $configfile = \"$ENV{'CURR_DIR'}/test.config\";\n>> +my %config;\n>> +open (CONFIG,\"<  $configfile\") || die \"can't open $configfile: $!\";\n>> +while (<CONFIG>)\n> You probably want to use lexical filehandles instead:\n>\n>      open my $config, \"<\", $configfile or die \"...\";\n>      while (<$config>)\n>\n> And also note the three-arg open I'm using, might want to change the\n> rest to use that.\n\nWe corrected it. The correction will appears in our next patch.\n\n>> +{\n>> +        chomp;\n>> +        s/#.*//;\n>> +        s/^\\s+//;\n>> +        s/\\s+$//;\n>> +        next unless length;\n>> +        my ($key, $value) = split (/\\s*=\\s*/,$_, 2);\n>> +        $config{$key} = $value;\n>> +       last if ($key eq 'LIGHTTPD' and $value eq 'false');\n>> +       last if ($key eq 'PORT');\n>> +}\n> And add:\n>\n>      close $config or die \"can't close $configfile: $!\";\n>\n> Also you can do:\n>\n>      while (my $line =<$config>) {\n>          chomp $line;\n>\n> Which IMO makes any code that's more than 2-3 lines long less\n> confusing as there's no doubt what $_ refers to.\n\nSame.\n\n>> +my $wiki_address = \"http://$config{'SERVER_ADDR'}\".\":\".\"$config{'PORT'}\";\n>> +my $wiki_url = \"$wiki_address/$config{'WIKI_DIR_NAME'}/api.php\";\n>> +my $wiki_admin = \"$config{'WIKI_ADMIN'}\";\n>> +my $wiki_admin_pass = \"$config{'WIKI_PASSW'}\";\n>> +my $mw = MediaWiki::API->new;\n>> +$mw->{config}->{api_url} = $wiki_url;\n>> +\n>> +sub mediawiki_clean_filename {\n>> +       my $filename = shift;\n>> +       $filename =~ s/@{[SLASH_REPLACEMENT]}/\\//g;\n>> +       # [, ], |, {, and } are forbidden by MediaWiki, even URL-encoded.\n>> +       # Do a variant of URL-encoding, i.e. looks like URL-encoding,\n>> +       # but with _ added to prevent MediaWiki from thinking this is\n>> +       # an actual special character.\n>> +       $filename =~ s/[\\[\\]\\{\\}\\|]/sprintf(\"_%%_%x\", ord($&))/ge;\n>> +       # If we use the uri escape before\n>> +       # we should unescape here, before anything\n>> +\n>> +       return $filename;\n>> +}\n>> +\n>> +sub mediawiki_smudge_filename {\n>> +       my $filename = shift;\n>> +       $filename =~ s/\\//@{[SLASH_REPLACEMENT]}/g;\n>> +       $filename =~ s/ /_/g;\n>> +       # Decode forbidden characters encoded in mediawiki_clean_filename\n>> +       $filename =~ s/_%_([0-9a-fA-F][0-9a-fA-F])/sprintf(\"%c\", hex($1))/ge;\n>> +       return $filename;\n>> +}\n> I don't how in the big picture you're aiming to encode article names\n> as filenames but if you can at all avoid doing so (i.e. the user\n> doesn't need to be exposed to those files) it's much simpler just to\n> take the article name, sha1sum it and use the first 5-10 bytes of that\n> as the filename.\n>\n> With all the filesystems and OS's out there and their odd rules it can\n> be tricky to write code that takes an arbitrary string and attempts to\n> cast it to a valid filename or path.\n\nActually, we copy paste this code from git-remote-mediawiki. As a test \nenvironment, this strategy appears to be a bad one (in addition of the \ncopy paste itself...).\nAnyway, we decided to remove this code and modify our tests.\n\nAs a matter this code's purpose in git-remote-mediawiki is to change the \nforbidden character in page name for wiki's, into understandable ones. \nSo, in my opinion, using sha1sum would be useless.\n\n>> +# wiki_login<name>  <password>\n>> +#\n>> +# Logs the user with<name>  and<password>  in the global variable\n>> +# of the mediawiki $mw\n>> +sub wiki_login {\n>> +       $mw->login( { lgname =>  \"$_[0]\",lgpassword =>  \"$_[1]\" } )\n>> +       || die \"getpage: login failed\";\n>> +}\n>> +\n>> +# wiki_getpage<wiki_page>  <dest_path>\n>> +#\n>> +# fetch a page<wiki_page>  from the wiki referenced in the global variable\n>> +# $mw and copies its content in directory dest_path\n>> +sub wiki_getpage {\n>> +       my $pagename = $_[0];\n>> +       my $destdir = $_[1];\n>> +\n>> +       my $page = $mw->get_page( { title =>  $pagename } );\n>> +       if (!defined($page)) {\n>> +               die \"getpage: wiki does not exist\";\n>> +       }\n>> +\n>> +       my $content = $page->{'*'};\n>> +       if (!defined($content)) {\n>> +               die \"getpage: page does not exist\";\n>> +       }\n>> +\n>> +       # Replace spaces by underscore in the page name\n>> +       $pagename=$page->{'title'};\n>> +       $pagename = mediawiki_smudge_filename $pagename;\n>> +       open(my $file, \">$destdir/$pagename.mw\");\n>> +       print $file \"$content\";\n>> +       close ($file);\n>> +\n>> +}\n>> +\n>> +# wiki_delete_page<page_name>\n>> +#\n>> +# delete the page with name<page_name>  from the wiki referenced\n>> +# in the global variable $mw\n>> +sub wiki_delete_page {\n>> +       my $pagename = $_[0];\n>> +\n>> +       my $exist=$mw->get_page({title =>  $pagename});\n>> +\n>> +       if (defined($exist->{'*'})){\n>> +               $mw->edit({ action =>  'delete',\n>> +                               title =>  $pagename})\n>> +               || die $mw->{error}->{code} . \": \" . $mw->{error}->{details};\n>> +       } else {\n>> +               die \"no page with such name found: $pagename\\n\";\n>> +       }\n>> +}\n>> +\n>> +# wiki_editpage<wiki_page>  <wiki_content>  <wiki_append>  [-c=<category>] [-s=<summary>]\n>> +#\n>> +# Edit a page named<wiki_page>  with content<wiki_content>  on the wiki\n>> +# referenced with the global variable $mw\n>> +# If<wiki_append>  == true : append<wiki_content>  at the end of the actual\n>> +# content of the page<wiki_page>\n>> +# If<wik_page>  doesn't exist, that page is created with the<wiki_content>\n>> +sub wiki_editpage {\n>> +       my $wiki_page = mediawiki_clean_filename $_[0];\n>> +       my $wiki_content = $_[1];\n>> +       my $wiki_append = $_[2];\n>> +       my $summary = \"\";\n>> +       my ($summ, $cat) = ();\n>> +       GetOptions('s=s' =>  \\$summ, 'c=s' =>  \\$cat);\n>> +\n>> +       my $append = 0;\n>> +       if (defined($wiki_append)&&  $wiki_append eq 'true') {\n>> +               $append=1;\n>> +       }\n>> +\n>> +       my $previous_text =\"\";\n>> +\n>> +       if ($append) {\n>> +               my $ref = $mw->get_page( { title =>  $wiki_page } );\n>> +               $previous_text = $ref->{'*'};\n>> +       }\n>> +\n>> +       my $text = $wiki_content;\n>> +       if (defined($previous_text)) {\n>> +               $text=\"$previous_text$text\";\n>> +       }\n>> +\n>> +       # Eventually, add this page to a category.\n>> +       if (defined($cat)) {\n>> +               my $category_name=\"[[Category:$cat]]\";\n>> +               $text=\"$text\\n $category_name\";\n>> +       }\n>> +       if(defined($summ)){\n>> +               $summary=$summ;\n>> +       }\n>> +\n>> +       $mw->edit( { action =>  'edit', title =>  $wiki_page, summary =>  $summary, text =>  \"$text\"} );\n>> +}\n>> +\n>> +# wiki_getallpagename [<category>]\n>> +#\n>> +# Fetch all pages of the wiki referenced by the global variable $mw\n>> +# and print the names of each one in the file all.txt with a new line\n>> +# (\"\\n\") between these.\n>> +# If the argument<category>  is defined, then this function get only the pages\n>> +# belonging to<category>.\n>> +sub wiki_getallpagename {\n>> +       # fetch the pages of the wiki\n>> +       if (defined($_[0])) {\n>> +               my $mw_pages = $mw->list ( { action =>  'query',\n>> +                               list =>  'categorymembers',\n>> +                               cmtitle =>  \"Category:$_[0]\",\n>> +                               cmnamespace =>  0,\n>> +                               cmlimit=>  500 },\n>> +               )\n>> +               || die $mw->{error}->{code}.\": \".$mw->{error}->{details};\n>> +               open(my $file, \">all.txt\");\n>> +               foreach my $page (@{$mw_pages}) {\n>> +                       print $file \"$page->{title}\\n\";\n>> +               }\n>> +               close ($file);\n>> +\n>> +       } else {\n>> +               my $mw_pages = $mw->list({\n>> +                               action =>  'query',\n>> +                               list =>  'allpages',\n>> +                               aplimit =>  500,\n>> +                       })\n>> +               || die $mw->{error}->{code}.\": \".$mw->{error}->{details};\n>> +               open(my $file, \">all.txt\");\n>> +               foreach my $page (@{$mw_pages}) {\n>> +                       print $file \"$page->{title}\\n\";\n>> +               }\n>> +               close ($file);\n>> +       }\n>> +}\n>> +\n>> +# Main part of this script: parse the command line arguments\n>> +# and select which function to execute\n>> +my $fct_to_call = shift;\n>> +\n>> +&wiki_login($wiki_admin,$wiki_admin_pass);\n>> +\n>> +switch ($fct_to_call) {\n>> +       case \"get_page\" {&wiki_getpage(@ARGV)}\n>> +       case \"delete_page\" {&wiki_delete_page(@ARGV)}\n>> +       case \"edit_page\" {&wiki_editpage(@ARGV)}\n>> +       case \"getallpagename\" {&wiki_getallpagename(@ARGV)}\n>> +       else { die(\"test-gitmw.pl ERROR: wrong argument\")}\n>> +}\n> When you're calling bareword functions you can just call them as as\n> wiki_login(..) not&wiki_login(..).\n>\n> Also please don't use Switch.pm at all, it's a source filter, is\n> deprecated from the Perl core, and it's much better to write this as:\n>\n> my %functions_to_call = qw(\n>      get_page       wiki_getpage\n>      delete_page    wiki_delete_page\n>      edit_page      wiki_editpage\n>      getallpagename wiki_getallpagename\n> );\n> die \"$0 ERROR: wrong argument\" unless exists $functions_to_call{$fct_to_call};\n> &{$functions_to_call{$fct_to_call}}(@ARGV);\nCorrected\n\nThanks ! :)\n\n-- \nCATHEBRAS Simon\n\n2A-ENSIMAG\n\nFilière Ingéniérie des Systèmes d'Information\nMembre Bug-Buster\n"},{"id":"193549","messageId":"1339607025-22725-1-git-send-email-simon.cathebras@ensimag.imag.fr","threadId":"30773","inReplyTo":"4FD8C71F.1070508@ensimag.imag.fr","subject":"[PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki","fromName":"Simon Cathebras","fromEmail":"simon.cathebras@ensimag.imag.fr","sentAt":"2012-06-13T17:03:41Z","receivedAt":"2012-06-13T17:03:41Z","isPatch":false,"sender":{"key":"simon.cathebras@ensimag.imag.fr","avatar":"https://avatars.githubusercontent.com/u/1764010?v=4"},"body":"From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n\nInstall_wiki.sh expects the first argument to be 'install' or 'delete'\n'install' installs a MediaWiki on the web's server with SQLite3\n'delete' deletes the previously created wiki.\nNote those functionnalities are made to be used from the user command line in\nthe directory git/contrib/mw-to-git/t/\n\ninstall_wiki also defines a function wiki_reset which clear all content\nof the previously created wiki. Note this functionnality is made to be\nused only by our test function in a subdirectory of t/\n\nSigned-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>\nSigned-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>\nSigned-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\nSigned-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>\nSigned-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@imag.fr>\n\n---\n contrib/mw-to-git/t/install-wiki.sh                |  45 ++++\n contrib/mw-to-git/t/install-wiki/LocalSettings.php | 128 +++++++++\n contrib/mw-to-git/t/install-wiki/db_install.php    | 110 ++++++++\n contrib/mw-to-git/t/test-gitmw-lib.sh              | 288 +++++++++++++++++++++\n contrib/mw-to-git/t/test.config                    |  35 +++\n 5 files changed, 606 insertions(+)\n create mode 100755 contrib/mw-to-git/t/install-wiki.sh\n create mode 100644 contrib/mw-to-git/t/install-wiki/LocalSettings.php\n create mode 100644 contrib/mw-to-git/t/install-wiki/db_install.php\n create mode 100755 contrib/mw-to-git/t/test-gitmw-lib.sh\n create mode 100644 contrib/mw-to-git/t/test.config\n\ndiff --git a/contrib/mw-to-git/t/install-wiki.sh b/contrib/mw-to-git/t/install-wiki.sh\nnew file mode 100755\nindex 0000000..17a1fc8\n--- /dev/null\n+++ b/contrib/mw-to-git/t/install-wiki.sh\n@@ -0,0 +1,45 @@\n+#!/bin/sh\n+\n+# This script installs or deletes a MediaWiki on your computer.\n+# It requires a web server with PHP and SQLite running. In addition, if you\n+# do not have MediaWiki sources on your computer, the option 'install'\n+# downloads them for you.\n+# Please set the CONFIGURATION VARIABLES in ./test-gitmw-lib.sh\n+\n+WIKI_TEST_DIR=$(cd \"$(dirname \"$0\")\" && pwd)\n+\n+if test -z \"$WIKI_TEST_DIR\"\n+then\n+\tWIKI_TEST_DIR=.\n+fi\n+\n+. \"$WIKI_TEST_DIR\"/test-gitmw-lib.sh\n+usage () {\n+\techo \"Usage: \"\n+\techo \"\t./install-wiki.sh <install | delete | help>\"\n+\techo \"\t\tinstall | -i :\tInstall a wiki on your computer.\"\n+\techo \"\t\tdelete | -d : Delete the wiki and all its pages and \"\n+\techo \"\t\t\tcontent.\"\n+}\n+\n+\n+# Argument: install, delete, --help | -h\n+case \"$1\" in\n+\t\"install\" | \"-i\")\n+\t\twiki_install\n+\t\texit 0\n+\t\t;;\n+\t\"delete\" | \"-d\")\n+\t\twiki_delete\n+\t\texit 0\n+\t\t;;\n+\t\"--help\" | \"-h\")\n+\t\tusage\n+\t\texit 0\n+\t\t;;\n+\t*)\n+\t\techo \"Invalid argument: $1\"\n+\t\tusage\n+\t\texit 1\n+\t\t;;\n+esac\ndiff --git a/contrib/mw-to-git/t/install-wiki/LocalSettings.php b/contrib/mw-to-git/t/install-wiki/LocalSettings.php\nnew file mode 100644\nindex 0000000..aa72518\n--- /dev/null\n+++ b/contrib/mw-to-git/t/install-wiki/LocalSettings.php\n@@ -0,0 +1,128 @@\n+<?php\n+# This file was automatically generated by the MediaWiki 1.19.0\n+# installer. If you make manual changes, please keep track in case you\n+# need to recreate them later.\n+#\n+# See includes/DefaultSettings.php for all configurable settings\n+# and their default values, but don't forget to make changes in _this_\n+# file, not there.\n+#\n+# Further documentation for configuration settings may be found at:\n+# http://www.mediawiki.org/wiki/Manual:Configuration_settings\n+\n+# Protect against web entry\n+if ( !defined( 'MEDIAWIKI' ) ) {\n+\texit;\n+}\n+\n+## Uncomment this to disable output compression\n+# $wgDisableOutputCompression = true;\n+\n+$wgSitename      = \"Git-MediaWiki-Test\";\n+$wgMetaNamespace = \"Git-MediaWiki-Test\";\n+\n+## The URL base path to the directory containing the wiki;\n+## defaults for all runtime URL paths are based off of this.\n+## For more information on customizing the URLs please see:\n+## http://www.mediawiki.org/wiki/Manual:Short_URL\n+$wgScriptPath       = \"@WG_SCRIPT_PATH@\";\n+$wgScriptExtension  = \".php\";\n+\n+## The protocol and server name to use in fully-qualified URLs\n+$wgServer           = \"@WG_SERVER@\";\n+\n+## The relative URL path to the skins directory\n+$wgStylePath        = \"$wgScriptPath/skins\";\n+\n+## The relative URL path to the logo.  Make sure you change this from the default,\n+## or else you'll overwrite your logo when you upgrade!\n+$wgLogo             = \"$wgStylePath/common/images/wiki.png\";\n+\n+## UPO means: this is also a user preference option\n+\n+$wgEnableEmail      = true;\n+$wgEnableUserEmail  = true; # UPO\n+\n+$wgEmergencyContact = \"apache@localhost\";\n+$wgPasswordSender   = \"apache@localhost\";\n+\n+$wgEnotifUserTalk      = false; # UPO\n+$wgEnotifWatchlist     = false; # UPO\n+$wgEmailAuthentication = true;\n+\n+## Database settings\n+$wgDBtype           = \"sqlite\";\n+$wgDBserver         = \"\";\n+$wgDBname           = \"@WG_SQLITE_DATAFILE@\";\n+$wgDBuser           = \"\";\n+$wgDBpassword       = \"\";\n+\n+# SQLite-specific settings\n+$wgSQLiteDataDir    = \"@WG_SQLITE_DATADIR@\";\n+\n+\n+## Shared memory settings\n+$wgMainCacheType    = CACHE_NONE;\n+$wgMemCachedServers = array();\n+\n+## To enable image uploads, make sure the 'images' directory\n+## is writable, then set this to true:\n+$wgEnableUploads  = false;\n+$wgUseImageMagick = true;\n+$wgImageMagickConvertCommand =\"@CONVERT@\";\n+\n+# InstantCommons allows wiki to use images from http://commons.wikimedia.org\n+$wgUseInstantCommons  = false;\n+\n+## If you use ImageMagick (or any other shell command) on a\n+## Linux server, this will need to be set to the name of an\n+## available UTF-8 locale\n+$wgShellLocale = \"en_US.utf8\";\n+\n+## If you want to use image uploads under safe mode,\n+## create the directories images/archive, images/thumb and\n+## images/temp, and make them all writable. Then uncomment\n+## this, if it's not already uncommented:\n+#$wgHashedUploadDirectory = false;\n+\n+## Set $wgCacheDirectory to a writable directory on the web server\n+## to make your wiki go slightly faster. The directory should not\n+## be publically accessible from the web.\n+#$wgCacheDirectory = \"$IP/cache\";\n+\n+# Site language code, should be one of the list in ./languages/Names.php\n+$wgLanguageCode = \"en\";\n+\n+$wgSecretKey = \"1c912bfe3519fb70f5dc523ecc698111cd43d81a11c585b3eefb28f29c2699b7\";\n+#$wgSecretKey = \"@SECRETKEY@\";\n+\n+\n+# Site upgrade key. Must be set to a string (default provided) to turn on the\n+# web installer while LocalSettings.php is in place\n+$wgUpgradeKey = \"ddae7dc87cd0a645\";\n+\n+## Default skin: you can change the default skin. Use the internal symbolic\n+## names, ie 'standard', 'nostalgia', 'cologneblue', 'monobook', 'vector':\n+$wgDefaultSkin = \"vector\";\n+\n+## For attaching licensing metadata to pages, and displaying an\n+## appropriate copyright notice / icon. GNU Free Documentation\n+## License and Creative Commons licenses are supported so far.\n+$wgRightsPage = \"\"; # Set to the title of a wiki page that describes your license/copyright\n+$wgRightsUrl  = \"\";\n+$wgRightsText = \"\";\n+$wgRightsIcon = \"\";\n+\n+# Path to the GNU diff3 utility. Used for conflict resolution.\n+$wgDiff3 = \"/usr/bin/diff3\";\n+\n+# Query string length limit for ResourceLoader. You should only set this if\n+# your web server has a query string length limit (then set it to that limit),\n+# or if you have suhosin.get.max_value_length set in php.ini (then set it to\n+# that value)\n+$wgResourceLoaderMaxQueryLength = -1;\n+\n+\n+\n+# End of automatically generated settings.\n+# Add more configuration options below.\ndiff --git a/contrib/mw-to-git/t/install-wiki/db_install.php b/contrib/mw-to-git/t/install-wiki/db_install.php\nnew file mode 100644\nindex 0000000..3111c73\n--- /dev/null\n+++ b/contrib/mw-to-git/t/install-wiki/db_install.php\n@@ -0,0 +1,110 @@\n+<?php\n+/**\n+ * This script generates a SQLite database for a MediaWiki version 1.19.0\n+ * You must specify the login of the admin (argument 1) and its\n+ * password (argument 2) and the folder where the database file\n+ * is located (absolute path in argument 3).\n+ * It is used by the script install-wiki.sh in order to make easy the\n+ * installation of a MediaWiki.\n+ *\n+ * In order to generate a SQLite database file, MediaWiki ask the user\n+ * to submit some forms in its web browser. This script simulates this\n+ * behavior though the functions <get> and <submit>\n+ *\n+ */\n+$argc = $_SERVER['argc'];\n+$argv = $_SERVER['argv'];\n+\n+$login = $argv[2];\n+$pass = $argv[3];\n+$tmp = $argv[4];\n+$port = $argv[5];\n+\n+$url = 'http://localhost:'.$port.'/wiki/mw-config/index.php';\n+$db_dir = urlencode($tmp);\n+$tmp_cookie = tempnam($tmp,\"COOKIE_\");\n+/*\n+ * Fetchs a page with cURL.\n+ */\n+function get ($page_name = \"\") {\n+        $curl = curl_init();\n+        $page_name_add = \"\";\n+        if ($page_name != \"\") {\n+                $page_name_add = '?page='.$page_name;\n+        }\n+\t$url = $GLOBALS['url'].$page_name_add;\n+        $tmp_cookie=$GLOBALS['tmp_cookie'];\n+        curl_setopt($curl, CURLOPT_COOKIEJAR, $tmp_cookie);\n+        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);\n+        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);\n+        curl_setopt($curl, CURLOPT_COOKIEFILE, $tmp_cookie);\n+        curl_setopt($curl, CURLOPT_HEADER, true);\n+        curl_setopt($curl, CURLOPT_URL,$url);\n+\n+        $page = curl_exec($curl);\n+        curl_close($curl);\n+        return $page;\n+}\n+\n+/*\n+ * Submits a form with cURL.\n+ */\n+function submit($page_name, $option = \"\") {\n+        $curl = curl_init();\n+        $datapost = 'submit-continue=Continue+%E2%86%92';\n+        if ($option != \"\") {\n+                $datapost = $option.'&'.$datapost;\n+        }\n+\t$url = $GLOBALS['url'].'?page='.$page_name;\n+        $tmp_cookie = $GLOBALS['tmp_cookie'];\n+        curl_setopt($curl, CURLOPT_URL, $url);\n+        curl_setopt($curl, CURLOPT_POST, true);\n+        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);\n+        curl_setopt($curl, CURLOPT_POSTFIELDS, $datapost);\n+        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);\n+        curl_setopt($curl, CURLOPT_COOKIEJAR, $tmp_cookie);\n+        curl_setopt($curl, CURLOPT_COOKIEFILE, $tmp_cookie);\n+\n+        $page = curl_exec($curl);\n+        curl_close($curl);\n+        return \"$page\";\n+}\n+\n+/*\n+ * Here starts this script: simulates the behavior of the user\n+ * submitting forms to generates the database file.\n+ * Note this simulation was made for the MediaWiki version 1.19.0,\n+ * we can't assume it works with other versions.\n+ *\n+ */\n+\n+$page = get();\n+preg_match('/input type=\"hidden\" value=\"([0-9]+)\" name=\"LanguageRequestTime\"/',\n+        $page, $matches);\n+$timestamp = $matches[1];\n+$language = \"LanguageRequestTime=$timestamp&uselang=en&ContLang=en\";\n+$page = submit('Language', $language);\n+\n+submit('Welcome');\n+\n+$db_config = 'DBType=sqlite';\n+$db_config = $db_config.'&sqlite_wgSQLiteDataDir='.$db_dir;\n+$db_config = $db_config.'&sqlite_wgDBname='.$argv[1];\n+submit('DBConnect', $db_config);\n+\n+$wiki_config = 'config_wgSitename=TEST';\n+$wiki_config = $wiki_config.'&config__NamespaceType=site-name';\n+$wiki_config = $wiki_config.'&config_wgMetaNamespace=MyWiki';\n+$wiki_config = $wiki_config.'&config__AdminName='.$login;\n+\n+$wiki_config = $wiki_config.'&config__AdminPassword='.$pass;\n+$wiki_config = $wiki_config.'&config__AdminPassword2='.$pass;\n+\n+$wiki_config = $wiki_config.'&wiki__configEmail=email%40email.org';\n+$wiki_config = $wiki_config.'&config__SkipOptional=skip';\n+submit('Name', $wiki_config);\n+submit('Install');\n+submit('Install');\n+\n+unlink($tmp_cookie);\n+?>\ndiff --git a/contrib/mw-to-git/t/test-gitmw-lib.sh b/contrib/mw-to-git/t/test-gitmw-lib.sh\nnew file mode 100755\nindex 0000000..a948f0c\n--- /dev/null\n+++ b/contrib/mw-to-git/t/test-gitmw-lib.sh\n@@ -0,0 +1,288 @@\n+# Copyright (C) 2012\n+#     Charles Roussel <charles.roussel@ensimag.imag.fr>\n+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>\n+#     Julien Khayat <julien.khayat@ensimag.imag.fr>\n+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n+#     Simon Perrat <simon.perrat@ensimag.imag.fr>\n+# License: GPL v2 or later\n+\n+#\n+# CONFIGURATION VARIABLES\n+# You might want to change these ones\n+#\n+\n+. ./test.config\n+\n+export CURR_DIR=$(pwd)\n+export TEST_DIRECTORY=$CURR_DIR/../../../t\n+\n+if test $LIGHTTPD = \"false\" ; then\n+\tPORT=80\n+else\n+\tWIKI_DIR_INST=\"$CURR_DIR/$WEB_WWW\"\n+fi\n+\n+# ================= Install part =================\n+\n+error () {\n+\techo \"$@\" >&2\n+\texit 1\n+}\n+\n+# config_lighttpd\n+#\n+# Create the configuration files and the folders necessary to start lighttpd.\n+# Overwrite any existing file.\n+config_lighttpd() {\n+\tmkdir -p $WEB\n+\tmkdir -p $WEB_TMP\n+\tmkdir -p $WEB_WWW\n+\tcat > $WEB/lighttpd.conf <<EOF\n+\tserver.document-root = \"$CURR_DIR/$WEB_WWW\"\n+\tserver.port = $PORT\n+\tserver.pid-file = \"$CURR_DIR/$WEB_TMP/pid\"\n+\n+\tserver.modules = (\n+\t\"mod_rewrite\",\n+\t\"mod_redirect\",\n+\t\"mod_access\",\n+\t\"mod_accesslog\",\n+\t\"mod_fastcgi\"\n+\t)\n+\n+\tindex-file.names = (\"index.php\" , \"index.html\")\n+\n+\tmimetype.assign\t\t    = (\n+\t\".pdf\"\t\t=>\t\"application/pdf\",\n+\t\".sig\"\t\t=>\t\"application/pgp-signature\",\n+\t\".spl\"\t\t=>\t\"application/futuresplash\",\n+\t\".class\"\t=>\t\"application/octet-stream\",\n+\t\".ps\"\t\t=>\t\"application/postscript\",\n+\t\".torrent\"\t=>\t\"application/x-bittorrent\",\n+\t\".dvi\"\t\t=>\t\"application/x-dvi\",\n+\t\".gz\"\t\t=>\t\"application/x-gzip\",\n+\t\".pac\"\t\t=>\t\"application/x-ns-proxy-autoconfig\",\n+\t\".swf\"\t\t=>\t\"application/x-shockwave-flash\",\n+\t\".tar.gz\"\t=>\t\"application/x-tgz\",\n+\t\".tgz\"\t\t=>\t\"application/x-tgz\",\n+\t\".tar\"\t\t=>\t\"application/x-tar\",\n+\t\".zip\"\t\t=>\t\"application/zip\",\n+\t\".mp3\"\t\t=>\t\"audio/mpeg\",\n+\t\".m3u\"\t\t=>\t\"audio/x-mpegurl\",\n+\t\".wma\"\t\t=>\t\"audio/x-ms-wma\",\n+\t\".wax\"\t\t=>\t\"audio/x-ms-wax\",\n+\t\".ogg\"\t\t=>\t\"application/ogg\",\n+\t\".wav\"\t\t=>\t\"audio/x-wav\",\n+\t\".gif\"\t\t=>\t\"image/gif\",\n+\t\".jpg\"\t\t=>\t\"image/jpeg\",\n+\t\".jpeg\"\t\t=>\t\"image/jpeg\",\n+\t\".png\"\t\t=>\t\"image/png\",\n+\t\".xbm\"\t\t=>\t\"image/x-xbitmap\",\n+\t\".xpm\"\t\t=>\t\"image/x-xpixmap\",\n+\t\".xwd\"\t\t=>\t\"image/x-xwindowdump\",\n+\t\".css\"\t\t=>\t\"text/css\",\n+\t\".html\"\t\t=>\t\"text/html\",\n+\t\".htm\"\t\t=>\t\"text/html\",\n+\t\".js\"\t\t=>\t\"text/javascript\",\n+\t\".asc\"\t\t=>\t\"text/plain\",\n+\t\".c\"\t\t=>\t\"text/plain\",\n+\t\".cpp\"\t\t=>\t\"text/plain\",\n+\t\".log\"\t\t=>\t\"text/plain\",\n+\t\".conf\"\t\t=>\t\"text/plain\",\n+\t\".text\"\t\t=>\t\"text/plain\",\n+\t\".txt\"\t\t=>\t\"text/plain\",\n+\t\".dtd\"\t\t=>\t\"text/xml\",\n+\t\".xml\"\t\t=>\t\"text/xml\",\n+\t\".mpeg\"\t\t=>\t\"video/mpeg\",\n+\t\".mpg\"\t\t=>\t\"video/mpeg\",\n+\t\".mov\"\t\t=>\t\"video/quicktime\",\n+\t\".qt\"\t\t=>\t\"video/quicktime\",\n+\t\".avi\"\t\t=>\t\"video/x-msvideo\",\n+\t\".asf\"\t\t=>\t\"video/x-ms-asf\",\n+\t\".asx\"\t\t=>\t\"video/x-ms-asf\",\n+\t\".wmv\"\t\t=>\t\"video/x-ms-wmv\",\n+\t\".bz2\"\t\t=>\t\"application/x-bzip\",\n+\t\".tbz\"\t\t=>\t\"application/x-bzip-compressed-tar\",\n+\t\".tar.bz2\"\t=>\t\"application/x-bzip-compressed-tar\",\n+\t\"\"\t\t=>\t\"text/plain\"\n+\t)\n+\n+\tfastcgi.server = ( \".php\" =>\n+\t(\"localhost\" =>\n+\t( \"socket\" => \"$CURR_DIR/$WEB_TMP/php.socket\",\n+\t\"bin-path\" => \"$PHP_DIR/php-cgi -c $CURR_DIR/$WEB/php.ini\"\n+\n+\t)\n+\t)\n+\t)\n+EOF\n+\n+\tcat > $WEB/php.ini <<EOF\n+\tsession.save_path ='$CURR_DIR/$WEB_TMP'\n+EOF\n+}\n+\n+# start_lighttpd\n+#\n+# Start or restart daemon lighttpd. If restart, rewrite configuration files.\n+start_lighttpd() {\n+\tif test -f \"$WEB_TMP/pid\"; then\n+\t\techo \"Instance already running. Restarting...\"\n+\t\tstop_lighttpd\n+\tfi\n+\tconfig_lighttpd\n+\t$LIGHTTPD_DIR/lighttpd -f $WEB/lighttpd.conf\n+\n+\tif test $? -ne 0 ; then\n+\t\techo \"Could not execute http deamon lighttpd\"\n+\t\texit 1\n+\tfi\n+}\n+\n+# stop_lighttpd\n+#\n+# Kill daemon lighttpd and removes files and folders associated.\n+stop_lighttpd () {\n+\n+\ttest -f \"$WEB_TMP/pid\" && kill $(cat \"$WEB_TMP/pid\")\n+\trm -rf $WEB\n+}\n+\n+# Create the SQLite database of the MediaWiki. If the database file already\n+# exists, it will be deleted.\n+# This script should be runned from the directory where $FILES_FOLDER is\n+# located.\n+create_db () {\n+\trm -f \"$TMP/$DB_FILE\"\n+\n+\techo \"Generating the SQLite database file. It can take some time ...\"\n+\t# Run the php script to generate the SQLite database file\n+\t# with cURL calls.\n+\tphp \"$FILES_FOLDER/$DB_INSTALL_SCRIPT\" $(basename \"$DB_FILE\" .sqlite) \\\n+\t\t\"$WIKI_ADMIN\" \"$WIKI_PASSW\" \"$TMP\" \"$PORT\"\n+\n+\tif [ ! -f \"$TMP/$DB_FILE\" ] ; then\n+\t\terror \"Can't create database file in TODO. Try to run ./install-wiki.sh delete first.\"\n+\tfi\n+\tchmod 666 \"$TMP/$DB_FILE\"\n+\n+\t# Copy the generated database file into the directory the\n+\t# user indicated.\n+\tcp --preserve=mode,ownership \"$TMP/$DB_FILE\" \"$FILES_FOLDER\" ||\n+\t\terror \"Unable to copy $TMP/$DB_FILE to $FILES_FOLDER\"\n+}\n+\n+# Install a wiki in your web server directory.\n+wiki_install () {\n+\tif test $LIGHTTPD = \"true\" ; then\n+\t\tstart_lighttpd\n+\tfi\n+\n+\tSERVER_ADDR=$SERVER_ADDR:$PORT\n+\t# In this part, we change directory to $TMP in order to download,\n+\t# unpack and copy the files of MediaWiki\n+\t(\n+\tmkdir -p \"$WIKI_DIR_INST/$WIKI_DIR_NAME\"\n+\tif [ ! -d \"$WIKI_DIR_INST/$WIKI_DIR_NAME\" ] ; then\n+\t\terror \"Folder $WIKI_DIR_INST/$WIKI_DIR_NAME doesn't exist.\n+\t\tPlease create it and launch the script again.\"\n+\tfi\n+\n+\t# Fetch MediaWiki's archive if not already present in the TMP directory\n+\tcd \"$TMP\"\n+\tif [ ! -f \"$MW_VERSION.tar.gz\" ] ; then\n+\t\techo \"Downloading $MW_VERSION sources ...\"\n+\t\twget \"http://download.wikimedia.org/mediawiki/1.19/mediawiki-1.19.0.tar.gz\" ||\n+\t\t\terror \"Unable to download \"\\\n+\t\t\t\"http://download.wikimedia.org/mediawiki/1.19/\"\\\n+\t\t\t\"mediawiki-1.19.0.tar.gz. \"\\\n+\t\t\t\"Please fix your connection and launch the script again.\"\n+\tfi\n+\ttar xfz \"$MW_VERSION.tar.gz\"\n+\techo \"$MW_VERSION.tar.gz downloaded in `pwd`.\"\\\n+\t\t\"You can delete it later if you want.\"\n+\n+\t# Copy the files of MediaWiki wiki in the web server's directory.\n+\tcd \"$MW_VERSION\"\n+\tcp -Rf * \"$WIKI_DIR_INST/$WIKI_DIR_NAME/\" ||\n+\t\terror \"Unable to copy WikiMedia's files from `pwd` to \"\\\n+\t\t\t\"$WIKI_DIR_INST/$WIKI_DIR_NAME\"\n+\t)\n+\n+\tcreate_db\n+\n+\t# Copy the generic LocalSettings.php in the web server's directory\n+\t# And modify parameters according to the ones set at the top\n+\t# of this script.\n+\t# Note that LocalSettings.php is never modified.\n+\tif [ ! -f \"$FILES_FOLDER/LocalSettings.php\" ] ; then\n+\t\terror \"Can't find $FILES_FOLDER/LocalSettings.php \" \\\n+\t\t\t\"in the current folder. \"\\\n+\t\t\"Please run the script inside its folder.\"\n+\tfi\n+\tcp \"$FILES_FOLDER/LocalSettings.php\" \\\n+\t\t\"$FILES_FOLDER/LocalSettings-tmp.php\" ||\n+\t\terror \"Unable to copy $FILES_FOLDER/LocalSettings.php \" \\\n+\t\t\"to $FILES_FOLDER/LocalSettings-tmp.php\"\n+\n+\t# Parse and set the LocalSettings file of the user according to the\n+\t# CONFIGURATION VARIABLES section at the beginning of this script\n+\tfile_swap=\"$FILES_FOLDER/LocalSettings-swap.php\"\n+\tsed \"s,@WG_SCRIPT_PATH@,/$WIKI_DIR_NAME,\" \\\n+\t\t\"$FILES_FOLDER/LocalSettings-tmp.php\" > \"$file_swap\"\n+\tmv \"$file_swap\" \"$FILES_FOLDER/LocalSettings-tmp.php\"\n+\tsed \"s,@WG_SERVER@,http://$SERVER_ADDR,\" \\\n+\t\t\"$FILES_FOLDER/LocalSettings-tmp.php\" > \"$file_swap\"\n+\tmv \"$file_swap\" \"$FILES_FOLDER/LocalSettings-tmp.php\"\n+\tsed \"s,@WG_SQLITE_DATADIR@,$TMP,\" \\\n+\t\t\"$FILES_FOLDER/LocalSettings-tmp.php\" > \"$file_swap\"\n+\tmv \"$file_swap\" \"$FILES_FOLDER/LocalSettings-tmp.php\"\n+\tsed \"s,@WG_SQLITE_DATAFILE@,$( basename $DB_FILE .sqlite),\" \\\n+\t\t\"$FILES_FOLDER/LocalSettings-tmp.php\" > \"$file_swap\"\n+\tmv \"$file_swap\" \"$FILES_FOLDER/LocalSettings-tmp.php\"\n+\n+\tmv \"$FILES_FOLDER/LocalSettings-tmp.php\" \\\n+\t\t\"$WIKI_DIR_INST/$WIKI_DIR_NAME/LocalSettings.php\" ||\n+\t\terror \"Unable to move $FILES_FOLDER/LocalSettings-tmp.php\" \\\n+\t\t\"in $WIKI_DIR_INST/$WIKI_DIR_NAME\"\n+\techo \"File $FILES_FOLDER/LocalSettings.php is set in\" \\\n+\t\t\" $WIKI_DIR_INST/$WIKI_DIR_NAME\"\n+\n+\tchmod ugo+w \"$FILES_FOLDER/$DB_FILE\"\n+\n+\techo \"Your wiki has been installed. You can check it at\n+\t\thttp://$SERVER_ADDR/$WIKI_DIR_NAME\"\n+}\n+\n+# Reset the database of the wiki and the password of the admin\n+#\n+# Warning: This function must be called only in a subdirectory of t/ directory\n+wiki_reset () {\n+\t# Copy initial database of the wiki\n+\tif [ ! -f \"../$FILES_FOLDER/$DB_FILE\" ] ; then\n+\t\terror \"Can't find ../$FILES_FOLDER/$DB_FILE in the current folder.\"\n+\tfi\n+\tcp \"../$FILES_FOLDER/$DB_FILE\" \"$TMP\" ||\n+\t\terror \"Can't copy ../$FILES_FOLDER/$DB_FILE in $TMP\"\n+\techo \"File $FILES_FOLDER/$DB_FILE is set in $TMP\"\n+}\n+\n+# Delete the wiki created in the web server's directory and all its content\n+# saved in the database.\n+wiki_delete () {\n+\tif test $LIGHTTPD = \"true\"; then\n+\t\tstop_lighttpd\n+\telse\n+\t\t# Delete the wiki's directory.\n+\t\trm -rf \"$WIKI_DIR_INST/$WIKI_DIR_NAME\" ||\n+\t\t\terror \"Wiki's directory $WIKI_DIR_INST/\" \\\n+\t\t\t\"$WIKI_DIR_NAME could not be deleted\"\n+\t\t# Delete the wiki's SQLite database.\n+\t\trm -f \"$TMP/$DB_FILE\" || error \"Database $TMP/$DB_FILE could not be deleted.\"\n+\tfi\n+\n+\t# Delete the wiki's SQLite database\n+\trm -f \"$TMP/$DB_FILE\" || error \"Database $TMP/$DB_FILE could not be deleted.\"\n+\trm -f \"$FILES_FOLDER/$DB_FILE\"\n+\trm -rf \"$TMP/$MW_VERSION\"\n+}\ndiff --git a/contrib/mw-to-git/t/test.config b/contrib/mw-to-git/t/test.config\nnew file mode 100644\nindex 0000000..958b37b\n--- /dev/null\n+++ b/contrib/mw-to-git/t/test.config\n@@ -0,0 +1,35 @@\n+# Name of the web server's directory dedicated to the wiki is WIKI_DIR_NAME\n+WIKI_DIR_NAME=wiki\n+\n+# Login and password of the wiki's admin\n+WIKI_ADMIN=WikiAdmin\n+WIKI_PASSW=AdminPass\n+\n+# Address of the web server\n+SERVER_ADDR=localhost\n+\n+# SQLite database of the wiki, named DB_FILE, is located in TMP\n+TMP=/tmp\n+DB_FILE=wikidb.sqlite\n+\n+# If LIGHTTPD is not set to true, the script will use the defaut\n+# web server running in WIKI_DIR_INST.\n+WIKI_DIR_INST=/var/www\n+\n+# If LIGHTTPD is set to true, the script will use Lighttpd to run\n+# the wiki.\n+LIGHTTPD=true\n+\n+# The variables below are useful only if LIGHTTPD is set to true.\n+PORT=1234\n+PHP_DIR=/usr/bin\n+LIGHTTPD_DIR=/usr/sbin\n+WEB=WEB\n+WEB_TMP=$WEB/tmp\n+WEB_WWW=$WEB/www\n+\n+# The variables below are used by the script to install a wiki.\n+# You should not modify these unless you are modifying the script itself.\n+MW_VERSION=mediawiki-1.19.0\n+FILES_FOLDER=install-wiki\n+DB_INSTALL_SCRIPT=db_install.php\n-- \n1.7.10.2.552.gaa3bb87\n"},{"id":"193551","messageId":"1339607025-22725-2-git-send-email-simon.cathebras@ensimag.imag.fr","threadId":"30773","inReplyTo":"1339607025-22725-1-git-send-email-simon.cathebras@ensimag.imag.fr","subject":"[PATCHv5 2/5] Test environment of git-remote-mediawiki","fromName":"Simon Cathebras","fromEmail":"simon.cathebras@ensimag.imag.fr","sentAt":"2012-06-13T17:03:42Z","receivedAt":"2012-06-13T17:03:42Z","isPatch":false,"sender":{"key":"simon.cathebras@ensimag.imag.fr","avatar":"https://avatars.githubusercontent.com/u/1764010?v=4"},"body":"From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n\nIn order to test git-remote-mediawiki, we need a package of functions\nto manage a MediaWiki: edit a page, remove a page, fetch a page,\nfetch all pages on a given wiki.\n\nWe also need functions to compare the content of directories.\n\nThis patch provide these functions in the file\ngit/contrib/mw-to-git/t/test-gitmw-lib.sh and\ngit/contrib/mw-to-git/t/test-gitmw.pl\n\nIn addition, this patch provide Makefiles to execute tests.\nSee README file for more details.\n\nSigned-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>\nSigned-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>\nSigned-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\nSigned-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>\nSigned-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@imag.fr>\n---\n contrib/mw-to-git/Makefile            |  48 ++++++++\n contrib/mw-to-git/t/Makefile          |  27 +++++\n contrib/mw-to-git/t/README            |  33 ++++++\n contrib/mw-to-git/t/test-gitmw-lib.sh | 141 ++++++++++++++++++++++-\n contrib/mw-to-git/t/test-gitmw.pl     | 209 ++++++++++++++++++++++++++++++++++\n 5 files changed, 456 insertions(+), 2 deletions(-)\n create mode 100644 contrib/mw-to-git/Makefile\n create mode 100644 contrib/mw-to-git/t/Makefile\n create mode 100644 contrib/mw-to-git/t/README\n create mode 100755 contrib/mw-to-git/t/test-gitmw.pl\n\ndiff --git a/contrib/mw-to-git/Makefile b/contrib/mw-to-git/Makefile\nnew file mode 100644\nindex 0000000..c9b1795\n--- /dev/null\n+++ b/contrib/mw-to-git/Makefile\n@@ -0,0 +1,48 @@\n+#\n+# Copyright (C) 2012\n+#     Charles Roussel <charles.roussel@ensimag.imag.fr>\n+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>\n+#     Julien Khayat <julien.khayat@ensimag.imag.fr>\n+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n+#     Simon Perrat <simon.perrat@ensimag.imag.fr>\n+#\n+## Build git-remote-mediawiki\n+\n+-include ../../config.mak.autogen\n+-include ../../config.mak\n+\n+ifndef PERL_PATH\n+\tPERL_PATH = /usr/bin/perl\n+endif\n+ifndef gitexecdir\n+\tgitexecdir = $(shell git --exec-path)\n+endif\n+\n+PERL_PATH_SQ = $(subst ','\\'',$(PERL_PATH))\n+gitexecdir_SQ = $(subst ','\\'',$(gitexecdir))\n+SCRIPT = git-remote-mediawiki\n+\n+.PHONY: install help doc test clean\n+\n+help:\n+\t@echo 'This is the help target of the Makefile. Current configuration:'\n+\t@echo '  gitexecdir = $(gitexecdir_SQ)'\n+\t@echo '  PERL_PATH = $(PERL_PATH_SQ)'\n+\t@echo 'Run \"$(MAKE) install\" to install $(SCRIPT) in gitexecdir'\n+\t@echo 'Run \"$(MAKE) test\" to run the testsuite'\n+\n+install:\n+\tsed -e '1s|#!.*/perl|#!$(PERL_PATH_SQ)|' $(SCRIPT) \\\n+            > '$(gitexecdir_SQ)/$(SCRIPT)'\n+\tchmod +x '$(gitexecdir)/$(SCRIPT)'\n+\n+doc:\n+\t@echo 'Sorry, \"make doc\" is not implemented yet for $(SCRIPT)'\n+\n+test:\n+\t$(MAKE) -C t/ test\n+\n+clean:\n+\t$(RM) '$(gitexecdir)/$(SCRIPT)'\n+\t$(MAKE) -C t/ clean\n+\ndiff --git a/contrib/mw-to-git/t/Makefile b/contrib/mw-to-git/t/Makefile\nnew file mode 100644\nindex 0000000..752fd1f\n--- /dev/null\n+++ b/contrib/mw-to-git/t/Makefile\n@@ -0,0 +1,27 @@\n+#\n+# Copyright (C) 2012\n+#     Charles Roussel <charles.roussel@ensimag.imag.fr>\n+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>\n+#     Julien Khayat <julien.khayat@ensimag.imag.fr>\n+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n+#     Simon Perrat <simon.perrat@ensimag.imag.fr>\n+#\n+## Test git-remote-mediawiki\n+\n+-include ../../../config.mak.autogen\n+-include ../../../config.mak\n+\n+T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)\n+\n+.PHONY: help test clean\n+\n+help:\n+\t@echo 'Run \"$(MAKE) test\" to launch test scripts'\n+\t@echo 'Run \"$(MAKE)\" clean to remove trash folders'\n+\n+test:\n+\tfor t in $(T); do \"./$$t\"; done\n+\n+clean:\n+\t$(RM) -r 'trash directory'.*\n+\ndiff --git a/contrib/mw-to-git/t/README b/contrib/mw-to-git/t/README\nnew file mode 100644\nindex 0000000..b68147b\n--- /dev/null\n+++ b/contrib/mw-to-git/t/README\n@@ -0,0 +1,33 @@\n+Tests for Mediawiki-to-Git\n+==========================\n+\n+\n+Installation\n+------------\n+These tests require a mediawiki with admin access to work on; you can install one\n+on localhost/wiki simply by running:\n+\t./install-wiki.sh install\n+Be aware that the tests will flush the wiki database, thus if you own a wiki at\n+this adress, it is strongly advised to configure another name in test-gitmw-lib.sh\n+before running the script.\n+Note that the wiki will be installed in /tmp (this can be configured too), meaning\n+you might have to install it again when you run tests later.\n+\n+\n+Running\n+-------\n+You can run these tests either individually or with make (recommended). Remember\n+to use make clean when you're done. You have access to all options from git core\n+tests.\n+\n+\n+Limitations\n+-------\n+This test environment does not allow you to test the behavior of git-remote-mediawiki\n+for name containing backslashes.\n+\n+t9360: tests git clone.\n+\n+t9361: tests git pull and git push.\n+\n+t9362: tests how UTF-8 special characters are handled.\ndiff --git a/contrib/mw-to-git/t/test-gitmw-lib.sh b/contrib/mw-to-git/t/test-gitmw-lib.sh\nindex a948f0c..36ac654 100755\n--- a/contrib/mw-to-git/t/test-gitmw-lib.sh\n+++ b/contrib/mw-to-git/t/test-gitmw-lib.sh\n@@ -14,14 +14,151 @@\n . ./test.config\n \n export CURR_DIR=$(pwd)\n-export TEST_DIRECTORY=$CURR_DIR/../../../t\n+export TEST_DIRECTORY=\"$CURR_DIR\"/../../../t\n \n-if test $LIGHTTPD = \"false\" ; then\n+if test \"$LIGHTTPD\" = \"false\" ; then\n \tPORT=80\n else\n \tWIKI_DIR_INST=\"$CURR_DIR/$WEB_WWW\"\n fi\n \n+\n+wiki_getpage () {\n+\t\"$CURR_DIR\"/test-gitmw.pl get_page \"$@\"\n+}\n+\n+wiki_delete_page () {\n+\t\"$CURR_DIR\"/test-gitmw.pl delete_page \"$@\"\n+}\n+\n+wiki_editpage () {\n+\t\"$CURR_DIR\"/test-gitmw.pl edit_page \"$@\"\n+}\n+\n+die () {\n+\tdie_with_status 1 \"$@\"\n+}\n+\n+die_with_status () {\n+\tstatus=$1\n+\tshift\n+\techo >&2 \"$*\"\n+\texit \"$status\"\n+}\n+\n+\n+# Check the preconditions to run git-remote-mediawiki's tests\n+test_check_precond () {\n+\tif ! test_have_prereq PERL\n+\tthen\n+\t\tskip_all='skipping gateway git-mw tests, perl not available'\n+\t\ttest_done\n+\tfi\n+\n+\tif [ ! -f \"$GIT_BUILD_DIR\"/git-remote-mediawiki ];\n+\tthen\n+\t\techo \"No remote mediawiki for git found. Copying it in git\"\n+\t\techo \"cp $GIT_BUILD_DIR/contrib/mw-to-git/git-remote-mediawiki $GIT_BUILD_DIR/\"\n+\t\tcp \"$GIT_BUILD_DIR\"/contrib/mw-to-git/git-remote-mediawiki \"$GIT_BUILD_DIR\"\n+\tfi\n+\n+\tif [ ! -d \"$WIKI_DIR_INST/$WIKI_DIR_NAME\" ];\n+\tthen\n+\t\tskip_all='skipping gateway git-mw tests, no mediawiki found'\n+\t\ttest_done\n+\tfi\n+}\n+\n+# test_diff_directories <dir_git> <dir_wiki>\n+#\n+# Compare the contents of directories <dir_git> and <dir_wiki> with diff\n+# and errors if they do not match. The program will\n+# not look into .git in the process.\n+# Warning: the first argument MUST be the directory containing the git data\n+test_diff_directories () {\n+\trm -rf \"$1_tmp\"\n+\tmkdir -p \"$1_tmp\"\n+\tcp \"$1\"/*.mw \"$1_tmp\"\n+\tdiff -r -b \"$1_tmp\" \"$2\"\n+}\n+\n+# $1=<dir>\n+# $2=<N>\n+#\n+# Check that <dir> contains exactly <N> files\n+test_contains_N_files () {\n+\ttest `ls \"$1\" | wc -l` -eq \"$2\";\n+}\n+\n+\n+# wiki_check_content <file_name> <page_name>\n+#\n+# Compares the contents of the file <file_name> and the wiki page\n+# <page_name> and exits with error 1 if they do not match.\n+wiki_check_content () {\n+\tmkdir -p wiki_tmp\n+\twiki_getpage \"$2\" wiki_tmp\n+\t#replacement of forbidden character in file name\n+\tpage_name=$(printf \"%s\\n\" \"$2\" | sed -e \"s/\\//%2F/g\")\n+\n+\tdiff -b \"$1\" wiki_tmp/\"$page_name\".mw\n+\tif test $? -ne 0\n+\tthen\n+\t\trm -rf wiki_tmp\n+\t\terror \"ERROR: file $2 not found on wiki\"\n+\tfi\n+\trm -rf wiki_tmp\n+}\n+\n+# wiki_page_exist <page_name>\n+#\n+# Check the existence of the page <page_name> on the wiki and exits\n+# with error if it is absent from it.\n+wiki_page_exist () {\n+\tmkdir -p wiki_tmp\n+\twiki_getpage \"$1\" wiki_tmp\n+\tpage_name=$(printf \"%s\\n\" \"$1\" | sed \"s/\\//%2F/g\")\n+\tif test -f wiki_tmp/\"$page_name\".mw ; then\n+\t\trm -rf wiki_tmp\n+\telse\n+\t\trm -rf wiki_tmp\n+\t\terror \"test failed: file $1 not found on wiki\"\n+\tfi\n+}\n+\n+# wiki_getallpagename\n+#\n+# Fetch the name of each page on the wiki.\n+wiki_getallpagename () {\n+\t$CURR_DIR/test-gitmw.pl getallpagename\n+}\n+\n+# wiki_getallpagecategory <category>\n+#\n+# Fetch the name of each page belonging to <category> on the wiki.\n+wiki_getallpagecategory () {\n+\t$CURR_DIR/test-gitmw.pl getallpagename \"$@\"\n+}\n+\n+# wiki_getallpage <dest_dir> [<category>]\n+#\n+# Fetch all the pages from the wiki and place them in the directory\n+# <dest_dir>.\n+# If <category> is define, then wiki_getallpage fetch the pages included\n+# in <category>.\n+wiki_getallpage () {\n+\tif test -z \"$2\";\n+\tthen\n+\t\twiki_getallpagename\n+\telse\n+\t\twiki_getallpagecategory \"$2\"\n+\tfi\n+\tmkdir -p \"$1\"\n+\twhile read -r line; do\n+\t\twiki_getpage \"$line\" $1;\n+\tdone < all.txt\n+}\n+\n # ================= Install part =================\n \n error () {\ndiff --git a/contrib/mw-to-git/t/test-gitmw.pl b/contrib/mw-to-git/t/test-gitmw.pl\nnew file mode 100755\nindex 0000000..e6c4adf\n--- /dev/null\n+++ b/contrib/mw-to-git/t/test-gitmw.pl\n@@ -0,0 +1,209 @@\n+#!/usr/bin/perl -w -s\n+# Copyright (C) 2012\n+#     Charles Roussel <charles.roussel@ensimag.imag.fr>\n+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>\n+#     Julien Khayat <julien.khayat@ensimag.imag.fr>\n+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n+#     Simon Perrat <simon.perrat@ensimag.imag.fr>\n+# License: GPL v2 or later\n+\n+# Usage:\n+#       ./test-gitmw.pl <command> [argument]*\n+# Execute in terminal using the name of the function to call as first\n+# parameter, and the function's arguments as following parameters\n+#\n+# Example:\n+#     ./test-gitmw.pl \"get_page\" foo .\n+# will call <wiki_getpage> with arguments <foo> and <.>\n+#\n+# Available functions are:\n+#     \"get_page\"\n+#     \"delete_page\"\n+#     \"edit_page\"\n+#     \"getallpagename\"\n+\n+use MediaWiki::API;\n+use Getopt::Long;\n+use encoding 'utf8';\n+use DateTime::Format::ISO8601;\n+use open ':encoding(utf8)';\n+use constant SLASH_REPLACEMENT => \"%2F\";\n+\n+#Parsing of the config file\n+\n+my $configfile = \"$ENV{'CURR_DIR'}/test.config\";\n+my %config;\n+open my $CONFIG, \"<\",  $configfile or die \"can't open $configfile: $!\";\n+while (<$CONFIG>)\n+{\n+        chomp;\n+        s/#.*//;\n+        s/^\\s+//;\n+        s/\\s+$//;\n+        next unless length;\n+        my ($key, $value) = split (/\\s*=\\s*/,$_, 2);\n+        $config{$key} = $value;\n+\tlast if ($key eq 'LIGHTTPD' and $value eq 'false');\n+\tlast if ($key eq 'PORT');\n+}\n+close $CONFIG or die \"can't close $configfile: $!\";\n+\n+my $wiki_address = \"http://$config{'SERVER_ADDR'}\".\":\".\"$config{'PORT'}\";\n+my $wiki_url = \"$wiki_address/$config{'WIKI_DIR_NAME'}/api.php\";\n+my $wiki_admin = \"$config{'WIKI_ADMIN'}\";\n+my $wiki_admin_pass = \"$config{'WIKI_PASSW'}\";\n+my $mw = MediaWiki::API->new;\n+$mw->{config}->{api_url} = $wiki_url;\n+\n+\n+# wiki_login <name> <password>\n+#\n+# Logs the user with <name> and <password> in the global variable\n+# of the mediawiki $mw\n+sub wiki_login {\n+\t$mw->login( { lgname => \"$_[0]\",lgpassword => \"$_[1]\" } )\n+\t|| die \"getpage: login failed\";\n+}\n+\n+# wiki_getpage <wiki_page> <dest_path>\n+#\n+# fetch a page <wiki_page> from the wiki referenced in the global variable\n+# $mw and copies its content in directory dest_path\n+sub wiki_getpage {\n+\tmy $pagename = $_[0];\n+\tmy $destdir = $_[1];\n+\n+\tmy $page = $mw->get_page( { title => $pagename } );\n+\tif (!defined($page)) {\n+\t\tdie \"getpage: wiki does not exist\";\n+\t}\n+\n+\tmy $content = $page->{'*'};\n+\tif (!defined($content)) {\n+\t\tdie \"getpage: page does not exist\";\n+\t}\n+\n+\t$pagename=$page->{'title'};\n+\t# Replace spaces by underscore in the page name\n+\t$pagename =~ s/ /_/g;\n+\t$pagename =~ s/\\//%2F/g;\n+\topen(my $file, \">$destdir/$pagename.mw\");\n+\tprint $file \"$content\";\n+\tclose ($file);\n+\n+}\n+\n+# wiki_delete_page <page_name>\n+#\n+# delete the page with name <page_name> from the wiki referenced\n+# in the global variable $mw\n+sub wiki_delete_page {\n+\tmy $pagename = $_[0];\n+\n+\tmy $exist=$mw->get_page({title => $pagename});\n+\n+\tif (defined($exist->{'*'})){\n+\t\t$mw->edit({ action => 'delete',\n+\t\t\t\ttitle => $pagename})\n+\t\t|| die $mw->{error}->{code} . \": \" . $mw->{error}->{details};\n+\t} else {\n+\t\tdie \"no page with such name found: $pagename\\n\";\n+\t}\n+}\n+\n+# wiki_editpage <wiki_page> <wiki_content> <wiki_append> [-c=<category>] [-s=<summary>]\n+#\n+# Edit a page named <wiki_page> with content <wiki_content> on the wiki\n+# referenced with the global variable $mw\n+# If <wiki_append> == true : append <wiki_content> at the end of the actual\n+# content of the page <wiki_page>\n+# If <wik_page> doesn't exist, that page is created with the <wiki_content>\n+sub wiki_editpage {\n+\tmy $wiki_page = $_[0];\n+\tmy $wiki_content = $_[1];\n+\tmy $wiki_append = $_[2];\n+\tmy $summary = \"\";\n+\tmy ($summ, $cat) = ();\n+\tGetOptions('s=s' => \\$summ, 'c=s' => \\$cat);\n+\n+\tmy $append = 0;\n+\tif (defined($wiki_append) && $wiki_append eq 'true') {\n+\t\t$append=1;\n+\t}\n+\n+\tmy $previous_text =\"\";\n+\n+\tif ($append) {\n+\t\tmy $ref = $mw->get_page( { title => $wiki_page } );\n+\t\t$previous_text = $ref->{'*'};\n+\t}\n+\n+\tmy $text = $wiki_content;\n+\tif (defined($previous_text)) {\n+\t\t$text=\"$previous_text$text\";\n+\t}\n+\n+\t# Eventually, add this page to a category.\n+\tif (defined($cat)) {\n+\t\tmy $category_name=\"[[Category:$cat]]\";\n+\t\t$text=\"$text\\n $category_name\";\n+\t}\n+\tif(defined($summ)){\n+\t\t$summary=$summ;\n+\t}\n+\n+\t$mw->edit( { action => 'edit', title => $wiki_page, summary => $summary, text => \"$text\"} );\n+}\n+\n+# wiki_getallpagename [<category>]\n+#\n+# Fetch all pages of the wiki referenced by the global variable $mw\n+# and print the names of each one in the file all.txt with a new line\n+# (\"\\n\") between these.\n+# If the argument <category> is defined, then this function get only the pages\n+# belonging to <category>.\n+sub wiki_getallpagename {\n+\t# fetch the pages of the wiki\n+\tif (defined($_[0])) {\n+\t\tmy $mw_pages = $mw->list ( { action => 'query',\n+\t\t\t\tlist => 'categorymembers',\n+\t\t\t\tcmtitle => \"Category:$_[0]\",\n+\t\t\t\tcmnamespace => 0,\n+\t\t\t\tcmlimit=> 500 },\n+\t\t)\n+\t\t|| die $mw->{error}->{code}.\": \".$mw->{error}->{details};\n+\t\topen(my $file, \">all.txt\");\n+\t\tforeach my $page (@{$mw_pages}) {\n+\t\t\tprint $file \"$page->{title}\\n\";\n+\t\t}\n+\t\tclose ($file);\n+\n+\t} else {\n+\t\tmy $mw_pages = $mw->list({\n+\t\t\t\taction => 'query',\n+\t\t\t\tlist => 'allpages',\n+\t\t\t\taplimit => 500,\n+\t\t\t})\n+\t\t|| die $mw->{error}->{code}.\": \".$mw->{error}->{details};\n+\t\topen(my $file, \">all.txt\");\n+\t\tforeach my $page (@{$mw_pages}) {\n+\t\t\tprint $file \"$page->{title}\\n\";\n+\t\t}\n+\t\tclose ($file);\n+\t}\n+}\n+\n+# Main part of this script: parse the command line arguments\n+# and select which function to execute\n+my $fct_to_call = shift;\n+\n+wiki_login($wiki_admin,$wiki_admin_pass);\n+\n+my %functions_to_call = qw(\n+    get_page       wiki_getpage\n+    delete_page    wiki_delete_page\n+    edit_page      wiki_editpage\n+    getallpagename wiki_getallpagename\n+);\n+die \"$0 ERROR: wrong argument\" unless exists $functions_to_call{$fct_to_call};\n+&{$functions_to_call{$fct_to_call}}(@ARGV);\n-- \n1.7.10.2.552.gaa3bb87\n"},{"id":"193552","messageId":"1339607025-22725-3-git-send-email-simon.cathebras@ensimag.imag.fr","threadId":"30773","inReplyTo":"1339607025-22725-1-git-send-email-simon.cathebras@ensimag.imag.fr","subject":"[PATCHv5 3/5] Test file for git-remote-mediawiki clone","fromName":"Simon Cathebras","fromEmail":"simon.cathebras@ensimag.imag.fr","sentAt":"2012-06-13T17:03:43Z","receivedAt":"2012-06-13T17:03:43Z","isPatch":false,"sender":{"key":"simon.cathebras@ensimag.imag.fr","avatar":"https://avatars.githubusercontent.com/u/1764010?v=4"},"body":"From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n\nThis patch provides some tests for the clone in use by\ngit-remote-mediawiki.\n\nSigned-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>\nSigned-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>\nSigned-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\nSigned-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>\nSigned-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@imag.fr>\n---\n contrib/mw-to-git/t/t9360-mw-to-git-clone.sh | 250 +++++++++++++++++++++++++++\n 1 file changed, 250 insertions(+)\n create mode 100755 contrib/mw-to-git/t/t9360-mw-to-git-clone.sh\n\ndiff --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\nnew file mode 100755\nindex 0000000..4ab46f2\n--- /dev/null\n+++ b/contrib/mw-to-git/t/t9360-mw-to-git-clone.sh\n@@ -0,0 +1,250 @@\n+#!/bin/sh\n+#\n+# Copyright (C) 2012\n+#     Charles Roussel <charles.roussel@ensimag.imag.fr>\n+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>\n+#     Julien Khayat <julien.khayat@ensimag.imag.fr>\n+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n+#     Simon Perrat <simon.perrat@ensimag.imag.fr>\n+#\n+# License: GPL v2 or later\n+\n+\n+test_description='Test the Git Mediawiki remote helper: git clone'\n+\n+. ./test-gitmw-lib.sh\n+. $TEST_DIRECTORY/test-lib.sh\n+\n+\n+test_check_precond\n+\n+\n+test_expect_success 'Git clone creates the git log expected with one file' '\n+\twiki_reset &&\n+\twiki_editpage foo \"this is not important\" false -c cat -s \"this must be the same\" &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_1 &&\n+\t(\n+\t\tcd mw_dir_1 &&\n+\t\tgit log --format=%s HEAD^..HEAD >log.tmp\n+\t) &&\n+\techo \"this must be the same\" >msg.tmp &&\n+\tdiff -b mw_dir_1/log.tmp msg.tmp\n+'\n+\n+\n+test_expect_success 'Git clone creates the git log expected with multiple files' '\n+\twiki_reset &&\n+\twiki_editpage daddy \"this is not important\" false -s=\"this must be the same\" &&\n+\twiki_editpage daddy \"neither is this\" true -s=\"this must also be the same\" &&\n+\twiki_editpage daddy \"neither is this\" true -s=\"same same same\" &&\n+\twiki_editpage dj \"dont care\" false -s=\"identical\" &&\n+\twiki_editpage dj \"dont care either\" true -s=\"identical too\" &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_2 &&\n+\t(\n+\t\tcd mw_dir_2 &&\n+\t\tgit log --format=%s Daddy.mw  >logDaddy.tmp &&\n+\t\tgit log --format=%s Dj.mw >logDj.tmp\n+\t) &&\n+\techo \"same same same\" >msgDaddy.tmp &&\n+\techo \"this must also be the same\" >>msgDaddy.tmp &&\n+\techo \"this must be the same\" >>msgDaddy.tmp &&\n+\techo \"identical too\" >msgDj.tmp &&\n+\techo \"identical\" >>msgDj.tmp &&\n+\tdiff -b mw_dir_2/logDaddy.tmp msgDaddy.tmp &&\n+\tdiff -b mw_dir_2/logDj.tmp msgDj.tmp\n+'\n+\n+\n+test_expect_success 'Git clone creates only Main_Page.mw with an empty wiki' '\n+\twiki_reset &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_3 &&\n+\ttest_contains_N_files mw_dir_3 1 &&\n+\ttest -e mw_dir_3/Main_Page.mw\n+'\n+\n+test_expect_success 'Git clone does not fetch a deleted page' '\n+\twiki_reset &&\n+\twiki_editpage foo \"this page must be deleted before the clone\" false &&\n+\twiki_delete_page foo &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_4 &&\n+\ttest_contains_N_files mw_dir_4 1 &&\n+\ttest -e mw_dir_4/Main_Page.mw &&\n+\ttest ! -e mw_dir_4/Foo.mw\n+'\n+\n+test_expect_success 'Git clone works with page added' '\n+\twiki_reset &&\n+\twiki_editpage foo \" I will be cloned\" false &&\n+\twiki_editpage bar \"I will be cloned\" false &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_5 &&\n+\twiki_getallpage ref_page_5 &&\n+\ttest_diff_directories mw_dir_5 ref_page_5 &&\n+\twiki_delete_page foo &&\n+\twiki_delete_page bar\n+'\n+\n+test_expect_success 'Git clone works with an edited page ' '\n+\twiki_reset &&\n+\twiki_editpage foo \"this page will be edited\" \\\n+\t\tfalse -s \"first edition of page foo\"&&\n+\twiki_editpage foo \"this page has been edited and must be on the clone \" true &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_6 &&\n+\ttest -e mw_dir_6/Foo.mw &&\n+\ttest -e mw_dir_6/Main_Page.mw &&\n+\twiki_getallpage mw_dir_6/page_ref_6 &&\n+\ttest_diff_directories mw_dir_6 mw_dir_6/page_ref_6 &&\n+\t(\n+\t\tcd mw_dir_6 &&\n+\t\tgit log --format=%s HEAD^ Foo.mw > ../Foo.log\n+\t) &&\n+\techo \"first edition of page foo\" > FooExpect.log &&\n+\tdiff FooExpect.log Foo.log\n+'\n+\n+\n+test_expect_success 'Git clone works with several pages and some deleted ' '\n+\twiki_reset &&\n+\twiki_editpage foo \"this page will not be deleted\" false &&\n+\twiki_editpage bar \"I must not be erased\" false &&\n+\twiki_editpage namnam \"I will not be there at the end\" false &&\n+\twiki_editpage nyancat \"nyan nyan nyan delete me\" false &&\n+\twiki_delete_page namnam &&\n+\twiki_delete_page nyancat &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_7 &&\n+\ttest -e mw_dir_7/Foo.mw &&\n+\ttest -e mw_dir_7/Bar.mw &&\n+\ttest ! -e mw_dir_7/Namnam.mw &&\n+\ttest ! -e mw_dir_7/Nyancat.mw &&\n+\twiki_getallpage mw_dir_7/page_ref_7 &&\n+\ttest_diff_directories mw_dir_7 mw_dir_7/page_ref_7\n+'\n+\n+\n+test_expect_success 'Git clone works with one specific page cloned ' '\n+\twiki_reset &&\n+\twiki_editpage foo \"I will not be cloned\" false &&\n+\twiki_editpage bar \"Do not clone me\" false &&\n+\twiki_editpage namnam \"I will be cloned :)\" false  -s=\"this log must stay\" &&\n+\twiki_editpage nyancat \"nyan nyan nyan you cant clone me\" false &&\n+\tgit clone -c remote.origin.pages=namnam mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_8 &&\n+\ttest_contains_N_files mw_dir_8 1 &&\n+\ttest -e mw_dir_8/Namnam.mw &&\n+\ttest ! -e mw_dir_8/Main_Page.mw &&\n+\t(\n+\t\tcd mw_dir_8 &&\n+\t\techo \"this log must stay\" >msg.tmp &&\n+\t\tgit log --format=%s >log.tmp &&\n+\t\tdiff -b msg.tmp log.tmp\n+\t) &&\n+\twiki_check_content mw_dir_8/Namnam.mw Namnam\n+'\n+\n+test_expect_success 'Git clone works with multiple specific page cloned ' '\n+\twiki_reset &&\n+\twiki_editpage foo \"I will be there\" false &&\n+\twiki_editpage bar \"I will not disapear\" false &&\n+\twiki_editpage namnam \"I be erased\" false &&\n+\twiki_editpage nyancat \"nyan nyan nyan you will not erase me\" false &&\n+\twiki_delete_page namnam &&\n+\tgit clone -c remote.origin.pages='\"'foo bar nyancat namnam'\"' mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_9 &&\n+\ttest_contains_N_files mw_dir_9 3 &&\n+\ttest ! -e mw_dir_9/Namnam.mw &&\n+\ttest -e mw_dir_9/Foo.mw &&\n+\ttest -e mw_dir_9/Nyancat.mw &&\n+\ttest -e mw_dir_9/Bar.mw &&\n+\twiki_check_content mw_dir_9/Foo.mw Foo &&\n+\twiki_check_content mw_dir_9/Bar.mw Bar &&\n+\twiki_check_content mw_dir_9/Nyancat.mw Nyancat\n+'\n+\n+test_expect_success 'Mediawiki-clone of several specific pages on wiki' '\n+\twiki_reset &&\n+\twiki_editpage foo \"foo 1\" false &&\n+\twiki_editpage bar \"bar 1\" false &&\n+\twiki_editpage dummy \"dummy 1\" false &&\n+\twiki_editpage cloned_1 \"cloned_1 1\" false &&\n+\twiki_editpage cloned_2 \"cloned_2 2\" false &&\n+\twiki_editpage cloned_3 \"cloned_3 3\" false &&\n+\tmkdir -p ref_page_10 &&\n+\twiki_getpage cloned_1 ref_page_10 &&\n+\twiki_getpage cloned_2 ref_page_10 &&\n+\twiki_getpage cloned_3 ref_page_10 &&\n+\tgit clone -c remote.origin.pages=\"cloned_1 cloned_2 cloned_3\" mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_10 &&\n+\ttest_diff_directories mw_dir_10 ref_page_10\n+'\n+\n+test_expect_success 'Git clone works with the shallow option' '\n+\twiki_reset &&\n+\twiki_editpage foo \"1st revision, should be cloned\" false &&\n+\twiki_editpage bar \"1st revision, should be cloned\" false &&\n+\twiki_editpage nyan \"1st revision, should not be cloned\" false &&\n+\twiki_editpage nyan \"2nd revision, should be cloned\" false &&\n+\tgit -c remote.origin.shallow=true clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_11 &&\n+\ttest_contains_N_files mw_dir_11 4 &&\n+\ttest -e mw_dir_11/Nyan.mw &&\n+\ttest -e mw_dir_11/Foo.mw &&\n+\ttest -e mw_dir_11/Bar.mw &&\n+\ttest -e mw_dir_11/Main_Page.mw &&\n+\t(\n+\t\tcd mw_dir_11 &&\n+\t\ttest `git log --oneline Nyan.mw | wc -l` -eq 1 &&\n+\t\ttest `git log --oneline Foo.mw | wc -l` -eq 1 &&\n+\t\ttest `git log --oneline Bar.mw | wc -l` -eq 1 &&\n+\t\ttest `git log --oneline Main_Page.mw | wc -l ` -eq 1\n+\t) &&\n+\twiki_check_content mw_dir_11/Nyan.mw Nyan &&\n+\twiki_check_content mw_dir_11/Foo.mw Foo &&\n+\twiki_check_content mw_dir_11/Bar.mw Bar &&\n+\twiki_check_content mw_dir_11/Main_Page.mw Main_Page\n+'\n+\n+test_expect_success 'Git clone works with the shallow option with a delete page' '\n+\twiki_reset &&\n+\twiki_editpage foo \"1st revision, will be deleted\" false &&\n+\twiki_editpage bar \"1st revision, should be cloned\" false &&\n+\twiki_editpage nyan \"1st revision, should not be cloned\" false &&\n+\twiki_editpage nyan \"2nd revision, should be cloned\" false &&\n+\twiki_delete_page foo &&\n+\tgit -c remote.origin.shallow=true clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_12 &&\n+\ttest_contains_N_files mw_dir_12 3 &&\n+\ttest -e mw_dir_12/Nyan.mw &&\n+\ttest ! -e mw_dir_12/Foo.mw &&\n+\ttest -e mw_dir_12/Bar.mw &&\n+\ttest -e mw_dir_12/Main_Page.mw &&\n+\t(\n+\t\tcd mw_dir_12 &&\n+\t\ttest `git log --oneline Nyan.mw | wc -l` -eq 1 &&\n+\t\ttest `git log --oneline Bar.mw | wc -l` -eq 1 &&\n+\t\ttest `git log --oneline Main_Page.mw | wc -l ` -eq 1\n+\t) &&\n+\twiki_check_content mw_dir_12/Nyan.mw Nyan &&\n+\twiki_check_content mw_dir_12/Bar.mw Bar &&\n+\twiki_check_content mw_dir_12/Main_Page.mw Main_Page\n+'\n+\n+test_expect_success 'Test of fetching a category' '\n+\twiki_reset &&\n+\twiki_editpage Foo \"I will be cloned\" false -c=Category &&\n+\twiki_editpage Bar \"Meet me on the repository\" false -c=Category &&\n+\twiki_editpage Dummy \"I will not come\" false &&\n+\twiki_editpage BarWrong \"I will stay online only\" false -c=NotCategory &&\n+\tgit clone -c remote.origin.categories=\"Category\" mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_13 &&\n+\twiki_getallpage ref_page_13 Category &&\n+\ttest_diff_directories mw_dir_13 ref_page_13\n+'\n+\n+test_expect_success 'Test of resistance to modification of category on wiki for clone' '\n+\twiki_reset &&\n+\twiki_editpage Tobedeleted \"this page will be deleted\" false -c=Catone &&\n+\twiki_editpage Tobeedited \"this page will be modified\" false -c=Catone &&\n+\twiki_editpage Normalone \"this page wont be modified and will be on git\" false -c=Catone &&\n+\twiki_editpage Notconsidered \"this page will not appear on local\" false &&\n+\twiki_editpage Othercategory \"this page will not appear on local\" false -c=Cattwo &&\n+\twiki_editpage Tobeedited \"this page have been modified\" true -c=Catone &&\n+\twiki_delete_page Tobedeleted\n+\tgit clone -c remote.origin.categories=\"Catone\" mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_14 &&\n+\twiki_getallpage ref_page_14 Catone &&\n+\ttest_diff_directories mw_dir_14 ref_page_14\n+'\n+\n+test_done\n-- \n1.7.10.2.552.gaa3bb87\n"},{"id":"193550","messageId":"1339607025-22725-4-git-send-email-simon.cathebras@ensimag.imag.fr","threadId":"30773","inReplyTo":"1339607025-22725-1-git-send-email-simon.cathebras@ensimag.imag.fr","subject":"[PATCHv5 4/5] Tests for git-remote-mediawiki pull and push","fromName":"Simon Cathebras","fromEmail":"simon.cathebras@ensimag.imag.fr","sentAt":"2012-06-13T17:03:44Z","receivedAt":"2012-06-13T17:03:44Z","isPatch":false,"sender":{"key":"simon.cathebras@ensimag.imag.fr","avatar":"https://avatars.githubusercontent.com/u/1764010?v=4"},"body":"From: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n\nThis patch provides a set of tests for the pull and push fonctionnality of\ngit-remote-mediawiki.\n\nSigned-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>\nSigned-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>\nSigned-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\nSigned-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>\nSigned-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@imag.fr>\n---\n contrib/mw-to-git/t/t9361-mw-to-git-push-pull.sh | 167 +++++++++++++++++++++++\n 1 file changed, 167 insertions(+)\n create mode 100755 contrib/mw-to-git/t/t9361-mw-to-git-push-pull.sh\n\ndiff --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\nnew file mode 100755\nindex 0000000..8cef764\n--- /dev/null\n+++ b/contrib/mw-to-git/t/t9361-mw-to-git-push-pull.sh\n@@ -0,0 +1,167 @@\n+#!/bin/sh\n+#\n+# Copyright (C) 2012\n+#     Charles Roussel <charles.roussel@ensimag.imag.fr>\n+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>\n+#     Julien Khayat <julien.khayat@ensimag.imag.fr>\n+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n+#     Simon Perrat <simon.perrat@ensimag.imag.fr>\n+#\n+# License: GPL v2 or later\n+\n+# tests for git-remote-mediawiki\n+\n+test_description='Test the Git Mediawiki remote helper: git push and git pull simple test cases'\n+\n+. ./test-gitmw-lib.sh\n+. $TEST_DIRECTORY/test-lib.sh\n+\n+\n+test_check_precond\n+\n+\n+test_expect_success 'Git pull works after adding a new wiki page' '\n+\twiki_reset &&\n+\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_1 &&\n+\twiki_editpage Foo \"page created after the git clone\" false &&\n+\n+\t(\n+\t\tcd mw_dir_1 &&\n+\t\tgit pull\n+\t) &&\n+\n+\twiki_getallpage ref_page_1 &&\n+\ttest_diff_directories mw_dir_1 ref_page_1\n+'\n+\n+test_expect_success 'Git pull works after editing a wiki page' '\n+\twiki_reset &&\n+\n+\twiki_editpage Foo \"page created before the git clone\" false &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_2 &&\n+\twiki_editpage Foo \"new line added on the wiki\" true &&\n+\n+\t(\n+\t\tcd mw_dir_2 &&\n+\t\tgit pull\n+\t) &&\n+\n+\twiki_getallpage ref_page_2 &&\n+\ttest_diff_directories mw_dir_2 ref_page_2\n+'\n+\n+test_expect_success 'git pull works on conflict handled by auto-merge' '\n+\twiki_reset &&\n+\n+\twiki_editpage Foo \"1 init\n+3\n+5\n+\" false &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_3 &&\n+\n+\twiki_editpage Foo \"1 init\n+2 content added on wiki after clone\n+3\n+5\n+\" false &&\n+\n+\t(\n+\t\tcd mw_dir_3 &&\n+\techo \"1 init\n+3\n+4 content added on git after clone\n+5\n+\" >Foo.mw &&\n+\t\tgit commit -am \"conflicting change on foo\" &&\n+\t\tgit pull &&\n+\t\tgit push\n+\t)\n+'\n+\n+test_expect_success 'Git push works after adding a file .mw' '\n+\twiki_reset &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_4 &&\n+\twiki_getallpage ref_page_4 &&\n+\t(\n+\t\tcd mw_dir_4 &&\n+\t\ttest ! -f Foo.mw &&\n+\t\ttouch Foo.mw &&\n+\t\techo \"hello world\" >>Foo.mw &&\n+\t\tgit add Foo.mw &&\n+\t\tgit commit -m \"Foo\" &&\n+\t\tgit push\n+\t) &&\n+\twiki_getallpage ref_page_4 &&\n+\ttest_diff_directories mw_dir_4 ref_page_4\n+'\n+\n+test_expect_success 'Git push works after editing a file .mw' '\n+\twiki_reset &&\n+\twiki_editpage \"Foo\" \"page created before the git clone\" false &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_5 &&\n+\n+\t(\n+\t\tcd mw_dir_5 &&\n+\t\techo \"new line added in the file Foo.mw\" >>Foo.mw &&\n+\t\tgit commit -am \"edit file Foo.mw\" &&\n+\t\tgit push\n+\t) &&\n+\n+\twiki_getallpage ref_page_5 &&\n+\ttest_diff_directories mw_dir_5 ref_page_5\n+'\n+\n+test_expect_failure 'Git push works after deleting a file' '\n+\twiki_reset &&\n+\twiki_editpage Foo \"wiki page added before git clone\" false &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_6 &&\n+\n+\t(\n+\t\tcd mw_dir_6 &&\n+\t\tgit rm Foo.mw &&\n+\t\tgit commit -am \"page Foo.mw deleted\" &&\n+\t\tgit push\n+\t) &&\n+\n+\ttest ! wiki_page_exist Foo\n+'\n+\n+\n+\n+test_expect_success 'Merge conflict expected and solving it' '\n+\twiki_reset &&\n+\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_7 &&\n+\twiki_editpage Foo \"1 conflict\n+3 wiki\n+4\" false &&\n+\n+\t(\n+\t\tcd mw_dir_7 &&\n+\techo \"1 conflict\n+2 git\n+4\" >Foo.mw &&\n+\t\tgit add Foo.mw &&\n+\t\tgit commit -m \"conflict created\" &&\n+\t\ttest_must_fail git pull &&\n+\t\tperl -pi -e \"s/[<=>].*//g\" Foo.mw &&\n+\t\tgit commit -am \"merge conflict solved\" &&\n+\t\tgit push\n+\t)\n+'\n+\n+test_expect_failure 'git pull works after deleting a wiki page' '\n+\twiki_reset &&\n+\twiki_editpage Foo \"wiki page added before the git clone\" false &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_8 &&\n+\n+\twiki_delete_page Foo &&\n+\t(\n+\t\tcd mw_dir_8 &&\n+\t\tgit pull &&\n+\t\ttest ! -f Foo.mw\n+\t)\n+'\n+\n+test_done\n-- \n1.7.10.2.552.gaa3bb87\n"},{"id":"193553","messageId":"1339607025-22725-5-git-send-email-simon.cathebras@ensimag.imag.fr","threadId":"30773","inReplyTo":"1339607025-22725-1-git-send-email-simon.cathebras@ensimag.imag.fr","subject":"[PATCHv5 5/5] Tests of UTF8 character with git-remote-mediawiki","fromName":"Simon Cathebras","fromEmail":"simon.cathebras@ensimag.imag.fr","sentAt":"2012-06-13T17:03:45Z","receivedAt":"2012-06-13T17:03:45Z","isPatch":false,"sender":{"key":"simon.cathebras@ensimag.imag.fr","avatar":"https://avatars.githubusercontent.com/u/1764010?v=4"},"body":"This patch provides a sample of tests for git-remote-mediawiki's\nresistance, concerning utf8 special characters.\n\nSigned-off-by: Simon Cathebras <simon.cathebras@ensimag.imag.fr>\nSigned-off-by: Simon Perrat <simon.perrat@ensimag.imag.fr>\nSigned-off-by: Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\nSigned-off-by: Charles Roussel <charles.roussel@ensimag.imag.fr>\nSigned-off-by: Julien Khayat <julien.khayat@ensimag.imag.fr>\nSigned-off-by: Matthieu Moy <matthieu.moy@imag.fr>\n---\n contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh | 298 ++++++++++++++++++++++++++++\n 1 file changed, 298 insertions(+)\n create mode 100755 contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh\n\ndiff --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\nnew file mode 100755\nindex 0000000..ee7cc9e\n--- /dev/null\n+++ b/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh\n@@ -0,0 +1,298 @@\n+#!/bin/sh\n+#\n+# Copyright (C) 2012\n+#     Charles Roussel <charles.roussel@ensimag.imag.fr>\n+#     Simon Cathebras <simon.cathebras@ensimag.imag.fr>\n+#     Julien Khayat <julien.khayat@ensimag.imag.fr>\n+#     Guillaume Sasdy <guillaume.sasdy@ensimag.imag.fr>\n+#     Simon Perrat <simon.perrat@ensimag.imag.fr>\n+#\n+# License: GPL v2 or later\n+\n+# tests for git-remote-mediawiki\n+\n+test_description='Test git-mediawiki with special characters in filenames'\n+\n+. ./test-gitmw-lib.sh\n+. $TEST_DIRECTORY/test-lib.sh\n+\n+\n+test_check_precond\n+\n+\n+test_expect_success 'Git clone works for a wiki with accents in the page names' '\n+\twiki_reset &&\n+\twiki_editpage féé \"This page must be délétéd before clone\" false &&\n+\twiki_editpage kèè \"This page must be deleted before clone\" false &&\n+\twiki_editpage hàà \"This page must be deleted before clone\" false &&\n+\twiki_editpage kîî \"This page must be deleted before clone\" false &&\n+\twiki_editpage foo \"This page must be deleted before clone\" false &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_1 &&\n+\twiki_getallpage ref_page_1 &&\n+\ttest_diff_directories mw_dir_1 ref_page_1\n+'\n+\n+\n+test_expect_success 'Git pull works with a wiki with accents in the pages names' '\n+\twiki_reset &&\n+\twiki_editpage kîî \"this page must be cloned\" false &&\n+\twiki_editpage foo \"this page must be cloned\" false &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_2 &&\n+\twiki_editpage éàîôû \"This page must be pulled\" false &&\n+\t(\n+\t\tcd mw_dir_2 &&\n+\t\tgit pull\n+\t) &&\n+\twiki_getallpage ref_page_2 &&\n+\ttest_diff_directories mw_dir_2 ref_page_2\n+'\n+\n+# 3\n+test_expect_success 'Cloning a chosen page works with accents' '\n+\twiki_reset &&\n+\twiki_editpage kîî \"this page must be cloned\" false &&\n+\tgit clone -c remote.origin.pages=kîî mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_3 &&\n+\twiki_check_content mw_dir_3/Kîî.mw Kîî &&\n+\ttest -e mw_dir_3/Kîî.mw &&\n+\trm -rf mw_dir_3\n+'\n+\n+\n+test_expect_success 'The shallow option works with accents' '\n+\twiki_reset &&\n+\twiki_editpage néoà \"1st revision, should not be cloned\" false &&\n+\twiki_editpage néoà \"2nd revision, should be cloned\" false &&\n+\tgit -c remote.origin.shallow=true clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_4 &&\n+\ttest_contains_N_files mw_dir_4 2 &&\n+\ttest -e mw_dir_4/Néoà.mw &&\n+\ttest -e mw_dir_4/Main_Page.mw &&\n+\t(\n+\t\tcd mw_dir_4 &&\n+\t\ttest `git log --oneline Néoà.mw | wc -l` -eq 1 &&\n+\t\ttest `git log --oneline Main_Page.mw | wc -l ` -eq 1\n+\t) &&\n+\twiki_check_content mw_dir_4/Néoà.mw Néoà &&\n+\twiki_check_content mw_dir_4/Main_Page.mw Main_Page\n+'\n+\n+\n+test_expect_success 'Cloning works when page name first letter has an accent' '\n+\twiki_reset &&\n+\twiki_editpage îî \"this page must be cloned\" false &&\n+\tgit clone -c remote.origin.pages=îî mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_5 &&\n+\ttest -e mw_dir_5/Îî.mw &&\n+\twiki_check_content mw_dir_5/Îî.mw Îî\n+'\n+\n+\n+test_expect_success 'Git push works with a wiki with accents' '\n+\twiki_reset &&\n+\twiki_editpage féé \"lots of accents : éèàÖ\" false &&\n+\twiki_editpage foo \"this page must be cloned\" false &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_6 &&\n+\t(\n+\t\tcd mw_dir_6 &&\n+\t\techo \"A wild Pîkächû appears on the wiki\" >Pîkächû.mw &&\n+\t\tgit add Pîkächû.mw &&\n+\t\tgit commit -m \"A new page appears\" &&\n+\t\tgit push\n+\t) &&\n+\twiki_getallpage ref_page_6 &&\n+\ttest_diff_directories mw_dir_6 ref_page_6\n+'\n+\n+test_expect_success 'Git clone works with accentsand spaces' '\n+\twiki_reset &&\n+\twiki_editpage \"é à î\" \"this page must be délété before the clone\" false &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_7 &&\n+\twiki_getallpage ref_page_7 &&\n+\ttest_diff_directories mw_dir_7 ref_page_7\n+'\n+\n+test_expect_success 'character $ in page name (mw -> git)' '\n+\twiki_reset &&\n+\twiki_editpage file_\\$_foo \"expect to be called file_$_foo\" false &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_8 &&\n+\ttest -f mw_dir_8/File_\\$_foo.mw &&\n+\twiki_getallpage ref_page_8 &&\n+\ttest_diff_directories mw_dir_8 ref_page_8\n+'\n+\n+\n+\n+test_expect_success 'character $ in file name (git -> mw) ' '\n+\twiki_reset &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_9 &&\n+\t(\n+\t\tcd mw_dir_9 &&\n+\t\techo \"this file is called File_\\$_foo.mw\" >File_\\$_foo.mw &&\n+\t\tgit add . &&\n+\t\tgit commit -am \"file File_\\$_foo.mw\" &&\n+\t\tgit pull &&\n+\t\tgit push\n+\t) &&\n+\twiki_getallpage ref_page_9 &&\n+\ttest_diff_directories mw_dir_9 ref_page_9\n+'\n+\n+\n+test_expect_failure 'capital at the begining of file names' '\n+\twiki_reset &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_10 &&\n+\t(\n+\t\tcd mw_dir_10 &&\n+\t\techo \"my new file foo\" >foo.mw &&\n+\t\techo \"my new file Foo... Finger crossed\" >Foo.mw &&\n+\t\tgit add . &&\n+\t\tgit commit -am \"file foo.mw\" &&\n+\t\tgit pull &&\n+\t\tgit push\n+\t) &&\n+\twiki_getallpage ref_page_10 &&\n+\ttest_diff_directories mw_dir_10 ref_page_10\n+'\n+\n+\n+test_expect_failure 'special character at the begining of file name from mw to git' '\n+\twiki_reset &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_11 &&\n+\twiki_editpage {char_1 \"expect to be renamed {char_1\" false &&\n+\twiki_editpage [char_2 \"expect to be renamed [char_2\" false &&\n+\t(\n+\t\tcd mw_dir_11 &&\n+\t\tgit pull\n+\t) &&\n+\ttest -f mw_dir_11/{char_1 &&\n+\ttest -f mw_dir_11/[char_2\n+'\n+\n+test_expect_success 'test of correct formating for file name from mw to git' '\n+\twiki_reset &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_12 &&\n+\twiki_editpage char_%_7b_1 \"expect to be renamed char{_1\" false &&\n+\twiki_editpage char_%_5b_2 \"expect to be renamed char{_2\" false &&\n+\t(\n+\t\tcd mw_dir_12 &&\n+\t\tgit pull\n+\t) &&\n+\ttest -f mw_dir_12/Char\\{_1.mw &&\n+\ttest -f mw_dir_12/Char\\[_2.mw &&\n+\twiki_getallpage ref_page_12 &&\n+\tmv ref_page_12/Char_%_7b_1.mw ref_page_12/Char\\{_1.mw &&\n+\tmv ref_page_12/Char_%_5b_2.mw ref_page_12/Char\\[_2.mw &&\n+\ttest_diff_directories mw_dir_12 ref_page_12\n+'\n+\n+\n+test_expect_failure 'test of correct formating for file name begining with special character' '\n+\twiki_reset &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_13 &&\n+\t(\n+\t\tcd mw_dir_13 &&\n+\t\techo \"my new file {char_1\" >\\{char_1.mw &&\n+\t\techo \"my new file [char_2\" >\\[char_2.mw &&\n+\t\tgit add . &&\n+\t\tgit commit -am \"commiting some exotic file name...\" &&\n+\t\tgit push &&\n+\t\tgit pull\n+\t) &&\n+\twiki_getallpage ref_page_13 &&\n+\ttest -f ref_page_13/{char_1.mw &&\n+\ttest -f ref_page_13/[char_2.mw &&\n+\ttest_diff_directories mw_dir_13 ref_page_13\n+'\n+\n+\n+test_expect_success 'test of correct formating for file name from git to mw' '\n+\twiki_reset &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_14 &&\n+\t(\n+\t\tcd mw_dir_14 &&\n+\t\techo \"my new file char{_1\" >Char\\{_1.mw &&\n+\t\techo \"my new file char[_2\" >Char\\[_2.mw &&\n+\t\tgit add . &&\n+\t\tgit commit -m \"commiting some exotic file name...\" &&\n+\t\tgit push\n+\t) &&\n+\twiki_getallpage ref_page_14 &&\n+\tmv mw_dir_14/Char\\{_1.mw mw_dir_14/Char_%_7b_1.mw &&\n+\tmv mw_dir_14/Char\\[_2.mw mw_dir_14/Char_%_5b_2.mw &&\n+\ttest_diff_directories mw_dir_14 ref_page_14\n+'\n+\n+\n+test_expect_success 'git clone with /' '\n+\twiki_reset &&\n+\twiki_editpage \\/fo\\/o \"this is not important\" false -c=Deleted &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_15 &&\n+\ttest -f mw_dir_15/%2Ffo%2Fo.mw &&\n+\twiki_check_content mw_dir_15/%2Ffo%2Fo.mw \\/fo\\/o\n+'\n+\n+\n+test_expect_success 'git push with /' '\n+\twiki_reset &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_16 &&\n+\techo \"I will be on the wiki\" >mw_dir_16/%2Ffo%2Fo.mw &&\n+\t(\n+\t\tcd mw_dir_16 &&\n+\t\tgit add %2Ffo%2Fo.mw &&\n+\t\tgit commit -m \" %2Ffo%2Fo added\" &&\n+\t\tgit push\n+\t) &&\n+\twiki_page_exist \\/fo\\/o &&\n+\twiki_check_content mw_dir_16/%2Ffo%2Fo.mw \\/fo\\/o\n+\n+'\n+\n+\n+test_expect_success 'git clone with \\' '\n+\twiki_reset &&\n+\twiki_editpage \\\\ko\\\\o \"this is not important\" false -c=Deleted &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_17 &&\n+\ttest -f mw_dir_17/\\\\ko\\\\o.mw &&\n+\twiki_check_content mw_dir_17/\\\\ko\\\\o.mw \\\\ko\\\\o\n+'\n+\n+\n+test_expect_success 'git push with \\' '\n+\twiki_reset &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_18 &&\n+\techo \"I will be on the wiki\" >mw_dir_18/\\\\ko\\\\o.mw &&\n+\t(\n+\t\tcd mw_dir_18 &&\n+\t\tgit add \\\\ko\\\\o.mw &&\n+\t\tgit commit -m \" \\\\ko\\\\o added\" &&\n+\t\tgit push\n+\t)&&\n+\twiki_page_exist \\\\ko\\\\o &&\n+\twiki_check_content mw_dir_18/\\\\ko\\\\o.mw \\\\ko\\\\o\n+\n+'\n+\n+test_expect_success 'git clone with \\ in format control' '\n+\twiki_reset &&\n+\twiki_editpage \\\\no\\\\o \"this is not important\" false &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_19 &&\n+\ttest -f mw_dir_19/\\\\no\\\\o.mw &&\n+\twiki_check_content mw_dir_19/\\\\no\\\\o.mw \\\\no\\\\o\n+'\n+\n+\n+test_expect_success 'git push with \\ in format control' '\n+\twiki_reset &&\n+\tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_20 &&\n+\techo \"I will be on the wiki\" >mw_dir_20/\\\\fo\\\\o.mw &&\n+\t(\n+\t\tcd mw_dir_20 &&\n+\t\tgit add \\\\fo\\\\o.mw &&\n+\t\tgit commit -m \" \\\\fo\\\\o added\" &&\n+\t\tgit push\n+\t)&&\n+\twiki_page_exist \\\\fo\\\\o &&\n+\twiki_check_content mw_dir_20/\\\\fo\\\\o.mw \\\\fo\\\\o\n+\n+'\n+\n+\n+test_done\n-- \n1.7.10.2.552.gaa3bb87\n"},{"id":"193630","messageId":"1339664243-31952-1-git-send-email-Matthieu.Moy@imag.fr","threadId":"30773","inReplyTo":"1339607025-22725-1-git-send-email-simon.cathebras@ensimag.imag.fr","subject":"Re: [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2012-06-14T08:57:20Z","receivedAt":"2012-06-14T08:57:20Z","isPatch":false,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"The script didn't work for me. I first applied the patches below\n(essentially style, but also a clearer error message). I get:\n\n$ ./install-wiki.sh install\nInstance already running. Restarting...                                                 \nkill: 45: No such process\n\n2012-06-14 10:53:21: (log.c.166) server started \nmediawiki-1.19.0.tar.gz downloaded in /tmp. You can delete it later if you want.\nGenerating the SQLite database file. It can take some time ...\nCould not get page: http://localhost:1234/wiki/mw-config/index.php\nCan't create database file in TODO. Try to run ./install-wiki.sh delete first.\n\nIndeed:\n\n$ ps -u moy | grep light\n$ telnet localhost 1234 \nTrying 127.0.0.1...\ntelnet: Unable to connect to remote host: Connection refused\n\nMatthieu Moy (3):\n  chmod -x test-gitmw-lib.sh\n  Coding style\n  Explicit error when curl_exec() fails\n\n contrib/mw-to-git/t/install-wiki/db_install.php | 11 ++++++-----\n 1 file changed, 6 insertions(+), 5 deletions(-)\n mode change 100755 => 100644 contrib/mw-to-git/t/test-gitmw-lib.sh\n\n-- \n1.7.11.rc0.57.g84a04c7\n"},{"id":"193627","messageId":"1339664243-31952-2-git-send-email-Matthieu.Moy@imag.fr","threadId":"30773","inReplyTo":"1339664243-31952-1-git-send-email-Matthieu.Moy@imag.fr","subject":"[PATCH 1/3] chmod -x test-gitmw-lib.sh","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2012-06-14T08:57:21Z","receivedAt":"2012-06-14T08:57:21Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"\nSigned-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\n 0 files changed\n mode change 100755 => 100644 contrib/mw-to-git/t/test-gitmw-lib.sh\n\ndiff --git a/contrib/mw-to-git/t/test-gitmw-lib.sh b/contrib/mw-to-git/t/test-gitmw-lib.sh\nold mode 100755\nnew mode 100644\n-- \n1.7.11.rc0.57.g84a04c7\n"},{"id":"193629","messageId":"1339664243-31952-3-git-send-email-Matthieu.Moy@imag.fr","threadId":"30773","inReplyTo":"1339664243-31952-1-git-send-email-Matthieu.Moy@imag.fr","subject":"[PATCH 2/3] Coding style","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2012-06-14T08:57:22Z","receivedAt":"2012-06-14T08:57:22Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"\nSigned-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\n contrib/mw-to-git/t/install-wiki/db_install.php | 8 +++-----\n 1 file changed, 3 insertions(+), 5 deletions(-)\n\ndiff --git a/contrib/mw-to-git/t/install-wiki/db_install.php b/contrib/mw-to-git/t/install-wiki/db_install.php\nindex 3111c73..b34772a 100644\n--- a/contrib/mw-to-git/t/install-wiki/db_install.php\n+++ b/contrib/mw-to-git/t/install-wiki/db_install.php\n@@ -10,7 +10,6 @@\n  * In order to generate a SQLite database file, MediaWiki ask the user\n  * to submit some forms in its web browser. This script simulates this\n  * behavior though the functions <get> and <submit>\n- *\n  */\n $argc = $_SERVER['argc'];\n $argv = $_SERVER['argv'];\n@@ -22,7 +21,7 @@ $port = $argv[5];\n \n $url = 'http://localhost:'.$port.'/wiki/mw-config/index.php';\n $db_dir = urlencode($tmp);\n-$tmp_cookie = tempnam($tmp,\"COOKIE_\");\n+$tmp_cookie = tempnam($tmp, \"COOKIE_\");\n /*\n  * Fetchs a page with cURL.\n  */\n@@ -33,13 +32,13 @@ function get ($page_name = \"\") {\n                 $page_name_add = '?page='.$page_name;\n         }\n \t$url = $GLOBALS['url'].$page_name_add;\n-        $tmp_cookie=$GLOBALS['tmp_cookie'];\n+        $tmp_cookie = $GLOBALS['tmp_cookie'];\n         curl_setopt($curl, CURLOPT_COOKIEJAR, $tmp_cookie);\n         curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);\n         curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);\n         curl_setopt($curl, CURLOPT_COOKIEFILE, $tmp_cookie);\n         curl_setopt($curl, CURLOPT_HEADER, true);\n-        curl_setopt($curl, CURLOPT_URL,$url);\n+        curl_setopt($curl, CURLOPT_URL, $url);\n \n         $page = curl_exec($curl);\n         curl_close($curl);\n@@ -75,7 +74,6 @@ function submit($page_name, $option = \"\") {\n  * submitting forms to generates the database file.\n  * Note this simulation was made for the MediaWiki version 1.19.0,\n  * we can't assume it works with other versions.\n- *\n  */\n \n $page = get();\n-- \n1.7.11.rc0.57.g84a04c7\n"},{"id":"193628","messageId":"1339664243-31952-4-git-send-email-Matthieu.Moy@imag.fr","threadId":"30773","inReplyTo":"1339664243-31952-1-git-send-email-Matthieu.Moy@imag.fr","subject":"[PATCH 3/3] Explicit error when curl_exec() fails","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2012-06-14T08:57:23Z","receivedAt":"2012-06-14T08:57:23Z","isPatch":true,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"\nSigned-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>\n---\n contrib/mw-to-git/t/install-wiki/db_install.php | 3 +++\n 1 file changed, 3 insertions(+)\n\ndiff --git a/contrib/mw-to-git/t/install-wiki/db_install.php b/contrib/mw-to-git/t/install-wiki/db_install.php\nindex b34772a..99d24e0 100644\n--- a/contrib/mw-to-git/t/install-wiki/db_install.php\n+++ b/contrib/mw-to-git/t/install-wiki/db_install.php\n@@ -41,6 +41,9 @@ function get ($page_name = \"\") {\n         curl_setopt($curl, CURLOPT_URL, $url);\n \n         $page = curl_exec($curl);\n+\tif (!$page) {\n+\t\tdie (\"Could not get page: $url\\n\");\n+\t}\n         curl_close($curl);\n         return $page;\n }\n-- \n1.7.11.rc0.57.g84a04c7\n"},{"id":"193631","messageId":"vpqlijqb780.fsf@bauges.imag.fr","threadId":"30773","inReplyTo":"1339607025-22725-1-git-send-email-simon.cathebras@ensimag.imag.fr","subject":"Re: [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2012-06-14T08:58:23Z","receivedAt":"2012-06-14T08:58:23Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Simon Cathebras <simon.cathebras@ensimag.imag.fr> writes:\n\n> +function get ($page_name = \"\") {\n> +        $curl = curl_init();\n> +        $page_name_add = \"\";\n> +        if ($page_name != \"\") {\n> +                $page_name_add = '?page='.$page_name;\n> +        }\n> +\t$url = $GLOBALS['url'].$page_name_add;\n> +        $tmp_cookie=$GLOBALS['tmp_cookie'];\n> +        curl_setopt($curl, CURLOPT_COOKIEJAR, $tmp_cookie);\n> +        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);\n> +        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);\n> +        curl_setopt($curl, CURLOPT_COOKIEFILE, $tmp_cookie);\n> +        curl_setopt($curl, CURLOPT_HEADER, true);\n> +        curl_setopt($curl, CURLOPT_URL,$url);\n> +\n> +        $page = curl_exec($curl);\n> +        curl_close($curl);\n> +        return $page;\n> +}\n\nMixed tab/space indentation.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"193634","messageId":"4FD9ACC6.50307@ensimag.imag.fr","threadId":"30773","inReplyTo":"1339664243-31952-1-git-send-email-Matthieu.Moy@imag.fr","subject":"Re: [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki","fromName":"Simon.Cathebras","fromEmail":"simon.cathebras@ensimag.imag.fr","sentAt":"2012-06-14T09:20:06Z","receivedAt":"2012-06-14T09:20:06Z","isPatch":false,"sender":{"key":"simon.cathebras@ensimag.imag.fr","avatar":"https://avatars.githubusercontent.com/u/1764010?v=4"},"body":"\n\nOn 14/06/2012 10:57, Matthieu Moy wrote:\n> The script didn't work for me. I first applied the patches below\n> (essentially style, but also a clearer error message). I get:\n>\n> $ ./install-wiki.sh install\n> Instance already running. Restarting...\n> kill: 45: No such process\n>\n> 2012-06-14 10:53:21: (log.c.166) server started\n> mediawiki-1.19.0.tar.gz downloaded in /tmp. You can delete it later if you want.\n> Generating the SQLite database file. It can take some time ...\n> Could not get page: http://localhost:1234/wiki/mw-config/index.php\n> Can't create database file in TODO. Try to run ./install-wiki.sh delete first.\n>\n> Indeed:\n>\n> $ ps -u moy | grep light\n> $ telnet localhost 1234\n> Trying 127.0.0.1...\n> telnet: Unable to connect to remote host: Connection refused\n\nAppears to be a local problem. Did you managed to run the script when \nthis was fixed ?\n\nAnyway, please check out with the following wiki page if you have all \nrequired package.\n\nurl: https://github.com/Fafinou/git/wiki\n\n> Matthieu Moy (3):\n>    chmod -x test-gitmw-lib.sh\n>    Coding style\n>    Explicit error when curl_exec() fails\n>\n>   contrib/mw-to-git/t/install-wiki/db_install.php | 11 ++++++-----\n>   1 file changed, 6 insertions(+), 5 deletions(-)\n>   mode change 100755 =>  100644 contrib/mw-to-git/t/test-gitmw-lib.sh\n>\n\n-- \nCATHEBRAS Simon\n\n2A-ENSIMAG\n\nFilière Ingéniérie des Systèmes d'Information\nMembre Bug-Buster\n"},{"id":"193635","messageId":"4FD9AD9F.5050708@ensimag.imag.fr","threadId":"30773","inReplyTo":"1339664243-31952-4-git-send-email-Matthieu.Moy@imag.fr","subject":"Re: [PATCH 3/3] Explicit error when curl_exec() fails","fromName":"Simon.Cathebras","fromEmail":"simon.cathebras@ensimag.imag.fr","sentAt":"2012-06-14T09:23:43Z","receivedAt":"2012-06-14T09:23:43Z","isPatch":true,"sender":{"key":"simon.cathebras@ensimag.imag.fr","avatar":"https://avatars.githubusercontent.com/u/1764010?v=4"},"body":"\n\nOn 14/06/2012 10:57, Matthieu Moy wrote:\n> Signed-off-by: Matthieu Moy<Matthieu.Moy@imag.fr>\n> ---\n>   contrib/mw-to-git/t/install-wiki/db_install.php | 3 +++\n>   1 file changed, 3 insertions(+)\n>\n> diff --git a/contrib/mw-to-git/t/install-wiki/db_install.php b/contrib/mw-to-git/t/install-wiki/db_install.php\n> index b34772a..99d24e0 100644\n> --- a/contrib/mw-to-git/t/install-wiki/db_install.php\n> +++ b/contrib/mw-to-git/t/install-wiki/db_install.php\n> @@ -41,6 +41,9 @@ function get ($page_name = \"\") {\n>           curl_setopt($curl, CURLOPT_URL, $url);\n>\n>           $page = curl_exec($curl);\n> +\tif (!$page) {\n> +\t\tdie (\"Could not get page: $url\\n\");\n> +\t}\n>           curl_close($curl);\n>           return $page;\n>   }\nSeems legitimate.\n\nBut there is a whitespace/indentation problem isn't it ?\n\n-- \nCATHEBRAS Simon\n\n2A-ENSIMAG\n\nFilière Ingéniérie des Systèmes d'Information\nMembre Bug-Buster\n"},{"id":"193650","messageId":"vpq7gvaawot.fsf@bauges.imag.fr","threadId":"30773","inReplyTo":"4FD9AD9F.5050708@ensimag.imag.fr","subject":"Re: [PATCH 3/3] Explicit error when curl_exec() fails","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2012-06-14T12:45:54Z","receivedAt":"2012-06-14T12:45:54Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"\"Simon.Cathebras\" <Simon.Cathebras@ensimag.imag.fr> writes:\n\n> But there is a whitespace/indentation problem isn't it ?\n\nYes: your code is indented with spaces.\n\n(my code has an extra space between die and \"(\" that said)\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"193657","messageId":"vpqbokl6f6k.fsf@bauges.imag.fr","threadId":"30773","inReplyTo":"4FD9ACC6.50307@ensimag.imag.fr","subject":"Re: [PATCHv5 1/5] Scripts to install, delete and clear a MediaWiki","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2012-06-14T16:17:39Z","receivedAt":"2012-06-14T16:17:39Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"\"Simon.Cathebras\" <Simon.Cathebras@ensimag.imag.fr> writes:\n\n> Appears to be a local problem. Did you managed to run the script when\n> this was fixed ?\n>\n> Anyway, please check out with the following wiki page if you have all\n> required package.\n\nIndeed, installing php5-cgi did it. I can now run the testsuite. But\nthat would have been nice to get explicit error messages about this.\n\n> url: https://github.com/Fafinou/git/wiki\n\nThis documentation should actually appear in the README file of your\ntest environment. Wikis are nice to work collaboratively on a draft, but\nthis kind of doc should really end up as close to the code as possible\n(currently, the code doesn't give a way to find the page above ...).\n\nWhile testing/reviewing, I fixed a few more issues (patch below).\n\nOne thing I wanted to do was to let \"install-wiki.sh\" be launched from\nany directory, like \"./t/install-wiki.sh install\", but it's still not\nthere, there are relative paths here and there that break it. Maybe we\nshould just run cd \"$WIKI_TEST_DIR\" at the top. Or error out asking the\nuser to cd himself.\n\nFrom 084babd650376437d0fb4697d680d3c325316b7c Mon Sep 17 00:00:00 2001\nFrom: Matthieu Moy <Matthieu.Moy@imag.fr>\nDate: Thu, 14 Jun 2012 18:13:20 +0200\nSubject: [PATCH] More fixups\n\n---\n contrib/mw-to-git/t/Makefile                |  7 +++++--\n contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh |  8 ++++----\n contrib/mw-to-git/t/test-gitmw-lib.sh       | 20 +++++++++++---------\n 3 files changed, 20 insertions(+), 15 deletions(-)\n\ndiff --git a/contrib/mw-to-git/t/Makefile b/contrib/mw-to-git/t/Makefile\nindex 752fd1f..0212b85 100644\n--- a/contrib/mw-to-git/t/Makefile\n+++ b/contrib/mw-to-git/t/Makefile\n@@ -17,10 +17,13 @@ T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)\n \n help:\n \t@echo 'Run \"$(MAKE) test\" to launch test scripts'\n-\t@echo 'Run \"$(MAKE)\" clean to remove trash folders'\n+\t@echo 'Run \"$(MAKE) clean\" to remove trash folders'\n \n test:\n-\tfor t in $(T); do \"./$$t\"; done\n+\t@for t in $(T); do \\\n+\t\techo \"$$t\"; \\\n+\t\t\"./$$t\" || { echo \"$$t failed\"; exit 1; } \\\n+\tdone\n \n clean:\n \t$(RM) -r 'trash directory'.*\ndiff --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\nindex ee7cc9e..0add2d5 100755\n--- a/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh\n+++ b/contrib/mw-to-git/t/t9362-mw-to-git-utf8.sh\n@@ -101,7 +101,7 @@ test_expect_success 'Git push works with a wiki with accents' '\n \ttest_diff_directories mw_dir_6 ref_page_6\n '\n \n-test_expect_success 'Git clone works with accentsand spaces' '\n+test_expect_success 'Git clone works with accents and spaces' '\n \twiki_reset &&\n \twiki_editpage \"é à î\" \"this page must be délété before the clone\" false &&\n \tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_7 &&\n@@ -166,7 +166,7 @@ test_expect_failure 'special character at the begining of file name from mw to g\n \ttest -f mw_dir_11/[char_2\n '\n \n-test_expect_success 'test of correct formating for file name from mw to git' '\n+test_expect_success 'correct formating for file name from mw to git' '\n \twiki_reset &&\n \tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_12 &&\n \twiki_editpage char_%_7b_1 \"expect to be renamed char{_1\" false &&\n@@ -184,7 +184,7 @@ test_expect_success 'test of correct formating for file name from mw to git' '\n '\n \n \n-test_expect_failure 'test of correct formating for file name begining with special character' '\n+test_expect_failure 'correct formating for file name begining with special character' '\n \twiki_reset &&\n \tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_13 &&\n \t(\n@@ -203,7 +203,7 @@ test_expect_failure 'test of correct formating for file name begining with speci\n '\n \n \n-test_expect_success 'test of correct formating for file name from git to mw' '\n+test_expect_success 'correct formating for file name from git to mw' '\n \twiki_reset &&\n \tgit clone mediawiki::http://'\"$SERVER_ADDR:$PORT/$WIKI_DIR_NAME\"' mw_dir_14 &&\n \t(\ndiff --git a/contrib/mw-to-git/t/test-gitmw-lib.sh b/contrib/mw-to-git/t/test-gitmw-lib.sh\nindex 36ac654..f444d1f 100644\n--- a/contrib/mw-to-git/t/test-gitmw-lib.sh\n+++ b/contrib/mw-to-git/t/test-gitmw-lib.sh\n@@ -10,8 +10,12 @@\n # CONFIGURATION VARIABLES\n # You might want to change these ones\n #\n+if test -z \"$WIKI_TEST_DIR\"\n+then\n+\tWIKI_TEST_DIR=.\n+fi\n \n-. ./test.config\n+. \"$WIKI_TEST_DIR\"/test.config\n \n export CURR_DIR=$(pwd)\n export TEST_DIRECTORY=\"$CURR_DIR\"/../../../t\n@@ -87,7 +91,7 @@ test_diff_directories () {\n #\n # Check that <dir> contains exactly <N> files\n test_contains_N_files () {\n-\ttest `ls \"$1\" | wc -l` -eq \"$2\";\n+\ttest `ls -- \"$1\" | wc -l` -eq \"$2\"\n }\n \n \n@@ -101,8 +105,7 @@ wiki_check_content () {\n \t#replacement of forbidden character in file name\n \tpage_name=$(printf \"%s\\n\" \"$2\" | sed -e \"s/\\//%2F/g\")\n \n-\tdiff -b \"$1\" wiki_tmp/\"$page_name\".mw\n-\tif test $? -ne 0\n+\tif ! diff -b \"$1\" wiki_tmp/\"$page_name\".mw\n \tthen\n \t\trm -rf wiki_tmp\n \t\terror \"ERROR: file $2 not found on wiki\"\n@@ -268,9 +271,9 @@ start_lighttpd() {\n \t\tstop_lighttpd\n \tfi\n \tconfig_lighttpd\n-\t$LIGHTTPD_DIR/lighttpd -f $WEB/lighttpd.conf\n-\n-\tif test $? -ne 0 ; then\n+\t\n+\tif ! $LIGHTTPD_DIR/lighttpd -f $WEB/lighttpd.conf\n+\tthen\n \t\techo \"Could not execute http deamon lighttpd\"\n \t\texit 1\n \tfi\n@@ -280,9 +283,8 @@ start_lighttpd() {\n #\n # Kill daemon lighttpd and removes files and folders associated.\n stop_lighttpd () {\n-\n \ttest -f \"$WEB_TMP/pid\" && kill $(cat \"$WEB_TMP/pid\")\n-\trm -rf $WEB\n+\trm -rf \"$WEB\"\n }\n \n # Create the SQLite database of the MediaWiki. If the database file already\n-- \n1.7.11.rc0.57.g84a04c7\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"}]}