From 8b9ab25125d0b38152e03d2104b3a1c53d9a13b3 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Fri, 2 Nov 2018 01:55:25 -0700 Subject: [PATCH] coverage: test compile leptonica --- src/ocrmypdf/lib/compile_leptonica.py | 3 ++- tests/test_lept.py | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ocrmypdf/lib/compile_leptonica.py b/src/ocrmypdf/lib/compile_leptonica.py index 066af029..963e45db 100644 --- a/src/ocrmypdf/lib/compile_leptonica.py +++ b/src/ocrmypdf/lib/compile_leptonica.py @@ -19,7 +19,6 @@ from cffi import FFI ffibuilder = FFI() -ffibuilder.set_source("ocrmypdf.lib._leptonica", None) ffibuilder.cdef(""" typedef signed char l_int8; typedef unsigned char l_uint8; @@ -324,5 +323,7 @@ lept_free(void *ptr); """) +ffibuilder.set_source("ocrmypdf.lib._leptonica", None) + if __name__ == '__main__': ffibuilder.compile(verbose=True) diff --git a/tests/test_lept.py b/tests/test_lept.py index 38efebc2..67d47bc5 100644 --- a/tests/test_lept.py +++ b/tests/test_lept.py @@ -78,3 +78,12 @@ def test_pickle(crom_pix): pickled = dumps(pix) pix2 = loads(pickled) assert pix.mode == pix2.mode + + +def test_leptonica_compile(tmpdir): + from ocrmypdf.lib.compile_leptonica import ffibuilder + + # Compile the library but build it somewhere that won't interfere with + # existing compiled library. Also compile in API mode so that we test + # the interfaces, even though we use it ABI mode. + ffibuilder.compile(tmpdir=tmpdir, target=(tmpdir /'lepttest.*'))