Ignore reflection usage warnings in outputs for streamex tests
authorVitaliy.Bibaev <vitaliy.bibaev@jetbrains.com>
Tue, 6 Mar 2018 14:19:33 +0000 (17:19 +0300)
committerVitaliy.Bibaev <vitaliy.bibaev@jetbrains.com>
Tue, 6 Mar 2018 16:15:55 +0000 (19:15 +0300)
plugins/stream-debugger/test/com/intellij/debugger/streams/exec/LibraryTraceExecutionTestCase.kt
plugins/stream-debugger/test/com/intellij/debugger/streams/exec/streamex/StreamExTestCase.kt

index d04670b59b0dd68cde532568935e2213114392e8..5386aa4043ac6bc62ae2825ef0ad7db4db446a8b 100644 (file)
@@ -5,31 +5,44 @@ import com.intellij.debugger.streams.test.TraceExecutionTestCase
 import com.intellij.execution.configurations.JavaParameters
 import com.intellij.openapi.application.ApplicationManager
 import com.intellij.openapi.application.PluginPathManager
+import com.intellij.openapi.util.SystemInfo
+import com.intellij.openapi.util.io.FileUtil
+import com.intellij.openapi.util.text.StringUtil
 import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess
 import com.intellij.testFramework.PsiTestUtil
 import java.io.File
+import java.nio.file.Paths
 
 /**
  * @author Vitaliy.Bibaev
  */
-abstract class LibraryTraceExecutionTestCase(private val jarName: String) : TraceExecutionTestCase() {
+abstract class LibraryTraceExecutionTestCase(jarName: String) : TraceExecutionTestCase() {
   private val libraryDirectory = File(PluginPathManager.getPluginHomePath("stream-debugger") + "/lib").absolutePath
+  private val jarPath = Paths.get(libraryDirectory, jarName).toAbsolutePath().toString()
+
+  private companion object {
+    fun String.replaceLibraryPath(libraryPath: String): String {
+      val caseSensitive = SystemInfo.isFileSystemCaseSensitive
+      val result = StringUtil.replace(this, FileUtil.toSystemDependentName(libraryPath), "!LIBRARY_JAR!", !caseSensitive)
+      return StringUtil.replace(result, FileUtil.toSystemIndependentName(libraryPath), "!LIBRARY_JAR!", !caseSensitive)
+    }
+  }
+
   override fun setUpModule() {
     super.setUpModule()
     ApplicationManager.getApplication().runWriteAction {
       VfsRootAccess.allowRootAccess(libraryDirectory)
-      PsiTestUtil.addLibrary(myModule, "$libraryDirectory/$jarName")
+      PsiTestUtil.addLibrary(myModule, jarPath)
     }
   }
 
   override fun replaceAdditionalInOutput(str: String): String {
-    return super.replaceAdditionalInOutput(str)
-      .replaceFirst("$libraryDirectory/$jarName", "!LIBRARY_JAR!")
+    return super.replaceAdditionalInOutput(str).replaceLibraryPath(jarPath)
   }
 
   override fun createJavaParameters(mainClass: String?): JavaParameters {
     val parameters = super.createJavaParameters(mainClass)
-    parameters.classPath.add("$libraryDirectory/$jarName")
+    parameters.classPath.add(jarPath)
     return parameters
   }
 
index 58f19fcaef09cf18df2a211101017c1a4c56e722..e7a00993cee2c85cf838ce97d9edccdf2e88a5bd 100644 (file)
@@ -12,8 +12,8 @@ abstract class StreamExTestCase : LibraryTraceExecutionTestCase("streamex-0.6.5.
   private companion object {
     const val STREAM_EX_REFLECTION_WARNING_MESSAGE =
       "WARNING: An illegal reflective access operation has occurred\n" +
-      "WARNING: Illegal reflective access by one.util.streamex.StreamExInternals (file:/C:/Projects/IDEA/community/plugins/" +
-      "stream-debugger/lib/streamex-0.6.5.jar) to field java.util.stream.AbstractPipeline.sourceSpliterator\n" +
+      "WARNING: Illegal reflective access by one.util.streamex.StreamExInternals (file:!LIBRARY_JAR!) to field " +
+      "java.util.stream.AbstractPipeline.sourceSpliterator\n" +
       "WARNING: Please consider reporting this to the maintainers of one.util.streamex.StreamExInternals\n" +
       "WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations\n" +
       "WARNING: All illegal access operations will be denied in a future release\n"
@@ -26,7 +26,9 @@ abstract class StreamExTestCase : LibraryTraceExecutionTestCase("streamex-0.6.5.
   }
 
   override fun replaceAdditionalInOutput(str: String): String {
-    return super.replaceAdditionalInOutput(str).replace(STREAM_EX_REFLECTION_WARNING_MESSAGE, "")
+    return super.replaceAdditionalInOutput(str)
+      .replace("file:/!LIBRARY_JAR!", "file:!LIBRARY_JAR!")
+      .replace(STREAM_EX_REFLECTION_WARNING_MESSAGE, "")
   }
 
   private val className: String