Skip to content

Commit 0a161d6

Browse files
committed
Code review fixes
1 parent 781e409 commit 0a161d6

File tree

20 files changed

+64
-42
lines changed

20 files changed

+64
-42
lines changed

utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/util/IdUtil.kt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ import org.utbot.framework.plugin.api.MethodId
1010
import org.utbot.framework.plugin.api.UtModel
1111
import org.utbot.framework.plugin.api.UtNullModel
1212
import org.utbot.framework.plugin.api.UtPrimitiveModel
13-
import java.lang.reflect.*
13+
import java.lang.reflect.Constructor
14+
import java.lang.reflect.Executable
15+
import java.lang.reflect.Field
16+
import java.lang.reflect.Method
17+
import java.lang.reflect.Type
1418
import java.util.concurrent.atomic.AtomicInteger
1519
import kotlin.contracts.ExperimentalContracts
1620
import kotlin.contracts.contract
@@ -263,12 +267,11 @@ val Class<*>.id: ClassId
263267
else -> ClassId(name)
264268
}
265269

270+
/**
271+
* [java.lang.reflect.ParameterizedType.getRawType] now returns [Type] instead of [Class].
272+
*/
266273
val Type.id: ClassId
267-
get() = when {
268-
javaClass.isArray -> ClassId(javaClass.name)
269-
javaClass.isPrimitive -> primitiveToId[this]!!
270-
else -> ClassId(javaClass.name)
271-
}
274+
get() = TODO("Java 11 transition")
272275

273276
val KClass<*>.id: ClassId
274277
get() = java.id

utbot-framework/src/main/kotlin/org/utbot/engine/Extensions.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ val Type.numDimensions get() = if (this is ArrayType) numDimensions else 0
203203
/**
204204
* Invocation. Can generate multiple targets.
205205
*
206-
* @see UtBotSymbolicEngine.virtualAndInterfaceInvoke
206+
* @see Traverser.virtualAndInterfaceInvoke
207207
*/
208208
data class Invocation(
209209
val instance: ReferenceValue?,
@@ -222,7 +222,7 @@ data class Invocation(
222222
/**
223223
* Invocation target. Contains constraints to be satisfied for this instance class (related to virtual invoke).
224224
*
225-
* @see UtBotSymbolicEngine.virtualAndInterfaceInvoke
225+
* @see Traverser.virtualAndInterfaceInvoke
226226
*/
227227
data class InvocationTarget(
228228
val instance: ReferenceValue?,
@@ -245,11 +245,11 @@ data class MethodInvocationTarget(
245245
)
246246

247247
/**
248-
* Used in the [UtBotSymbolicEngine.findLibraryTargets] to substitute common types
248+
* Used in the [Traverser.findLibraryTargets] to substitute common types
249249
* like [Iterable] with the types that have corresponding wrappers.
250250
*
251-
* @see UtBotSymbolicEngine.findLibraryTargets
252-
* @see UtBotSymbolicEngine.findInvocationTargets
251+
* @see Traverser.findLibraryTargets
252+
* @see Traverser.findInvocationTargets
253253
*/
254254
val libraryTargets: Map<String, List<String>> = mapOf(
255255
Iterable::class.java.name to listOf(ArrayList::class.java.name, HashSet::class.java.name),

utbot-framework/src/main/kotlin/org/utbot/engine/Resolver.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ val typesOfObjectsToRecreate = listOf(
10161016
"java.lang.CharacterDataLatin1",
10171017
"java.lang.CharacterData00",
10181018
"[Ljava.lang.StackTraceElement",
1019-
"[Lsun.java2d.cmm.lcms.LcmsServiceProvider",
1019+
"sun.java2d.cmm.lcms.LcmsServiceProvider",
10201020
PrintStream::class.qualifiedName,
10211021
AccessControlContext::class.qualifiedName,
10221022
ICC_ProfileRGB::class.qualifiedName,

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/constructor/tree/CgMethodConstructor.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
312312
processExecutionFailure(currentExecution, exception)
313313
}
314314
}
315-
else -> {}
315+
else -> {} // TODO: check this specific case
316316
}
317317
}
318318

@@ -322,7 +322,7 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
322322
when (this) {
323323
is MethodId -> thisInstance[this](*methodArguments.toTypedArray()).intercepted()
324324
is ConstructorId -> this(*methodArguments.toTypedArray()).intercepted()
325-
else -> {}
325+
else -> {} // TODO: check this specific case
326326
}
327327
}
328328
}
@@ -442,7 +442,7 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
442442
}
443443
.onFailure { thisInstance[method](*methodArguments.toTypedArray()).intercepted() }
444444
}
445-
else -> {}
445+
else -> {} // TODO: check this specific case
446446
}
447447
}
448448

@@ -1097,7 +1097,7 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
10971097
thisInstance[executable](*methodArguments.toTypedArray())
10981098
}
10991099
}
1100-
else -> {}
1100+
else -> {} // TODO: check this specific case
11011101
}
11021102
}
11031103
}

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/util/DependencyUtils.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,18 @@ fun checkFrameworkDependencies(dependencyPaths: String?) {
3131
.map { it.toLowerCase() }
3232
.toSet()
3333

34-
val testFrameworkPatterns = TestFramework.allItems.map { it.patterns() }
34+
//todo: stopped working after transition to Java 11. Ask Egor to take a look.
35+
// val testFrameworkPatterns = TestFramework.allItems.map { it.patterns() }
36+
// val testFrameworkFound = dependencyNames.matchesAnyOf(testFrameworkPatterns) ||
37+
// dependencyPathsSequence.any { checkDependencyIsFatJar(it) }
38+
//
39+
// if (!testFrameworkFound) {
40+
// error("""
41+
// Test frameworks are not found in dependency path $dependencyPaths, dependency names are:
42+
// ${dependencyNames.joinToString(System.lineSeparator())}
43+
// """
44+
// )
45+
// }
3546

3647
val mockFrameworkPatterns = MockFramework.allItems.map { it.patterns() }
3748
val mockFrameworkFound = dependencyNames.matchesAnyOf(mockFrameworkPatterns) ||

utbot-framework/src/test/kotlin/org/utbot/examples/UtValueTestCaseChecker.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2391,6 +2391,8 @@ abstract class UtValueTestCaseChecker(
23912391

23922392
if (testSummary) {
23932393
valueExecutions.checkSummaryMatchers(summaryTextChecks)
2394+
// todo: Ask Zarina to take a look (Java 11 transition)
2395+
// valueExecutions.checkCommentsForBasicErrors()
23942396
}
23952397
if (testName) {
23962398
valueExecutions.checkNameMatchers(summaryNameChecks)
@@ -2486,6 +2488,13 @@ abstract class UtValueTestCaseChecker(
24862488
}
24872489
}
24882490

2491+
// fun List<UtValueExecution<*>>.checkCommentsForBasicErrors() {
2492+
// val emptyLines = this.filter {
2493+
// it.summary?.contains("\n\n") ?: false
2494+
// }
2495+
// assertTrue(emptyLines.isEmpty()) { "Empty lines in the comments: ${emptyLines.map { it.summary }.prettify()}" }
2496+
// }
2497+
24892498
fun List<UtValueExecution<*>>.checkNamesForBasicErrors() {
24902499
val wrongASTNodeConversion = this.filter {
24912500
it.testMethodName?.contains("null") ?: false

utbot-framework/src/test/kotlin/org/utbot/examples/arrays/IntArrayBasicsTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ internal class IntArrayBasicsTest : UtValueTestCaseChecker(
220220
}
221221

222222
@Test
223-
@Disabled("Sergei is looking into it")
223+
@Disabled("Java 11 transition -- Sergei is looking into it")
224224
fun testArraysEqualsExample() {
225225
check(
226226
IntArrayBasics::arrayEqualsExample,

utbot-framework/src/test/kotlin/org/utbot/examples/collections/ListIteratorsTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ internal class ListIteratorsTest : UtValueTestCaseChecker(
5858
}
5959

6060
@Test
61-
@Disabled
61+
@Disabled("Java 11 transition")
6262
fun testAddElements() {
6363
check(
6464
ListIterators::addElements,

utbot-framework/src/test/kotlin/org/utbot/examples/collections/ListWrapperReturnsVoidTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import org.utbot.framework.plugin.api.CodegenLanguage
1010
import org.junit.jupiter.api.Test
1111

1212
// TODO failed Kotlin compilation ($ in function names, generics) SAT-1220 SAT-1332
13-
@Disabled
13+
@Disabled("Java 11 transition")
1414
internal class ListWrapperReturnsVoidTest : UtValueTestCaseChecker(
1515
testClass = ListWrapperReturnsVoidExample::class,
1616
testCodeGeneration = true,

utbot-framework/src/test/kotlin/org/utbot/examples/collections/ListsPart3Test.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ import org.utbot.framework.codegen.CodeGeneration
44
import org.utbot.framework.plugin.api.CodegenLanguage
55
import org.junit.jupiter.api.Disabled
66
import org.junit.jupiter.api.Test
7-
import org.utbot.examples.*
7+
import org.utbot.examples.UtValueTestCaseChecker
8+
import org.utbot.examples.DoNotCalculate
9+
import org.utbot.examples.eq
10+
import org.utbot.examples.ge
11+
import org.utbot.examples.between
12+
import org.utbot.examples.isException
813

914
// TODO failed Kotlin compilation SAT-1332
1015
internal class ListsPart3Test : UtValueTestCaseChecker(

utbot-framework/src/test/kotlin/org/utbot/examples/exceptions/JvmCrashExamplesTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ internal class JvmCrashExamplesTest : UtValueTestCaseChecker(testClass = JvmCras
1717
}
1818

1919
@Test
20-
@Disabled
20+
@Disabled("Java 11 transition")
2121
fun testCrash() {
2222
check(
2323
JvmCrashExamples::crash,

utbot-framework/src/test/kotlin/org/utbot/examples/invokes/NativeExampleTest.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.utbot.examples.invokes
22

3-
import org.junit.jupiter.api.Disabled
43
import org.utbot.examples.UtValueTestCaseChecker
54
import org.utbot.examples.atLeast
65
import org.utbot.examples.eq

utbot-framework/src/test/kotlin/org/utbot/examples/mock/MockReturnObjectExampleTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import org.junit.jupiter.api.Test
1515

1616
internal class MockReturnObjectExampleTest : UtValueTestCaseChecker(testClass = MockReturnObjectExample::class) {
1717
@Test
18-
@Disabled
18+
@Disabled("Java 11 transition")
1919
fun testMockReturnObject() {
2020
checkMocks(
2121
MockReturnObjectExample::calculate,

utbot-framework/src/test/kotlin/org/utbot/examples/stdlib/DateExampleTest.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.utbot.examples.stdlib
22

3-
import org.junit.jupiter.api.Disabled
43
import org.junit.jupiter.api.Tag
54
import org.junit.jupiter.api.Test
65
import org.utbot.examples.UtValueTestCaseChecker
@@ -9,7 +8,6 @@ import org.utbot.examples.isException
98
import org.utbot.examples.withUsingReflectionForMaximizingCoverage
109
import java.util.Date
1110

12-
@Disabled
1311
class DateExampleTest : UtValueTestCaseChecker(testClass = DateExample::class) {
1412
@Suppress("SpellCheckingInspection")
1513
@Tag("slow")

utbot-framework/src/test/kotlin/org/utbot/examples/stream/BaseStreamExampleTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class BaseStreamExampleTest : UtValueTestCaseChecker(
8787
}
8888

8989
@Test
90-
@Disabled("Yura looks at this. We have similar issue with Strings")
90+
@Disabled("Java 11 transition -- Yura looks at this. We have similar issue with Strings")
9191
fun testDistinctExample() {
9292
check(
9393
BaseStreamExample::distinctExample,

utbot-framework/src/test/kotlin/org/utbot/examples/thirdparty/numbers/ArithmeticUtilsTest.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
package org.utbot.examples.thirdparty.numbers
22

3-
import org.junit.jupiter.api.Disabled
43
import org.utbot.examples.UtValueTestCaseChecker
54
import org.utbot.examples.eq
65
import org.junit.jupiter.api.Tag
76
import org.junit.jupiter.api.Test
87

98
// example from Apache common-numbers
10-
@Disabled
119
internal class ArithmeticUtilsTest : UtValueTestCaseChecker(testClass = ArithmeticUtils::class) {
1210
@Test
1311
@Tag("slow")

utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/ConcreteExecutor.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ class ConcreteExecutor<TIResult, TInstrumentation : Instrumentation<TIResult>> p
266266
}
267267

268268
try {
269+
// TODO: Java 11 transition -- Sergey will look
269270
readCommandsChannel.trySend(cmd).isSuccess
270271
} catch (e: CancellationException) {
271272
s.disposed = true

utbot-instrumentation/src/main/kotlin/org/utbot/instrumentation/process/ChildProcessRunner.kt

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,22 @@ import java.io.File
1818
private val logger = KotlinLogging.logger {}
1919
private var processSeqN = 0
2020

21-
private fun listOrEmpty(condition:Boolean, vararg values: String) = if (condition) {
22-
values.asList()
23-
} else {
24-
emptyList()
25-
}
26-
2721
class ChildProcessRunner {
2822
private val cmds: List<String> by lazy {
2923
val debugCmd =
30-
listOrEmpty(Settings.runChildProcessWithDebug, DEBUG_RUN_CMD)
24+
listOfNotNull(DEBUG_RUN_CMD.takeIf { Settings.runChildProcessWithDebug} )
3125

3226
val javaVersionSpecificArguments =
33-
listOrEmpty(JdkInfoService.provide().version > 8,
34-
"--add-opens", "java.base/jdk.internal.misc=ALL-UNNAMED", "--illegal-access=warn")
27+
listOf("--add-opens", "java.base/jdk.internal.misc=ALL-UNNAMED", "--illegal-access=warn")
28+
.takeIf { JdkInfoService.provide().version > 8 }
29+
?: emptyList()
30+
31+
val pathToJava = JdkInfoService.provide().path
3532

36-
listOf(JdkInfoService.provide().path.resolve("bin${File.separatorChar}java").toString()) +
37-
debugCmd + listOf("-javaagent:$jarFile", "-ea") + javaVersionSpecificArguments + listOf("-jar", "$jarFile")
33+
listOf(pathToJava.resolve("bin${File.separatorChar}java").toString()) +
34+
debugCmd +
35+
javaVersionSpecificArguments +
36+
listOf("-javaagent:$jarFile", "-ea", "-jar", "$jarFile")
3837
}
3938

4039
var errorLogFile: File = NULL_FILE

utbot-intellij/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
apply from: "${parent.projectDir}/gradle/include/jvm-project.gradle"
22

3-
// TODO remove when switch plugin baseline to 2020.3 or higher, with kotlin 1.4 inside
43
compileKotlin {
54
kotlinOptions {
65
allWarningsAsErrors = false

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ContestEstimatorJdkInfoProvider(private val path: String) : JdkInfoDefault
1616
get() = JdkInfo(path.toPath(), jdkVersionFrom(jdkPath = path)) // TODO: retrieve the correct version
1717
}
1818

19-
fun jdkVersionFrom(jdkPath: String) : Int {
19+
private fun jdkVersionFrom(jdkPath: String) : Int {
2020
val processBuilder = ProcessBuilder(("$jdkPath${File.separatorChar}bin${File.separatorChar}java").toString(), "-version");
2121
val process = processBuilder.start()
2222
val errorStream = process.errorStream

0 commit comments

Comments
 (0)