From 22edfe999ffcaa69f241c8dd84ed54e0baa4bcf5 Mon Sep 17 00:00:00 2001 From: "Vitaliy.Bibaev" Date: Tue, 6 Mar 2018 17:19:33 +0300 Subject: [PATCH] Ignore reflection usage warnings in outputs for streamex tests --- .../exec/LibraryTraceExecutionTestCase.kt | 23 +++++++++++++++---- .../streams/exec/streamex/StreamExTestCase.kt | 8 ++++--- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/plugins/stream-debugger/test/com/intellij/debugger/streams/exec/LibraryTraceExecutionTestCase.kt b/plugins/stream-debugger/test/com/intellij/debugger/streams/exec/LibraryTraceExecutionTestCase.kt index d04670b59b0d..5386aa4043ac 100644 --- a/plugins/stream-debugger/test/com/intellij/debugger/streams/exec/LibraryTraceExecutionTestCase.kt +++ b/plugins/stream-debugger/test/com/intellij/debugger/streams/exec/LibraryTraceExecutionTestCase.kt @@ -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 } diff --git a/plugins/stream-debugger/test/com/intellij/debugger/streams/exec/streamex/StreamExTestCase.kt b/plugins/stream-debugger/test/com/intellij/debugger/streams/exec/streamex/StreamExTestCase.kt index 58f19fcaef09..e7a00993cee2 100644 --- a/plugins/stream-debugger/test/com/intellij/debugger/streams/exec/streamex/StreamExTestCase.kt +++ b/plugins/stream-debugger/test/com/intellij/debugger/streams/exec/streamex/StreamExTestCase.kt @@ -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 -- 2.32.0