mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
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. Cherry picked from https://github.com/jbergstroem/io.js/commit/31940738e2d256e91c1c694c5219b8f840c629ff Original commit message follows: 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> Conflicts: tools/test.py Reviewed-By: Julien Gilli <julien.gilli@joyent.com> PR-URL: https://github.com/joyent/node/pull/25653
This commit is contained in:
1 parent
b8ac6584fa
commit
b48639befd
1 file changed
+20
-8
+20
-8
@@ -29,6 +29,7 @@
|
||||
|
||||
|
||||
import imp
|
||||
import logging
|
||||
import optparse
|
||||
import os
|
||||
import platform
|
||||
@@ -45,6 +46,8 @@ from os.path import join, dirname, abspath, basename, isdir, exists
|
||||
from datetime import datetime
|
||||
from Queue import Queue, Empty
|
||||
|
||||
logger = logging.getLogger('testrunner')
|
||||
|
||||
VERBOSE = False
|
||||
|
||||
|
||||
@@ -225,7 +228,7 @@ class DotsProgressIndicator(SimpleProgressIndicator):
|
||||
class TapProgressIndicator(SimpleProgressIndicator):
|
||||
|
||||
def Starting(self):
|
||||
print '1..%i' % len(self.cases)
|
||||
logger.info('1..%i' % len(self.cases))
|
||||
self._done = 0
|
||||
|
||||
def AboutToRun(self, case):
|
||||
@@ -238,16 +241,16 @@ class TapProgressIndicator(SimpleProgressIndicator):
|
||||
status_line = 'not ok %i - %s' % (self._done, command)
|
||||
if FLAKY in output.test.outcomes and self.flaky_tests_mode == "dontcare":
|
||||
status_line = status_line + " # TODO : Fix flaky test"
|
||||
print status_line
|
||||
logger.info(status_line)
|
||||
for l in output.output.stderr.splitlines():
|
||||
print '#' + l
|
||||
logger.info('#' + l)
|
||||
for l in output.output.stdout.splitlines():
|
||||
print '#' + l
|
||||
logger.info('#' + l)
|
||||
else:
|
||||
status_line = 'ok %i - %s' % (self._done, command)
|
||||
if FLAKY in output.test.outcomes:
|
||||
status_line = status_line + " # TODO : Fix flaky test"
|
||||
print status_line
|
||||
logger.info(status_line)
|
||||
|
||||
duration = output.test.duration
|
||||
|
||||
@@ -255,9 +258,9 @@ class TapProgressIndicator(SimpleProgressIndicator):
|
||||
total_seconds = (duration.microseconds +
|
||||
(duration.seconds + duration.days * 24 * 3600) * 10**6) / 10**6
|
||||
|
||||
print ' ---'
|
||||
print ' duration_ms: %d.%d' % (total_seconds, duration.microseconds / 1000)
|
||||
print ' ...'
|
||||
logger.info(' ---')
|
||||
logger.info(' duration_ms: %d.%d' % (total_seconds, duration.microseconds / 1000))
|
||||
logger.info(' ...')
|
||||
|
||||
def Done(self):
|
||||
pass
|
||||
@@ -1192,6 +1195,8 @@ def BuildOptions():
|
||||
default='release')
|
||||
result.add_option("-v", "--verbose", help="Verbose output",
|
||||
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",
|
||||
default=[], action="append")
|
||||
result.add_option("-p", "--progress",
|
||||
@@ -1368,6 +1373,13 @@ def Main():
|
||||
parser.print_help()
|
||||
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]), '..'))
|
||||
suites = GetSuites(join(workspace, 'test'))
|
||||
repositories = [TestRepository(join(workspace, 'test', name)) for name in suites]
|
||||
|
||||
Reference in new issue
Block a user