Skip to content

Commit

Permalink
Minor cleanup in tests discovery (#1538)
Browse files Browse the repository at this point in the history
  • Loading branch information
wind57 authored Dec 15, 2023
1 parent 25e790d commit 0b50dba
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@
public class TestsDiscovery {

public static void main(String[] args) throws Exception {
List<String> targetClasses = entireClasspath().stream().filter(x -> x.contains("target/classes")).toList();
List<String> classpathEntries = entireClasspath();
List<String> targetClasses = classpathEntries.stream().filter(x -> x.contains("target/classes")).toList();
List<String> targetTestClasses = targetClasses.stream().map(x -> x.replace("classes", "test-classes")).toList();
List<String> jars = entireClasspath().stream().filter(x -> x.contains(".jar")).toList();
List<String> jars = classpathEntries.stream().filter(x -> x.contains(".jar")).toList();

List<URL> urls = Stream.of(targetClasses, targetTestClasses, jars).flatMap(List::stream)
.map(x -> toURL(new File(x).toPath().toUri())).toList();
Expand All @@ -62,9 +63,9 @@ public static void main(String[] args) throws Exception {
Launcher launcher = session.getLauncher();
TestPlan testPlan = launcher.discover(request);
testPlan.getRoots().stream().flatMap(x -> testPlan.getChildren(x).stream())
.map(TestIdentifier::getLegacyReportingName).sorted().forEach(test -> {
System.out.println("spring.cloud.k8s.test.to.run -> " + test);
});
.map(TestIdentifier::getLegacyReportingName).sorted().forEach(test ->
System.out.println("spring.cloud.k8s.test.to.run -> " + test)
);
}

}
Expand All @@ -75,7 +76,7 @@ private static void replaceClassloader(List<URL> classpathURLs) {
Thread.currentThread().setContextClassLoader(classLoader);
}

// /tmp/deps.txt are created by the pipeline
// /tmp/deps.txt is created by the pipeline
private static List<String> entireClasspath() throws Exception {
try (Stream<String> lines = Files.lines(Paths.get("/tmp/deps.txt"))) {
return lines.distinct().collect(Collectors.toList());
Expand Down

0 comments on commit 0b50dba

Please sign in to comment.