summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPeter Scheibel <scheibel1@llnl.gov>2015-11-25 17:10:45 -0800
committerPeter Scheibel <scheibel1@llnl.gov>2015-11-25 17:10:45 -0800
commitd50a18d9ebe38137690dfd0a6972616c0e07271c (patch)
tree3410720971277b12cf3ca1027cd5f6f638f0516c /lib
parent60f7756626271b46ee7d32a80ba1e78b337d6f91 (diff)
downloadspack-d50a18d9ebe38137690dfd0a6972616c0e07271c.tar.gz
spack-d50a18d9ebe38137690dfd0a6972616c0e07271c.tar.bz2
spack-d50a18d9ebe38137690dfd0a6972616c0e07271c.tar.xz
spack-d50a18d9ebe38137690dfd0a6972616c0e07271c.zip
XML output for unit tests is now enabled with an option (disabled by default)
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/test.py21
-rw-r--r--lib/spack/spack/test/__init__.py12
-rw-r--r--lib/spack/spack/test/tally_plugin.py1
3 files changed, 22 insertions, 12 deletions
diff --git a/lib/spack/spack/cmd/test.py b/lib/spack/spack/cmd/test.py
index 001ebfaef0..f93d126851 100644
--- a/lib/spack/spack/cmd/test.py
+++ b/lib/spack/spack/cmd/test.py
@@ -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)
diff --git a/lib/spack/spack/test/__init__.py b/lib/spack/spack/test/__init__.py
index 158e8bdfcb..cb75f15ca1 100644
--- a/lib/spack/spack/test/__init__.py
+++ b/lib/spack/spack/test/__init__.py
@@ -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])
diff --git a/lib/spack/spack/test/tally_plugin.py b/lib/spack/spack/test/tally_plugin.py
index e314fae6ce..c167d58529 100644
--- a/lib/spack/spack/test/tally_plugin.py
+++ b/lib/spack/spack/test/tally_plugin.py
@@ -35,6 +35,7 @@ class Tally(Plugin):
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