Merge lp:~salgado/offspring/test-runner into lp:offspring

Proposed by Guilherme Salgado
Status: Merged
Merged at revision: 84
Proposed branch: lp:~salgado/offspring/test-runner
Merge into: lp:offspring
Diff against target: 86 lines (+30/-11)
4 files modified
Makefile (+9/-0)
docs/HACKING (+21/-0)
lib/offspring/master/tests.py (+0/-6)
lib/offspring/slave/tests.py (+0/-5)
To merge this branch: bzr merge lp:~salgado/offspring/test-runner
Reviewer Review Type Date Requested Status
Offspring Hackers Pending
Review via email: mp+74674@code.launchpad.net

Description of the change

Add a shell script and instructions to run the test suite.

The script uses nose to run the non-django tests and django's standard test
runner for any tests we put under lib/offspring/web/queuemanager.

Currently the new script doesn't expect any arguments but in the future we can
extend it so that users can specify a subset of the tests to run.

To post a comment you must log in.
Revision history for this message
Cody A.W. Somerville (cody-somerville) wrote :

On Thu, Sep 8, 2011 at 3:54 PM, Guilherme Salgado <
<email address hidden>> wrote:
<snip>

> === added directory 'lib/offspring/tests'
> === added file 'test.sh'
> --- test.sh 1970-01-01 00:00:00 +0000
> +++ test.sh 2011-09-08 19:53:46 +0000
> @@ -0,0 +1,6 @@
> +#!/bin/sh
> +
> +# Run all tests, excluding the ones under web.queuemanager.
> +.virtualenv/bin/nosetests -e 'queuemanager.*'
> +# Run the tests under web.queuemanager.
> +./bin/offspring-web test queuemanager
> --settings=offspring.web.settings_test
>

Is there any reason not to just add a new Makefile rule called 'test' to do
this? That way you can even make it make sure everything is setup plus
install nose.

Also, is there any benefit to using nose over updating setup.py so that you
can just run './setup.py test'?

Revision history for this message
Guilherme Salgado (salgado) wrote :

Thanks for the review, Cody.

On Wed, 2011-09-14 at 19:18 +0000, Cody A.W. Somerville wrote:
> On Thu, Sep 8, 2011 at 3:54 PM, Guilherme Salgado <
> <email address hidden>> wrote:
> <snip>
>
> > === added directory 'lib/offspring/tests'
> > === added file 'test.sh'
> > --- test.sh 1970-01-01 00:00:00 +0000
> > +++ test.sh 2011-09-08 19:53:46 +0000
> > @@ -0,0 +1,6 @@
> > +#!/bin/sh
> > +
> > +# Run all tests, excluding the ones under web.queuemanager.
> > +.virtualenv/bin/nosetests -e 'queuemanager.*'
> > +# Run the tests under web.queuemanager.
> > +./bin/offspring-web test queuemanager
> > --settings=offspring.web.settings_test
> >
>
> Is there any reason not to just add a new Makefile rule called 'test' to do
> this? That way you can even make it make sure everything is setup plus
> install nose.

Indeed, that's a good idea. I'll do it.

> Also, is there any benefit to using nose over updating setup.py so that you
> can just run './setup.py test'?

Right now the only benefit is that nose does test discovery so we don't
have to enumerate all our tests for setup.py to run them. But it has
several other features that will probably be useful once we have a real
test suite, e.g.

 - package/module level fixtures
 - several options to run just a subset of the tests
 - plugins for code-coverage, dropping into pdb on failure, etc
 - junit output so that we can integrate with subunit/hudson
 - parallel testing, to make use of all those idle cores we have!

lp:~salgado/offspring/test-runner updated
88. By Guilherme Salgado

Get rid of the test.sh script and write a couple Makefile targets to run the tests

Revision history for this message
Guilherme Salgado (salgado) wrote :

I've just updated this to use new Makefile rules to run the tests, including one extra rule to install nose. However, now that I think of it, shouldn't we install nose as part of the 'develop' rule?

Also, I'm guessing I should also add a nose tarball to lp:~oem-solutions-releng/offspring/offspring-deps/?

lp:~salgado/offspring/test-runner updated
89. By Guilherme Salgado

Move installation of nose to the develop Makefile rule

90. By Guilherme Salgado

merge trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2011-09-01 14:42:20 +0000
3+++ Makefile 2011-09-20 16:23:23 +0000
4@@ -21,6 +21,7 @@
5 [ -f bin/offspring-build ] || ln -s `pwd`/lib/offspring/build/bin/* bin/
6 mkdir -p logs
7 mkdir -p scripts && ln -s --force `pwd`/lib/offspring/build/scripts/* scripts/
8+ $(PIP_INSTALL) nose
9
10 slave: install-virtualenv requirements/requirements.slave.txt
11 $(PIP_INSTALL) -r requirements/requirements.slave.txt
12@@ -42,4 +43,12 @@
13 rm -fr lib/offspring/web/media/js/isomorphic/
14 find lib -name "*.pyc" -delete
15
16+test: django-tests non-django-tests
17+
18+non-django-tests:
19+ ./.virtualenv/bin/nosetests -e 'queuemanager.*'
20+
21+django-tests:
22+ ./bin/offspring-web test queuemanager --settings=offspring.web.settings_test
23+
24 .PHONY: run develop install-virtualenv
25
26=== added file 'docs/HACKING'
27--- docs/HACKING 1970-01-01 00:00:00 +0000
28+++ docs/HACKING 2011-09-20 16:23:23 +0000
29@@ -0,0 +1,21 @@
30+= Running the test suite =
31+
32+We use nose to run the non-Django tests and the standard Django test runner
33+for the tests in lib/offspring/web/queuemanager.
34+
35+To install nose, run:
36+
37+ $ make install-nose
38+
39+After that you can set the OFFSPRING_CONFIGFILE environment variable and run
40+the tests with
41+
42+ $ make test
43+
44+If you want to run just the Django tests:
45+
46+ $ make django-tests
47+
48+Similarly, if you want to run all tests except for the Django ones:
49+
50+ $ make non-django-tests
51
52=== modified file 'lib/offspring/master/tests.py'
53--- lib/offspring/master/tests.py 2011-09-06 18:04:17 +0000
54+++ lib/offspring/master/tests.py 2011-09-20 16:23:23 +0000
55@@ -2,7 +2,6 @@
56 # GNU Affero General Public License version 3 (see the file LICENSE).
57
58 import email.parser
59-import email.utils
60 import unittest
61
62 from offspring import config
63@@ -120,8 +119,3 @@
64 from_header = mailer.mails[0][0]
65 sender_real_name, sender_addr = email.utils.parseaddr(from_header)
66 self.assertEqual(addr, sender_addr)
67-
68-
69-def test_suite():
70- loader = unittest.TestLoader()
71- return loader.loadTestsFromName(__name__)
72
73=== modified file 'lib/offspring/slave/tests.py'
74--- lib/offspring/slave/tests.py 2010-11-29 08:27:24 +0000
75+++ lib/offspring/slave/tests.py 2011-09-20 16:23:23 +0000
76@@ -19,8 +19,3 @@
77
78 def test_retrieveState(self):
79 self.assertEqual(self.x.getBuilderState(), LexbuilderSlave.STATE_IDLE)
80-
81-
82-def test_suite():
83- loader = unittest.TestLoader()
84- return loader.loadTestsFromName(__name__)
85
86=== added directory 'lib/offspring/tests'

Subscribers

People subscribed via source and target branches