test: support writing test output to file
This is a minimal effort to support test output written both to stdout and file in order to get our buildbots understanding test output. PR-URL: https://github.com/iojs/io.js/pull/934 Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
parent
ed3b057e9f
commit
a7bdce249c
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
|
|
||||||
import imp
|
import imp
|
||||||
|
import logging
|
||||||
import optparse
|
import optparse
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
@ -47,6 +48,8 @@ from os.path import join, dirname, abspath, basename, isdir, exists
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from Queue import Queue, Empty
|
from Queue import Queue, Empty
|
||||||
|
|
||||||
|
logger = logging.getLogger('testrunner')
|
||||||
|
|
||||||
VERBOSE = False
|
VERBOSE = False
|
||||||
|
|
||||||
|
|
||||||
@ -237,7 +240,7 @@ class DotsProgressIndicator(SimpleProgressIndicator):
|
|||||||
class TapProgressIndicator(SimpleProgressIndicator):
|
class TapProgressIndicator(SimpleProgressIndicator):
|
||||||
|
|
||||||
def Starting(self):
|
def Starting(self):
|
||||||
print '1..%i' % len(self.cases)
|
logger.info('1..%i' % len(self.cases))
|
||||||
self._done = 0
|
self._done = 0
|
||||||
|
|
||||||
def AboutToRun(self, case):
|
def AboutToRun(self, case):
|
||||||
@ -247,13 +250,13 @@ class TapProgressIndicator(SimpleProgressIndicator):
|
|||||||
self._done += 1
|
self._done += 1
|
||||||
command = basename(output.command[-1])
|
command = basename(output.command[-1])
|
||||||
if output.UnexpectedOutput():
|
if output.UnexpectedOutput():
|
||||||
print 'not ok %i - %s' % (self._done, command)
|
logger.info('not ok %i - %s' % (self._done, command))
|
||||||
for l in output.output.stderr.splitlines():
|
for l in output.output.stderr.splitlines():
|
||||||
print '#' + l
|
logger.info('#' + l)
|
||||||
for l in output.output.stdout.splitlines():
|
for l in output.output.stdout.splitlines():
|
||||||
print '#' + l
|
logger.info('#' + l)
|
||||||
else:
|
else:
|
||||||
print 'ok %i - %s' % (self._done, command)
|
logger.info('ok %i - %s' % (self._done, command))
|
||||||
|
|
||||||
duration = output.test.duration
|
duration = output.test.duration
|
||||||
|
|
||||||
@ -261,9 +264,9 @@ class TapProgressIndicator(SimpleProgressIndicator):
|
|||||||
total_seconds = (duration.microseconds +
|
total_seconds = (duration.microseconds +
|
||||||
(duration.seconds + duration.days * 24 * 3600) * 10**6) / 10**6
|
(duration.seconds + duration.days * 24 * 3600) * 10**6) / 10**6
|
||||||
|
|
||||||
print ' ---'
|
logger.info(' ---')
|
||||||
print ' duration_ms: %d.%d' % (total_seconds, duration.microseconds / 1000)
|
logger.info(' duration_ms: %d.%d' % (total_seconds, duration.microseconds / 1000))
|
||||||
print ' ...'
|
logger.info(' ...')
|
||||||
|
|
||||||
def Done(self):
|
def Done(self):
|
||||||
pass
|
pass
|
||||||
@ -1216,6 +1219,8 @@ def BuildOptions():
|
|||||||
default='release')
|
default='release')
|
||||||
result.add_option("-v", "--verbose", help="Verbose output",
|
result.add_option("-v", "--verbose", help="Verbose output",
|
||||||
default=False, action="store_true")
|
default=False, action="store_true")
|
||||||
|
result.add_option('--logfile', dest='logfile',
|
||||||
|
help='write test output to file. NOTE: this only applies the tap progress indicator')
|
||||||
result.add_option("-S", dest="scons_flags", help="Flag to pass through to scons",
|
result.add_option("-S", dest="scons_flags", help="Flag to pass through to scons",
|
||||||
default=[], action="append")
|
default=[], action="append")
|
||||||
result.add_option("-p", "--progress",
|
result.add_option("-p", "--progress",
|
||||||
@ -1359,6 +1364,13 @@ def Main():
|
|||||||
parser.print_help()
|
parser.print_help()
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
ch = logging.StreamHandler(sys.stdout)
|
||||||
|
logger.addHandler(ch)
|
||||||
|
logger.setLevel('INFO')
|
||||||
|
if options.logfile:
|
||||||
|
fh = logging.FileHandler(options.logfile)
|
||||||
|
logger.addHandler(fh)
|
||||||
|
|
||||||
workspace = abspath(join(dirname(sys.argv[0]), '..'))
|
workspace = abspath(join(dirname(sys.argv[0]), '..'))
|
||||||
suites = GetSuites(join(workspace, 'test'))
|
suites = GetSuites(join(workspace, 'test'))
|
||||||
repositories = [TestRepository(join(workspace, 'test', name)) for name in suites]
|
repositories = [TestRepository(join(workspace, 'test', name)) for name in suites]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user