-
Notifications
You must be signed in to change notification settings - Fork 46
Better naming for functions and comments could be deduced from fuzzer #288
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
@amandelpie I implemented idea that fuzzer can add information about each value it creates. At the moment this information is pretty simple, like:
Here, |
if (GENERATE_DISPLAY_NAMES) { | ||
if (GENERATE_DISPLAY_NAMES | ||
// do not rewrite display name if already set | ||
&& traceTags.execution.displayName.isNullOrBlank()) { |
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.
Probably we need to move this behaviour to settings? Like GENERATE_DISPLAY_NAMES
Because it's very direct logic in the internals of summarization module
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 don't think it is good idea to keep global settings at all. Also, I don't like to add new settings until it really necessary. I think it is better to make this settings be customizable through the Summarization instance. But at the moment I find Summarization code is a bit messy.
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.
Waiting TODO
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 suggest to use alternative format with todos like TODO: link to the issue or discussion on the Github. If you disagree with the settings model lets discuss it, don't hide the thoughts
utbot-fuzzers/src/main/kotlin/org/utbot/fuzzer/names/SingleModelNameSuggester.kt
Show resolved
Hide resolved
package org.utbot.fuzzer.names | ||
|
||
/** | ||
* Information that can be used to generate tests. |
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.
To generate tests or test names?
utbot-fuzzers/src/main/kotlin/org/utbot/fuzzer/names/TestSuggestedInfo.kt
Show resolved
Hide resolved
@@ -25,7 +25,9 @@ class ArrayModelProvider( | |||
length = arraySize, | |||
arrayClassId.elementClassId!!.defaultValueModel(), | |||
mutableMapOf() | |||
) | |||
).fuzzed { | |||
this.summary = "%var% = ${arrayClassId.elementClassId!!.simpleName}[$arraySize]" |
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.
%var% - is very popular place in you code and look like is one of the basic concepts. But it requires a time to understand what is the final goal and area of usage.
Could you please provide Readme or extended comments related to the concept of %var% usage and replacing. Now it requires a time to restore the concept from the code.
The minor architecture note in .md format also will be useful.
Some comments like above methods createTestName/displayName was very useful for me.
Just imagine that somebody need to extend your functionality or fix a bug in it, please help him
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.
It is described as a kdoc in FuzzedValue class for summary field. The test is follow:
/**
* Summary is a piece of useful information that clarify why this value has a concrete value.
*
* It supports a special character `%var%` that is used as a placeholder for parameter name.
*
* For example:
* 1. `%var% = 2` for a value that have value 2
* 2. `%var% >= 4` for a value that shouldn't be less than 4
* 3. `foo(%var%) returns true` for values that should be passed as a function parameter
* 4. `%var% has special characters` to describe content
*/
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 left some comments and suggestions.
I'd like a few basic rules which were proposed in this PR and moreover, I suppose NameSuggesters could be independently used for all other summaries like a simple level instead of just ignoring summaries when it fails.
2dd8c98
to
5fd0342
Compare
5fd0342
to
ca65095
Compare
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.
LGTM for me
ca65095
to
cef1577
Compare
Description
Generates more reasonable names of tests which were generated by fuzzer.
Fixes #180
Type of Change
Please delete options that are not relevant.
How Has This Been Tested?
Manual Scenario
Create method like this:
Generate test with fuzzing. There's 2 test should be generated (can be a little different):
Checklist (remove irrelevant options):