Skip to content

Soot artifacts appear in test method display name #437

Closed as not planned
Closed as not planned

Description

@amandelpie

Description

Currently, Soot generates the following Jimple for org.utbot.examples.collections.ListWrapperReturnsVoidExample#runForEach:

r4 := @this: org.utbot.examples.collections.ListWrapperReturnsVoidExample
r2 := @parameter0: java.util.List
$r0 = newarray (int)[1]
$r0[0] = 0
$r3 = staticinvoke <org.utbot.examples.collections.ListWrapperReturnsVoidExample$lambda_runForEach_0__1: java.util.function.Consumer bootstrap$(int[])>($r0)
interfaceinvoke r2.<java.util.List: void forEach(java.util.function.Consumer)>($r3)
$i0 = $r0[0]
return $i0

After that, when it comes to generation of the test method name (org.utbot.utbot.summary.name.SimpleNameBuilder#collectTags), Soot-generated name "bootstrap$" is used as-is and passed to the code generation stage.

"bootstrap$" is clearly a Soot-generated helper code, which should not be used for names seen by user.
We should avoid it by modifying collectTags method.

To Reproduce

Please, fill your step to reproduce here, is the ticket description valid?

Expected behavior

Soot and another internal artifact should not be part of display name, comments or test name

Actual behavior

Now it's a problem and depends on our internals

Additional context

it's ok just filter it, but it will great to propose an approach to avoid another internal stuff

Activity

  1. added
    ctg-bugIssue is a bug
    comp-summariesSomething related to the method names, code comments and display names generation
    on Jul 6, 2022
  2. onewhl commented on Jul 6, 2022

    @onewhl
    Member

    Steps to reproduce:

    I pulled last changes from the main branch and started debugging org.utbot.examples.collections.ListWrapperReturnsVoidTest#testRunForEach method. I put one breakpoint on line 74 in org.utbot.summary.Summarization#summary method to get jimpleBody and another one on line 150 to see the test method name generated by UTBot.

    Actual behavior

    Indeed, for org.utbot.examples.collections.ListWrapperReturnsVoidExample#runForEach Soot generates the same Jimple as you attached to the issue. UTBot generated 4 unit tests, here are their names:
    testRunForEach_ThrowNullPointerException, testRunForEach_Return0OfI, testRunForEach_Return0OfI_1, testRunForEach_Return0OfI_2.

    I wrote unit tests for ListWrapperReturnsVoidExample.kt that capture the current behavior related to the generation of summary part of tests. I will open PR in an hour.

    Suggestions

    I would suggest two improvements for test methods naming:

    1. Use structure type instead of its name in test method name, at least when the name consists of one character.
      For example, testRunForEach_Return0OfArray instead of testRunForEach_Return0OfI;
    2. Describe the first element of structures as firstElement, not as 0. The same about the last element.
      For example, testRunForEach_ReturnFirstElementOfI instead of testRunForEach_Return0OfI.

    Please, let me know what you think about it.

  3. amandelpie commented on Jul 7, 2022

    @amandelpie
    CollaboratorAuthor

    Thanks, @onewhl, for the answer. Probably, this issue is outdated, but I agree, that we need to fix the current behavior in the test.

    The improvements regarding the naming could be summarized and discussed separately.

  4. amandelpie commented on Jul 8, 2022

    @amandelpie
    CollaboratorAuthor

    Looks like the issue is not actual anymore and the current behaviour is fixed with the PR #444

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

comp-summariesSomething related to the method names, code comments and display names generationctg-bugIssue is a bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions