use of com.synopsys.integration.detectable.detectables.clang.packagemanager.PackageDetailsResult in project synopsys-detect by blackducksoftware.
the class ClangExtractor method extract.
public Extraction extract(ClangPackageManager currentPackageManager, ClangPackageManagerRunner packageManagerRunner, File sourceDirectory, File outputDirectory, File jsonCompilationDatabaseFile, boolean cleanup) {
try {
logger.debug(String.format("Analyzing %s", jsonCompilationDatabaseFile.getAbsolutePath()));
logger.debug(String.format("extract() called; compileCommandsJsonFilePath: %s", jsonCompilationDatabaseFile.getAbsolutePath()));
List<CompileCommand> compileCommands = compileCommandDatabaseParser.parseCompileCommandDatabase(jsonCompilationDatabaseFile);
Set<File> dependencyFileDetails = dependencyFileDetailGenerator.fromCompileCommands(compileCommands, outputDirectory, cleanup);
PackageDetailsResult results = packageManagerRunner.getAllPackages(currentPackageManager, sourceDirectory, executableRunner, dependencyFileDetails);
logger.trace("Found : " + results.getFoundPackages() + " packages.");
logger.trace("Found : " + results.getUnRecognizedDependencyFiles() + " non-package files.");
List<Forge> packageForges = forgeChooser.determineForges(currentPackageManager);
CodeLocation codeLocation = clangPackageDetailsTransformer.toCodeLocation(packageForges, results.getFoundPackages());
logFileCollection("Unrecognized dependency files (all)", results.getUnRecognizedDependencyFiles());
List<File> unrecognizedIncludeFiles = results.getUnRecognizedDependencyFiles().stream().filter(file -> !isFileUnderDir(sourceDirectory, file)).collect(Collectors.toList());
logFileCollection(String.format("Unrecognized dependency files that are outside the compile_commands.json directory (%s) and will be collected", sourceDirectory), unrecognizedIncludeFiles);
return new Extraction.Builder().unrecognizedPaths(unrecognizedIncludeFiles).success(codeLocation).build();
} catch (Exception e) {
return new Extraction.Builder().exception(e).build();
}
}
use of com.synopsys.integration.detectable.detectables.clang.packagemanager.PackageDetailsResult in project synopsys-detect by blackducksoftware.
the class ClangPackageManagerRunnerTest method testSuccessCase.
private void testSuccessCase(ClangPackageManagerInfo packageManagerInfo, ClangPackageManagerResolver packageResolver, String pkgName, String pkgArchitecture, boolean archBuried, String pkgVersion, String pkgMgrQueryResultPattern, String pkgMgrDetailsQueryResultPattern) throws ExecutableRunnerException {
// Test
PackageDetailsResult result = runTest(packageManagerInfo, packageResolver, pkgName, pkgArchitecture, archBuried, pkgMgrQueryResultPattern, pkgMgrDetailsQueryResultPattern, dependencyFile);
// Verify
assertEquals(0, result.getUnRecognizedDependencyFiles().size());
assertEquals(1, result.getFoundPackages().size());
PackageDetails foundPkgDetails = result.getFoundPackages().iterator().next();
assertEquals(pkgName, foundPkgDetails.getPackageName());
assertEquals(pkgArchitecture, foundPkgDetails.getPackageArch());
assertEquals(pkgVersion, foundPkgDetails.getPackageVersion());
}
use of com.synopsys.integration.detectable.detectables.clang.packagemanager.PackageDetailsResult in project synopsys-detect by blackducksoftware.
the class ClangPackageManagerRunnerTest method testNonPkgOwnedIncludeFile.
private void testNonPkgOwnedIncludeFile(ClangPackageManagerInfo packageManagerInfo, ClangPackageManagerResolver packageResolver, String pkgMgrOwnerQueryResultPattern) throws ExecutableRunnerException {
// Test
PackageDetailsResult result = runTest(packageManagerInfo, packageResolver, null, null, false, pkgMgrOwnerQueryResultPattern, null, dependencyFile);
// Verify
assertEquals(1, result.getUnRecognizedDependencyFiles().size());
assertEquals(dependencyFile, result.getUnRecognizedDependencyFiles().iterator().next());
}
use of com.synopsys.integration.detectable.detectables.clang.packagemanager.PackageDetailsResult in project synopsys-detect by blackducksoftware.
the class ClangPackageManagerRunnerTest method testNoResultsCase.
private void testNoResultsCase(ClangPackageManagerInfo packageManagerInfo, ClangPackageManagerResolver packageResolver, String pkgName, String pkgArchitecture, String pkgMgrQueryResultPattern, String pkgMgrDetailsQueryResultPattern) throws ExecutableRunnerException {
// Test
PackageDetailsResult result = runTest(packageManagerInfo, packageResolver, pkgName, pkgArchitecture, false, pkgMgrQueryResultPattern, pkgMgrDetailsQueryResultPattern, dependencyFile);
// Verify
assertEquals(0, result.getUnRecognizedDependencyFiles().size());
assertEquals(0, result.getFoundPackages().size());
}
Aggregations