def test_target_with_multiple_path_entries(self): """ :API: public """ options = attrdict(coverage=True, coverage_jvm_options=[]) syscalls = MockSystemCalls() settings = self.get_settings(options, self.pants_workdir, fake_log(), syscalls) classpath_products = ClasspathProducts(self.pants_workdir) self._add_for_target(classpath_products, self.java_target, '/java/target/first.jar') self._add_for_target(classpath_products, self.java_target, '/java/target/second.jar') self._add_for_target(classpath_products, self.java_target, '/java/target/third.jar') Cobertura.initialize_instrument_classpath(settings, [self.java_target], classpath_products) self.assertEquals( len(syscalls.copy2_calls), 3, 'Should be 3 call for the single java_library target.') self._assert_target_copy(syscalls, '/java/target/first.jar', '/coverage/classes/foo.foo-java/0') self._assert_target_copy(syscalls, '/java/target/second.jar', '/coverage/classes/foo.foo-java/1') self._assert_target_copy(syscalls, '/java/target/third.jar', '/coverage/classes/foo.foo-java/2') self.assertEquals( len(syscalls.copytree_calls), 0, 'Should be no copytree calls when targets are not coverage targets.' )
def test_skips_non_coverage_targets(self): """ :API: public """ options = attrdict(coverage=True, coverage_jvm_options=[]) syscalls = MockSystemCalls() settings = self.get_settings(options, self.pants_workdir, fake_log(), syscalls) classpath_products = ClasspathProducts(self.pants_workdir) self._add_for_target(classpath_products, self.jar_lib, '/jar/lib/classpath') self._add_for_target(classpath_products, self.binary_target, '/binary/target/classpath') self._add_for_target(classpath_products, self.app_target, '/app/target/classpath') self._add_for_target(classpath_products, self.java_target, '/java/target/classpath.jar') Cobertura.initialize_instrument_classpath(settings, [ self.jar_lib, self.binary_target, self.app_target, self.java_target ], classpath_products) self.assertEquals( len(syscalls.copy2_calls), 1, 'Should only be 1 call for the single java_library target.') self._assert_target_copy(syscalls, '/java/target/classpath.jar', '/coverage/classes/foo.foo-java/0') self.assertEquals( len(syscalls.copytree_calls), 0, 'Should be no copytree calls when targets are not coverage targets.' )
def test_target_with_multiple_path_entries(self): options = attrdict(coverage=True, coverage_jvm_options=[]) syscalls = MockSystemCalls() settings = self.get_settings(options, syscalls) classpath_products = ClasspathProducts(self.pants_workdir) self._add_for_target(classpath_products, self.java_target, 'java/target/first.jar') self._add_for_target(classpath_products, self.java_target, 'java/target/second.jar') self._add_for_target(classpath_products, self.java_target, 'java/target/third.jar') Cobertura.initialize_instrument_classpath(self.pants_workdir, settings, [self.java_target], classpath_products) self.assertEquals(len(syscalls.copy2_calls), 3, 'Should be 3 call for the single java_library target.') self._assert_target_copy(syscalls, frm='java/target/first.jar', to='coverage/classes/foo.foo-java/0') self._assert_target_copy(syscalls, frm='java/target/second.jar', to='coverage/classes/foo.foo-java/1') self._assert_target_copy(syscalls, frm='java/target/third.jar', to='coverage/classes/foo.foo-java/2') self.assertEquals(len(syscalls.copytree_calls), 0, 'Should be no copytree calls when targets are not coverage targets.')
def test_skips_non_coverage_targets(self): options = attrdict(coverage=True, coverage_jvm_options=[]) syscalls = MockSystemCalls() settings = self.get_settings(options, syscalls) classpath_products = ClasspathProducts(self.pants_workdir) self._add_for_target(classpath_products, self.jar_lib, 'jar/lib/classpath') self._add_for_target(classpath_products, self.binary_target, 'binary/target/classpath') self._add_for_target(classpath_products, self.app_target, 'app/target/classpath') self._add_for_target(classpath_products, self.java_target, 'java/target/classpath.jar') Cobertura.initialize_instrument_classpath(self.pants_workdir, settings, [self.jar_lib, self.binary_target, self.app_target, self.java_target], classpath_products) self.assertEquals(len(syscalls.copy2_calls), 1, 'Should only be 1 call for the single java_library target.') self._assert_target_copy(syscalls, frm='java/target/classpath.jar', to='coverage/classes/foo.foo-java/0') self.assertEquals(len(syscalls.copytree_calls), 0, 'Should be no copytree calls when targets are not coverage targets.')
def test_target_annotation_processor(self): options = attrdict(coverage=True, coverage_jvm_options=[]) syscalls = MockSystemCalls() settings = self.get_settings(options, syscalls) classpath_products = ClasspathProducts(self.pants_workdir) self._add_for_target(classpath_products, self.annotation_target, "anno/target/dir") Cobertura.initialize_instrument_classpath(self.pants_workdir, settings, [self.annotation_target], classpath_products) self.assertEqual(len(syscalls.copy2_calls), 0, "Should be 0 call for the single annotation target.") self._assert_target_copytree(syscalls, frm="anno/target/dir", to="coverage/classes/foo.foo-anno/0")
def test_target_annotation_processor(self): options = attrdict(coverage=True, coverage_jvm_options=[]) syscalls = MockSystemCalls() settings = self.get_settings(options, syscalls) classpath_products = ClasspathProducts(self.pants_workdir) self._add_for_target(classpath_products, self.annotation_target, 'anno/target/dir') Cobertura.initialize_instrument_classpath(self.pants_workdir, settings, [self.annotation_target], classpath_products) self.assertEquals(len(syscalls.copy2_calls), 0, 'Should be 0 call for the single annotation target.') self._assert_target_copytree(syscalls, frm='anno/target/dir', to='coverage/classes/foo.foo-anno/0')
def test_skips_non_coverage_targets(self): options = attrdict(coverage=True, coverage_jvm_options=[]) syscalls = MockSystemCalls() settings = self.get_settings(options, syscalls) classpath_products = ClasspathProducts(self.pants_workdir) self._add_for_target(classpath_products, self.jar_lib, "jar/lib/classpath") self._add_for_target(classpath_products, self.binary_target, "binary/target/classpath") self._add_for_target(classpath_products, self.app_target, "app/target/classpath") self._add_for_target(classpath_products, self.java_target, "java/target/classpath.jar") Cobertura.initialize_instrument_classpath( self.pants_workdir, settings, [ self.jar_lib, self.binary_target, self.app_target, self.java_target ], classpath_products, ) self.assertEqual( len(syscalls.copy2_calls), 1, "Should only be 1 call for the single java_library target.", ) self._assert_target_copy(syscalls, frm="java/target/classpath.jar", to="coverage/classes/foo.foo-java/0") self.assertEqual( len(syscalls.copytree_calls), 0, "Should be no copytree calls when targets are not coverage targets.", )
def test_target_annotation_processor(self): """ :API: public """ options = attrdict(coverage=True, coverage_jvm_options=[]) syscalls = MockSystemCalls() settings = self.get_settings(options, self.pants_workdir, fake_log(), syscalls) classpath_products = ClasspathProducts(self.pants_workdir) self._add_for_target(classpath_products, self.annotation_target, '/anno/target/dir') Cobertura.initialize_instrument_classpath(settings, [self.annotation_target], classpath_products) self.assertEquals( len(syscalls.copy2_calls), 0, 'Should be 0 call for the single annotation target.') self._assert_target_copytree(syscalls, '/anno/target/dir', '/coverage/classes/foo.foo-anno/0')
def test_target_with_multiple_path_entries(self): options = attrdict(coverage=True, coverage_jvm_options=[]) syscalls = MockSystemCalls() settings = self.get_settings(options, syscalls) classpath_products = ClasspathProducts(self.pants_workdir) self._add_for_target(classpath_products, self.java_target, "java/target/first.jar") self._add_for_target(classpath_products, self.java_target, "java/target/second.jar") self._add_for_target(classpath_products, self.java_target, "java/target/third.jar") Cobertura.initialize_instrument_classpath(self.pants_workdir, settings, [self.java_target], classpath_products) self.assertEqual( len(syscalls.copy2_calls), 3, "Should be 3 call for the single java_library target.") self._assert_target_copy(syscalls, frm="java/target/first.jar", to="coverage/classes/foo.foo-java/0") self._assert_target_copy(syscalls, frm="java/target/second.jar", to="coverage/classes/foo.foo-java/1") self._assert_target_copy(syscalls, frm="java/target/third.jar", to="coverage/classes/foo.foo-java/2") self.assertEqual( len(syscalls.copytree_calls), 0, "Should be no copytree calls when targets are not coverage targets.", )