google / googletest

GoogleTest - Google Testing and Mocking Framework
https://google.github.io/googletest/
BSD 3-Clause "New" or "Revised" License
34.47k stars 10.08k forks source link

Easily parsable test list #3822

Open BMBurstein opened 2 years ago

BMBurstein commented 2 years ago

Whe using --gtest_list_tests, the list is split into the test suite on one line, and individual test names on separate lines. This makes it harder to parse the output for listing all available tests. Maybe there should be an option to list the tests using their full names, so that instead of this:

TestSuite1.
  Test1
  Test2
TestSuite2.
  Test1

we can get this:

TestSuite1.Test1
TestSuite1.Test2
TestSuite2.Test1
joshiayush commented 2 years ago

@BMBurstein What makes it harder to parse the available tests when the result is the following?

TestSuite1.
  Test1
  Test2
TestSuite2.
  Test1

And how it gets easier to parse available tests when the result is the following?

TestSuite1.Test1
TestSuite1.Test2
TestSuite2.Test1

You can write your own logic to get a list of available tests when the result is the first one. It won't be hard I think. Well, I can write internal logic for it once the developers are ready to accept a PR resolving this issue...

@derekmauro What do you say?

BMBurstein commented 2 years ago

@joshiayush If parsing with very simple line-based parser, it is much easier if each line is a whole test name, then if I have to parse 2 kinds of lines and keep the current test suite name in a variable for concatenating to each test name. Obviously it is easy enough to do in a proper programming language, but think of trying to parse it in some of the less powerful scripting languages and you will get the idea.

joshiayush commented 2 years ago

but think of trying to parse it in some of the less powerful scripting languages and you will get the idea.

Now I got your point and I'm thinking of parsing it in Bash so I can relate with that pain :joy: . Let's do one thing and add two kinds of values for flag --gtest_list_tests, one is 0 (for less verbosity) and 1 (for high verbosity).

Let's ask @derekmauro about it. What do you say?

dinord commented 2 years ago

Thank you for suggesting this. This is not something we plan to work on, but we would consider accepting a pull request.

joshiayush commented 2 years ago

@dinord Okay then, Assign it to me.

dianarg commented 1 year ago

If anyone needs a workaround to convert the output to the full test list, this awk command works for me (awk 4.0.2):

./mytest --gtest_list_tests | awk '/\./{ SUITE=$1 }  /  / { print SUITE $1 }'