1
# Copyright (C) 2011 Canonical Ltd
2
# Copyright (C) 2019 Jelmer Vernooij <jelmer@jelmer.uk>
4
# Breezy is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# Breezy is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with Breezy; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
"""Tests for the quilt code."""
21
from __future__ import absolute_import
25
from ..wrapper import (
33
from ....tests import TestCaseWithTransport
34
from ....tests.features import ExecutableFeature
36
quilt_feature = ExecutableFeature('quilt')
38
TRIVIAL_PATCH = """--- /dev/null 2012-01-02 01:09:10.986490031 +0100
39
+++ base/a 2012-01-02 20:03:59.710666215 +0100
44
class QuiltTests(TestCaseWithTransport):
46
_test_needs_features = [quilt_feature]
48
def make_empty_quilt_dir(self, path):
49
source = self.make_branch_and_tree(path)
51
[os.path.join(path, n) for n in ['patches/']])
52
self.build_tree_contents([
53
(os.path.join(path, "patches/series"), "\n")])
54
source.add(["patches", "patches/series"])
57
def test_series_all_empty(self):
58
source = self.make_empty_quilt_dir("source")
59
self.assertEquals([], quilt_series(source, 'patches/series'))
61
def test_series_all(self):
62
source = self.make_empty_quilt_dir("source")
63
self.build_tree_contents([
64
("source/patches/series", "patch1.diff\n"),
65
("source/patches/patch1.diff", TRIVIAL_PATCH)])
66
source.smart_add(["source"])
68
["patch1.diff"], quilt_series(source, 'patches/series'))
70
def test_push_all_empty(self):
71
self.make_empty_quilt_dir("source")
72
quilt_push_all("source", quiet=True)
74
def test_poph_all_empty(self):
75
self.make_empty_quilt_dir("source")
76
quilt_pop_all("source", quiet=True)
78
def test_applied_empty(self):
79
source = self.make_empty_quilt_dir("source")
80
self.build_tree_contents([
81
("source/patches/series", "patch1.diff\n"),
82
("source/patches/patch1.diff", "foob ar")])
83
self.assertEquals([], quilt_applied(source))
85
def test_unapplied(self):
86
self.make_empty_quilt_dir("source")
87
self.build_tree_contents([
88
("source/patches/series", "patch1.diff\n"),
89
("source/patches/patch1.diff", "foob ar")])
90
self.assertEquals(["patch1.diff"], quilt_unapplied("source"))
92
def test_unapplied_multi(self):
93
self.make_empty_quilt_dir("source")
94
self.build_tree_contents([
95
("source/patches/series", "patch1.diff\npatch2.diff"),
96
("source/patches/patch1.diff", "foob ar"),
97
("source/patches/patch2.diff", "bazb ar")])
98
self.assertEquals(["patch1.diff", "patch2.diff"],
99
quilt_unapplied("source", "patches"))