-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kex Integration #294
base: development
Are you sure you want to change the base?
Kex Integration #294
Conversation
Needs debugging and testing * load kex-runner jar from github (build.gradle.kts toplevel) * setup code for kex properties * KexErrorManager based on LLMErrorManager * KexProcessManager based on EvoSuiteProcessManager * Basic UI element (button for running kex) * kex works only for the class codeType (todo funciton and line if possible) * read resource files kex.policy and modules.info
use a provided kex path for now instead of downloading jar and adding dependency use ProcessBuilder (jdk) instead of OSProcessHandler (IJ sdk) use kex.py instead of building java command directly generate Report objects by reading generated java classes
Deleted stuff: running Kex through through OSProcessHandler (IJ sdk) running Kex with kex.py downloading kex from github in build.gradle.kts
arguably overkill solution of modify PsiMethodWrapper class added parameter names, types and return tyepes explicitly updated implementation for java and kotlin
e623ee7
to
237e549
Compare
935b0c9
to
b766057
Compare
…' into edwin1729/improvement/kex-integration
For multimodule projects using TestSpark the correct module's build directory path is passed based on the location of code for which tests are generated
also fixed a bug with the way options were passed to kex subprocess made them a list of strings instead of a single big space separated string
This also includes a simple string based mapping to jvm types through type erasure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some error during the test generation, should I set up something in the settings?
The error stack:
java.io.FileNotFoundException: /Users/arkadii.sapozhnikov/.cache/JetBrains/TestSpark/kex/runtime-deps/modules.info (No such file or directory)
at java.base/java.io.FileInputStream.open0(Native Method)
at java.base/java.io.FileInputStream.open(FileInputStream.java:216)
at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
at kotlin.io.FilesKt__FileReadWriteKt.forEachLine(FileReadWrite.kt:190)
at kotlin.io.FilesKt__FileReadWriteKt.readLines(FileReadWrite.kt:219)
at kotlin.io.FilesKt__FileReadWriteKt.readLines$default(FileReadWrite.kt:217)
at org.jetbrains.research.testspark.tools.kex.KexSettingsArguments.setAddOpensArgs(KexSettingsArguments.kt:42)
at org.jetbrains.research.testspark.tools.kex.KexSettingsArguments.buildCommand(KexSettingsArguments.kt:26)
at org.jetbrains.research.testspark.tools.kex.generation.KexProcessManager.runTestGenerator(KexProcessManager.kt:126)
at org.jetbrains.research.testspark.tools.Pipeline$runTestGeneration$1.run(Pipeline.kt:95)
at com.intellij.openapi.progress.impl.CoreProgressManager.startTask(CoreProgressManager.java:477)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.startTask(ProgressManagerImpl.java:133)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressAsynchronously$6(CoreProgressManager.java:528)
at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:250)
at com.intellij.openapi.progress.ProgressManager.lambda$runProcess$0(ProgressManager.java:100)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:221)
at com.intellij.platform.diagnostic.telemetry.helpers.TraceKt.use(trace.kt:46)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:220)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:660)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:735)
at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:691)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:659)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:79)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:202)
at com.intellij.openapi.progress.ProgressManager.runProcess(ProgressManager.java:100)
at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$5(ProgressRunner.java:250)
at com.intellij.openapi.progress.impl.ProgressRunner$ProgressRunnable.run(ProgressRunner.java:500)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
at java.base/java.lang.Thread.run(Thread.java:840)
Not sure why this is happening. That file was supposed to be downloaded from the github release. Could you maybe try this alternative to using the |
I'd like to postpone this for later. Kex generates tests from the compiled |
Closes #328 |
This is expected by TestSpark. Relevant file TestProcess.kt:createXmlFromJacoco:109
Integrating Kex (Symbolic Execution) into TestSpark
Generates test cases using Kex and displays them in the TestSpark tool window
Summary of changes
The integration of kex follows the example of EvoSuite and LLM for teh most part, so I highlight just the kex specific parts.
Automatic folding (hiding behind
...
) of all code other than test annotated methods in the tool window is implemented. This is using thePsiFile
for each test casePsiMethodWrapper
(and implementations) because kex requires specification of the method for which tests are generated in a specific format. Namely it involves FQNs and an example is given here:org.example.Matrix::product(org.example.Matrix,java.util.function.BinaryOperator,java.util.function.BinaryOperator):org.example.Matrix
Note also that types have been erased. Kex expects JVM types which is easy to get from Java types but not from kotlin. For this reason kotlin is not yet supported by kex.