Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
T
test-vscode-c-win
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸大学计算机学院
教师群组
赵鹏翀-zpc
test-vscode-c-win
提交
de58ef4b
提交
de58ef4b
3月 17, 2021
创建
作者:
宋海霞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更新 local_test_c.py
上级
8ac82073
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
12 行增加
和
38 行删除
+12
-38
local_test_c.py
local_test_c.py
+12
-38
没有找到文件。
local_test_c.py
浏览文件 @
de58ef4b
...
@@ -79,7 +79,7 @@ def compare_file(file1, file2, seqNum, caseCount):
...
@@ -79,7 +79,7 @@ def compare_file(file1, file2, seqNum, caseCount):
sys
.
exit
()
sys
.
exit
()
else
:
else
:
print
(
"正在比较文件 {0} 和 {1}"
.
format
(
file1
,
file2
),
end
=
': '
)
print
(
"正在比较文件 {0} 和 {1}"
.
format
(
file1
,
file2
),
end
=
': '
)
# if os.path.isfile(file1) and os.path.isfile(file2) and filecmp.cmp(file1, file2):
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
)
and
advanced_file_compare
(
file1
,
file2
):
print
(
"文件相同"
)
print
(
"文件相同"
)
score
=
60
score
=
60
...
@@ -91,18 +91,13 @@ def compare_file(file1, file2, seqNum, caseCount):
...
@@ -91,18 +91,13 @@ def compare_file(file1, file2, seqNum, caseCount):
promptInfo
=
"Case{0} 验证成功"
.
format
(
seqNum
)
promptInfo
=
"Case{0} 验证成功"
.
format
(
seqNum
)
outputPromptInfo
(
bIncludeCi
,
promptInfo
,
1
)
outputPromptInfo
(
bIncludeCi
,
promptInfo
,
1
)
print
(
"exec-score"
,
round
(
score
,
2
))
print
(
"exec-score"
,
round
(
score
,
2
))
# promptInfo = "exec-score {0}".format(round(score, 2))
# outputPromptInfo(bIncludeCi, promptInfo, 1)
# print(Fore.GREEN + "Case{0} 验证成功, 分数: {1}".format(seqNum, round(score, 2)), file = stream, end='')
# print(Fore.WHITE, file = stream)
returnVal
=
1
returnVal
=
1
return
returnVal
return
returnVal
else
:
else
:
print
(
"文件不同"
)
print
(
"文件不同"
)
promptInfo
=
"Case{0} 验证失败"
.
format
(
seqNum
)
promptInfo
=
"Case{0} 验证失败"
.
format
(
seqNum
)
outputPromptInfo
(
bIncludeCi
,
promptInfo
,
2
)
outputPromptInfo
(
bIncludeCi
,
promptInfo
,
2
)
# print(Fore.RED + "Case{0} 验证失败".format(seqNum), file = stream, end='')
# print(Fore.WHITE, file = stream)
text1_lines
=
read_file
(
file1
)
text1_lines
=
read_file
(
file1
)
text2_lines
=
read_file
(
file2
)
text2_lines
=
read_file
(
file2
)
...
@@ -147,11 +142,6 @@ if __name__ == "__main__":
...
@@ -147,11 +142,6 @@ if __name__ == "__main__":
promptInfo
=
"提示:
\n
1.如果验证程序长时间未结束,说明应用程序中可能存在死循环。请停止验证程序,修改应用程序后再验证。
\n
2.如果提示‘python’不是内部或外部命令,也不是可运行的程序或批处理文件。需要设置 Python 的环境变量并重启开发环境来解决此问题。"
promptInfo
=
"提示:
\n
1.如果验证程序长时间未结束,说明应用程序中可能存在死循环。请停止验证程序,修改应用程序后再验证。
\n
2.如果提示‘python’不是内部或外部命令,也不是可运行的程序或批处理文件。需要设置 Python 的环境变量并重启开发环境来解决此问题。"
outputPromptInfo
(
bIncludeCi
,
promptInfo
,
3
)
outputPromptInfo
(
bIncludeCi
,
promptInfo
,
3
)
# if bIncludeCi :
# print(yellow(promptInfo))
# else:
# print(Fore.YELLOW + promptInfo, file = stream)
# print(Fore.WHITE, file = stream)
print
(
"开发环境中的 Python 解释器版本号:"
+
platform
.
python_version
())
print
(
"开发环境中的 Python 解释器版本号:"
+
platform
.
python_version
())
print
(
"环境变量中的 Python 解释器版本号:"
,
end
=
' '
)
print
(
"环境变量中的 Python 解释器版本号:"
,
end
=
' '
)
...
@@ -160,11 +150,7 @@ if __name__ == "__main__":
...
@@ -160,11 +150,7 @@ if __name__ == "__main__":
if
execResult
!=
0
:
if
execResult
!=
0
:
errorInfo
=
"应用程序异常,返回值:{0}。"
.
format
(
execResult
)
errorInfo
=
"应用程序异常,返回值:{0}。"
.
format
(
execResult
)
outputPromptInfo
(
bIncludeCi
,
errorInfo
,
2
)
outputPromptInfo
(
bIncludeCi
,
errorInfo
,
2
)
# if bIncludeCi :
# print(red(errorInfo))
# else:
# print(Fore.RED + "应用程序异常,返回值:{0}。".format(execResult), file = stream, end='')
# print(Fore.WHITE, file = stream)
exit
(
1
)
exit
(
1
)
print
()
print
()
...
@@ -185,11 +171,6 @@ if __name__ == "__main__":
...
@@ -185,11 +171,6 @@ if __name__ == "__main__":
if
execResult
!=
0
:
if
execResult
!=
0
:
errorInfo
=
"应用程序异常,返回值:{0}。"
.
format
(
execResult
)
errorInfo
=
"应用程序异常,返回值:{0}。"
.
format
(
execResult
)
outputPromptInfo
(
bIncludeCi
,
errorInfo
,
2
)
outputPromptInfo
(
bIncludeCi
,
errorInfo
,
2
)
# if bIncludeCi :
# print(red(errorInfo))
# else:
# print(Fore.RED + "应用程序异常,返回值:{0}。".format(execResult), file = stream, end='')
# print(Fore.WHITE, file = stream)
exit
(
1
)
exit
(
1
)
else
:
else
:
promptInfo
=
"项目生成成功"
promptInfo
=
"项目生成成功"
...
@@ -197,12 +178,7 @@ if __name__ == "__main__":
...
@@ -197,12 +178,7 @@ if __name__ == "__main__":
promptInfo
=
"exec-score {0}"
.
format
(
60
)
promptInfo
=
"exec-score {0}"
.
format
(
60
)
if
not
os
.
path
.
isfile
(
"output1.txt"
):
if
not
os
.
path
.
isfile
(
"output1.txt"
):
promptInfo
=
"exec-score {0}"
.
format
(
100
)
promptInfo
=
"exec-score {0}"
.
format
(
100
)
outputPromptInfo
(
bIncludeCi
,
promptInfo
,
1
)
print
(
promptInfo
)
# if bIncludeCi :
# print(green("项目生成成功,分数:{0}。".format(60)))
# else:
# print(Fore.GREEN + "项目生成成功,分数:{0}。".format(60), file = stream, end='')
# print(Fore.WHITE, file = stream)
# 获取case的数量
# 获取case的数量
caseCount
=
1
caseCount
=
1
...
@@ -236,23 +212,20 @@ if __name__ == "__main__":
...
@@ -236,23 +212,20 @@ if __name__ == "__main__":
runCommand
=
"app.exe < {0} > {1}"
.
format
(
inputFile
,
useroutputFile
)
runCommand
=
"app.exe < {0} > {1}"
.
format
(
inputFile
,
useroutputFile
)
execResult
=
os
.
system
(
runCommand
)
execResult
=
os
.
system
(
runCommand
)
if
execResult
!=
0
:
if
execResult
!=
0
:
errorInfo
=
"应用程序异常,返回值:{0}。"
.
format
(
execResult
)
errorInfo
=
"应用程序
执行
异常,返回值:{0}。"
.
format
(
execResult
)
outputPromptInfo
(
bIncludeCi
,
errorInfo
,
2
)
outputPromptInfo
(
bIncludeCi
,
errorInfo
,
2
)
# if bIncludeCi :
# print(red(errorInfo))
# else:
# print(Fore.RED + "应用程序异常,返回值:{0}。".format(execResult), file = stream, end='')
# print(Fore.WHITE, file = stream)
exit
(
1
)
exit
(
1
)
if
os
.
path
.
isfile
(
outputFile
)
and
os
.
path
.
isfile
(
useroutputFile
):
if
os
.
path
.
isfile
(
outputFile
)
and
os
.
path
.
isfile
(
useroutputFile
):
if
compare_file
(
outputFile
,
useroutputFile
,
seqNum
,
caseCount
)
==
0
:
if
compare_file
(
outputFile
,
useroutputFile
,
seqNum
,
caseCount
)
==
0
:
runCommand
=
"code --diff {0} {1}"
.
format
(
outputFile
,
useroutputFile
)
#
runCommand = "code --diff {0} {1}".format(outputFile, useroutputFile)
if
bIncludeCi
:
if
bIncludeCi
:
runCommand
=
"diff {0} {1} -b -B -y -i -W 100"
.
format
(
outputFile
,
useroutputFile
)
runCommand
=
"diff {0} {1} -b -B -y -i -W 100"
.
format
(
outputFile
,
useroutputFile
)
execResult
=
os
.
system
(
runCommand
)
execResult
=
os
.
system
(
runCommand
)
# print("正在使用浏览器打开文件比较结果,可帮助用户查找验证失败的原因。")
if
execResult
!=
0
:
# 使用浏览器打开比较结果页面
errorInfo
=
"输出结果比较异常,返回值:{0}。"
.
format
(
execResult
)
# webbrowser.open('file://' + os.path.realpath(compResultFile))
outputPromptInfo
(
bIncludeCi
,
errorInfo
,
2
)
else
:
webbrowser
.
open
(
'file://'
+
os
.
path
.
realpath
(
compResultFile
))
exit
(
1
)
exit
(
1
)
seqNum
=
seqNum
+
1
seqNum
=
seqNum
+
1
\ No newline at end of file
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论