未验证 提交 78790ed8 编写于 作者: Y Yu Yang 提交者: GitHub

Merge pull request #11963 from reyoung/API_diff

Check API changes
......@@ -312,6 +312,20 @@ EOF
fi
}
function assert_api_not_changed() {
mkdir -p ${PADDLE_ROOT}/build/.check_api_workspace
cd ${PADDLE_ROOT}/build/.check_api_workspace
virtualenv .env
source .env/bin/activate
pip install ${PADDLE_ROOT}/build/python/dist/*whl
curl ${PADDLE_API_SPEC_URL:-https://raw.githubusercontent.com/reyoung/FluidAPISpec/master/API.spec} \
> origin.spec
python ${PADDLE_ROOT}/tools/print_signatures.py paddle.fluid > new.spec
python ${PADDLE_ROOT}/tools/diff_api.py origin.spec new.spec
deactivate
}
function single_test() {
TEST_NAME=$1
if [ -z "${TEST_NAME}" ]; then
......@@ -550,6 +564,7 @@ function main() {
cicheck)
cmake_gen ${PYTHON_ABI:-""}
build
assert_api_not_changed
run_test
gen_capi_package
gen_fluid_inference_lib
......
#!/usr/bin/env python
from __future__ import print_function
import difflib
import sys
with open(sys.argv[1], 'r') as f:
origin = f.read()
origin = origin.splitlines()
with open(sys.argv[2], 'r') as f:
new = f.read()
new = new.splitlines()
differ = difflib.Differ()
result = differ.compare(origin, new)
error = False
print('API Difference is: ')
for each_diff in result:
if each_diff[0] in ['-', '?']: # delete or change API is not allowed
error = True
elif each_diff[0] == '+':
# only new layers is allowed.
if not each_diff.startswith('+ paddle.fluid.layers.'):
error = True
if each_diff[0] != ' ':
print(each_diff)
if error:
sys.exit(1)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册