Merge lp:~cjwatson/cupstream2distro/fix-symbols-replacement into lp:cupstream2distro

Proposed by Colin Watson
Status: Merged
Approved by: Robert Bruce Park
Approved revision: 634
Merged at revision: 630
Proposed branch: lp:~cjwatson/cupstream2distro/fix-symbols-replacement
Merge into: lp:cupstream2distro
Diff against target: 43 lines (+21/-1)
2 files modified
cupstream2distro/packagemanager.py (+4/-1)
tests/unit/test_packagemanager.py (+17/-0)
To merge this branch: bzr merge lp:~cjwatson/cupstream2distro/fix-symbols-replacement
Reviewer Review Type Date Requested Status
Robert Bruce Park (community) Approve
John Lenton (community) Approve
Review via email: mp+227434@code.launchpad.net

Commit message

Don't try to substitute 0replaceme in directories or symlinks.

Description of the change

r629 broke building any package containing a directory under debian/, such as debian/source/ (so including but not limited to all 3.0 (quilt) packages). See https://ci-train.ubuntu.com/job/landing-009-1-build/119/console for an example.

Make sure only to attempt substitutions in regular files, not directories or symlinks.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) wrote :

Incidentally, I would have written a unit test for this, but the relevant tests (tests.unit.test_packagemanager.PackageManagerOfflineTests) currently fail in flames. Perhaps somebody could fix things up a bit there ...

631. By Colin Watson

Test the directories-under-debian/ case.

632. By Colin Watson

Make test actually be meaningful.

Revision history for this message
Colin Watson (cjwatson) wrote :

Oh look, turns out I can write a test after all, though the other ones still need fixing.

633. By Colin Watson

Avoid applying replacements to symlinks too.

634. By Colin Watson

Tweak test name.

Revision history for this message
John Lenton (chipaca) wrote :

LGTM, FWIW :-)

review: Approve
Revision history for this message
Robert Bruce Park (robru) wrote :

lgtm, deploying!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cupstream2distro/packagemanager.py'
2--- cupstream2distro/packagemanager.py 2014-07-18 22:11:43 +0000
3+++ cupstream2distro/packagemanager.py 2014-07-20 12:27:50 +0000
4@@ -523,7 +523,10 @@
5 new_upstream_version = packaging_version.split("-")[0]
6 files_replaced = set()
7 for filename in os.listdir("debian"):
8- for line in fileinput.input(os.path.join('debian', filename), inplace=1):
9+ path = os.path.join('debian', filename)
10+ if not os.path.isfile(path) or os.path.islink(path):
11+ continue
12+ for line in fileinput.input(path, inplace=1):
13 if settings.REPLACEME_TAG in line:
14 files_replaced.add(filename)
15 line = line.replace(settings.REPLACEME_TAG, new_upstream_version)
16
17=== modified file 'tests/unit/test_packagemanager.py'
18--- tests/unit/test_packagemanager.py 2014-06-12 16:49:00 +0000
19+++ tests/unit/test_packagemanager.py 2014-07-20 12:27:50 +0000
20@@ -954,6 +954,23 @@
21 subprocess.Popen(['bzr', 'revno'],
22 stdout=subprocess.PIPE).communicate()[0], "8\n")
23
24+ def test_dont_refresh_symbols_files_for_directory(self):
25+ '''We don't fail for directories under debian/'''
26+ self.get_data_branch('dummypackage')
27+ debian_source_path = os.path.join("debian", "source")
28+ self.assertTrue(os.path.isdir(debian_source_path))
29+ packagemanager.refresh_symbol_files('42.0daily83.09.14-0ubuntu1')
30+ self.assertTrue(os.path.isdir(debian_source_path))
31+
32+ def test_dont_refresh_symbols_files_for_symlink(self):
33+ '''We don't touch symlinks under debian/'''
34+ self.get_data_branch('basic_symbols')
35+ symlink_path = os.path.join("debian", "foo.symbols.link")
36+ os.symlink("foo.symbols", symlink_path)
37+ packagemanager.refresh_symbol_files('42.0daily83.09.14-0ubuntu1')
38+ self.assertTrue(os.path.islink(symlink_path))
39+ self.assertEqual("foo.symbols", os.readlink(symlink_path))
40+
41
42 class PackageManagerOnlineTests(BaseUnitTestCase):
43 '''Test that uses online services, but as we just pull from them, we can use them'''

Subscribers

People subscribed via source and target branches

to all changes: