/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/plugins/quilt/tests/test_wrapper.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2019-06-15 13:52:00 UTC
  • mfrom: (7321.2.5 bundle-quilt)
  • Revision ID: breezy.the.bot@gmail.com-20190615135200-dd5zif8ub3xi179t
Add a quilt plugin that can do smart things with quilt patches.

Merged from https://code.launchpad.net/~jelmer/brz/bundle-quilt/+merge/368585

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#    Copyright (C) 2011 Canonical Ltd
 
2
#    Copyright (C) 2019 Jelmer Vernooij <jelmer@jelmer.uk>
 
3
#
 
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.
 
8
#
 
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.
 
13
#
 
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
 
17
#
 
18
 
 
19
"""Tests for the quilt code."""
 
20
 
 
21
from __future__ import absolute_import
 
22
 
 
23
import os
 
24
 
 
25
from ..wrapper import (
 
26
    quilt_pop_all,
 
27
    quilt_applied,
 
28
    quilt_unapplied,
 
29
    quilt_push_all,
 
30
    quilt_series,
 
31
    )
 
32
 
 
33
from ....tests import TestCaseWithTransport
 
34
from ....tests.features import ExecutableFeature
 
35
 
 
36
quilt_feature = ExecutableFeature('quilt')
 
37
 
 
38
TRIVIAL_PATCH = """--- /dev/null        2012-01-02 01:09:10.986490031 +0100
 
39
+++ base/a      2012-01-02 20:03:59.710666215 +0100
 
40
@@ -0,0 +1 @@
 
41
+a
 
42
"""
 
43
 
 
44
class QuiltTests(TestCaseWithTransport):
 
45
 
 
46
    _test_needs_features = [quilt_feature]
 
47
 
 
48
    def make_empty_quilt_dir(self, path):
 
49
        source = self.make_branch_and_tree(path)
 
50
        self.build_tree(
 
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"])
 
55
        return source
 
56
 
 
57
    def test_series_all_empty(self):
 
58
        source = self.make_empty_quilt_dir("source")
 
59
        self.assertEquals([], quilt_series(source, 'patches/series'))
 
60
 
 
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"])
 
67
        self.assertEquals(
 
68
            ["patch1.diff"], quilt_series(source, 'patches/series'))
 
69
 
 
70
    def test_push_all_empty(self):
 
71
        self.make_empty_quilt_dir("source")
 
72
        quilt_push_all("source", quiet=True)
 
73
 
 
74
    def test_poph_all_empty(self):
 
75
        self.make_empty_quilt_dir("source")
 
76
        quilt_pop_all("source", quiet=True)
 
77
 
 
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))
 
84
 
 
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"))
 
91
 
 
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"))