| 1 | # -*- mode: python; coding: utf-8 -*- |
|---|
| 2 | # :Progetto: vcpx -- Operational tests |
|---|
| 3 | # :Creato: lun 08 ago 2005 22:17:10 CEST |
|---|
| 4 | # :Autore: Lele Gaifax <lele@nautilus.homeip.net> |
|---|
| 5 | # :Licenza: GNU General Public License |
|---|
| 6 | # |
|---|
| 7 | |
|---|
| 8 | """\ |
|---|
| 9 | #!tailor |
|---|
| 10 | ''' |
|---|
| 11 | [DEFAULT] |
|---|
| 12 | target-module = None |
|---|
| 13 | source-repository = %(tailor_repo)s |
|---|
| 14 | encoding = None |
|---|
| 15 | target-repository = None |
|---|
| 16 | use-svn-propset = False |
|---|
| 17 | source-module = None |
|---|
| 18 | update = True |
|---|
| 19 | subdir = test |
|---|
| 20 | debug = False |
|---|
| 21 | remove-first-log-line = False |
|---|
| 22 | patch-name-format = None |
|---|
| 23 | verbose = False |
|---|
| 24 | state-file = tailor.state |
|---|
| 25 | start-revision = Version 0.9.17 |
|---|
| 26 | |
|---|
| 27 | [darcs2bzr] |
|---|
| 28 | target = bzr:tailor |
|---|
| 29 | root-directory = /tmp/tailor-tests/darcs2bzr |
|---|
| 30 | source = darcs:tailor |
|---|
| 31 | patch-name-format = %(revision)s |
|---|
| 32 | |
|---|
| 33 | [bzr2darcs] |
|---|
| 34 | source = bzr:tailor |
|---|
| 35 | root-directory = /tmp/tailor-tests/bzr2darcs |
|---|
| 36 | target = darcs:bzrtailor |
|---|
| 37 | patch-name-format = %(revision)s |
|---|
| 38 | start-revision = INITIAL |
|---|
| 39 | |
|---|
| 40 | [darcs:tailor] |
|---|
| 41 | |
|---|
| 42 | [bzr:tailor] |
|---|
| 43 | python-path = /opt/src/bzr.dev |
|---|
| 44 | repository = /tmp/tailor-tests/darcs2bzr |
|---|
| 45 | |
|---|
| 46 | [darcs:bzrtailor] |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | [darcs2cdv] |
|---|
| 50 | target = cdv:tailor |
|---|
| 51 | root-directory = /tmp/tailor-tests/darcs2cdv |
|---|
| 52 | source = darcs:tailor |
|---|
| 53 | |
|---|
| 54 | [cdv:tailor] |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | [darcs2hg] |
|---|
| 58 | target = hg:tailor |
|---|
| 59 | root-directory = /tmp/tailor-tests/darcs2hg |
|---|
| 60 | source = darcs:tailor |
|---|
| 61 | |
|---|
| 62 | [hg:tailor] |
|---|
| 63 | |
|---|
| 64 | |
|---|
| 65 | [darcs2svn] |
|---|
| 66 | target = svn:tailor |
|---|
| 67 | root-directory = /tmp/tailor-tests/darcs2svn |
|---|
| 68 | source = darcs:svntailor |
|---|
| 69 | start-revision = INITIAL |
|---|
| 70 | |
|---|
| 71 | [svn2darcs] |
|---|
| 72 | target = darcs:svntailor |
|---|
| 73 | root-directory = /tmp/tailor-tests/svn2darcs |
|---|
| 74 | source = svn:tailor |
|---|
| 75 | start-revision = 1 |
|---|
| 76 | |
|---|
| 77 | [svn:tailor] |
|---|
| 78 | repository = file:///tmp/tailor-tests/svnrepo |
|---|
| 79 | module = tailor |
|---|
| 80 | subdir = svnside |
|---|
| 81 | use-propset = True |
|---|
| 82 | |
|---|
| 83 | [darcs:svntailor] |
|---|
| 84 | subdir = darcside |
|---|
| 85 | |
|---|
| 86 | |
|---|
| 87 | [darcs2monotone] |
|---|
| 88 | target = monotone:tailor |
|---|
| 89 | root-directory = /tmp/tailor-tests/darcs2monotone |
|---|
| 90 | source = darcs:tailor |
|---|
| 91 | |
|---|
| 92 | [monotone2darcs] |
|---|
| 93 | source = monotone:tailor |
|---|
| 94 | root-directory = /tmp/tailor-tests/monotone2darcs |
|---|
| 95 | target = darcs:mtntailor |
|---|
| 96 | start-revision = INITIAL |
|---|
| 97 | |
|---|
| 98 | [monotone:tailor] |
|---|
| 99 | keyid = tailor |
|---|
| 100 | passphrase = fin che la barca va |
|---|
| 101 | repository = /tmp/tailor-tests/tailor-mtn.db |
|---|
| 102 | module = tailor.test |
|---|
| 103 | subdir = mntside |
|---|
| 104 | |
|---|
| 105 | [darcs:mtntailor] |
|---|
| 106 | subdir = darcside |
|---|
| 107 | |
|---|
| 108 | |
|---|
| 109 | [cvs2darcs] |
|---|
| 110 | target = darcs:pxlib |
|---|
| 111 | root-directory = /tmp/tailor-tests/cvs2darcs |
|---|
| 112 | source = cvs:pxlib |
|---|
| 113 | start-revision = R-0-5-1 |
|---|
| 114 | subdir = pxlib |
|---|
| 115 | |
|---|
| 116 | [darcs:pxlib] |
|---|
| 117 | |
|---|
| 118 | [cvs:pxlib] |
|---|
| 119 | repository = :pserver:anonymous@cvs.sf.net:/cvsroot/pxlib |
|---|
| 120 | module = pxlib |
|---|
| 121 | encoding = iso-8859-1 |
|---|
| 122 | |
|---|
| 123 | |
|---|
| 124 | [cvs2hglib] |
|---|
| 125 | root-directory = /tmp/tailor-tests/cvs2hglib |
|---|
| 126 | source = cvs:cmsmini |
|---|
| 127 | target = hglib:cmsmini |
|---|
| 128 | start-revision = INITIAL |
|---|
| 129 | subdir = cmsmini |
|---|
| 130 | before-commit = remap_authors |
|---|
| 131 | |
|---|
| 132 | [cvs:cmsmini] |
|---|
| 133 | repository = :ext:anoncvs@savannah.nongnu.org:/cvsroot/cmsmini |
|---|
| 134 | module = cmsmini |
|---|
| 135 | |
|---|
| 136 | [hglib:cmsmini] |
|---|
| 137 | |
|---|
| 138 | |
|---|
| 139 | [cvs2bzr] |
|---|
| 140 | root-directory = /tmp/tailor-tests/cvs2bzr |
|---|
| 141 | source = cvs:atse |
|---|
| 142 | target = bzr:atse |
|---|
| 143 | start-revision = spamies-improvement-branch INITIAL |
|---|
| 144 | subdir = atse |
|---|
| 145 | |
|---|
| 146 | [cvs:atse] |
|---|
| 147 | repository = :pserver:anonymous@cvs.sourceforge.net:/cvsroot/collective |
|---|
| 148 | module = ATSchemaEditorNG |
|---|
| 149 | |
|---|
| 150 | [bzr:atse] |
|---|
| 151 | python-path = /opt/src/bzr.dev |
|---|
| 152 | |
|---|
| 153 | |
|---|
| 154 | [svndump2darcs] |
|---|
| 155 | source = svndump:simple |
|---|
| 156 | target = darcs:simple |
|---|
| 157 | root-directory = /tmp/tailor-tests/svndump2darcs |
|---|
| 158 | subdir = simple |
|---|
| 159 | start-revision = INITIAL |
|---|
| 160 | |
|---|
| 161 | [svndump:simple] |
|---|
| 162 | repository = %(tailor_repo)s/vcpx/tests/data/simple.svndump |
|---|
| 163 | subdir = plain |
|---|
| 164 | |
|---|
| 165 | [darcs:simple] |
|---|
| 166 | subdir = . |
|---|
| 167 | |
|---|
| 168 | |
|---|
| 169 | [svndump2hg] |
|---|
| 170 | source = svndump:pyobjc |
|---|
| 171 | target = hg:pyobjc |
|---|
| 172 | root-directory = /tmp/tailor-tests/svndump2hg |
|---|
| 173 | start-revision = INITIAL |
|---|
| 174 | |
|---|
| 175 | [svndump:pyobjc] |
|---|
| 176 | repository = %(tailor_repo)s/pyobjc.svndump |
|---|
| 177 | subdir = plain |
|---|
| 178 | |
|---|
| 179 | [hg:pyobjc] |
|---|
| 180 | subdir = hg |
|---|
| 181 | |
|---|
| 182 | |
|---|
| 183 | [svndump2hg-partial] |
|---|
| 184 | source = svndump:simple-partial |
|---|
| 185 | target = hg:simple-partial |
|---|
| 186 | root-directory = /tmp/tailor-tests/svndump2hg-partial |
|---|
| 187 | start-revision = INITIAL |
|---|
| 188 | |
|---|
| 189 | [svndump:simple-partial] |
|---|
| 190 | repository = %(tailor_repo)s/vcpx/tests/data/simple.svndump |
|---|
| 191 | #repository = /usr/local/tmp/docit.svndump |
|---|
| 192 | module = subdir |
|---|
| 193 | subdir = plain |
|---|
| 194 | |
|---|
| 195 | [hg:simple-partial] |
|---|
| 196 | subdir = hg |
|---|
| 197 | |
|---|
| 198 | |
|---|
| 199 | [cvs2svn] |
|---|
| 200 | source = cvs:cmfeditions-houston-sprint |
|---|
| 201 | target = svn:cmfeditions |
|---|
| 202 | start-revision = houston-sprint-branch INITIAL |
|---|
| 203 | root-directory = /tmp/tailor-tests/cvs2svn |
|---|
| 204 | |
|---|
| 205 | [cvs:cmfeditions-houston-sprint] |
|---|
| 206 | repository = :pserver:anonymous@cvs.sourceforge.net:/cvsroot/collective |
|---|
| 207 | module = CMFEditions |
|---|
| 208 | subdir = cvside |
|---|
| 209 | |
|---|
| 210 | [svn:cmfeditions] |
|---|
| 211 | repository = file:///tmp/tailor-tests/cmfeditions.svnrepo |
|---|
| 212 | module = cmfeditions |
|---|
| 213 | subdir = svnside |
|---|
| 214 | |
|---|
| 215 | |
|---|
| 216 | [svn2hg] |
|---|
| 217 | source = svn:plonebook |
|---|
| 218 | target = hg:plonebook |
|---|
| 219 | start-revision = 1101 |
|---|
| 220 | root-directory = /tmp/tailor-tests/svn2hg |
|---|
| 221 | |
|---|
| 222 | [svn:plonebook] |
|---|
| 223 | repository = http://docit.bice.dyndns.org |
|---|
| 224 | module = /Plone/PloneBook2/it |
|---|
| 225 | |
|---|
| 226 | [hg:plonebook] |
|---|
| 227 | |
|---|
| 228 | [svn2hg_with_externals] |
|---|
| 229 | source = svn:plonebook_we |
|---|
| 230 | target = hg:plonebook |
|---|
| 231 | start-revision = HEAD |
|---|
| 232 | root-directory = /tmp/tailor-tests/svn2hg_we |
|---|
| 233 | |
|---|
| 234 | [svn:plonebook_we] |
|---|
| 235 | repository = http://docit.bice.dyndns.org |
|---|
| 236 | module = /Plone/PloneBook2/it |
|---|
| 237 | ignore-externals = False |
|---|
| 238 | ''' |
|---|
| 239 | |
|---|
| 240 | def remap_authors(context, changeset): |
|---|
| 241 | if changeset.author == 'tizziano': |
|---|
| 242 | changeset.author = 'tiziano' |
|---|
| 243 | return True |
|---|
| 244 | """ |
|---|
| 245 | |
|---|
| 246 | from unittest import TestCase |
|---|
| 247 | from cStringIO import StringIO |
|---|
| 248 | from vcpx.config import Config |
|---|
| 249 | from vcpx.tailor import Tailorizer |
|---|
| 250 | from vcpx.shwrap import ExternalCommand, PIPE |
|---|
| 251 | |
|---|
| 252 | class OperationalTest(TestCase): |
|---|
| 253 | |
|---|
| 254 | def setUp(self): |
|---|
| 255 | from os import mkdir, getcwd |
|---|
| 256 | from os.path import exists, split, join |
|---|
| 257 | from atexit import register |
|---|
| 258 | from shutil import rmtree |
|---|
| 259 | |
|---|
| 260 | tailor_repo = getcwd() |
|---|
| 261 | while tailor_repo and not exists(join(tailor_repo, '_darcs')): |
|---|
| 262 | tailor_repo = split(tailor_repo)[0] |
|---|
| 263 | assert exists(join(tailor_repo, '_darcs')), "Tailor Darcs repository not found!" |
|---|
| 264 | self.tailor_repo = tailor_repo |
|---|
| 265 | self.config = Config(StringIO(__doc__), {'tailor_repo': tailor_repo}) |
|---|
| 266 | if not exists('/tmp/tailor-tests'): |
|---|
| 267 | mkdir('/tmp/tailor-tests') |
|---|
| 268 | register(rmtree, '/tmp/tailor-tests') |
|---|
| 269 | |
|---|
| 270 | def diffWhenPossible(self, tailorizer): |
|---|
| 271 | "Diff the resulting sides" |
|---|
| 272 | |
|---|
| 273 | dwd = tailorizer.workingDir() |
|---|
| 274 | if not dwd.shared_basedirs: |
|---|
| 275 | cmd = ["diff", "-r", "-u"] |
|---|
| 276 | if tailorizer.source.METADIR: |
|---|
| 277 | cmd.extend(["-x", tailorizer.source.METADIR]) |
|---|
| 278 | if tailorizer.target.METADIR: |
|---|
| 279 | cmd.extend(["-x", tailorizer.target.METADIR]) |
|---|
| 280 | d = ExternalCommand(command=cmd) |
|---|
| 281 | out = d.execute(dwd.source.basedir, dwd.target.basedir, |
|---|
| 282 | stdout=PIPE)[0] |
|---|
| 283 | return out.read() |
|---|
| 284 | else: |
|---|
| 285 | return "" |
|---|
| 286 | |
|---|
| 287 | def tailorize(self, project): |
|---|
| 288 | "The actual test" |
|---|
| 289 | |
|---|
| 290 | tailorizer = Tailorizer(project, self.config) |
|---|
| 291 | self.assert_(not tailorizer.exists()) |
|---|
| 292 | tailorizer() |
|---|
| 293 | self.assertEqual(self.diffWhenPossible(tailorizer), "") |
|---|
| 294 | |
|---|
| 295 | class Darcs(OperationalTest): |
|---|
| 296 | "Test darcs backend" |
|---|
| 297 | |
|---|
| 298 | def testConfiguration(self): |
|---|
| 299 | "Test basic configuration" |
|---|
| 300 | |
|---|
| 301 | from os.path import expanduser |
|---|
| 302 | |
|---|
| 303 | p = Tailorizer('darcs2svn', self.config) |
|---|
| 304 | self.assertEqual(p.source.subdir, 'darcside') |
|---|
| 305 | self.assertEqual(p.rootdir, '/tmp/tailor-tests/darcs2svn') |
|---|
| 306 | self.assertEqual(p.source.repository, self.tailor_repo) |
|---|
| 307 | self.assertEqual(p.target.repository, |
|---|
| 308 | 'file:///tmp/tailor-tests/svnrepo') |
|---|
| 309 | self.assertEqual(p.state_file.filename, |
|---|
| 310 | '/tmp/tailor-tests/darcs2svn/tailor.state') |
|---|
| 311 | |
|---|
| 312 | tailorizer = Tailorizer('cvs2darcs', self.config) |
|---|
| 313 | self.assertEqual(tailorizer.subdir, 'pxlib') |
|---|
| 314 | self.assertEqual(tailorizer.source.subdir, 'pxlib') |
|---|
| 315 | |
|---|
| 316 | def testDarcsAndBazaarng(self): |
|---|
| 317 | "Test darcs to bazaar-ng and the other way around" |
|---|
| 318 | |
|---|
| 319 | self.tailorize('darcs2bzr') |
|---|
| 320 | self.tailorize('bzr2darcs') |
|---|
| 321 | |
|---|
| 322 | def testDarcsToMercurial(self): |
|---|
| 323 | "Test darcs to mercurial" |
|---|
| 324 | |
|---|
| 325 | self.tailorize('darcs2hg') |
|---|
| 326 | |
|---|
| 327 | def testDarcsToCodeville(self): |
|---|
| 328 | "Test darcs to codeville" |
|---|
| 329 | |
|---|
| 330 | self.tailorize('darcs2cdv') |
|---|
| 331 | |
|---|
| 332 | def testDarcsAndSubversion(self): |
|---|
| 333 | "Test darcs to subversion and the other way around" |
|---|
| 334 | |
|---|
| 335 | self.tailorize('darcs2svn') |
|---|
| 336 | self.tailorize('svn2darcs') |
|---|
| 337 | |
|---|
| 338 | def testDarcsAndMonotone(self): |
|---|
| 339 | "Test darcs to monotone and the other way around" |
|---|
| 340 | |
|---|
| 341 | self.tailorize('darcs2monotone') |
|---|
| 342 | self.tailorize('monotone2darcs') |
|---|
| 343 | |
|---|
| 344 | |
|---|
| 345 | class Cvs(OperationalTest): |
|---|
| 346 | "Test the CVS source backend" |
|---|
| 347 | |
|---|
| 348 | def testCvsToDarcs(self): |
|---|
| 349 | "Test CVS to darcs" |
|---|
| 350 | |
|---|
| 351 | self.tailorize('cvs2darcs') |
|---|
| 352 | |
|---|
| 353 | def testCvsToMercurial(self): |
|---|
| 354 | "Test CVS to mercurial" |
|---|
| 355 | |
|---|
| 356 | self.tailorize('cvs2hglib') |
|---|
| 357 | |
|---|
| 358 | def testCvsToBazaarng(self): |
|---|
| 359 | "Test CVS to bazaar-ng" |
|---|
| 360 | |
|---|
| 361 | self.tailorize('cvs2bzr') |
|---|
| 362 | |
|---|
| 363 | def testCvsToSubversion(self): |
|---|
| 364 | "Test CVS branch to Subversion" |
|---|
| 365 | |
|---|
| 366 | self.tailorize('cvs2svn') |
|---|
| 367 | |
|---|
| 368 | |
|---|
| 369 | class Svn(OperationalTest): |
|---|
| 370 | "Test the subversion backend" |
|---|
| 371 | |
|---|
| 372 | def testExternals(self): |
|---|
| 373 | "Exercise svn to mercurial with and without svn:externals" |
|---|
| 374 | |
|---|
| 375 | from os.path import exists |
|---|
| 376 | |
|---|
| 377 | external = '/tmp/tailor-tests/svn2hg%s/test/make/docutils.make' |
|---|
| 378 | self.tailorize('svn2hg') |
|---|
| 379 | self.failIf(exists(external % '')) |
|---|
| 380 | |
|---|
| 381 | self.tailorize('svn2hg_with_externals') |
|---|
| 382 | self.failUnless(exists(external % '_we')) |
|---|
| 383 | |
|---|
| 384 | |
|---|
| 385 | class Svndump(OperationalTest): |
|---|
| 386 | "Test the svndump source backend (deprecated)" |
|---|
| 387 | |
|---|
| 388 | def testSvndumpToDarcs(self): |
|---|
| 389 | "Test subversion dump to darcs" |
|---|
| 390 | |
|---|
| 391 | self.tailorize('svndump2darcs') |
|---|
| 392 | |
|---|
| 393 | def testSvndumpToMercurial(self): |
|---|
| 394 | "Test subversion dump to mercurial" |
|---|
| 395 | |
|---|
| 396 | self.tailorize('svndump2hg') |
|---|
| 397 | |
|---|
| 398 | def testPartialSvndumpToMercurial(self): |
|---|
| 399 | "Test partial subversion dump to mercurial" |
|---|
| 400 | |
|---|
| 401 | self.tailorize('svndump2hg-partial') |
|---|