提交 e0d39189 创建 作者: 宋海霞's avatar 宋海霞

modify

上级 61f9246b
流水线 #156523 已通过 于阶段
用时 1 分 23 秒
...@@ -73,6 +73,14 @@ def advanced_file_compare(file1, file2): ...@@ -73,6 +73,14 @@ def advanced_file_compare(file1, file2):
return returnVal return returnVal
def advanced_dat_file_compare(file1, file2):
returnVal = 1
runCommand = "diff {0} {1} -b -B -y -i -W 100".format(file1, file2)
execResult = os.system(runCommand)
if execResult != 0:
returnVal = 0
return returnVal
def getPlatformType(): def getPlatformType():
platformType = PlatformType.other platformType = PlatformType.other
if platform.system().lower() == 'windows': if platform.system().lower() == 'windows':
......
...@@ -34,26 +34,41 @@ def getFileCount(fileStr): ...@@ -34,26 +34,41 @@ def getFileCount(fileStr):
# 比较两个文件并把结果生成一份html文本 # 比较两个文件并把结果生成一份html文本
def compare_file(file1, file2, type): def compare_file(file1, file2, type):
returnVal = 0 returnVal = 0
bDat = False
if file1 == "" or file2 == "": if file1 == "" or file2 == "":
print('文件路径不能为空:第一个文件的路径:{0}, 第二个文件的路径:{1} .'.format(file1, file2)) print('文件路径不能为空:第一个文件的路径:{0}, 第二个文件的路径:{1} .'.format(file1, file2))
sys.exit() sys.exit()
else: else:
resultFileType = getResultFileType()
dsFileType = getDataSourceFileType()
if type == CmpFileType.userprojresult: if type == CmpFileType.userprojresult:
promptInfo = "正在比较标准答案结果文件 {0} 和用户编写的应用程序结果文件 {1}" promptInfo = "正在比较标准答案结果文件 {0} 和用户编写的应用程序结果文件 {1}"
if resultFileType == ResultFileType.writedat:
bDat = True
elif type == CmpFileType.templateresult: elif type == CmpFileType.templateresult:
promptInfo = "正在比较模板中的标准答案结果文件 {0} 和用户程序中的标准答案结果文件 {1}" promptInfo = "正在比较模板中的标准答案结果文件 {0} 和用户程序中的标准答案结果文件 {1}"
if resultFileType == ResultFileType.writedat:
bDat = True
elif type == CmpFileType.templatedatasource: elif type == CmpFileType.templatedatasource:
promptInfo = "正在比较模板中的数据源文件 {0} 和用户程序中的数据源文件 {1}" promptInfo = "正在比较模板中的数据源文件 {0} 和用户程序中的数据源文件 {1}"
if dsFileType == DataSourceFileType.readdat:
bDat = True
print(promptInfo.format(file1, file2), end=': ') print(promptInfo.format(file1, file2), end=': ')
sys.stdout.flush() sys.stdout.flush()
if os.path.isfile(file1) and os.path.isfile(file2) and advanced_file_compare(file1, file2): if os.path.isfile(file1) and os.path.isfile(file2):
print("文件相同") comResult = 0
sys.stdout.flush() if bDat:
returnVal = 1 comResult = advanced_dat_file_compare(file1, file2)
else: else:
print("文件不同") comResult = advanced_file_compare(file1, file2)
sys.stdout.flush() if comResult == 1:
print("文件相同")
sys.stdout.flush()
returnVal = 1
else:
print("文件不同")
sys.stdout.flush()
return returnVal return returnVal
if __name__ == "__main__": if __name__ == "__main__":
......
...@@ -42,14 +42,7 @@ red = lambda text: '\033[0;31;1m' + text + '\033[0m' ...@@ -42,14 +42,7 @@ red = lambda text: '\033[0;31;1m' + text + '\033[0m'
green = lambda text: '\033[0;32;1m' + text + '\033[0m' green = lambda text: '\033[0;32;1m' + text + '\033[0m'
yellow = lambda text: '\033[0;33;1m' + text + '\033[0m' yellow = lambda text: '\033[0;33;1m' + text + '\033[0m'
def advanced_dat_file_compare(file1, file2):
returnVal = 1
runCommand = "diff {0} {1} -b -B -y -i -W 100".format(file1, file2)
execResult = os.system(runCommand)
if execResult != 0:
returnVal = 0
return returnVal
# 比较两个文件并把结果生成一份html文本 # 比较两个文件并把结果生成一份html文本
def compare_file(file1, file2, seqNum, caseCount, bCI, resultFileType, dsType): def compare_file(file1, file2, seqNum, caseCount, bCI, resultFileType, dsType):
returnVal = 0 returnVal = 0
......
  • Developer

    代码质量分析发现了 7 个问题。

    • 0 blocker
    • 🚫 0 critical
    • 0 major
    • 🔽 4 minor
    • 3 info

    注意: 存在下列问题的代码行在本次提交中没有发生变更,无法使用代码行评论的方式进行报告。所以将下列问题汇总显示在这里(点击问题链接可以转到对应的源代码行):

    1. 🔽 Cppcheck cannot find all the include files. Cppcheck can check the code without the include files found. But the results will probably be more accurate if all the include files are found. Please check your project's include directories and add all of them as include directories for Cppcheck. To see what files Cppcheck cannot find use --check-config. (ProjectKey-176961) 📘
    2. 🔽 Variable 'b' is assigned a value that is never used. 📘
    3. 🔽 Either the condition 'fp2!=0' is redundant or there is possible null pointer dereference: fp2. 📘
    4. 🔽 Either the condition 'fp!=0' is redundant or there is possible null pointer dereference: fp. 📘
    5. keyword 'if' not followed by a single space 📘
    6. closing curly bracket not in the same line or column 📘
    7. closing curly bracket not in the same line or column 📘
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论