[PATCH 4/5] tests: run python-cffi tests

Tomi Ollila tomi.ollila at iki.fi
Wed Nov 6 12:51:42 PST 2019


On Tue, Nov 05 2019, David Bremner wrote:

> Tomi Ollila <tomi.ollila at iki.fi> writes:
>
>
>>
>> probably
>>
>> test_expect_success "${NOTMUCH_PYTHON} -m pytest \
>>                     --log-file=$TMP_DIRECTORY/test.output \
>>                     $NOTMUCH_SRCDIR/bindings/python-cffi/build/stage" 
>>
>> worked (which reminds me out-of-tree... ;)
>>
>
> despite looking prettier this does not work because it looks for the
> "notdb" module in the current directory. It could work (maybe) if we set
> PYTHONPATH. Would that be better than the 'cd'?

So that would basically be:

  test_expect_success "PYTHONPATH=$PWD${PYTHONPATH:+:$PYTHONPATH} \
                       ${NOTMUCH_PYTHON} -m pytest \
                       --log-file=$TMP_DIRECTORY/test.output \
                       $NOTMUCH_SRCDIR/bindings/python-cffi/build/stage"
(if it worked)

perhaps 'cd' in subshell is clearer

(i also wonder what --rootdir= does (and how new pytest is needed for that)

>> It prints the version, then exists. Could not figure out how to request
>> specific version in quick look (10 min search/trial/error session),
>> parsing version output is so... :/ 
>
> I think something like
>
> conf=$(mktemp)
> printf "[pytest]\nminversion=3.0\n" > $conf
> if pytest-3 -c $conf --version >/dev/null; then
>    have_pytest=1
> else
>    have_pytest=0
> fi
> rm -f $(conf)
>
> should work.

Right -- just that pytest-3 may not be available -- to iterate (tested)...

if ${NOTMUCH_PYTHON} -m pytest -c $conf --version >/dev/null 2>&1; then

(in this particular case redirecting both stdout and stderr is needed
 to silence noise in all 'ordinary' cases, being 
   1) pytest module not available -- silence stderr
   2) pytest version not new enough -- silence stderr
   3) pytest exists and is new enought -- silence stdout )



More information about the notmuch mailing list