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

Extract Traverser from UtBotSymbolicEngine #307

Merged
merged 19 commits into from
Jul 8, 2022

Conversation

sergeypospelov
Copy link
Member

@sergeypospelov sergeypospelov commented Jun 27, 2022

Description

Split the logic of UtBotSymbolicEngine into two classes:

  • UtBotSymbolicEngine
  • Traverser

Introduced new classes and some TODO stubs:

  • StateLabel is used for marking ExecutionState accordingly to their status (INTERMIDIATE, CONCRETE, TERMINAL). See the comments in the code for more information.
  • TraversalContext is a context during one Jimple instruction traversal. Now there are some TODO stubs for the future work.

Refactored several relevant places with non-functional changes:

  • Changed signatures of some traversal functions
  • Moved some functions to more convenient places
  • Fixed hack on nullable SymbolicResult in processResult
  • Other minor refactorings

Fixes #259

Details

Previously UtBotSymbolicEngine had the complex logic of different types:

  • setting up everything
  • working with the states queue
  • Jimple travesal
  • working with the symbolic state
  • processing final states

The idea is to split some of the aspects of the engine logic into different classes. In this MR the extraction of Jimple traversal was done. Now we have two classes:

UtBotSymbolicEngine

Now UtBotSymbolicEngine is a manager class. It's created once for one method analysis process. We can't reuse it for different methods. It sets up everything for Traverser, controls the flow of polling states from the queue and pushing new states to the queue and also processes terminal states.

So now the next things are done in UtBotSymbolicEngine:

  • setting up everything
  • working with the states queue
  • processing final states

Traverser

Traverser is responsible for traversing the top instruction from the passed ExecutionState. It's created inside UtBotSymbolicEngine and can't be reused between different methods ("method-under-test"s). The main function is traverse(state: ExecutionState): Collection<ExecutionState> which takes an ExecutionState and produces next states, so all other extra information needed for traversal should be passed via the constructor of Traverser.

Please note, that now it's Traverser responsibility to choose the right label for the next ExecutionState. Then UtBotSymbolicEngine matches on this label and decides what to do with this state.

So now the next things are done in Traverser:

  • Jimple travesal
  • working with the symbolic state

Type of Change

  • Refactoring (non-functional change improving code quality)

How Has This Been Tested?

Automated Testing

Ran all tests in IDEA. No new test failures have been detected in this change.

Checklist:

  • 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 (Except some TODOs for the following MRs)
  • All tests pass locally with my changes

@sergeypospelov sergeypospelov self-assigned this Jun 27, 2022
@sergeypospelov sergeypospelov force-pushed the sergey/engine-refactoring branch from 8b50bb2 to f7359f3 Compare June 27, 2022 08:56
@sergeypospelov sergeypospelov changed the title Sergey/engine refactoring Extract Traverser from UtBotSymbolicEngine ([#259](https://github.com/UnitTestBot/UTBotJava/issues/259)) Jun 27, 2022
@sergeypospelov sergeypospelov changed the title Extract Traverser from UtBotSymbolicEngine ([#259](https://github.com/UnitTestBot/UTBotJava/issues/259)) Extract Traverser from UtBotSymbolicEngine (#259) Jun 27, 2022
@sergeypospelov sergeypospelov changed the title Extract Traverser from UtBotSymbolicEngine (#259) Extract Traverser from UtBotSymbolicEngine Jun 27, 2022
Copy link
Collaborator

@SBOne-Kenobi SBOne-Kenobi left a comment

Choose a reason for hiding this comment

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

LGTM

@sergeypospelov sergeypospelov force-pushed the sergey/engine-refactoring branch 2 times, most recently from 6679597 to 5274326 Compare July 7, 2022 05:38
Copy link
Member

@nikitavlaev nikitavlaev left a comment

Choose a reason for hiding this comment

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

Checked force mocks: no regression so far.

Copy link
Collaborator

@dtim dtim left a comment

Choose a reason for hiding this comment

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

Seems nice.

@sergeypospelov sergeypospelov force-pushed the sergey/engine-refactoring branch from 5274326 to 33c61d1 Compare July 8, 2022 08:29
@sergeypospelov sergeypospelov merged commit c6bb765 into main Jul 8, 2022
@sergeypospelov sergeypospelov deleted the sergey/engine-refactoring branch July 8, 2022 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Extract Traverser from UtBotSymbolicEngine
6 participants