GoogleTestAdapter icon indicating copy to clipboard operation
GoogleTestAdapter copied to clipboard

Consider take tests location (file name & line number) from XML

Open aey76 opened this issue 5 years ago • 2 comments
trafficstars

In google test version 1.10.0 (and maybe even from 1.8.1) the XML output of the --gtest_list_tests contains the file name and the line number for every testcase. You can use this information to locate the test_case position instated of parsing the debug information, this will allow us to select any debug information generation, even no debug information at all. And maybe it will increase the tests discovering time.

Here is example of XML with the position information:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="5" name="AllTests">
  <testsuite name="TestCaseName" tests="1">
    <testcase name="TestName" file="C:\Users\p1\source\repos\Sample-Test1\Sample-Test1\test.cpp" line="34" />
  </testsuite>
  <testsuite name="TestCaseName2" tests="1">
    <testcase name="TestName" file="C:\Users\p1\source\repos\Sample-Test1\Sample-Test1\test.cpp" line="59" />
  </testsuite>
  <testsuite name="TestCaseName3" tests="3">
    <testcase name="TestName" file="C:\Users\p1\source\repos\Sample-Test1\Sample-Test1\test.cpp" line="65" />
    <testcase name="TestName1" file="C:\Users\p1\source\repos\Sample-Test1\Sample-Test1\test.cpp" line="75" />
    <testcase name="TestName2" file="C:\Users\p1\source\repos\Sample-Test1\Sample-Test1\test.cpp" line="82" />
  </testsuite>
</testsuites>

aey76 avatar Jan 29 '20 21:01 aey76

Sounds like a good idea to me - not sure when I will have time to look into this, though... Sorry for the late reply, btw.

csoltenborn avatar Feb 27 '20 06:02 csoltenborn

Btw, I agree with original author that source code location and line should be taken from someplace else.

I by myself have actively used /debug:fastlink /INCREMENTAL flags after which google unit test does not show up test location anymore.

Briefly why - linking happens 2-5 times faster, see also: https://devblogs.microsoft.com/cppblog/faster-c-build-cycle-in-vs-15-with-debugfastlink/.

In my own custom builds - I by myself have used special <LOC> text tags - so --gtest_list_tests would list those tests immediately. https://github.com/tapika/googletest/blob/master/googletest/src/gtest.cc#L5556 (Google test, code when you print test list using --gtest_list_tests command line argument)

I think Microsoft Visual studio uses #pragma section, and then in a turn uses binary structure recognition / parsing.

It would be good to find solution for this, because currently if I'll cross compare google test + google test adapter for visual studio versus visual studio test framework - visual studio test framework is better at least for windows. (Test location is discovered correctly - but for GT based framework it's easier to start test than VS)

tapika avatar Oct 13 '20 19:10 tapika