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