use of com.synopsys.integration.detectable.detectables.bitbake.model.BitbakeGraph in project synopsys-detect by blackducksoftware.
the class BitbakeDependencyGraphTransformerTest method parentHasChild.
@Test
public void parentHasChild() {
ExternalIdFactory externalIdFactory = new ExternalIdFactory();
BitbakeGraph bitbakeGraph = new BitbakeGraph();
bitbakeGraph.addNode("example", "1:75-r50", "meta");
bitbakeGraph.addNode("foobar", "12", "meta");
bitbakeGraph.addChild("example", "foobar");
Map<String, List<String>> recipeToLayerMap = new HashMap<>();
recipeToLayerMap.put("example", Collections.singletonList("meta"));
recipeToLayerMap.put("foobar", Collections.singletonList("meta"));
BitbakeDependencyGraphTransformer bitbakeDependencyGraphTransformer = new BitbakeDependencyGraphTransformer(EnumListFilter.excludeNone());
DependencyGraph dependencyGraph = bitbakeDependencyGraphTransformer.transform(bitbakeGraph, recipeToLayerMap, null);
NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.YOCTO, dependencyGraph);
ExternalId example = graphAssert.hasDependency(externalIdFactory.createYoctoExternalId("meta", "example", "1:75-r50"));
ExternalId foobar = graphAssert.hasDependency(externalIdFactory.createYoctoExternalId("meta", "foobar", "12"));
graphAssert.hasParentChildRelationship(example, foobar);
}
use of com.synopsys.integration.detectable.detectables.bitbake.model.BitbakeGraph in project synopsys-detect by blackducksoftware.
the class BitbakeDependencyGraphTransformerTest method ignoredNoVersion.
@Test
public void ignoredNoVersion() {
ExternalIdFactory externalIdFactory = new ExternalIdFactory();
BitbakeGraph bitbakeGraph = new BitbakeGraph();
bitbakeGraph.addNode("example", null, "meta");
Map<String, List<String>> recipeToLayerMap = new HashMap<>();
recipeToLayerMap.put("example", Collections.singletonList("meta"));
BitbakeDependencyGraphTransformer bitbakeDependencyGraphTransformer = new BitbakeDependencyGraphTransformer(EnumListFilter.excludeNone());
DependencyGraph dependencyGraph = bitbakeDependencyGraphTransformer.transform(bitbakeGraph, recipeToLayerMap, null);
GraphAssert graphAssert = new GraphAssert(Forge.YOCTO, dependencyGraph);
graphAssert.hasNoDependency(externalIdFactory.createYoctoExternalId("meta", "example", null));
graphAssert.hasRootSize(0);
}
use of com.synopsys.integration.detectable.detectables.bitbake.model.BitbakeGraph in project synopsys-detect by blackducksoftware.
the class BitbakeGraphTransformerTest method removedQuotesFromName.
@Test
public void removedQuotesFromName() throws IntegrationException {
HashMap<String, GraphEdge> edges = new HashMap<>();
HashMap<String, GraphNode> nodes = new HashMap<>();
addNode("quotes\"removed", "example\\n:example\\n/example/meta/some.bb", nodes);
Set<String> knownLayers = new HashSet<>(Arrays.asList("aaa", "meta", "bbb"));
BitbakeGraph bitbakeGraph = buildGraph(nodes, edges, knownLayers);
assertEquals(1, bitbakeGraph.getNodes().size());
assertEquals("quotesremoved", bitbakeGraph.getNodes().get(0).getName());
}
use of com.synopsys.integration.detectable.detectables.bitbake.model.BitbakeGraph in project synopsys-detect by blackducksoftware.
the class BitbakeGraphTransformerTest method parsedVersionFromLabel.
@Test
public void parsedVersionFromLabel() {
HashMap<String, GraphEdge> edges = new HashMap<>();
HashMap<String, GraphNode> nodes = new HashMap<>();
addNode("name", "name\\n:version\\n/some/meta/path/to.bb", nodes);
Set<String> knownLayers = new HashSet<>(Arrays.asList("aaa", "meta", "bbb"));
BitbakeGraph bitbakeGraph = buildGraph(nodes, edges, knownLayers);
assertEquals(1, bitbakeGraph.getNodes().size());
assertTrue(bitbakeGraph.getNodes().get(0).getVersion().isPresent());
assertEquals("version", bitbakeGraph.getNodes().get(0).getVersion().get());
assertTrue(bitbakeGraph.getNodes().get(0).getLayer().isPresent());
assertEquals("meta", bitbakeGraph.getNodes().get(0).getLayer().get());
}
use of com.synopsys.integration.detectable.detectables.bitbake.model.BitbakeGraph in project synopsys-detect by blackducksoftware.
the class BitbakeExtractor method generateCodeLocationForTargetPackage.
private Optional<CodeLocation> generateCodeLocationForTargetPackage(String targetPackage, File sourceDirectory, ExecutableTarget bashExecutable, File buildEnvironmentFile, File buildDirectory, ShowRecipesResults showRecipesResults, BitbakeEnvironment bitbakeEnvironment) {
try {
BitbakeGraph bitbakeGraph = generateBitbakeGraph(sourceDirectory, bashExecutable, buildEnvironmentFile, buildDirectory, targetPackage, showRecipesResults.getLayerNames());
Map<String, String> imageRecipes = null;
if (dependencyTypeFilter.shouldExclude(BitbakeDependencyType.BUILD)) {
imageRecipes = readImageRecipes(buildDirectory, targetPackage, bitbakeEnvironment);
}
DependencyGraph dependencyGraph = bitbakeDependencyGraphTransformer.transform(bitbakeGraph, showRecipesResults.getRecipesWithLayers(), imageRecipes);
return Optional.of(new CodeLocation(dependencyGraph));
} catch (ExecutableFailedException | IntegrationException | IOException e) {
logger.error("Failed to extract a Code Location while running Bitbake against package '{}': {}", targetPackage, e.getMessage());
logger.debug(e.getMessage(), e);
return Optional.empty();
}
}
Aggregations