Simplify test data and refactor
This commit is contained in:
@@ -116,15 +116,15 @@ describe('depgraph', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('hadoop-tree', () => {
|
||||
describe('cycle-tree', () => {
|
||||
let depGraph;
|
||||
beforeAll(() => {
|
||||
depGraph = parseDependencyJson(getTestDataFile("hadoop-tree"));
|
||||
depGraph = parseDependencyJson(getTestDataFile("cycle-tree"));
|
||||
});
|
||||
|
||||
it('should parse out the top level dependencies', () => {
|
||||
const mavenDependencies = new MavenDependencyGraph(depGraph);
|
||||
expect(mavenDependencies.getPackageCount()).to.equal(678);
|
||||
expect(mavenDependencies.getPackageCount()).to.equal(3);
|
||||
});
|
||||
|
||||
it('should be able to generate a manifest despite having a cycle', () => {
|
||||
@@ -132,7 +132,7 @@ describe('depgraph', () => {
|
||||
const manifest = mavenDependencies.createManifest();
|
||||
|
||||
expect(manifest.name).to.equal('hadoop-main');
|
||||
expect(manifest.countDependencies()).to.equal(653);
|
||||
expect(manifest.countDependencies()).to.equal(2);
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
+4
-3
@@ -88,14 +88,15 @@ export class MavenDependencyGraph {
|
||||
function addTransitiveDeps(dependencies, seen: Set<string> = new Set()) {
|
||||
if (dependencies) {
|
||||
dependencies.forEach(transitiveDep => {
|
||||
if (seen.has(transitiveDep.packageURL.toString())) {
|
||||
let purl = transitiveDep.packageURL.toString();
|
||||
if (seen.has(purl)) {
|
||||
// we're in a cycle! skip this one.
|
||||
return;
|
||||
}
|
||||
seen.add(transitiveDep.packageURL.toString());
|
||||
const transitiveDepArtifact = packageUrlToArtifact[transitiveDep.packageURL.toString()];
|
||||
const transitiveDepArtifact = packageUrlToArtifact[purl];
|
||||
const transitiveDepScope = getDependencyScopeForMavenScope(transitiveDepArtifact.scopes);
|
||||
manifest.addIndirectDependency(transitiveDep, transitiveDepScope);
|
||||
seen.add(purl);
|
||||
addTransitiveDeps(transitiveDep.dependencies, seen);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
{
|
||||
"graphName" : "hadoop-main",
|
||||
"artifacts" : [ {
|
||||
"id" : "org.apache.hadoop:hadoop-annotations:jar:compile",
|
||||
"numericId" : 1,
|
||||
"groupId" : "org.apache.hadoop",
|
||||
"artifactId" : "hadoop-annotations",
|
||||
"version" : "3.5.0-SNAPSHOT",
|
||||
"optional" : false,
|
||||
"scopes" : [ "compile" ],
|
||||
"types" : [ "jar" ]
|
||||
}, {
|
||||
"id" : "jdiff:jdiff:jar:provided",
|
||||
"numericId" : 2,
|
||||
"groupId" : "jdiff",
|
||||
"artifactId" : "jdiff",
|
||||
"version" : "1.0.9",
|
||||
"optional" : false,
|
||||
"scopes" : [ "provided" ],
|
||||
"types" : [ "jar" ]
|
||||
}, {
|
||||
"id" : "org.apache.hadoop:hadoop-project-dist:pom:compile",
|
||||
"numericId" : 3,
|
||||
"groupId" : "org.apache.hadoop",
|
||||
"artifactId" : "hadoop-project-dist",
|
||||
"version" : "3.5.0-SNAPSHOT",
|
||||
"optional" : false,
|
||||
"scopes" : [ "compile" ],
|
||||
"types" : [ "pom" ]
|
||||
} ],
|
||||
"dependencies" : [ {
|
||||
"from" : "org.apache.hadoop:hadoop-annotations:jar:compile",
|
||||
"to" : "jdiff:jdiff:jar:provided",
|
||||
"numericFrom" : 1,
|
||||
"numericTo" : 2,
|
||||
"resolution" : "INCLUDED"
|
||||
}, {
|
||||
"from" : "org.apache.hadoop:hadoop-annotations:jar:compile",
|
||||
"to" : "jdiff:jdiff:jar:provided",
|
||||
"numericFrom" : 1,
|
||||
"numericTo" : 3,
|
||||
"resolution" : "INCLUDED"
|
||||
}, {
|
||||
"from" : "jdiff:jdiff:jar:provided",
|
||||
"to" : "org.apache.hadoop:hadoop-project-dist:pom:compile",
|
||||
"numericFrom" : 2,
|
||||
"numericTo" : 3,
|
||||
"resolution" : "INCLUDED"
|
||||
}, {
|
||||
"from" : "org.apache.hadoop:hadoop-project-dist:pom:compile",
|
||||
"to" : "jdiff:jdiff:jar:provided",
|
||||
"numericFrom" : 3,
|
||||
"numericTo" : 2,
|
||||
"resolution" : "INCLUDED"
|
||||
}
|
||||
]
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user