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

Re: [PATCH 2/2] Support Out-Of-Tree Valgrind Tests

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 6, 2012, 22:37 UTC
Message-ID
<7v7gyxqrty.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7vboo9qskb.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 17 quoted lines
> "David A. Greene" <dag@cray.com> writes:
>
>> Junio C Hamano <gitster@pobox.com> writes:
>> ...
>>> Could it be that the reason for the breakage is because you are
>>> setting TEST_DIRECTORY to the directory that contains out-of-tree
>>> tests, instead of $GIT_BUILD_DIR/t/ directory?
>> ...
>>> Shouldn't TEST_DIRECTORY merely a short-hand for GIT_BUILD_DIR/t?
>>> What do you find relative to $TEST_DIRECTORY that cannot be found
>>> relative to GIT_BUILD_DIR/t?
>> ...
>>
>> Thanks for clarifying!
>
> Not so fast. The questions in the message you are responding to were
> not rhetorical.
So I ended up looking at t/test-lib.sh, sigh...

We have this bit from 62f5390 (test-lib: Allow overriding of TEST_DIRECTORY, 2010-08-19):

   # Test the binaries we have just built.  The tests are kept in
   # t/ subdirectory and are run in 'trash directory' subdirectory.
   if test -z "$TEST_DIRECTORY"
   then
           # We allow tests to override this, in case they want to run tests
           # outside of t/, e.g. for running tests on the test library
           # itself.
           TEST_DIRECTORY=$(pwd)
   fi
   GIT_BUILD_DIR="$TEST_DIRECTORY"/..

that says "As a side benefit this change also makes it easy for us to move the t/*.sh tests into subdirectories if we ever want to do that."

This expects that an out-of-tree test script is expected to set TEST_DIRECTORY before dot-sourcing test-lib.sh, e.g.

	#!/bin/sh
	TEST_DIRECTORY=/srv/project/git/git.git/t
        test_description='an out-of-tree test'
        . "$TEST_DIRECTORY/test-lib.sh"

which in turn lets the test framework to learn GIT_BUILD_DIR. From there, 'git' will be found in GIT_BUILD_DIR/bin-wrappers and the valgrind variants are found in a similar way.

One thing that is potentially missing is a way for such an out-of-tree test scripts to ship with supporting material in a separate file, relative to the test script. The in-tree t/t4013-diff-various.sh has its test vectors kept in t/t4013/ directory and finds them by doing

	expect="$TEST_DIRECTORY/t4013/diff.$test"

This is because the working directory after test-lib comes back to us may not be "trash" directory under TEST_DIRECTORY, and ../t4013/ is not the right way to find it. If an out-of-tree test t9999 wants to do something similar, it needs to do something like:

	#!/bin/sh
        HERE=$(PWD)
	TEST_DIRECTORY=/srv/project/git/git.git/t
        test_description='an out-of-tree test'
        . "$TEST_DIRECTORY/test-lib.sh"
and find it relative to $HERE, e.g. "$HERE/../t9999/diff.$test"

Of course, it would be nice to use a name better than $HERE for such a purpose ;-)

Previous: Junio C HamanoNext: David A. Greene
Message 10 of 18 in “Allow Overriding GIT_BUILD_DIR”
  1. 1/2 Allow Overriding GIT_BUILD_DIRgreened@obbligato.org, Mar 4, 2012
  2. 2/2 Support Out-Of-Tree Valgrind Testsgreened@obbligato.org, Mar 4, 2012
  3. Thomas RastMar 5, 2012
  4. David A. GreeneMar 5, 2012
  5. Thomas RastMar 6, 2012
  6. David A. GreeneMar 6, 2012
  7. Junio C HamanoMar 6, 2012
  8. David A. GreeneMar 6, 2012
  9. Junio C HamanoMar 6, 2012
  10. Junio C HamanoMar 6, 2012
  11. David A. GreeneMar 6, 2012
  12. Junio C HamanoMar 6, 2012
  13. David A. GreeneMar 6, 2012
  14. Junio C HamanoMar 6, 2012
  15. Junio C HamanoMar 5, 2012
  16. David A. GreeneMar 5, 2012
  17. Junio C HamanoMar 5, 2012
  18. David A. GreeneMar 6, 2012

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.