[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] Time taken to execute the test suite

From: Branko Cibej <brane_at_xbc.nu>
Date: Thu, 08 Oct 2009 11:41:51 +0200

Bhuvaneswaran A wrote:
> Hello,
> I'm in the process of generating junit file from Subversion build
> process. The junit file is generated by parsing the log file, tests.log
> created during "make check" process. The junit file can be used to
> integrate the Subversion build with continuous integration tools like
> Hudson. This patch is to follow ...
>
> Meanwhile, please find attached a patch to print the time taken by each
> test suite in the log file, if specified. The time may be mentioned in
> the junit file associated to the test suite.
>
> Can you please review this patch?
>
> [[[
> This fix adds the ability to print the time taken to execute each test.
> The time taken is printed in the log file, if specified; otherwise in
> the stdout interface.
>
> * build/run_tests.py
> import time
> (TestHarness._run_test): Print the time taken by each test in
> "HH:MM:SShrs" format.
> ]]]
>
Surely you didn't mean to put that "import time" into the log message. :)
Why the "hrs" suffix on the time? That makes the timestamp format
non-standard.

> Index: build/run_tests.py
> =======================================
> --- build/run_tests.py (revision 39857)
> +++ build/run_tests.py (working copy)
> @@ -16,6 +16,7 @@
> '''
> import os, sys
> +import time
> import getopt
> try:
> @@ -193,6 +194,7 @@
> else:
> print('START: %s' % progbase)
> + starttime = int(time.time())

start_time = time.time()

> if progbase[-3:] == '.py':
> progname = sys.executable
> cmdline = [quote(progname),
> @@ -255,10 +257,14 @@
> print(TextColors.FAILURE + 'FAILURE' + TextColors.ENDC)
> else:
> print(TextColors.SUCCESS + 'success' + TextColors.ENDC)
> + endtime = int(time.time())
> + epoch = endtime - starttime
> + (hrs, mins, secs) = ((epoch/(60*60))%24, (epoch/60)%60, epoch%60)
> + total_time = "%02d:%02d:%02d" % (hrs, mins, secs)

elapsed_time = time.strftime('%H:%M:%S', time.time() - start_time)

> if self.log:
> - self.log.write('END: %s\n\n' % progbase)
> + self.log.write('END: %s; TIME TAKEN: %shrs\n\n' % (progbase,
> total_time))
> else:
> - print('END: %s\n' % progbase)
> + print('END: %s; TIME TAKEN: %shrs\n' % (progbase, total_time))
> return failed

I object to appending the elapsed time onto the END: line. It makes
parsing the log file harder. Instead, just put the elapsed time on its
own line, e.g.:

    self.log.write('ELAPSED: %s %s\n\n' % (progbase, elapsed_time))

-- Brane

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2404867
Received on 2009-10-08 11:42:05 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.