Patchwork tests: Solaris diff -U also emits "No differences encountered"

login
register
mail settings
Submitter Danek Duvall
Date Dec. 27, 2015, 11:38 p.m.
Message ID <9040ac49e79c1018bba2.1451259491@smelly.us.oracle.com>
Download mbox | patch
Permalink /patch/12366/
State Accepted
Headers show

Comments

Danek Duvall - Dec. 27, 2015, 11:38 p.m.
# HG changeset patch
# User Danek Duvall <danek.duvall@oracle.com>
# Date 1451258688 28800
#      Sun Dec 27 15:24:48 2015 -0800
# Node ID 9040ac49e79c1018bba287bb321aa7acccaec5a0
# Parent  e2aa9c4030c4109e5efa50462ffc6048ca30106f
tests: Solaris diff -U also emits "No differences encountered"

This came up before, but the tests in check-code.py don't find -U (only -u)
and they don't work when the diff is inside a shell function.  This fixes
the offending tests and beefs up check-code.py.
Augie Fackler - Dec. 29, 2015, 10:16 p.m.
On Sun, Dec 27, 2015 at 03:38:11PM -0800, danek.duvall@oracle.com wrote:
> # HG changeset patch
> # User Danek Duvall <danek.duvall@oracle.com>
> # Date 1451258688 28800
> #      Sun Dec 27 15:24:48 2015 -0800
> # Node ID 9040ac49e79c1018bba287bb321aa7acccaec5a0
> # Parent  e2aa9c4030c4109e5efa50462ffc6048ca30106f
> tests: Solaris diff -U also emits "No differences encountered"

Queued this, thanks!

>
> This came up before, but the tests in check-code.py don't find -U (only -u)
> and they don't work when the diff is inside a shell function.  This fixes
> the offending tests and beefs up check-code.py.
>
> diff --git a/contrib/check-code.py b/contrib/check-code.py
> --- a/contrib/check-code.py
> +++ b/contrib/check-code.py
> @@ -122,7 +122,8 @@ testpats = [
>      (r'^( *)\t', "don't use tabs to indent"),
>      (r'sed (-e )?\'(\d+|/[^/]*/)i(?!\\\n)',
>       "put a backslash-escaped newline after sed 'i' command"),
> -    (r'^diff *-\w*u.*$\n(^  \$ |^$)', "prefix diff -u with cmp"),
> +    (r'^diff *-\w*[uU].*$\n(^  \$ |^$)', "prefix diff -u/-U with cmp"),
> +    (r'^\s+(if)? diff *-\w*[uU]', "prefix diff -u/-U with cmp"),
>      (r'seq ', "don't use 'seq', use $TESTDIR/seq.py"),
>      (r'\butil\.Abort\b', "directly use error.Abort"),
>      (r'\|&', "don't use |&, use 2>&1"),
> diff --git a/tests/test-merge-changedelete.t b/tests/test-merge-changedelete.t
> --- a/tests/test-merge-changedelete.t
> +++ b/tests/test-merge-changedelete.t
> @@ -460,7 +460,7 @@ Force prompts with no input (should be s
>    --- file3 ---
>    3
>    changed2
> -  $ diff -U8 $TESTTMP/fail.status $TESTTMP/prompt.status
> +  $ cmp $TESTTMP/fail.status $TESTTMP/prompt.status || diff -U8 $TESTTMP/fail.status $TESTTMP/prompt.status
>
>
>  Force prompts
> @@ -583,7 +583,7 @@ invocations.)
>    >         hg resolve --tool ":$tool" --all --config ui.interactive=True
>    >         status > "$TESTTMP/compare.status" 2>&1
>    >         echo '--- diff of status ---'
> -  >         if diff -U8 "$TESTTMP/$tool.status" "$TESTTMP/compare.status"; then
> +  >         if cmp "$TESTTMP/$tool.status" "$TESTTMP/compare.status" || diff -U8 "$TESTTMP/$tool.status" "$TESTTMP/compare.status"; then
>    >             echo '(status identical)'
>    >         fi
>    >         lasttool="$tool"
> @@ -868,7 +868,7 @@ Force prompts with no input
>    --- file3 ---
>    3
>    changed1
> -  $ diff -U8 $TESTTMP/fail.status $TESTTMP/prompt.status
> +  $ cmp $TESTTMP/fail.status $TESTTMP/prompt.status || diff -U8 $TESTTMP/fail.status $TESTTMP/prompt.status
>
>  Choose to merge all files
>
> diff --git a/tests/test-merge-force.t b/tests/test-merge-force.t
> --- a/tests/test-merge-force.t
> +++ b/tests/test-merge-force.t
> @@ -779,4 +779,4 @@ Re-resolve and check status
>    warning: conflicts while merging missing_content2_missing_content4-untracked! (edit, then use 'hg resolve --mark')
>    [1]
>    $ checkstatus > $TESTTMP/status2 2>&1
> -  $ diff -U8 $TESTTMP/status1 $TESTTMP/status2
> +  $ cmp $TESTTMP/status1 $TESTTMP/status2 || diff -U8 $TESTTMP/status1 $TESTTMP/status2
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -122,7 +122,8 @@  testpats = [
     (r'^( *)\t', "don't use tabs to indent"),
     (r'sed (-e )?\'(\d+|/[^/]*/)i(?!\\\n)',
      "put a backslash-escaped newline after sed 'i' command"),
-    (r'^diff *-\w*u.*$\n(^  \$ |^$)', "prefix diff -u with cmp"),
+    (r'^diff *-\w*[uU].*$\n(^  \$ |^$)', "prefix diff -u/-U with cmp"),
+    (r'^\s+(if)? diff *-\w*[uU]', "prefix diff -u/-U with cmp"),
     (r'seq ', "don't use 'seq', use $TESTDIR/seq.py"),
     (r'\butil\.Abort\b', "directly use error.Abort"),
     (r'\|&', "don't use |&, use 2>&1"),
diff --git a/tests/test-merge-changedelete.t b/tests/test-merge-changedelete.t
--- a/tests/test-merge-changedelete.t
+++ b/tests/test-merge-changedelete.t
@@ -460,7 +460,7 @@  Force prompts with no input (should be s
   --- file3 ---
   3
   changed2
-  $ diff -U8 $TESTTMP/fail.status $TESTTMP/prompt.status
+  $ cmp $TESTTMP/fail.status $TESTTMP/prompt.status || diff -U8 $TESTTMP/fail.status $TESTTMP/prompt.status
 
 
 Force prompts
@@ -583,7 +583,7 @@  invocations.)
   >         hg resolve --tool ":$tool" --all --config ui.interactive=True
   >         status > "$TESTTMP/compare.status" 2>&1
   >         echo '--- diff of status ---'
-  >         if diff -U8 "$TESTTMP/$tool.status" "$TESTTMP/compare.status"; then
+  >         if cmp "$TESTTMP/$tool.status" "$TESTTMP/compare.status" || diff -U8 "$TESTTMP/$tool.status" "$TESTTMP/compare.status"; then
   >             echo '(status identical)'
   >         fi
   >         lasttool="$tool"
@@ -868,7 +868,7 @@  Force prompts with no input
   --- file3 ---
   3
   changed1
-  $ diff -U8 $TESTTMP/fail.status $TESTTMP/prompt.status
+  $ cmp $TESTTMP/fail.status $TESTTMP/prompt.status || diff -U8 $TESTTMP/fail.status $TESTTMP/prompt.status
 
 Choose to merge all files
 
diff --git a/tests/test-merge-force.t b/tests/test-merge-force.t
--- a/tests/test-merge-force.t
+++ b/tests/test-merge-force.t
@@ -779,4 +779,4 @@  Re-resolve and check status
   warning: conflicts while merging missing_content2_missing_content4-untracked! (edit, then use 'hg resolve --mark')
   [1]
   $ checkstatus > $TESTTMP/status2 2>&1
-  $ diff -U8 $TESTTMP/status1 $TESTTMP/status2
+  $ cmp $TESTTMP/status1 $TESTTMP/status2 || diff -U8 $TESTTMP/status1 $TESTTMP/status2