threads / discuss / 6862

test suite failures because cmp behaves oddly

Subject: test suite failures because cmp behaves oddly

## tl;dr

3 messages between Feb 17, 2007 and Feb 17, 2007.

replies: 2people: 3as markdown or json

Johannes Sixt· Feb 17, 2007, 21:25 UTC · lore

Does anyone know how 'cmp' can signal success when its output is redirected to /dev/null, even if the compared files are different?

$ cmp M.sum actual7.sum; echo $? M.sum actual7.sum differ: char 20, line 2 1 $ cmp M.sum actual7.sum > /dev/null; echo $? 0 $ bash --version GNU bash, version 3.1.17(1)-release (i586-suse-linux) $ cmp --version cmp (GNU diffutils) 2.8.7 [...]

Due to this behavior I see reproducible failures in the test suite, unless the tests are run in --verbose mode:

$ make GIT_TEST_OPTS=-i t1002-read-tree-m-u-2way.sh
*** t1002-read-tree-m-u-2way.sh ***
*   ok 1: setup
*   ok 2: 1, 2, 3 - no carry forward
*   ok 3: 4 - carry forward local addition.
*   ok 4: 5 - carry forward local addition.
*   ok 5: 6 - local addition already has the same.
* FAIL 6: 7 - local addition already has the same.
        rm -f .git/index nitfol bozbar rezrov frotz &&
             git-read-tree --reset -u $treeH &&
             echo frotz >frotz &&
             git-update-index --add frotz &&
             echo frotz frotz >frotz &&
             git-read-tree -m -u $treeH $treeM &&
             git-ls-files --stage >7.out &&
             diff -U0 M.out 7.out &&
             check_cache_at frotz dirty &&
             sum bozbar frotz nitfol >actual7.sum &&
             if cmp M.sum actual7.sum; then false; else :; fi &&
             : dirty index should have prevented -u from checking it out. &&
             echo frotz frotz >frotz1 &&
             diff frotz frotz1 &&
             rm -f frotz1
make: *** [t1002-read-tree-m-u-2way.sh] Error 1
Has anyone seen something like this?
-- Hannes
Junio C Hamano· Feb 17, 2007, 23:03 UTC · re: Johannes Sixt · lore

Re: test suite failures because cmp behaves oddly

Johannes Sixt <johannes.sixt@telecom.at> writes:
Show 10 quoted lines
> Does anyone know how 'cmp' can signal success when its output is redirected 
> to /dev/null, even if the compared files are different?
>
> $ cmp M.sum actual7.sum; echo $?
> M.sum actual7.sum differ: char 20, line 2
> 1
> $ cmp M.sum actual7.sum > /dev/null; echo $?
> 0
> ...
> Has anyone seen something like this?

I vaguely recall this reported long time ago from one of the regulars on the list, but googling or gmane search came up empty.

Johannes Schindelin· Feb 17, 2007, 23:16 UTC · re: Junio C Hamano · lore

Re: test suite failures because cmp behaves oddly

Hi,
On Sat, 17 Feb 2007, Junio C Hamano wrote:
Show 16 quoted lines
> Johannes Sixt <johannes.sixt@telecom.at> writes:
> 
> > Does anyone know how 'cmp' can signal success when its output is redirected 
> > to /dev/null, even if the compared files are different?
> >
> > $ cmp M.sum actual7.sum; echo $?
> > M.sum actual7.sum differ: char 20, line 2
> > 1
> > $ cmp M.sum actual7.sum > /dev/null; echo $?
> > 0
> > ...
> > Has anyone seen something like this?
> 
> I vaguely recall this reported long time ago from one of the
> regulars on the list, but googling or gmane search came up
> empty.
Was me. AFAIR it was fixed in CVS.

Ciao, Dscho

← back to recent threads