From f823399a738feacaa83205716c0c7ea2dc92034f Mon Sep 17 00:00:00 2001 From: ccremers Date: Mon, 13 Mar 2006 16:26:53 +0000 Subject: [PATCH] - Minor improvements. --- test/scythercache.py | 34 ++++++++++++++++++++++++++-------- test/scythertest.py | 7 ++++--- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/test/scythercache.py b/test/scythercache.py index a47d577..ae47077 100755 --- a/test/scythercache.py +++ b/test/scythercache.py @@ -23,6 +23,7 @@ from tempfile import NamedTemporaryFile, gettempdir CacheTimer = 0.1 ScytherProgram = "scyther" RetrieveFromCache = True +LastArguments = "" #---------------------------------------------------------------------------- # How to override Scyther program setting @@ -62,17 +63,28 @@ def scythercall (argumentstring, inputfile): # argstring: a smaller string def evaluate (argumentstring, inputstring): - def cacheid(): - m = md5.new() - + global LastArguments + + def getversion(): # Determine scyther version (status, scout) = scythercall ("--version", "") if status == 1 or status < 0: # some problem print "Problem with determining scyther version!" os.exit() - # Add version to hash - m.update (scout) + ll = scout.splitlines() + versionline = ll[1].split() + if versionline[0] != "Revision": + print "Could not find revision ID in:" + print scout + + return versionline[1] + + def cacheid(): + m = md5.new() + + # Determine scyther version + m.update (version) # Add inputfile to hash m.update (inputstring) @@ -96,9 +108,9 @@ def evaluate (argumentstring, inputstring): # Determine name def cachefilename(id): - fn = gettempdir() + "/scyther/" - fn = fn + slashcutter(id,"/",3,2) - fn = fn + ".txt" + fn = gettempdir() + "/scyther/" + version + "/" + fn += slashcutter(id,"/",3,2) + fn += ".txt" return fn # Ensure directory @@ -143,6 +155,12 @@ def evaluate (argumentstring, inputstring): #print "Retrieved cached version for [%s]." % argumentstring return (0,res) + # Retrieve version + version = getversion() + + # Store for later refernce + LastArguments = argumentstring + # Determine the unique filename for this test cachefile = cachefilename(cacheid()) if os.path.exists(cachefile) and RetrieveFromCache: diff --git a/test/scythertest.py b/test/scythertest.py index 7d1215d..8524ec2 100755 --- a/test/scythertest.py +++ b/test/scythertest.py @@ -72,9 +72,10 @@ def add_extra_parameters(args): global g_extra if args != "": - if g_extra != "": - g_extra = g_extra + " " - g_extra = g_extra + args + if g_extra.find(args) == -1: + if g_extra != "": + g_extra = g_extra + " " + g_extra = g_extra + args # Yield arguments, given a bound type: # 0: fast