提交 58fe95e0 编写于 作者: W wangjiawei04

another commit test=serving

上级 226b464c
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. # Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
...@@ -17,9 +16,10 @@ import os ...@@ -17,9 +16,10 @@ import os
import re import re
import sys import sys
def ReadMarkDown(file): def ReadMarkDown(file):
folder = 'test' folder = 'test'
os.system('rm -rf '+ folder + ' && mkdir -p ' + folder) os.system('rm -rf ' + folder + ' && mkdir -p ' + folder)
with open(file, 'r') as f: with open(file, 'r') as f:
lines = f.readlines() lines = f.readlines()
for i, line in enumerate(lines): for i, line in enumerate(lines):
...@@ -31,9 +31,11 @@ def ReadMarkDown(file): ...@@ -31,9 +31,11 @@ def ReadMarkDown(file):
GetTestFile(lines, i, os.path.join(folder, filename)) GetTestFile(lines, i, os.path.join(folder, filename))
def GetCodeFile(lines, i , filename): def GetCodeFile(lines, i, filename):
if '```' not in lines[i+1]: if '```' not in lines[i + 1]:
raise ValueError('Syntax Error, code block should be tightly followed by "[//file]:#" ') raise ValueError(
'Syntax Error, code block should be tightly followed by "[//file]:#" '
)
i += 2 i += 2
code = '' code = ''
while True: while True:
...@@ -43,7 +45,8 @@ def GetCodeFile(lines, i , filename): ...@@ -43,7 +45,8 @@ def GetCodeFile(lines, i , filename):
i += 1 i += 1
with open(filename, 'w+') as f: with open(filename, 'w+') as f:
f.write(code) f.write(code)
def GetTestFile(lines, i, filename): def GetTestFile(lines, i, filename):
i += 1 i += 1
code = '' code = ''
...@@ -53,12 +56,14 @@ def GetTestFile(lines, i, filename): ...@@ -53,12 +56,14 @@ def GetTestFile(lines, i, filename):
code += lines[i] code += lines[i]
i += 1 i += 1
with open(filename, 'w+') as f: with open(filename, 'w+') as f:
f.write(code) f.write(code)
def RunTest(): def RunTest():
folder = 'test' folder = 'test'
os.system('cd ' + folder + ' && sh start.sh') os.system('cd ' + folder + ' && sh start.sh')
os.system('cd .. && rm -rf ' + folder) os.system('cd .. && rm -rf ' + folder)
if __name__ == '__main__': if __name__ == '__main__':
ReadMarkDown(os.path.join(sys.argv[1], sys.argv[2])) ReadMarkDown(os.path.join(sys.argv[1], sys.argv[2]))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册