Skip to content

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
//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

2 participants