~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_source.py

  • Committer: John Arbash Meinel
  • Date: 2006-10-16 01:47:43 UTC
  • mto: This revision was merged to the branch mainline in revision 2080.
  • Revision ID: john@arbash-meinel.com-20061016014743-17784d83b1949604
Guide people to how to add files to the list of exceptions

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
from bzrlib.tests import TestCase, TestSkipped
34
34
 
35
35
 
 
36
# Technically, lsprof.py should be in bzrlib/util, but
 
37
# historical reasons put it in bzrlib, and make it difficult
 
38
# to move in a compatible manner
 
39
COPYRIGHT_EXCEPTIONS = ['bzrlib/lsprof.py']
 
40
 
 
41
LICENSE_EXCEPTIONS = ['bzrlib/lsprof.py']
 
42
 
 
43
 
36
44
class TestSourceHelper(TestCase):
37
45
 
38
46
    def source_file_name(self, package):
118
126
                f.close()
119
127
            yield fname, text
120
128
 
121
 
    def is_exception(self, fname):
122
 
        """Certain files are allowed to be different"""
123
 
        if '/util/' in fname:
124
 
            # We don't require external utilities to be (C) Canonical Ltd
125
 
            return True
126
 
 
127
 
        exceptions = ['bzrlib/lsprof.py']
128
 
        for exc in exceptions:
 
129
    def is_copyright_exception(self, fname):
 
130
        """Certain files are allowed to be different"""
 
131
        if '/util/' in fname:
 
132
            # We don't require external utilities to be (C) Canonical Ltd
 
133
            return True
 
134
 
 
135
        for exc in COPYRIGHT_EXCEPTIONS:
 
136
            if fname.endswith(exc):
 
137
                return True
 
138
 
 
139
        return False
 
140
 
 
141
    def is_license_exception(self, fname):
 
142
        """Certain files are allowed to be different"""
 
143
        if '/util/' in fname:
 
144
            # We don't require external utilities to be (C) Canonical Ltd
 
145
            return True
 
146
 
 
147
        for exc in LICENSE_EXCEPTIONS:
129
148
            if fname.endswith(exc):
130
149
                return True
131
150
 
145
164
            )
146
165
 
147
166
        for fname, text in self.get_source_file_contents():
148
 
            if self.is_exception(fname):
 
167
            if self.is_copyright_exception(fname):
149
168
                continue
150
169
            match = copyright_canonical_re.search(text)
151
170
            if not match:
163
182
        if incorrect:
164
183
            help_text = ["Some files have missing or incorrect copyright"
165
184
                         " statements.",
166
 
                         "Please add '# Copyright (C) 2006 Canonical Ltd'"
167
 
                         " to these files:",
 
185
                         "",
 
186
                         "Please either add them to the list of"
 
187
                         " COPYRIGHT_EXCEPTIONS in"
 
188
                         " bzrlib/tests/test_source.py",
 
189
                         # this is broken to prevent a false match
 
190
                         "or add '# Copyright (C)"
 
191
                         " 2006 Canonical Ltd' to these files:",
168
192
                         "",
169
193
                        ]
170
194
            for fname, comment in incorrect:
195
219
        gpl_re = re.compile(re.escape(gpl_txt), re.MULTILINE)
196
220
 
197
221
        for fname, text in self.get_source_file_contents():
198
 
            if self.is_exception(fname):
 
222
            if self.is_license_exception(fname):
199
223
                continue
200
224
            if not gpl_re.search(text):
201
225
                incorrect.append(fname)
202
226
 
203
227
        if incorrect:
204
228
            help_text = ['Some files have missing or incomplete GPL statement',
205
 
                         'Please fix the following files to have text:',
 
229
                         "",
 
230
                         "Please either add them to the list of"
 
231
                         " LICENSE_EXCEPTIONS in"
 
232
                         " bzrlib/tests/test_source.py",
 
233
                         "Or add the following text to the beginning:",
206
234
                         gpl_txt
207
235
                        ]
208
236
            for fname in incorrect: