Skip to content

Fix fuzzing enum in recursion #907

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

Merged
merged 2 commits into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import java.lang.reflect.Field
import java.lang.reflect.Member
import java.lang.reflect.Method
import java.lang.reflect.Modifier.*
import org.utbot.framework.plugin.api.util.isEnum

/**
* Creates [UtAssembleModel] for objects which have public constructors
Expand All @@ -42,7 +43,7 @@ class ObjectModelProvider(
description: FuzzedMethodDescription,
classId: ClassId
): List<ModelConstructor> {
if (classId == stringClassId || classId.isPrimitiveWrapper)
if (classId == stringClassId || classId.isPrimitiveWrapper || classId.isEnum || classId.isAbstract)
return listOf()

val constructors = collectConstructors(classId) { javaConstructor ->
Expand Down
28 changes: 12 additions & 16 deletions utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
package org.utbot.contest

import java.io.File
import java.lang.reflect.Method
import java.lang.reflect.Modifier
import java.net.URL
import java.net.URLClassLoader
import java.nio.file.Paths
import kotlin.concurrent.thread
import kotlin.math.max
import kotlin.math.min
import kotlin.reflect.KCallable
import kotlin.reflect.jvm.isAccessible
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.GlobalScope
Expand Down Expand Up @@ -39,8 +50,6 @@ import org.utbot.framework.plugin.api.UtMethodTestSet
import org.utbot.framework.plugin.api.util.UtContext
import org.utbot.framework.plugin.api.util.executableId
import org.utbot.framework.plugin.api.util.id
import org.utbot.framework.plugin.api.util.isConstructor
import org.utbot.framework.plugin.api.util.isEnum
import org.utbot.framework.plugin.api.util.jClass
import org.utbot.framework.plugin.api.util.utContext
import org.utbot.framework.plugin.api.util.withUtContext
Expand All @@ -50,18 +59,6 @@ import org.utbot.instrumentation.ConcreteExecutor
import org.utbot.instrumentation.ConcreteExecutorPool
import org.utbot.instrumentation.Settings
import org.utbot.instrumentation.warmup.Warmup
import java.io.File
import java.lang.reflect.Method
import java.lang.reflect.Modifier
import java.net.URL
import java.net.URLClassLoader
import java.nio.file.Paths
import java.util.concurrent.ConcurrentSkipListSet
import kotlin.concurrent.thread
import kotlin.math.max
import kotlin.math.min
import kotlin.reflect.KCallable
import kotlin.reflect.jvm.isAccessible

internal const val junitVersion = 4
private val logger = KotlinLogging.logger {}
Expand Down Expand Up @@ -396,14 +393,13 @@ private fun prepareClass(javaClazz: Class<*>, methodNameFilter: String?): List<E

//2. all constructors from cut
val constructors =
if (javaClazz.isAbstract) emptyList() else javaClazz.declaredConstructors.filterNotNull()
if (javaClazz.isAbstract || javaClazz.isEnum) emptyList() else javaClazz.declaredConstructors.filterNotNull()

//3. Now join methods and constructors together
val methodsToGenerate = methods.filter { it.isVisibleFromGeneratedTest } + constructors

val classFilteredMethods = methodsToGenerate
.map { it.executableId }
.filterNot { it.isConstructor && it.classId.isEnum }
.filter { methodNameFilter?.equals(it.name) ?: true }
.filterWhen(UtSettings.skipTestGenerationForSyntheticMethods) { !isKnownSyntheticMethod(it) }
.toList()
Expand Down