Skip to content

Introduce new single entry point for contest estimator (#1741) #1751

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

Closed
wants to merge 2 commits into from

Conversation

Markoutte
Copy link
Collaborator

Description

PR contains changes that are aimed to gather all existing contest mains into one entry point.

Fixes #1741

How to test

No tests at the moment

Self-check list

  • I've set the proper labels for my PR (at least, for category and component).
  • PR title and description are clear and intelligible.
  • I've added enough comments to my code, particularly in hard-to-understand areas.
  • The functionality I've repaired, changed or added is covered with automated tests.
  • Manual tests have been provided optionally.
  • The documentation for the functionality I've been working on is up-to-date.

@Markoutte Markoutte added ctg-refactoring Issue related to refactoring process comp-contest-estimator Issue is related to contest estimator labels Jan 26, 2023
@@ -42,7 +42,7 @@ private val logger = KotlinLogging.logger {}
private val classPathSeparator = System.getProperty("path.separator")
//To hack it to debug something be like Duke
// if (System.getProperty("user.name") == "duke") my_path else "JAVA_HOME"
private val javaHome = System.getenv("JAVA_HOME")
internal val javaHome = System.getenv("JAVA_HOME")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

fun main(args: Array<String>) {
val entryPointClass = System.getProperty(entryPointToolKey)
@Suppress("UNCHECKED_CAST")
val entryPoint: EntryPointTool<Data> = if (entryPointClass != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think better add explicit warning like:

There are no `Dutbot.entryPointTool` property defined, switching to `oneClassEntryPoint`

runBlocking {
entryPoint.setup()
entryPoint.prepare().forEach { data ->
withTimeout(data.timeBudget) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be withTimeoutOrNull? This would throw exception and break all execution if some test generation exceedes timeout.

@Suppress("OPT_IN_USAGE")
runGeneration(
data.name,
ClassUnderTest(data.classLoader.loadClass(data.classUnderTest).id, data.outputDirectory),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

provided class might not be loadable, or loading class might throw exception -> it be will propagated until the top and breaks all execution

ClassUnderTest(data.classLoader.loadClass(data.classUnderTest).id, data.outputDirectory),
data.timeBudget,
data.fuzzingRatio,
data.classPaths.joinToString(System.getProperty("path.separator")),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File.separatorChar?

unzippedJars
)

logger.info { "\n>>>" }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really useful?

val project = ProjectToEstimate(
name,
classesFQN,
File(classpathDir, name).listFiles()!!.filter { it.toString().endsWith("jar") },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK we rely not only on .jars, we also useful unzipped class files

val methodFilter: String? = "com.google.common.primitives.Shorts.*"
@Suppress("RedundantNullableReturnType")
val projectFilter: List<String>? = listOf("guava-26.0")
val processedClassesThreshold = 9999
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we again have some distributed logic for configuration contest estimator - there is some configuration in setup method also, is there any way to localize this logic?

@Suppress("RedundantNullableReturnType")
val methodFilter: String? = "com.google.common.primitives.Shorts.*"
@Suppress("RedundantNullableReturnType")
val projectFilter: List<String>? = listOf("guava-26.0")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. In ContestEstimator.kt there is big list of project, but only 1 here
  2. I dont see any way to setup this property outside from code

data.tool.run(
project = project,
cut = ClassUnderTest(
project.classloader.loadClass(data.classUnderTest).id,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again classloading without try-catch braces up until main call
May be its better to load it somewhere once and then provide in run?

@Markoutte Markoutte closed this Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-contest-estimator Issue is related to contest estimator ctg-refactoring Issue related to refactoring process
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redesign contest estimator entry points
2 participants