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