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

Re: [PATCH v3 3/4] test-lib: make $GIT_BUILD_DIR an absolute path

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 23, 2022, 20:16 UTC
Message-ID
<xmqq4k4puyn9.fsf@gitster.g>
In-Reply-To
<220222.86o82z8als.gmgdl@evledraar.gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 67 quoted lines
> On Mon, Feb 21 2022, Junio C Hamano wrote:
>
>> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>>
>>>> Sorry to notice this so late, but this hunk caught my eye. What happens
>>>> if `TEST_DIRECTORY` is provided by the user (and doesn't end in "/t")?
>>>
>>> I think that the preceding 2/4 should cover your concern here, i.e. I
>>> think that's not possible.
>>>
>>>> Before this change, we would have set GIT_BUILD_DIR to the parent of
>>>> whatever TEST_DIRECTORY is, whether or not it ended in "/t". We'll still
>>>> do the same thing with this patch if TEST_DIRECTORY ends in "/t". But if
>>>> it doesn't, then we'll set GIT_BUILD_DIR to be the same as
>>>> TEST_DIRECTORY, which is a behavior change.
>>>
>>> Indeed, but I believe (again see 2/4) that can't happen.
>>
>> It is not like "can't happen", but "whoever wrote the TEST_DIRECTORY
>> override logic did not mean to support such a use case".
>
> To clarify with "can't happen" I mean (and should have said) that "can't
> work", i.e. it would error out anyway.
>
> E.g. try in a git.git checkout:
>     
>     (
>         mv t t2 &&
>         cd t &&
>         ./t0001-init.sh
>     )
>
> It will die with:
>     
>     You need to build test-tool:
>     Run "make t/helper/test-tool" in the source (toplevel) directory
>     FATAL: Unexpected exit with code 1
>
> And if you were to manually patch test-lib.sh to get past that error it
> would start erroring on e.g.:
>
>     sed: couldn't open file /home/avar/g/git/t2/../t/chainlint.sed: No such file or directory
>
> And if you "fix" that it'll error out on something else.
>
> I.e. we'll have discovered that $(pwd)/.. must be our build directory,
> and we then construct paths by adding the string "/t/[...]" to that.
>
>> I am perfectly fine if we declared that we do not to support the use
>> of that override mechanism by anybody but the "subtest" thing we do
>> ourselves.  If we can catch a workflow that misuses the mechansim
>> cheaply enough (e.g. perhaps erroring out if TEST_DIRECTORY is set
>> and it does not end in "/t"), we should do so, I would think, instead
>> of doing the "go up and do pwd", which will make things worse.
>
> What I was going for in 2/4 in
> http://lore.kernel.org/git/patch-v3-2.4-33a628e9c3a-20220221T155656Z-avarab@gmail.com
> is that we've already declared that. I.e. test-lib.sh has various
> assumptions about appending "/t/..." to the build directory being a
> valid way to get paths to various test-lib.sh-adjacent code.
>
> So trimming off "/t" here with a string operation v.s. $(cd .. && pwd)
> is being consistent with that code.
>
> It would be odd to make the bit at the top very generic, only to have
> the reader keep reading and wonder how that generic mechanism and the
> subsequent hardcoding of "/t/[...]" are supposed to work together.

Correct. That is why I said $(... pwd) to pretend that we can take anything would make it worse in a separate message.

If we have to strip off /t anyway, piggy-backing on that part to detect and abort when somebody misused the mechanism would be a good idea---which is what I said in the message you are responding to and not responding to.

Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 27 of 39 in “test-lib: improve LSAN + ASAN stack traces”
  1. 0/4 test-lib: improve LSAN + ASAN stack tracesÆvar Arnfjörð Bjarmason, Feb 18, 2022
  2. 1/4 test-lib: add XSAN_OPTIONS, inherit [AL]SAN_OPTIONSÆvar Arnfjörð Bjarmason, Feb 18, 2022
  3. Junio C HamanoFeb 18, 2022
  4. Taylor BlauFeb 19, 2022
  5. Ævar Arnfjörð BjarmasonFeb 19, 2022
  6. Taylor BlauFeb 19, 2022
  7. Ævar Arnfjörð BjarmasonFeb 19, 2022
  8. Taylor BlauFeb 19, 2022
  9. 2/4 test-lib: make $GIT_BUILD_DIR an absolute pathÆvar Arnfjörð Bjarmason, Feb 18, 2022
  10. Junio C HamanoFeb 18, 2022
  11. Ævar Arnfjörð BjarmasonFeb 19, 2022
  12. 0/4 test-lib: improve LSAN + ASAN stack tracesÆvar Arnfjörð Bjarmason, Feb 19, 2022
  13. 1/4 test-lib: add GIT_XSAN_OPTIONS, inherit [AL]SAN_OPTIONSÆvar Arnfjörð Bjarmason, Feb 19, 2022
  14. Junio C HamanoFeb 20, 2022
  15. 2/4 test-lib: correct commentary on TEST_DIRECTORY overridingÆvar Arnfjörð Bjarmason, Feb 19, 2022
  16. 3/4 test-lib: make $GIT_BUILD_DIR an absolute pathÆvar Arnfjörð Bjarmason, Feb 19, 2022
  17. 4/4 test-lib: add "fast_unwind_on_malloc=0" to LSAN_OPTIONSÆvar Arnfjörð Bjarmason, Feb 19, 2022
  18. Taylor BlauFeb 21, 2022
  19. 0/4 test-lib: improve LSAN + ASAN stack tracesÆvar Arnfjörð Bjarmason, Feb 21, 2022
  20. 1/4 test-lib: add GIT_SAN_OPTIONS, inherit [AL]SAN_OPTIONSÆvar Arnfjörð Bjarmason, Feb 21, 2022
  21. 2/4 test-lib: correct commentary on TEST_DIRECTORY overridingÆvar Arnfjörð Bjarmason, Feb 21, 2022
  22. 3/4 test-lib: make $GIT_BUILD_DIR an absolute pathÆvar Arnfjörð Bjarmason, Feb 21, 2022
  23. Taylor BlauFeb 21, 2022
  24. Ævar Arnfjörð BjarmasonFeb 21, 2022
  25. Junio C HamanoFeb 22, 2022
  26. Ævar Arnfjörð BjarmasonFeb 22, 2022
  27. Junio C HamanoFeb 23, 2022
  28. Ævar Arnfjörð BjarmasonFeb 24, 2022
  29. Junio C HamanoFeb 24, 2022
  30. 4/4 test-lib: add "fast_unwind_on_malloc=0" to LSAN_OPTIONSÆvar Arnfjörð Bjarmason, Feb 21, 2022
  31. Taylor BlauFeb 21, 2022
  32. Ævar Arnfjörð BjarmasonFeb 21, 2022
  33. Junio C HamanoFeb 21, 2022
  34. Ævar Arnfjörð BjarmasonFeb 21, 2022
  35. 0/4 test-lib: improve LSAN + ASAN stack tracesÆvar Arnfjörð Bjarmason, Feb 27, 2022
  36. 1/4 test-lib: add GIT_SAN_OPTIONS, inherit [AL]SAN_OPTIONSÆvar Arnfjörð Bjarmason, Feb 27, 2022
  37. 2/4 test-lib: correct and assert TEST_DIRECTORY overridingÆvar Arnfjörð Bjarmason, Feb 27, 2022
  38. 3/4 test-lib: make $GIT_BUILD_DIR an absolute pathÆvar Arnfjörð Bjarmason, Feb 27, 2022
  39. 4/4 test-lib: add "fast_unwind_on_malloc=0" to LSAN_OPTIONSÆvar Arnfjörð Bjarmason, Feb 27, 2022

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.