Merge lp:~james-w/pkgme/enable-tests into lp:pkgme

Proposed by James Westby
Status: Merged
Approved by: Jonathan Lange
Approved revision: 95
Merged at revision: 92
Proposed branch: lp:~james-w/pkgme/enable-tests
Merge into: lp:pkgme
Diff against target: 162 lines (+51/-19)
8 files modified
pkgme/backends/dummy/package_name (+3/-0)
pkgme/backends/dummy/version (+3/-0)
pkgme/backends/dummy/want (+7/-0)
pkgme/distutils_command/pkgme_info.py (+4/-4)
pkgme/testing.py (+13/-0)
pkgme/tests/test_distutils_command.py (+7/-4)
pkgme/tests/test_script.py (+10/-10)
tarmac_tests.sh (+4/-1)
To merge this branch: bzr merge lp:~james-w/pkgme/enable-tests
Reviewer Review Type Date Requested Status
Jonathan Lange Approve
Review via email: mp+85032@code.launchpad.net

Commit message

Have tarmac run the tests. Skip the debpython tests if it is missing.

Description of the change

Hi,

This is the change to enable the tests for pkgme in tarmac.

I went with disabling the tests using debpython if it's not
present. This isn't ideal, but I figured that testing
99% of the code in tarmac was better than testing 0%.

Thanks,

James

To post a comment you must log in.
Revision history for this message
Jonathan Lange (jml) wrote :

Looks good to me.

You do have a repeated literal, the path to debpython in your diff is also, sort of, in distutils_command/pkgme_info. Since they both have FIXME comments, it's not such a big deal.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'pkgme/backends/dummy'
2=== added file 'pkgme/backends/dummy/package_name'
3--- pkgme/backends/dummy/package_name 1970-01-01 00:00:00 +0000
4+++ pkgme/backends/dummy/package_name 2011-12-08 21:22:19 +0000
5@@ -0,0 +1,3 @@
6+#!/bin/sh
7+
8+echo "foo"
9
10=== added file 'pkgme/backends/dummy/version'
11--- pkgme/backends/dummy/version 1970-01-01 00:00:00 +0000
12+++ pkgme/backends/dummy/version 2011-12-08 21:22:19 +0000
13@@ -0,0 +1,3 @@
14+#!/bin/sh
15+
16+echo "0.0.0"
17
18=== added file 'pkgme/backends/dummy/want'
19--- pkgme/backends/dummy/want 1970-01-01 00:00:00 +0000
20+++ pkgme/backends/dummy/want 2011-12-08 21:22:19 +0000
21@@ -0,0 +1,7 @@
22+#!/bin/sh
23+
24+if [ -e is_pkgme_test ]; then
25+ echo 100
26+else
27+ echo 0
28+fi
29
30=== modified file 'pkgme/distutils_command/pkgme_info.py'
31--- pkgme/distutils_command/pkgme_info.py 2011-07-11 15:58:53 +0000
32+++ pkgme/distutils_command/pkgme_info.py 2011-12-08 21:22:19 +0000
33@@ -3,10 +3,6 @@
34 import sys
35 import textwrap
36
37-# FIXME: should avoid depending on this Debian-specific module
38-sys.path.insert(1, "/usr/share/python")
39-from debpython import pydist
40-
41
42 class pkgme_info(Command):
43 """distutils command that yields packaging information.
44@@ -88,6 +84,10 @@
45 def get_build_depends(self):
46 basics = "python-all, python-setuptools"
47 if getattr(self.distribution, "install_requires", None) is not None:
48+ # FIXME: should avoid depending on this Debian-specific module
49+ sys.path.insert(1, "/usr/share/python")
50+ from debpython import pydist
51+
52 for pkg in self.distribution.install_requires:
53 dep = pydist.guess_dependency(pkg)
54 if dep:
55
56=== modified file 'pkgme/testing.py'
57--- pkgme/testing.py 2011-10-31 16:12:58 +0000
58+++ pkgme/testing.py 2011-12-08 21:22:19 +0000
59@@ -314,6 +314,19 @@
60 self.skipTest("'%s' not executable: %s" % (command_name, find_error))
61
62
63+class PathRequiredTestCase(object):
64+
65+ def skipTestIfPathNotPresent(self, path):
66+ """Skip the test if a particular path doesn't exist.
67+
68+ :param path: the path that must exist
69+ :return: None
70+ :raises: TestSkipped if path isn't present
71+ """
72+ if not os.path.exists(path):
73+ self.skipTest("'%s' not present" % (path, ))
74+
75+
76 class StaticLoaderFixture(Fixture):
77 """Change the default loader to one that only loads the given backends."""
78
79
80=== modified file 'pkgme/tests/test_distutils_command.py'
81--- pkgme/tests/test_distutils_command.py 2011-07-15 09:22:47 +0000
82+++ pkgme/tests/test_distutils_command.py 2011-12-08 21:22:19 +0000
83@@ -5,10 +5,10 @@
84 from testtools import TestCase
85
86 from pkgme.distutils_command.pkgme_info import pkgme_info
87-from pkgme.testing import TempdirFixture
88-
89-
90-class pkgme_info_tests(TestCase, TestWithFixtures):
91+from pkgme.testing import PathRequiredTestCase, TempdirFixture
92+
93+
94+class pkgme_info_tests(TestCase, TestWithFixtures, PathRequiredTestCase):
95
96 def test_interprets_pkgmeinfo(self):
97 dist = Distribution()
98@@ -124,6 +124,9 @@
99 self.assertIn("python-setuptools", cmd.get_build_depends())
100
101 def test_build_depends_examines_install_requires(self):
102+ # FIXME: we shouldn't really be skipping here, it's a symptom
103+ # of the fact that there are undocumented dependencies.
104+ self.skipTestIfPathNotPresent("/usr/share/python/debpython")
105 cmd = self.get_cmd_with_metadata({})
106 cmd.distribution.install_requires = ["foo"]
107 self.assertIn("python-foo", cmd.get_build_depends())
108
109=== modified file 'pkgme/tests/test_script.py'
110--- pkgme/tests/test_script.py 2011-07-29 17:18:19 +0000
111+++ pkgme/tests/test_script.py 2011-12-08 21:22:19 +0000
112@@ -1,3 +1,4 @@
113+import os
114 import pkg_resources
115 from StringIO import StringIO
116
117@@ -22,23 +23,22 @@
118 ep(argv=[], target_dir=cwd, interactive=False)
119 self.assertEqual('', stderr.getvalue())
120
121+ def create_marker_file(self, tempdir, prefix=None):
122+ """Create the file that triggers the dummy backend for testing."""
123+ path = "is_pkgme_test"
124+ if prefix is not None:
125+ path = os.path.join(prefix, path)
126+ tempdir.create_file(path, "")
127+
128 def test_writes_files(self):
129 tempdir = self.useFixture(TempdirFixture())
130- tempdir.create_file(
131- "setup.py", """from distutils.core import setup
132-
133-setup(name="foo")
134-""")
135+ self.create_marker_file(tempdir)
136 self.run_script(tempdir.path)
137 self.assertThat(tempdir.abspath("debian"), DirExists())
138
139 def test_builds_source_package(self):
140 tempdir = self.useFixture(TempdirFixture())
141- tempdir.create_file(
142- "foo/setup.py", """from distutils.core import setup
143-
144-setup(name="foo")
145-""")
146+ self.create_marker_file(tempdir, prefix="foo")
147 self.run_script(tempdir.abspath('foo'))
148 self.assertThat(tempdir.path, DirContains(
149 ["foo_0.0.0.tar.gz",
150
151=== modified file 'tarmac_tests.sh'
152--- tarmac_tests.sh 2011-12-07 20:02:49 +0000
153+++ tarmac_tests.sh 2011-12-08 21:22:19 +0000
154@@ -2,4 +2,7 @@
155
156 set -e
157
158-echo "No tests on merge yet."
159+virtualenv --no-site-packages virtualenv > log
160+. virtualenv/bin/activate >> log
161+python setup.py develop >> log
162+python -m testtools.run pkgme.tests.test_suite

Subscribers

People subscribed via source and target branches

to all changes: