diff tests/test-run-tests.t @ 35536:f04d16bef2c7

tests: make #testcase available as env var in test It can be useful for e.g. helper functions to behave differently depending on which test case is being executed. This patch helps with that by making the #testcase case available as a TESTCASE environment variable. Differential Revision: https://phab.mercurial-scm.org/D1816
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 05 Jan 2018 11:53:33 -0800
parents 417fa23017f9
children 69d7fcd91696
line wrap: on
line diff
--- a/tests/test-run-tests.t	Fri Jan 05 19:30:37 2018 +0530
+++ b/tests/test-run-tests.t	Fri Jan 05 11:53:33 2018 -0800
@@ -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