Browse Source

imported patch prism-auto-progress.patch

tud-infrastructure-2018-10-12
Joachim Klein 7 years ago
parent
commit
507eb68a8a
  1. 47
      prism/etc/scripts/prism-auto

47
prism/etc/scripts/prism-auto

@ -60,6 +60,11 @@ switchShortcuts = {
# set of PRISM argument tuples that already ran
alreadyRan = set()
# task counter & mode for counting tasks
currentTask = 0
numberOfTasks = 0
countTaskMode = False
#==================================================================================================
# Utility functions
#==================================================================================================
@ -483,6 +488,14 @@ def canonicaliseArgs(args):
# Run PRISM with a given list of command-line args
def runPrism(args, dir=""):
if countTaskMode:
global numberOfTasks
numberOfTasks+=1
return
global currentTask
currentTask+=1
# check if we can skip
if options.skipDuplicates:
canonicalArgs = canonicaliseArgs(args)
@ -515,6 +528,9 @@ def runPrism(args, dir=""):
prismArgs += ['|', 'grep "Testing result:"']
print(' '.join(prismArgs))
return
if options.showProgress:
# prepend progress indicator before the command line printing
sys.stdout.write('[%d/%d] ' % (currentTask, numberOfTasks))
print(' '.join(prismArgs))
sys.stdout.flush()
if options.logDir:
@ -759,7 +775,7 @@ def benchmark(file, args, dir=""):
return
# Determine which out files apply to this benchmark from the -export switches (if required)
if not options.echo and options.test:
if not options.echo and not countTaskMode and options.test:
outFiles = getExpectedOutFilesFromArgs(args)
# Rename export files to avoid overriding out files
@ -789,7 +805,7 @@ def benchmark(file, args, dir=""):
runPrism(modelFileArg + args, dir)
# Verify that exported files are correct (if required)
if not options.echo and options.test and outFiles:
if not options.echo and not countTaskMode and options.test and outFiles:
# print "Out files to verify exports against: " + ' '.join(outFiles)
allEqual = verifyAndCleanupExports(outFiles, exportPrefix)
if (not allEqual) and (not options.testAll):
@ -988,6 +1004,16 @@ def closeDown(exitCode):
printTestStatistics()
sys.exit(exitCode)
def runLoop(args):
currentTask = 0
for arg in args:
if os.path.isdir(arg):
benchmarkDir(arg)
elif os.path.isfile(arg):
benchmarkFile(arg)
else:
print("Error: File/directory " + arg + " does not exist")
# Main program
signal.signal(signal.SIGINT, signal_handler)
@ -1016,6 +1042,7 @@ parser.add_option("--skip-duplicate-runs", action="store_true", dest="skipDuplic
parser.add_option("--timeout", dest="timeout", metavar="N", default=None, help='Timeout for each PRISM run (examples values for N: 5 / 5s for seconds, 5m / 5h for minutes / hours)')
parser.add_option("--dd-warnings", action="store_true", dest="ddWarnings", default=False, help="Print the DD reference count warnings")
parser.add_option("--colour", dest="colourEnabled", metavar="X", type="choice", choices=["yes","no","auto"], default="auto", help="Whether to colour test results: yes, no, auto (yes iff in terminal mode) [default=auto]")
parser.add_option("--progress", action="store_true", dest="showProgress", default=False, help="Show progress indicator")
(options, args) = parser.parse_args()
if len(args) < 1:
parser.print_help()
@ -1059,13 +1086,15 @@ if options.nailgun:
restartNailGunServer();
# process benchmarks
for arg in args:
if os.path.isdir(arg):
benchmarkDir(arg)
elif os.path.isfile(arg):
benchmarkFile(arg)
else:
print("Error: File/directory " + arg + " does not exist")
if options.showProgress:
# to show process indicators, we first have to do a run
# in countTaskMode, which just counts how often runPrism will be called
countTaskMode = True
runLoop(args)
countTaskMode = False
# actually process all the remaining arguments
runLoop(args)
# shutdown
if options.test and options.testAll and not options.echo:

Loading…
Cancel
Save