XML output for unit tests is now enabled with an option (disabled by default)
This commit is contained in:
@@ -39,9 +39,12 @@ def setup_parser(subparser):
|
|||||||
'names', nargs='*', help="Names of tests to run.")
|
'names', nargs='*', help="Names of tests to run.")
|
||||||
subparser.add_argument(
|
subparser.add_argument(
|
||||||
'-l', '--list', action='store_true', dest='list', help="Show available tests")
|
'-l', '--list', action='store_true', dest='list', help="Show available tests")
|
||||||
# TODO: make XML output optional
|
|
||||||
subparser.add_argument(
|
subparser.add_argument(
|
||||||
'-d', '--outputDir', dest='outputDir', help="Nose creates XML files in this directory")
|
'--createXmlOutput', action='store_true', dest='createXmlOutput',
|
||||||
|
help="Create JUnit XML from test results")
|
||||||
|
subparser.add_argument(
|
||||||
|
'--xmlOutputDir', dest='xmlOutputDir',
|
||||||
|
help="Nose creates XML files in this directory")
|
||||||
subparser.add_argument(
|
subparser.add_argument(
|
||||||
'-v', '--verbose', action='store_true', dest='verbose',
|
'-v', '--verbose', action='store_true', dest='verbose',
|
||||||
help="verbose output")
|
help="verbose output")
|
||||||
@@ -53,10 +56,14 @@ def test(parser, args):
|
|||||||
colify(spack.test.list_tests(), indent=2)
|
colify(spack.test.list_tests(), indent=2)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if not args.outputDir:
|
if not args.createXmlOutput:
|
||||||
outputDir = join_path(os.getcwd(), "test-output")
|
outputDir = None
|
||||||
else:
|
else:
|
||||||
outputDir = args.outputDir
|
if not args.xmlOutputDir:
|
||||||
if not os.path.exists(outputDir):
|
outputDir = join_path(os.getcwd(), "test-output")
|
||||||
mkdirp(outputDir)
|
else:
|
||||||
|
outputDir = os.path.abspath(args.xmlOutputDir)
|
||||||
|
|
||||||
|
if not os.path.exists(outputDir):
|
||||||
|
mkdirp(outputDir)
|
||||||
spack.test.run(args.names, outputDir, args.verbose)
|
spack.test.run(args.names, outputDir, args.verbose)
|
||||||
|
|||||||
@@ -92,11 +92,13 @@ def run(names, outputDir, verbose=False):
|
|||||||
|
|
||||||
tty.msg("Running test: %s" % test)
|
tty.msg("Running test: %s" % test)
|
||||||
|
|
||||||
xmlOutputFname = "unittests-{0}.xml".format(test)
|
runOpts = ["--with-%s" % spack.test.tally_plugin.Tally.name]
|
||||||
xmlOutputPath = join_path(outputDir, xmlOutputFname)
|
|
||||||
runOpts = ["--with-%s" % spack.test.tally_plugin.Tally.name,
|
if outputDir:
|
||||||
"--with-xunit",
|
xmlOutputFname = "unittests-{0}.xml".format(test)
|
||||||
"--xunit-file={0}".format(xmlOutputPath)]
|
xmlOutputPath = join_path(outputDir, xmlOutputFname)
|
||||||
|
runOpts += ["--with-xunit",
|
||||||
|
"--xunit-file={0}".format(xmlOutputPath)]
|
||||||
argv = [""] + runOpts + [module]
|
argv = [""] + runOpts + [module]
|
||||||
result = nose.run(argv=argv, addplugins=[tally])
|
result = nose.run(argv=argv, addplugins=[tally])
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ def __init__(self):
|
|||||||
self.failCount = 0
|
self.failCount = 0
|
||||||
self.errorCount = 0
|
self.errorCount = 0
|
||||||
|
|
||||||
|
# TODO: this doesn't account for the possibility of skipped tests
|
||||||
@property
|
@property
|
||||||
def numberOfTests(self):
|
def numberOfTests(self):
|
||||||
return self.errorCount + self.failCount + self.successCount
|
return self.errorCount + self.failCount + self.successCount
|
||||||
|
|||||||
Reference in New Issue
Block a user