unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Floris Bruynooghe <flub@devork.be>
To: notmuch@notmuchmail.org
Subject: experimenting with pytest tests
Date: Sat, 07 Apr 2018 13:08:57 +0200	[thread overview]
Message-ID: <py3ibmevqnna.fsf@devork.be> (raw)

Hi,

From another conversation on this list I've dug up my earlier attempts
at integrating a pytest run into the notmuch testing suite.  I'd be
grateful for some guidance on whether this is the right way to go about
things.

Here's the diff of configure:

diff --git a/configure b/configure
index c5e2ffed..8aa57b83 100755
--- a/configure
+++ b/configure
@@ -567,6 +567,28 @@ if [ $have_python -eq 0 ]; then
     errors=$((errors + 1))
 fi
 
+check_python() {
+    local bin=$1
+    local var=$(echo $bin | tr -d '.')
+    printf "Checking for $bin (with: pytest)... "
+    if command -v $bin > /dev/null; then
+        if $bin -c 'import pytest' >/dev/null 2>&1; then
+            eval have_$var=1
+            eval $var=$bin
+            printf "Yes.\n"
+        else
+            printf "No (skipping $bin tests).\n"
+        fi
+    else
+        printf "No (skipping $bin tests).\n"
+    fi
+}
+
+check_python python2.7
+check_python python3.5
+check_python python3.6
+check_python pypy3.5
+
 printf "Checking for valgrind development files... "
 if pkg-config --exists valgrind; then
     printf "Yes.\n"
@@ -1209,6 +1231,10 @@ NOTMUCH_HAVE_MAN=$((have_sphinx))
 
 # Name of python interpreter
 NOTMUCH_PYTHON=${python}
+NOTMUCH_PYTHON27=${python27-}
+NOTMUCH_PYTHON35=${python35-}
+NOTMUCH_PYTHON36=${python36-}
+NOTMUCH_PYPY35=${pypy35-}


And I was then also trying to introduce a test/T391-pytest.sh file.
What I'm trying to do in this file, but it doesn't currently work, is to
have one test, with 4 subtests where each subtest is a pytest run with a
particular python version.  But if the NOTMUCH_PYTHON27 (etc) is not
found in sh.config then the subtest should be skipped.  I'm not really
familiar enough with test-lib.sh to do this correctly without a bunch of
more looking into it, but maybe someone else knows how to do this?
Anyway, here my failing attempt:

#!/usr/bin/env bash
test_description="python unittests"
. ./test-lib.sh || exit 1


test_require_external_prereq "${NOTMUCH_PYTHON27}" && {
    test_begin_subtest "${NOTMUCH_PYTHON27}"
    (
        cd "$NOTMUCH_SRCDIR/bindings/python"
        PYTHONPATH=".${PYTHONPATH:+:$PYTHONPATH}" \
	$NOTMUCH_PYTHON27 -m pytest
    )
    test_expect_equal $? 0
}


test_require_external_prereq ${NOTMUCH_PYTHON35} && {
    test_begin_subtest "${NOTMUCH_PYTHON35}"
    (
        cd "$NOTMUCH_SRCDIR/bindings/python"
        PYTHONPATH=".${PYTHONPATH:+:$PYTHONPATH}" \
	$NOTMUCH_PYTHON35 -m pytest
    )
    test_expect_equal $? 0
}


test_done


Any tips on whether this is the right direction?

Many thanks,
Floris

             reply	other threads:[~2018-04-07 11:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-07 11:08 Floris Bruynooghe [this message]
2018-04-07 19:52 ` experimenting with pytest tests Tomi Ollila
2018-04-07 21:39   ` remix of pytest runner David Bremner
2018-04-07 21:39     ` [PATCH 1/2] configure: detect which versions of python can run pytest David Bremner
2018-04-07 21:55       ` Tomi Ollila
2018-04-07 22:04         ` Tomi Ollila
2018-04-07 21:39     ` [PATCH 2/2] test: pytest runner for the test suite David Bremner
2018-04-08 13:15       ` Floris Bruynooghe
2018-04-10 19:28         ` Tomi Ollila
     [not found]         ` <87po39uz0z.fsf@tethera.net>
2018-04-13 19:29           ` Floris Bruynooghe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=py3ibmevqnna.fsf@devork.be \
    --to=flub@devork.be \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).