{"thread":{"id":"31823","subject":"t3302-notes-index-expensive.sh and t3419-rebase-patch-id.sh need time in /usr/bin","startedAt":"2012-10-15T10:56:43Z","lastAt":"2012-10-16T19:34:08Z","messageCount":17,"participants":["Joachim Schmitz","Michael J Gruber","Junio C Hamano","Andreas Schwab","Stefano Lattarini","Johannes Sixt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"201242","messageId":"k5gq60$q8c$1@ger.gmane.org","threadId":"31823","inReplyTo":null,"subject":"t3302-notes-index-expensive.sh and t3419-rebase-patch-id.sh need time in /usr/bin","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-10-15T10:56:43Z","receivedAt":"2012-10-15T10:56:43Z","isPatch":false,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"Hi folks\n\nt3302-notes-index-expensive.sh and t3419-rebase-patch-id.sh need \"time \" to \nbe in \"/usr/bin\", however on my system it is in \"/bin\".\n\nCan't this be checked for?\n\nBye, Jojo \n"},{"id":"201329","messageId":"cover.1350387132.git.git@drmicha.warpmail.net","threadId":"31823","inReplyTo":"k5gq60$q8c$1@ger.gmane.org","subject":"[PATCH 0/4] Allow different time commands","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2012-10-16T11:39:43Z","receivedAt":"2012-10-16T11:39:43Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"This mini series enables the use of the lazy prereq framework for tests\nwhich need a (non-builtin) time command.\n\n1/4 is a bugfix\n2/4 allows lazy prereq test scripts to set variables for later use\n3/4 implements the prereq\n4/4 uses it\n\nThis should solve the problem reported by Joachim Schmitz.\n\n3/4 could be done in various different ways, see the comments there.\n\nMichael J Gruber (4):\n  t3419-rebase-patch-id: heed USR_BIN_TIME prereq\n  test-lib: allow variable export from lazy prereq tests\n  test-lib: provide lazy TIME_COMMAND prereq\n  t3302,t3419: use the TIME_COMMAND prereq\n\n t/t3302-notes-index-expensive.sh | 5 ++---\n t/t3419-rebase-patch-id.sh       | 7 +++----\n t/test-lib-functions.sh          | 6 ++++--\n t/test-lib.sh                    | 7 +++++++\n 4 files changed, 16 insertions(+), 9 deletions(-)\n\n-- \n1.8.0.rc2.304.g9f3ac5c\n"},{"id":"201326","messageId":"b04898886f0c7ed9d943aef0ce6e047f10c97d76.1350387132.git.git@drmicha.warpmail.net","threadId":"31823","inReplyTo":"k5gq60$q8c$1@ger.gmane.org","subject":"[PATCH 1/4] t3419-rebase-patch-id: heed USR_BIN_TIME prereq","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2012-10-16T11:39:44Z","receivedAt":"2012-10-16T11:39:44Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"t3419 sets the t3419-rebase-patch-id.sh prereq based on the availability\nof /usr/bin/time but calls the binary unconditionally (in debug mode).\n\nMake it run the timing only when the prereq is matched.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\n t/t3419-rebase-patch-id.sh | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t3419-rebase-patch-id.sh b/t/t3419-rebase-patch-id.sh\nindex e70ac10..52af547 100755\n--- a/t/t3419-rebase-patch-id.sh\n+++ b/t/t3419-rebase-patch-id.sh\n@@ -69,7 +69,7 @@ do_tests()\n \t\tgit cherry-pick master >/dev/null 2>&1\n \t\"\n \n-\ttest_debug \"\n+\ttest_have_prereq USR_BIN_TIME && test_debug \"\n \t\trun git diff master^\\!\n \t\"\n \n@@ -77,7 +77,7 @@ do_tests()\n \t\techo 'file binary' >.gitattributes\n \t\"\n \n-\ttest_debug \"\n+\ttest_have_prereq USR_BIN_TIME && test_debug \"\n \t\trun git format-patch --stdout master &&\n \t\trun git format-patch --stdout --ignore-if-in-upstream master\n \t\"\n-- \n1.8.0.rc2.304.g9f3ac5c\n"},{"id":"201325","messageId":"ca07c5a1cf836826fc0ee53daf3e7f3dfe111ece.1350387132.git.git@drmicha.warpmail.net","threadId":"31823","inReplyTo":"k5gq60$q8c$1@ger.gmane.org","subject":"[PATCH 2/4] test-lib: allow variable export from lazy prereq tests","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2012-10-16T11:39:45Z","receivedAt":"2012-10-16T11:39:45Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Currently, lazy prereq tests are run in a subshell which communicates\nonly the exit code to the outer world.\n\nRun it as a subcommand so that variables can be exported to the test\nenvironment.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\nI don't think this has any adverse side effects, but I'm begging for\nanother set of eyeballs to have a look. (Test suite passes, of course.)\n\n t/test-lib-functions.sh | 6 ++++--\n 1 file changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\nindex 8889ba5..e587902 100644\n--- a/t/test-lib-functions.sh\n+++ b/t/test-lib-functions.sh\n@@ -246,13 +246,15 @@ test_lazy_prereq () {\n test_run_lazy_prereq_ () {\n \tscript='\n mkdir -p \"$TRASH_DIRECTORY/prereq-test-dir\" &&\n-(\n+{\n \tcd \"$TRASH_DIRECTORY/prereq-test-dir\" &&'\"$2\"'\n-)'\n+}'\n \tsay >&3 \"checking prerequisite: $1\"\n \tsay >&3 \"$script\"\n+\torig_pwd=\"$(pwd)\"\n \ttest_eval_ \"$script\"\n \teval_ret=$?\n+\tcd \"$orig_pwd\"\n \trm -rf \"$TRASH_DIRECTORY/prereq-test-dir\"\n \tif test \"$eval_ret\" = 0; then\n \t\tsay >&3 \"prerequisite $1 ok\"\n-- \n1.8.0.rc2.304.g9f3ac5c\n"},{"id":"201327","messageId":"0140f3f2f2f4bded6868f4082bef0c36e9a8560e.1350387132.git.git@drmicha.warpmail.net","threadId":"31823","inReplyTo":"k5gq60$q8c$1@ger.gmane.org","subject":"[RFC/PATCH 3/4] test-lib: provide lazy TIME_COMMAND prereq","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2012-10-16T11:39:46Z","receivedAt":"2012-10-16T11:39:46Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Some test want to use the time command (not the shell builtin) and test\nfor its availability at /usr/bin/time.\n\nProvide a lazy prereq TIME_COMMAND which tests for /usr/bin/time and\n/bin/time. If any is found, set TEST_COMMAND_PATH to the first match.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\nRather than iterating over 2 or more hardcoded paths, one could use\n\"test -P time\" or allow a make variable TIME_COMMAND_PATH whose\nexecutability is checked by the prereq. I really don't know what's best.\n\n t/test-lib.sh | 7 +++++++\n 1 file changed, 7 insertions(+)\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 489bc80..7977c15 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -738,6 +738,13 @@ test_lazy_prereq UTF8_NFD_TO_NFC '\n \tesac\n '\n \n+test_lazy_prereq TIME_COMMAND '\n+\tfor command in /usr/bin/time /bin/time\n+\tdo\n+\t\ttest -x \"$command\" && break\n+\tdone && TIME_COMMAND_PATH=\"$command\"\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.8.0.rc2.304.g9f3ac5c\n"},{"id":"201328","messageId":"71d3a0f9ab2bfd73fb2abfb4a0bc9fa7be6cd70b.1350387132.git.git@drmicha.warpmail.net","threadId":"31823","inReplyTo":"k5gq60$q8c$1@ger.gmane.org","subject":"[PATCH 4/4] t3302,t3419: use the TIME_COMMAND prereq","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2012-10-16T11:39:47Z","receivedAt":"2012-10-16T11:39:47Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Use the TIME_COMMAND prereq in both tests so that time from several\npaths can be used.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\n t/t3302-notes-index-expensive.sh | 5 ++---\n t/t3419-rebase-patch-id.sh       | 7 +++----\n 2 files changed, 5 insertions(+), 7 deletions(-)\n\ndiff --git a/t/t3302-notes-index-expensive.sh b/t/t3302-notes-index-expensive.sh\nindex e35d781..3d9f37e 100755\n--- a/t/t3302-notes-index-expensive.sh\n+++ b/t/t3302-notes-index-expensive.sh\n@@ -9,7 +9,6 @@ test_description='Test commit notes index (expensive!)'\n \n test_set_prereq NOT_EXPENSIVE\n test -n \"$GIT_NOTES_TIMING_TESTS\" && test_set_prereq EXPENSIVE\n-test -x /usr/bin/time && test_set_prereq USR_BIN_TIME\n \n create_repo () {\n \tnumber_of_commits=$1\n@@ -96,7 +95,7 @@ time_notes () {\n \tfor mode in no-notes notes\n \tdo\n \t\techo $mode\n-\t\t/usr/bin/time \"$SHELL_PATH\" ../time_notes $mode $1\n+\t\t\"$TIME_COMMAND_PATH\" \"$SHELL_PATH\" ../time_notes $mode $1\n \tdone\n }\n \n@@ -113,7 +112,7 @@ do_tests () {\n \n \ttest_expect_success $pr 'notes work' \"test_notes $count\"\n \n-\ttest_expect_success USR_BIN_TIME,$pr 'notes timing with /usr/bin/time' \"time_notes 100\"\n+\ttest_expect_success TIME_COMMAND,$pr 'notes timing with a time command' \"time_notes 100\"\n \n \ttest_expect_success $pr 'teardown / cd ..' 'cd ..'\n }\ndiff --git a/t/t3419-rebase-patch-id.sh b/t/t3419-rebase-patch-id.sh\nindex 52af547..c7d90a6 100755\n--- a/t/t3419-rebase-patch-id.sh\n+++ b/t/t3419-rebase-patch-id.sh\n@@ -6,7 +6,6 @@ test_description='git rebase - test patch id computation'\n \n test_set_prereq NOT_EXPENSIVE\n test -n \"$GIT_PATCHID_TIMING_TESTS\" && test_set_prereq EXPENSIVE\n-test -x /usr/bin/time && test_set_prereq USR_BIN_TIME\n \n count()\n {\n@@ -35,7 +34,7 @@ scramble()\n run()\n {\n \techo \\$ \"$@\"\n-\t/usr/bin/time \"$@\" >/dev/null\n+\t\"$TIME_COMMAND_PATH\" \"$@\" >/dev/null\n }\n \n test_expect_success 'setup' '\n@@ -69,7 +68,7 @@ do_tests()\n \t\tgit cherry-pick master >/dev/null 2>&1\n \t\"\n \n-\ttest_have_prereq USR_BIN_TIME && test_debug \"\n+\ttest_have_prereq TIME_COMMAND && test_debug \"\n \t\trun git diff master^\\!\n \t\"\n \n@@ -77,7 +76,7 @@ do_tests()\n \t\techo 'file binary' >.gitattributes\n \t\"\n \n-\ttest_have_prereq USR_BIN_TIME && test_debug \"\n+\ttest_have_prereq TIME_COMMAND && test_debug \"\n \t\trun git format-patch --stdout master &&\n \t\trun git format-patch --stdout --ignore-if-in-upstream master\n \t\"\n-- \n1.8.0.rc2.304.g9f3ac5c\n"},{"id":"201341","messageId":"007001cdaba8$5afc6c00$10f54400$@schmitz-digital.de","threadId":"31823","inReplyTo":"0140f3f2f2f4bded6868f4082bef0c36e9a8560e.1350387132.git.git@drmicha.warpmail.net","subject":"RE: [RFC/PATCH 3/4] test-lib: provide lazy TIME_COMMAND prereq","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-10-16T14:13:02Z","receivedAt":"2012-10-16T14:13:02Z","isPatch":true,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"> From: Michael J Gruber [mailto:git@drmicha.warpmail.net]\n> Sent: Tuesday, October 16, 2012 1:40 PM\n> To: git@vger.kernel.org\n> Cc: Joachim Schmitz; Junio C Hamano\n> Subject: [RFC/PATCH 3/4] test-lib: provide lazy TIME_COMMAND prereq\n> \n> Some test want to use the time command (not the shell builtin) and test\n> for its availability at /usr/bin/time.\n> \n> Provide a lazy prereq TIME_COMMAND which tests for /usr/bin/time and\n> /bin/time. If any is found, set TEST_COMMAND_PATH to the first match.\n> \n> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n> ---\n> Rather than iterating over 2 or more hardcoded paths, one could use\n> \"test -P time\" or allow a make variable TIME_COMMAND_PATH whose\n\ntest -P time won't work for me:\ntest -P: unary operator expected\n\nI do have another one in /usr/local/bin, maybe that could get added too?\n\n> executability is checked by the prereq. I really don't know what's best.\n> \n>  t/test-lib.sh | 7 +++++++\n>  1 file changed, 7 insertions(+)\n> \n> diff --git a/t/test-lib.sh b/t/test-lib.sh\n> index 489bc80..7977c15 100644\n> --- a/t/test-lib.sh\n> +++ b/t/test-lib.sh\n> @@ -738,6 +738,13 @@ test_lazy_prereq UTF8_NFD_TO_NFC '\n>  \tesac\n>  '\n> \n> +test_lazy_prereq TIME_COMMAND '\n> +\tfor command in /usr/bin/time /bin/time\n> +\tdo\n> +\t\ttest -x \"$command\" && break\n> +\tdone && TIME_COMMAND_PATH=\"$command\"\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> --\n> 1.8.0.rc2.304.g9f3ac5c\n"},{"id":"201342","messageId":"507D7809.6040904@drmicha.warpmail.net","threadId":"31823","inReplyTo":"007001cdaba8$5afc6c00$10f54400$@schmitz-digital.de","subject":"Re: [RFC/PATCH 3/4] test-lib: provide lazy TIME_COMMAND prereq","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2012-10-16T15:06:49Z","receivedAt":"2012-10-16T15:06:49Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Joachim Schmitz venit, vidit, dixit 16.10.2012 16:13:\n>> From: Michael J Gruber [mailto:git@drmicha.warpmail.net]\n>> Sent: Tuesday, October 16, 2012 1:40 PM\n>> To: git@vger.kernel.org\n>> Cc: Joachim Schmitz; Junio C Hamano\n>> Subject: [RFC/PATCH 3/4] test-lib: provide lazy TIME_COMMAND prereq\n>>\n>> Some test want to use the time command (not the shell builtin) and test\n>> for its availability at /usr/bin/time.\n>>\n>> Provide a lazy prereq TIME_COMMAND which tests for /usr/bin/time and\n>> /bin/time. If any is found, set TEST_COMMAND_PATH to the first match.\n>>\n>> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n>> ---\n>> Rather than iterating over 2 or more hardcoded paths, one could use\n>> \"test -P time\" or allow a make variable TIME_COMMAND_PATH whose\n> \n> test -P time won't work for me:\n> test -P: unary operator expected\n> \n> I do have another one in /usr/local/bin, maybe that could get added too?\n\nYikes.\n\nIf we introduce a make variable TIME_COMMAND_PATH we can even get rid of\n2/4 (but have to change Makefile or t/Makefile).\n\n>> executability is checked by the prereq. I really don't know what's best.\n>>\n>>  t/test-lib.sh | 7 +++++++\n>>  1 file changed, 7 insertions(+)\n>>\n>> diff --git a/t/test-lib.sh b/t/test-lib.sh\n>> index 489bc80..7977c15 100644\n>> --- a/t/test-lib.sh\n>> +++ b/t/test-lib.sh\n>> @@ -738,6 +738,13 @@ test_lazy_prereq UTF8_NFD_TO_NFC '\n>>  \tesac\n>>  '\n>>\n>> +test_lazy_prereq TIME_COMMAND '\n>> +\tfor command in /usr/bin/time /bin/time\n>> +\tdo\n>> +\t\ttest -x \"$command\" && break\n>> +\tdone && TIME_COMMAND_PATH=\"$command\"\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>> --\n>> 1.8.0.rc2.304.g9f3ac5c\n> \n"},{"id":"201343","messageId":"28ca29e59c5905ba7232dcdbe4661f37ef90cac5.1350399860.git.git@drmicha.warpmail.net","threadId":"31823","inReplyTo":"007001cdaba8$5afc6c00$10f54400$@schmitz-digital.de","subject":"[RFC/PATCH 3/4v2] test-lib: provide lazy TIME_COMMAND prereq","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2012-10-16T15:07:01Z","receivedAt":"2012-10-16T15:07:01Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Some test want to use the time command (not the shell builtin) and test\nfor its availability at /usr/bin/time.\n\nProvide a lazy prereq TIME_COMMAND which tests for $TEST_COMMAND_PATH,\nwhich can be set from config.mak. It defaults to /usr/bin/time.\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\nHere's what the make variable version could look like.\n1/4 and 4/4 would stay as is, 2/4 could be dropped.\n\n t/Makefile    | 5 +++--\n t/test-lib.sh | 4 ++++\n 2 files changed, 7 insertions(+), 2 deletions(-)\n\ndiff --git a/t/Makefile b/t/Makefile\nindex 88e289f..52b4039 100644\n--- a/t/Makefile\n+++ b/t/Makefile\n@@ -13,6 +13,7 @@ TAR ?= $(TAR)\n RM ?= rm -f\n PROVE ?= prove\n DEFAULT_TEST_TARGET ?= test\n+TIME_COMMAND_PATH ?= /usr/bin/time\n \n # Shell quote;\n SHELL_PATH_SQ = $(subst ','\\'',$(SHELL_PATH))\n@@ -27,11 +28,11 @@ test: pre-clean $(TEST_LINT)\n \t$(MAKE) aggregate-results-and-cleanup\n \n prove: pre-clean $(TEST_LINT)\n-\t@echo \"*** prove ***\"; GIT_CONFIG=.git/config $(PROVE) --exec '$(SHELL_PATH_SQ)' $(GIT_PROVE_OPTS) $(T) :: $(GIT_TEST_OPTS)\n+\t@echo \"*** prove ***\"; GIT_CONFIG=.git/config TIME_COMMAND_PATH=$(TIME_COMMAND_PATH) $(PROVE) --exec '$(SHELL_PATH_SQ)' $(GIT_PROVE_OPTS) $(T) :: $(GIT_TEST_OPTS)\n \t$(MAKE) clean-except-prove-cache\n \n $(T):\n-\t@echo \"*** $@ ***\"; GIT_CONFIG=.git/config '$(SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)\n+\t@echo \"*** $@ ***\"; GIT_CONFIG=.git/config TIME_COMMAND_PATH=$(TIME_COMMAND_PATH) '$(SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)\n \n pre-clean:\n \t$(RM) -r test-results\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 489bc80..173eb13 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -738,6 +738,10 @@ test_lazy_prereq UTF8_NFD_TO_NFC '\n \tesac\n '\n \n+test_lazy_prereq TIME_COMMAND '\n+\ttest -x \"$TIME_COMMAND_PATH\"\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.8.0.rc2.304.g9f3ac5c\n"},{"id":"201345","messageId":"007401cdabb0$831d1f10$89575d30$@schmitz-digital.de","threadId":"31823","inReplyTo":"507D7809.6040904@drmicha.warpmail.net","subject":"RE: [RFC/PATCH 3/4] test-lib: provide lazy TIME_COMMAND prereq","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-10-16T15:11:25Z","receivedAt":"2012-10-16T15:11:25Z","isPatch":true,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"> From: Michael J Gruber [mailto:git@drmicha.warpmail.net]\n> Sent: Tuesday, October 16, 2012 5:07 PM\n> To: Joachim Schmitz\n> Cc: git@vger.kernel.org; 'Junio C Hamano'\n> Subject: Re: [RFC/PATCH 3/4] test-lib: provide lazy TIME_COMMAND prereq\n> \n> Joachim Schmitz venit, vidit, dixit 16.10.2012 16:13:\n> >> From: Michael J Gruber [mailto:git@drmicha.warpmail.net]\n> >> Sent: Tuesday, October 16, 2012 1:40 PM\n> >> To: git@vger.kernel.org\n> >> Cc: Joachim Schmitz; Junio C Hamano\n> >> Subject: [RFC/PATCH 3/4] test-lib: provide lazy TIME_COMMAND prereq\n> >>\n> >> Some test want to use the time command (not the shell builtin) and test\n> >> for its availability at /usr/bin/time.\n> >>\n> >> Provide a lazy prereq TIME_COMMAND which tests for /usr/bin/time and\n> >> /bin/time. If any is found, set TEST_COMMAND_PATH to the first match.\n> >>\n> >> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n> >> ---\n> >> Rather than iterating over 2 or more hardcoded paths, one could use\n> >> \"test -P time\" or allow a make variable TIME_COMMAND_PATH whose\n> >\n> > test -P time won't work for me:\n> > test -P: unary operator expected\n> >\n> > I do have another one in /usr/local/bin, maybe that could get added too?\n> \n> Yikes.\n> \n> If we introduce a make variable TIME_COMMAND_PATH we can even get rid of\n> 2/4 (but have to change Makefile or t/Makefile).\n\nI don't mind too much. /usr/bin/time and /bin/time should be enough.\n"},{"id":"201351","messageId":"7vipaatmsb.fsf@alter.siamese.dyndns.org","threadId":"31823","inReplyTo":"ca07c5a1cf836826fc0ee53daf3e7f3dfe111ece.1350387132.git.git@drmicha.warpmail.net","subject":"Re: [PATCH 2/4] test-lib: allow variable export from lazy prereq tests","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-10-16T16:16:36Z","receivedAt":"2012-10-16T16:16:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael J Gruber <git@drmicha.warpmail.net> writes:\n\n> I don't think this has any adverse side effects, but I'm begging for\n> another set of eyeballs to have a look. (Test suite passes, of course.)\n\nThe lazy prereqs are designed to be used lazily, in any test that he\nwho wrote lazy-prereq did not anticipate.  It is run inside a subshell\nto make it absolutely sure that whatever it does (like use of shell\nvariables, chdir around) will not be able to affect _any_ calling\ncontext that is not anticipated by who writes lazy prerequisite.\n\nPlease don't do this.\n\n>\n>  t/test-lib-functions.sh | 6 ++++--\n>  1 file changed, 4 insertions(+), 2 deletions(-)\n>\n> diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh\n> index 8889ba5..e587902 100644\n> --- a/t/test-lib-functions.sh\n> +++ b/t/test-lib-functions.sh\n> @@ -246,13 +246,15 @@ test_lazy_prereq () {\n>  test_run_lazy_prereq_ () {\n>  \tscript='\n>  mkdir -p \"$TRASH_DIRECTORY/prereq-test-dir\" &&\n> -(\n> +{\n>  \tcd \"$TRASH_DIRECTORY/prereq-test-dir\" &&'\"$2\"'\n> -)'\n> +}'\n>  \tsay >&3 \"checking prerequisite: $1\"\n>  \tsay >&3 \"$script\"\n> +\torig_pwd=\"$(pwd)\"\n>  \ttest_eval_ \"$script\"\n>  \teval_ret=$?\n> +\tcd \"$orig_pwd\"\n>  \trm -rf \"$TRASH_DIRECTORY/prereq-test-dir\"\n>  \tif test \"$eval_ret\" = 0; then\n>  \t\tsay >&3 \"prerequisite $1 ok\"\n"},{"id":"201353","messageId":"m2mwzmxtyb.fsf@igel.home","threadId":"31823","inReplyTo":"28ca29e59c5905ba7232dcdbe4661f37ef90cac5.1350399860.git.git@drmicha.warpmail.net","subject":"Re: [RFC/PATCH 3/4v2] test-lib: provide lazy TIME_COMMAND prereq","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2012-10-16T16:28:12Z","receivedAt":"2012-10-16T16:28:12Z","isPatch":true,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Michael J Gruber <git@drmicha.warpmail.net> writes:\n\n> Some test want to use the time command (not the shell builtin) and test\n> for its availability at /usr/bin/time.\n\nAn alternative way to suppress the builtin meaning is to quote it, like\n\\time.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"201354","messageId":"7vd30itm2k.fsf@alter.siamese.dyndns.org","threadId":"31823","inReplyTo":"b04898886f0c7ed9d943aef0ce6e047f10c97d76.1350387132.git.git@drmicha.warpmail.net","subject":"Re: [PATCH 1/4] t3419-rebase-patch-id: heed USR_BIN_TIME prereq","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-10-16T16:32:03Z","receivedAt":"2012-10-16T16:32:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael J Gruber <git@drmicha.warpmail.net> writes:\n\n> t3419 sets the t3419-rebase-patch-id.sh prereq based on the availability\n> of /usr/bin/time but calls the binary unconditionally (in debug mode).\n>\n> Make it run the timing only when the prereq is matched.\n>\n> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n\nI do not think we should ship our tests with too many test_debug in\nthe first place (it is something you as a developer who are trying\nto figure out why your change broke tests can insert into tests).\nIt might be useful to be able to say \"sh ./t1234-*.sh -d\" and see\ndebug output that somebody else thought that it might be useful, so\nI wouldn't say we should remove all existing test_debug, but at the\nsame time, if a developer finds existing test_debug does not work\nfor him (either what the debug output gives him is insufficient for\nhis needs, or what the debug command uses is not available on his\nsystem), he should be willing to update (and capable of doing so) it\nto suit his needs.  Adding prereq in front of test_debug is simply\nan act of insanity.\n\nFor this particular one, I think this should suffice.  If the shell\ndoes not have \"time\" built-in, then timeme can be set to even an\nempty string, but that is left as an exercise to the readers.\n\n t/t3419-rebase-patch-id.sh | 8 ++++++--\n 1 file changed, 6 insertions(+), 2 deletions(-)\n\ndiff --git i/t/t3419-rebase-patch-id.sh w/t/t3419-rebase-patch-id.sh\nindex e70ac10..bf2736a 100755\n--- i/t/t3419-rebase-patch-id.sh\n+++ w/t/t3419-rebase-patch-id.sh\n@@ -6,7 +6,11 @@ test_description='git rebase - test patch id computation'\n \n test_set_prereq NOT_EXPENSIVE\n test -n \"$GIT_PATCHID_TIMING_TESTS\" && test_set_prereq EXPENSIVE\n-test -x /usr/bin/time && test_set_prereq USR_BIN_TIME\n+if test -x /usr/bin/time\n+\ttimeme=/usr/bin/time\n+else\n+\ttimeme=time\n+fi\n \n count()\n {\n@@ -35,7 +39,7 @@ scramble()\n run()\n {\n \techo \\$ \"$@\"\n-\t/usr/bin/time \"$@\" >/dev/null\n+\t$timeme \"$@\" >/dev/null\n }\n \n test_expect_success 'setup' '\n"},{"id":"201355","messageId":"7v8vb6tlne.fsf@alter.siamese.dyndns.org","threadId":"31823","inReplyTo":"0140f3f2f2f4bded6868f4082bef0c36e9a8560e.1350387132.git.git@drmicha.warpmail.net","subject":"Re: [RFC/PATCH 3/4] test-lib: provide lazy TIME_COMMAND prereq","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-10-16T16:41:09Z","receivedAt":"2012-10-16T16:41:09Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael J Gruber <git@drmicha.warpmail.net> writes:\n\n> Some test want to use the time command (not the shell builtin) and test\n> for its availability at /usr/bin/time.\n\nAs we have t/perf these days, I suspect that we should aim to remove\nthese uses of /usr/bin/time in the main testsuite instead.\n\nThe one in 3419 was \"run this command, and while at it run it under\n'time'\" but it is only inside test_debug and I do not think it gives\nanything more than curiosity values.\n\nThe one in 3302 is used to compare two runs (one without and one\nwith notes tree), so it has a little more value than just curiosity,\nbut its value inside the main test suite is still highly dubious. It\ndoes not have any \"under this value the test passes\" criteria.\n\nWhen the performance of having to look up notes tree really matters,\nit shouldn't be done inside the main test suite that is designed to\nbe runnable unattended and the only check the humans do is to see\ntheir \"ok/fail\" output.\n\nIn short, what you would get out of /usr/bin/time simply is not a\ngood match inside the context of these unit tests.\n"},{"id":"201376","messageId":"507DA749.30509@gmail.com","threadId":"31823","inReplyTo":"m2mwzmxtyb.fsf@igel.home","subject":"Re: [RFC/PATCH 3/4v2] test-lib: provide lazy TIME_COMMAND prereq","fromName":"Stefano Lattarini","fromEmail":"stefano.lattarini@gmail.com","sentAt":"2012-10-16T18:28:25Z","receivedAt":"2012-10-16T18:28:25Z","isPatch":true,"sender":{"key":"stefano.lattarini@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1429199?v=4"},"body":"Hi Andreas.  I hope you don't mind my nitpickiness, but ...\n\nOn 10/16/2012 06:28 PM, Andreas Schwab wrote:\n> Michael J Gruber <git@drmicha.warpmail.net> writes:\n> \n>> Some test want to use the time command (not the shell builtin) and test\n>> for its availability at /usr/bin/time.\n> \n> An alternative way to suppress the builtin meaning is to quote it, like\n> \\time.\n>\n... to be 100% precise, this quoting trick works because 'time' is a\nshell keyword, rather than a builtin:\n\n    $ type time\n    time is a shell keyword\n\nRegards,\n  Stefano\n"},{"id":"201381","messageId":"507DB39C.3080005@kdbg.org","threadId":"31823","inReplyTo":"28ca29e59c5905ba7232dcdbe4661f37ef90cac5.1350399860.git.git@drmicha.warpmail.net","subject":"Re: [RFC/PATCH 3/4v2] test-lib: provide lazy TIME_COMMAND prereq","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2012-10-16T19:21:00Z","receivedAt":"2012-10-16T19:21:00Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 16.10.2012 17:07, schrieb Michael J Gruber:\n> Some test want to use the time command (not the shell builtin) and test\n> for its availability at /usr/bin/time.\n> \n> Provide a lazy prereq TIME_COMMAND which tests for $TEST_COMMAND_PATH,\n> which can be set from config.mak. It defaults to /usr/bin/time.\n\nThis avoids the builtin:\n\n\tcommand time $that_command\n\nIt works for bash, ksh, zsh, and dash (where the latter doesn't have it\nas builtin).\n\n-- Hannes\n"},{"id":"201384","messageId":"7v8vb6rz2n.fsf@alter.siamese.dyndns.org","threadId":"31823","inReplyTo":"507DB39C.3080005@kdbg.org","subject":"Re: [RFC/PATCH 3/4v2] test-lib: provide lazy TIME_COMMAND prereq","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-10-16T19:34:08Z","receivedAt":"2012-10-16T19:34:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Sixt <j6t@kdbg.org> writes:\n\n> Am 16.10.2012 17:07, schrieb Michael J Gruber:\n>> Some test want to use the time command (not the shell builtin) and test\n>> for its availability at /usr/bin/time.\n>> \n>> Provide a lazy prereq TIME_COMMAND which tests for $TEST_COMMAND_PATH,\n>> which can be set from config.mak. It defaults to /usr/bin/time.\n>\n> This avoids the builtin:\n>\n> \tcommand time $that_command\n>\n> It works for bash, ksh, zsh, and dash (where the latter doesn't have it\n> as builtin).\n\n\"command time\" works but I think that is because it is not a\nbuilt-in ;-)\n\nHere is what I read in bash(1):\n\n       command [-pVv] command [arg ...]  Run command with args\n              suppressing the normal shell function lookup. Only\n              builtin commands or commands found in the PATH are\n              executed.\n\nTaken together with this from \"COMMAND EXECUTION\":\n\n       If the command name contains no slashes, the shell attempts\n       to locate it.  If there exists a shell function by that name,\n       that function is invoked as described above in FUNCTIONS.  If\n       the name does not match a function, the shell searches for it\n       in the list of shell builtins.  If a match is found, that\n       builtin is invoked.\n\n       If the name is neither a shell function nor a builtin, and\n       contains no slashes, bash searches each element of the PATH\n       for a directory containing an executable file by that name.\n\nI suspect \"command printf 'a b c\\n'\" would not use $HOME/bin/printf\neven when I have $HOME/bin early in my $PATH (nor /usr/bin/printf\nfor that matter).\n"}]}