git-remote-mediawiki: allow stop/start-ing the test server
[gitweb.git] / contrib / mw-to-git / t / test-gitmw-lib.sh
index 3b2cfacf512b0476c157e475b3ad6ea15cadeb2b..d9a114995a0f75434fc105ce7be508293da49227 100755 (executable)
@@ -62,12 +62,8 @@ test_check_precond () {
                test_done
        fi
 
-       if [ ! -f "$GIT_BUILD_DIR"/git-remote-mediawiki ];
-       then
-               echo "No remote mediawiki for git found. Copying it in git"
-               echo "cp $GIT_BUILD_DIR/contrib/mw-to-git/git-remote-mediawiki $GIT_BUILD_DIR/"
-               ln -s "$GIT_BUILD_DIR"/contrib/mw-to-git/git-remote-mediawiki "$GIT_BUILD_DIR"
-       fi
+       GIT_EXEC_PATH=$(cd "$(dirname "$0")" && cd "../.." && pwd)
+       PATH="$GIT_EXEC_PATH"'/bin-wrapper:'"$PATH"
 
        if [ ! -d "$WIKI_DIR_INST/$WIKI_DIR_NAME" ];
        then
@@ -95,7 +91,7 @@ test_diff_directories () {
 # Check that <dir> contains exactly <N> files
 test_contains_N_files () {
        if test `ls -- "$1" | wc -l` -ne "$2"; then
-               echo "directory $1 sould contain $2 files"
+               echo "directory $1 should contain $2 files"
                echo "it contains these files:"
                ls "$1"
                false
@@ -293,7 +289,6 @@ start_lighttpd () {
 # Kill daemon lighttpd and removes files and folders associated.
 stop_lighttpd () {
        test -f "$WEB_TMP/pid" && kill $(cat "$WEB_TMP/pid")
-       rm -rf "$WEB"
 }
 
 # Create the SQLite database of the MediaWiki. If the database file already
@@ -336,20 +331,21 @@ wiki_install () {
        fi
 
        # Fetch MediaWiki's archive if not already present in the TMP directory
+       MW_FILENAME="mediawiki-$MW_VERSION_MAJOR.$MW_VERSION_MINOR.tar.gz"
        cd "$TMP"
-       if [ ! -f "$MW_VERSION.tar.gz" ] ; then
-               echo "Downloading $MW_VERSION sources ..."
-               wget "http://download.wikimedia.org/mediawiki/1.19/mediawiki-1.19.0.tar.gz" ||
+       if [ ! -f $MW_FILENAME ] ; then
+               echo "Downloading $MW_VERSION_MAJOR.$MW_VERSION_MINOR sources ..."
+               wget "http://download.wikimedia.org/mediawiki/$MW_VERSION_MAJOR/$MW_FILENAME" ||
                        error "Unable to download "\
-                       "http://download.wikimedia.org/mediawiki/1.19/"\
-                       "mediawiki-1.19.0.tar.gz. "\
+                       "http://download.wikimedia.org/mediawiki/$MW_VERSION_MAJOR/"\
+                       "$MW_FILENAME. "\
                        "Please fix your connection and launch the script again."
-               echo "$MW_VERSION.tar.gz downloaded in `pwd`. "\
+               echo "$MW_FILENAME downloaded in `pwd`. "\
                        "You can delete it later if you want."
        else
-               echo "Reusing existing $MW_VERSION.tar.gz downloaded in `pwd`."
+               echo "Reusing existing $MW_FILENAME downloaded in `pwd`."
        fi
-       archive_abs_path=$(pwd)/"$MW_VERSION.tar.gz"
+       archive_abs_path=$(pwd)/$MW_FILENAME
        cd "$WIKI_DIR_INST/$WIKI_DIR_NAME/" ||
                error "can't cd to $WIKI_DIR_INST/$WIKI_DIR_NAME/"
        tar xzf "$archive_abs_path" --strip-components=1 ||
@@ -418,6 +414,7 @@ wiki_reset () {
 wiki_delete () {
        if test $LIGHTTPD = "true"; then
                stop_lighttpd
+               rm -fr "$WEB"
        else
                # Delete the wiki's directory.
                rm -rf "$WIKI_DIR_INST/$WIKI_DIR_NAME" ||
@@ -431,5 +428,5 @@ wiki_delete () {
        # Delete the wiki's SQLite database
        rm -f "$TMP/$DB_FILE" || error "Database $TMP/$DB_FILE could not be deleted."
        rm -f "$FILES_FOLDER/$DB_FILE"
-       rm -rf "$TMP/$MW_VERSION"
+       rm -rf "$TMP/mediawiki-$MW_VERSION_MAJOR.$MW_VERSION_MINOR.tar.gz"
 }