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

Support the 'file' attribute for testcases #12

Open
LordAro opened this issue Dec 12, 2022 · 0 comments
Open

Support the 'file' attribute for testcases #12

LordAro opened this issue Dec 12, 2022 · 0 comments

Comments

@LordAro
Copy link

LordAro commented Dec 12, 2022

GitLab test output supports the (apparently non-standard?) file attribute, which enables tests to be linked to the files they came from:

image

I'll admit, I'm not entirely sure where this attribute comes from, as it's not mentioned in any of the official JUnit specs, nor does it even appear in GitLab's own documentation. But regardless, currently TAP::Formatter::JUnit does not add this attribute and it'd be very nice to have.

My current workaround for this is the exceptionally ugly:

mkdir tap
tar -f tap.tar.gz -C tap -zx
cd tap
for i in `find t xt -name '*.t'` ; do
    perl -0777pe 's@(\s*)<testcase([^>]*)name="@\1<testcase\2file="'$i'" name="@sg' $i.junit.xml >> ../junit-raw.xml
done
cd ..
perl -0777pe 's@</testsuites>\s*<\?xml[^>]*\?>\s*<testsuites>@@sg' junit-raw.xml > junit.xml

(that is, unpacking the archive generated by prove --archive, adding the file attribute, then very much hackily concatenating the files all back together again)

Is this something you'd be open to adding? I'm happy to make a pull request that adds it to the output - as best as I can tell, it's just adding 3 lines to the relevant testcase objects.

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

1 participant