summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPeter Scheibel <scheibel1@llnl.gov>2015-10-12 20:49:23 -0700
committerPeter Scheibel <scheibel1@llnl.gov>2015-10-12 20:49:23 -0700
commit6cd22e5786dbf40f1261b9b0410bdafbb6dd6f29 (patch)
tree6a4cccd5059c010d1d308ace67aad104739a4c11 /lib
parentb7249d66b3b47f710ddbb1719f433b507322b5a3 (diff)
downloadspack-6cd22e5786dbf40f1261b9b0410bdafbb6dd6f29.tar.gz
spack-6cd22e5786dbf40f1261b9b0410bdafbb6dd6f29.tar.bz2
spack-6cd22e5786dbf40f1261b9b0410bdafbb6dd6f29.tar.xz
spack-6cd22e5786dbf40f1261b9b0410bdafbb6dd6f29.zip
1. Added Junit XML format
2. Specify output to a file vs. a directory 3. Use [1] and [2] to write an XML file tracking success of package installs in Junit XML format
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/testinstall.py50
1 files changed, 34 insertions, 16 deletions
diff --git a/lib/spack/spack/cmd/testinstall.py b/lib/spack/spack/cmd/testinstall.py
index d3a2cae3c2..7ebadbd344 100644
--- a/lib/spack/spack/cmd/testinstall.py
+++ b/lib/spack/spack/cmd/testinstall.py
@@ -64,24 +64,43 @@ def setup_parser(subparser):
# help="Fake install. Just remove the prefix and touch a fake file in it.")
subparser.add_argument(
- 'outputdir', help="test output goes in this directory, 1 file per package")
+ 'output', help="test output goes in this file")
subparser.add_argument(
'packages', nargs=argparse.REMAINDER, help="specs of packages to install")
-class JunitTestResult(object):
+class JunitResultFormat(object):
def __init__(self):
- self.root = Element('testsuite')
+ self.root = ET.Element('testsuite')
self.tests = []
- def addTest(self, identifier, passed=True, output=None):
- self.tests.append((identifier, passed, output))
+ def addTest(self, buildId, passed=True, buildLog=None):
+ self.tests.append((buildId, passed, buildLog))
- def output(self):
+ def writeTo(self, stream):
self.root.set('tests', '{0}'.format(len(self.tests)))
-
-
+ for buildId, passed, buildLog in self.tests:
+ testcase = ET.SubElement(self.root, 'testcase')
+ testcase.set('classname', buildId.name)
+ testcase.set('name', buildId.stringId())
+ if not passed:
+ failure = ET.SubElement(testcase, 'failure')
+ failure.set('type', "Build Error")
+ failure.text = buildLog
+ ET.ElementTree(self.root).write(stream)
+
+
+class BuildId(object):
+ def __init__(self, name, version, hashId):
+ self.name = name
+ self.version = version
+ self.hashId = hashId
+
+ def stringId(self):
+ return "-".join(str(x) for x in (self.name, self.version, self.hashId))
+
+
def testinstall(parser, args):
if not args.packages:
tty.die("install requires at least one package argument")
@@ -93,8 +112,6 @@ def testinstall(parser, args):
if args.no_checksum:
spack.do_checksum = False # TODO: remove this global.
- print "Output to:", args.outputdir
-
specs = spack.cmd.parse_specs(args.packages, concretize=True)
try:
for spec in specs:
@@ -108,13 +125,12 @@ def testinstall(parser, args):
verbose=args.verbose,
fake=False)
finally:
+ jrf = JunitResultFormat()
for spec in specs:
package = spack.db.get(spec)
#import pdb; pdb.set_trace()
- print spec.name
- print spec.version
- print spec.dag_hash()
+ bId = BuildId(spec.name, spec.version, spec.dag_hash())
if package.installed:
installLog = spack.install_layout.build_log_path(spec)
@@ -124,6 +140,8 @@ def testinstall(parser, args):
installLog = join_path(package.stage.source_path, 'spack-build.out')
with open(installLog, 'rb') as F:
- for line in F.readlines()[:10]:
- print "\t{0}".format(line.strip())
-
+ buildLog = F.read() #TODO: this may not return all output
+ jrf.addTest(bId, package.installed, buildLog)
+
+ with open(args.output, 'wb') as F:
+ jrf.writeTo(F)