-
Notifications
You must be signed in to change notification settings - Fork 46
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
Conversation
@@ -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") |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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")), |
There was a problem hiding this comment.
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>>>" } |
There was a problem hiding this comment.
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") }, |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- In
ContestEstimator.kt
there is big list of project, but only 1 here - 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, |
There was a problem hiding this comment.
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?
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