UTBotCpp icon indicating copy to clipboard operation
UTBotCpp copied to clipboard

Auto target does not work for project as expected

Open Lana243 opened this issue 3 years ago • 0 comments

Description When auto target is chosen for project generation, it is expected that for each source file in project the exact target would be chosen. However, currently this functionality is unavailable. Instead, when auto target is selected for project then only one target would be chosen and tests for sources included into this target would be generated.

Also there exists some confusing pieces of code that should be either removed or fixed to support the auto target for project generation. Those are the following.

  1. TargetBuildDatabase constructor in TargetBuildDatabase.cpp file. isAutoTarget flag assignment is incorrect. Until this commit the flag assignment used to be the following. image In fact this assignment is the same as isAutoTarget = false because before line 22: isAutoTarget = target == GrpcUtils::UTBOT_AUTO_TARGET_PATH target is assigned as a real path to a target and this comparison always fails. By PR fixing auto target for files and lines this line was removed and flag was set to be always false.

  2. The bigger issue is in Linker.cpp, function linkForProject. Here we try to link the targets one by one calling linkWholeTarget function. image Moving to this function we can notice that in line 126 we change target and at the end of the function (line 158) we change the target back. However, if we take a look at setTargetPath method, we'll find out that target will be changed only once. The reason of such behavior is that when entering this function the first time, if isAutoTarget is true, then we proceed to if's body and change target path. However, for new target set flag will be false as path to a target is set manually, so calling this function for the second time will do nothing. image

To conclude, I suppose this issue needs further investigation. Also tests for correct behavior should be definitely added. This can be, for example, project with multiple targets not included to one big target. In this case tests for all source files should be generated.

Environment UTBot main at 94d79a3731e45ba00b0d0850beb003f8a3dcd1b8. Release 2022.10.4.

Lana243 avatar Dec 14 '22 10:12 Lana243