JD2022-TU1/main/extern/gear4/buildfolder/ComparingCovFiles.py

65 lines
No EOL
2.4 KiB
Python

import os
import sys
import xml.etree.ElementTree as ET
import os.path
import time
import argparse
import subprocess
import pymssql
import smtplib
import shutil
argParser = argparse.ArgumentParser(description="Set the client and the path of the branch you are using")
argParser.add_argument( '--branchPath',
type=str,
default='',
help="Set the path of the branch you are using.")
argParser.add_argument( '--perforceClient',
type=str,
default='',
help="Set the cleint spec.")
argParser.add_argument( '--module',
type=str,
default='',
help="Set the module.")
args = argParser.parse_args()
BRANCH_PATH = args.branchPath
PERFORCE_CLIENT=args.perforceClient
CURRENT_MODULE=args.module
def ConvertingLineEnding(covFile):
with open(os.getcwd()+'\\bullseye\\'+covFile, 'r') as covFileConvertion1:
covFileConvertion = covFileConvertion1.read()
covFileConvertion = covFileConvertion.replace('\r\n','\n')
covFileConvertion1.close()
with open(os.getcwd()+'\\bullseye\\'+covFile, 'wb') as covFileConvertionWrite:
covFileConvertionWrite.write(str(covFileConvertion))
covFileConvertionWrite.close
def CompareCovFiles(covFile):
#ConvertingLineEnding(covFile)
subprocess.call(['p4', 'edit',PERFORCE_CLIENT, os.getcwd()+'\\bullseye\\'+covFile])
result = subprocess.check_output(['p4', 'diff',PERFORCE_CLIENT, os.getcwd()+'\\bullseye\\'+covFile,'//technology-group-playground/gear/team/buildfolder/bullseye/'+covFile])
if(result.find('<')!=-1 or result.find('>')!=-1) or result.find('(... files differ ...)'):
subprocess.call(['p4', 'submit','-d "update gear_core_test @review jflemay @submitassistant(2.4.6.0) @skipped"' ,os.getcwd()+'\\bullseye\\'+covFile])
subprocess.call(['p4', 'resolve', '-at' ,os.getcwd()+'\\bullseye\\'+covFile])
print('submit file : '+str(covFile))
else:
subprocess.call(['p4', 'revert',PERFORCE_CLIENT, os.getcwd()+'\\bullseye\\'+covFile])
print('revert file : '+str(covFile))
# Main
def main():
print ('Comparing COV files for the current module = '+str(CURRENT_MODULE))
if (str(CURRENT_MODULE) =='gear_core'):
CompareCovFiles('gear_core_test.cov')
if (str(CURRENT_MODULE) =='gear_detection'):
CompareCovFiles('gear_detection_test.cov')
if __name__ == '__main__':
sys.exit( main() )