changeset 36706:a247a0e82e7d

run-tests: allow #require inside #if Used by the next patch. Differential Revision: https://phab.mercurial-scm.org/D2605
author Jun Wu <quark@fb.com>
date Sat, 03 Mar 2018 12:39:14 -0800
parents c6a61298ac32
children 7834927f0243
files tests/run-tests.py tests/test-run-tests.t
diffstat 2 files changed, 15 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/tests/run-tests.py	Sat Mar 03 12:39:14 2018 -0800
+++ b/tests/run-tests.py	Sat Mar 03 12:39:14 2018 -0800
@@ -1373,10 +1373,11 @@
                 lsplit = l.split()
                 if len(lsplit) < 2 or lsplit[0] != b'#require':
                     after.setdefault(pos, []).append('  !!! invalid #require\n')
-                haveresult, message = self._hghave(lsplit[1:])
-                if not haveresult:
-                    script = [b'echo "%s"\nexit 80\n' % message]
-                    break
+                if not skipping:
+                    haveresult, message = self._hghave(lsplit[1:])
+                    if not haveresult:
+                        script = [b'echo "%s"\nexit 80\n' % message]
+                        break
                 after.setdefault(pos, []).append(l)
             elif l.startswith(b'#if'):
                 lsplit = l.split()
--- a/tests/test-run-tests.t	Sat Mar 03 12:39:14 2018 -0800
+++ b/tests/test-run-tests.t	Sat Mar 03 12:39:14 2018 -0800
@@ -921,16 +921,24 @@
 ================
   $ cat > test-skip.t <<EOF
   >   $ echo xyzzy
+  > #if true
   > #require false
+  > #end
+  > EOF
+  $ cat > test-noskip.t <<EOF
+  > #if false
+  > #require false
+  > #endif
   > EOF
   $ rt --nodiff
-  !.s
+  !.s.
   Skipped test-skip.t: missing feature: nail clipper
   Failed test-failure.t: output changed
-  # Ran 2 tests, 1 skipped, 1 failed.
+  # Ran 3 tests, 1 skipped, 1 failed.
   python hash seed: * (glob)
   [1]
 
+  $ rm test-noskip.t
   $ rt --keyword xyzzy
   .s
   Skipped test-skip.t: missing feature: nail clipper