Patchwork [5,of,5] solaris: test cases shouldn't use diff -u when no output is expected

login
register
mail settings
Submitter Danek Duvall
Date Aug. 26, 2013, 8:25 p.m.
Message ID <495ae167858c589bcce7.1377548709@smelly>
Download mbox | patch
Permalink /patch/2269/
State Changes Requested
Headers show

Comments

Danek Duvall - Aug. 26, 2013, 8:25 p.m.
# HG changeset patch
# User Danek Duvall <danek.duvall@oracle.com>
# Date 1377548599 25200
# Node ID 495ae167858c589bcce7411904855121275746a5
# Parent  e8d378497e82e22fe9c0cff4d2be56635d7057f3
solaris: test cases shouldn't use diff -u when no output is expected

When using Solaris diff, the -u option emits "No differences encountered"
when the two files are the same, leading to extraneous test failures.  In
such cases, we can easily remove the -u option, since that has no output
with either Solaris or GNU diff, and we can remove the various mechanisms
that have been used to handle the difference.

In order to write a test for check-code.py, though, all uses of diff -u
need to be eliminated.  The one case where a simple output is expected, we
can just cat the two (one-line) files and confirm the output.  In the other
cases, we switch to regular diffs.

Patch

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -62,6 +62,7 @@  testpats = [
     (r'\W\$?\(\([^\)\n]*\)\)', "don't use (()) or $(()), use 'expr'"),
     (r'grep.*-q', "don't use 'grep -q', redirect to /dev/null"),
     (r'(?<!hg )grep.*-a', "don't use 'grep -a', use in-line python"),
+    (r'diff\s+-\w*u', "don't use 'diff -u'"),
     (r'sed.*-i', "don't use 'sed -i', use a temporary file"),
     (r'\becho\b.*\\n', "don't use 'echo \\n', use printf"),
     (r'echo -n', "don't use 'echo -n', use printf"),
diff --git a/tests/test-command-template.t b/tests/test-command-template.t
--- a/tests/test-command-template.t
+++ b/tests/test-command-template.t
@@ -67,15 +67,15 @@  Default style is like normal output:
 
   $ hg log > log.out
   $ hg log --style default > style.out
-  $ cmp log.out style.out || diff -u log.out style.out
+  $ diff log.out style.out
 
   $ hg log -v > log.out
   $ hg log -v --style default > style.out
-  $ cmp log.out style.out || diff -u log.out style.out
+  $ diff log.out style.out
 
   $ hg log --debug > log.out
   $ hg log --debug --style default > style.out
-  $ cmp log.out style.out || diff -u log.out style.out
+  $ diff log.out style.out
 
 Revision with no copies (used to print a traceback):
 
diff --git a/tests/test-convert-bzr.t b/tests/test-convert-bzr.t
--- a/tests/test-convert-bzr.t
+++ b/tests/test-convert-bzr.t
@@ -102,7 +102,7 @@  compare timestamps
   >   > ../bzr-timestamps
   $ cd ..
   $ hg -R source-hg log --template "{date|isodate}\n" > hg-timestamps
-  $ diff -u bzr-timestamps hg-timestamps
+  $ diff bzr-timestamps hg-timestamps
   $ cd ..
 
 merge
diff --git a/tests/test-glog.t b/tests/test-glog.t
--- a/tests/test-glog.t
+++ b/tests/test-glog.t
@@ -1430,7 +1430,7 @@  Test log -G options
   >     | sed 's/.*nodetag/nodetag/' > log.nodes
   >   hg log -G --template 'nodetag {rev}\n' "$@" | grep nodetag \
   >     | sed 's/.*nodetag/nodetag/' > glog.nodes
-  >   diff -u log.nodes glog.nodes | grep '^[-+@ ]' || :
+  >   diff log.nodes glog.nodes
   > }
 
 glog always reorders nodes which explains the difference with log
@@ -1438,18 +1438,15 @@  glog always reorders nodes which explain
   $ testlog -r 27 -r 25 -r 21 -r 34 -r 32 -r 31
   ['27', '25', '21', '34', '32', '31']
   []
-  --- log.nodes	* (glob)
-  +++ glog.nodes	* (glob)
-  @@ -1,6 +1,6 @@
-  -nodetag 27
-  -nodetag 25
-  -nodetag 21
-   nodetag 34
-   nodetag 32
-   nodetag 31
-  +nodetag 27
-  +nodetag 25
-  +nodetag 21
+  1,3d0
+  < nodetag 27
+  < nodetag 25
+  < nodetag 21
+  6a4,6
+  \> nodetag 27
+  \> nodetag 25
+  \> nodetag 21
+  [1]
   $ testlog -u test -u not-a-user
   []
   (group
@@ -1969,13 +1966,11 @@  Test --follow and forward --rev
     (func
       ('symbol', 'descendants')
       ('symbol', '6')))
-  --- log.nodes	* (glob)
-  +++ glog.nodes	* (glob)
-  @@ -1,3 +1,3 @@
-  -nodetag 6
-   nodetag 8
-   nodetag 7
-  +nodetag 6
+  1d0
+  < nodetag 6
+  3a3
+  \> nodetag 6
+  [1]
 
 Test --follow-first and forward --rev
 
@@ -1985,13 +1980,11 @@  Test --follow-first and forward --rev
     (func
       ('symbol', '_firstdescendants')
       ('symbol', '6')))
-  --- log.nodes	* (glob)
-  +++ glog.nodes	* (glob)
-  @@ -1,3 +1,3 @@
-  -nodetag 6
-   nodetag 8
-   nodetag 7
-  +nodetag 6
+  1d0
+  < nodetag 6
+  3a3
+  \> nodetag 6
+  [1]
 
 Test --follow and backward --rev
 
diff --git a/tests/test-highlight.t b/tests/test-highlight.t
--- a/tests/test-highlight.t
+++ b/tests/test-highlight.t
@@ -522,7 +522,7 @@  hgweb fileannotate, raw
   $ echo "" >> b
   $ echo "" >> b
   $ echo "" >> b
-  $ diff -u b a
+  $ diff b a
 
 hgweb filerevision, raw
 
@@ -531,7 +531,7 @@  hgweb filerevision, raw
   $ echo "200 Script output follows" > b
   $ echo "" >> b
   $ hg cat primes.py >> b
-  $ diff -u b a
+  $ diff b a
 
 hgweb highlightcss friendly
 
diff --git a/tests/test-rename.t b/tests/test-rename.t
--- a/tests/test-rename.t
+++ b/tests/test-rename.t
@@ -276,13 +276,9 @@  overwrite existing files (d2/b)
   R d1/a
   R d1/ba
   R d1/d11/a1
-  $ diff -u d1/b d2/b
-  --- d1/b	* (glob)
-  +++ d2/b	* (glob)
-  @@ * (glob)
-  -d1/b
-  +d2/b
-  [1]
+  $ cat d1/b d2/b
+  d1/b
+  d2/b
   $ hg update -C
   3 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ rm d2/a d2/ba d2/d11/a1