8276650: GenGraphs does not produce deterministic output
Reviewed-by: iris
This commit is contained in:
parent
7b1916efda
commit
e21b5c7b37
@ -333,7 +333,7 @@ public class ModuleDotGraph {
|
||||
|
||||
private final String name;
|
||||
private final Graph<String> graph;
|
||||
private final Set<ModuleDescriptor> descriptors = new TreeSet<>();
|
||||
private final TreeSet<ModuleDescriptor> descriptors = new TreeSet<>();
|
||||
private final List<SubGraph> subgraphs = new ArrayList<>();
|
||||
private final Attributes attributes;
|
||||
public DotGraphBuilder(String name,
|
||||
@ -414,7 +414,7 @@ public class ModuleDotGraph {
|
||||
.collect(toSet());
|
||||
|
||||
String mn = md.name();
|
||||
edges.forEach(dn -> {
|
||||
edges.stream().sorted().forEach(dn -> {
|
||||
String attr = "";
|
||||
if (dn.equals("java.base")) {
|
||||
attr = "color=\"" + attributes.requiresMandatedColor() + "\"";
|
||||
|
@ -37,13 +37,12 @@
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.spi.ToolProvider;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.DataProvider;
|
||||
@ -72,41 +71,43 @@ public class DotFileTest {
|
||||
@DataProvider(name = "modules")
|
||||
public Object[][] modules() {
|
||||
return new Object[][]{
|
||||
{"java.desktop", Set.of("java.datatransfer -> java.base",
|
||||
"java.desktop -> java.datatransfer",
|
||||
"java.desktop -> java.prefs",
|
||||
"java.prefs -> java.xml",
|
||||
"java.xml -> java.base" )
|
||||
// the edges for each module are printed in lexicographical order
|
||||
{"java.desktop", List.of("java.datatransfer -> java.base",
|
||||
"java.desktop -> java.datatransfer",
|
||||
"java.desktop -> java.prefs",
|
||||
"java.prefs -> java.xml",
|
||||
"java.xml -> java.base" )
|
||||
},
|
||||
{ "java.sql", Set.of("java.logging -> java.base",
|
||||
"java.transaction.xa -> java.base",
|
||||
"java.sql -> java.logging",
|
||||
"java.sql -> java.transaction.xa",
|
||||
"java.sql -> java.xml",
|
||||
"java.xml -> java.base" )
|
||||
{ "java.sql", List.of("java.logging -> java.base",
|
||||
"java.sql -> java.logging",
|
||||
"java.sql -> java.transaction.xa",
|
||||
"java.sql -> java.xml",
|
||||
"java.transaction.xa -> java.base",
|
||||
"java.xml -> java.base" )
|
||||
}
|
||||
};
|
||||
}
|
||||
@DataProvider(name = "specVersion")
|
||||
public Object[][] specVersion() {
|
||||
return new Object[][]{
|
||||
{"java.desktop", Set.of("java.datatransfer -> java.base",
|
||||
"java.desktop -> java.datatransfer",
|
||||
"java.desktop -> java.xml",
|
||||
"java.xml -> java.base")
|
||||
// the edges for each module are printed in lexicographical order
|
||||
{"java.desktop", List.of("java.datatransfer -> java.base",
|
||||
"java.desktop -> java.datatransfer",
|
||||
"java.desktop -> java.xml",
|
||||
"java.xml -> java.base")
|
||||
},
|
||||
{ "java.sql", Set.of("java.logging -> java.base",
|
||||
"java.transaction.xa -> java.base",
|
||||
"java.sql -> java.logging",
|
||||
"java.sql -> java.transaction.xa",
|
||||
"java.sql -> java.xml",
|
||||
"java.xml -> java.base" )
|
||||
{ "java.sql", List.of("java.logging -> java.base",
|
||||
"java.sql -> java.logging",
|
||||
"java.sql -> java.transaction.xa",
|
||||
"java.sql -> java.xml",
|
||||
"java.transaction.xa -> java.base",
|
||||
"java.xml -> java.base" )
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Test(dataProvider = "modules")
|
||||
public void test(String name, Set<String> edges) throws Exception {
|
||||
public void test(String name, List<String> edges) throws Exception {
|
||||
String[] options = new String[] {
|
||||
"-dotoutput", DOTS_DIR.toString(),
|
||||
"-s", "-m", name
|
||||
@ -115,15 +116,15 @@ public class DotFileTest {
|
||||
|
||||
Path path = DOTS_DIR.resolve(name + ".dot");
|
||||
assertTrue(Files.exists(path));
|
||||
Set<String> lines = Files.readAllLines(path).stream()
|
||||
List<String> lines = Files.readAllLines(path).stream()
|
||||
.filter(l -> l.contains(" -> "))
|
||||
.map(this::split)
|
||||
.collect(Collectors.toSet());
|
||||
.toList();
|
||||
assertEquals(lines, edges);
|
||||
}
|
||||
|
||||
@Test(dataProvider = "specVersion")
|
||||
public void testAPIOnly(String name, Set<String> edges) throws Exception {
|
||||
public void testAPIOnly(String name, List<String> edges) throws Exception {
|
||||
String[] options = new String[]{
|
||||
"-dotoutput", SPEC_DIR.toString(),
|
||||
"-s", "-apionly",
|
||||
@ -133,10 +134,10 @@ public class DotFileTest {
|
||||
|
||||
Path path = SPEC_DIR.resolve(name + ".dot");
|
||||
assertTrue(Files.exists(path));
|
||||
Set<String> lines = Files.readAllLines(path).stream()
|
||||
List<String> lines = Files.readAllLines(path).stream()
|
||||
.filter(l -> l.contains(" -> "))
|
||||
.map(this::split)
|
||||
.collect(Collectors.toSet());
|
||||
.toList();
|
||||
assertEquals(lines, edges);
|
||||
}
|
||||
|
||||
@ -160,7 +161,7 @@ public class DotFileTest {
|
||||
assertTrue(Files.exists(path));
|
||||
|
||||
// package dependences
|
||||
Set<String> expected = Set.of(
|
||||
List<String> expected = List.of(
|
||||
"org.indirect -> java.lang",
|
||||
"org.indirect -> org.unsafe",
|
||||
"org.safe -> java.io",
|
||||
@ -170,7 +171,7 @@ public class DotFileTest {
|
||||
);
|
||||
|
||||
Pattern pattern = Pattern.compile("(.*) -> +([^ ]*) (.*)");
|
||||
Set<String> lines = new HashSet<>();
|
||||
List<String> lines = new ArrayList<>();
|
||||
for (String line : Files.readAllLines(path)) {
|
||||
line = line.replace('"', ' ').replace(';', ' ');
|
||||
Matcher pm = pattern.matcher(line);
|
||||
@ -201,15 +202,15 @@ public class DotFileTest {
|
||||
assertTrue(Files.exists(path));
|
||||
|
||||
// module dependences
|
||||
Set<String> expected = Set.of(
|
||||
"unsafe -> jdk.unsupported",
|
||||
"jdk.unsupported -> java.base"
|
||||
List<String> expected = List.of(
|
||||
"jdk.unsupported -> java.base",
|
||||
"unsafe -> jdk.unsupported"
|
||||
);
|
||||
|
||||
Set<String> lines = Files.readAllLines(path).stream()
|
||||
List<String> lines = Files.readAllLines(path).stream()
|
||||
.filter(l -> l.contains(" -> "))
|
||||
.map(this::split)
|
||||
.collect(Collectors.toSet());
|
||||
.toList();
|
||||
assertEquals(lines, expected);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user