Test environment for Git-MediaWiki
Hello all,
We are developing the test environment for the Git-MediaWiki project. For now, we have focused mainly on the environment with some simple test cases.
In this version, we have developed a script to install and delete a MediaWiki wiki easily.
The environment provides shell functions to manage a wiki (fetch, delete, edit a page, compare the content of a page) and a git-mediawiki () repository. There are two simple test cases for git clone.
You can find all the code in our Github: https://github.com/Fafinou/git/wiki and how to install and run the tests.
We would like you to give us a lot of comments about our code :)
Note
* In this version we have a binary file "wikidb.sqlite" which contains an empty SQLite3 database. We know this is not a good thing to put a binary file in a repository so we will change this bad behavior later (we will generate the "wikidb.sqlite" file with a http request to the config page of MediaWiki)
* We will add simple test cases for pull and push the soonest
Thanks you in advance for your time ;)
Signature · 6 lines
CATHEBRAS Simon 2A-ENSIMAG Filière Ingéniérie des Systèmes d'Information Membre Bug-Buster
PATCH 1/3 Script to install, delete and clear a MediaWiki
From: Charles Roussel <[email protected]>
install_wiki.sh expects the first argument to be 'install' or 'delete' 'install' installs a MediaWiki on the web's server with SQLite3 'delete' deletes the previously created wiki. Note those functionnalities are made to be used from the user command line in the directory /t
install_wiki also defines a function cmd_reset which clear all content of the previously created wiki. Note this functionnality is made to be used only by our test function in a subdirectory of t/
--- t/install-wiki.sh | 38 ++++++++++ t/install-wiki/LocalSettings.php | 129 ++++++++++++++++++++++++++++++++++ t/install-wiki/wikidb.sqlite | Bin 0 -> 210944 bytes t/test-gitmw-lib.sh | 147 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 314 insertions(+) create mode 100755 t/install-wiki.sh create mode 100644 t/install-wiki/LocalSettings.php create mode 100644 t/install-wiki/wikidb.sqlite create mode 100755 t/test-gitmw-lib.sh mode change 100644 => 100755 t/test-lib-functions.sh mode change 100644 => 100755 t/test-lib.sh
t/install-wiki.sh new file +38 -0
@@ -0,0 +1,38 @@ +#!/bin/sh + +# This script installs or deletes a MediaWiki on your computer. +# It requires a web server with PHP and SQLite running. In addition, if you +# do not have MediaWiki sources on your computer, the option 'install' +# downloads them for you. +# Please set the CONFIGURATION VARIABLES in ./test-gitmw-lib.sh + +. ./test-gitmw-lib.sh + +usage () { + echo "Usage: " + echo " ./install-wiki.sh <install|delete|--help|-h>" + echo " install: Install a wiki on your computer." + echo " delete: Delete the wiki and all its pages and content" +} + + +# Argument: install, delete, --help | -h +case "$1" in + "install") + cmd_install + exit 0 + ;; + "delete") + cmd_delete + exit 0 + ;; + "--help" | "-h") + usage + exit 0 + ;; + *) + usage + exit 0 + ;; +esac +
t/install-wiki/LocalSettings.php new file +129 -0
129 lines not on this page · raw message
t/install-wiki/wikidb.sqlite new file binary +0 -0
t/test-gitmw-lib.sh new file +147 -0
147 lines not on this page · raw message
t/test-lib-functions.sh +0 -0
t/test-lib.sh +0 -0
Signature · 1 line
1.7.10.2.552.gaa3bb87
PATCH 2/3 Test environment of git-remote-mw
From: Charles Roussel <[email protected]>
In order to test git-remote-mediawiki, we need a package of functions to manage a MediaWiki: edit a page, remove a page, fetch a page, fetch all pages on a given wiki.
We also need functions to compare the content of directories.
--- t/test-gitmw-lib.sh | 125 ++++++++++++++++++++++++++++++++++++--- t/test-gitmw.pl | 164 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 281 insertions(+), 8 deletions(-) create mode 100755 t/test-gitmw.pl
t/test-gitmw-lib.sh +117 -8
@@ -1,27 +1,136 @@ +# Copyright (C) 2012 +# Charles Roussel <[email protected]> +# Simon Cathebras <[email protected]> +# Julien Khayat <[email protected]> +# Guillaume Sasdy <[email protected]> +# Simon Perrat <[email protected]> +# Matthieu Moy <[email protected]> +# License: GPL v2 or later + # # CONFIGURATION VARIABLES -# You might want to change those ones ... +# You might want to change these ones # WIKI_DIR_NAME="wiki" # Name of the wiki's directory WIKI_DIR_INST="/var/www" # Directory of the web server TMP="/tmp" # Temporary directory for downloads - # Absolute address needed! + # Absolute path required! SERVER_ADDR="localhost" # Web server's address -# # CONFIGURATION -# You should not change those ones unless you know what you to +# You should not change these ones unless you know what you do # -# Do not change the variables below MW_VERSION="mediawiki-1.19.0" DB_FILE="wikidb.sqlite" FILES_FOLDER="install-wiki" WIKI_ADMIN="WikiAdmin" WIKI_PASSW="AdminPass" -fail () { - echo "$1" - exit 1 +# wiki_getpage <page_name> <dest_path> +# +# Fetch a page <page_name> from the wiki and copy its content +# into directory <dest_path>. +wiki_getpage () { + ../test-gitmw.pl "get_page" -p "$1" "$2" +} + +# wiki_delete_page <page_name> +# +# Delete the page <page_name> on the wiki. +wiki_delete_page () { + ../test-gitmw.pl "delete_page" -p "$1" +} + +# wiki_edit_page <page_name> <page_content> <page_append> +# +# Edit a page <wiki_page> on the wiki with content <wiki_content> +# If <wiki_append> == true the content will be appended +# If the page doesn't exist, it is created. +wiki_editpage () { + ../test-gitmw.pl "edit_page" -p "$1" "$2" "$3" +} + +# git_content <dir_1> <dir_2> +# +# Compare the contents of directories <dir_1> and <dir_2> with diff +# and exits with error 1 if they do not match. The program will +# not look into .git in the process. +git_content () { + result=$(diff -r -B -w --exclude=".git" "$1" "$2") + + if echo $result | grep -q ">" ; then + echo "test failed: files $1 and $2 do not match" + exit 1 + fi +} + +# git_exist <rep_name> <file_name> +# +# Check the existence of <file_name> into the git repository +# <rep_name> and exits with error 1 if it is absent. +git_exist () { + result=$(find "$1" -type f -name "$2") + + if ! echo $result | grep -q "$2" ; then + echo "test failed: file $2 does not exist in $1" + exit 1 + fi +} + +# wiki_page_content <file_name> <page_name> +# +# Compares the contents of the file <file_name> and the wiki page +# <page_name> and exits with error 1 if they do not match. +wiki_page_content () { + wiki_getpage "$2" . + + if test -f "$2".mw ; then + git_content "$1" "$2".mw + rm "$2".mw + else + die "ERROR: file $2 not found on wiki" + fi +} + +# wiki_page_exist <page_name> +# +# Check the existence of the page <page_name> on the wiki and exits +# with error if it is absent from it. +wiki_page_exist () { + wiki_getpage "$1" . + + if test -f "$1".mw ; then + echo "test failed: file $1 not found on wiki" + exit 1 + else + rm "$1".mw + fi +} + +# wiki_getallpagename +# +# Fetch the name of each page on the wiki. +wiki_getallpagename () { + ../test-gitmw.pl "getallpagename" -p +} + +# wiki_getallpage <dest_dir> +# +# Fetch all the pages from the wiki and place them in the directory +# <dest_dir>. +wiki_getallpage () { + wiki_getallpagename + mkdir $1 + while read -r line; do + wiki_getpage "$line" $1; + done < all.txt + #rm all.txt +} + +fail() +{ + echo $1 + exit 1 }
t/test-gitmw.pl new file +164 -0
164 lines not on this page · raw message
Signature · 1 line
1.7.10.2.552.gaa3bb87
Re: [PATCH 2/3] Test environment of git-remote-mw
t/test-gitmw-lib.sh line 9
Quoted 13 lines · Simon Cathebras
index 2deead7..8698625 100755
t/test-gitmw-lib.sh +9
-0@@ -1,27 +1,136 @@ +# Copyright (C) 2012 +# Charles Roussel <[email protected]> +# Simon Cathebras <[email protected]> +# Julien Khayat <[email protected]> +# Guillaume Sasdy <[email protected]> +# Simon Perrat <[email protected]> +# Matthieu Moy <[email protected]> +# License: GPL v2 or later +
Why is this added by [PATCH 2/3]?
Quoted 4 lines
t/test-gitmw-lib.sh +1
-1-# You might want to change those ones ... +# You might want to change these ones # WIKI_DIR_NAME="wiki" # Name of the wiki's directory
t/test-gitmw-lib.sh line 21
Quoted 10 lines
t/test-gitmw-lib.sh +2
-3WIKI_DIR_INST="/var/www" # Directory of the web server TMP="/tmp" # Temporary directory for downloads - # Absolute address needed! + # Absolute path required! SERVER_ADDR="localhost" # Web server's address -# # CONFIGURATION -# You should not change those ones unless you know what you to +# You should not change these ones unless you know what you do
These fixups should have been squashed into the previous one. Bad use of "git rebase -i"?
t/test-gitmw-lib.sh line 34
Quoted 1 line
t/test-gitmw-lib.sh +1
-0+ ../test-gitmw.pl "get_page" -p "$1" "$2"
Useless quotes around "get_page".
(but useful ones around $1 and $2 ;-))
t/test-gitmw-lib.sh line 59
Quoted 1 line
t/test-gitmw-lib.sh +1
-0+ result=$(diff -r -B -w --exclude=".git" "$1" "$2")
Doesn't seem to be in POSIX:
http://pubs.opengroup.org/onlinepubs/009695399/utilities/diff.html
Will this run on all platforms?
t/test-gitmw-lib.sh line 83
Quoted 4 lines
t/test-gitmw-lib.sh +4
-0+# wiki_page_content <file_name> <page_name> +# +# Compares the contents of the file <file_name> and the wiki page +# <page_name> and exits with error 1 if they do not match.
If it does a comparison, why isn't it named "check_content", or "diff_content"?
t/test-gitmw-lib.sh line 27
Quoted 2 lines
t/test-gitmw-lib.sh +2
-0+# Usage: +# ./test-gitmw.pl <function> [argument]*
I'd say s/function/command/
t/test-gitmw-lib.sh line 30
Quoted 3 lines
t/test-gitmw-lib.sh +3
-0+my $wiki_url="http://localhost/wiki/api.php"; +my $wiki_admin='WikiAdmin'; +my $wiki_admin_pass='AdminPass';
It would be nice to allow overriding these from the command-line. But as you are now writting tests, you may as well apply the YAGNI principle ;-).
t/test-gitmw-lib.sh line 31
Quoted 1 line
t/test-gitmw-lib.sh +1
-0+ # Replace spaces by underscore in the page name
Indent with space.
Signature · 2 lines
Matthieu Moy http://www-verimag.imag.fr/~moy/
Re: [PATCH 2/3] Test environment of git-remote-mw
Quoted 8 lines · Matthieu Moy
t/test-gitmw-lib.sh line 59
Quoted 2 lines
t/test-gitmw-lib.sh +1
-0+ result=$(diff -r -B -w --exclude=".git" "$1" "$2")Doesn't seem to be in POSIX:
http://pubs.opengroup.org/onlinepubs/009695399/utilities/diff.html
Will this run on all platforms?
Indeed. According to the POSIX manual, the option -B and -w are merged in the single option -b. In addition, -r option still exists (to compare recursively two directories). The previous instruction will be write as follow :
diff -r -b "$first_folder" "$second_folder"
With this fix, it will works on all platforms. ;)
Quoted 6 lines
t/test-gitmw.pl line 31
Quoted 3 lines
t/test-gitmw.pl new file +3
-0+my $wiki_url="http://localhost/wiki/api.php"; +my $wiki_admin='WikiAdmin'; +my $wiki_admin_pass='AdminPass';It would be nice to allow overriding these from the command-line. But as you are now writting tests, you may as well apply the YAGNI principle ;-).
Does it seems important for you to overriding these from CL ?
By default, those settings work fine. You have to edit this only if you need a special configuration. But it is purely optionnal.
Included in v2 patches:
* Fixing errors pointed above.
* Sqlite file excluded from the patches. Mainly with reviewing thewiki_install script.
On the other hand, considering the git-mediawiki is curently on contrib branch, shall we move our test environement from git/t to git/contrib/t ?
SimonC
Signature · 6 lines
CATHEBRAS Simon 2A-ENSIMAG Filière Ingéniérie des Systèmes d'Information Membre Bug-Buster
Re: [PATCH 2/3] Test environment of git-remote-mw
Quoted 3 lines · Simon.Cathebras
On the other hand, considering the git-mediawiki is curently on contrib branch, shall we move our test environement from git/t to git/contrib/t ?
If so, that would be to $git/contrib/mw-to-git/t/.
I'm not sur what's best, depending on the future of the tool:
If, once Git-MediaWiki is robust, well-tested, ... and enough people are interested, it may make sense to move Git-MediaWiki out of the contrib/ directory, and integrate it as an official command (like git-svn for example). That would make the installation process seamless ("make install" would install git-remote-mediawiki like other commands, "make doc" would generate the doc, and so on), which would be nice for the user.
My feeling is that we're still quite far from this. Although we're in the process of having a well-tested program, and that new features are going to come soon, there is still little interest of the community for it (at least, uncomparable to the one of git-svn for example).
So, I'd say that we should stick to something non-intrusive, within contrib/, and if more people show interest in the tool and if it becomes mature enough, we can start trying to push it out of contrib/.
What do other people think?
Signature · 2 lines
Matthieu Moy http://www-verimag.imag.fr/~moy/
Re: [PATCH 2/3] Test environment of git-remote-mw
Quoted 10 lines · Matthieu Moy
Quoted 3 lines · Simon.Cathebras
On the other hand, considering the git-mediawiki is curently on contrib branch, shall we move our test environement from git/t to git/contrib/t ?
If so, that would be to $git/contrib/mw-to-git/t/.
I'm not sur what's best, depending on the future of the tool:
Quoted 7 lines
If, once Git-MediaWiki is robust, well-tested, ... and enough people are interested, it may make sense to move Git-MediaWiki out of the contrib/ directory, and integrate it as an official command (like git-svn for example). That would make the installation process seamless ("make install" would install git-remote-mediawiki like other commands, "make doc" would generate the doc, and so on), which would be nice for the user.
Here's another attempt to be nice to the user, without getting out of the contrib/ directory. I suggest that you include it in your patch serie, and build your stuff on top of it.
--------------- 8< ----------------- 8< ------------------------ From 25187a652abc0b546be2fb1afb707b32b9f1d4fc Mon Sep 17 00:00:00 2001
From: Matthieu Moy <[email protected]>
Date: Fri, 1 Jun 2012 11:18:20 +0200
Subject: [PATCH] git-remote-mediawiki: simple Makefile for simple
installation
This allows the user to run "make check" to install the script in Git's exec path, following the configuration (manual in config.mak, or through autoconf).
--- contrib/mw-to-git/Makefile | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 contrib/mw-to-git/Makefile
contrib/mw-to-git/Makefile new file +29 -0
@@ -0,0 +1,29 @@ +-include ../../config.mak +-include ../../config.mak.autogen + +ifndef PERL_PATH + PERL_PATH = /usr/bin/perl +endif + +PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH)) +gitexecdir_SQ = $(subst ','\'',$(gitexecdir)) + +SCRIPT=git-remote-mediawiki + +.PHONY: install help doc test +help: + @echo 'This is the help target of the Makefile. Current configuration:' + @echo ' gitexecdir = $(gitexecdir_SQ)' + @echo ' PERL_PATH = $(PERL_PATH_SQ)' + @echo 'Run "$(MAKE) install" to install $(SCRIPT) in gitexecdir.' + +install: + sed -e '1s|#!.*/perl|#!$(PERL_PATH_SQ)|' $(SCRIPT) \ + > '$(gitexecdir_SQ)/$(SCRIPT)' + chmod 755 '$(gitexecdir)/$(SCRIPT)' + +doc: + @echo 'Sorry, "make doc" is not implemented yet for $(SCRIPT)' + +test: + @echo 'Sorry, "make test" is not implemented yet for $(SCRIPT)'
Signature · 7 lines
1.7.10.2.817.g37218b0 -- Matthieu Moy http://www-verimag.imag.fr/~moy/
PATCH 3/3 Tests file for git-remote-mediawiki
In reply to Simon CathebrasFrom: Charles Roussel <[email protected]>
This file (will) contains all tests for git-remote-mediawiki. For now, we have one test of git-clone on a wiki with one page.
--- t/t9360-git-mediawiki.sh | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 t/t9360-git-mediawiki.sh
t/t9360-git-mediawiki.sh new file +49 -0
@@ -0,0 +1,49 @@ +#!/bin/sh +# +# Copyright (C) 2012 +# Charles Roussel <[email protected]> +# Simon Cathebras <[email protected]> +# Julien Khayat <[email protected]> +# Guillaume Sasdy <[email protected]> +# Simon Perrat <[email protected]> +# Matthieu Moy <[email protected]> +# +# License: GPL v2 or later + +# tests for git-remote-mediawiki + +test_description='Test the Git Mediawiki remote helper' + +. ./test-gitmw-lib.sh +. ./test-lib.sh + +if ! test_have_prereq PERL +then + skip_all='skipping gateway git-mw tests, perl not available' + test_done +fi + +if [ ! -f /$GIT_BUILD_DIR/git-remote-mediawiki ]; +then + skip_all='skipping gateway git-mw tests, no remote mediawiki for git found' + test_done +fi + +if [ ! -d "$WIKI_DIR_INST/$WIKI_DIR_NAME" ] ; +then + skip_all='skipping gateway git-mw tests, no mediawiki found' + test_done +fi + +test_expect_success 'git clone works with page added' ' + cmd_reset && + wiki_editpage foo "hello_world" false && + wiki_editpage bar "hi everybody !" false && + git clone mediawiki::http://localhost/wiki mw_dir && + wiki_getallpage ref_page && + git_content mw_dir ref_page && + wiki_delete_page foo && + wiki_delete_page bar +' + +test_done
Signature · 1 line
1.7.10.2.552.gaa3bb87
Re: [PATCH 1/3] Script to install, delete and clear a MediaWiki
In reply to Simon CathebrasQuoted 1 line · Simon Cathebras
install_wikialso defines a functioncmd_reset
Why the "cmd_reset" name?
Wouldn't wiki_reset be both more descriptive and more consistent?
Signature · 2 lines
Matthieu Moy http://www-verimag.imag.fr/~moy/
PATCH 1/2 FIX: t9360. NEW test t9361 for git pull and git push
In reply to Simon.Cathebrast9360: change the description of the test. Test git clone
t9361: Test git pull (add page, edit page, delete page) and git push on simple test cases (add file, edit file, delete file).
--- t/t9360-git-mediawiki.sh | 4 +- t/t9361-git-mediawiki.sh | 156 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 158 insertions(+), 2 deletions(-) create mode 100755 t/t9361-git-mediawiki.sh
t/t9360-git-mediawiki.sh +2 -2
@@ -12,7 +12,7 @@ # tests for git-remote-mediawiki -test_description='Test the Git Mediawiki remote helper' +test_description='Test the Git Mediawiki remote helper: git clone' . ./test-gitmw-lib.sh . ./test-lib.sh
@@ -36,7 +36,7 @@ then fi test_expect_success 'git clone works with page added' ' - cmd_reset && + wiki_reset && wiki_editpage foo "hello_world" false && wiki_editpage bar "hi everybody !" false && git clone mediawiki::http://localhost/wiki mw_dir &&
t/t9361-git-mediawiki.sh new file +156 -0
156 lines not on this page · raw message
Signature · 1 line
1.7.10.2.568.g4c26a3a
PATCH 2/2 FIX: Syntax of shell and perl scripts and posix compliant
From: Simon Cathebras <[email protected]>
t/test-gitmw.pl: no more '\n' in the append of wiki_editpage t/test-gitmw-lib.sh: grep is now Posix compliant t/test-gitmw-lib.sh: some " " were misplaced
--- t/test-gitmw-lib.sh | 17 ++++++++--------- t/test-gitmw.pl | 4 ++-- 2 files changed, 10 insertions(+), 11 deletions(-)
t/test-gitmw-lib.sh +8 -9
@@ -31,14 +31,14 @@ WIKI_PASSW="AdminPass" # Fetch a page <page_name> from the wiki and copy its content # into directory <dest_path>. wiki_getpage () { - ../test-gitmw.pl "get_page" -p "$1" "$2" + ../test-gitmw.pl get_page -p "$1" "$2" } # wiki_delete_page <page_name> # # Delete the page <page_name> on the wiki. wiki_delete_page () { - ../test-gitmw.pl "delete_page" -p "$1" + ../test-gitmw.pl delete_page -p "$1" } # wiki_edit_page <page_name> <page_content> <page_append>
@@ -47,7 +47,7 @@ wiki_delete_page () { # If <wiki_append> == true the content will be appended # If the page doesn't exist, it is created. wiki_editpage () { - ../test-gitmw.pl "edit_page" -p "$1" "$2" "$3" + ../test-gitmw.pl edit_page -p "$1" "$2" "$3" } # git_content <dir_1> <dir_2>
@@ -56,7 +56,7 @@ wiki_editpage () { # and exits with error 1 if they do not match. The program will # not look into .git in the process. git_content () { - result=$(diff -r -B -w --exclude=".git" "$1" "$2") + result=$(diff -r -b --exclude=".git" "$1" "$2") if echo $result | grep -q ">" ; then echo "test failed: files $1 and $2 do not match"
@@ -77,11 +77,11 @@ git_exist () { fi } -# wiki_page_content <file_name> <page_name> +# wiki_check_content <file_name> <page_name> # # Compares the contents of the file <file_name> and the wiki page # <page_name> and exits with error 1 if they do not match. -wiki_page_content () { +wiki_check_content () { wiki_getpage "$2" . if test -f "$2".mw ; then
@@ -120,16 +120,15 @@ wiki_getallpagename () { # <dest_dir>. wiki_getallpage () { wiki_getallpagename - mkdir $1 + mkdir -p "$1" while read -r line; do wiki_getpage "$line" $1; done < all.txt - #rm all.txt } fail() { - echo $1 + echo "$1" exit 1 }
t/test-gitmw.pl +2 -2
@@ -9,7 +9,7 @@ # License: GPL v2 or later # Usage: -# ./test-gitmw.pl <function> [argument]* +# ./test-gitmw.pl <command> [argument]* # Execute in terminal using the name of the function to call as first # parameter, and the function's arguments as following parameters #
@@ -111,7 +111,7 @@ sub wiki_editpage { my $text = $wiki_content; if (defined($previous_text)) { - $text="$previous_text\n\n$text"; + $text="$previous_text$text"; } $mw->edit( { action => 'edit', title => $wiki_page, text => "$text"} ); }
Signature · 1 line
1.7.10.2.568.g4c26a3a
PATCH 1/1 FIX: Syntax of shell and perl scripts and posix compliant
In reply to Simon.CathebrasFrom: Simon Cathebras <[email protected]>
t/test-gitmw.pl: no more '\n' in the append of wiki_editpage t/test-gitmw-lib.sh: grep is now Posix compliant t/test-gitmw-lib.sh: some " " were misplaced
--- t/test-gitmw-lib.sh | 17 ++++++++--------- t/test-gitmw.pl | 4 ++-- 2 files changed, 10 insertions(+), 11 deletions(-)
t/test-gitmw-lib.sh +8 -9
@@ -31,14 +31,14 @@ WIKI_PASSW="AdminPass" # Fetch a page <page_name> from the wiki and copy its content # into directory <dest_path>. wiki_getpage () { - ../test-gitmw.pl "get_page" -p "$1" "$2" + ../test-gitmw.pl get_page -p "$1" "$2" } # wiki_delete_page <page_name> # # Delete the page <page_name> on the wiki. wiki_delete_page () { - ../test-gitmw.pl "delete_page" -p "$1" + ../test-gitmw.pl delete_page -p "$1" } # wiki_edit_page <page_name> <page_content> <page_append>
@@ -47,7 +47,7 @@ wiki_delete_page () { # If <wiki_append> == true the content will be appended # If the page doesn't exist, it is created. wiki_editpage () { - ../test-gitmw.pl "edit_page" -p "$1" "$2" "$3" + ../test-gitmw.pl edit_page -p "$1" "$2" "$3" } # git_content <dir_1> <dir_2>
@@ -56,7 +56,7 @@ wiki_editpage () { # and exits with error 1 if they do not match. The program will # not look into .git in the process. git_content () { - result=$(diff -r -B -w --exclude=".git" "$1" "$2") + result=$(diff -r -b --exclude=".git" "$1" "$2") if echo $result | grep -q ">" ; then echo "test failed: files $1 and $2 do not match"
@@ -77,11 +77,11 @@ git_exist () { fi } -# wiki_page_content <file_name> <page_name> +# wiki_check_content <file_name> <page_name> # # Compares the contents of the file <file_name> and the wiki page # <page_name> and exits with error 1 if they do not match. -wiki_page_content () { +wiki_check_content () { wiki_getpage "$2" . if test -f "$2".mw ; then
@@ -120,16 +120,15 @@ wiki_getallpagename () { # <dest_dir>. wiki_getallpage () { wiki_getallpagename - mkdir $1 + mkdir -p "$1" while read -r line; do wiki_getpage "$line" $1; done < all.txt - #rm all.txt } fail() { - echo $1 + echo "$1" exit 1 }
t/test-gitmw.pl +2 -2
@@ -9,7 +9,7 @@ # License: GPL v2 or later # Usage: -# ./test-gitmw.pl <function> [argument]* +# ./test-gitmw.pl <command> [argument]* # Execute in terminal using the name of the function to call as first # parameter, and the function's arguments as following parameters #
@@ -111,7 +111,7 @@ sub wiki_editpage { my $text = $wiki_content; if (defined($previous_text)) { - $text="$previous_text\n\n$text"; + $text="$previous_text$text"; } $mw->edit( { action => 'edit', title => $wiki_page, text => "$text"} ); }
Signature · 1 line
1.7.10.2.568.g4c26a3a
PATCH 1/1 FIX: Syntax of shell and perl scripts and posix compliant
In reply to Simon.CathebrasFrom: Simon Cathebras <[email protected]>
t/test-gitmw.pl: no more '\n' in the append of wiki_editpage t/test-gitmw-lib.sh: grep is now Posix compliant t/test-gitmw-lib.sh: some " " were misplaced
--- t/test-gitmw-lib.sh | 17 ++++++++--------- t/test-gitmw.pl | 4 ++-- 2 files changed, 10 insertions(+), 11 deletions(-)
t/test-gitmw-lib.sh +8 -9
@@ -31,14 +31,14 @@ WIKI_PASSW="AdminPass" # Fetch a page <page_name> from the wiki and copy its content # into directory <dest_path>. wiki_getpage () { - ../test-gitmw.pl "get_page" -p "$1" "$2" + ../test-gitmw.pl get_page -p "$1" "$2" } # wiki_delete_page <page_name> # # Delete the page <page_name> on the wiki. wiki_delete_page () { - ../test-gitmw.pl "delete_page" -p "$1" + ../test-gitmw.pl delete_page -p "$1" } # wiki_edit_page <page_name> <page_content> <page_append>
@@ -47,7 +47,7 @@ wiki_delete_page () { # If <wiki_append> == true the content will be appended # If the page doesn't exist, it is created. wiki_editpage () { - ../test-gitmw.pl "edit_page" -p "$1" "$2" "$3" + ../test-gitmw.pl edit_page -p "$1" "$2" "$3" } # git_content <dir_1> <dir_2>
@@ -56,7 +56,7 @@ wiki_editpage () { # and exits with error 1 if they do not match. The program will # not look into .git in the process. git_content () { - result=$(diff -r -B -w --exclude=".git" "$1" "$2") + result=$(diff -r -b --exclude=".git" "$1" "$2") if echo $result | grep -q ">" ; then echo "test failed: files $1 and $2 do not match"
@@ -77,11 +77,11 @@ git_exist () { fi } -# wiki_page_content <file_name> <page_name> +# wiki_check_content <file_name> <page_name> # # Compares the contents of the file <file_name> and the wiki page # <page_name> and exits with error 1 if they do not match. -wiki_page_content () { +wiki_check_content () { wiki_getpage "$2" . if test -f "$2".mw ; then
@@ -120,16 +120,15 @@ wiki_getallpagename () { # <dest_dir>. wiki_getallpage () { wiki_getallpagename - mkdir $1 + mkdir -p "$1" while read -r line; do wiki_getpage "$line" $1; done < all.txt - #rm all.txt } fail() { - echo $1 + echo "$1" exit 1 }
t/test-gitmw.pl +2 -2
@@ -9,7 +9,7 @@ # License: GPL v2 or later # Usage: -# ./test-gitmw.pl <function> [argument]* +# ./test-gitmw.pl <command> [argument]* # Execute in terminal using the name of the function to call as first # parameter, and the function's arguments as following parameters #
@@ -111,7 +111,7 @@ sub wiki_editpage { my $text = $wiki_content; if (defined($previous_text)) { - $text="$previous_text\n\n$text"; + $text="$previous_text$text"; } $mw->edit( { action => 'edit', title => $wiki_page, text => "$text"} ); }
Signature · 1 line
1.7.10.2.568.g4c26a3a
PATCH 1/3 FIX: cmd_* moved to wiki_* in test-gitmw-lib.sh and other files
In reply to Simon.CathebrasFrom: Simon Cathebras <[email protected]>
Function cmd_* has been renamed in wiki_* in t/install-wiki.sh. Change the calls in t/test-gitmw-lib.sh
--- t/install-wiki.sh | 4 ++-- t/test-gitmw-lib.sh | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-)
t/install-wiki.sh +2 -2
@@ -19,11 +19,11 @@ usage () { # Argument: install, delete, --help | -h case "$1" in "install") - cmd_install + wiki_install exit 0 ;; "delete") - cmd_delete + wiki_delete exit 0 ;; "--help" | "-h")
t/test-gitmw-lib.sh +5 -5
@@ -136,7 +136,7 @@ fail() # Install a wiki in your web server directory. -cmd_install () { +wiki_install () { # Copy the generic LocalSettings.php in the web server's directory # And modify parameters according to the ones set at the top
@@ -206,7 +206,7 @@ cmd_install () { # Argument $1 is the relative path to the folder $FILES_FOLDER # # Warning: This function should be not called by user. This is a private -# function used by cmd_install and cmd_delete +# function used by wiki_install and wiki_delete reset_db_wiki () { # Copy initial database of the wiki
@@ -221,7 +221,7 @@ reset_db_wiki () { # Set the admin WikiAdmin with password AdminPass in the database. # # Warning: This function should be not called by user. This is a private -# function used by cmd_install and cmd_delete +# function used by wiki_install and wiki_delete set_admin_wiki () { #Add the admin
@@ -237,14 +237,14 @@ set_admin_wiki () { # Reset the database of the wiki and the password of the admin # # Warning: This function must be called only in a subdirectory of t/ directory -cmd_reset () { +wiki_reset () { reset_db_wiki ".." set_admin_wiki } # Delete the wiki created in the web server's directory and all its content # saved in the database. -cmd_delete () { +wiki_delete () { # Delete the wiki's directory. rm -rf "$WIKI_DIR_INST/$WIKI_DIR_NAME" || fail "Wiki's directory $WIKI_DIR_INST/" \
Signature · 1 line
1.7.10.2.568.g4c26a3a
PATCH 1/3 Script to install, delete and clear a MediaWiki
In reply to Simon.CathebrasFrom: Charles Roussel <[email protected]>
install_wiki.sh expects the first argument to be 'install' or 'delete' 'install' installs a MediaWiki on the web's server with SQLite3 'delete' deletes the previously created wiki.
Note those functionnalities are made to be used from the user command line in the directory t/
install_wiki also defines a function cmd_reset which clear all content of the previously created wiki. Note this functionnality is made to be used only by our test function in a subdirectory of t/
--- t/install-wiki.sh | 38 ++++++++++ t/install-wiki/LocalSettings.php | 129 ++++++++++++++++++++++++++++++++++ t/install-wiki/wikidb.sqlite | Bin 0 -> 210944 bytes t/test-gitmw-lib.sh | 147 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 314 insertions(+) create mode 100755 t/install-wiki.sh create mode 100644 t/install-wiki/LocalSettings.php create mode 100644 t/install-wiki/wikidb.sqlite create mode 100755 t/test-gitmw-lib.sh mode change 100644 => 100755 t/test-lib-functions.sh mode change 100644 => 100755 t/test-lib.sh
t/install-wiki.sh new file +38 -0
@@ -0,0 +1,38 @@ +#!/bin/sh + +# This script installs or deletes a MediaWiki on your computer. +# It requires a web server with PHP and SQLite running. In addition, if you +# do not have MediaWiki sources on your computer, the option 'install' +# downloads them for you. +# Please set the CONFIGURATION VARIABLES in ./test-gitmw-lib.sh + +. ./test-gitmw-lib.sh + +usage () { + echo "Usage: " + echo " ./install-wiki.sh <install|delete|--help|-h>" + echo " install: Install a wiki on your computer." + echo " delete: Delete the wiki and all its pages and content" +} + + +# Argument: install, delete, --help | -h +case "$1" in + "install") + wiki_install + exit 0 + ;; + "delete") + wiki_delete + exit 0 + ;; + "--help" | "-h") + usage + exit 0 + ;; + *) + usage + exit 0 + ;; +esac +
t/install-wiki/LocalSettings.php new file +129 -0
129 lines not on this page · raw message
t/install-wiki/wikidb.sqlite new file binary +0 -0
t/test-gitmw-lib.sh new file +147 -0
147 lines not on this page · raw message
t/test-lib-functions.sh +0 -0
t/test-lib.sh +0 -0
Signature · 1 line
1.7.10.2.568.g4c26a3a
PATCH 2/3 Test environment of git-remote-mw
From: Charles Roussel <[email protected]>
In order to test git-remote-mediawiki, we need a package of functions to manage a MediaWiki: edit a page, remove a page, fetch a page, fetch all pages on a given wiki.
We also need functions to compare the content of directories.
--- t/test-gitmw-lib.sh | 124 ++++++++++++++++++++++++++++++++++++--- t/test-gitmw.pl | 164 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 280 insertions(+), 8 deletions(-) create mode 100755 t/test-gitmw.pl
t/test-gitmw-lib.sh +116 -8
@@ -1,27 +1,135 @@ +# Copyright (C) 2012 +# Charles Roussel <[email protected]> +# Simon Cathebras <[email protected]> +# Julien Khayat <[email protected]> +# Guillaume Sasdy <[email protected]> +# Simon Perrat <[email protected]> +# Matthieu Moy <[email protected]> +# License: GPL v2 or later + # # CONFIGURATION VARIABLES -# You might want to change those ones ... +# You might want to change these ones # WIKI_DIR_NAME="wiki" # Name of the wiki's directory WIKI_DIR_INST="/var/www" # Directory of the web server TMP="/tmp" # Temporary directory for downloads - # Absolute address needed! + # Absolute path required! SERVER_ADDR="localhost" # Web server's address -# # CONFIGURATION -# You should not change those ones unless you know what you to +# You should not change these ones unless you know what you do # -# Do not change the variables below MW_VERSION="mediawiki-1.19.0" DB_FILE="wikidb.sqlite" FILES_FOLDER="install-wiki" WIKI_ADMIN="WikiAdmin" WIKI_PASSW="AdminPass" -fail () { - echo "$1" - exit 1 +# wiki_getpage <page_name> <dest_path> +# +# Fetch a page <page_name> from the wiki and copy its content +# into directory <dest_path>. +wiki_getpage () { + ../test-gitmw.pl get_page -p "$1" "$2" +} + +# wiki_delete_page <page_name> +# +# Delete the page <page_name> on the wiki. +wiki_delete_page () { + ../test-gitmw.pl delete_page -p "$1" +} + +# wiki_edit_page <page_name> <page_content> <page_append> +# +# Edit a page <wiki_page> on the wiki with content <wiki_content> +# If <wiki_append> == true the content will be appended +# If the page doesn't exist, it is created. +wiki_editpage () { + ../test-gitmw.pl edit_page -p "$1" "$2" "$3" +} + +# git_content <dir_1> <dir_2> +# +# Compare the contents of directories <dir_1> and <dir_2> with diff +# and exits with error 1 if they do not match. The program will +# not look into .git in the process. +git_content () { + result=$(diff -r -b --exclude=".git" "$1" "$2") + + if echo $result | grep -q ">" ; then + echo "test failed: files $1 and $2 do not match" + exit 1 + fi +} + +# git_exist <rep_name> <file_name> +# +# Check the existence of <file_name> into the git repository +# <rep_name> and exits with error 1 if it is absent. +git_exist () { + result=$(find "$1" -type f -name "$2") + + if ! echo $result | grep -q "$2" ; then + echo "test failed: file $2 does not exist in $1" + exit 1 + fi +} + +# wiki_check_content <file_name> <page_name> +# +# Compares the contents of the file <file_name> and the wiki page +# <page_name> and exits with error 1 if they do not match. +wiki_check_content () { + wiki_getpage "$2" . + + if test -f "$2".mw ; then + git_content "$1" "$2".mw + rm "$2".mw + else + die "ERROR: file $2 not found on wiki" + fi +} + +# wiki_page_exist <page_name> +# +# Check the existence of the page <page_name> on the wiki and exits +# with error if it is absent from it. +wiki_page_exist () { + wiki_getpage "$1" . + + if test -f "$1".mw ; then + echo "test failed: file $1 not found on wiki" + exit 1 + else + rm "$1".mw + fi +} + +# wiki_getallpagename +# +# Fetch the name of each page on the wiki. +wiki_getallpagename () { + ../test-gitmw.pl "getallpagename" -p +} + +# wiki_getallpage <dest_dir> +# +# Fetch all the pages from the wiki and place them in the directory +# <dest_dir>. +wiki_getallpage () { + wiki_getallpagename + mkdir -p "$1" + while read -r line; do + wiki_getpage "$line" $1; + done < all.txt +} + +fail() +{ + echo "$1" + exit 1 }
t/test-gitmw.pl new file +164 -0
164 lines not on this page · raw message
Signature · 1 line
1.7.10.2.568.g4c26a3a
Re: [PATCH 2/3] Test environment of git-remote-mw
Quoted 5 lines · Guillaume Sasdy
# CONFIGURATION VARIABLES
t/test-gitmw-lib.sh +1
-1-# You might want to change those ones ... +# You might want to change these ones # WIKI_DIR_NAME="wiki" # Name of the wiki's directory
t/test-gitmw-lib.sh line 21
Quoted 10 lines
t/test-gitmw-lib.sh +2
-3WIKI_DIR_INST="/var/www" # Directory of the web server TMP="/tmp" # Temporary directory for downloads - # Absolute address needed! + # Absolute path required! SERVER_ADDR="localhost" # Web server's address -# # CONFIGURATION -# You should not change those ones unless you know what you to +# You should not change these ones unless you know what you do
I already mentionned in in your v1, but these fixups do not belong to PATCH 2/3. You do not want reviewers to see your mistakes in PATCH 1/2 and see the fix in PATCH 2/3.
t/test-gitmw-lib.sh line 35
Quoted 3 lines
t/test-gitmw-lib.sh +3
-0+wiki_getpage () { + ../test-gitmw.pl get_page -p "$1" "$2" +}
Any reason why test-gitmw.pl and wiki_getpage have this slightly different API? The perl version has a "-p" flag, and the shell command has only positionnal arguments.
I'd rather have a more uniform way to wrap calls to test-gitmw.pl in shell, like
wiki_<something> () {
../test-gitmw.pl <something> "$@"
}Then, you probably want to move the API documentation (i.e. comments you put before the shell functions) in, or next to the Perl script, and avoid repeating it in the shell.
t/test-gitmw-lib.sh line 58
Quoted 6 lines
t/test-gitmw-lib.sh +6
-0+# git_content <dir_1> <dir_2> +# +# Compare the contents of directories <dir_1> and <dir_2> with diff +# and exits with error 1 if they do not match. The program will +# not look into .git in the process. +git_content () {
Didn't I already say that the naming was strange? A function that compares something shouldn't be called just "content".
t/test-gitmw-lib.sh line 61
Quoted 3 lines
t/test-gitmw-lib.sh +3
-0+ result=$(diff -r -b --exclude=".git" "$1" "$2") + + if echo $result | grep -q ">" ; then
Why grep, when the exit status of diff tells you about the differences already?
t/test-gitmw-lib.sh line 74
Quoted 8 lines
t/test-gitmw-lib.sh +8
-0+# git_exist <rep_name> <file_name> +# +# Check the existence of <file_name> into the git repository +# <rep_name> and exits with error 1 if it is absent. +git_exist () { + result=$(find "$1" -type f -name "$2") + + if ! echo $result | grep -q "$2" ; then
Missing quotes around $result.
Why do you need grep again? You just want to check whether "$result" is empty (test -z).
Review
Quoted 2 lines
(quoted diff) +2
-0+ echo "test failed: file $2 does not exist in $1" + exit 1
die
?
t/test-gitmw-lib.sh line 104
Quoted 6 lines
t/test-gitmw-lib.sh +6
-0+wiki_page_exist () { + wiki_getpage "$1" . + + if test -f "$1".mw ; then + echo "test failed: file $1 not found on wiki" + exit 1
likewise.
t/test-gitmw-lib.sh line 130
Quoted 2 lines
t/test-gitmw-lib.sh +2
-0+fail() +{
Style: fail () {
Plus, didn't we say "die" was already there for this?
t/test-gitmw.pl line 63
Quoted 2 lines
t/test-gitmw.pl new file +2
-0+ # Replace spaces by underscore in the page name + $pagename=~s/\ /_/;
Indent with space (didn't I already mention that?).
t/test-gitmw.pl line 151
Quoted 3 lines
t/test-gitmw.pl new file +3
-0+my $login = $ARGV[0]; + +if ($login eq "-p")
Feels weird. If you're not sure it's a login, why call the variable $login?
Any reason not to use Perl's option parsing?
Signature · 2 lines
Matthieu Moy http://www-verimag.imag.fr/~moy/
Re: [PATCH 2/3] Test environment of git-remote-mw
Quoted 13 lines · Matthieu Moy
Quoted 11 lines · Guillaume Sasdy
# CONFIGURATION VARIABLES
t/test-gitmw-lib.sh +2
-2-# You might want to change those ones ... +# You might want to change these ones # WIKI_DIR_NAME="wiki" # Name of the wiki's directory WIKI_DIR_INST="/var/www" # Directory of the web server TMP="/tmp" # Temporary directory for downloads - # Absolute address needed! + # Absolute path required! SERVER_ADDR="localhost" # Web server's address
Quoted 7 lines
t/test-gitmw-lib.sh line 21
Quoted 4 lines
t/test-gitmw-lib.sh +1
-2-# # CONFIGURATION -# You should not change those ones unless you know what you to +# You should not change these ones unless you know what you doI already mentionned in in your v1, but these fixups do not belong to PATCH 2/3. You do not want reviewers to see your mistakes in PATCH 1/2 and see the fix in PATCH 2/3.
Got it. With the problem experienced yesterday, we had still this issue this morning. It is now fixed :).
Quoted 6 lines
t/test-gitmw-lib.sh line 35
Quoted 3 lines
t/test-gitmw-lib.sh +3
-0+wiki_getpage () { + ../test-gitmw.pl get_page -p "$1" "$2" +}Any reason why test-gitmw.pl and
wiki_getpagehave this slightly different API? The perl version has a "-p" flag, and the shell command has only positionnal arguments.
The "-p" flag exists to specify if we have to use the admin login on wiki to do the command. For instance, here we fetch a page from the wiki with Admin privilege. Others arguments remains the same.
Quoted 6 lines
I'd rather have a more uniform way to wrap calls to test-gitmw.pl in shell, like
wiki_<something> () { ../test-gitmw.pl<something> "$@" }
Do you suggest we include the "-p" flag in <something> ? I agree for the use of "$@".
Quoted 5 lines
Then, you probably want to move the API documentation (i.e. comments you put before the shell functions) in, or next to the Perl script, and avoid repeating it in the shell.
Ok.
Quoted 8 lines
t/test-gitmw-lib.sh line 58
Quoted 6 lines
t/test-gitmw-lib.sh +6
-0+# git_content<dir_1> <dir_2> +# +# Compare the contents of directories<dir_1> and<dir_2> with diff +# and exits with error 1 if they do not match. The program will +# not look into .git in the process. +git_content () {Didn't I already say that the naming was strange? A function that compares something shouldn't be called just "content".
Sorry, we misunderstood what you mean... Update is coming. What about git_diff_directories ? Because this shell function execute a special instance of diff, matching two directories and ignoring blank character.
Quoted 6 lines
t/test-gitmw-lib.sh line 61
Quoted 3 lines
t/test-gitmw-lib.sh +3
-0+ result=$(diff -r -b --exclude=".git" "$1" "$2") + + if echo $result | grep -q ">" ; thenWhy grep, when the exit status of diff tells you about the differences already?
Good idea for the exit status.
Quoted 10 lines
t/test-gitmw-lib.sh line 74
Quoted 8 lines
t/test-gitmw-lib.sh +8
-0+# git_exist<rep_name> <file_name> +# +# Check the existence of<file_name> into the git repository +#<rep_name> and exits with error 1 if it is absent. +git_exist () { + result=$(find "$1" -type f -name "$2") + + if ! echo $result | grep -q "$2" ; thenMissing quotes around $result.
Quoted 2 lines
Why do you need grep again? You just want to check whether "$result" is empty (test -z).
this function is now erased from our code... Actually, it was really useless...
Quoted 6 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ echo "test failed: file $2 does not exist in $1" + exit 1die
?
Quoted 7 lines
t/test-gitmw-lib.sh line 104
Quoted 6 lines
t/test-gitmw-lib.sh +6
-0+wiki_page_exist () { + wiki_getpage "$1" . + + if test -f "$1".mw ; then + echo "test failed: file $1 not found on wiki" + exit 1likewise.
We were supposed to do it with the previous version.
But we are facing some difficulties using die function outside the test harness. We wanted to include the file "test-lib.sh" in our own script "test-gitmw-lib.sh" to use die. It doesn't work, because the harness expect the file "test-gitmw-lib.sh" to be a test script. Wich is not the case.
Do you have any Idea about how to fix this problem ?
Quoted 5 lines
t/test-gitmw-lib.sh line 130
Quoted 2 lines
t/test-gitmw-lib.sh +2
-0+fail() +{Style: fail () {
Plus, didn't we say "die" was already there for this?
Agree, see above.
Quoted 9 lines
t/test-gitmw.pl line 63
Quoted 2 lines
t/test-gitmw.pl new file +2
-0+ # Replace spaces by underscore in the page name + $pagename=~s/\ /_/;Indent with space (didn't I already mention that?).
t/test-gitmw.pl line 151
Quoted 3 lines
t/test-gitmw.pl new file +3
-0+my $login = $ARGV[0]; + +if ($login eq "-p")Feels weird. If you're not sure it's a login, why call the variable $login?
Change on the way. renaming this variable "is_login". Is this ok for you ?
Quoted 1 line
Any reason not to use Perl's option parsing?
Not at all, we juste didn't thought about it.
Signature · 6 lines
CATHEBRAS Simon 2A-ENSIMAG Filière Ingéniérie des Systèmes d'Information Membre Bug-Buster
Re: [PATCH 2/3] Test environment of git-remote-mw
Quoted 8 lines · Simon.Cathebras
Quoted 6 lines
t/test-gitmw-lib.sh line 35
Quoted 3 lines
t/test-gitmw-lib.sh +3
-0+wiki_getpage () { + ../test-gitmw.pl get_page -p "$1" "$2" +}Any reason why test-gitmw.pl and
wiki_getpagehave this slightly different API? The perl version has a "-p" flag, and the shell command has only positionnal arguments.The "-p" flag exists to specify if we have to use the admin login on wiki to do the command.
(then, maybe --admin would be a better name?)
Quoted 2 lines
For instance, here we fetch a page from the wiki with Admin privilege. Others arguments remains the same.
What I don't understand is why you need the flexibility to choose between admin and non-admin on the Perl side, and you don't need in on the shell side.
Signature · 2 lines
Matthieu Moy http://www-verimag.imag.fr/~moy/
Re: [PATCH 2/3] Test environment of git-remote-mw
Quoted 8 lines · Matthieu Moy
Quoted 6 lines · Simon.Cathebras
Quoted 6 lines
t/test-gitmw-lib.sh line 35
Quoted 3 lines
t/test-gitmw-lib.sh +3
-0+wiki_getpage () { + ../test-gitmw.pl get_page -p "$1" "$2" +}Any reason why test-gitmw.pl and
wiki_getpagehave this slightly different API? The perl version has a "-p" flag, and the shell command has only positionnal arguments.
Quoted 4 lines
Quoted 2 lines
The "-p" flag exists to specify if we have to use the admin login on wiki to do the command.
(then, maybe --admin would be a better name?)
I am ok with this... It would be more understandable.
Quoted 6 lines
Quoted 2 lines
For instance, here we fetch a page from the wiki with Admin privilege. Others arguments remains the same.
What I don't understand is why you need the flexibility to choose between admin and non-admin on the Perl side, and you don't need in on the shell side.
On one hand, we need to be authentificated as an admin to do some wiki's operations, like deleting a page for instance. It is needed by the Perl. On the other hand, we don't need it on the shell side because we believe that we don't have to bother the user with some authentification consideration.
I mean, if I intend to delete the page <foo> from wiki, it is easier to call 'wiki_delete_page foo', than 'wiki_delete_page --user=thingumy --pass=blahblah foo'.
Does it make sense ? If not, what do you think we should do ?
Simon
Signature · 6 lines
CATHEBRAS Simon 2A-ENSIMAG Filière Ingéniérie des Systèmes d'Information Membre Bug-Buster
PATCH 3/3 Tests file for git-remote-mediawiki
In reply to Guillaume SasdyFrom: Charles Roussel <[email protected]>
Those scripts test the functions of git-remote-mediawiki.
t9360: simple test case for git clone.
t9361: simple test cases for git pull (add page, edit page, delete page) and git push (add file, edit file, delete file).
--- t/t9360-git-mediawiki.sh | 49 +++++++++++++++ t/t9361-git-mediawiki.sh | 156 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 205 insertions(+) create mode 100755 t/t9360-git-mediawiki.sh create mode 100755 t/t9361-git-mediawiki.sh
t/t9360-git-mediawiki.sh new file +49 -0
@@ -0,0 +1,49 @@ +#!/bin/sh +# +# Copyright (C) 2012 +# Charles Roussel <[email protected]> +# Simon Cathebras <[email protected]> +# Julien Khayat <[email protected]> +# Guillaume Sasdy <[email protected]> +# Simon Perrat <[email protected]> +# Matthieu Moy <[email protected]> +# +# License: GPL v2 or later + +# tests for git-remote-mediawiki + +test_description='Test the Git Mediawiki remote helper: git clone' + +. ./test-gitmw-lib.sh +. ./test-lib.sh + +if ! test_have_prereq PERL +then + skip_all='skipping gateway git-mw tests, perl not available' + test_done +fi + +if [ ! -f /$GIT_BUILD_DIR/git-remote-mediawiki ]; +then + skip_all='skipping gateway git-mw tests, no remote mediawiki for git found' + test_done +fi + +if [ ! -d "$WIKI_DIR_INST/$WIKI_DIR_NAME" ] ; +then + skip_all='skipping gateway git-mw tests, no mediawiki found' + test_done +fi + +test_expect_success 'git clone works with page added' ' + wiki_reset && + wiki_editpage foo "hello_world" false && + wiki_editpage bar "hi everybody !" false && + git clone mediawiki::http://localhost/wiki mw_dir && + wiki_getallpage ref_page && + git_content mw_dir ref_page && + wiki_delete_page foo && + wiki_delete_page bar +' + +test_done
t/t9361-git-mediawiki.sh new file +156 -0
156 lines not on this page · raw message
Signature · 1 line
1.7.10.2.568.g4c26a3a