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
=== modified file 'Makefile'
--- Makefile 2011-09-01 14:42:20 +0000
+++ Makefile 2011-09-20 16:23:23 +0000
@@ -21,6 +21,7 @@
21 [ -f bin/offspring-build ] || ln -s `pwd`/lib/offspring/build/bin/* bin/21 [ -f bin/offspring-build ] || ln -s `pwd`/lib/offspring/build/bin/* bin/
22 mkdir -p logs22 mkdir -p logs
23 mkdir -p scripts && ln -s --force `pwd`/lib/offspring/build/scripts/* scripts/23 mkdir -p scripts && ln -s --force `pwd`/lib/offspring/build/scripts/* scripts/
24 $(PIP_INSTALL) nose
2425
25slave: install-virtualenv requirements/requirements.slave.txt26slave: install-virtualenv requirements/requirements.slave.txt
26 $(PIP_INSTALL) -r requirements/requirements.slave.txt27 $(PIP_INSTALL) -r requirements/requirements.slave.txt
@@ -42,4 +43,12 @@
42 rm -fr lib/offspring/web/media/js/isomorphic/43 rm -fr lib/offspring/web/media/js/isomorphic/
43 find lib -name "*.pyc" -delete44 find lib -name "*.pyc" -delete
4445
46test: django-tests non-django-tests
47
48non-django-tests:
49 ./.virtualenv/bin/nosetests -e 'queuemanager.*'
50
51django-tests:
52 ./bin/offspring-web test queuemanager --settings=offspring.web.settings_test
53
45.PHONY: run develop install-virtualenv54.PHONY: run develop install-virtualenv
4655
=== added file 'docs/HACKING'
--- docs/HACKING 1970-01-01 00:00:00 +0000
+++ docs/HACKING 2011-09-20 16:23:23 +0000
@@ -0,0 +1,21 @@
1= Running the test suite =
2
3We use nose to run the non-Django tests and the standard Django test runner
4for the tests in lib/offspring/web/queuemanager.
5
6To install nose, run:
7
8 $ make install-nose
9
10After that you can set the OFFSPRING_CONFIGFILE environment variable and run
11the tests with
12
13 $ make test
14
15If you want to run just the Django tests:
16
17 $ make django-tests
18
19Similarly, if you want to run all tests except for the Django ones:
20
21 $ make non-django-tests
022
=== modified file 'lib/offspring/master/tests.py'
--- lib/offspring/master/tests.py 2011-09-06 18:04:17 +0000
+++ lib/offspring/master/tests.py 2011-09-20 16:23:23 +0000
@@ -2,7 +2,6 @@
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4import email.parser4import email.parser
5import email.utils
6import unittest5import unittest
76
8from offspring import config7from offspring import config
@@ -120,8 +119,3 @@
120 from_header = mailer.mails[0][0]119 from_header = mailer.mails[0][0]
121 sender_real_name, sender_addr = email.utils.parseaddr(from_header)120 sender_real_name, sender_addr = email.utils.parseaddr(from_header)
122 self.assertEqual(addr, sender_addr)121 self.assertEqual(addr, sender_addr)
123
124
125def test_suite():
126 loader = unittest.TestLoader()
127 return loader.loadTestsFromName(__name__)
128122
=== modified file 'lib/offspring/slave/tests.py'
--- lib/offspring/slave/tests.py 2010-11-29 08:27:24 +0000
+++ lib/offspring/slave/tests.py 2011-09-20 16:23:23 +0000
@@ -19,8 +19,3 @@
1919
20 def test_retrieveState(self):20 def test_retrieveState(self):
21 self.assertEqual(self.x.getBuilderState(), LexbuilderSlave.STATE_IDLE)21 self.assertEqual(self.x.getBuilderState(), LexbuilderSlave.STATE_IDLE)
22
23
24def test_suite():
25 loader = unittest.TestLoader()
26 return loader.loadTestsFromName(__name__)
2722
=== added directory 'lib/offspring/tests'

Subscribers

People subscribed via source and target branches