From c48a3a64b7f05880028a188f95e5cc9b7bdf759a Mon Sep 17 00:00:00 2001 From: Pouryafard75 Date: Fri, 22 Mar 2024 02:44:52 -0400 Subject: [PATCH] ASTDiff: Fix tests --- .../astDiff/matchers/MissingIdenticalSubtree.java | 8 +++++--- .../tests/RefactoringOracleProblematicCasesTest.java | 2 -- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/refactoringminer/astDiff/matchers/MissingIdenticalSubtree.java b/src/main/java/org/refactoringminer/astDiff/matchers/MissingIdenticalSubtree.java index 05e3482e50..970cffa2ff 100644 --- a/src/main/java/org/refactoringminer/astDiff/matchers/MissingIdenticalSubtree.java +++ b/src/main/java/org/refactoringminer/astDiff/matchers/MissingIdenticalSubtree.java @@ -25,7 +25,7 @@ public class MissingIdenticalSubtree extends GreedySubtreeMatcher implements Tre protected Tree src; protected Tree dst; protected ExtendedMultiMappingStore mappings; - + @Override public void match(Tree src, Tree dst, ExtendedMultiMappingStore mappingStore) { this.src = src; @@ -66,7 +66,9 @@ public void match(Tree src, Tree dst, ExtendedMultiMappingStore mappingStore) { public void filterMappings(MultiMappingStore multiMappings) { List ambiguousList = new ArrayList<>(); Set ignored = new HashSet<>(); - for (var src : multiMappings.allMappedSrcs()) { + Set trees = new TreeSet<>(Comparator.comparingInt(Tree::getPos)); + trees.addAll(multiMappings.allMappedSrcs()); + for (var src : trees) { var isMappingUnique = false; if (tinyTrees(src,multiMappings,minPriority)) continue; @@ -91,7 +93,7 @@ public void filterMappings(MultiMappingStore multiMappings) { } Set srcIgnored = new HashSet<>(); Set dstIgnored = new HashSet<>(); - Collections.sort(ambiguousList, new MappingComparators.FullMappingComparator(mappings.getMonoMappingStore())); + Collections.sort(ambiguousList, new CustomTopDownMatcher.ExtendedFullMappingComparator(mappings.getMonoMappingStore())); // Select the best ambiguous mappings retainBestMapping(ambiguousList, srcIgnored, dstIgnored); } diff --git a/src/test/java/org/refactoringminer/astDiff/tests/RefactoringOracleProblematicCasesTest.java b/src/test/java/org/refactoringminer/astDiff/tests/RefactoringOracleProblematicCasesTest.java index cbe928446d..355ca5a5ac 100644 --- a/src/test/java/org/refactoringminer/astDiff/tests/RefactoringOracleProblematicCasesTest.java +++ b/src/test/java/org/refactoringminer/astDiff/tests/RefactoringOracleProblematicCasesTest.java @@ -26,8 +26,6 @@ public class RefactoringOracleProblematicCasesTest { @ParameterizedTest(name= "{index}: {0}") @JsonFileSource(resources = {"/astDiff/commits/cases-problematic.json"}) public void testSubTreeMappings(@ConvertWith(CaseInfo.CaseInfoConverter.class) CaseInfo info) throws Exception { - //TODO : Fix the flakiness for this case - if (info.makeURL().equals("https://github.com/infinispan/infinispan/commit/03573a655bcbb77f7a76d8e22d851cc22796b4f8")) return; File mappingsDirFile = new File(getFinalFolderPath(dir, info.getRepo(), info.getCommit())); String[] files = mappingsDirFile.list();