From 5c21a80d680f266a8143055c4d6b31ec8eaa3c37 Mon Sep 17 00:00:00 2001 From: Joachim Klein Date: Fri, 23 Jun 2017 10:59:14 +0000 Subject: [PATCH] prism-auto: print test statistics at the end if in test-mode git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@11995 bbc10eb1-c90d-0410-af57-cb519fbb1720 --- prism/etc/scripts/prism-auto | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/prism/etc/scripts/prism-auto b/prism/etc/scripts/prism-auto index dfa54134..bd444e96 100755 --- a/prism/etc/scripts/prism-auto +++ b/prism/etc/scripts/prism-auto @@ -15,6 +15,13 @@ import os,sys,re,subprocess,signal,tempfile,functools,logging,time,platform from pipes import quote from optparse import OptionParser +#================================================================================================== +# Global variables +#================================================================================================== + +# statistics about test results +testStats = dict(SUCCESS = 0, FAILURE = 0, SKIPPED = 0, UNSUPPORTED = 0) + #================================================================================================== # Utility functions #================================================================================================== @@ -413,6 +420,7 @@ def runPrism(args, dir=""): def printTestResult(msg): msg = str.rstrip(msg) + countTestResult(msg) if not isColourEnabled(): print(msg); return @@ -430,6 +438,30 @@ def printTestResult(msg): else: print(msg) +def incrementTestStat(stat): + global testStats + testStats[stat]+=1 + +def printTestStatistics(): + if options.test and not options.echo: + print('\nTest results:'); + print(' Success: ' + str(testStats['SUCCESS'])); + print(' Failure: ' + str(testStats['FAILURE'])); + print(' Unsupported: ' + str(testStats['UNSUPPORTED'])); + print(' Skipped: ' + str(testStats['SKIPPED'])); + +def countTestResult(msg): + if 'Error:' in msg or 'FAIL' in msg: + incrementTestStat('FAILURE') +# ignore warnings +# elif 'Warning:' in msg: + elif 'PASS' in msg: + incrementTestStat('SUCCESS') + elif 'SKIPPED' in msg or 'NOT TESTED' in msg: + incrementTestStat('SKIPPED') + elif 'UNSUPPORTED' in msg: + incrementTestStat('UNSUPPORTED') + # Is printing of colour coded messages enabled? def isColourEnabled(): @@ -698,6 +730,7 @@ def closeDown(exitCode): print(options.ngprism + " stop") else: subprocess.Popen([options.ngprism, "stop"]).wait() + printTestStatistics() sys.exit(exitCode) # Main program