Patchwork [STABLE] test-annotate: rewrite sed with some python

login
register
mail settings
Submitter Yuya Nishihara
Date March 4, 2018, 6:24 p.m.
Message ID <0c042b499ba989d19378.1520187860@mimosa>
Download mbox | patch
Permalink /patch/28958/
State Accepted
Headers show

Comments

Yuya Nishihara - March 4, 2018, 6:24 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1520187545 18000
#      Sun Mar 04 13:19:05 2018 -0500
# Branch stable
# Node ID 0c042b499ba989d193783a5cd64cca866ce01ae8
# Parent  b394778b1a5042ca5799f5bae43620dd3324c797
test-annotate: rewrite sed with some python

I hope this will fix the test failure seen on FreeBSD and Windows.
Augie Fackler - March 4, 2018, 6:27 p.m.
> On Mar 4, 2018, at 13:24, Yuya Nishihara <yuya@tcha.org> wrote:
> 
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1520187545 18000
> #      Sun Mar 04 13:19:05 2018 -0500
> # Branch stable
> # Node ID 0c042b499ba989d193783a5cd64cca866ce01ae8
> # Parent  b394778b1a5042ca5799f5bae43620dd3324c797
> test-annotate: rewrite sed with some python

queued, thanks

> 
> I hope this will fix the test failure seen on FreeBSD and Windows.
> 
> diff --git a/tests/test-annotate.t b/tests/test-annotate.t
> --- a/tests/test-annotate.t
> +++ b/tests/test-annotate.t
> @@ -901,9 +901,12 @@ Annotate with orphaned CR (issue5798)
>   $ hg init repo-cr
>   $ cd repo-cr
> 
> -  $ substcr() {
> -  > sed 's/\r/[CR]/g'
> -  > }
> +  $ cat <<'EOF' >> "$TESTTMP/substcr.py"
> +  > import sys
> +  > stdin = getattr(sys.stdin, 'buffer', sys.stdin)
> +  > stdout = getattr(sys.stdout, 'buffer', sys.stdout)
> +  > stdout.write(stdin.read().replace(b'\r', b'[CR]'))
> +  > EOF
> 
>>>> with open('a', 'wb') as f:
>   ...     f.write(b'0a\r0b\r\n0c\r0d\r\n0e\n0f\n0g')
> @@ -912,13 +915,13 @@ Annotate with orphaned CR (issue5798)
>   ...     f.write(b'0a\r0b\r\n1c\r1d\r\n0e\n1f\n0g')
>   $ hg ci -m1
> 
> -  $ hg annotate -r0 a | substcr
> +  $ hg annotate -r0 a | $PYTHON "$TESTTMP/substcr.py"
>   0: 0a[CR]0b[CR]
>   0: 0c[CR]0d[CR]
>   0: 0e
>   0: 0f
>   0: 0g
> -  $ hg annotate -r1 a | substcr
> +  $ hg annotate -r1 a | $PYTHON "$TESTTMP/substcr.py"
>   0: 0a[CR]0b[CR]
>   1: 1c[CR]1d[CR]
>   0: 0e
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/tests/test-annotate.t b/tests/test-annotate.t
--- a/tests/test-annotate.t
+++ b/tests/test-annotate.t
@@ -901,9 +901,12 @@  Annotate with orphaned CR (issue5798)
   $ hg init repo-cr
   $ cd repo-cr
 
-  $ substcr() {
-  > sed 's/\r/[CR]/g'
-  > }
+  $ cat <<'EOF' >> "$TESTTMP/substcr.py"
+  > import sys
+  > stdin = getattr(sys.stdin, 'buffer', sys.stdin)
+  > stdout = getattr(sys.stdout, 'buffer', sys.stdout)
+  > stdout.write(stdin.read().replace(b'\r', b'[CR]'))
+  > EOF
 
   >>> with open('a', 'wb') as f:
   ...     f.write(b'0a\r0b\r\n0c\r0d\r\n0e\n0f\n0g')
@@ -912,13 +915,13 @@  Annotate with orphaned CR (issue5798)
   ...     f.write(b'0a\r0b\r\n1c\r1d\r\n0e\n1f\n0g')
   $ hg ci -m1
 
-  $ hg annotate -r0 a | substcr
+  $ hg annotate -r0 a | $PYTHON "$TESTTMP/substcr.py"
   0: 0a[CR]0b[CR]
   0: 0c[CR]0d[CR]
   0: 0e
   0: 0f
   0: 0g
-  $ hg annotate -r1 a | substcr
+  $ hg annotate -r1 a | $PYTHON "$TESTTMP/substcr.py"
   0: 0a[CR]0b[CR]
   1: 1c[CR]1d[CR]
   0: 0e