Patchwork [stable] tests: use inline Python instead of sed to add trailing whitespace

login
register
mail settings
Submitter Augie Fackler
Date July 30, 2018, 2:22 p.m.
Message ID <b31164c5af62e7f1614c.1532960539@augie-macbookpro2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/32971/
State Accepted
Headers show

Comments

Augie Fackler - July 30, 2018, 2:22 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1532960309 14400
#      Mon Jul 30 10:18:29 2018 -0400
# Branch stable
# Node ID b31164c5af62e7f1614ced760ab05bd644d5fbec
# Parent  71d6886d27cf94dc45d0e495c3912d3c6e74794e
tests: use inline Python instead of sed to add trailing whitespace

The sed invocation was failing on OS X and FreeBSD. I'm far too lazy
to diagnose that, so just use some inline Python to fix the build.
Yuya Nishihara - July 30, 2018, 2:30 p.m.
On Mon, 30 Jul 2018 10:22:19 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1532960309 14400
> #      Mon Jul 30 10:18:29 2018 -0400
> # Branch stable
> # Node ID b31164c5af62e7f1614ced760ab05bd644d5fbec
> # Parent  71d6886d27cf94dc45d0e495c3912d3c6e74794e
> tests: use inline Python instead of sed to add trailing whitespace

Queued, thanks.

Patch

diff --git a/tests/test-diff-color.t b/tests/test-diff-color.t
--- a/tests/test-diff-color.t
+++ b/tests/test-diff-color.t
@@ -54,8 +54,10 @@  default context
 trailing whitespace
 
   $ cp a a.orig
-  $ sed 's/^dd$/dd \r/' a >a.new
-  $ mv a.new a
+  >>> with open('a', 'rb') as f:
+  ...     data = f.read()
+  >>> with open('a', 'wb') as f:
+  ...     f.write(data.replace('dd', 'dd \r'))
   $ hg diff --nodates
   \x1b[0;1mdiff -r cf9f4ba66af2 a\x1b[0m (esc)
   \x1b[0;31;1m--- a/a\x1b[0m (esc)