Skip to content

Support the 'file' attribute for testcases #12

@LordAro

Description

@LordAro

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions