8
8
9
9
10
10
def testCoverage ():
11
- #First save the coverage files
12
- saveCoverageFiles ("coverage" ,"scenario_1" , ["bddtests_vp0_1" ,"bddtests_vp1_1" ,"bddtests_vp2_1" ,"bddtests_vp3_1" ,], "cov" )
11
+ #First save the coverage files
12
+ saveCoverageFiles ("coverage" ,"scenario_1" , ["bddtests_vp0_1" ,"bddtests_vp1_1" ,"bddtests_vp2_1" ,"bddtests_vp3_1" ,], "cov" )
13
13
14
14
# Now collect the filenames for coverage files.
15
- files = glob .glob (os .path .join ('coverage' ,'*.cov' ))
15
+ files = glob .glob (os .path .join ('coverage' ,'*.cov' ))
16
16
17
17
#Create the aggregate coverage file
18
- coverageContents = createCoverageFile (files )
18
+ coverageContents = createCoverageFile (files )
19
19
20
20
#Ouput the aggregate coverage file
21
- with open ('coverage.total' , 'w' ) as outfile :
22
- outfile .write (coverageContents )
23
- outfile .close ()
21
+ with open ('coverage.total' , 'w' ) as outfile :
22
+ outfile .write (coverageContents )
23
+ outfile .close ()
24
24
25
25
def createCoverageAggregate ():
26
26
# Now collect the filenames for coverage files.
@@ -39,10 +39,10 @@ def saveCoverageFiles(folderName, rootName, containerNames, extension):
39
39
'Will save the converage files to folderName'
40
40
# Make the directory
41
41
try :
42
- os .makedirs (folderName )
42
+ os .makedirs (folderName )
43
43
except OSError as exception :
44
- if exception .errno != errno .EEXIST :
45
- raise
44
+ if exception .errno != errno .EEXIST :
45
+ raise
46
46
for containerName in containerNames :
47
47
srcPath = "{0}:/opt/gopath/src/github.com/hyperledger/fabric/coverage.cov" .format (containerName )
48
48
print ("sourcepath = {0}" .format (srcPath ))
@@ -68,27 +68,27 @@ def createCoverageFile(filenames):
68
68
#with open('coverage.total', 'w') as outfile:
69
69
for fname in filenames :
70
70
with open (fname ) as infile :
71
- firstLine = True
72
- for line in infile :
73
- if firstLine :
74
- firstLine = False
75
- continue
76
- else :
77
- # Split the line based upon white space
78
- lineParts = line .split ()
79
- if lineParts [0 ] in linesMap :
80
- # Found, keep the greater
81
- newCount = long (lineParts [2 ])
82
- oldCount = long (linesMap [lineParts [0 ]].split ()[2 ])
83
- if newCount > oldCount :
84
- linesMap [lineParts [0 ]] = line
85
- else :
86
- linesMap [lineParts [0 ]] = line
71
+ firstLine = True
72
+ for line in infile :
73
+ if firstLine :
74
+ firstLine = False
75
+ continue
76
+ else :
77
+ # Split the line based upon white space
78
+ lineParts = line .split ()
79
+ if lineParts [0 ] in linesMap :
80
+ # Found, keep the greater
81
+ newCount = long (lineParts [2 ])
82
+ oldCount = long (linesMap [lineParts [0 ]].split ()[2 ])
83
+ if newCount > oldCount :
84
+ linesMap [lineParts [0 ]] = line
85
+ else :
86
+ linesMap [lineParts [0 ]] = line
87
87
# Now sort the output
88
88
od = OrderedDict (sorted (linesMap .items (), key = lambda i : i [1 ]))
89
89
90
90
for (key , line ) in od .items ():
91
- output .write (line )
91
+ output .write (line )
92
92
contents = output .getvalue ()
93
93
output .close ()
94
94
return contents
0 commit comments