{"thread":{"id":"29741","subject":"[PATCH] Allow Overriding GIT_BUILD_DIR","startedAt":"2012-02-05T22:28:06Z","lastAt":"2012-03-02T09:25:37Z","messageCount":4,"participants":["David A. Greene","Junio C Hamano","Thomas Rast"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"185446","messageId":"87vcmu5psm.fsf@smith.obbligato.org","threadId":"29741","inReplyTo":null,"subject":"[PATCH] Allow Overriding GIT_BUILD_DIR","fromName":"David A. Greene","fromEmail":"greened@obbligato.org","sentAt":"2012-02-05T22:28:06Z","receivedAt":"2012-02-05T22:28:06Z","isPatch":true,"sender":{"key":"greened@obbligato.org","avatar":"https://avatars.githubusercontent.com/u/5291869?v=4"},"body":"\nLet tests override GIT_BUILD_DIR so git will work if tests are not at\nthe same directory level as standard git tests.  Prior to this change,\nGIT_BUILD_DIR is hardwired to be exactly one directory above where the\ntest lives.  A test within contrib/, for example, can now use\ntest-lib.sh and set an appropriate value for GIT_BUILD_DIR.\n\nSigned-off-by: David A. Greene <greened@obbligato.org>\n---\n t/test-lib.sh |   10 +++++++++-\n 1 files changed, 9 insertions(+), 1 deletions(-)\n\n\n------------------\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex a65dfc7..4585138 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -55,6 +55,7 @@ unset $(perl -e '\n \t\t.*_TEST\n \t\tPROVE\n \t\tVALGRIND\n+                BUILD_DIR\n \t));\n \tmy @vars = grep(/^GIT_/ && !/^GIT_($ok)/o, @env);\n \tprint join(\"\\n\", @vars);\n@@ -901,7 +902,14 @@ then\n \t# itself.\n \tTEST_DIRECTORY=$(pwd)\n fi\n-GIT_BUILD_DIR=\"$TEST_DIRECTORY\"/..\n+\n+if test -z \"$GIT_BUILD_DIR\"\n+then\n+\t# We allow tests to override this, in case they want to run tests\n+\t# outside of t/, e.g. for running tests on the test library\n+\t# itself.\n+        GIT_BUILD_DIR=\"$TEST_DIRECTORY\"/..\n+fi\n \n if test -n \"$valgrind\"\n then\n\n--------------------\n"},{"id":"185471","messageId":"7vpqd1dyq7.fsf@alter.siamese.dyndns.org","threadId":"29741","inReplyTo":"87vcmu5psm.fsf@smith.obbligato.org","subject":"Re: [PATCH] Allow Overriding GIT_BUILD_DIR","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-02-26T22:19:28Z","receivedAt":"2012-02-26T22:19:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"David A. Greene\" <greened@obbligato.org> writes:\n\n> Let tests override GIT_BUILD_DIR so git will work if tests are not at\n> the same directory level as standard git tests.  Prior to this change,\n> GIT_BUILD_DIR is hardwired to be exactly one directory above where the\n> test lives.  A test within contrib/, for example, can now use\n> test-lib.sh and set an appropriate value for GIT_BUILD_DIR.\n\nOk, this is getting closer. We use GIT_BUILD_DIR to find out crucial bits\nof the build environment in order to run tests, like the binaries being\ntested that are in $GIT_BUILD_DIR/bin-wrappers, but we set GIT_BUILD_DIR\nalways to one level above where the test script being run is (because they\nare typically t/t1234-name.sh).  By making them able to name GIT_BUILD_DIR\ndirectly to a place that is different from a level above \"$TEST_DIRECTORY\",\na test script can live anywhere.\n\nThere are two more things that worries me a bit.\n\nOne is what TEST_DIRECTORY should mean in the new world order.  We use it\nto find where the test-lib.sh and other lib-*.sh helper definitions are,\nalso we use it to find large-ish test vectors like t3900/ and t4013/.  If\nan external test script t1234-git-subtree.sh wants to use a separate file\nto keep its own helper definitions, how should it name it?  It cannot be\nrelative to TEST_DIRECTORY that is typically \"t/\".  It cannot be relative\nto \"../\" as TRASH_DIRECTORY where the script runs, as the --root option\nmay move it elsewhere on the filesystem (and is the reason TEST_DIRECTORY\nvariable exists in the first place).\n\nAnd how well does an external test script work with the --root option that\nmoves the TEST_DIRECTORY?\n\n> Signed-off-by: David A. Greene <greened@obbligato.org>\n> ---\n>  t/test-lib.sh |   10 +++++++++-\n>  1 files changed, 9 insertions(+), 1 deletions(-)\n>\n>\n> ------------------\n>\n> diff --git a/t/test-lib.sh b/t/test-lib.sh\n> index a65dfc7..4585138 100644\n> --- a/t/test-lib.sh\n> +++ b/t/test-lib.sh\n> @@ -55,6 +55,7 @@ unset $(perl -e '\n>  \t\t.*_TEST\n>  \t\tPROVE\n>  \t\tVALGRIND\n> +                BUILD_DIR\n\nA funny    indentation found here.\n\n>  \t));\n\n> @@ -901,7 +902,14 @@ then\n>  \t# itself.\n>  \tTEST_DIRECTORY=$(pwd)\n>  fi\n> -GIT_BUILD_DIR=\"$TEST_DIRECTORY\"/..\n> +\n> +if test -z \"$GIT_BUILD_DIR\"\n> +then\n> +\t# We allow tests to override this, in case they want to run tests\n> +\t# outside of t/, e.g. for running tests on the test library\n> +\t# itself.\n\n# For in-tree test scripts, this is one level above the TEST_DIRECTORY\n# (t/), but a test script that lives outside t/ can set this variable to\n# point at the right place so that it can find t/ directory that house\n# test helpers like lib-pager*.sh and test vectors like t4013/.\n\n> +        GIT_BUILD_DIR=\"$TEST_DIRECTORY\"/..\n> +fi\n>  \n>  if test -n \"$valgrind\"\n>  then\n>\n> --------------------\n"},{"id":"185876","messageId":"87fwdrk6d4.fsf@smith.obbligato.org","threadId":"29741","inReplyTo":"7vpqd1dyq7.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] Allow Overriding GIT_BUILD_DIR","fromName":"David A. Greene","fromEmail":"greened@obbligato.org","sentAt":"2012-03-02T03:51:35Z","receivedAt":"2012-03-02T03:51:35Z","isPatch":true,"sender":{"key":"greened@obbligato.org","avatar":"https://avatars.githubusercontent.com/u/5291869?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Ok, this is getting closer. We use GIT_BUILD_DIR to find out crucial bits\n> of the build environment in order to run tests, like the binaries being\n> tested that are in $GIT_BUILD_DIR/bin-wrappers, but we set GIT_BUILD_DIR\n> always to one level above where the test script being run is (because they\n> are typically t/t1234-name.sh).  By making them able to name GIT_BUILD_DIR\n> directly to a place that is different from a level above \"$TEST_DIRECTORY\",\n> a test script can live anywhere.\n\nRight.\n\n> There are two more things that worries me a bit.\n>\n> One is what TEST_DIRECTORY should mean in the new world order.  \n\nThat and its interaction with GIT_BUILD_DIR really confused me when I\nwas trying to get the subtree tests to work.  I think they could use\neither a bit more documentation or a bit more separation of purpose.\nI'm not sure which.\n\n> We use it to find where the test-lib.sh and other lib-*.sh helper\n> definitions are, also we use it to find large-ish test vectors like\n> t3900/ and t4013/.  If an external test script t1234-git-subtree.sh\n> wants to use a separate file to keep its own helper definitions, how\n> should it name it?  It cannot be relative to TEST_DIRECTORY that is\n> typically \"t/\".  It cannot be relative to \"../\" as TRASH_DIRECTORY\n> where the script runs, as the --root option may move it elsewhere on\n> the filesystem (and is the reason TEST_DIRECTORY variable exists in\n> the first place).\n\nI must admit I am still confused about what these variables do even\nafter reading this explanation several times.  I have a pretty good\nidea what TRASH_DIRECTORY is.\n\n> And how well does an external test script work with the --root option that\n> moves the TEST_DIRECTORY?\n\nI have no idea.  I didn't even know about --root and I still don't know\nwhat it does.  It would be helpful to have some commentary about\noptions.\n\nI am willing to add comments (as a separate patch?) as I figure out what\nthese things do.  Perhaps I'll write up a patch and get feedback to spur\ndiscussion so I can come to better understanding.  :)\n\n>> @@ -55,6 +55,7 @@ unset $(perl -e '\n>>  \t\t.*_TEST\n>>  \t\tPROVE\n>>  \t\tVALGRIND\n>> +                BUILD_DIR\n>\n> A funny    indentation found here.\n\nWill fix.\n\n>> +if test -z \"$GIT_BUILD_DIR\"\n>> +then\n>> +\t# We allow tests to override this, in case they want to run tests\n>> +\t# outside of t/, e.g. for running tests on the test library\n>> +\t# itself.\n>\n> # For in-tree test scripts, this is one level above the TEST_DIRECTORY\n> # (t/), but a test script that lives outside t/ can set this variable to\n> # point at the right place so that it can find t/ directory that house\n> # test helpers like lib-pager*.sh and test vectors like t4013/.\n\nThis is good commentary.  Will add.\n\n                                -Dave\n"},{"id":"185896","messageId":"87hay7e4mm.fsf@thomas.inf.ethz.ch","threadId":"29741","inReplyTo":"87fwdrk6d4.fsf@smith.obbligato.org","subject":"Re: [PATCH] Allow Overriding GIT_BUILD_DIR","fromName":"Thomas Rast","fromEmail":"trast@inf.ethz.ch","sentAt":"2012-03-02T09:25:37Z","receivedAt":"2012-03-02T09:25:37Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"greened@obbligato.org (David A. Greene) writes:\n\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>> We use it to find where the test-lib.sh and other lib-*.sh helper\n>> definitions are, also we use it to find large-ish test vectors like\n>> t3900/ and t4013/.  If an external test script t1234-git-subtree.sh\n>> wants to use a separate file to keep its own helper definitions, how\n>> should it name it?  It cannot be relative to TEST_DIRECTORY that is\n>> typically \"t/\".  It cannot be relative to \"../\" as TRASH_DIRECTORY\n>> where the script runs, as the --root option may move it elsewhere on\n>> the filesystem (and is the reason TEST_DIRECTORY variable exists in\n>> the first place).\n>\n> I must admit I am still confused about what these variables do even\n> after reading this explanation several times.  I have a pretty good\n> idea what TRASH_DIRECTORY is.\n>\n>> And how well does an external test script work with the --root option that\n>> moves the TEST_DIRECTORY?\n\nI think Junio meant TRASH_DIRECTORY here, too.\n\n> I have no idea.  I didn't even know about --root and I still don't know\n> what it does.  It would be helpful to have some commentary about\n> options.\n\n--root tells the tests where to put its TRASH_DIRECTORY and is\nfrequently used to place it on a tmpfs (such as /dev/shm) as that gives\nthe tests a *huge* speed boost.\n\nThat is, if I say\n\n  ./t5510-fetch.sh --root=/dev/shm\n\nthen the \"main test repo\" aka TRASH_DIRECTORY is\n\n  /dev/shm/trash directory.t5510-fetch\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"}]}