Patchwork [STABLE] tests: account for different newline behavior between Solaris and GNU grep

login
register
mail settings
Submitter Danek Duvall
Date Jan. 29, 2017, 8:54 p.m.
Message ID <24d82f28412d67323d13.1485723275@smelly>
Download mbox | patch
Permalink /patch/18275/
State Accepted
Headers show

Comments

Danek Duvall - Jan. 29, 2017, 8:54 p.m.
# HG changeset patch
# User Danek Duvall <danek.duvall@oracle.com>
# Date 1485722456 28800
#      Sun Jan 29 12:40:56 2017 -0800
# Branch stable
# Node ID 24d82f28412d67323d13ac2b9f8c7c489c171ee0
# Parent  7bfe02b57695900ef996989286c1fdc2a13aec82
tests: account for different newline behavior between Solaris and GNU grep

GNU grep, when emitting a matching line that doesn't have a terminating
newline, will add an extra newline.  Solaris grep passes the original line
through without the newline.  This causes differences in test output when
looking at the last line of the output of get-with-headers.py, which
doesn't usually emit (and certainly doesn't guarantee) a terminating
newline.

Both grep implementations succeed in matching the requested pattern,
though, so rely on specifying the full pattern on grep's commandline
instead of expecting it in the output, and send the output to /dev/null.
Yuya Nishihara - Jan. 30, 2017, 1:35 p.m.
On Sun, 29 Jan 2017 12:54:35 -0800, danek.duvall@oracle.com wrote:
> # HG changeset patch
> # User Danek Duvall <danek.duvall@oracle.com>
> # Date 1485722456 28800
> #      Sun Jan 29 12:40:56 2017 -0800
> # Branch stable
> # Node ID 24d82f28412d67323d13ac2b9f8c7c489c171ee0
> # Parent  7bfe02b57695900ef996989286c1fdc2a13aec82
> tests: account for different newline behavior between Solaris and GNU grep

Looks good, queued, thanks.

Patch

diff --git a/tests/test-http-protocol.t b/tests/test-http-protocol.t
--- a/tests/test-http-protocol.t
+++ b/tests/test-http-protocol.t
@@ -16,11 +16,9 @@ 
 compression formats are advertised in compression capability
 
 #if zstd
-  $ get-with-headers.py 127.0.0.1:$HGPORT '?cmd=capabilities' | tr ' ' '\n' | grep compression
-  compression=zstd,zlib
+  $ get-with-headers.py 127.0.0.1:$HGPORT '?cmd=capabilities' | tr ' ' '\n' | grep '^compression=zstd,zlib$' > /dev/null
 #else
-  $ get-with-headers.py 127.0.0.1:$HGPORT '?cmd=capabilities' | tr ' ' '\n' | grep compression
-  compression=zlib
+  $ get-with-headers.py 127.0.0.1:$HGPORT '?cmd=capabilities' | tr ' ' '\n' | grep '^compression=zlib$' > /dev/null
 #endif
 
   $ killdaemons.py
@@ -29,8 +27,7 @@  server.compressionengines can replace en
 
   $ hg --config server.compressionengines=none -R server serve -p $HGPORT -d --pid-file hg.pid
   $ cat hg.pid > $DAEMON_PIDS
-  $ get-with-headers.py 127.0.0.1:$HGPORT '?cmd=capabilities' | tr ' ' '\n' | grep compression
-  compression=none
+  $ get-with-headers.py 127.0.0.1:$HGPORT '?cmd=capabilities' | tr ' ' '\n' | grep '^compression=none$' > /dev/null
 
   $ killdaemons.py
 
@@ -38,8 +35,7 @@  Order of engines can also change
 
   $ hg --config server.compressionengines=none,zlib -R server serve -p $HGPORT -d --pid-file hg.pid
   $ cat hg.pid > $DAEMON_PIDS
-  $ get-with-headers.py 127.0.0.1:$HGPORT '?cmd=capabilities' | tr ' ' '\n' | grep compression
-  compression=none,zlib
+  $ get-with-headers.py 127.0.0.1:$HGPORT '?cmd=capabilities' | tr ' ' '\n' | grep '^compression=none,zlib$' > /dev/null
 
   $ killdaemons.py