[PATCH 13 of 14] tests/hghave: implement #if true / #if false

Adrian Buehlmann adrian at cadifra.com
Fri Jun 8 08:18:53 CDT 2012


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1339161065 -7200
# Node ID fef7294bb8184c9c5a2a542148fbb15de62f31a4
# Parent  60fed8d848740a23b8539ea5f1e11c29229179db
tests/hghave: implement #if true / #if false

For unconditionally testing / skipping a section. Useful for testing the test
infrastructure in test-run-tests.t and for debugging/developing tests.

diff --git a/tests/hghave b/tests/hghave
--- a/tests/hghave
+++ b/tests/hghave
@@ -241,6 +241,8 @@
     return os.getenv('MSYSTEM')
 
 checks = {
+    "true": (lambda: True, "yak shaving"),
+    "false": (lambda: False, "nail clipper"),
     "baz": (has_baz, "GNU Arch baz client"),
     "bzr": (has_bzr, "Canonical's Bazaar client"),
     "bzr114": (has_bzr114, "Canonical's Bazaar client >= 1.14"),
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
@@ -52,9 +52,27 @@
   $ echo 'foo (re)'
   foo (re)
 
+testing hghave
+
+  $ "$TESTDIR/hghave" true
+  $ "$TESTDIR/hghave" false
+  skipped: missing feature: nail clipper
+  [1]
+  $ "$TESTDIR/hghave" no-true
+  skipped: system supports yak shaving
+  [1]
+  $ "$TESTDIR/hghave" no-false
+
 Conditional sections based on hghave:
 
-#if fifo no-fifo
+#if true
+  $ echo tested
+  tested
+#else
+  $ echo skipped
+#endif
+
+#if false
   $ echo skipped
 #else
   $ echo tested


More information about the Mercurial-devel mailing list