def test_copy(self):
    b = self.make_target('b', JvmTarget, excludes=[Exclude('com.example', 'lib')])
    a = self.make_target('a', JvmTarget, dependencies=[b])

    classpath_product = ClasspathProducts(self.pants_workdir)
    resolved_jar = self.add_jar_classpath_element_for_path(classpath_product,
                                                           a,
                                                           self._example_jar_path())
    classpath_product.add_for_target(a, [('default', self.path('a/path'))])

    copied = classpath_product.copy()

    a_closure = a.closure(bfs=True)

    self.assertEqual([('default', resolved_jar.pants_path), ('default', self.path('a/path'))],
                     classpath_product.get_for_targets(a_closure))
    self.assertEqual([('default', resolved_jar.pants_path), ('default', self.path('a/path'))],
                     copied.get_for_targets(a_closure))

    self.add_excludes_for_targets(copied, b, a)
    self.assertEqual([('default', resolved_jar.pants_path), ('default', self.path('a/path'))],
                     classpath_product.get_for_targets(a_closure))
    self.assertEqual([('default', self.path('a/path'))],
                     copied.get_for_targets(a_closure))

    copied.add_for_target(b, [('default', self.path('b/path'))])
    self.assertEqual([('default', resolved_jar.pants_path), ('default', self.path('a/path'))],
                     classpath_product.get_for_targets(a_closure))
    self.assertEqual([('default', self.path('a/path')), ('default', self.path('b/path'))],
                     copied.get_for_targets(a_closure))
Example #2
0
  def test_copy(self):
    b = self.make_target('b', JvmTarget, excludes=[Exclude('com.example', 'lib')])
    a = self.make_target('a', JvmTarget, dependencies=[b])

    classpath_product = ClasspathProducts(self.pants_workdir)
    resolved_jar = self.add_jar_classpath_element_for_path(classpath_product,
                                                           a,
                                                           self._example_jar_path())
    classpath_product.add_for_target(a, [('default', self.path('a/path'))])

    copied = classpath_product.copy()

    a_closure = a.closure(bfs=True)

    self.assertEqual([('default', resolved_jar.pants_path), ('default', self.path('a/path'))],
                     classpath_product.get_for_targets(a_closure))
    self.assertEqual([('default', resolved_jar.pants_path), ('default', self.path('a/path'))],
                     copied.get_for_targets(a_closure))

    self.add_excludes_for_targets(copied, b, a)
    self.assertEqual([('default', resolved_jar.pants_path), ('default', self.path('a/path'))],
                     classpath_product.get_for_targets(a_closure))
    self.assertEqual([('default', self.path('a/path'))],
                     copied.get_for_targets(a_closure))

    copied.add_for_target(b, [('default', self.path('b/path'))])
    self.assertEqual([('default', resolved_jar.pants_path), ('default', self.path('a/path'))],
                     classpath_product.get_for_targets(a_closure))
    self.assertEqual([('default', self.path('a/path')), ('default', self.path('b/path'))],
                     copied.get_for_targets(a_closure))
Example #3
0
    def test_copy(self):
        b = self.make_target("b",
                             JvmTarget,
                             excludes=[Exclude("com.example", "lib")])
        a = self.make_target("a", JvmTarget, dependencies=[b])

        classpath_product = ClasspathProducts(self.pants_workdir)
        resolved_jar = self.add_jar_classpath_element_for_path(
            classpath_product, a, self._example_jar_path())
        classpath_product.add_for_target(a, [("default", self.path("a/path"))])

        copied = classpath_product.copy()

        a_closure = a.closure(bfs=True)

        self.assertEqual(
            [("default", resolved_jar.pants_path),
             ("default", self.path("a/path"))],
            classpath_product.get_for_targets(a_closure),
        )
        self.assertEqual(
            [("default", resolved_jar.pants_path),
             ("default", self.path("a/path"))],
            copied.get_for_targets(a_closure),
        )

        self.add_excludes_for_targets(copied, b, a)
        self.assertEqual(
            [("default", resolved_jar.pants_path),
             ("default", self.path("a/path"))],
            classpath_product.get_for_targets(a_closure),
        )
        self.assertEqual([("default", self.path("a/path"))],
                         copied.get_for_targets(a_closure))

        copied.add_for_target(b, [("default", self.path("b/path"))])
        self.assertEqual(
            [("default", resolved_jar.pants_path),
             ("default", self.path("a/path"))],
            classpath_product.get_for_targets(a_closure),
        )
        self.assertEqual(
            [("default", self.path("a/path")),
             ("default", self.path("b/path"))],
            copied.get_for_targets(a_closure),
        )