File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 312
312
fi
313
313
}
314
314
315
+ function assert_api_not_changed() {
316
+ mkdir -p ${PADDLE_ROOT} /build/.check_api_workspace
317
+ cd ${PADDLE_ROOT} /build/.check_api_workspace
318
+ virtualenv .env
319
+ source .env/bin/activate
320
+ pip install ${PADDLE_ROOT} /build/python/dist/* whl
321
+ curl ${PADDLE_API_SPEC_URL:- https:// raw.githubusercontent.com/ reyoung/ FluidAPISpec/ master/ API.spec} \
322
+ > origin.spec
323
+ python ${PADDLE_ROOT} /tools/print_signatures.py paddle.fluid > new.spec
324
+ python ${PADDLE_ROOT} /tools/diff_api.py origin.spec new.spec
325
+ deactivate
326
+ }
327
+
328
+
315
329
function single_test() {
316
330
TEST_NAME=$1
317
331
if [ -z " ${TEST_NAME} " ]; then
@@ -550,6 +564,7 @@ function main() {
550
564
cicheck)
551
565
cmake_gen ${PYTHON_ABI:- " " }
552
566
build
567
+ assert_api_not_changed
553
568
run_test
554
569
gen_capi_package
555
570
gen_fluid_inference_lib
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python
2
+ from __future__ import print_function
3
+ import difflib
4
+ import sys
5
+
6
+ with open (sys .argv [1 ], 'r' ) as f :
7
+ origin = f .read ()
8
+ origin = origin .splitlines ()
9
+
10
+ with open (sys .argv [2 ], 'r' ) as f :
11
+ new = f .read ()
12
+ new = new .splitlines ()
13
+
14
+ differ = difflib .Differ ()
15
+ result = differ .compare (origin , new )
16
+
17
+ error = False
18
+ print ('API Difference is: ' )
19
+ for each_diff in result :
20
+ if each_diff [0 ] in ['-' , '?' ]: # delete or change API is not allowed
21
+ error = True
22
+ elif each_diff [0 ] == '+' :
23
+ # only new layers is allowed.
24
+ if not each_diff .startswith ('+ paddle.fluid.layers.' ):
25
+ error = True
26
+
27
+ if each_diff [0 ] != ' ' :
28
+ print (each_diff )
29
+
30
+ if error :
31
+ sys .exit (1 )
You can’t perform that action at this time.
0 commit comments