Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,29 @@ else ()
find_package(PythonLibs EXACT "${PYTHON_VERSION}" REQUIRED)
endif ()

set (NOSETESTS "" CACHE STRING "nosetests binary")
set (PYLINT "" CACHE STRING "pylint binary")

if (NOSETESTS)
set(NOSETESTS_BIN ${NOSETESTS})
else ()
if (PYTHON_VERSION STREQUAL "3")
find_program(NOSETESTS_BIN "nosetests3")
else ()
find_program(NOSETESTS_BIN "nosetests")
endif ()
endif()

if (PYLINT)
set(PYLINT_BIN ${PYLINT})
else ()
if (PYTHON_VERSION STREQUAL "3")
find_program(PYLINT_BIN "pylint3")
else ()
find_program(PYLINT_BIN "pylint")
endif ()
endif()

include(openssl_functions)
openssl_set_defines()

Expand Down
49 changes: 47 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,12 @@ AC_ARG_WITH(python,
[ --with-python=VERSION Build with a specific version of python]
,,with_python="auto")

AC_ARG_WITH(nosetests,
[ --with-nosetests=ABSOLUTE_PATH Specify nosetests location])

AC_ARG_WITH(pylint,
[ --with-pylint=ABSOLUTE_PATH Specify pylint location])

AC_ARG_WITH(docbook,
AC_HELP_STRING([--with-docbook=FILE],
[compiling manpages using docbook in the specified path, if not set online version will be used from http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl]),
Expand Down Expand Up @@ -1358,10 +1364,44 @@ if test "x$enable_python" != "xno"; then
AC_MSG_ERROR([Could not find the requested Python development libraries])
fi
enable_python="$python_found"

if (echo "$with_python" | grep -Eq "python-?3.*"); then
python_version=3
else
python_version=2
fi
else
with_python=""
fi

dnl ***************************************************************************
dnl nosetests, pylint
dnl ***************************************************************************

if test "x$with_nosetests" != "x"; then
NOSETESTS=$with_nosetests
else
if test "$python_found" = "yes"; then
if test "$python_version" = "3"; then
AC_CHECK_PROG(NOSETESTS, nosetests3, nosetests3)
else
AC_CHECK_PROG(NOSETESTS, nosetests, nosetests)
fi
fi
fi

if test "x$with_pylint" != "x"; then
PYLINT=$with_pylint
else
if test "$python_found" = "yes"; then
if test "$python_version" = "3"; then
AC_CHECK_PROG(PYLINT, pylint3, pylint3)
else
AC_CHECK_PROG(PYLINT, pylint, pylint)
fi
fi
fi

dnl ***************************************************************************
dnl java headers/libraries
dnl ***************************************************************************
Expand Down Expand Up @@ -1710,8 +1750,8 @@ AC_DEFINE_UNQUOTED(ENABLE_SYSTEMD, `enable_value $enable_systemd`, [Enable syste
AC_DEFINE_UNQUOTED(SYSTEMD_JOURNAL_MODE, `journald_mode`, [Systemd-journal support mode])
AC_DEFINE_UNQUOTED(HAVE_INOTIFY, `enable_value $ac_cv_func_inotify_init`, [Have inotify])
AC_DEFINE_UNQUOTED(HAVE_GETRANDOM, `enable_value $ac_cv_func_getrandom`, [Have getrandom])
AC_DEFINE_UNQUOTED(ENABLE_PYTHONv2, `(echo "$with_python" | grep -Eq "python-?2.*") && echo 1 || echo 0`, [Python2 c api])
AC_DEFINE_UNQUOTED(ENABLE_PYTHONv3, `(echo "$with_python" | grep -Eq "python-?3.*") && echo 1 || echo 0`, [Python3 c api])
AC_DEFINE_UNQUOTED(ENABLE_PYTHONv2, `(test "$python_version" = "2" ) && echo 1 || echo 0`, [Python2 c api])
AC_DEFINE_UNQUOTED(ENABLE_PYTHONv3, `(test "$python_version" = "3" ) && echo 1 || echo 0`, [Python3 c api])
AC_DEFINE_UNQUOTED(HAVE_RIEMANN_MICROSECONDS, `enable_value $riemann_micros`, [Riemann microseconds support])
AC_DEFINE_UNQUOTED(USE_CONST_IVYKIS_MOCK, `enable_value $IVYKIS_VERSION_UPDATED`, [ivykis version is greater than $IVYKIS_UPDATED_VERSION])

Expand Down Expand Up @@ -1749,7 +1789,12 @@ AM_CONDITIONAL([HAVE_INOTIFY], [test x$ac_cv_func_inotify_init = xyes])
AM_CONDITIONAL([HAVE_GETRANDOM], [test x$ac_cv_func_getrandom = xyes])
AM_CONDITIONAL([HAVE_FMEMOPEN], [test x$ac_cv_func_fmemopen = xyes])
AM_CONDITIONAL(ENABLE_IPV6, [test $enable_ipv6 = yes])
AM_CONDITIONAL(NOSETESTS, [test "x$NOSETESTS" != "x"])
AM_CONDITIONAL(PYLINT, [test "x$PYLINT" != "x"])


AC_SUBST(NOSETESTS)
AC_SUBST(PYLINT)
AC_SUBST(timezonedir)
AC_SUBST(pidfiledir)
AC_SUBST(moduledir)
Expand Down
4 changes: 2 additions & 2 deletions modules/python/pylib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/install/ DESTINATION ${CMAKE_INSTA
)

if (BUILD_TESTING)
add_test(test_pylib_unit ${CMAKE_COMMAND} -E env nosetests ${CMAKE_CURRENT_SOURCE_DIR}/syslogng)
add_test(test_pylib_unit ${CMAKE_COMMAND} -E env ${NOSETESTS_BIN} ${CMAKE_CURRENT_SOURCE_DIR}/syslogng)
add_test(test_pylib_pep8 ${CMAKE_COMMAND} -E env pep8 --ignore=E501 ${CMAKE_CURRENT_SOURCE_DIR}/syslogng)
add_test(test_pylib_pylint ${CMAKE_COMMAND} -E env pylint -r n --rcfile=${CMAKE_CURRENT_SOURCE_DIR}/pylintrc ${CMAKE_CURRENT_SOURCE_DIR}/syslogng)
add_test(test_pylib_pylint ${CMAKE_COMMAND} -E env ${PYLINT_BIN} -r n --rcfile=${CMAKE_CURRENT_SOURCE_DIR}/pylintrc ${CMAKE_CURRENT_SOURCE_DIR}/syslogng)
endif()
15 changes: 13 additions & 2 deletions modules/python/pylib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,25 @@ clean-pylib:

python-checks: python-unit python-pep8 python-pylint

if NOSETESTS
python-unit:
nosetests $(PYLIB_SRCDIR)/syslogng
@NOSETESTS@ $(PYLIB_SRCDIR)/syslogng
else
python-unit:
$(error "missing nosetests")
endif

python-pep8:
pep8 --ignore=E501 $(PYLIB_SRCDIR)/syslogng

if PYLINT
python-pylint:
@PYLINT@ -r n --rcfile=$(PYLIB_SRCDIR)/pylintrc $(PYLIB_SRCDIR)/syslogng
else
python-pylint:
pylint -r n --rcfile=$(PYLIB_SRCDIR)/pylintrc $(PYLIB_SRCDIR)/syslogng
$(error "missing pylint")
endif


modules_python_pylib_tests_TESTS = modules/python/pylib/test_pylib.sh
check_SCRIPTS += $(modules_python_pylib_tests_TESTS)
Expand Down