Patchwork D11034: test-run-test: use explicit variable to clarify path

login
register
mail settings
Submitter phabricator
Date July 9, 2021, 11:48 a.m.
Message ID <differential-rev-PHID-DREV-5johilzhazuatfjzgsck-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49348/
State Superseded
Headers show

Comments

phabricator - July 9, 2021, 11:48 a.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Since TESTTMP and TESTDIR are defined for both the main scope and the test run
  during the test, the situation get confusing. To work around that, we define
  some explicit variable with the value we needs.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11034

AFFECTED FILES
  tests/test-run-tests.t

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t
--- a/tests/test-run-tests.t
+++ b/tests/test-run-tests.t
@@ -1381,8 +1381,28 @@ 
 Test reusability for third party tools
 ======================================
 
-  $ mkdir "$TESTTMP"/anothertests
-  $ cd "$TESTTMP"/anothertests
+  $ THISTESTDIR="$TESTDIR"
+  $ export THISTESTDIR
+  $ THISTESTTMP="$TESTTMP"
+  $ export THISTESTTMP
+
+#if windows
+
+  $ NEWTESTDIR="$THISTESTTMP"\\anothertests
+
+#else
+
+  $ NEWTESTDIR="$THISTESTTMP"/anothertests
+
+#endif
+
+  $ export NEWTESTDIR
+
+  $ echo creating some new test in: $NEWTESTDIR
+  creating some new test in: $TESTTMP\anothertests (windows !)
+  creating some new test in: $TESTTMP/anothertests (no-windows !)
+  $ mkdir "$NEWTESTDIR"
+  $ cd "$NEWTESTDIR"
 
 test that `run-tests.py` can execute hghave, even if it runs not in
 Mercurial source tree.
@@ -1400,22 +1420,20 @@ 
 test that RUNTESTDIR refers the directory, in which `run-tests.py` now
 running is placed.
 
+
   $ cat > test-runtestdir.t <<EOF
-  > - $TESTDIR, in which test-run-tests.t is placed
-  > - \$TESTDIR, in which test-runtestdir.t is placed (expanded at runtime)
-  > - \$RUNTESTDIR, in which run-tests.py is placed (expanded at runtime)
+  > # \$THISTESTDIR, in which test-run-tests.t (this test file) is placed
+  > # \$THISTESTTMP, in which test-run-tests.t (this test file) is placed
+  > # \$TESTDIR, in which test-runtestdir.t is placed (expanded at runtime)
+  > # \$RUNTESTDIR, in which run-tests.py is placed (expanded at runtime)
   > 
-  > #if windows
-  >   $ test "\$TESTDIR" = "$TESTTMP\\anothertests"
-  > #else
-  >   $ test "\$TESTDIR" = "$TESTTMP"/anothertests
-  > #endif
+  >   $ test "\$TESTDIR" = "\$NEWTESTDIR"
   > If this prints a path, that means RUNTESTDIR didn't equal
-  > TESTDIR as it should have.
-  >   $ test "\$RUNTESTDIR" = "$TESTDIR" || echo "\$RUNTESTDIR"
+  > THISTESTDIR as it should have.
+  >   $ test "\$RUNTESTDIR" = "\$THISTESTDIR" || echo "\$RUNTESTDIR"
   > This should print the start of check-code. If this passes but the
   > previous check failed, that means we found a copy of check-code at whatever
-  > RUNTESTSDIR ended up containing, even though it doesn't match TESTDIR.
+  > RUNTESTSDIR ended up containing, even though it doesn't match THISTESTDIR.
   >   $ head -n 3 "\$RUNTESTDIR"/../contrib/check-code.py | sed 's@.!.*python3@#!USRBINENVPY@'
   >   #!USRBINENVPY
   >   #