source: tailor/vcpx/tests/fixed_bugs.py @ 1277

Revision 1277, 4.2 KB checked in by lele@…, 7 years ago (diff)

Rename a few ivars to lower case

Line 
1# -*- mode: python; coding: utf-8 -*-
2# :Progetto: vcpx -- Prevents reintroduced bugs
3# :Creato:   Sun Jul 16 02:50:04 CEST 2006
4# :Autore:   Adeodato Simó <dato@net.com.org.es>
5# :Licenza:  GNU General Public License
6#
7
8from os.path import exists, join
9from unittest import TestCase
10from cStringIO import StringIO
11
12from vcpx.config import Config
13from vcpx.tailor import Tailorizer
14from vcpx.repository.mock import MockChangeset as Changeset, \
15                                 MockChangesetEntry as Entry
16
17
18class FixedBugs(TestCase):
19    """Ensure already fixed bugs don't get reintroduced"""
20
21    TESTDIR = '/tmp/tailor-tests/fixed-bugs'
22
23    ALL_TARGET_VCS = [ 'arx', 'bzr', 'cdv', 'cg', 'cvs', 'cvsps', 'darcs', 'git', 'hg', 'monotone', 'svn' ]
24
25    CONFIG = """\
26[%(test_name)s]
27# verbose = Yes
28source = mock:source
29target = %(vcs)s:target
30root-directory = %(test_dir)s
31state-file = state
32
33[mock:source]
34%(subdir)s.source
35
36[%(vcs)s:target]
37%(subdir)s
38module = /
39repository = file://%(test_dir)s/repo
40"""
41
42    def setUp(self):
43        from os import makedirs
44        from shutil import rmtree
45        from atexit import register
46
47        self.test_name = self.id().split('.')[-1]
48        self.test_dir  = join(self.TESTDIR, self.test_name)
49
50        if exists(self.test_dir):
51            rmtree(self.test_dir)
52        makedirs(self.test_dir)
53        register(rmtree, self.test_dir)
54
55        # defaults
56        self.target_vcs = []
57        self.source_changesets = []
58        self.shared_basedirs = False
59
60    def run_tailor(self, assert_function=None):
61        test_name = self.test_name
62
63        for vcs in self.target_vcs:
64            subdir   = self.shared_basedirs and '#' or 'subdir = %s' % vcs
65            test_dir = join(self.test_dir, vcs)
66            config   = Config(StringIO(self.CONFIG % vars()), {})
67            project  = Tailorizer(test_name, config)
68            project.workingDir().source.changesets = self.source_changesets
69            project()
70
71            if assert_function is not None:
72                assert_function(project, vcs)
73
74    def testTicket64(self):
75        """#64: support add('foo/bar/baz') even if 'foo' was not previously added"""
76        self.target_vcs = [ 'bzr', 'darcs', 'hg' ]
77        self.source_changesets = [
78            Changeset("Dummy first commit",
79                [ Entry(Entry.ADDED, 'dummy.txt'), ]),
80            Changeset("Add a/b/c",
81                [ Entry(Entry.ADDED, 'a/b/'),
82                  Entry(Entry.ADDED, 'a/b/c'),
83            ]),
84        ]
85        self.run_tailor()
86
87    def testTicket64_2(self):
88        """#64 (2): support update('foo2/bar') even if 'foo2' is added in the same changeset"""
89        self.target_vcs = [ 'bzr', 'darcs', 'hg' ] # XXX bzr 0.8 fails :-?
90        self.source_changesets = [
91            Changeset("Dummy first commit",
92                [ Entry(Entry.ADDED, 'dummy.txt'), ]),
93            Changeset("Add a/b/c",
94                [ Entry(Entry.ADDED, 'a/b/c'),
95            ]),
96            Changeset("Add (cp) a2 and modify a2/b/c",
97                [ Entry(Entry.ADDED, 'a2/b/c'),
98                  Entry(Entry.UPDATED, 'a2/b/c', contents='foo')
99            ]),
100        ]
101        self.run_tailor()
102
103    def testTicket74(self):
104        """Files must be physically removed on dir removal, so they don't get readded"""
105        self.target_vcs = [ 'svn' ] # FAIL: bzr for sure, probably others
106        self.source_changesets = [
107            Changeset("Add dir/a{1,2,3}",
108                [ Entry(Entry.ADDED, 'dir/'),
109                  Entry(Entry.ADDED, 'dir/a1'),
110                  Entry(Entry.ADDED, 'dir/a2'),
111                  Entry(Entry.ADDED, 'dir/a3'),
112                ]),
113            Changeset("rm dir",
114                [ Entry(Entry.DELETED, 'dir/'), ]),
115            Changeset("Add dir/z{1,2,3}",
116                [ Entry(Entry.ADDED, 'dir/'),
117                  Entry(Entry.ADDED, 'dir/z1'),
118                  Entry(Entry.ADDED, 'dir/z2'),
119                  Entry(Entry.ADDED, 'dir/z3'),
120                ]),
121        ]
122        def assert_function(project, vcs):
123            repository = project.workingDir().target.repository
124            tree = join(repository.rootdir, repository.subdir)
125            for file in ('a1', 'a2', 'a3'):
126                self.failIf(exists(join(tree, 'dir', file)))
127
128        self.run_tailor(assert_function)
Note: See TracBrowser for help on using the repository browser.