def _get_resource_extensions(self, project): resource_extensions = set() resource_extensions.update(project.resource_extensions) # TODO(John Sirois): make test resources 1st class in ant build and punch this through to pants # model for _, _, files in safe_walk(os.path.join(get_buildroot(), 'tests', 'resources')): resource_extensions.update(Project.extract_resource_extensions(files)) return resource_extensions
def test_collapse_source_root(self): source_set_list = [] self.assertEquals([], Project._collapse_by_source_root(source_set_list)) SourceRoot.register("src/java", JavaLibrary) SourceRoot.register("tests/java", JavaTests) source_sets = [ SourceSet("/repo-root", "src/java", "com/pants/app", False), SourceSet("/repo-root", "tests/java", "com/pants/app", True), SourceSet("/repo-root", "some/other", "path", False), ] results = Project._collapse_by_source_root(source_sets) self.assertEquals(SourceSet("/repo-root", "src/java", "", False), results[0]) self.assertFalse(results[0].is_test) self.assertEquals(SourceSet("/repo-root", "tests/java", "", True), results[1]) self.assertTrue(results[1].is_test) # If there is no registered source root, the SourceSet should be returned unmodified self.assertEquals(source_sets[2], results[2]) self.assertFalse(results[2].is_test)