Mercurial > hgrepos > DevTools > mercurial-extensions
diff tests/lib-test-revinfo.sh @ 251:e19782e7b21c
Add unit-tests for the "revinfo" extension
| author | Franz Glasner <hg@dom66.de> |
|---|---|
| date | Sun, 06 Jan 2019 23:53:34 +0100 |
| parents | |
| children | b8fc7f0990e7 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/lib-test-revinfo.sh Sun Jan 06 23:53:34 2019 +0100 @@ -0,0 +1,62 @@ +#!/bin/sh + +# +# Preconditions for a manual setup: +# +# - cd tests +# - . ./lib-test-revinfo.sh +# - TESTDIR=`pwd`; export TESTDIR +# + +# +# Prepare a "canonical" repository for testing the kwarchive extension +# +# prepare_repo REPO +# +prepare_repo() { + if [ -z "$TESTDIR" ]; then + echo "TESTDIR is not set" + return 1 + else + if [ ! -f "$TESTDIR/../extensions/kwarchive.py" ]; then + echo "Wrong TESTDIR setup" + return 1 + fi + LOCAL_TESTDIR="$TESTDIR" + fi + if [ -z "$HGRCPATH" ]; then + # + # Check whether we are running in the context of Mercurial's + # run-tests.py + # + if [ "$TESTTMP" = "$HOME" ]; then + echo "HGRCPATH is not set" + return 1 + else + # Path after changing wd into $1 + LOCAL_HGRCPATH=".hg/hgrc" + fi + else + LOCAL_HGRCPATH="$HGRCPATH" + fi + hg init "$1" + cd "$1" + cat >>$LOCAL_HGRCPATH <<EOF +[extensions] +revinfo=$LOCAL_TESTDIR/../extensions/revinfo.py +[ui] +username=First Second <first.second@example.com> +[paths] +default=https://theuser:thepass@hg.example.com:4443/repo.hg +EOF + unset HGUSER + unset EMAIL + + cat >>test.txt <<EOF +Test content +EOF + hg add test.txt + hg ci -m 'Some files' + + cd .. +}
