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

login
register
mail settings
Submitter phabricator
Date Jan. 5, 2018, 9:05 p.m.
Message ID <dcd696c4d75e745cc828090e501647e3@localhost.localdomain>
Download mbox | patch
Permalink /patch/26575/
State Not Applicable
Headers show

Comments

phabricator - Jan. 5, 2018, 9:05 p.m.
martinvonz updated this revision to Diff 4716.
martinvonz marked an inline comment as done.

REPOSITORY
  rHG Mercurial

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

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
Cc: 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,8 @@ 
             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))
 
         n = 0
         for n, l in enumerate(lines):