bazelbuild / intellij

IntelliJ plugin for Bazel projects
https://ij.bazel.build/
Apache License 2.0
763 stars 305 forks source link

Clion bazel plugin shows "Bazel test" for Helloworld.cc class from examples project #5767

Open sgowroji opened 11 months ago

sgowroji commented 11 months ago

Description of the bug:

The Clion Bazel plugin shows the "Bazel test" for the Helloworld.cc class from the sample CPP of the example project.

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Import Clion project and do a sync. Then go to https://github.com/bazelbuild/intellij/blob/master/examples/cpp/simple_project/src/hello_world.cc class and click on Green icon beside int main(int argc, char** argv) { main method. it shows Bazel test src which is confusing.

Screenshot 2023-11-23 at 15 30 29 for reference https://screenshot.googleplex.com/95UVRLzpsj9zPHp

Which Intellij IDE are you using? Please provide the specific version.

CLION 2023.2.

What programming languages and tools are you using? Please provide specific versions.

CPP

What Bazel plugin version are you using?

v2023.11.07

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

tpasternak commented 11 months ago

Could be caused by my change #5743

tpasternak commented 11 months ago

Nope, wasn't it always like that @mai93

mai93 commented 11 months ago

I reviewed the notes for manual testing and yes in C++ the binary and test runs should be invoked from the target in the BUILD file. But when we tried running the test from the .cc file worked, I'm not sure if fixing it for the binary is something we want to keep in mind or close this bug as not planned.

tpasternak commented 11 months ago

O haven't looked at the code in the picture. Indeed, we shouldn't print test for main function run

mai93 commented 10 months ago

There is a cc_test target for the .cc file here that I did not notice before, so I'm not sure if this is WAI now? @blorente who added this target, what do you think?

blorente commented 10 months ago

This is intentional as per https://github.com/bazelbuild/intellij/pull/4786 The heuristic introduced there goes like: If there is a "main" function and a cc_test target, please treat it as a test.

It's definitely a heuristic more than a hard rule, we (internally, at Apple) just found that it suited us well for tests that were essentially "just a main function".

I assumed, perhaps incorrectly, that a main function would be either a test or a binary, not both.

I'm happy to:

mai93 commented 10 months ago

I think what needs to be updated is if there is also a cc_binary target for the same "main" function then which rule should be used. I think we can separate the targets in the example project for now.