[RFC/PATCH 3/4] test-lib: provide lazy TIME_COMMAND prereq

2012-10-16 Thread Michael J Gruber
Some test want to use the time command (not the shell builtin) and test
for its availability at /usr/bin/time.

Provide a lazy prereq TIME_COMMAND which tests for /usr/bin/time and
/bin/time. If any is found, set TEST_COMMAND_PATH to the first match.

Signed-off-by: Michael J Gruber g...@drmicha.warpmail.net
---
Rather than iterating over 2 or more hardcoded paths, one could use
test -P time or allow a make variable TIME_COMMAND_PATH whose
executability is checked by the prereq. I really don't know what's best.

 t/test-lib.sh | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/t/test-lib.sh b/t/test-lib.sh
index 489bc80..7977c15 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -738,6 +738,13 @@ test_lazy_prereq UTF8_NFD_TO_NFC '
esac
 '
 
+test_lazy_prereq TIME_COMMAND '
+   for command in /usr/bin/time /bin/time
+   do
+   test -x $command  break
+   done  TIME_COMMAND_PATH=$command
+'
+
 # When the tests are run as root, permission tests will report that
 # things are writable when they shouldn't be.
 test -w / || test_set_prereq SANITY
-- 
1.8.0.rc2.304.g9f3ac5c

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [RFC/PATCH 3/4] test-lib: provide lazy TIME_COMMAND prereq

2012-10-16 Thread Joachim Schmitz
 From: Michael J Gruber [mailto:g...@drmicha.warpmail.net]
 Sent: Tuesday, October 16, 2012 1:40 PM
 To: git@vger.kernel.org
 Cc: Joachim Schmitz; Junio C Hamano
 Subject: [RFC/PATCH 3/4] test-lib: provide lazy TIME_COMMAND prereq
 
 Some test want to use the time command (not the shell builtin) and test
 for its availability at /usr/bin/time.
 
 Provide a lazy prereq TIME_COMMAND which tests for /usr/bin/time and
 /bin/time. If any is found, set TEST_COMMAND_PATH to the first match.
 
 Signed-off-by: Michael J Gruber g...@drmicha.warpmail.net
 ---
 Rather than iterating over 2 or more hardcoded paths, one could use
 test -P time or allow a make variable TIME_COMMAND_PATH whose

test -P time won't work for me:
test -P: unary operator expected

I do have another one in /usr/local/bin, maybe that could get added too?

 executability is checked by the prereq. I really don't know what's best.
 
  t/test-lib.sh | 7 +++
  1 file changed, 7 insertions(+)
 
 diff --git a/t/test-lib.sh b/t/test-lib.sh
 index 489bc80..7977c15 100644
 --- a/t/test-lib.sh
 +++ b/t/test-lib.sh
 @@ -738,6 +738,13 @@ test_lazy_prereq UTF8_NFD_TO_NFC '
   esac
  '
 
 +test_lazy_prereq TIME_COMMAND '
 + for command in /usr/bin/time /bin/time
 + do
 + test -x $command  break
 + done  TIME_COMMAND_PATH=$command
 +'
 +
  # When the tests are run as root, permission tests will report that
  # things are writable when they shouldn't be.
  test -w / || test_set_prereq SANITY
 --
 1.8.0.rc2.304.g9f3ac5c

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [RFC/PATCH 3/4] test-lib: provide lazy TIME_COMMAND prereq

2012-10-16 Thread Joachim Schmitz
 From: Michael J Gruber [mailto:g...@drmicha.warpmail.net]
 Sent: Tuesday, October 16, 2012 5:07 PM
 To: Joachim Schmitz
 Cc: git@vger.kernel.org; 'Junio C Hamano'
 Subject: Re: [RFC/PATCH 3/4] test-lib: provide lazy TIME_COMMAND prereq
 
 Joachim Schmitz venit, vidit, dixit 16.10.2012 16:13:
  From: Michael J Gruber [mailto:g...@drmicha.warpmail.net]
  Sent: Tuesday, October 16, 2012 1:40 PM
  To: git@vger.kernel.org
  Cc: Joachim Schmitz; Junio C Hamano
  Subject: [RFC/PATCH 3/4] test-lib: provide lazy TIME_COMMAND prereq
 
  Some test want to use the time command (not the shell builtin) and test
  for its availability at /usr/bin/time.
 
  Provide a lazy prereq TIME_COMMAND which tests for /usr/bin/time and
  /bin/time. If any is found, set TEST_COMMAND_PATH to the first match.
 
  Signed-off-by: Michael J Gruber g...@drmicha.warpmail.net
  ---
  Rather than iterating over 2 or more hardcoded paths, one could use
  test -P time or allow a make variable TIME_COMMAND_PATH whose
 
  test -P time won't work for me:
  test -P: unary operator expected
 
  I do have another one in /usr/local/bin, maybe that could get added too?
 
 Yikes.
 
 If we introduce a make variable TIME_COMMAND_PATH we can even get rid of
 2/4 (but have to change Makefile or t/Makefile).

I don't mind too much. /usr/bin/time and /bin/time should be enough.

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC/PATCH 3/4] test-lib: provide lazy TIME_COMMAND prereq

2012-10-16 Thread Junio C Hamano
Michael J Gruber g...@drmicha.warpmail.net writes:

 Some test want to use the time command (not the shell builtin) and test
 for its availability at /usr/bin/time.

As we have t/perf these days, I suspect that we should aim to remove
these uses of /usr/bin/time in the main testsuite instead.

The one in 3419 was run this command, and while at it run it under
'time' but it is only inside test_debug and I do not think it gives
anything more than curiosity values.

The one in 3302 is used to compare two runs (one without and one
with notes tree), so it has a little more value than just curiosity,
but its value inside the main test suite is still highly dubious. It
does not have any under this value the test passes criteria.

When the performance of having to look up notes tree really matters,
it shouldn't be done inside the main test suite that is designed to
be runnable unattended and the only check the humans do is to see
their ok/fail output.

In short, what you would get out of /usr/bin/time simply is not a
good match inside the context of these unit tests.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html