Patchwork [2,of,4] tests: Solaris sed does not support "\n" meaning newline in the RHS of s///

login
register
mail settings
Submitter Danek Duvall
Date March 2, 2016, 11:22 p.m.
Message ID <06f40ce66d200ab9869e.1456960941@smelly.us.oracle.com>
Download mbox | patch
Permalink /patch/13578/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

Danek Duvall - March 2, 2016, 11:22 p.m.
# HG changeset patch
# User Danek Duvall <danek.duvall@oracle.com>
# Date 1456959313 28800
#      Wed Mar 02 14:55:13 2016 -0800
# Node ID 06f40ce66d200ab9869e2d70bfa127582c6ea26d
# Parent  47d43135bf430d7172c8fb8fe35fb17b6f8f029c
tests: Solaris sed does not support "\n" meaning newline in the RHS of s///

The blackbox test rewrites a copy of test-dispatch.py on the fly, and adds
a couple of lines with the s/// command.  GNU sed supports the use of the
\n escape to represent a newline, but not Solaris sed.  Using a literal
newline, prefixed by a backslash, works with both versions of the utility.
Yuya Nishihara - March 4, 2016, 2:27 p.m.
On Wed, 02 Mar 2016 15:22:21 -0800, danek.duvall@oracle.com wrote:
> # HG changeset patch
> # User Danek Duvall <danek.duvall@oracle.com>
> # Date 1456959313 28800
> #      Wed Mar 02 14:55:13 2016 -0800
> # Node ID 06f40ce66d200ab9869e2d70bfa127582c6ea26d
> # Parent  47d43135bf430d7172c8fb8fe35fb17b6f8f029c
> tests: Solaris sed does not support "\n" meaning newline in the RHS of s///
> 
> The blackbox test rewrites a copy of test-dispatch.py on the fly, and adds
> a couple of lines with the s/// command.  GNU sed supports the use of the
> \n escape to represent a newline, but not Solaris sed.  Using a literal
> newline, prefixed by a backslash, works with both versions of the utility.
> 
> diff --git a/tests/test-blackbox.t b/tests/test-blackbox.t
> --- a/tests/test-blackbox.t
> +++ b/tests/test-blackbox.t
> @@ -154,7 +154,9 @@ log rotation
>    1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
>    $ mv .hg/blackbox.log .hg/blackbox.log-
>    $ mkdir .hg/blackbox.log
> -  $ sed -e 's/\(.*test1.*\)/#\1/; s#\(.*commit2.*\)#os.rmdir(".hg/blackbox.log")\nos.rename(".hg/blackbox.log-", ".hg/blackbox.log")\n\1#' $TESTDIR/test-dispatch.py > ../test-dispatch.py
> +  $ sed -e 's/\(.*test1.*\)/#\1/; s#\(.*commit2.*\)#os.rmdir(".hg/blackbox.log")\
> +  > os.rename(".hg/blackbox.log-", ".hg/blackbox.log")\
> +  > \1#' $TESTDIR/test-dispatch.py > ../test-dispatch.py

timeless, can you rewrite this test with inline Python?
It's really hard to understand what's going on here.
timeless - March 6, 2016, 1:30 a.m.
Sure

On Fri, Mar 4, 2016 at 9:27 AM, Yuya Nishihara <yuya@tcha.org> wrote:
> On Wed, 02 Mar 2016 15:22:21 -0800, danek.duvall@oracle.com wrote:
>> # HG changeset patch
>> # User Danek Duvall <danek.duvall@oracle.com>
>> # Date 1456959313 28800
>> #      Wed Mar 02 14:55:13 2016 -0800
>> # Node ID 06f40ce66d200ab9869e2d70bfa127582c6ea26d
>> # Parent  47d43135bf430d7172c8fb8fe35fb17b6f8f029c
>> tests: Solaris sed does not support "\n" meaning newline in the RHS of s///
>>
>> The blackbox test rewrites a copy of test-dispatch.py on the fly, and adds
>> a couple of lines with the s/// command.  GNU sed supports the use of the
>> \n escape to represent a newline, but not Solaris sed.  Using a literal
>> newline, prefixed by a backslash, works with both versions of the utility.
>>
>> diff --git a/tests/test-blackbox.t b/tests/test-blackbox.t
>> --- a/tests/test-blackbox.t
>> +++ b/tests/test-blackbox.t
>> @@ -154,7 +154,9 @@ log rotation
>>    1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
>>    $ mv .hg/blackbox.log .hg/blackbox.log-
>>    $ mkdir .hg/blackbox.log
>> -  $ sed -e 's/\(.*test1.*\)/#\1/; s#\(.*commit2.*\)#os.rmdir(".hg/blackbox.log")\nos.rename(".hg/blackbox.log-", ".hg/blackbox.log")\n\1#' $TESTDIR/test-dispatch.py > ../test-dispatch.py
>> +  $ sed -e 's/\(.*test1.*\)/#\1/; s#\(.*commit2.*\)#os.rmdir(".hg/blackbox.log")\
>> +  > os.rename(".hg/blackbox.log-", ".hg/blackbox.log")\
>> +  > \1#' $TESTDIR/test-dispatch.py > ../test-dispatch.py
>
> timeless, can you rewrite this test with inline Python?
> It's really hard to understand what's going on here.

Patch

diff --git a/tests/test-blackbox.t b/tests/test-blackbox.t
--- a/tests/test-blackbox.t
+++ b/tests/test-blackbox.t
@@ -154,7 +154,9 @@  log rotation
   1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
   $ mv .hg/blackbox.log .hg/blackbox.log-
   $ mkdir .hg/blackbox.log
-  $ sed -e 's/\(.*test1.*\)/#\1/; s#\(.*commit2.*\)#os.rmdir(".hg/blackbox.log")\nos.rename(".hg/blackbox.log-", ".hg/blackbox.log")\n\1#' $TESTDIR/test-dispatch.py > ../test-dispatch.py
+  $ sed -e 's/\(.*test1.*\)/#\1/; s#\(.*commit2.*\)#os.rmdir(".hg/blackbox.log")\
+  > os.rename(".hg/blackbox.log-", ".hg/blackbox.log")\
+  > \1#' $TESTDIR/test-dispatch.py > ../test-dispatch.py
   $ python ../test-dispatch.py
   running: add foo
   result: 0