Skip to content

Go support #1757

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

Merged
merged 31 commits into from
Feb 7, 2023
Merged

Go support #1757

merged 31 commits into from
Feb 7, 2023

Conversation

egiptipavel
Copy link
Collaborator

Description

I added Go tests generation.

UI

Module utbot-intellij-go contains language-specific implementations of LanguageAssistant, DialogWrapper and other classes.

CLI

Module utbot-go-cli contains command line generation and run tests interface for Go.

How to test

Manual tests

// DivOrPanic divides x by y or panics if y is 0
func DivOrPanic(x int, y int) int {
    if y == 0 {
        panic("div by 0")
    }
    return x / y
}

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.

@egiptipavel egiptipavel added ctg-enhancement New feature, improvement or change request comp-fuzzing Issue is related to the fuzzing labels Jan 27, 2023
override val classId: GoTypeId,
) : UtModel(classId) {
open fun getRequiredImports(): Set<String> = emptySet()
abstract fun canNotBeEqual(): Boolean
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is hard to understand code with negative assertion. canBeEqual is easier to understand.

@Markoutte
Copy link
Collaborator

Please, use Mermaid to create document diagrams instead of binary images with diagrams (like utbot-go/docs/diagrams/how-it-works.png is used)


### Test code generation

Finally, the last stage: the test cases are ready, UTBot Go needs only to generate code for them. Nothing terrible
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nothing terrible happens here

Sounds not very good for documentation.


## How to test UTBot Go

_**TODO:**_ Gradle `runIde` task and building CLI application JAR locally.
Copy link
Collaborator

Choose a reason for hiding this comment

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

To build CLI version the build on utbot-cli-go should be called

tasks {
compileKotlin {
kotlinOptions {
jvmTarget = "11"
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is preferrable to use 8 Java API for all modules except IntelliJ plugin and CLI

implementsError: Boolean
) : GoTypeId(name, implementsError = implementsError) {
override fun getRelativeName(packageName: String): String {
TODO("Not yet implemented")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suspicious TODO

*/
abstract class GoTypeId(
name: String, elementClassId: GoTypeId? = null, val implementsError: Boolean = false
) : ClassId(name, elementClassId) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need to rid off all dependencies of core-api, like ClassId

Copy link
Member

Choose a reason for hiding this comment

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

We all have ClassId in dependencies (including Python, even though we have our own types). It is needed to use code generation, maybe some other places too.

@Markoutte Markoutte merged commit bd31da7 into UnitTestBot:main Feb 7, 2023
@alisevych alisevych added this to the 2023.03 Release milestone Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-fuzzing Issue is related to the fuzzing ctg-enhancement New feature, improvement or change request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants