Use the xunit nose plugin to generate JUnit XML test results from Spack's unit
tests.
This commit is contained in:
parent
0adf93853d
commit
18dea24df8
@ -22,8 +22,10 @@
|
|||||||
# along with this program; if not, write to the Free Software Foundation,
|
# along with this program; if not, write to the Free Software Foundation,
|
||||||
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
import os
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
|
||||||
|
from llnl.util.filesystem import join_path, mkdirp
|
||||||
from llnl.util.tty.colify import colify
|
from llnl.util.tty.colify import colify
|
||||||
from llnl.util.lang import list_modules
|
from llnl.util.lang import list_modules
|
||||||
|
|
||||||
@ -37,6 +39,9 @@ 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(
|
||||||
|
'-d', '--outputDir', dest='outputDir', 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")
|
||||||
@ -48,4 +53,10 @@ def test(parser, args):
|
|||||||
colify(spack.test.list_tests(), indent=2)
|
colify(spack.test.list_tests(), indent=2)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
spack.test.run(args.names, args.verbose)
|
if not args.outputDir:
|
||||||
|
outputDir = join_path(os.getcwd(), "test-output")
|
||||||
|
else:
|
||||||
|
outputDir = args.outputDir
|
||||||
|
if not os.path.exists(outputDir):
|
||||||
|
mkdirp(outputDir)
|
||||||
|
spack.test.run(args.names, outputDir, args.verbose)
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
import nose
|
import nose
|
||||||
|
|
||||||
from spack.test.tally_plugin import Tally
|
from spack.test.tally_plugin import Tally
|
||||||
|
from llnl.util.filesystem import join_path
|
||||||
import llnl.util.tty as tty
|
import llnl.util.tty as tty
|
||||||
from llnl.util.tty.colify import colify
|
from llnl.util.tty.colify import colify
|
||||||
|
|
||||||
@ -69,7 +70,7 @@ def list_tests():
|
|||||||
return test_names
|
return test_names
|
||||||
|
|
||||||
|
|
||||||
def run(names, verbose=False):
|
def run(names, outputDir, verbose=False):
|
||||||
"""Run tests with the supplied names. Names should be a list. If
|
"""Run tests with the supplied names. Names should be a list. If
|
||||||
it's empty, run ALL of Spack's tests."""
|
it's empty, run ALL of Spack's tests."""
|
||||||
verbosity = 1 if not verbose else 2
|
verbosity = 1 if not verbose else 2
|
||||||
@ -91,8 +92,13 @@ def run(names, verbose=False):
|
|||||||
|
|
||||||
tty.msg("Running test: %s" % test)
|
tty.msg("Running test: %s" % test)
|
||||||
|
|
||||||
activateTally = "--with-%s" % spack.test.tally_plugin.Tally.name
|
xmlOutputFname = "unittests-{0}.xml".format(test)
|
||||||
result = nose.run(argv=["", activateTally, module], addplugins=[tally])
|
xmlOutputPath = join_path(outputDir, xmlOutputFname)
|
||||||
|
runOpts = ["--with-%s" % spack.test.tally_plugin.Tally.name,
|
||||||
|
"--with-xunit",
|
||||||
|
"--xunit-file={0}".format(xmlOutputPath)]
|
||||||
|
argv = [""] + runOpts + [module]
|
||||||
|
result = nose.run(argv=argv, addplugins=[tally])
|
||||||
|
|
||||||
succeeded = not tally.failCount and not tally.errorCount
|
succeeded = not tally.failCount and not tally.errorCount
|
||||||
tty.msg("Tests Complete.",
|
tty.msg("Tests Complete.",
|
||||||
|
Loading…
Reference in New Issue
Block a user