Skip to content
Snippets Groups Projects
Commit 36b90634 authored by Sebastian Khan's avatar Sebastian Khan
Browse files

Update lvcnrcheck with pass/fail information

parent 67cd989c
No related branches found
No related tags found
1 merge request!5Update lvcnrcheck with pass/fail information
Pipeline #
......@@ -51,6 +51,8 @@ else:
def checkField(sim, field):
# Check validity of field against specification class `field`
valid = field.valid(sim)
msg = valid.msg if valid.msg is not None else ''
......@@ -59,7 +61,7 @@ def checkField(sim, field):
if isinstance(valid, err.Missing):
print FIELD_INVALID.format(
valid.name, field.name, 'undefined', msg).strip('')
return
return 1
# Condition on being an attribute
isAttribute = not isinstance(
......@@ -69,11 +71,16 @@ def checkField(sim, field):
value = sim.att(field.name) if isAttribute else type(sim[field.name])
if isinstance(valid, err.Valid):
print FIELD_VALID.format(valid.name, field.name, value, msg).strip()
return 0
else:
print FIELD_INVALID.format(valid.name, field.name, value, msg).strip()
return 1
if __name__ == '__main__':
# Initialise checkInt. checkInt = 0 for pass and >0 for fail.
checkInt = 0
sim = Sim(args.file)
# Format 1
......@@ -83,16 +90,16 @@ if __name__ == '__main__':
print("## {0:s}\n".format(groupKey))
for fieldKey, field in group.items():
checkField(sim, field())
checkInt += checkField(sim, field())
print('')
if args.format > 1:
# Format 2
print('# Format 2\n')
for fieldKey, field in format2.items():
checkField(sim, field())
checkInt += checkField(sim, field())
print('')
......@@ -101,7 +108,7 @@ if __name__ == '__main__':
print('# Format 3\n')
for fieldKey, field in format3.items():
checkField(sim, field())
checkInt += checkField(sim, field())
print('')
......@@ -110,7 +117,7 @@ if __name__ == '__main__':
if len(phaseModes) > 0:
print('# Phase Modes\n')
for phaseMode in phaseModes:
checkField(sim, phaseMode)
checkInt += checkField(sim, phaseMode)
print ('')
......@@ -119,4 +126,10 @@ if __name__ == '__main__':
if len(ampModes) > 0:
print('# Amplitude Modes\n')
for ampMode in ampModes:
checkField(sim, ampMode)
checkInt += checkField(sim, ampMode)
# report back if the simulation has passed or failed the check
if checkInt == 0:
print('pass')
else:
print('fail')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment