Description
Now there is a problems with CodeGeneration class: when we create child PythonCodeGenerator we initialize field context twice but at first we assign to this field CgContext with default CgLanguageAssistant (it it JavaLanguageAssistant) and it failing during initialization of field outerMostTestClass in CgContext because of invalid java function call on python oriented class.
To Reproduce
Steps to reproduce the behavior:
- Run the python project in IntelliJ Idea
- Try to use plugin to generate tests
Expected behavior
Tests are supposed to be generated.
Actual behavior
No one test. There are an error in logs.
Visual proofs (screenshots, logs, images)
Example code
def div(a, b):
return a / b
Result log:
ava.lang.ClassNotFoundException: TopLevelFunction PluginClassLoader(plugin=PluginDescriptor(name=UnitTestBot, id=org.utbot.intellij.plugin.id, descriptorPath=plugin.xml, path=~/Projects/utbot3/UTBotJava/utbot-intellij/build/idea-sandbox/plugins/utbot-intellij, version=2023.01-SNAPSHOT, package=null, isBundled=false), packagePrefix=null, instanceId=150, state=active)
at com.intellij.ide.plugins.cl.PluginClassLoader.loadClass(PluginClassLoader.java:214)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at org.utbot.framework.plugin.api.util.IdUtilKt.getJClass(IdUtil.kt:102)
at org.utbot.framework.plugin.api.ClassId.getSimpleNameWithEnclosingClasses(Api.kt:870)
at org.utbot.framework.plugin.api.util.IdUtilKt.getNameWithEnclosingClassesAsContigousString(IdUtil.kt:213)
at org.utbot.framework.plugin.api.utils.CodeLanguageUtilsKt.testClassNameGenerator(CodeLanguageUtils.kt:12)
at org.utbot.framework.codegen.services.language.JavaCgLanguageAssistant.testClassName(JavaCgLanguageAssistant.kt:29)
at org.utbot.framework.codegen.domain.context.CgContext$outerMostTestClass$2.invoke(CgContext.kt:496)
at org.utbot.framework.codegen.domain.context.CgContext$outerMostTestClass$2.invoke(CgContext.kt:495)
at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
at org.utbot.framework.codegen.domain.context.CgContext.getOuterMostTestClass(CgContext.kt:495)
at org.utbot.framework.codegen.domain.context.CgContext.<init>(CgContext.kt:582)
at org.utbot.framework.codegen.domain.context.CgContext.<init>(CgContext.kt:432)
at org.utbot.framework.codegen.CodeGenerator.<init>(CodeGenerator.kt:45)
at org.utbot.framework.codegen.CodeGenerator.<init>(CodeGenerator.kt:26)
at org.utbot.python.framework.codegen.model.PythonCodeGenerator.<init>(PythonCodeGenerator.kt:51)
at org.utbot.python.framework.codegen.model.PythonCodeGenerator.<init>(PythonCodeGenerator.kt:38)
at org.utbot.python.code.PythonCodeGenerator.generateMypyCheckCode(CodeGen.kt:54)
at org.utbot.python.typing.MypyAnnotations$getCheckedByMypyAnnotations$1.invokeSuspend(MypyAnnotations.kt:34)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlin.sequences.SequenceBuilderIterator.hasNext(SequenceBuilder.kt:129)
at org.utbot.python.PythonTestCaseGenerator.generate(PythonTestCaseGenerator.kt:180)
at org.utbot.python.PythonTestGenerationProcessor.processTestGeneration(PythonTestGenerationProcessor.kt:100)
at org.utbot.python.PythonTestGenerationProcessor.processTestGeneration$default(PythonTestGenerationProcessor.kt:34)
at org.utbot.intellij.plugin.language.python.PythonDialogProcessor$createTests$1.run(PythonDialogProcessor.kt:140)
at com.intellij.openapi.progress.impl.CoreProgressManager.startTask(CoreProgressManager.java:442)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.startTask(ProgressManagerImpl.java:114)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcessWithProgressAsynchronously$5(CoreProgressManager.java:493)
at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$3(ProgressRunner.java:252)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:188)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$12(CoreProgressManager.java:608)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:683)
at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:639)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:607)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:60)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:175)
at com.intellij.openapi.progress.impl.ProgressRunner.lambda$submit$4(ProgressRunner.java:252)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
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:833)
Description
Now there is a problems with
CodeGenerationclass: when we create childPythonCodeGeneratorwe initialize fieldcontexttwice but at first we assign to this fieldCgContextwith defaultCgLanguageAssistant(it it JavaLanguageAssistant) and it failing during initialization of fieldouterMostTestClassinCgContextbecause of invalid java function call on python oriented class.To Reproduce
Steps to reproduce the behavior:
Expected behavior
Tests are supposed to be generated.
Actual behavior
No one test. There are an error in logs.
Visual proofs (screenshots, logs, images)
Example code
Result log: