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

Add a possibility to group Google Test using regexes on the test executable path/name #337

Closed
1 task done
orzechow opened this issue Mar 7, 2022 · 9 comments
Closed
1 task done

Comments

@orzechow
Copy link

orzechow commented Mar 7, 2022

First of all: thanks for this plugin! 👍

Checklist

Is your feature request related to a problem? Please describe.
I have a workspace full of projects, each of which has multiple cpp test files. Each cpp test file produces one executable, containing multiple testsuites with again multiple tests.
So, I have four hierarchy levels:

  • project / directory
    • test file / executable
      • test suite
        • test

Currently, it seems to me, that it is possible to group by the executable name, regex on the test suite / name / tags – but not by a regex on the test executable path.

Describe the solution you'd like
I'd like to be able to group the tests by project. As the project name is given in the test executable path, it would be sufficient to be able to group by regex on the path.

In the end, I'd like to group by project and maybe aggregate all test executables of a project in the same group:

  • project / directory
    • test suite
      • test

Describe alternatives you've considered
I tried a couple of things, including #231 (comment), but all of the approaches did not work. Grouping by tag regex for example doesn't help, as the tags contain only the test name in my case (how are these tags generated btw?).

Additional context
As an example for (part of) the source directory structure, see the lanelet2 Project. We use it within ROS with catkin/cmake as build tool.
The resulting test files with directory structure:

.
├── lanelet2_core
│   └── lib
│       └── lanelet2_core
│           ├── lanelet2_core-gtest-test_area
│           ├── lanelet2_core-gtest-test_attribute
│           ├── lanelet2_core-gtest-test_lanelet
│           ├── lanelet2_core-gtest-test_lanelet_map
│           ├── lanelet2_core-gtest-test_lanelet_map_geometry
│           ├── lanelet2_core-gtest-test_lanelet_or_area
│           ├── lanelet2_core-gtest-test_lanelet_sequence
│           ├── lanelet2_core-gtest-test_linestring
│           ├── lanelet2_core-gtest-test_point
│           ├── lanelet2_core-gtest-test_polygon
│           └── lanelet2_core-gtest-test_regulatory_element
├── lanelet2_io
│   └── lib
│       └── lanelet2_io
│           ├── lanelet2_io-gtest-TestBinHandler
│           ├── lanelet2_io-gtest-TestLanelet2Io
│           ├── lanelet2_io-gtest-TestOsmFile
│           ├── lanelet2_io-gtest-TestOsmHandler
│           └── lanelet2_io-gtest-TestSimpleUsage
├── lanelet2_matching
│   └── lib
│       └── lanelet2_matching
│           ├── lanelet2_matching-gtest-lanelet2_matching
│           └── lanelet2_matching-gtest-lanelet2_matching_integration
├── lanelet2_projection
│   └── lib
│       └── lanelet2_projection
│           ├── lanelet2_projection-gtest-test_Mercator
│           └── lanelet2_projection-gtest-test_UTM
├── lanelet2_routing
│   └── lib
│       └── lanelet2_routing
│           ├── lanelet2_routing-gtest-test_lanelet_or_area_path
│           ├── lanelet2_routing-gtest-test_relations
│           ├── lanelet2_routing-gtest-test_route
│           ├── lanelet2_routing-gtest-test_routing
│           ├── lanelet2_routing-gtest-test_routing_graph_container
│           └── lanelet2_routing-gtest-test_routing_visualization
├── lanelet2_traffic_rules
│   └── lib
│       └── lanelet2_traffic_rules
│           └── lanelet2_traffic_rules-gtest-lanelet2_traffic_rules
└─── lanelet2_validation
      └── lib
           └── lanelet2_validation
                └── lanelet2_validation-gtest-lanelet2_validation

In this example, it would be handy to regex the executable name to get these groups:

  • lanelet2_core
  • lanelet2_io
  • lanelet2_matching
  • lanelet2_projection
  • lanelet2_routing
  • lanelet2_traffic_rules
  • lanelet2_validation
@matepek
Copy link
Owner

matepek commented Mar 8, 2022

How about

"groupByExecutable": {
  "label": "${absDirpath[-1]}"
}

?

@matepek
Copy link
Owner

matepek commented Mar 8, 2022

Also one nest the groupings:

"groupByExecutable": {
  "label": "${absDirpath[-4]}",
  "groupByExecutable": {
    "label": "${absDirpath[-1]}"
  }
}

@orzechow
Copy link
Author

orzechow commented Mar 8, 2022

Thanks for the response!
Both options create the correct labels (project name), but don't group the results. The reason probably is, that e.g. lanelet2_io contains five executables. So the result looks like:

  • lanelet2_core
  • lanelet2_core
  • lanelet2_core
  • lanelet2_core
  • lanelet2_core
  • lanelet2_core
  • lanelet2_core
  • lanelet2_core
  • lanelet2_core
  • lanelet2_core
  • lanelet2_core
  • lanelet2_io
  • lanelet2_io
  • lanelet2_io
  • lanelet2_io
  • lanelet2_io
  • lanelet2_matching
  • lanelet2_matching
  • lanelet2_projection
  • lanelet2_projection
  • lanelet2_routing
  • lanelet2_routing
  • lanelet2_routing
  • lanelet2_routing
  • lanelet2_routing
  • lanelet2_routing
  • lanelet2_traffic_rules
  • lanelet2_validation

Can I group these somehow together?

@matepek
Copy link
Owner

matepek commented Mar 9, 2022

I see. I will work on this

@orzechow
Copy link
Author

orzechow commented Mar 9, 2022

Thanks :) I hope, it wasn't too confusing.

@matepek
Copy link
Owner

matepek commented Apr 26, 2022

Fixed in **v4.1.0**.

This issue was mentioned in CHANGELOG.md under a released entry so it is assumed to be fixed.
User verifications are always welcome.

@matepek matepek closed this as completed Apr 26, 2022
@orzechow
Copy link
Author

Great, thanks! 😃
Now, this does exactly, what I was looking for 👍

"testGrouping": {
    "groupByExecutable": {
        "label": "${absDirpath[-1]}",
        "mergeByLabel": true,
        "groupByTags": {}
    }
}

@matepek
Copy link
Owner

matepek commented Apr 6, 2023

Are you still using this feature?
I'm considering some refactoring. This stuff is on the way. Please tell me about your current use case

@orzechow
Copy link
Author

Thanks for asking!
Personally, I started a new job and don't use this feature anymore.
Maybe my former collegues like @keroe still use this, as they work with a couple of ROS meta packages – where this feature is helpful to manage the unit tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants