changeset 270:89ce8d4b55cf

Help for for manual tests setup when using "lib-test-timestamps.sh": 1. Check required environment settings 2. Some minimal documentation
author Franz Glasner <hg@dom66.de>
date Fri, 04 Jan 2019 17:34:13 +0100
parents 1e375da37f2e
children 56656dab50c4
files tests/lib-test-timestamps.sh
diffstat 1 files changed, 35 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/tests/lib-test-timestamps.sh	Fri Jan 04 17:09:30 2019 +0100
+++ b/tests/lib-test-timestamps.sh	Fri Jan 04 17:34:13 2019 +0100
@@ -1,12 +1,44 @@
 #!/bin/sh
 
 #
+# Preconditions for a manual setup:
+#
+#   - cd tests
+#   - . lib-test-timestamps.sh
+#   - TESTDIR=`pwd`; export TESTDIR
+#
+
+#
 # Prepare a "canonical" repository for testing the timestamps extension
 #
 # prepare_repo REPO SHOW_OUTPUT
 #
 prepare_repo() {
-    if [ -z "$HGRCPATH" ]; then echo "HGRCPATH is not set"; return 1; fi
+    if [ -z "$TESTDIR" ]; then
+	echo "TESTDIR is not set"
+	return 1
+    else
+	if [ ! -f "$TESTDIR/../extensions/timestamps.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
     SHOW_OUTPUT="$2"
     hg init "$1"
     cd "$1"
@@ -14,9 +46,9 @@
 [patterns]
 files/** =
 EOF
-    cat >>$HGRCPATH <<EOF
+    cat >>$LOCAL_HGRCPATH <<EOF
 [extensions]
-timestamps=$TESTDIR/../extensions/timestamps.py
+timestamps=$LOCAL_TESTDIR/../extensions/timestamps.py
 EOF
     hg add .hgtimestamps
     hg ci -m 'Activate timestamps'