Skip to content

Soot artifacts appear in test method display name #437

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

Closed
amandelpie opened this issue Jul 6, 2022 · 3 comments
Closed

Soot artifacts appear in test method display name #437

amandelpie opened this issue Jul 6, 2022 · 3 comments
Assignees
Labels
comp-summaries Something related to the method names, code comments and display names generation ctg-bug Issue is a bug

Comments

@amandelpie
Copy link
Collaborator

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

@amandelpie amandelpie added ctg-bug Issue is a bug comp-summaries Something related to the method names, code comments and display names generation labels Jul 6, 2022
@onewhl
Copy link
Member

onewhl commented Jul 6, 2022

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.

@amandelpie
Copy link
Collaborator Author

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.

@amandelpie
Copy link
Collaborator Author

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

@amandelpie amandelpie closed this as not planned Won't fix, can't repro, duplicate, stale Jul 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-summaries Something related to the method names, code comments and display names generation ctg-bug Issue is a bug
Projects
None yet
Development

No branches or pull requests

2 participants