Skip to content

Commit

Permalink
fix failing tests in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
monperrus committed Sep 14, 2023
1 parent 2729921 commit 0b9e858
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
<repositories>
<repository>
<!-- This repository is used in the Spoon Jenkins tests for grabbing the latest Spoon snapshot -->
<id>ow2.org-snapshot</id>
<id>snapshot</id>
<name>Maven Repository for Spoon Snapshots</name>
<url>https://repository.ow2.org/nexus/content/repositories/snapshots/</url>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<snapshots/>
</repository>
</repositories>
Expand All @@ -29,7 +29,7 @@
<dependency>
<groupId>fr.inria.gforge.spoon</groupId>
<artifactId>spoon-core</artifactId>
<version>10.1.1</version>
<version>10.4.1</version>
</dependency>
<dependency>
<groupId>fr.inria.gforge.spoon.labs</groupId>
Expand Down
25 changes: 22 additions & 3 deletions src/test/java/se/kth/spork/spoon/Spoon3dmMergeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import static org.junit.jupiter.api.Assertions.*;

import java.io.IOException;
import java.util.Comparator;
import java.util.List;
import java.util.Set;

import kotlin.Pair;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down Expand Up @@ -69,11 +73,26 @@ private static void runTestMerge(Util.TestSources sources) {
// this assert is just to give a better overview of obvious errors, but it relies on the
// pretty printer's
// correctness
// assertEquals(Cli.prettyPrint(expected), Cli.prettyPrint(mergeTree));
//assertEquals(Cli.prettyPrint(expected), Cli.prettyPrint(mergeTree));
System.out.println(Cli.prettyPrint(mergeTree));

// these asserts are what actually matters
assertEquals(expected, mergeTree);
// we cannot assert CtModules so stricly
// because the order of types is taken into account in the EqualityVisitor of Spoon
// assertEquals(expected, mergeTree);

// so we force the order of types and assert one by one
assertTrue(expected instanceof CtModule);
final Comparator<CtType> nameComparator = new Comparator<>() {
@Override
public int compare(CtType o, CtType t1) {
return o.getQualifiedName().compareTo(t1.getQualifiedName());
}
};
final List<CtType> list1 = expected.filterChildren(c -> (c instanceof CtType)).list();
final List<CtType> list2 = mergeTree.filterChildren(c -> (c instanceof CtType)).list();
list1.sort(nameComparator);
list2.sort(nameComparator);
assertEquals(list1, list2);
assertEquals(expectedImports, mergedImports);
assertEquals(expectedCuComment, mergedCuComment);
}
Expand Down

0 comments on commit 0b9e858

Please sign in to comment.