Esempio n. 1
0
  def test_type_test_jar(self):
    with temporary_dir() as tmpdir:
      with open(os.path.join(tmpdir, 'pom.xml') , 'w') as pomfile:
        pomfile.write(dedent('''<?xml version="1.0" encoding="UTF-8"?>
        <project xmlns="http://maven.apache.org/POM/4.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
             http://maven.apache.org/xsd/maven-4.0.0.xsd">

          <groupId>com.example</groupId>
          <artifactId>base</artifactId>
          <description>A generic Square module.</description>
          <version>HEAD-SNAPSHOT</version>
          <dependencies>
            <dependency>
              <groupId>com.example</groupId>
              <artifactId>dep1</artifactId>
              <type>foo</type>
              <version>1.0</version>
            </dependency>
            <dependency>
              <groupId>com.example</groupId>
              <artifactId>dep2</artifactId>
              <type>test-jar</type>
              <version>1.2.3</version>
            </dependency>
          </dependencies>
        </project>
      '''))

      # TODO(Eric Ayers): Right now, our builds expect a file in <rootdir>/parents/base/pom.xml
      os.makedirs(os.path.join(tmpdir, 'parents', 'base'))
      with open(os.path.join(tmpdir, 'parents', 'base', 'pom.xml'), 'w') as dep_mgmt_pom:
        dep_mgmt_pom.write(DEPENDENCY_MANAGEMENT_POM)

      df = squarepants.pom_handlers.DependencyInfo('pom.xml', rootdir=tmpdir)
      self.assertEquals({u'groupId' : 'com.example',
                         u'artifactId' : 'dep1',
                         u'type' : 'foo',
                         u'exclusions' : [],
                         u'version' : '1.0'
                         }, df.dependencies[0])
      self.assertEquals({u'groupId' : 'com.example',
                         u'artifactId' : 'dep2',
                         u'type' : 'test-jar',
                         u'exclusions' : [],
                         u'version' : '1.2.3'
                         }, df.dependencies[1])
      self.assertEquals(2, len(df.dependencies))

      deps_from_pom = squarepants.pom_handlers.DepsFromPom(PomUtils.pom_provides_target(),
                                                           rootdir=tmpdir)
      refs = deps_from_pom.build_pants_refs(df.dependencies)
      self.assertEquals("sjar(org='com.example', name='dep1', rev='1.0', ext='foo',)", refs[0])
      # type test-jar gets transformed into a 'tests' classifier
      self.assertEquals("sjar(org='com.example', name='dep2', rev='1.2.3', classifier='tests',)", refs[1])
      self.assertEquals(2, len(refs))
Esempio n. 2
0
 def test_is_third_party_dep(self):
   self.assertFalse(PomUtils.is_third_party_dep('bogus-dep'))
Esempio n. 3
0
 def test_parse_common_args(self):
   unprocessed = PomUtils.parse_common_args(['-ldebug', 'unused'])
   self.assertEquals(['unused'], unprocessed)
   self.assertTrue(logging.DEBUG, logging.getLogger().getEffectiveLevel())
Esempio n. 4
0
 def test_get_modules(self):
   top_modules = PomUtils.top_pom_content_handler()
   self.assertIsNotNone(top_modules)
Esempio n. 5
0
 def test_top_pom_content_handler(self):
   tpch = PomUtils.top_pom_content_handler()
   self.assertIsNotNone(tpch)
   self.assertIs(tpch, PomUtils.top_pom_content_handler())
Esempio n. 6
0
 def test_local_dep_targets(self):
   ldt = PomUtils.local_dep_targets()
   self.assertIsNotNone(ldt)
   self.assertIs(ldt,  PomUtils.local_dep_targets()) # should be a singleton
Esempio n. 7
0
 def test_dependency_management_Finder(self):
   dmf = PomUtils.dependency_management_finder()
   self.assertIsNotNone(dmf)
   self.assertIs(dmf, PomUtils.dependency_management_finder()) # should be a singleton
Esempio n. 8
0
 def test_pom_provides_target(self):
     ppt = PomUtils.pom_provides_target()
     self.assertIsNotNone(ppt)
     self.assertIs(ppt,
                   PomUtils.pom_provides_target())  # should be a singleton
Esempio n. 9
0
 def test_common_usage(self):
     # nothing really to test here, it just prints a message to sdout.
     PomUtils.common_usage()
Esempio n. 10
0
 def test_get_modules(self):
     top_modules = PomUtils.top_pom_content_handler()
     self.assertIsNotNone(top_modules)
Esempio n. 11
0
 def test_external_protos_content_handler(self):
     epch = PomUtils.external_protos_content_handler()
     self.assertIsNotNone(epch)
     self.assertIs(epch, PomUtils.external_protos_content_handler())
Esempio n. 12
0
 def test_top_pom_content_handler(self):
     tpch = PomUtils.top_pom_content_handler()
     self.assertIsNotNone(tpch)
     self.assertIs(tpch, PomUtils.top_pom_content_handler())
Esempio n. 13
0
 def test_third_party_dep_targets(self):
     tpdt = PomUtils.third_party_dep_targets()
     self.assertIsNotNone(tpdt)
     self.assertIs(tpdt, PomUtils.third_party_dep_targets())
Esempio n. 14
0
 def test_local_dep_targets(self):
     ldt = PomUtils.local_dep_targets()
     self.assertIsNotNone(ldt)
     self.assertIs(ldt,
                   PomUtils.local_dep_targets())  # should be a singleton
Esempio n. 15
0
def reset_caches():
    """Reset the internal caches in some of the libraries used for BUILD file generation."""
    PomUtils.reset_caches()
    squarepants.pom_handlers.reset_caches()
 def setUp(self):
     self.maxDiff = None
     self._wd = os.getcwd()
     PomUtils.reset_caches()
Esempio n. 17
0
 def test_parse_common_args(self):
     unprocessed = PomUtils.parse_common_args(['-ldebug', 'unused'])
     self.assertEquals(['unused'], unprocessed)
     self.assertTrue(logging.DEBUG, logging.getLogger().getEffectiveLevel())
Esempio n. 18
0
    def test_type_test_jar(self):
        with temporary_dir() as tmpdir:
            with open(os.path.join(tmpdir, 'pom.xml'), 'w') as pomfile:
                pomfile.write(
                    dedent('''<?xml version="1.0" encoding="UTF-8"?>
        <project xmlns="http://maven.apache.org/POM/4.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
             http://maven.apache.org/xsd/maven-4.0.0.xsd">

          <groupId>com.example</groupId>
          <artifactId>base</artifactId>
          <description>A generic Square module.</description>
          <version>HEAD-SNAPSHOT</version>
          <dependencies>
            <dependency>
              <groupId>com.example</groupId>
              <artifactId>dep1</artifactId>
              <type>foo</type>
              <version>1.0</version>
            </dependency>
            <dependency>
              <groupId>com.example</groupId>
              <artifactId>dep2</artifactId>
              <type>test-jar</type>
              <version>1.2.3</version>
            </dependency>
          </dependencies>
        </project>
      '''))

            # TODO(Eric Ayers): Right now, our builds expect a file in <rootdir>/parents/base/pom.xml
            os.makedirs(os.path.join(tmpdir, 'parents', 'base'))
            with open(os.path.join(tmpdir, 'parents', 'base', 'pom.xml'),
                      'w') as dep_mgmt_pom:
                dep_mgmt_pom.write(DEPENDENCY_MANAGEMENT_POM)

            df = squarepants.pom_handlers.DependencyInfo('pom.xml',
                                                         rootdir=tmpdir)
            self.assertEquals(
                {
                    u'groupId': 'com.example',
                    u'artifactId': 'dep1',
                    u'type': 'foo',
                    u'exclusions': [],
                    u'version': '1.0'
                }, df.dependencies[0])
            self.assertEquals(
                {
                    u'groupId': 'com.example',
                    u'artifactId': 'dep2',
                    u'type': 'test-jar',
                    u'exclusions': [],
                    u'version': '1.2.3'
                }, df.dependencies[1])
            self.assertEquals(2, len(df.dependencies))

            deps_from_pom = squarepants.pom_handlers.DepsFromPom(
                PomUtils.pom_provides_target(), rootdir=tmpdir)
            refs = deps_from_pom.build_pants_refs(df.dependencies)
            self.assertEquals(
                "sjar(org='com.example', name='dep1', rev='1.0', ext='foo',)",
                refs[0])
            # type test-jar gets transformed into a 'tests' classifier
            self.assertEquals(
                "sjar(org='com.example', name='dep2', rev='1.2.3', classifier='tests',)",
                refs[1])
            self.assertEquals(2, len(refs))
Esempio n. 19
0
 def test_is_local_dep(self):
     self.assertFalse(PomUtils.is_local_dep('bogus-dep'))
Esempio n. 20
0
 def test_pom_provides_target(self):
   ppt = PomUtils.pom_provides_target()
   self.assertIsNotNone(ppt)
   self.assertIs(ppt, PomUtils.pom_provides_target()) # should be a singleton
Esempio n. 21
0
 def test_is_third_party_dep(self):
     self.assertFalse(PomUtils.is_third_party_dep('bogus-dep'))
Esempio n. 22
0
 def test_third_party_dep_targets(self):
   tpdt = PomUtils.third_party_dep_targets()
   self.assertIsNotNone(tpdt)
   self.assertIs(tpdt, PomUtils.third_party_dep_targets())
Esempio n. 23
0
 def test_is_external_dep(self):
     self.assertTrue(PomUtils.is_external_dep('bogus-dep'))
Esempio n. 24
0
 def test_external_protos_content_handler(self):
   epch = PomUtils.external_protos_content_handler()
   self.assertIsNotNone(epch)
   self.assertIs(epch, PomUtils.external_protos_content_handler())
Esempio n. 25
0
 def setUp(self):
     self._orig_wd = os.getcwd()
     os.chdir(self.REPO_ROOT)
     PomUtils.reset_caches()
Esempio n. 26
0
 def test_common_usage(self):
   # nothing really to test here, it just prints a message to sdout.
   PomUtils.common_usage()
 def setUp(self):
   self._orig_wd = os.getcwd()
   os.chdir(self.REPO_ROOT)
   PomUtils.reset_caches()
Esempio n. 28
0
 def test_is_local_dep(self):
   self.assertFalse(PomUtils.is_local_dep('bogus-dep'))
Esempio n. 29
0
def reset_caches():
  """Reset the internal caches in some of the libraries used for BUILD file generation."""
  PomUtils.reset_caches()
  squarepants.pom_handlers.reset_caches()
Esempio n. 30
0
 def test_is_external_dep(self):
   self.assertTrue(PomUtils.is_external_dep('bogus-dep'))
Esempio n. 31
0
 def setUp(self):
   PomUtils.reset_caches()
   logging.basicConfig()
Esempio n. 32
0
 def setUp(self):
   self.maxDiff = None
   self._wd = os.getcwd()
   PomUtils.reset_caches()
Esempio n. 33
0
 def setUp(self):
     PomUtils.reset_caches()
     logging.basicConfig()
Esempio n. 34
0
 def setUp(self):
   PomUtils.reset_caches()
Esempio n. 35
0
 def test_dependency_management_Finder(self):
     dmf = PomUtils.dependency_management_finder()
     self.assertIsNotNone(dmf)
     self.assertIs(
         dmf,
         PomUtils.dependency_management_finder())  # should be a singleton