@ -31,9 +31,9 @@ def getTestdata(job=None):
if job is None :
if job is None :
job = basic . program . Job . getInstance ( )
job = basic . program . Job . getInstance ( )
if " testcase " in job . program :
if " testcase " in job . program :
return collectTestdata ( B . PAR_TESTCASE , job . par [ B . PAR_TESTCASE ] , job )
return collectTestdata ( B . PAR_TESTCASE , getattr ( job . par , B . PAR_TESTCASE ) , job )
else :
else :
return collectTestdata ( B . PAR_TESTSUITE , job . par [ B . PAR_TESTSUITE ] , job )
return collectTestdata ( B . PAR_TESTSUITE , getattr ( job . par , B . PAR_TESTSUITE ) , job )
def collectTestdata ( gran , testentity , job ) :
def collectTestdata ( gran , testentity , job ) :
@ -45,27 +45,28 @@ def collectTestdata(gran, testentity, job):
setBlockLists ( job )
setBlockLists ( job )
if gran == B . PAR_TESTCASE :
if gran == B . PAR_TESTCASE :
basispath = utils . path_tool . rejoinPath ( job . conf . confs [ B . SUBJECT_PATH ] [ B . ATTR_PATH_TDATA ] , testentity )
basispath = utils . path_tool . rejoinPath ( job . conf . confs [ B . SUBJECT_PATH ] [ B . ATTR_PATH_TDATA ] , testentity )
pathname = utils . config_tool . getConfigPath ( P . KEY_TESTCASE , job . par [ B . PAR_TESTCASE ] , " " , job )
pathname = utils . config_tool . getConfigPath ( P . KEY_TESTCASE , getattr ( job . par , B . PAR_TESTCASE ) , " " , job )
if gran == B . PAR_TESTSUITE :
if gran == B . PAR_TESTSUITE :
basispath = utils . path_tool . rejoinPath ( job . conf . confs [ B . SUBJECT_PATH ] [ B . ATTR_PATH_TDATA ] , testentity )
basispath = utils . path_tool . rejoinPath ( job . conf . confs [ B . SUBJECT_PATH ] [ B . ATTR_PATH_TDATA ] , testentity )
pathname = utils . config_tool . getConfigPath ( P . KEY_TESTSUITE , job . par [ B . PAR_TESTSUITE ] , " " , job )
pathname = utils . config_tool . getConfigPath ( P . KEY_TESTSUITE , getattr ( job . par , B . PAR_TESTSUITE ) , " " , job )
if pathname [ - 3 : ] == D . DFILE_TYPE_CSV :
if pathname [ - 3 : ] == D . DFILE_TYPE_CSV :
tdata = getCsvSpec ( job . m , pathname , D . CSV_SPECTYPE_DATA )
tdata = getCsvSpec ( job . m , pathname , D . CSV_SPECTYPE_DATA )
else :
else :
tdata = utils . file_tool . readFileDict ( pathname , job . m )
tdata = utils . file_tool . readFileDict ( pathname , job . m )
# get explicit specdata of includes
# get explicit specdata of includes
for pathname in tdata [ D . CSV_BLOCK_IMPORT ] :
if D . CSV_BLOCK_IMPORT in tdata :
pathname = utils . path_tool . rejoinPath ( pathname )
for pathname in tdata [ D . CSV_BLOCK_IMPORT ] :
if job . conf . confs [ B . SUBJECT_PATH ] [ B . ATTR_PATH_TDATA ] not in pathname :
pathname = utils . path_tool . rejoinPath ( pathname )
pathname = utils . path_tool . rejoinPath ( basispath , pathname )
if job . conf . confs [ B . SUBJECT_PATH ] [ B . ATTR_PATH_TDATA ] not in pathname :
if pathname [ - 3 : ] == D . DFILE_TYPE_CSV :
pathname = utils . path_tool . rejoinPath ( basispath , pathname )
data = getCsvSpec ( job . m , pathname , D . CSV_SPECTYPE_DATA )
if pathname [ - 3 : ] == D . DFILE_TYPE_CSV :
else :
data = getCsvSpec ( job . m , pathname , D . CSV_SPECTYPE_DATA )
data = utils . file_tool . readFileDict ( pathname , job . m )
else :
for table in data [ D . CSV_BLOCK_TABLES ] :
data = utils . file_tool . readFileDict ( pathname , job . m )
if table in tdata [ D . CSV_BLOCK_TABLES ] :
for table in data [ D . CSV_BLOCK_TABLES ] :
print ( " Fehler " )
if table in tdata [ D . CSV_BLOCK_TABLES ] :
tdata [ D . CSV_BLOCK_TABLES ] [ table ] = data [ D . CSV_BLOCK_TABLES ] [ table ]
print ( " Fehler " )
tdata [ D . CSV_BLOCK_TABLES ] [ table ] = data [ D . CSV_BLOCK_TABLES ] [ table ]
# get implicit specdata of spec-library
# get implicit specdata of spec-library
for prefix in list_blocks [ D . DFILE_TABLE_PREFIX ] :
for prefix in list_blocks [ D . DFILE_TABLE_PREFIX ] :
files = utils . file_tool . getFiles ( job . m , basispath , prefix , None )
files = utils . file_tool . getFiles ( job . m , basispath , prefix , None )
@ -178,7 +179,7 @@ def parseCsvSpec(msg, lines, ttype, tdata, job=None):
# keywords option, step, table
# keywords option, step, table
if verbose : print ( str ( a ) + " -- " + str ( fields ) )
if verbose : print ( str ( a ) + " -- " + str ( fields ) )
tableAttr = setTableAttribute ( tableAttr , a [ 0 ] , fields [ 1 ] , job )
tableAttr = setTableAttribute ( tableAttr , a [ 0 ] , fields [ 1 ] , job )
if ( tableAttr [ " hit " ] ) :
if ( tableAttr [ " _ hit" ] ) :
status = " TABLE_ALIAS "
status = " TABLE_ALIAS "
continue
continue
if ( a [ 0 ] . lower ( ) in list_blocks [ D . CSV_BLOCK_HEAD ] ) :
if ( a [ 0 ] . lower ( ) in list_blocks [ D . CSV_BLOCK_HEAD ] ) :
@ -229,9 +230,18 @@ def parseCsvSpec(msg, lines, ttype, tdata, job=None):
setTableHeader ( tableDict , tableAttr , fields , ttype , job )
setTableHeader ( tableDict , tableAttr , fields , ttype , job )
status = D . CSV_SPECTYPE_DATA
status = D . CSV_SPECTYPE_DATA
if ttype == D . CSV_SPECTYPE_CONF :
if ttype == D . CSV_SPECTYPE_CONF :
header = [ ]
for k in tdata :
for k in tdata :
if k in D . LIST_DATA_ATTR :
continue
if B . DATA_NODE_DATA in tdata [ k ] :
if B . DATA_NODE_DATA in tdata [ k ] :
tdata [ k ] . pop ( B . DATA_NODE_DATA )
tdata [ k ] . pop ( B . DATA_NODE_DATA )
for f in tdata [ k ] :
if f in [ B . DATA_NODE_HEADER , " _hit " ] + D . LIST_DATA_ATTR :
continue
header . append ( f )
tdata [ k ] [ B . DATA_NODE_HEADER ] = header
header = [ ]
if B . DATA_NODE_TABLES in tdata and B . DATA_NODE_TABLES in tdata [ B . DATA_NODE_TABLES ] :
if B . DATA_NODE_TABLES in tdata and B . DATA_NODE_TABLES in tdata [ B . DATA_NODE_TABLES ] :
for k in tdata [ B . DATA_NODE_TABLES ] [ B . DATA_NODE_TABLES ] :
for k in tdata [ B . DATA_NODE_TABLES ] [ B . DATA_NODE_TABLES ] :
if k in tdata [ B . DATA_NODE_TABLES ] :
if k in tdata [ B . DATA_NODE_TABLES ] :
@ -271,11 +281,17 @@ def setTableData(tableDict, fields, ttype, job):
row [ f ] = fields [ i ] . strip ( )
row [ f ] = fields [ i ] . strip ( )
i + = 1
i + = 1
if ttype == D . CSV_SPECTYPE_DATA :
if ttype == D . CSV_SPECTYPE_DATA :
if B . ATTR_DATA_COMP in tableDict :
tcomps = tableDict [ B . ATTR_DATA_COMP ]
else :
tcomps = { }
row [ B . ATTR_DATA_COMP ] = { }
row [ B . ATTR_DATA_COMP ] = { }
for c in fields [ 0 ] . split ( " , " ) :
for c in fields [ 0 ] . split ( " , " ) :
a = c . split ( " : " )
a = c . split ( " : " )
tcomps [ a [ 0 ] ] = a [ 1 ]
row [ B . ATTR_DATA_COMP ] [ a [ 0 ] ] = a [ 1 ] . strip ( )
row [ B . ATTR_DATA_COMP ] [ a [ 0 ] ] = a [ 1 ] . strip ( )
tableDict [ B . DATA_NODE_DATA ] . append ( row )
tableDict [ B . DATA_NODE_DATA ] . append ( row )
tableDict [ B . ATTR_DATA_COMP ] = tcomps
elif ttype == D . CSV_SPECTYPE_KEYS :
elif ttype == D . CSV_SPECTYPE_KEYS :
tableDict [ D . CSV_NODETYPE_KEYS ] [ fields [ tableDict [ D . DATA_ATTR_KEY ] ] . strip ( ) ] = row
tableDict [ D . CSV_NODETYPE_KEYS ] [ fields [ tableDict [ D . DATA_ATTR_KEY ] ] . strip ( ) ] = row
elif ttype == D . CSV_SPECTYPE_CONF :
elif ttype == D . CSV_SPECTYPE_CONF :
@ -287,9 +303,9 @@ def setTableAttribute(tableAttr, key, val, job):
for attr in D . LIST_DATA_ATTR :
for attr in D . LIST_DATA_ATTR :
if ( key . lower ( ) in list_blocks [ attr ] ) :
if ( key . lower ( ) in list_blocks [ attr ] ) :
tableAttr [ attr ] = val . strip ( )
tableAttr [ attr ] = val . strip ( )
tableAttr [ " hit " ] = True
tableAttr [ " _ hit" ] = True
return tableAttr
return tableAttr
tableAttr [ " hit " ] = False
tableAttr [ " _ hit" ] = False
return tableAttr
return tableAttr
@ -362,6 +378,15 @@ def splitFields(line, delimiter, job):
return out
return out
def writeCsvData ( filename , tdata , comp , job ) :
text = " "
if B . DATA_NODE_TABLES in tdata :
for k in tdata [ B . DATA_NODE_TABLES ] :
text + = buildCsvData ( tdata [ B . DATA_NODE_TABLES ] [ k ] , k , job )
text + = " \n "
utils . file_tool . writeFileText ( comp . m , filename , text )
def buildCsvData ( tdata , table , job = None ) :
def buildCsvData ( tdata , table , job = None ) :
"""
"""
writes the testdata into a csv - file for documentation of the test - run
writes the testdata into a csv - file for documentation of the test - run