Browse Source

Normalize paths for stable plugin test (#90811)

gradle on windows does not like \. Normalized method should replace it with /
closes #90793
Przemyslaw Gomulka 3 years ago
parent
commit
9bebec2868

+ 3 - 3
build-tools/src/integTest/groovy/org/elasticsearch/gradle/plugin/StableBuildPluginPluginFuncTest.groovy → build-tools/src/integTest/groovy/org/elasticsearch/gradle/plugin/StablePluginBuildPluginFuncTest.groovy

@@ -19,7 +19,7 @@ import java.nio.file.Files
 import java.nio.file.Path
 import java.util.stream.Collectors
 
-class StableBuildPluginPluginFuncTest extends AbstractGradleFuncTest {
+class StablePluginBuildPluginFuncTest extends AbstractGradleFuncTest {
 
     def setup() {
         // underlaying TestClusterPlugin and StandaloneRestIntegTestTask are not cc compatible
@@ -78,8 +78,8 @@ class StableBuildPluginPluginFuncTest extends AbstractGradleFuncTest {
             }
 
             dependencies {
-                implementation files('${StableApiJarMocks.createPluginApiJar(jarFolder.toPath()).toAbsolutePath()}')
-                implementation files('${StableApiJarMocks.createExtensibleApiJar(jarFolder.toPath()).toAbsolutePath()}')
+                implementation files('${normalized(StableApiJarMocks.createPluginApiJar(jarFolder.toPath()).toAbsolutePath().toString())}')
+                implementation files('${normalized(StableApiJarMocks.createExtensibleApiJar(jarFolder.toPath()).toAbsolutePath().toString())}')
             }
 
             """

+ 8 - 2
build-tools/src/test/groovy/org/elasticsearch/gradle/plugin/scanner/ClassScannerSpec.groovy

@@ -15,13 +15,14 @@ import org.hamcrest.Matchers
 import org.objectweb.asm.ClassReader
 import org.objectweb.asm.Type
 
-import java.nio.file.Path
 import java.nio.file.Paths
+import java.util.stream.Collectors
 import java.util.stream.Stream
 
 import static org.hamcrest.MatcherAssert.assertThat
 
 class ClassScannerSpec extends Specification {
+    static final System.Logger logger = System.getLogger(ClassScannerSpec.class.getName())
     def "class and interface hierarchy is scanned"() {
         given:
         def reader = new ClassScanner(
@@ -31,6 +32,7 @@ class ClassScannerSpec extends Specification {
         }
         )
         Stream<ClassReader> classReaderStream = ofClassPath()
+        logger.log(System.Logger.Level.INFO, "classReaderStream size "+ofClassPath().collect(Collectors.toList()).size())
 
         when:
         reader.visit(classReaderStream);
@@ -58,12 +60,16 @@ class ClassScannerSpec extends Specification {
 
     static Stream<ClassReader> ofClassPath() throws IOException {
         String classpath = System.getProperty("java.class.path");
+        logger.log(System.Logger.Level.INFO, "classpath "+classpath);
         return ofClassPath(classpath);
     }
 
     static Stream<ClassReader> ofClassPath(String classpath) {
         if (classpath != null && classpath.equals("") == false) {// todo when do we set cp to "" ?
-            String[] pathelements = classpath.split(":");
+            def classpathSeparator = System.getProperty("path.separator")
+            logger.log(System.Logger.Level.INFO, "classpathSeparator "+classpathSeparator);
+
+            String[] pathelements = classpath.split(classpathSeparator);
             return ClassReaders.ofPaths(Arrays.stream(pathelements).map(Paths::get));
         }
         return Stream.empty();