#!/bin/bash
#
#   vc-test.sh -- Test suite for distributed version control systems
#
#       Copyright (C) 2009 Jari Aalto
#
#   License
#
#       This program is free software; you can redistribute it and/or
#       modify it under the terms of the GNU General Public License as
#       published by the Free Software Foundation; either version 2 of
#       the License, or (at your option) any later version.
#
#       This program is distributed in the hope that it will be useful, but
#       WITHOUT ANY WARRANTY; without even the implied warranty of
#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#       General Public License for more details.
#
#       You should have received a copy of the GNU General Public License
#       along with program. If not, write to the Free Software
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
#       02110-1301, USA.
#
#       Visit <http://www.gnu.org/copyleft/gpl.html>

VERSION="2009.0828.2221"
TEMPDIR=${TEMPDIR:-/tmp}
LC_ALL=C

#  Command line options will set these global variables
CMD=
PATCH=
PATCH_OPT=
PATCH_UNOPT=
REPO_INIT_OPT=
BZR_SHARED=
SSH_LOCAL=
SSH_REMOTE=
TEST=

# -T      Disable pseudo-tty allocation.
# -x      Disables X11 forwarding.

SSH_OPT="-T -x"
SSHCMD="ssh $SSH_OPT"

[ "$BASH" = "/usr/bin/bash" ] || [ "$BASH" = "/bin/bash" ] ||
{
    prg="$0"

    # If we did not find ourselves, most probably we were run as
    # 'sh PROGRAM' in which case we are not to be found in the path.

    if [ -f "$prg" ]; then
        [ -x /bin/bash ] && exec /bin/bash "$prg" ${1+"$@"}
    fi

    echo "$0 [FATAL] $prg called with wrong shell: needs bash" >&2
    exit 1 ;
}

Help ()
{
    echo "\
NAME

$0 - Test suite for version control systems

SYNOPSIS

$0 [option] {--command CMD}

OPTIONS

   -b, --bzr-shared
	Only valid with '-c bzr'. Create a shared repository
	with command 'cd .. ; bzr init-repository -q \$REPO_INIT_OPT'.

	This effectively enables Bzr to use shared repositories for
	branches, which is the 'normal' case for Bzr use. Use this
	option for more non-biased branching results.

    -c, --command CMD
	Version control command: git, hg, bzr.
        This option is mandatory to select DCVS to test.

    -d, --tempdir TEMPDIR
	Temporary directory to use.

    -h, --help
	Help

    -i, --init-opt REPO_INIT_OPT
	Options for 'init' command. E.g. to use
	different repository format for Bzr:

	-c bzr -i '--2a'

    -p, --patch-file FILE
	Patch with FILE

    -P, --patch-opt OPT
	Patch options, like '-p2'

    -R, --unpatch-opt OPT
	Reverse patch options to cancel -p FILE. E.g. '-p2 -R'

    -s, --ssh-local URL
	The current host's SSH URL. This option is used in 'pull repo
	from network' test. Format is login name and FQDN how to
	access current host from outside. An example:
	login@localhost.example.com

	The local directory information is not supplied, because the
	program will use current DVCS directory it has created,

    -S, --ssh-remote URL
	The remote host's SSH URL. This option is used in 'push repo
	over network' test. Format is login name, FQDN and directory:
	login@remote.example.com:/absolute/path

    -t, --test, --dry-run
        Run in test more. No commands are really done.

    -w, --www-remote URL
	The remote host's HTTP URL. This option is used to test
	'http pull over network'. Format is SSH style URL
	login@remote:public_html/dir

	TODO: Not yet implemented.

    -V, --version
        Print program version.

DESCRIPTION

    Test suite for Git, Hg and Bzr DVCS. Copy the source code to test
    in this clean layout:

	top-level/
	+- code-to-test.patch
	|
	+-code-to-test/
	  'cd here'


    1. cd to the source directory 'code-to-test/'. This and the
       top-level/ must be completely pure: just unpacked sources
       and possible patch file.

       ** WARNING: all temporary VCS directories (.bzr, .git etc.) and
       other temporary directories used (?.[a-z]*) will be deleted
       in code-to-test/ and top-level/

    2. If you hava a patch (see picture) at hand to test changing
       multiple files, supply it with option '-p'. This runs
       additional tests, like 'add, commit, log' for after
       applying the patch.

    3. If you want to test cloning over network using SSH, please
       supply option --ssh-remote (push) and possibly --ssh-local
       (pull).

    Note: option --bzr-shared tests use special branching that utilize
    so clled shared repository and lightweight checkouts in the
    top-level/ directory.

    About Network tests
    -------------------

    In order for the SSH network test to succeed, the remote site must
    have DVCS program installed.

    Ensure also that you have ssh-agent(1) running and keys have been
    distributed to ~/.ssh/ directories to avoid login questions.

    The destination directory at remote host must be given
    in absolute path name.

EXAMPLES

    The Following command tests Bzr using shared repositories with
    repo format '--2a'. A patch file and how to apply/deapply it is
    given. The patch file has been prepared beforehand and it will
    upgrade kernel to 2.6.NN+1. The patch is a simple recursive
    diff(1) result between the two kernels. Lastly, the network 'push
    repo' performance is measured with option --ssh-remote.

    All is run in --test mode (shows what commands would run):

	cd /tmp/test/linux-2.6.NN
	bash $0 \\
	    --patch-file ../*.patch \\
	    --patch-opt '-p2' \\
	    --unpatch-opt '-p2 -R' \\
	    --command bzr \\
	    --bzr-shared \\
	    --init-opt '--2a' \\
	    --ssh-remote foo@example.com:/tmp \\
	    --test

TECHNICAL INFORMATION

    The test program runs series of commands that are 'translated'
    to the DVCS in use. There are few notable tests that are
    specifically designed for Bzr and this section intends to
    document how they are conducted.

    With option '--bzr-shared', the followin layout is used:

	top-level/	bzr init-repository --no-trees \$INITOPT
	|
	+-code-to-test/ NOT USED AT ALL FOR TESTS
	|
	+- x.trunk	bzr init -q x.trunk
	|
	|
	+- x.working	bzr co --lightweight x.working
			cp -r code-to-test/* x.working
			bzr add -q .
			bzr ci -q -m initial

    The picture reads: use x.working for all tests, it is a
    lightweight checkout of x.trunk

    Cloning
    --------

    To continue with Bzr, there are 3 clone tests:

    *) clone 'pure'

	bzr branch FROM/x.working DEST

    *) clone stacked

	bzr branch --stacked FROM/x.trunk DEST.stacked

    *) clone to another shared repo

	cd DEST
	bzr init-repository \$INTIOPT
	bzr co -q FROM/x.trunk x.trunk
	bzr branch x.trunk x.working

VARIABLES

    TEMPDIR defaults to /tmp. Used for temporary files
	    and cloning. Can be set with option '-d'.

VERSION

    $VERSION

DEPENDS

    bash
    ssh
    git, hg, bzr
    patch
    lsdiff (from patchutils)

AUTHOR

    Copyright (C) Jari Aalto <jari.aalto@cante.net>

    This program is free software; you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by the Free
    Software Foundation; either version 2 of the License, or (at your option)
    any later version. See <http://www.gnu.org/copyleft/gpl.html>.
"
    exit 0
}

Warn ()
{
    echo "# $*" >&2
}

Die ()
{
    Warn "$*"
    exit 1
}

Date ()
{
    date "+%Y-%m-%d %H:%M:%S"
}

SumAwk ()
{
    awk '{ sum += $5 } END { printf "%.2f MiB\n", sum / (1024 * 1024) }' "$@"
}

SumDir ()
{
    [ "$1" ] || local dummy=$(pwd)	# For debugging

    ls -Rla $1 | SumAwk
}

Sum ()
{
    Run SumDir $1
}

PatchLevel ()
{
    [ "$1" ] || return 0

    local arg level=0

    #  -p2 -Rp2 -p2R

    for arg in "$@"
    do
	if [[ "$arg" == -*p* ]]; then
	    level=${arg#-*p}		# remove prefix
	    level=${level%%[!0-9]*}	# remove suffix
	    break
	fi
    done

    echo $level
}

IsBzrShared ()
{
    [ "$CMD" = "bzr" ] && [ "$BZR_SHARED" ]
}

EchoSection ()
{
    echo ""
    echo "# -----------------------------------------------------------"
    echo "# SECTION $*"
    echo "# -----------------------------------------------------------"
}

EchoNote ()
{
    echo "# -- $*"
}

Echo ()
{
    echo "# $*"
}

EchoSum ()
{
    Echo "SIZE ($1): " $(Sum ${2:-.} )
}

Run ()
{
    local eval=eval

    if [ "$1" = --no-eval ]; then
	shift
	eval=
    fi

    if [ "$TEST" ]; then
	echo "$*"
	return 0
    fi

    if [ "$eval" ]; then
	eval "$@"
    else
	"$@"
    fi
}

RunEcho ()
{
    if [ ! "$TEST" ]; then
	Echo "CMD: " $(echo $* | sed 's/--no-eval//')
    fi

    Run "$@"
}

Prepare ()
{
    EchoNote "Wait, cleaning directories..."
    Run rm -rf .git .bzr .hg .svn .cvs
    Run rm -rf ../.bzr ../?.[a-z]*
}

PrepareInit ()
{
    if IsBzrShared ; then
	Section "Bzr: creating shared repository"
	echo "# $(pwd)/.."
	CmdRun init-repository -q --no-trees $REPO_INIT_OPT .. || return 1
    fi
}

CmdRun ()
{
    if [ "$TEST" ] ; then
	echo "$CMD $*"
	return 0
    fi

    local dummy=$(pwd)			# For debugging

    echo "# CMD: $CMD $*"
    time Run "LC_ALL=C TERM= DISPLAY= BZR_PROGRESS_BAR=none $CMD $*"
}

CmdBzrShared ()
{
    # All commands must be run in separate 'working'
    # directory (lightweight checkout)
    #
    #	top-level/.bzr			# Shared repo, --no-trees
    #	|
    #	+- x.trunk
    #	+- x.working			# co --lightweight x.trunk
    #	   <sources are copied here>
    #

    local pwd=$(pwd)
    local src=${pwd##*/}		# last dir
    local top=${pwd%/*}			# one directory up
    local work=x.working

    (
	cd $top || return

	if [[ "$*" ==  init\ * ]]; then

	    echo "# Bzr: Make WORKING as workplace of TRUNK (data store)"
	    echo "# $(pwd)"

	    CmdRun init -q x.trunk &&
	    CmdRun checkout --lightweight x.trunk $work || return 1

	    echo "# Bzr: wait, copying sources to $(pwd)/$work"

	    Run mkdir -p $top/$work	 || return 1
	    Run cp -r $src/* $top/$work/ || return 1

	    return $?
	fi

	if [ "$TEST" ]; then
	    echo "cd $top/$work"
	else
	    cd $top/$work
	fi &&

	CmdRun "$*"
    )
}

Cmd ()
{
    local devnull=
    local file

    if [[ "$*" = diff* ]]; then
	#  pick any file for testing

	local level

	if [ "$PATCH_OPT" ]; then
	    level=$(PatchLevel $PATCH_OPT)
	fi

	if [ "$level" ] && [ "$PATCH" ]; then
	    file=$(lsdiff $PATCH | head -n 1)

	    # strip LEVEL count of slashes
	    # /path/to/dir/file.c => dir/file.c

	else
	    file=$(ls -l | awk '/^-r/ { print $(NF); exit }' )
	fi
    fi

    # Some special cases

    if [ "$CMD" = bzr ] && [[ "$*" == add* ]]; then
	# Bzr needs -q to not display messages
	set -- add -q .

    elif [ "$CMD" = bzr ] && [[ "$*" == diff* ]]; then
	devnull="> /dev/null"
	set -- diff -q -r1.. $file

    elif [ "$CMD" = hg ] && [[ "$*" == clone* ]]; then
	# Hg don't know -q options, remove
	set -- clone . $4

    elif [ "$CMD"  = hg ] && [[ "$*" == add* ]]; then
	# There is no -q option in "hg add"
	devnull="> /dev/null"

    elif [ "$CMD" = hg ] && [[ "$*" == diff* ]]; then
	devnull="> /dev/null"
	set -- diff -r tip -r -2 $file

    elif [ "$CMD"  = git ] && [[ "$*" == info* ]]; then
	set -- branch

    elif [ "$CMD"  = git ] && [[ "$*" == diff* ]]; then
	devnull="> /dev/null"
	set -- diff HEAD~100 $file
    fi

    if IsBzrShared ; then
	CmdBzrShared "$@" $devnull
	return $?
    fi

    CmdRun "$* $devnull"
}

CmdBranchCreate ()
{
    local dir=$1
    local name=${dir##*/}

    if [ "$CMD" = "bzr" ] ; then
	set -- branch . $dir
    elif [ "$CMD" = "hg" ] ; then
	set -- branch $name
    elif [ "$CMD" = "git" ] ; then
	# remove directory path
	set -- branch $name master
    fi

    CmdRun "$*"
}

TestPatchRun ()
{
    local file=$1
    local tmp=$TEMPDIR/$$.log

    EchoSection "Patch test: add, commit, log, diff"
    EchoNote "Count of patched files:" $(lsdiff $PATCH | wc -l)
    Echo $(pwd)

    #	Check for errors
    RunEcho "patch $PATCH_OPT < $file > $tmp"
    local status=$?

    Run "egrep -vi 'patching file|\<hunk.*\<succeeded' $tmp"

    if [ ! "$status" = "0" ]; then
	Warn "[WARN] Patch did not apply cleanly, check $tmp"
    fi

    Cmd add .
    Cmd commit -q -m patch
    Cmd log
    Cmd diff

    local dummy="PATCH_UNOPT: $PATCH_UNOPT"

    if [ "$PATCH_UNOPT" ]; then
	EchoNote "Unpatching"
	RunEcho "patch $PATCH_UNOPT < $file > /dev/null"
    fi
}

TestPatchMain ()
{
    if [ "$PATCH" ]; then
	TestPatchRun "$PATCH" &&
	EchoSum "repository + patch"
    fi
}

TestsBzrCloneShared ()
{
    #  For Bzr to be effective in cloning, it should have
    #  shared repository, where a REPO is checked out.

    EchoNote "Bzr: clone test using shared repo $(pwd)"

    local dir=$1

    local pwd=$(pwd)
    local name=${dir##*/}
    local root=${dir%/*}

    Run rm -rf $dir	|| return 1
    Run mkdir -p $root	|| return 1

    (
	Run cd $root	|| return 1
	echo "# $(pwd)"

	CmdRun init-repository $REPO_INIT_OPT $name &&

	Run cd $name &&
	echo "# $(pwd)" &&

	CmdRun checkout -q $pwd/../x.trunk x.trunk &&
	CmdRun branch -q x.trunk x.working &&

	EchoSum "clone to shared repo)" $dir
    )
}

TestsBzrCloneStacked ()
{
    # http://doc.bazaar-vcs.org/latest/en/user-guide/index.html#using-stacked-branches

    # A stacked branch is a branch that knows how to find revisions in
    # another branch. Stacked branches store just the unique
    # revisions, making them faster to create and more storage
    # efficient. In these respects, stacked branches are similar to
    # shared repositories.
    #
    # The stacked command effectively pulls only the latest revision
    # from the source branch, and notes that any history-referencing
    # operations must refer to the source branch.
    #
    # Stacked branches involve a trade-off between saving disk space
    # and incurring network delay. Although the full history is not
    # downloaded, any operation requiring history, such as log or diff
    # to an earlier revision, requires accessing the source branch. In
    # the case above, such operations will require network access.

    EchoSection "clone test: stacked branching"

    local dir=$1.stacked
    local root=${dir%/*}

    Run rm -rf $dir	|| return 1
    Run mkdir -p $root	|| return 1

    local src=.

    IsBzrShared && src=../x.trunk

    (
	Run cd $src &&

	echo "# $(pwd)" &&
	CmdRun info &&
	CmdRun branch -q --stacked . $dir
    )

    EchoSum "clone stacked" $dir
}

TestCloneBzr ()
{
    [ "$CMD" = bzr ] || return 0

    local default=$TEMPDIR/${LOGNAME:-foo}
    local dir=${1:-$default}
    local root=${dir%/*}

    Run rm -rf $dir	|| return 1
    Run mkdir -p $root	|| return 1

    TestsBzrCloneStacked $dir

    if IsBzrShared ; then
	Run rm -rf $dir	    || return 1
	Run mkdir -p $root  || return 1

	TestsBzrCloneShared $dir
    fi
}

TestCloneSshRemotePush ()
{
    [ "$SSH_REMOTE" ] || return 0

    EchoSection "Clone test: network SSH push"
    Echo $(Date)

    if [ "$CMD" = git ]; then
	#   FIXME:
	#   - Have do make a remote repository
	#   - git remote add ...
	#   - git push ...

	EchoNote "No Git 'clone push' test implemented"
	return 0
    fi

    local remote=${SSH_REMOTE%%:*}
    local dir=${SSH_REMOTE##*:}
    local rdir=$dir			# remote dir
    local repo=x.test.tmp

    # Strip leading slash. The location is relative to USER

    [ "$CMD" = hg  ] && rdir=${rdir#/}
    # [ "$CMD" = bzr ] && rdir=${rdir#/}

    local repodir=$rdir/$repo		# remote dir

    RunEcho --no-eval $SSHCMD $remote "rm -rf $repodir"

    local pwd=$(pwd)
    Echo $pwd

    local scheme=ssh

    [ "$CMD" = bzr ] && scheme=bzr+ssh

    local proto=$scheme://

    if [ "$CMD" = git ]; then
	#  Git uses Ssh format 'login@host:'
	proto=
	remote=$remote:
    fi

    local url=$proto$remote$dir/$repo

    CmdRun clone -q . $url || return $?
    Echo $(Date)

    local tmp=$TEMPDIR/$$.lst

    Echo "Wait, measuring remote repository size..."
    Run --no-eval $SSHCMD $remote "ls -laR $repodir" > $tmp

    Echo "SIZE (remote push): " $(SumAwk $tmp)
}

TestCloneSshRemotePull ()
{
    [ "$SSH_REMOTE" ] || return 0
    [ "$SSH_LOCAL"  ] || return 0

    EchoSection "Clone test: network SSH pull"
    Echo $(Date)

    local host=$SSH_LOCAL
    local host=${host%:}

    local remote=${SSH_REMOTE%%:*}

    local dir=${SSH_REMOTE##*:}
    local rdir=$dir			# remote dir
    local repo=x.test.tmp

    # Strip leading slash. The location is relative to USER

    [ "$CMD" = hg  ] && rdir=${rdir#/}

    local repodir=$rdir/$repo		# remote dir

    RunEcho --no-eval $SSHCMD $remote "rm -rf $repodir"

    local pwd=$(pwd)
    Echo $pwd

    local scheme=ssh
    local proto=

    [ "$CMD" = bzr ] && scheme=bzr+ssh

    proto=$scheme://

    if [ "$CMD" = git ]; then
	host=$host:
	proto=
    fi

    local url=$proto$host$pwd

    RunEcho --no-eval $SSHCMD $remote \
	"time $CMD clone -q $url $repodir"

    Echo $(Date)

    local tmp=$TEMPDIR/$$.lst

    Echo "Wait, measuring remote repository size..."
    Run --no-eval $SSHCMD $remote "ls -laR $repodir" > $tmp

    Echo "SIZE (remote pull): " $(SumAwk $tmp)
}

TestCloneLightweight ()
{
    EchoSection "Clone test: lightweight, shallow"

    local default=$TEMPDIR/${LOGNAME:-foo}
    local dir=${1:-$default}
    local root=${dir%/*}

    Run rm -rf $dir	|| return 1
    Run mkdir -p $root	|| return 1

    if [ "$CMD" = bzr ]; then

	Cmd checkout --lightweight . $dir

    elif [ "$CMD" = git ]; then

	Cmd clone --depth 1 . $dir

    elif [ "$CMD" = hg ]; then
	EchoNote "Feature not available in Hg"
	return 0
    fi

    EchoSum "clone lightweight" $dir
}

TestCloneMain ()
{
    EchoSection "Clone test: local full clone"

    local default=$TEMPDIR/${LOGNAME:-foo}
    local dir=${1:-$default}
    local root=${dir%/*}

    Run rm -rf $dir	|| return 1
    Run mkdir -p $root	|| return 1

    Cmd clone -q . $dir

    EchoSum "clone" $dir
}

TestsBzrLightweight ()
{
    EchoNote "Bzr: testing shared branching and switching in $(pwd)"

    for dest in 1 2 3
    do
	local name=x.$dest.branch
	local dir=../$name

	Run rm -rf $dir || return 1

	Cmd branch ../x.trunk ../$name || return 1
	Cmd switch $name || return 1
    done
}

TestBranchMain ()
{
    #	Create nultiple branches NOTE: For Bzr to be effective, it
    #	should use shared repositories. See -i option.

    EchoSection "Branching speed tests"

    if IsBzrShared ; then
	TestsBzrLightweight
	return $?
    fi

    local dest dir

    for dest in 1 2 3
    do
	dir=../$dest.branch
	Run rm -rf $dir		|| return 1
	CmdBranchCreate $dir	|| return 1
    done

    #	There is really nothing to test. 'git branch' is blinding
    #	fast

    [ "$CMD" = "git" ] && return 0
}

TestStandard ()
{
    Cmd add . &&
    Cmd commit -q -m initial &&
    EchoSum "repository"
}

VerifyVariables ()
{
    # Check variables that were set by line options

    if [ ! "$CMD" ]; then
	Die "Missing command. See option -c CMD"
    fi

    TEMPDIR=${TEMPDIR%/}		# Delete trailing slash

    if [ ! -d "$TEMPDIR" ]; then
	Die "\$TEMPDIR is not a directory: $TEMPDIR"
    fi
}

Main ()
{
    EchoNote "DVCS Tester $VERSION"
    Echo "CMD: $0 $*"

    while :
    do
        case "$1" in
        -b|--bzr-shared)
	    BZR_SHARED="bzr shared"
	    shift
	    ;;
        -c|--command)
            CMD=$2
	    shift 2
            ;;
        -d|--tempdir)
	    TEMPDIR=$2
	    shift 2
            ;;
        -h|--help)
	    Help
            ;;
	-i|--init-opt)
	    REPO_INIT_OPT=$2
	    shift 2
	    ;;
        -p|--patch-file)
	    PATCH=$2

	    if [ ! -f "$PATCH" ]; then
		Die "[WARN] file does not exist: $PATCH"
	    fi

	    shift 2
            ;;
        -P|--patch-opt)
	    PATCH_OPT=$2
	    shift 2
            ;;
        -R|--unpatch-opt)
	    PATCH_UNOPT=$2
	    shift 2
            ;;

	-s|--ssh-local)
	    SSH_LOCAL=$2
	    shift 2

	    if [[ ! "$SSH_LOCAL" == *@* ]]; then
		Die "[ERROR] No at-sign '@' in $SSH_LOCAL"
	    fi

	    if [[ "$SSH_LOCAL" == root@* ]]; then
		Die "[ERROR] root login not accepted in $SSH_LOCAL"
	    fi

	    if [[ "$SSH_LOCAL" == *:* ]]; then
		Die "[ERROR] Invalid colon character in $SSH_LOCAL"
	    fi

	    if [[ "$SSH_LOCAL" == */* ]]; then
		Die "[ERROR] Invalid '/' character in $SSH_LOCAL"
	    fi

	    ;;

	-S|--ssh-remote)
	    SSH_REMOTE=$2
	    shift 2

	    SSH_REMOTE=${SSH_REMOTE%/}	# strip trailing slash

	    if [[ ! "$SSH_REMOTE" == *@* ]]; then
		Die "[ERROR] No at-sign '@' in $SSH_REMOTE"
	    fi

	    if [[ "$SSH_REMOTE" == root@* ]]; then
		Die "[ERROR] root login not accepted in $SSH_REMOTE"
	    fi

	    if [[ ! "$SSH_REMOTE" == *:* ]]; then
		Die "[ERROR] No destination dir in $SSH_REMOTE"
	    fi

	    if [[ ! "$SSH_REMOTE" == *:/[a-zA-Z]* ]]; then
		Die "[ERROR] No absolute path after colon in $SSH_REMOTE"
	    fi

	    ;;

        -t|--test|--dry-ryn)
	    TEST=test
	    shift
	    ;;
        -V|--version)
	    echo $VERSION
	    return 0
	    ;;
         --)
	    local dummy="End of options"
	    break
	    ;;
         *)
	    local dummy="Non option: $*"
	    break
            ;;
        esac
    done

    VerifyVariables
    Prepare
    EchoSum "original sources"

    CmdRun --version

    PrepareInit		    || return 1

    EchoSection "Import test: storing sources to repository"

    Echo $(pwd)
    Cmd init -q $REPO_INIT_OPT

    TestStandard	    || return 1
    TestPatchMain	    || return 1
    TestBranchMain

    TestCloneMain	    || return 1
    TestCloneLightweight    || return 1

    TestCloneBzr	    || return 1

    TestCloneSshRemotePush
    TestCloneSshRemotePull
}

Main "$@"

# End of file

