Skip to content
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

Self-documenting settings template #1420

Merged
merged 20 commits into from
Dec 2, 2022

Conversation

Vassiliy-Kudryashov
Copy link
Member

Description

  1. There is new helper to be used from Gradle task. It converts UtSettings.kt to resource file settings.properties.
    So, actual state of UtSettings.kt (properties, defauls, relevant documentation comments) will allways be converted to bundled resource file we publish along with the plugin as top-level entry inside utbot-intellij-{version}.jar file.
    Note, the template contains commented lines only so we free to change our hardcoded defaults later and re-write outdated template with new one until it's customized by user.

  2. Just after IDE start (namely when plugin loads its settings) we check if settings.properties is presented in user's local file system as {home}/.utbot/settings.properties:

  • If not we create it from the resource template together with the folder is need.
  • If file already exists we copy resource template only if there are no custom (provided by user) values inside to persist existing users' configuration "as is".

Fixes #1412

Type of Change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Manual Scenarios

Scenario 1

  • Delete {home}/.utbot folder if exists.
  • Start IDE, wait for project loading.
    The folder {home}/.utbot should be created automatically, for Windows it also should be marked as "hidden file".
    There should be template file settings.properties inside.
    If you delete the file it should appear again after IDE restart.

Scenario 2

  • Clear the file {home}/.utbot/settings.properties, leave just one line inside: disableCoroutinesDebug=true
  • Start IDE, wait for project loading.
    As soon as property file contains defaults, it should be re-writen with template.

Scenario 3

  • Clear the file {home}/.utbot/settings.properties, leave just one line inside: disableCoroutinesDebug=false
  • Start IDE, wait for project loading.
  • As soon as property file contains custom value, it should stay as is.

Checklist (remove irrelevant options):

  • The change followed the style guidelines of the UTBot project
  • Self-review of the code is passed
  • The change contains enough commentaries, particularly in hard-to-understand areas
  • New documentation is provided or existed one is altered
  • No new warnings

Vassiliy-Kudryashov and others added 13 commits November 17, 2022 10:06
UTSettings.kt -> settings.properties, first iteration with several yet-not-parsed (skipped) properties
Split Single description for bunch options to dedicated ones in code
Get rid of default value description in code
Skip <a href... lines
Support both var/val options
Add empty lines between description/enum values/default to make output more user-friendly
Save template to user's local file if absent
Add some documentation comments
…ent to TestCaseGenerator.kt:300 some time ago)

Get rid of unused property singleSelector
Delete resource file settings.properties that is designed to be re-generated locally from the repository
…er-defined custom settings

Make newly created ".utbot" folder hidden under Windows only
Make all properties commented to be free switch our hardcoded defaults later if any.
@alisevych
Copy link
Member

Some ideas from our discussion with @Vassiliy-Kudryashov and @olganaumenko:

  1. Create settings.properties.template near to settings.properties - and recreate it every time the plugin is installed.
    That can be useful to have the template with the current version of settings.

  2. Select the most important settings. Which can be suggested first to the user.
    They can be listed above all others. And described separately in docs.

@Vassiliy-Kudryashov Vassiliy-Kudryashov changed the title Vassiliy kudryashov/experiments Self-documenting settings template Nov 28, 2022
@Vassiliy-Kudryashov Vassiliy-Kudryashov requested review from EgorkaKulikov and removed request for denis-fokin November 28, 2022 10:30
Copy link
Collaborator

@EgorkaKulikov EgorkaKulikov left a comment

Choose a reason for hiding this comment

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

LNVGTM, but it seems to be our way now. Discussed verbally with Vasya. Some potential mines are going to be removed in further implementations.
Also I suggest to test it in branch before merge.

@alisevych
Copy link
Member

alisevych commented Nov 29, 2022

@Vassiliy-Kudryashov Please check:
the changed settings are not applied (or may be not parsed)
Checked utBotGenerationTimeoutInMillis and useCustomJavaDocTags - not applied.
They are applied correctly with plugin built from main.

To reproduce

  1. Removed existing settings.properties file
  2. Installed build from this branch
  3. Restarted IDE
  4. Opened generated settings.properties file
  5. Uncommented the line with utBotGenerationTimeoutInMillis and changed value to 1000
  6. Restarted IDE once more
  7. Open UnitTestBot dialog

Expected behavior

Test generation timeout should be 1 sec

Actual behavior

Default test generation timeout is applied - 60 sec

Additional context

The same issue is when executing runIde task.
The issue is not reproducing in main - the change of this setting is applied.

@alisevych
Copy link
Member

@Vassiliy-Kudryashov Could you please correct the naming of treatAssertAsErrorSuit to treatAssertAsErrorSuite?

@alisevych
Copy link
Member

@Vassiliy-Kudryashov
Also the usability question:

  • after UnitTestBot plugin installation there are 2 IDE restarts needed to apply new settings:
  1. To generate settings.properties template
  2. To apply changes in properties-file
    Could we consider some improvements for this? Probably a discussion would help?

@alisevych
Copy link
Member

@Vassiliy-Kudryashov @Domonion
Could you please advise if we can log the settings that differ from default ones?
One the step of IDE start or when the test run is performed.
That can explain some issues and help with reproducing customer's bugs.

@Vassiliy-Kudryashov Vassiliy-Kudryashov enabled auto-merge (squash) December 2, 2022 15:58
@Vassiliy-Kudryashov Vassiliy-Kudryashov merged commit 31a983b into main Dec 2, 2022
@Vassiliy-Kudryashov Vassiliy-Kudryashov deleted the Vassiliy-Kudryashov/experiments branch December 2, 2022 16:36
tamarinvs19 pushed a commit that referenced this pull request Dec 6, 2022
* Convert 'UTSettings.kt' into '.utbot/settings.properties'
* Add Apache 2.0 license to settings.properties output and tune comments wording in sourcecode
* Add template generation to gradle build process
* Add AbstractSettings.areCustomized() ability to tell template from user-defined custom settings
* Make all properties commented to be free switch our hardcoded defaults later if any.
* Fix an issue with always-default settings state.
* Change copyright in the license template to utbot.org
* Fix a misprint in UtSettings property name "treatAssertAsErrorSuite"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Self-documenting settings template
3 participants