[libvirt] [PATCH 0/2] Add tox.ini to run tests with tox

Tox is a convinient tool creating virtual environment to install dependencies and run tests. To run all tests, just type "tox". To only test a specific Python version, use "tox -e py34" (Python 3.4). Victor Stinner (2): sanitytest.py parameters are now optional Add tox.ini to run tests on Python 2.6, 2.7 & 3.4 .gitignore | 1 + sanitytest.py | 23 ++++++++++++++++++----- tox.ini | 10 ++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 tox.ini -- 2.1.0

When called without parameters, sanitytest.py doesn't touch sys.path and locates itself the patch to the libvirt-api.xml file using pkg-config. This change makes possible to run sanitytest.py from tox. --- sanitytest.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/sanitytest.py b/sanitytest.py index eb44cdb..faabccb 100644 --- a/sanitytest.py +++ b/sanitytest.py @@ -5,18 +5,31 @@ import lxml import lxml.etree import string -# Munge import path to insert build location for libvirt mod -sys.path.insert(0, sys.argv[1]) +if len(sys.argv) >= 2: + # Munge import path to insert build location for libvirt mod + sys.path.insert(0, sys.argv[1]) import libvirt if sys.version > '3': long = int +def get_libvirt_api_xml_path(): + import subprocess + args = ["pkg-config", "--variable", "libvirt_api", "libvirt"] + proc = subprocess.Popen(args, stdout=subprocess.PIPE) + stdout, _ = proc.communicate() + if proc.returncode: + sys.exit(proc.returncode) + return stdout.splitlines()[0] + # Path to the libvirt API XML file -xml = sys.argv[2] +if len(sys.argv) >= 3: + xml = sys.argv[2] +else: + xml = get_libvirt_api_xml_path() -f = open(xml, "r") -tree = lxml.etree.parse(f) +with open(xml, "r") as fp: + tree = lxml.etree.parse(fp) verbose = False fail = False -- 2.1.0

On Wed, Apr 22, 2015 at 03:06:59PM +0200, Victor Stinner wrote:
When called without parameters, sanitytest.py doesn't touch sys.path and locates itself the patch to the libvirt-api.xml file using pkg-config.
This change makes possible to run sanitytest.py from tox. --- sanitytest.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
ACK & pushed. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

--- .gitignore | 1 + tox.ini | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index a28e63c..19ee546 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ MANIFEST *.#*# *.pyc tags +.tox diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..e8c33f1 --- /dev/null +++ b/tox.ini @@ -0,0 +1,10 @@ +[tox] +envlist = py26,py27,py34 + +[testenv] +deps= + lxml + nose +commands= + python sanitytest.py + nosetests -- 2.1.0

On Wed, Apr 22, 2015 at 03:07:00PM +0200, Victor Stinner wrote:
--- .gitignore | 1 + tox.ini | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 tox.ini
ACK & pushed. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On Wed, Apr 22, 2015 at 04:44:00PM +0100, Daniel P. Berrange wrote:
On Wed, Apr 22, 2015 at 03:07:00PM +0200, Victor Stinner wrote:
--- .gitignore | 1 + tox.ini | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 tox.ini
ACK & pushed.
Oh, I'm also adding tox.ini to MANIFEST.in so it gets included in the dist tar.gz Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On 04/22/2015 07:06 AM, Victor Stinner wrote:
Tox is a convinient tool creating virtual environment to install dependencies and run tests. To run all tests, just type "tox". To only test a specific Python version, use "tox -e py34" (Python 3.4).
Is it also worth hooking this into the Makefile, so that the existing 'make check' also runs tox? Also, please run 'git config format.subjectprefix "python PATCH"' to make it obvious that your patches are against libvirt-python.git instead of libvirt.git.
Victor Stinner (2): sanitytest.py parameters are now optional Add tox.ini to run tests on Python 2.6, 2.7 & 3.4
.gitignore | 1 + sanitytest.py | 23 ++++++++++++++++++----- tox.ini | 10 ++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 tox.ini
-- 2.1.0
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Wed, Apr 22, 2015 at 07:56:58AM -0600, Eric Blake wrote:
On 04/22/2015 07:06 AM, Victor Stinner wrote:
Tox is a convinient tool creating virtual environment to install dependencies and run tests. To run all tests, just type "tox". To only test a specific Python version, use "tox -e py34" (Python 3.4).
Is it also worth hooking this into the Makefile, so that the existing 'make check' also runs tox?
The makefile already runs the tests - tox is just another way to invoke the tests we already have. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

Is it also worth hooking this into the Makefile, so that the existing 'make check' also runs tox?
I have no opinion on that :-) I don't know how other developers are testing libvirt-python. "python setup.py test" tests /usr/bin/python" (usually Python 2.7) and it doesn't install dependencies. It might be faster than tox. "tox" tests Python 2.6, 2.7 and 3.4 at once and it installs dependencies. But it requires the external tox program (install it using "pip install tox").
Also, please run 'git config format.subjectprefix "python PATCH"' to make it obvious that your patches are against libvirt-python.git instead of libvirt.git.
Yeah sorry, it was the first time that I used git format-patch/git send-email for real! I missed the fact that the mailing list is for multiple projects. I will mention "python" in the topic next time ;-) (I already added "libvirt-python" for my setup.py patch.) Victor
participants (4)
-
Daniel P. Berrange
-
Eric Blake
-
Victor Stinner
-
Victor Stinner