Skip to content

First adoption of JCDB #669

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
wants to merge 54 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
ddf94a8
switching to jcdb. initial commit for #349
lehvolk Jul 25, 2022
6fe710e
switching to jcdb: switching to jcdb ClassId #349
lehvolk Jul 27, 2022
403b01b
switching to jcdb: another portion #349
lehvolk Jul 27, 2022
d8966ad
switching to jcdb: another portion #349
lehvolk Jul 27, 2022
0ef4583
switching to jcdb: another portion #349
lehvolk Jul 28, 2022
79ba353
Merge branch 'main' into feature-jclass-remove
lehvolk Jul 28, 2022
1365d22
switching to jcdb: another portion #349
lehvolk Jul 28, 2022
d4af361
Change signature in CodeGenerator.kt
sergeypospelov Jul 29, 2022
d85f1fa
switching to jcdb: another portion #349
lehvolk Jul 29, 2022
2c5debd
Fix usages in ObjectModelProvider
sergeypospelov Jul 29, 2022
0bb6a05
Merge remote-tracking branch 'origin/feature-jclass-remove' into feat…
sergeypospelov Jul 29, 2022
3837280
Remove FieldId.field
sergeypospelov Jul 29, 2022
943d1cc
Remove jClass usage from Traverser.kt
sergeypospelov Jul 29, 2022
2a73f74
Java 11 migration
denis-fokin Jul 29, 2022
3e492c2
Java 11 migration
denis-fokin Jul 29, 2022
6978c9b
Java 11 migration
denis-fokin Jul 29, 2022
343937b
Java 11 migration
denis-fokin Jul 29, 2022
0c7a604
Sergey's tests
denis-fokin Jul 29, 2022
d4cf9e1
Sergey's tests
denis-fokin Jul 29, 2022
aa6a2c5
Disable instrumentation test
denis-fokin Jul 29, 2022
396f405
Update build-and-run-tests-from-branch.yml
denis-fokin Jul 31, 2022
4b67dfe
Disable test
bissquit Aug 1, 2022
c6a33e1
remove extra options
denis-fokin Aug 1, 2022
e2cc085
Build projects in parallel
viktoriia-fomina Aug 1, 2022
8742273
Build projects in parallel
viktoriia-fomina Aug 1, 2022
fc660af
Update build-and-run-tests-from-branch.yml
viktoriia-fomina Aug 1, 2022
4c9a2ce
out-of-process
denis-fokin Aug 1, 2022
da6dc90
Update publish-plugin-and-cli-from-branch.yml
viktoriia-fomina Aug 1, 2022
2ae17c2
Remove maven
denis-fokin Aug 1, 2022
b77ab34
switching to jcdb: another portion #349
lehvolk Aug 1, 2022
1f31d3c
Framework tests run in parallel
viktoriia-fomina Aug 2, 2022
2c36e0f
Merge remote-tracking branch 'origin/feature-jclass-remove' into feat…
sergeypospelov Aug 2, 2022
6db088e
Merge branch 'main' into feature-jclass-remove
lehvolk Aug 2, 2022
62836de
Add self-hosted runners
viktoriia-fomina Aug 2, 2022
000818d
merge main + another portion #349
lehvolk Aug 2, 2022
baefad4
Merge remote-tracking branch 'origin/feature-jclass-remove' into feat…
lehvolk Aug 2, 2022
10ed40e
Create build-and-run-tests-java11
viktoriia-fomina Aug 2, 2022
b1ccc41
Build and run tests with java 11
viktoriia-fomina Aug 2, 2022
0d5418a
Stacktrace, debug
denis-fokin Aug 2, 2022
c865d43
Upgrade junit
denis-fokin Aug 3, 2022
a92ecbf
Remove debug
denis-fokin Aug 3, 2022
915d953
Disable a couple of tests
denis-fokin Aug 3, 2022
e9883ca
Memory options
denis-fokin Aug 3, 2022
4e9decc
merge main + refactor codegen from ClassId to CgClassType #349
lehvolk Aug 3, 2022
22e7767
Merge branch 'feature-jclass-remove' into feature-kotlin17-with-jclass
lehvolk Aug 3, 2022
6926184
- code compiles
lehvolk Aug 4, 2022
e36ab4a
Merge branch 'main' into feature-kotlin17-with-jclass
lehvolk Aug 5, 2022
848c1cf
- merge `main` branch
lehvolk Aug 5, 2022
272400a
- cleanup some code
lehvolk Aug 5, 2022
a24583d
Fix tests
sergeypospelov Aug 16, 2022
cb19678
Merge branch 'main' into feature-kotlin17-with-jclass
lehvolk Aug 22, 2022
f3b4c67
cleanup
lehvolk Aug 23, 2022
c12d032
Merge branch 'main' into feature-kotlin17-with-jclass
lehvolk Aug 23, 2022
e041973
fix compile
lehvolk Aug 23, 2022
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
12 changes: 6 additions & 6 deletions .github/workflows/build-and-run-tests-from-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ jobs:
steps:
- name: Print environment variables
run: printenv

- name: Checkout repository
uses: actions/checkout@v3

- name: Check out ${{ github.event.inputs.commit_sha }} commit
if: github.event.inputs.commit_sha != ''
run: |
Expand All @@ -47,10 +47,10 @@ jobs:
echo $TASKS
framework:
# This job does not need to wait for 'prepare-tests-matrix' result.
# GitHub allocates runners portionally. Framework tests are time consuming. That's why we want to force them
# GitHub allocates runners portionally. Framework tests are time consuming. That's why we want to force them
# to start execution early.
needs: prepare-tests-matrix
# Using matrices let create multiple jobs runs based on the combinations of the variables from matrices.
# Using matrices let create multiple jobs runs based on the combinations of the variables from matrices.
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
strategy:
# The option forces to execute all jobs even though some of them have failed.
Expand All @@ -61,7 +61,7 @@ jobs:
steps:
- name: Print environment variables
run: printenv

- name: Checkout repository
uses: actions/checkout@v3

Expand Down Expand Up @@ -103,7 +103,7 @@ jobs:

project:
needs: prepare-tests-matrix
# Using matrices let create multiple jobs runs based on the combinations of the variables from matrices.
# Using matrices let create multiple jobs runs based on the combinations of the variables from matrices.
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
strategy:
# The option forces to execute all jobs even though some of them have failed.
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/build-and-run-tests-java11
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: "[M] UTBot Java (11): build and run tests"

on:
workflow_dispatch

jobs:
build-and-run-tests:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'zulu'
java-package: jdk+fx
cache: gradle
- uses: gradle/gradle-build-action@v2
with:
gradle-version: 7.4.2

- name: Build and run tests in UTBot Java
run: |
export KOTLIN_HOME="/usr"
gradle clean build --no-daemon

- name: Upload utbot-framework logs
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: utbot_framework_logs
path: utbot-framework/logs/*

- name: Upload utbot-framework tests report artifacts if tests have failed
if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: utbot_framework_tests_report
path: utbot-framework/build/reports/tests/test/*

- name: Upload utbot-intellij tests report artifacts if tests have failed
if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: utbot_intellij_tests_report
path: utbot-intellij/build/reports/tests/test/*
14 changes: 7 additions & 7 deletions utbot-analytics/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ compileKotlin.dependsOn project(':utbot-instrumentation').tasks.jar
compileTestJava.dependsOn tasks.getByPath(':utbot-framework:testClasses')

dependencies {
implementation(project(":utbot-api"))
implementation(project(":utbot-core"))
implementation(project(":utbot-summary"))
implementation(project(":utbot-framework-api"))
implementation(project(":utbot-fuzzers"))
implementation(project(":utbot-instrumentation"))
implementation(project(":utbot-framework"))
implementation project(":utbot-api")
implementation project(":utbot-core")
implementation project(":utbot-summary")
implementation project(":utbot-framework-api")
implementation project(":utbot-fuzzers")
implementation project(":utbot-instrumentation")
implementation project(":utbot-framework")
testImplementation project(':utbot-sample')
testImplementation group: 'junit', name: 'junit', version: junit4_version

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ import com.github.ajalt.clikt.parameters.arguments.argument
import com.github.ajalt.clikt.parameters.options.default
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.types.choice
import kotlinx.coroutines.runBlocking
import mu.KotlinLogging
import org.utbot.cli.util.createClassLoader
import org.utbot.engine.Mocker
import org.utbot.framework.plugin.api.ClassId
import org.utbot.framework.plugin.api.CodegenLanguage
import org.utbot.framework.plugin.api.util.UtContext
import org.utbot.framework.plugin.api.util.utContext
import org.utbot.framework.plugin.api.util.withUtContext
import java.io.File
import java.net.URLClassLoader
import java.nio.file.Paths
import java.time.temporal.ChronoUnit
import kotlin.reflect.KClass
import kotlin.reflect.jvm.jvmName
import mu.KotlinLogging


private val logger = KotlinLogging.logger {}
Expand Down Expand Up @@ -66,7 +67,7 @@ class BunchTestGeneratorCommand : GenerateTestsAbstractCommand(
}
}

override fun run() {
override fun run() = runBlocking {
val classesFromPath = loadClassesFromPath(classLoader, classRootDirectory)
classesFromPath.filterNot { it.java.isInterface }.filter { clazz ->
clazz.qualifiedName != null
Expand All @@ -84,7 +85,7 @@ class BunchTestGeneratorCommand : GenerateTestsAbstractCommand(
}
}

private fun generateTestsForClass(targetClassFqn: String) {
private suspend fun generateTestsForClass(targetClassFqn: String) {
val started = now()
val workingDirectory = getWorkingDirectory(targetClassFqn)
?: throw IllegalStateException("Error: Cannot find the target class in the classpath")
Expand All @@ -109,7 +110,7 @@ class BunchTestGeneratorCommand : GenerateTestsAbstractCommand(
targetMethods,
searchDirectory = workingDirectory,
chosenClassesToMockAlways = (Mocker.defaultSuperClassesToMockAlwaysNames + classesToMockAlways)
.mapTo(mutableSetOf()) { ClassId(it) }
.mapNotNullTo(mutableSetOf()) { utContext.classpath.findClassOrNull(it) }
)

val testClassBody = generateTest(classUnderTest, testClassName, testSets)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package org.utbot.cli

import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.parameters.options.check
import com.github.ajalt.clikt.parameters.options.default
import com.github.ajalt.clikt.parameters.options.multiple
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.options.unique
import com.github.ajalt.clikt.parameters.options.*
import com.github.ajalt.clikt.parameters.types.choice
import com.github.ajalt.clikt.parameters.types.long
import mu.KotlinLogging
Expand All @@ -16,20 +12,11 @@ import org.utbot.common.PathUtil.toURL
import org.utbot.common.toPath
import org.utbot.engine.Mocker
import org.utbot.framework.UtSettings
import org.utbot.framework.codegen.ForceStaticMocking
import org.utbot.framework.codegen.MockitoStaticMocking
import org.utbot.framework.codegen.NoStaticMocking
import org.utbot.framework.codegen.StaticsMocking
import org.utbot.framework.codegen.*
import org.utbot.framework.codegen.model.CodeGenerator
import org.utbot.framework.codegen.testFrameworkByName
import org.utbot.framework.plugin.api.ClassId
import org.utbot.framework.plugin.api.CodegenLanguage
import org.utbot.framework.plugin.api.MockStrategyApi
import org.utbot.framework.plugin.api.TreatOverflowAsError
import org.utbot.framework.plugin.api.TestCaseGenerator
import org.utbot.framework.plugin.api.UtMethod
import org.utbot.framework.plugin.api.UtMethodTestSet
import org.utbot.framework.plugin.api.*
import org.utbot.framework.plugin.api.util.id
import org.utbot.jcdb.api.ClassId
import org.utbot.summary.summarize
import java.io.File
import java.lang.reflect.Method
Expand Down Expand Up @@ -206,7 +193,7 @@ abstract class GenerateTestsAbstractCommand(name: String, help: String) :
forceStaticMocking == ForceStaticMocking.FORCE && staticsMocking is NoStaticMocking
return CodeGenerator(
testFramework = testFrameworkByName(testFramework),
classUnderTest = classUnderTest.id,
classUnderTest = classUnderTest.java.id,
codegenLanguage = codegenLanguage,
staticsMocking = staticsMocking,
forceStaticMocking = forceStaticMocking,
Expand Down
21 changes: 9 additions & 12 deletions utbot-cli/src/main/kotlin/org/utbot/cli/GenerateTestsCommand.kt
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
package org.utbot.cli

import com.github.ajalt.clikt.parameters.arguments.argument
import com.github.ajalt.clikt.parameters.options.check
import com.github.ajalt.clikt.parameters.options.default
import com.github.ajalt.clikt.parameters.options.flag
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.options.required
import com.github.ajalt.clikt.parameters.options.*
import com.github.ajalt.clikt.parameters.types.choice
import kotlinx.coroutines.runBlocking
import mu.KotlinLogging
import org.utbot.common.PathUtil.toPath
import org.utbot.common.filterWhen
import org.utbot.engine.Mocker
import org.utbot.framework.plugin.api.ClassId
import org.utbot.framework.UtSettings
import org.utbot.framework.plugin.api.CodegenLanguage
import org.utbot.framework.plugin.api.UtMethodTestSet
import org.utbot.framework.plugin.api.util.UtContext
import org.utbot.framework.plugin.api.util.utContext
import org.utbot.framework.plugin.api.util.withUtContext
import org.utbot.framework.util.isKnownSyntheticMethod
import org.utbot.sarif.SarifReport
import org.utbot.sarif.SourceFindingStrategyDefault
import java.nio.file.Files
import java.nio.file.Paths
import java.time.temporal.ChronoUnit
import kotlin.reflect.KClass
import mu.KotlinLogging
import org.utbot.common.filterWhen
import org.utbot.framework.UtSettings
import org.utbot.framework.util.isKnownSyntheticMethod


private val logger = KotlinLogging.logger {}
Expand Down Expand Up @@ -84,7 +81,7 @@ class GenerateTestsCommand :
)
.flag(default = false)

override fun run() {
override fun run(): Unit = runBlocking {
val started = now()
val workingDirectory = getWorkingDirectory(targetClassFqn)
?: throw Exception("Cannot find the target class in the classpath")
Expand Down Expand Up @@ -113,7 +110,7 @@ class GenerateTestsCommand :
Paths.get(sourceCodeFile),
searchDirectory = workingDirectory,
chosenClassesToMockAlways = (Mocker.defaultSuperClassesToMockAlwaysNames + classesToMockAlways)
.mapTo(mutableSetOf()) { ClassId(it) }
.mapNotNullTo (mutableSetOf()) { utContext.classpath.findClassOrNull(it) }
)
val testClassBody = generateTest(classUnderTest, testClassName, testSets)

Expand Down
3 changes: 3 additions & 0 deletions utbot-framework-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ dependencies {
// TODO do we really need apache commons?
implementation group: 'org.apache.commons', name: 'commons-lang3', version: commons_lang_version
implementation group: 'io.github.microutils', name: 'kotlin-logging', version: kotlin_logging_version
implementation group: 'org.ow2.asm', name: 'asm', version: asm_version

api group: 'com.github.UnitTestBot.jcdb', name: 'jcdb-core', version: 'a5c479bcf8'
}

compileKotlin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ object UtSettings {
*
* True by default.
*/
var useConcreteExecution by getBooleanProperty(true)
var useConcreteExecution by getBooleanProperty(false)

/**
* Enable check of full coverage for methods with code generations tests.
Expand Down Expand Up @@ -313,7 +313,7 @@ object UtSettings {
*
* False by default (for saving disk space).
*/
var logConcreteExecutionErrors by getBooleanProperty(false)
var logConcreteExecutionErrors by getBooleanProperty(true)

/**
* Number of branch instructions using for clustering executions in the test minimization phase.
Expand Down
Loading