google / google/googletest

[Bug]: Malformed XML report file created whe running GTest with option --gtest_output (wrong XML syntax)

Open
#4,427 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
39.5k
Forks
10.9k
Avg merge
6d 13h
Merged PRs (30d)
1

Description

### Describe the issue

Hi,

I am dealing with a problem with XML report that GTest produces. It has significant influence on the JUnit tool built into Jenkins - it leads to marking Jenkins build as failed, because JUnit cannot read test report file (since it is not in readable XML format). Let me show you and example of malformed report file:

```

































































































































































SPLAY_LEGS" file="StreamerTestTimezoneDisplay.cpp" line="94" status="run" result="completed" time="0.529" timestamp="2023-11-29T13:58:35.901" classname="StreamerTestDisplay" />

```

Please pay attention to the last several lines of the code above, namely:
```
SPLAY_LEGS" file="StreamerTestTimezoneDisplay.cpp" line="94" status="run" result="completed" time="0.529" timestamp="2023-11-29T13:58:35.901" classname="StreamerTestDisplay" />

```

These "extra" lines seem to be not needed, although they show up and break the XML format of the report file.

The tests (cases, suites) are _not_ run in parallel. It looks like there was some concurrency problem when writing to the same output file. It might be relevant that the tests are executed with an option "--r 2" which repeats the failing tests up to two times until they eventually pass.

### Steps to reproduce the problem

Will try to prepare minimal working code reproducing the fail scenario if you find that it is a must in order to fix the problem. It might be quite a chunk of work to me since I cannot share the entire project.

### What version of GoogleTest are you using?

v1.14.0

### What operating system and version are you using?

RedHat 7

### What compiler and version are you using?

gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)

### What build system are you using?

GNU Make 3.82

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by locating the GoogleTest XML reporting implementation reached by --gtest_output and compare its output with the malformed sample in this issue. Add a regression test that parses the generated report as XML and verify the output is readable by Jenkins JUnit consumers.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.