Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wind57 committed Sep 8, 2023
1 parent d8aca5b commit 29f043e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ runs:
shell: bash
run: |
cd spring-cloud-kubernetes-test-support
.././mvnw -q exec:java -Dexec.mainClass="org.springframework.cloud.kubernetes.tests.discovery.TestsDiscovery" > /tmp/tests.txt
.././mvnw -q exec:java -Prun-on-github-actions -Dexec.mainClass="org.springframework.cloud.kubernetes.tests.discovery.TestsDiscovery" > /tmp/tests.txt
cd ..
- name: show result
Expand Down
47 changes: 28 additions & 19 deletions spring-cloud-kubernetes-test-support/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,33 @@

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>org.springframework.cloud.kubernetes.tests.discovery.TestsDiscovery</mainClass>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>run-on-github-actions</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>org.springframework.cloud.kubernetes.tests.discovery.TestsDiscovery</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.junit.platform.engine.discovery.DiscoverySelectors;
import org.junit.platform.launcher.Launcher;
import org.junit.platform.launcher.LauncherDiscoveryRequest;
import org.junit.platform.launcher.LauncherSession;
import org.junit.platform.launcher.TestIdentifier;
import org.junit.platform.launcher.TestPlan;
import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder;
Expand All @@ -57,12 +58,15 @@ public static void main(String[] args) throws Exception {
LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request()
.selectors(DiscoverySelectors.selectClasspathRoots(paths)).build();

Launcher launcher = LauncherFactory.openSession().getLauncher();
TestPlan testPlan = launcher.discover(request);
testPlan.getRoots().stream().flatMap(x -> testPlan.getChildren(x).stream())
try (LauncherSession session = LauncherFactory.openSession()) {
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);
});
}

}

private static void replaceClassloader(List<URL> classpathURLs) {
Expand All @@ -73,7 +77,9 @@ private static void replaceClassloader(List<URL> classpathURLs) {

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

private static URL toURL(URI uri) {
Expand Down

0 comments on commit 29f043e

Please sign in to comment.