Skip to content

Commit

Permalink
Rework pipenv requirement to be more relaxed
Browse files Browse the repository at this point in the history
Keep a cached copy of the man tests that we can use when no manpage
changes are made. This allows automated systems that might not have
easy access to a pipenv to build and run tests.
  • Loading branch information
wtlangford committed Mar 2, 2020
1 parent 8c61eba commit 50a7022
Show file tree
Hide file tree
Showing 4 changed files with 892 additions and 30 deletions.
39 changes: 29 additions & 10 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -130,27 +130,46 @@ endif

### Tests (make check)

if ENABLE_DOCS
TESTS = tests/optionaltest tests/mantest tests/jqtest tests/onigtest tests/shtest tests/utf8test tests/base64test
else
TESTS = tests/optionaltest tests/jqtest tests/onigtest tests/shtest tests/utf8test tests/base64test
endif
TESTS_ENVIRONMENT = NO_VALGRIND=$(NO_VALGRIND)

# This is a magic make variable that causes it to treat tests/man.test as a
# DATA-type dependency for the check target. As a result, it will attempt to
# run any defined targets for tests/man.test as a dependency for check. This
# allows us to ensure that the tests are up-to-date if the manual has been updated
check_DATA = tests/man.test

### Building the man tests

# We use the examples in the manual as additional tests, to ensure they always work.
# As a result, we need to rebuild the tests if the manual has been updated.
# Making changes to the manpage without having the python deps means your
# tests won't run. If you aren't making changes to the examples, you probably
# don't care. But if you are, then you need to run the tests anyway.
tests/man.test: $(srcdir)/docs/content/manual/manual.yml
if ENABLE_DOCS
$(AM_V_GEN) ( cd ${abs_srcdir}/docs; $(PIPENV) run python build_mantests.py ) > $@
else
@echo Changes to the manual.yml require docs to be enabled to run the tests
@false
endif

### Building the manpage

# We build the docs from the manpage yml. If no changes have been made to the
# manpage, then we'll end up using the cached version. Otherwise, we need to
# rebuild it.
man_MANS = jq.1
jq.1.prebuilt: $(srcdir)/docs/content/manual/manual.yml
if ENABLE_DOCS
jq.1: $(srcdir)/docs/content/manual/manual.yml
$(AM_V_GEN) ( cd ${abs_srcdir}/docs; pipenv run python build_manpage.py ) > $@ || { rm -f $@; false; }
jq.1.prebuilt: jq.1
$(AM_V_GEN) cp jq.1 $@ || { rm -f $@; false; }
$(AM_V_GEN) ( cd ${abs_srcdir}/docs; $(PIPENV) run python build_manpage.py ) > $@ || { rm -f $@; false; }
else
jq.1: $(srcdir)/jq.1.prebuilt
$(AM_V_GEN) cp $(srcdir)/jq.1.prebuilt $@
@echo Changes to the manual.yml require docs to be enabled to generate an updated manpage
@echo As a result, your manpage is out of date.
endif

jq.1: jq.1.prebuilt
$(AM_V_GEN) cp jq.1.prebuilt $@

### Build oniguruma

Expand Down
37 changes: 19 additions & 18 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ AC_ARG_ENABLE([gcov],

dnl Don't attempt to build docs if python deps aren't installed
AC_ARG_ENABLE([docs],
AC_HELP_STRING([--disable-docs], [don't build docs]))
AC_HELP_STRING([--disable-docs], [don't build docs]), [], [enable_docs=yes])

dnl Don't attempt to build the error injection object (if there is no LD_PRELOAD support)
AC_ARG_ENABLE([error-injection],
Expand All @@ -87,28 +87,29 @@ dnl Enable building all static
AC_ARG_ENABLE([all-static],
AC_HELP_STRING([--enable-all-static], [link jq with static libraries only]))

AS_IF([test "x$enable_docs" = "xyes"],[
AC_CHECK_PROGS(pipenv_cmd, pipenv)
dnl find pipenv
AC_ARG_VAR([PIPENV], [pipenv command])
AC_CHECK_PROGS([PIPENV], pipenv)

AC_CACHE_CHECK([for Python dependencies], [jq_cv_python_deps],
[jq_cv_python_deps=yes;
AS_IF([test "x$pipenv_cmd" = "x" || \
! bmsg="`cd ${srcdir}/docs; LC_ALL=$LANG "$pipenv_cmd" check`"],[
AC_MSG_ERROR([$bmsg])
cat <<EOF
AS_IF([test "x$enable_docs" != "xno"],[
AC_CACHE_CHECK([for Python dependencies], [jq_cv_python_deps],[
jq_cv_python_deps=yes
AS_IF([test "x$PIPENV" = "x" || \
! bmsg="`cd ${srcdir}/docs; LC_ALL=$LANG "$PIPENV" --venv`"],[
jq_cv_python_deps=no
])
])
AS_IF([test "x$jq_cv_python_deps" != "xyes"], [
AC_MSG_WARN([Error checking python dependencies: $bmsg
*****************************************************************
* Python dependencies for building jq documentation not found. *
* You can still build, install and hack on jq, but the manpage *
* will not be rebuilt and some of the tests will not run. *
* will not be rebuilt and new manpage tests will not be run. *
* See docs/README.md for how to install the docs dependencies. *
*****************************************************************
EOF
jq_cv_python_deps=no
])])
if test "x$jq_cv_python_deps" != "xyes"; then
enable_docs=no
fi
*****************************************************************])
enable_docs=no
])
])

dnl Disable decNumber support
Expand Down
Loading

0 comments on commit 50a7022

Please # to comment.