Patchwork D1816: tests: make #testcase available as env var in test

login
register
mail settings
Submitter phabricator
Date Jan. 6, 2018, 6:32 a.m.
Message ID <7297633ecfa6732aaeddbb687ec2934f@localhost.localdomain>
Download mbox | patch
Permalink /patch/26579/
State Not Applicable
Headers show

Comments

phabricator - Jan. 6, 2018, 6:32 a.m.
martinvonz updated this revision to Diff 4730.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1816?vs=4716&id=4730

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

AFFECTED FILES
  tests/run-tests.py
  tests/test-run-tests.t

CHANGE DETAILS




To: martinvonz, #hg-reviewers, quark, yuja
Cc: yuja, 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
@@ -1533,6 +1533,26 @@ 
   python hash seed: * (glob)
   [1]
 
+Test TESTCASE variable
+
+  $ cat > test-cases-ab.t <<'EOF'
+  >   $ dostuff() {
+  >   >   echo "In case $TESTCASE"
+  >   > }
+  > #testcases A B
+  > #if A
+  >   $ dostuff
+  >   In case A
+  > #endif
+  > #if B
+  >   $ dostuff
+  >   In case B
+  > #endif
+  > EOF
+  $ rt test-cases-ab.t
+  ..
+  # Ran 2 tests, 0 skipped, 0 failed.
+
 Test automatic pattern replacement
 
   $ cat << EOF >> common-pattern.py
diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1334,6 +1334,9 @@ 
             script.append(b'alias hg="%s"\n' % self._hgcommand)
         if os.getenv('MSYSTEM'):
             script.append(b'alias pwd="pwd -W"\n')
+        if self._case:
+            script.append(b'TESTCASE=%s\n' % shellquote(self._case))
+            script.append(b'export TESTCASE\n')
 
         n = 0
         for n, l in enumerate(lines):