示例#1
0
 def _resolve_conflict(self, existing, proposed):
     if proposed == existing:
         return existing
     elif existing.force and proposed.force:
         raise TaskError(
             'Cannot force %s#%s to both rev %s and %s' %
             (proposed.org, proposed.name, existing.rev, proposed.rev))
     elif existing.force:
         self.context.log.debug(
             'Ignoring rev %s for %s#%s already forced to %s' %
             (proposed.rev, proposed.org, proposed.name, existing.rev))
         return existing
     elif proposed.force:
         self.context.log.debug(
             'Forcing %s#%s from %s to %s' %
             (proposed.org, proposed.name, existing.rev, proposed.rev))
         return proposed
     else:
         try:
             if Revision.lenient(proposed.rev) > Revision.lenient(
                     existing.rev):
                 self.context.log.debug(
                     'Upgrading %s#%s from rev %s  to %s' % (
                         proposed.org,
                         proposed.name,
                         existing.rev,
                         proposed.rev,
                     ))
                 return proposed
             else:
                 return existing
         except Revision.BadRevision as e:
             raise TaskError('Failed to parse jar revision', e)
示例#2
0
 def _resolve_conflict(self, existing, proposed):
   if proposed == existing:
     return existing
   elif existing.force and proposed.force:
     raise TaskError('Cannot force %s#%s to both rev %s and %s' % (
       proposed.org, proposed.name, existing.rev, proposed.rev
     ))
   elif existing.force:
     self.context.log.debug('Ignoring rev %s for %s#%s already forced to %s' % (
       proposed.rev, proposed.org, proposed.name, existing.rev
     ))
     return existing
   elif proposed.force:
     self.context.log.debug('Forcing %s#%s from %s to %s' % (
       proposed.org, proposed.name, existing.rev, proposed.rev
     ))
     return proposed
   else:
     try:
       if Revision.lenient(proposed.rev) > Revision.lenient(existing.rev):
         self.context.log.debug('Upgrading %s#%s from rev %s  to %s' % (
           proposed.org, proposed.name, existing.rev, proposed.rev,
         ))
         return proposed
       else:
         return existing
     except Revision.BadRevision as e:
       raise TaskError('Failed to parse jar revision', e)
示例#3
0
  def test_pre_release(self):
    self.assertEqual(Revision.semver('1.2.3-pre1.release.1'),
                     Revision.semver('1.2.3-pre1.release.1'))
    self.assertComponents(Revision.semver('1.2.3-pre1.release.1'),
                          1, 2, 3, 'pre1', 'release', 1, None)

    self.assertTrue(
      Revision.semver('1.2.3-pre1.release.1') < Revision.semver('1.2.3-pre2.release.1'))
    self.assertTrue(
      Revision.semver('1.2.3-pre1.release.2') < Revision.semver('1.2.3-pre1.release.10'))

    self.assertTrue(Revision.semver('1.2.3') < Revision.semver('1.2.3-pre2.release.1'))
示例#4
0
 def _parse_java_version(version):
     # Java version strings have been well defined since release 1.3.1 as defined here:
     #  http://www.oracle.com/technetwork/java/javase/versioning-naming-139433.html
     # These version strings comply with semver except that the traditional pre-release semver
     # slot (the 4th) can be delimited by an _ in the case of update releases of the jdk.
     # We accomodate that difference here.
     return Revision.semver(version.replace('_', '-'))
示例#5
0
 def _parse_java_version(version):
   # Java version strings have been well defined since release 1.3.1 as defined here:
   #  http://www.oracle.com/technetwork/java/javase/versioning-naming-139433.html
   # These version strings comply with semver except that the traditional pre-release semver
   # slot (the 4th) can be delimited by an _ in the case of update releases of the jdk.
   # We accomodate that difference here.
   return Revision.semver(version.replace('_', '-'))
示例#6
0
  def test_validate_version(self):
    with pytest.raises(Distribution.Error):
      with self.distribution(executables=self.exe('java', '1.7.0_25')) as jdk:
        Distribution(bin_path=jdk, minimum_version='1.7.0_45').validate()

    with self.distribution(executables=self.exe('java', '1.7.0_25')) as jdk:
      Distribution(bin_path=jdk, minimum_version='1.7.0_25').validate()
      Distribution(bin_path=jdk, minimum_version=Revision.semver('1.6.0')).validate()
示例#7
0
    def test_pre_release(self):
        self.assertEqual(Revision.semver('1.2.3-pre1.release.1'),
                         Revision.semver('1.2.3-pre1.release.1'))
        self.assertComponents(Revision.semver('1.2.3-pre1.release.1'), 1, 2, 3,
                              'pre1', 'release', 1, None)

        self.assertTrue(
            Revision.semver('1.2.3-pre1.release.1') < Revision.semver(
                '1.2.3-pre2.release.1'))
        self.assertTrue(
            Revision.semver('1.2.3-pre1.release.2') < Revision.semver(
                '1.2.3-pre1.release.10'))

        self.assertTrue(
            Revision.semver('1.2.3') < Revision.semver('1.2.3-pre2.release.1'))
示例#8
0
  def test(self):
    self.assertComponents(Revision.lenient('1.2.3'), 1, 2, 3)
    self.assertComponents(Revision.lenient('1.2.3-SNAPSHOT-eabc'), 1, 2, 3, 'SNAPSHOT', 'eabc')
    self.assertComponents(Revision.lenient('1.2.3-SNAPSHOT4'), 1, 2, 3, 'SNAPSHOT', 4)

    self.assertTrue(Revision.lenient('a') < Revision.lenient('b'))
    self.assertTrue(Revision.lenient('1') < Revision.lenient('2'))
    self.assertTrue(Revision.lenient('1') < Revision.lenient('a'))

    self.assertEqual(Revision.lenient('1.2.3'), Revision.lenient('1.2.3'))
    self.assertTrue(Revision.lenient('1.2.3') < Revision.lenient('1.2.3-SNAPSHOT'))
    self.assertTrue(Revision.lenient('1.2.3-SNAPSHOT') < Revision.lenient('1.2.3-SNAPSHOT-abc'))
    self.assertTrue(Revision.lenient('1.2.3-SNAPSHOT-abc') < Revision.lenient('1.2.3-SNAPSHOT-bcd'))
    self.assertTrue(
      Revision.lenient('1.2.3-SNAPSHOT-abc6') < Revision.lenient('1.2.3-SNAPSHOT-abc10'))
示例#9
0
  def test_pre_release_build(self):
    self.assertEqual(Revision.semver('1.2.3-pre1.release.1+1'),
                     Revision.semver('1.2.3-pre1.release.1+1'))
    self.assertComponents(Revision.semver('1.2.3-pre1.release.1+1'),
                          1, 2, 3, 'pre1', 'release', 1, 1)

    self.assertTrue(
      Revision.semver('1.2.3-pre1.release.1') < Revision.semver('1.2.3-pre2.release.1+1'))
    self.assertTrue(
      Revision.semver('1.2.3-pre1.release.2') > Revision.semver('1.2.3-pre1.release.1+1'))

    self.assertTrue(Revision.semver('1.2.3') < Revision.semver('1.2.3-pre2.release.2+1.foo'))
    self.assertTrue(
      Revision.semver('1.2.3-pre1.release.2+1') < Revision.semver('1.2.3-pre1.release.2+1.foo'))
    self.assertTrue(
      Revision.semver('1.2.3-pre1.release.2+1') < Revision.semver('1.2.3-pre1.release.2+2'))
示例#10
0
  def test_simple(self):
    self.assertEqual(Revision.semver('1.2.3'), Revision.semver('1.2.3'))
    self.assertComponents(Revision.semver('1.2.3'), 1, 2, 3, None, None)

    self.assertTrue(Revision.semver('1.2.3') > Revision.semver('1.2.2'))
    self.assertTrue(Revision.semver('1.3.0') > Revision.semver('1.2.2'))
    self.assertTrue(Revision.semver('1.3.10') > Revision.semver('1.3.2'))
    self.assertTrue(Revision.semver('2.0.0') > Revision.semver('1.3.2'))
示例#11
0
 def test_bad(self):
   for bad_rev in ('a.b.c', '1.b.c', '1.2.c', '1.2.3;4', '1.2.3;4+5'):
     with pytest.raises(Revision.BadRevision):
       Revision.semver(bad_rev)
示例#12
0
    def test_pre_release_build(self):
        self.assertEqual(Revision.semver('1.2.3-pre1.release.1+1'),
                         Revision.semver('1.2.3-pre1.release.1+1'))
        self.assertComponents(Revision.semver('1.2.3-pre1.release.1+1'), 1, 2,
                              3, 'pre1', 'release', 1, 1)

        self.assertTrue(
            Revision.semver('1.2.3-pre1.release.1') < Revision.semver(
                '1.2.3-pre2.release.1+1'))
        self.assertTrue(
            Revision.semver('1.2.3-pre1.release.2') > Revision.semver(
                '1.2.3-pre1.release.1+1'))

        self.assertTrue(
            Revision.semver('1.2.3') < Revision.semver(
                '1.2.3-pre2.release.2+1.foo'))
        self.assertTrue(
            Revision.semver('1.2.3-pre1.release.2+1') < Revision.semver(
                '1.2.3-pre1.release.2+1.foo'))
        self.assertTrue(
            Revision.semver('1.2.3-pre1.release.2+1') < Revision.semver(
                '1.2.3-pre1.release.2+2'))
示例#13
0
    def test_simple(self):
        self.assertEqual(Revision.semver('1.2.3'), Revision.semver('1.2.3'))
        self.assertComponents(Revision.semver('1.2.3'), 1, 2, 3, None, None)

        self.assertTrue(Revision.semver('1.2.3') > Revision.semver('1.2.2'))
        self.assertTrue(Revision.semver('1.3.0') > Revision.semver('1.2.2'))
        self.assertTrue(Revision.semver('1.3.10') > Revision.semver('1.3.2'))
        self.assertTrue(Revision.semver('2.0.0') > Revision.semver('1.3.2'))
示例#14
0
 def test_bad(self):
     for bad_rev in ('a.b.c', '1.b.c', '1.2.c', '1.2.3;4', '1.2.3;4+5'):
         with pytest.raises(Revision.BadRevision):
             Revision.semver(bad_rev)
示例#15
0
    def test(self):
        self.assertComponents(Revision.lenient('1.2.3'), 1, 2, 3)
        self.assertComponents(Revision.lenient('1.2.3-SNAPSHOT-eabc'), 1, 2, 3,
                              'SNAPSHOT', 'eabc')
        self.assertComponents(Revision.lenient('1.2.3-SNAPSHOT4'), 1, 2, 3,
                              'SNAPSHOT', 4)

        self.assertTrue(Revision.lenient('a') < Revision.lenient('b'))
        self.assertTrue(Revision.lenient('1') < Revision.lenient('2'))
        self.assertTrue(Revision.lenient('1') < Revision.lenient('a'))

        self.assertEqual(Revision.lenient('1.2.3'), Revision.lenient('1.2.3'))
        self.assertTrue(
            Revision.lenient('1.2.3') < Revision.lenient('1.2.3-SNAPSHOT'))
        self.assertTrue(
            Revision.lenient('1.2.3-SNAPSHOT') < Revision.lenient(
                '1.2.3-SNAPSHOT-abc'))
        self.assertTrue(
            Revision.lenient('1.2.3-SNAPSHOT-abc') < Revision.lenient(
                '1.2.3-SNAPSHOT-bcd'))
        self.assertTrue(
            Revision.lenient('1.2.3-SNAPSHOT-abc6') < Revision.lenient(
                '1.2.3-SNAPSHOT-abc10'))