Commit cc96d9d3 authored by Ansgar Burchardt's avatar Ansgar Burchardt

Install duneci-ctest.

parent 2fb98d74
/*-stamp
/base-?/duneci-ctest
......@@ -2,12 +2,15 @@ all: base-8-stamp base-9-stamp dune-2.3-stamp dune-2.4-stamp dune-fufem-stamp du
clean:
rm -f -- ./*-stamp
rm -f -- base-8/duneci-ctest base-9/duneci-ctest
base-8-stamp: base-8/Dockerfile
base-8-stamp: base-8/Dockerfile base-common/duneci-ctest
cp base-common/duneci-ctest base-8/duneci-ctest
docker build --no-cache -t duneci/base:8 base-8
touch $@
base-9-stamp: base-9/Dockerfile
base-9-stamp: base-9/Dockerfile base-common/duneci-ctest
cp base-common/duneci-ctest base-9/duneci-ctest
docker build --no-cache -t duneci/base:9 base-9
touch $@
......
......@@ -35,6 +35,8 @@ RUN apt-get update && apt-get dist-upgrade --no-install-recommends --yes \
RUN adduser --disabled-password --home /duneci duneci
USER duneci
WORKDIR /duneci
RUN mkdir -p /duneci/modules
RUN mkdir -p /duneci/bin /duneci/modules
ENV DUNE_CONTROL_PATH=.:/duneci/modules
ENV PATH=/duneci/bin:$PATH
COPY opts.clang opts.gcc /duneci/
COPY duneci-ctest /duneci/bin/
......@@ -35,6 +35,8 @@ RUN apt-get update && apt-get dist-upgrade --no-install-recommends --yes \
RUN adduser --disabled-password --home /duneci duneci
USER duneci
WORKDIR /duneci
RUN mkdir -p /duneci/modules
RUN mkdir -p /duneci/bin /duneci/modules
ENV DUNE_CONTROL_PATH=.:/duneci/modules
ENV PATH=/duneci/bin:$PATH
COPY opts.clang opts.gcc /duneci/
COPY duneci-ctest /duneci/bin/
#! /usr/bin/env python3
# Wrapper around CTest for DUNE
# Author: Ansgar Burchardt <Ansgar.Burchardt@tu-dresden.de>
import errno
import glob
import os.path
import shutil
import subprocess
import sys
import xml.etree.ElementTree
def printTest(test):
status = test.get("Status")
name = test.find("Name").text
fullName = test.find("FullName").text
output = test.find("Results").find("Measurement").find("Value").text
print("======================================================================")
print("Name: {}".format(name))
print("FullName: {}".format(fullName))
print("Status: {}".format(status.upper()))
if output:
print("Output:")
for line in output.splitlines():
print(" ", line)
print()
def handleTest(test):
status = test.get("Status")
name = test.find("Path").text
if status == "passed":
passed = True
elif status == "notrun":
printTest(test)
passed = True
else:
printTest(test)
passed = False
return passed
def findCTestOutput():
files = glob.glob("Testing/*/Test.xml")
if len(files) != 1:
fn = files.join(", ")
raise Exception("Found multiple CTest output files: {}".format(files.join(", ")))
return files[0]
def handleCTestOutput():
path = findCTestOutput()
with open(path, "r") as fh:
tree = xml.etree.ElementTree.parse(fh)
root = tree.getroot()
testing = root.find("Testing")
passed = True
for test in testing.findall("Test"):
testPassed = handleTest(test)
passed = passed and testPassed
return passed
def runCTest(argv=[]):
cmd = ["ctest",
"--output-on-failure",
"--dashboard", "ExperimentalTest",
"--no-compress-output",
]
cmd.extend(argv)
subprocess.run(cmd, check=False)
def checkDirectory():
if not os.path.exists("CMakeCache.txt"):
raise Exception("ERROR: dune-ctest must be run in a cmake build directory")
def removeCTestOutput():
try:
shutil.rmtree("Testing")
except OSError as e:
if e.errno != errno.ENOENT:
raise
def main():
try:
checkDirectory()
removeCTestOutput()
runCTest(argv=sys.argv[1:])
passed = handleCTestOutput()
status = 0 if passed else 1
sys.exit(status)
except Exception as e:
print("Internal error: {}".format(e))
sys.exit(127)
if __name__ == "__main__":
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment