Skip to content

Conversation

@bdolewski-intellias
Copy link
Contributor

This PR fixes Cobertura XML output so it’s valid against the official coverage-04.dtd and adds CLI flags for easier path handling in CI/CD environments.

My last PR missed a few marks and I decided to spent my time making xcresultparser compliant with latest Cobertura DTD standard :)
Too bad that Apple doesn't give the official support for it but I believe I managed to bridge that gap with the help from Claude 4 Sonnet.

The test workflows behave like "e2e" tests. Went with Python instead of XCTests or Swift Testing to let external tool run xcresultparser and validate its output.

TODO

  • verify that YAML files works - until that this is going to be draft

Fixes

  • Coverage counters and timestamps are now integers
  • Version string standardized to xcresultparser 1.9.3
  • Branch coverage correctly reported as 0 (not tracked)
  • Consistent decimal formatting across attributes

New CLI Flags

--coverage-base-path <path>   # normalize file paths
--sources-root <path>         # set <sources> root path

Example

Before ❌

lines-covered="1530.0" timestamp="1672825221.218"

After ✅

lines-covered="1530" timestamp="1672825221"

Testing

  • Added XML fixtures that validate against the Cobertura DTD
  • CI workflow now runs automated validation on each PR
  • Extra scenarios included for new flags to prevent regressions

Notes

  • Backward-compatible: existing CLI usage still works
  • New flags are optional

I've also tested it locally with my project to see if DataDog CLI likes it:
Image 29-09-2025 at 11 22

@a7ex
Copy link
Owner

a7ex commented Oct 1, 2025

Hi Bartosz, thanks for your contribution. Quite a bit to digest :-)
I will look into it later today, when I finish my daywork. Then I will also investigate, why we need "coverageBasePath", instead of project-root. :-)

@bdolewski-intellias
Copy link
Contributor Author

@a7ex take your time :)

Copy link
Owner

@a7ex a7ex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Terrific work, Bartosz, thank you. I struggled y bit with the Python unit tests, but that's just me being a swift head. As I understand that is a standard test and that is of course smart.

@a7ex a7ex marked this pull request as ready for review October 14, 2025 14:08
- name: Test Individual File Validation
run: |
echo "🔍 Testing individual file validation..."
# Generate a test XML file
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no .build/release/...
The built product is in:
.build/apple/Products/Release/$productName

swift build -c release --disable-sandbox --arch arm64 --arch x86_64
# Verify binary was created
if [[ ! -f .build/release/xcresultparser ]]; then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no .build/release/xcresultparser
The built product is in:
.build/apple/Products/Release/xcresultparser

fi
echo "✅ Binary built successfully"
.build/release/xcresultparser --version || echo "Binary version check completed"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

# Test --coverage-base-path flag
echo "Testing --coverage-base-path flag..."
.build/release/xcresultparser Tests/XcresultparserTests/TestAssets/test.xcresult \
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

# Test --sources-root flag
echo "Testing --sources-root flag..."
.build/release/xcresultparser Tests/XcresultparserTests/TestAssets/test.xcresult \
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong path

# Test backward compatibility with -p flag
echo "Testing backward compatibility (-p flag)..."
.build/release/xcresultparser Tests/XcresultparserTests/TestAssets/test.xcresult \
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just pretend I made a comment everywhere, where you used ".build/release/xcresultparser"
After building on my machine, there is not symlink to ".build/apple/Products/Release/" we will need to figure out the correct build path here.

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

Successfully merging this pull request may close these issues.

2 participants