git/list[1] front-page[2] threads[3] people[4] search[5] about
 

test suite failures because cmp behaves oddly

From
Johannes Sixt <johannes.sixt@telecom.at>
Date
Feb 17, 2007, 21:25 UTC
Message-ID
<200702172225.12758.johannes.sixt@telecom.at>

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
Next: Junio C Hamano
Message 1 of 3 in “test suite failures because cmp behaves oddly”
  1. Johannes SixtFeb 17, 2007
  2. Junio C HamanoFeb 17, 2007
  3. Johannes SchindelinFeb 17, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.