Skip to content

Commit 22593eb

Browse files
authored
Fix fuzzing enum in recursion (#907)
1 parent 44e1de9 commit 22593eb

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

utbot-fuzzers/src/main/kotlin/org/utbot/fuzzer/providers/ObjectModelProvider.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import java.lang.reflect.Field
2222
import java.lang.reflect.Member
2323
import java.lang.reflect.Method
2424
import java.lang.reflect.Modifier.*
25+
import org.utbot.framework.plugin.api.util.isEnum
2526

2627
/**
2728
* Creates [UtAssembleModel] for objects which have public constructors
@@ -42,7 +43,7 @@ class ObjectModelProvider(
4243
description: FuzzedMethodDescription,
4344
classId: ClassId
4445
): List<ModelConstructor> {
45-
if (classId == stringClassId || classId.isPrimitiveWrapper)
46+
if (classId == stringClassId || classId.isPrimitiveWrapper || classId.isEnum || classId.isAbstract)
4647
return listOf()
4748

4849
val constructors = collectConstructors(classId) { javaConstructor ->

utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
package org.utbot.contest
22

3+
import java.io.File
4+
import java.lang.reflect.Method
5+
import java.lang.reflect.Modifier
6+
import java.net.URL
7+
import java.net.URLClassLoader
8+
import java.nio.file.Paths
9+
import kotlin.concurrent.thread
10+
import kotlin.math.max
11+
import kotlin.math.min
12+
import kotlin.reflect.KCallable
13+
import kotlin.reflect.jvm.isAccessible
314
import kotlinx.coroutines.CancellationException
415
import kotlinx.coroutines.CoroutineScope
516
import kotlinx.coroutines.GlobalScope
@@ -39,8 +50,6 @@ import org.utbot.framework.plugin.api.UtMethodTestSet
3950
import org.utbot.framework.plugin.api.util.UtContext
4051
import org.utbot.framework.plugin.api.util.executableId
4152
import org.utbot.framework.plugin.api.util.id
42-
import org.utbot.framework.plugin.api.util.isConstructor
43-
import org.utbot.framework.plugin.api.util.isEnum
4453
import org.utbot.framework.plugin.api.util.jClass
4554
import org.utbot.framework.plugin.api.util.utContext
4655
import org.utbot.framework.plugin.api.util.withUtContext
@@ -50,18 +59,6 @@ import org.utbot.instrumentation.ConcreteExecutor
5059
import org.utbot.instrumentation.ConcreteExecutorPool
5160
import org.utbot.instrumentation.Settings
5261
import org.utbot.instrumentation.warmup.Warmup
53-
import java.io.File
54-
import java.lang.reflect.Method
55-
import java.lang.reflect.Modifier
56-
import java.net.URL
57-
import java.net.URLClassLoader
58-
import java.nio.file.Paths
59-
import java.util.concurrent.ConcurrentSkipListSet
60-
import kotlin.concurrent.thread
61-
import kotlin.math.max
62-
import kotlin.math.min
63-
import kotlin.reflect.KCallable
64-
import kotlin.reflect.jvm.isAccessible
6562

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

397394
//2. all constructors from cut
398395
val constructors =
399-
if (javaClazz.isAbstract) emptyList() else javaClazz.declaredConstructors.filterNotNull()
396+
if (javaClazz.isAbstract || javaClazz.isEnum) emptyList() else javaClazz.declaredConstructors.filterNotNull()
400397

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

404401
val classFilteredMethods = methodsToGenerate
405402
.map { it.executableId }
406-
.filterNot { it.isConstructor && it.classId.isEnum }
407403
.filter { methodNameFilter?.equals(it.name) ?: true }
408404
.filterWhen(UtSettings.skipTestGenerationForSyntheticMethods) { !isKnownSyntheticMethod(it) }
409405
.toList()

0 commit comments

Comments
 (0)