Patchwork [4,of,6,v2] run-tests: add support for using 127.0.0.1 as a glob

login
register
mail settings
Submitter Augie Fackler
Date July 12, 2016, 7:49 p.m.
Message ID <8cbb7bea9c02697fa4ad.1468352991@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/15806/
State Accepted
Headers show

Comments

Augie Fackler - July 12, 2016, 7:49 p.m.
# HG changeset patch
# User Augie Fackler <raf@durin42.com>
# Date 1468119662 14400
#      Sat Jul 09 23:01:02 2016 -0400
# Node ID 8cbb7bea9c02697fa4addbdf884a18b95a228b8a
# Parent  22e0c03114ed488eb162b8dd9f06593f0524f39f
run-tests: add support for using 127.0.0.1 as a glob

Some systems don't have a 127/8 address for localhost (I noticed this
on a FreeBSD jail). In order to work around this, use 127.0.0.1 as a
glob pattern. A future commit will update needed output lines and add
a requirement to check-code.py.
Yuya Nishihara - July 13, 2016, 1:24 p.m.
On Tue, 12 Jul 2016 15:49:51 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <raf@durin42.com>
> # Date 1468119662 14400
> #      Sat Jul 09 23:01:02 2016 -0400
> # Node ID 8cbb7bea9c02697fa4addbdf884a18b95a228b8a
> # Parent  22e0c03114ed488eb162b8dd9f06593f0524f39f
> run-tests: add support for using 127.0.0.1 as a glob

Queued the series, thanks.

> @@ -1263,6 +1268,7 @@ class TTest(Test):
>                          return True
>                  return b'-glob'
>              return True
> +        el = el.replace(b'127.0.0.1', b'*')

This seemed a bit wild at first, but the diff in the next patch wasn't that
big, which made me feel globbing 127.0.0.1 is good.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -949,13 +949,18 @@  class PythonTest(Test):
 
         return result
 
-# This script may want to drop globs from lines matching these patterns on
-# Windows, but check-code.py wants a glob on these lines unconditionally.  Don't
-# warn if that is the case for anything matching these lines.
+# Some glob patterns apply only in some circumstances, so the script
+# might want to remove (glob) annotations that otherwise should be
+# retained.
 checkcodeglobpats = [
+    # On Windows it looks like \ doesn't require a (glob), but we know
+    # better.
     re.compile(br'^pushing to \$TESTTMP/.*[^)]$'),
     re.compile(br'^moving \S+/.*[^)]$'),
-    re.compile(br'^pulling from \$TESTTMP/.*[^)]$')
+    re.compile(br'^pulling from \$TESTTMP/.*[^)]$'),
+    # Not all platforms have 127.0.0.1 as loopback (though most do),
+    # so we always glob that too.
+    re.compile(br'.*127.0.0.1.*$'),
 ]
 
 bchr = chr
@@ -1263,6 +1268,7 @@  class TTest(Test):
                         return True
                 return b'-glob'
             return True
+        el = el.replace(b'127.0.0.1', b'*')
         i, n = 0, len(el)
         res = b''
         while i < n:
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
@@ -735,6 +735,10 @@  backslash on end of line with glob match
 
   $ rm -f test-glob-backslash.t
 
+Test globbing of 127.0.0.1
+  $ echo 172.16.18.1
+  127.0.0.1 (glob)
+
 Test reusability for third party tools
 ======================================