def _test_canonical_classpath_helper(self, classpath_products, targets, libs_dir, expected_canonical_classpath, expected_classspath_files, excludes=None): """ Helper method to call `create_canonical_classpath` and verify generated canonical classpath. :param ClasspathProducts classpath_products: Classpath products. :param list targets: List of targets to generate canonical classpath from. :param string libs_dir: Directory where canonical classpath are to be generated. :param list expected_canonical_classpath: List of canonical classpath relative to a base directory. :param dict expected_classspath_files: A dict of classpath.txt path to its expected content. """ canonical_classpath = ClasspathProducts.create_canonical_classpath( classpath_products, targets, libs_dir, save_classpath_file=True, internal_classpath_only=False, excludes=excludes) # check canonical path returned self.assertEquals(expected_canonical_classpath, relativize_paths(canonical_classpath, libs_dir)) # check canonical path created contain the exact set of files, no more, no less self.assertTrue(contains_exact_files(libs_dir, expected_canonical_classpath + expected_classspath_files.keys())) # check the content of classpath.txt for classpath_file in expected_classspath_files: self.assertTrue(check_file_content(os.path.join(libs_dir, classpath_file), expected_classspath_files[classpath_file]))
def _test_canonical_classpath_helper(self, classpath_products, targets, expected_canonical_classpath, expected_classspath_files, use_target_id): """ Helper method to call `create_canonical_classpath` and verify generated canonical classpath. :param ClasspathProducts classpath_products: Classpath products. :param list targets: List of targets to generate canonical classpath from. :param list expected_canonical_classpath: List of canonical classpath relative to a base directory. :param dict expected_classspath_files: A dict of classpath.txt path to its expected content. """ with temporary_dir() as base_dir: canonical_classpath = ClasspathUtil.create_canonical_classpath( classpath_products, targets, base_dir, save_classpath_file=True, use_target_id=use_target_id) # check canonical path returned self.assertEquals(expected_canonical_classpath, relativize_paths(canonical_classpath, base_dir)) # check canonical path created contain the exact set of files, no more, no less self.assertTrue( contains_exact_files( base_dir, expected_canonical_classpath + expected_classspath_files.keys())) # check the content of classpath.txt for classpath_file in expected_classspath_files: self.assertTrue( check_file_content( os.path.join(base_dir, classpath_file), expected_classspath_files[classpath_file]))
def _test_canonical_classpath_helper(self, classpath_products, targets, expected_canonical_classpath, expected_classspath_files, use_target_id): """ Helper method to call `create_canonical_classpath` and verify generated canonical classpath. :param ClasspathProducts classpath_products: Classpath products. :param list targets: List of targets to generate canonical classpath from. :param list expected_canonical_classpath: List of canonical classpath relative to a base directory. :param dict expected_classspath_files: A dict of classpath.txt path to its expected content. """ with temporary_dir() as base_dir: canonical_classpath = ClasspathUtil.create_canonical_classpath(classpath_products, targets, base_dir, save_classpath_file=True, use_target_id=use_target_id) # check canonical path returned self.assertEquals(expected_canonical_classpath, relativize_paths(canonical_classpath, base_dir)) # check canonical path created contain the exact set of files, no more, no less self.assertTrue(contains_exact_files(base_dir, expected_canonical_classpath + expected_classspath_files.keys())) # check the content of classpath.txt for classpath_file in expected_classspath_files: self.assertTrue(check_file_content(os.path.join(base_dir, classpath_file), expected_classspath_files[classpath_file]))