Patchwork [1,of,6,misc] tests: warn on invalid #if directive

login
register
mail settings
Submitter Mads Kiilerich
Date April 13, 2014, 5:13 p.m.
Message ID <3d61b730ab071141c7ae.1397409225@localhost.localdomain>
Download mbox | patch
Permalink /patch/4329/
State Accepted
Commit 713284510ac01eec90c92b057176f0ec39e1aaaa
Headers show

Comments

Mads Kiilerich - April 13, 2014, 5:13 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1397408460 -7200
#      Sun Apr 13 19:01:00 2014 +0200
# Node ID 3d61b730ab071141c7ae69b497b343a0023a3b8a
# Parent  40800668e01921e41db1eb97d19e473971e93f5e
tests: warn on invalid #if directive

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -692,9 +692,12 @@  def tsttest(test, wd, options, replaceme
         if not l.endswith('\n'):
             l += '\n'
         if l.startswith('#if'):
+            lsplit = l.split()
+            if len(lsplit) < 2 or lsplit[0] != '#if':
+                after.setdefault(pos, []).append('  !!! invalid #if\n')
             if skipping is not None:
                 after.setdefault(pos, []).append('  !!! nested #if\n')
-            skipping = not hghave(l.split()[1:])
+            skipping = not hghave(lsplit[1:])
             after.setdefault(pos, []).append(l)
         elif l.startswith('#else'):
             if skipping is None:
diff --git a/tests/test-permissions.t b/tests/test-permissions.t
--- a/tests/test-permissions.t
+++ b/tests/test-permissions.t
@@ -1,4 +1,4 @@ 
-#ifdef unix-permissions no-root
+#if unix-permissions no-root
 
   $ hg init t
   $ cd t