Gitlab will migrate to a new storage backend starting 0300 UTC on 2020-04-04. We do not anticipate a maintenance window for this migration. Performance may be impacted over the weekend. Thanks for your patience.

Commit f600ca5f authored by Daniel Brown's avatar Daniel Brown

Merge branch 'master' of git.ligo.org:finesse/test

parents 5661cdd2 391ee2b2
......@@ -8,7 +8,12 @@ import os.path as path
import requests
import traceback
################ Exceptions ################
# ===========
# Exceptions
# ===========
# Setting the exception hooks
# ---------------------------
class ExitCodeException(Exception):
""" Base class for all exceptions which set the exit code"""
......@@ -17,13 +22,20 @@ class ExitCodeException(Exception):
return 1
def handleUncaughtException(exctype, value, trace):
""" Function to exit with error code from exception object """
oldHook(exctype, value, trace)
if isinstance(value, ExitCodeException):
sys.exit(value.getExitCode())
# Set the exception hook to be our new function which exits with a error code
# Store old hook as a variable
sys.excepthook, oldHook = handleUncaughtException, sys.excepthook
# Definning new exceptions
# --------------------------
class RunException(ExitCodeException):
""" Exception for failures of finesse to run """
def __init__(self, returncode, args, err, out):
self.returncode = returncode
self.args = args
......@@ -35,6 +47,7 @@ class RunException(ExitCodeException):
return 3
class DiffException(ExitCodeException):
""" Exception for differances against the referance file """
def __init__(self, msg, outfile):
self.msg = msg
self.outfile = outfile
......@@ -42,9 +55,11 @@ class DiffException(ExitCodeException):
def getExitCode(self):
return 5
################ Functions ################
# ===========
# Functions
# ===========
def runkat(katfile):
""" Run the katfile """
try:
p = sub.Popen(["kat","--test","--noheader",katfile], stdout=sub.PIPE, stderr=sub.PIPE)
out, err = p.communicate()
......@@ -55,6 +70,9 @@ def runkat(katfile):
except OSError:
pass
# BrumSoftTest once we leave this file, stdout and stderr get mapped though
# docker back to the system stdout and stderr on the host server
# This can only handel ascii, so here we re-encode the data stream as ascii
encoding=sys.stdout.encoding
if encoding==None:
encoding='utf-8'
......@@ -64,12 +82,14 @@ def runkat(katfile):
print(out.encode('ascii','replace'))
print(err.encode('ascii','replace'), file=sys.stderr)
# if finesse exited with a non-zero error code we raise a run exception (which maps to error code 3)
if p.returncode != 0:
raise RunException(p.returncode, "kat "+katfile, err, out)
return [out,err,p.returncode]
def diff(katfile):
""" If everything ran okay we will calculate the differance """
diffFound = False
katdir=path.dirname(katfile)
......@@ -139,7 +159,18 @@ def diff(katfile):
if __name__ == "__main__":
print("Kat Test Started, Arguments: "+str(sys.argv))
test_kat = sys.argv[1]
try:
runkat(test_kat)
except Exception as e:
errtext = 'Error running finesse. Output file not produced, referance file not used. These will not be uploaded'
print(errtext)
print(errtext, file=sys.stderr)
raise e
else:
print('Finesse ran without error')
try:
diff(test_kat)
finally:
......
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