Merge pull request #4752 from 219sansim:fix_flaky_LatticeRelation

[core] Fix flaky LatticeRelationTest #4752
This commit is contained in:
Andreas Dangel
2024-03-15 13:46:21 +01:00
3 changed files with 13 additions and 9 deletions

View File

@ -415,6 +415,7 @@ See [Detailed Release Notes for PMD 7.0.0]({{ baseurl }}pmd_release_notes_pmd7.h
* [#4738](https://github.com/pmd/pmd/pull/4738): \[doc] Added reference to the PMD extension for bld - [Erik C. Thauvin](https://github.com/ethauvin) (@ethauvin)
* [#4749](https://github.com/pmd/pmd/pull/4749): Fixes NoSuchMethodError on processing errors in pmd-compat6 - [Andreas Bergander](https://github.com/bergander) (@bergander)
* [#4750](https://github.com/pmd/pmd/pull/4750): \[core] Fix flaky SummaryHTMLRenderer - [219sansim](https://github.com/219sansim) (@219sansim)
* [#4752](https://github.com/pmd/pmd/pull/4752): \[core] Fix flaky LatticeRelationTest - [219sansim](https://github.com/219sansim) (@219sansim)
* [#4754](https://github.com/pmd/pmd/pull/4754): \[java] EmptyControlStatementRule: Add allowCommentedBlocks property - [Andreas Bergander](https://github.com/bergander) (@bergander)
* [#4759](https://github.com/pmd/pmd/pull/4759): \[java] fix: remove delimiter attribute from ruleset category/java/errorprone.xml - [Marcin Dąbrowski](https://github.com/marcindabrowski) (@marcindabrowski)
* [#4825](https://github.com/pmd/pmd/pull/4825): \[plsql] Fix ignored WITH clause for SELECT INTO statements - [Laurent Bovet](https://github.com/lbovet) (@lbovet)
@ -1223,6 +1224,7 @@ Language specific fixes:
* [#4738](https://github.com/pmd/pmd/pull/4738): \[doc] Added reference to the PMD extension for bld - [Erik C. Thauvin](https://github.com/ethauvin) (@ethauvin)
* [#4749](https://github.com/pmd/pmd/pull/4749): Fixes NoSuchMethodError on processing errors in pmd-compat6 - [Andreas Bergander](https://github.com/bergander) (@bergander)
* [#4750](https://github.com/pmd/pmd/pull/4750): \[core] Fix flaky SummaryHTMLRenderer - [219sansim](https://github.com/219sansim) (@219sansim)
* [#4752](https://github.com/pmd/pmd/pull/4752): \[core] Fix flaky LatticeRelationTest - [219sansim](https://github.com/219sansim) (@219sansim)
* [#4754](https://github.com/pmd/pmd/pull/4754): \[java] EmptyControlStatementRule: Add allowCommentedBlocks property - [Andreas Bergander](https://github.com/bergander) (@bergander)
* [#4759](https://github.com/pmd/pmd/pull/4759): \[java] fix: remove delimiter attribute from ruleset category/java/errorprone.xml - [Marcin Dąbrowski](https://github.com/marcindabrowski) (@marcindabrowski)
* [#4825](https://github.com/pmd/pmd/pull/4825): \[plsql] Fix ignored WITH clause for SELECT INTO statements - [Laurent Bovet](https://github.com/lbovet) (@lbovet)

View File

@ -43,7 +43,9 @@ public final class GraphUtil {
StringBuilder sb = new StringBuilder("strict digraph {\n");
Map<V, String> ids = new HashMap<>();
int i = 0;
for (V node : vertices) {
List<V> vertexList = new ArrayList<>(vertices);
vertexList.sort(Comparator.comparing(Object::toString)); // for reproducibility in tests
for (V node : vertexList) {
String id = "n" + i++;
ids.put(node, id);
sb.append(id)
@ -56,7 +58,7 @@ public final class GraphUtil {
List<String> edges = new ArrayList<>();
for (V node : vertices) {
for (V node : vertexList) {
// edges
String id = ids.get(node);
for (V succ : successorFun.apply(node)) {

View File

@ -279,15 +279,15 @@ class LatticeRelationTest {
// all {1}, {2}, and { } are query nodes, not {1,2}
assertEquals("strict digraph {\n"
+ "n0 [ shape=box, color=green, label=\"[]\" ];\n"
+ "n0 [ shape=box, color=black, label=\"[1, 2]\" ];\n"
+ "n1 [ shape=box, color=green, label=\"[1]\" ];\n"
+ "n2 [ shape=box, color=green, label=\"[2]\" ];\n"
+ "n3 [ shape=box, color=black, label=\"[1, 2]\" ];\n"
+ "n1 -> n0;\n" // {1} -> { }
+ "n2 -> n0;\n" // {2} -> { }
+ "n3 -> n0;\n" // {1,2} -> { }
+ "n3 -> n1;\n" // {1,2} -> {1}
+ "n3 -> n2;\n" // {1,2} -> {2}
+ "n3 [ shape=box, color=green, label=\"[]\" ];\n"
+ "n0 -> n1;\n" // {1} -> { }
+ "n0 -> n2;\n" // {2} -> { }
+ "n0 -> n3;\n" // {1,2} -> { }
+ "n1 -> n3;\n" // {1,2} -> {1}
+ "n2 -> n3;\n" // {1,2} -> {2}
+ "}", lattice.toString());
}