simplified updating
This commit is contained in:
parent
5321019457
commit
41b097bbc1
|
@ -24,7 +24,7 @@ class Test():
|
|||
self.dirBase = os.path.dirname(os.path.realpath(sys.modules[self.__class__.__module__].__file__))
|
||||
self.parser = OptionParser(
|
||||
description = 'Using: $Id run_test.py 1285 2012-02-09 08:54:09Z MPIE\m.diehl $',
|
||||
usage='run_test.py [options]')
|
||||
usage='./test.py [options]')
|
||||
|
||||
self.parser.add_option("-u", "--update", action="store_true",\
|
||||
dest="update",\
|
||||
|
@ -33,13 +33,12 @@ class Test():
|
|||
|
||||
(self.options, self.args) = self.parser.parse_args()
|
||||
|
||||
def execute(self,variants = [],update = []):
|
||||
def execute(self):
|
||||
'''
|
||||
Run all variants and report first failure.
|
||||
'''
|
||||
if not self.testPossible(): return -1
|
||||
if len(update) == 0 and self.options.update: print(' This test has no reference to update')
|
||||
if len(variants) == 0: variants = xrange(len(self.variants)) # iterate over all variants
|
||||
if len(variants) == 0: variants = xrange(len(self.variants)) # iterate over all variants
|
||||
self.clean()
|
||||
self.prepareAll()
|
||||
for variant in variants:
|
||||
|
@ -47,13 +46,13 @@ class Test():
|
|||
self.prepare(variant)
|
||||
self.run(variant)
|
||||
self.postprocess(variant)
|
||||
if variant in update:
|
||||
if options.update: # update requested
|
||||
self.update(variant)
|
||||
elif not self.compare(variant):
|
||||
return variant+1
|
||||
elif not self.compare(variant): # no update, do comparison
|
||||
return variant+1 # return culprit
|
||||
except Exception as e :
|
||||
print('\nWARNING:\n %s\n'%e)
|
||||
return variant+1
|
||||
return variant+1 # return culprit
|
||||
return 0
|
||||
|
||||
def testPossible(self):
|
||||
|
@ -120,6 +119,7 @@ class Test():
|
|||
'''
|
||||
Update reference with current results.
|
||||
'''
|
||||
print('Update not necessary')
|
||||
return True
|
||||
|
||||
|
||||
|
@ -129,36 +129,42 @@ class Test():
|
|||
'''
|
||||
return os.path.normpath(os.path.join(self.dirBase,'reference/'))
|
||||
|
||||
|
||||
def dirCurrent(self):
|
||||
'''
|
||||
Directory containing current results of the test.
|
||||
'''
|
||||
return os.path.normpath(os.path.join(self.dirBase,'current/'))
|
||||
|
||||
|
||||
def dirProof(self):
|
||||
'''
|
||||
Directory containing human readable proof of correctness for the test.
|
||||
'''
|
||||
return os.path.normpath(os.path.join(self.dirBase,'proof/'))
|
||||
|
||||
|
||||
def fileInReference(self,file):
|
||||
'''
|
||||
Path to a file in the refrence directory for the test.
|
||||
'''
|
||||
return os.path.join(self.dirReference(),file)
|
||||
|
||||
|
||||
def fileInCurrent(self,file):
|
||||
'''
|
||||
Path to a file in the current results directory for the test.
|
||||
'''
|
||||
return os.path.join(self.dirCurrent(),file)
|
||||
|
||||
|
||||
def fileInProof(self,file):
|
||||
'''
|
||||
Path to a file in the proof directory for the test.
|
||||
'''
|
||||
return os.path.join(self.dirProof(),file)
|
||||
|
||||
|
||||
def copy_Reference2Current(self,sourcefiles=[],targetfiles=[]):
|
||||
|
||||
if len(targetfiles) == 0: targetfiles = sourcefiles
|
||||
|
@ -168,6 +174,7 @@ class Test():
|
|||
except:
|
||||
print('Reference2Current: Unable to copy file %s'%file)
|
||||
|
||||
|
||||
def copy_Base2Current(self,sourceDir,sourcefiles=[],targetfiles=[]):
|
||||
|
||||
source=os.path.normpath(os.path.join(self.dirBase,'../../'+sourceDir))
|
||||
|
@ -179,6 +186,7 @@ class Test():
|
|||
print(os.path.join(source,file))
|
||||
print('Base2Current: Unable to copy file %s'%file)
|
||||
|
||||
|
||||
def copy_Current2Reference(self,sourcefiles=[],targetfiles=[]):
|
||||
|
||||
if len(targetfiles) == 0: targetfiles = sourcefiles
|
||||
|
@ -188,6 +196,7 @@ class Test():
|
|||
except:
|
||||
print('Current2Reference: Unable to copy file %s'%file)
|
||||
|
||||
|
||||
def copy_Proof2Current(self,sourcefiles=[],targetfiles=[]):
|
||||
|
||||
if len(targetfiles) == 0: targetfiles = sourcefiles
|
||||
|
@ -197,6 +206,7 @@ class Test():
|
|||
except:
|
||||
print('Proof2Current: Unable to copy file %s'%file)
|
||||
|
||||
|
||||
def copy_Current2Current(self,sourcefiles=[],targetfiles=[]):
|
||||
|
||||
for i,file in enumerate(sourcefiles):
|
||||
|
@ -205,6 +215,7 @@ class Test():
|
|||
except:
|
||||
print('Current2Current: Unable to copy file %s'%file)
|
||||
|
||||
|
||||
def execute_inCurrentDir(self,cmd,outfile='execute_log.txt'):
|
||||
|
||||
initialPath=os.getcwd()
|
||||
|
@ -216,6 +227,7 @@ class Test():
|
|||
file.close()
|
||||
os.chdir(initialPath)
|
||||
|
||||
|
||||
def compare_Array(self,File1,File2):
|
||||
|
||||
import numpy
|
||||
|
@ -239,6 +251,7 @@ class Test():
|
|||
else:
|
||||
raise Exception('mismatch in array size to compare')
|
||||
|
||||
|
||||
def compare_ArrayRefCur(self,ref,cur=''):
|
||||
|
||||
if cur =='': cur = ref
|
||||
|
@ -246,6 +259,7 @@ class Test():
|
|||
curName = self.fileInCurrent(cur)
|
||||
return self.compare_Array(refName,curName)
|
||||
|
||||
|
||||
def compare_ArrayCurCur(self,cur0,cur1):
|
||||
|
||||
cur0Name = self.fileInCurrent(cur0)
|
||||
|
@ -355,6 +369,7 @@ class Test():
|
|||
print(' ********')
|
||||
return maxError
|
||||
|
||||
|
||||
def compare_TableRefCur(self,headingsRef,ref,headingsCur='',cur='',normHeadings='',normType=None,\
|
||||
absoluteTolerance=False,perLine=False,skipLines=[]):
|
||||
|
||||
|
@ -365,6 +380,7 @@ class Test():
|
|||
return self.compare_Table(headingsRef,refName,headingsCur,curName,normHeadings,normType,
|
||||
absoluteTolerance,perLine,skipLines)
|
||||
|
||||
|
||||
def compare_TableCurCur(self,headingsCur0,Cur0,Cur1,headingsCur1='',normHeadings='',normType=None,\
|
||||
absoluteTolerance=False,perLine=False,skipLines=[]):
|
||||
|
||||
|
@ -374,6 +390,7 @@ class Test():
|
|||
return self.compare_Table(headingsCur0,cur0Name,headingsCur1,cur1Name,normHeadings,normType,
|
||||
absoluteTolerance,perLine,skipLines)
|
||||
|
||||
|
||||
def report_Success(self,culprit):
|
||||
|
||||
if culprit == 0:
|
||||
|
|
Loading…
Reference in New Issue