{"thread":{"id":"31109","subject":"[PATCH 1/2] test: rename $satisfied to $satisfied_prereq","startedAt":"2012-07-26T23:04:56Z","lastAt":"2012-07-27T17:15:02Z","messageCount":7,"participants":["Junio C Hamano","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"195902","messageId":"7vboj25dk7.fsf@alter.siamese.dyndns.org","threadId":"31109","inReplyTo":null,"subject":"[PATCH 1/2] test: rename $satisfied to $satisfied_prereq","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-07-26T23:04:56Z","receivedAt":"2012-07-26T23:04:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"All other shell variables that globally keep track of prerequisite\nrelated states have \"prereq\" somewhere in their names.  Be consistent\nand avoid name crashes.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n * Just a preparatory clean-up.\n\n t/test-lib-functions.sh | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 80daaca..4dc027d 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -221,9 +221,9 @@ write_script () {\n # capital letters by convention).\n \n test_set_prereq () {\n-\tsatisfied=\"$satisfied$1 \"\n+\tsatisfied_prereq=\"$satisfied_prereq$1 \"\n }\n-satisfied=\" \"\n+satisfied_prereq=\" \"\n \n test_have_prereq () {\n \t# prerequisites can be concatenated with ','\n@@ -239,7 +239,7 @@ test_have_prereq () {\n \tfor prerequisite\n \tdo\n \t\ttotal_prereq=$(($total_prereq + 1))\n-\t\tcase $satisfied in\n+\t\tcase \"$satisfied_prereq\" in\n \t\t*\" $prerequisite \"*)\n \t\t\tok_prereq=$(($ok_prereq + 1))\n \t\t\t;;\n-- \n1.7.12.rc0.44.gc69a8ad\n"},{"id":"195903","messageId":"7v7gtq5da3.fsf@alter.siamese.dyndns.org","threadId":"31109","inReplyTo":"7vboj25dk7.fsf@alter.siamese.dyndns.org","subject":"[RFC/PATCH 2/2] test: allow prerequisite to be evaluated lazily","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-07-26T23:11:00Z","receivedAt":"2012-07-26T23:11:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The test prerequisite mechanism is a useful way to allow some tests\nin a test script to be skipped in environments that do not offer\ncertain features (e.g. checking how symbolic links are handled on\nfilesystems that do not support them).  It is OK for commonly used\nprerequisites to be always tested during start-up of test script by\nhaving a codeblock that tests a feature and calls test_set_prereq,\nbut for an uncommon feature, forcing 90% of scripts to pay the same\nprobing overhead for prerequisite they do not care about is wasteful.\n\nIntroduce a mechanism to probe the prerequiste lazily.  Changes are:\n\n - test_lazy_prereq () function, which takes the name of the\n   prerequisite it probes and the script to probe for it, is\n   added.  This only registers the name of the prerequiste that can\n   be lazily probed and the script to eval (without running).\n\n - test_have_prereq() function (which is used by test_expect_success\n   and also can be called directly by test scripts) learns to look\n   at the list of prerequisites that can be lazily probed, and the\n   prerequisites that have already been probed that way.\n\nUpdate the codeblock to probe and set SYMLINKS prerequisite using\nthe new mechanism as an example.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n * I thought about various error conditions but didn't come up with\n   a solid conclusion.  For example, what should happen when the\n   prober directory cannot be created, or removed?  Perhaps aborting\n   the whole thing may be a safe and better option.\n\n   Also, I am not distinguishing a syntax error in the script and\n   \"the prerequisite is not satisfied\" signal (they would both be a\n   false in the \"if ()\" part). I do not think we care too much, but\n   others may have better ideas.\n\n t/test-lib-functions.sh | 28 ++++++++++++++++++++++++++++\n t/test-lib.sh           |  7 ++++---\n 2 files changed, 32 insertions(+), 3 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 4dc027d..2214388 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -224,6 +224,13 @@ test_set_prereq () {\n \tsatisfied_prereq=\"$satisfied_prereq$1 \"\n }\n satisfied_prereq=\" \"\n+lazy_testable_prereq= lazy_tested_prereq=\n+\n+# Usage: test_lazy_prereq PREREQ 'script'\n+test_lazy_prereq () {\n+\tlazy_testable_prereq=\"$lazy_testable_prereq$1 \"\n+\teval test_prereq_lazily_$1=\\$2\n+}\n \n test_have_prereq () {\n \t# prerequisites can be concatenated with ','\n@@ -238,6 +245,27 @@ test_have_prereq () {\n \n \tfor prerequisite\n \tdo\n+\t\tcase \" $lazy_tested_prereq \" in\n+\t\t*\" $prerequisite \"*)\n+\t\t\t;;\n+\t\t*)\n+\t\t\tcase \" $lazy_testable_prereq \" in\n+\t\t\t*\" $prerequisite \"*)\n+\t\t\t\tmkdir -p \"$TRASH_DIRECTORY/prereq-test-dir\"\n+\t\t\t\tif (\n+\t\t\t\t\teval \"script=\\$test_prereq_lazily_$prerequisite\" &&\n+\t\t\t\t\tcd \"$TRASH_DIRECTORY/prereq-test-dir\" &&\n+\t\t\t\t\teval \"$script\"\n+\t\t\t\t)\n+\t\t\t\tthen\n+\t\t\t\t\ttest_set_prereq $prerequisite\n+\t\t\t\tfi\n+\t\t\t\trm -fr \"$TRASH_DIRECTORY/prereq-test-dir\"\n+\t\t\t\tlazy_tested_prereq=\"$lazy_tested_prereq$prerequisite \"\n+\t\t\tesac\n+\t\t\t;;\n+\t\tesac\n+\n \t\ttotal_prereq=$(($total_prereq + 1))\n \t\tcase \"$satisfied_prereq\" in\n \t\t*\" $prerequisite \"*)\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex bb4f886..878d000 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -659,9 +659,10 @@ test_i18ngrep () {\n \tfi\n }\n \n-# test whether the filesystem supports symbolic links\n-ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS\n-rm -f y\n+test_lazy_prereq SYMLINKS '\n+\t# test whether the filesystem supports symbolic links\n+\tln -s x y 2>/dev/null && test -h y 2>/dev/null\n+'\n \n # When the tests are run as root, permission tests will report that\n # things are writable when they shouldn't be.\n-- \n1.7.12.rc0.44.gc69a8ad\n"},{"id":"195904","messageId":"7v394e5cv5.fsf_-_@alter.siamese.dyndns.org","threadId":"31109","inReplyTo":"7v7gtq5da3.fsf@alter.siamese.dyndns.org","subject":"[PATCH 3/2] test-lib: provide case insensitivity as a prerequisite","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-07-26T23:19:58Z","receivedAt":"2012-07-26T23:19:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"And on top, Michael's [1/5] would become like this, and [2/5] would\napply unchanged.\n\n-- >8 --\nFrom: Michael J Gruber <git@drmicha.warpmail.net>\nDate: Thu, 26 Jul 2012 15:39:53 +0200\n\nCase insensitivity plays a role in several tests and is tested in several\ntests. Therefore, move the test from t003 into the test lib and use the\nprerequisite in t0003.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n t/README              |  4 ++++\n t/t0003-attributes.sh | 10 ----------\n t/test-lib.sh         |  6 ++++++\n 3 files changed, 10 insertions(+), 10 deletions(-)\n\ndiff --git a/t/README b/t/README\nindex 4c3ea25..5725607 100644\n--- a/t/README\n+++ b/t/README\n@@ -625,6 +625,10 @@ use these, and \"test_set_prereq\" for how to define your own.\n    Git was compiled with USE_LIBPCRE=YesPlease. Wrap any tests\n    that use git-grep --perl-regexp or git-grep -P in these.\n \n+ - CASE_INSENSITIVE_FS\n+\n+   Test is run on a case insensitive file system.\n+\n Tips for Writing Tests\n ----------------------\n \ndiff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh\nindex 51f3045..febc45c 100755\n--- a/t/t0003-attributes.sh\n+++ b/t/t0003-attributes.sh\n@@ -123,16 +123,6 @@ test_expect_success 'attribute matching is case insensitive when core.ignorecase\n \n '\n \n-test_expect_success 'check whether FS is case-insensitive' '\n-\tmkdir junk &&\n-\techo good >junk/CamelCase &&\n-\techo bad >junk/camelcase &&\n-\tif test \"$(cat junk/CamelCase)\" != good\n-\tthen\n-\t\ttest_set_prereq CASE_INSENSITIVE_FS\n-\tfi\n-'\n-\n test_expect_success CASE_INSENSITIVE_FS 'additional case insensitivity tests' '\n \ttest_must_fail attr_check a/B/D/g \"a/b/d/*\" \"-c core.ignorecase=0\" &&\n \ttest_must_fail attr_check A/B/D/NO \"a/b/d/*\" \"-c core.ignorecase=0\" &&\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 878d000..52cb32a 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -664,6 +664,12 @@ test_lazy_prereq SYMLINKS '\n \tln -s x y 2>/dev/null && test -h y 2>/dev/null\n '\n \n+test_lazy_prereq CASE_INSENSITIVE_FS '\n+\techo good >CamelCase &&\n+\techo bad >camelcase &&\n+\ttest \"$(cat CamelCase)\" != good\n+'\n+\n # When the tests are run as root, permission tests will report that\n # things are writable when they shouldn't be.\n test -w / || test_set_prereq SANITY\n-- \n1.7.12.rc0.44.gc69a8ad\n"},{"id":"195909","messageId":"7vy5m63xwd.fsf_-_@alter.siamese.dyndns.org","threadId":"31109","inReplyTo":"7v394e5cv5.fsf_-_@alter.siamese.dyndns.org","subject":"[PATCH 4/2] test-lib: provide UTF8 behaviour as a prerequisite","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-07-26T23:28:34Z","receivedAt":"2012-07-26T23:28:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"And Michael's [4/5] would become like this (again, [3/5] does not\nneed any change).\n\n-- >8 --\n\nFrom: Michael J Gruber <git@drmicha.warpmail.net>\nDate: Thu, 26 Jul 2012 15:39:56 +0200\n\nUTF8 behaviour of the filesystem (conversion from nfd to nfc)  plays a\nrole in several tests and is tested in several tests. Therefore, move\nthe test from t0050 into the test lib and use the prerequisite in t0050.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n t/README              |  5 +++++\n t/t0050-filesystem.sh | 24 +++++++-----------------\n t/test-lib.sh         | 13 +++++++++++++\n 3 files changed, 25 insertions(+), 17 deletions(-)\n\ndiff --git a/t/README b/t/README\nindex 5725607..e4128e5 100644\n--- a/t/README\n+++ b/t/README\n@@ -629,6 +629,11 @@ use these, and \"test_set_prereq\" for how to define your own.\n \n    Test is run on a case insensitive file system.\n \n+ - UTF8_NFD_TO_NFC\n+\n+   Test is run on a filesystem which converts decomposed utf-8 (nfd)\n+   to precomposed utf-8 (nfc).\n+\n Tips for Writing Tests\n ----------------------\n \ndiff --git a/t/t0050-filesystem.sh b/t/t0050-filesystem.sh\nindex b46ae72..78816d9 100755\n--- a/t/t0050-filesystem.sh\n+++ b/t/t0050-filesystem.sh\n@@ -7,22 +7,6 @@ test_description='Various filesystem issues'\n auml=$(printf '\\303\\244')\n aumlcdiar=$(printf '\\141\\314\\210')\n \n-unibad=\n-test_expect_success 'see what we expect' '\n-\n-\ttest_unicode=test_expect_success &&\n-\tmkdir junk &&\n-\t>junk/\"$auml\" &&\n-\tcase \"$(cd junk && echo *)\" in\n-\t\"$aumlcdiar\")\n-\t\ttest_unicode=test_expect_failure &&\n-\t\tunibad=t\n-\t\t;;\n-\t*)\t;;\n-\tesac &&\n-\trm -fr junk\n-'\n-\n if test_have_prereq CASE_INSENSITIVE_FS\n then\n \tsay \"will test on a case insensitive filesystem\"\n@@ -31,8 +15,14 @@ else\n \ttest_case=test_expect_success\n fi\n \n-test \"$unibad\" &&\n+if test_have_prereq UTF8_NFD_TO_NFC\n+then\n \tsay \"will test on a unicode corrupting filesystem\"\n+\ttest_unicode=test_expect_failure\n+else\n+\ttest_unicode=test_expect_success\n+fi\n+\n test_have_prereq SYMLINKS ||\n \tsay \"will test on a filesystem lacking symbolic links\"\n \ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 52cb32a..95c966e 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -670,6 +670,19 @@ test_lazy_prereq CASE_INSENSITIVE_FS '\n \ttest \"$(cat CamelCase)\" != good\n '\n \n+test_lazy_prereq UTF8_NFD_TO_NFC '\n+\t# check whether FS converts nfd unicode to nfc\n+\tauml=$(printf \"\\303\\244\")\n+\taumlcdiar=$(printf \"\\141\\314\\210\")\n+\t>\"$auml\" &&\n+\tcase \"$(echo *)\" in\n+\t\"$aumlcdiar\")\n+\t\ttrue ;;\n+\t*)\n+\t\tfalse ;;\n+\tesac\n+'\n+\n # When the tests are run as root, permission tests will report that\n # things are writable when they shouldn't be.\n test -w / || test_set_prereq SANITY\n-- \n1.7.12.rc0.44.gc69a8ad\n"},{"id":"195945","messageId":"20120727154500.GA11957@sigill.intra.peff.net","threadId":"31109","inReplyTo":"7v7gtq5da3.fsf@alter.siamese.dyndns.org","subject":"Re: [RFC/PATCH 2/2] test: allow prerequisite to be evaluated lazily","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-07-27T15:45:00Z","receivedAt":"2012-07-27T15:45:00Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Jul 26, 2012 at 04:11:00PM -0700, Junio C Hamano wrote:\n\n> Introduce a mechanism to probe the prerequiste lazily.  Changes are:\n> \n>  - test_lazy_prereq () function, which takes the name of the\n>    prerequisite it probes and the script to probe for it, is\n>    added.  This only registers the name of the prerequiste that can\n>    be lazily probed and the script to eval (without running).\n> \n>  - test_have_prereq() function (which is used by test_expect_success\n>    and also can be called directly by test scripts) learns to look\n>    at the list of prerequisites that can be lazily probed, and the\n>    prerequisites that have already been probed that way.\n\nThe overall strategy looks good to me. A few minor comments follow.\n\n>  * I thought about various error conditions but didn't come up with\n>    a solid conclusion.  For example, what should happen when the\n>    prober directory cannot be created, or removed?  Perhaps aborting\n>    the whole thing may be a safe and better option.\n\nYeah, it would be safer. But we have the same problems in the probes\nthemselves, which sometimes have setup steps (e.g., before this patch,\nthey typically set up the equivalent of the probe directory themselves).\nFixing it completely would involve the probes returning a tri-state\n(yes, no, error), but it would make them more annoying to write.\n\nSo you are at least preserving the status quo, and as far as I know,\nthat has never been a problem in practice.\n\n>    Also, I am not distinguishing a syntax error in the script and\n>    \"the prerequisite is not satisfied\" signal (they would both be a\n>    false in the \"if ()\" part). I do not think we care too much, but\n>    others may have better ideas.\n\nFor a syntax error in a regular test, the script aborts (and you get\na \"FATAL: unexpected exit...\"). It probably makes sense to do the same\nthing here. I find it is helpful when writing tests to have an immediate\nabort instead of having to investigate why your test did not pass.\n\n> +\t\t\t*\" $prerequisite \"*)\n> +\t\t\t\tmkdir -p \"$TRASH_DIRECTORY/prereq-test-dir\"\n> +\t\t\t\tif (\n> +\t\t\t\t\teval \"script=\\$test_prereq_lazily_$prerequisite\" &&\n> +\t\t\t\t\tcd \"$TRASH_DIRECTORY/prereq-test-dir\" &&\n> +\t\t\t\t\teval \"$script\"\n> +\t\t\t\t)\n\nI expected to see test_run_ here so we could get the usual redirections\nand \"-v\" support in case the probe has useful output (and it might be\nnice to report to the user during \"-v\" that we are checking the prereq,\nand what we are about to do).\n\nPushing the subshell and chdir inside the test would let us just die\nnaturally on syntax errors, like regular tests do. There's no reason not\nto put the mkdir there, too, so that somebody debugging via \"-v\" can see\nmore of what's happening.\n\nSomething like this on top of your patch:\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 2214388..f5831cc 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -232,6 +232,21 @@ test_lazy_prereq () {\n \teval test_prereq_lazily_$1=\\$2\n }\n \n+test_run_prereq_ () {\n+\tscript='\n+mkdir -p \"$TRASH_DIRECTORY/prereq-test-dir\" &&\n+(cd \"$TRASH_DIRECTORY/prereq-test-dir\" &&\n+'\"$2\"'\n+)\n+'\n+\tsay >&3 \"checking prerequisite: $1\"\n+\tsay >&3 \"$script\"\n+\ttest_eval_ \"$script\"\n+\teval_ret=$?\n+\trm -rf \"$TRASH_DIRECTORY/prereq-test-dir\"\n+\treturn $eval_ret\n+}\n+\n test_have_prereq () {\n \t# prerequisites can be concatenated with ','\n \tsave_IFS=$IFS\n@@ -251,16 +266,11 @@ test_have_prereq () {\n \t\t*)\n \t\t\tcase \" $lazy_testable_prereq \" in\n \t\t\t*\" $prerequisite \"*)\n-\t\t\t\tmkdir -p \"$TRASH_DIRECTORY/prereq-test-dir\"\n-\t\t\t\tif (\n-\t\t\t\t\teval \"script=\\$test_prereq_lazily_$prerequisite\" &&\n-\t\t\t\t\tcd \"$TRASH_DIRECTORY/prereq-test-dir\" &&\n-\t\t\t\t\teval \"$script\"\n-\t\t\t\t)\n+\t\t\t\teval \"script=\\$test_prereq_lazily_$prerequisite\" &&\n+\t\t\t\tif test_run_prereq_ \"$prerequisite\" \"$script\"\n \t\t\t\tthen\n \t\t\t\t\ttest_set_prereq $prerequisite\n \t\t\t\tfi\n-\t\t\t\trm -fr \"$TRASH_DIRECTORY/prereq-test-dir\"\n \t\t\t\tlazy_tested_prereq=\"$lazy_tested_prereq$prerequisite \"\n \t\t\tesac\n \t\t\t;;\n\nTry it with a broken probe like:\n\n  $ cat >foo.sh <<EOF\n  #!/bin/sh\n\n  test_description='broken lazy eval'\n  . ./test-lib.sh\n  test_lazy_prereq LAZY 'broken &&'\n  test_expect_success LAZY 'need lazy' 'echo lazy ok'\n  test_done\n  EOF\n\n  : properly alert us to syntactic error\n  $ sh foo.sh\n  FATAL: Unexpected exit with code 2\n\n  : give sane output for debugging a broken probe\n  $ sh foo.sh -v\n  Initialized empty Git repository in /home/peff/compile/git/t/trash directory.foo/.git/\n  checking prerequisite: LAZY\n\n  mkdir -p \"$TRASH_DIRECTORY/prereq-test-dir\" &&\n  (cd \"$TRASH_DIRECTORY/prereq-test-dir\" &&\n  broken &&\n  )\n\n  foo.sh: 5: eval: Syntax error: \")\" unexpected\n  FATAL: Unexpected exit with code 2\n\nAnd of course with non-broken probes, \"-v\" would also help to see exactly\nwhen the probe is run, using which commands, and what output they\nproduced. E.g., for SYMLINKS, we should probably drop the stderr\nredirection from the probe so we can see how \"ln\" complains.\n\nIt might also be worth doing a \"say >&3\" at the end of the check, too,\nto tell \"-v\" users the outcome.\n\n-Peff\n"},{"id":"195946","messageId":"20120727155000.GB11957@sigill.intra.peff.net","threadId":"31109","inReplyTo":"20120727154500.GA11957@sigill.intra.peff.net","subject":"Re: [RFC/PATCH 2/2] test: allow prerequisite to be evaluated lazily","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-07-27T15:50:00Z","receivedAt":"2012-07-27T15:50:00Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Jul 27, 2012 at 11:45:00AM -0400, Jeff King wrote:\n\n> And of course with non-broken probes, \"-v\" would also help to see exactly\n> when the probe is run, using which commands, and what output they\n> produced. E.g., for SYMLINKS, we should probably drop the stderr\n> redirection from the probe so we can see how \"ln\" complains.\n> \n> It might also be worth doing a \"say >&3\" at the end of the check, too,\n> to tell \"-v\" users the outcome.\n\nHere is an updated version of my suggestion that does both of those\nthings.  I think it should just be squashed into your patch.\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 2214388..d2ebe24 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -232,6 +232,26 @@ test_lazy_prereq () {\n \teval test_prereq_lazily_$1=\\$2\n }\n \n+test_run_prereq_ () {\n+\tscript='\n+mkdir -p \"$TRASH_DIRECTORY/prereq-test-dir\" &&\n+(cd \"$TRASH_DIRECTORY/prereq-test-dir\" &&\n+'\"$2\"'\n+)\n+'\n+\tsay >&3 \"checking prerequisite: $1\"\n+\tsay >&3 \"$script\"\n+\ttest_eval_ \"$script\"\n+\teval_ret=$?\n+\trm -rf \"$TRASH_DIRECTORY/prereq-test-dir\"\n+\tif test \"$eval_ret\" = 0; then\n+\t\tsay >&3 \"prerequisite $1 ok\"\n+\telse\n+\t\tsay >&3 \"prerequisite $1 not fulfilled\"\n+\tfi\n+\treturn $eval_ret\n+}\n+\n test_have_prereq () {\n \t# prerequisites can be concatenated with ','\n \tsave_IFS=$IFS\n@@ -251,16 +271,11 @@ test_have_prereq () {\n \t\t*)\n \t\t\tcase \" $lazy_testable_prereq \" in\n \t\t\t*\" $prerequisite \"*)\n-\t\t\t\tmkdir -p \"$TRASH_DIRECTORY/prereq-test-dir\"\n-\t\t\t\tif (\n-\t\t\t\t\teval \"script=\\$test_prereq_lazily_$prerequisite\" &&\n-\t\t\t\t\tcd \"$TRASH_DIRECTORY/prereq-test-dir\" &&\n-\t\t\t\t\teval \"$script\"\n-\t\t\t\t)\n+\t\t\t\teval \"script=\\$test_prereq_lazily_$prerequisite\" &&\n+\t\t\t\tif test_run_prereq_ \"$prerequisite\" \"$script\"\n \t\t\t\tthen\n \t\t\t\t\ttest_set_prereq $prerequisite\n \t\t\t\tfi\n-\t\t\t\trm -fr \"$TRASH_DIRECTORY/prereq-test-dir\"\n \t\t\t\tlazy_tested_prereq=\"$lazy_tested_prereq$prerequisite \"\n \t\t\tesac\n \t\t\t;;\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 878d000..35739b9 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -661,7 +661,7 @@ test_i18ngrep () {\n \n test_lazy_prereq SYMLINKS '\n \t# test whether the filesystem supports symbolic links\n-\tln -s x y 2>/dev/null && test -h y 2>/dev/null\n+\tln -s x y && test -h y\n '\n \n # When the tests are run as root, permission tests will report that\n"},{"id":"195949","messageId":"7vfw8d15yh.fsf@alter.siamese.dyndns.org","threadId":"31109","inReplyTo":"20120727155000.GB11957@sigill.intra.peff.net","subject":"Re: [RFC/PATCH 2/2] test: allow prerequisite to be evaluated lazily","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-07-27T17:15:02Z","receivedAt":"2012-07-27T17:15:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Fri, Jul 27, 2012 at 11:45:00AM -0400, Jeff King wrote:\n>\n>> And of course with non-broken probes, \"-v\" would also help to see exactly\n>> when the probe is run, using which commands, and what output they\n>> produced. E.g., for SYMLINKS, we should probably drop the stderr\n>> redirection from the probe so we can see how \"ln\" complains.\n>> \n>> It might also be worth doing a \"say >&3\" at the end of the check, too,\n>> to tell \"-v\" users the outcome.\n>\n> Here is an updated version of my suggestion that does both of those\n> things.  I think it should just be squashed into your patch.\n\nThanks. The changes look good.\n"}]}