Feature request: Transform class name before resolving class name into file name
windymelt opened this issue · 11 comments
Dear maintainer,
This is a feature request. I'm perl engineer using this action, along https://metacpan.org/pod/TAP::Harness::JUnit .
In short, my test runner generates strange report xml file (because perl is not JVM language):
- Test file
t/Foo/Bar/Qux.t
is represendted as classt.Foo.Bar.Qux_t
in JUnit XML - action-junit-report tries to find
t/Foo/Bar/Qux_t
to annotate error message - the action cannot find test file, so we cannot annotate error message in correct position
Thus, I suggest following feature to resolve test file accurately:
- Class name transformer , represented in regex (or some similar way), that intercepts mapping from class name to file name
Thanks for great action, working perfectly other language I'm developing in.
Hello @windymelt
Thank you so much for the feature suggestion. Sounds like a great solution to make the action more flexible.
Looking into this, another problem which I'd see for this is that it probably would not have the right line numbers in those situations? 🤔
Do you have a sample test output, will it contain line number information or so?
Sorry for late reply.
Here is sample output for testcase
:
<testcase name="L123: ..." classname="t.Foo.Bar.Blah.Blah.Blah.FileName_t" time="4.50611114501953e-05" />
Is this enough?
Unfortunately, sometimes name
attribute does not contain linum info. Using linum 1 instead of actual linum may be useful.
Could you please test the PR here: #614
You can use it by referring to its full ref 9578c0df5d710a4c8eab4f8977a145374b150dc8
as version.
Not sure if possible but it would be great to have testcases for this scenario added.
Thank you very much!! I'll test that ref.
I provided this option to see warning:
transformers: |
[{"searchValue":"\\\.","replaceValue":"/"},{"searchValue":"_t\\\z","replaceValue":".t"}]
=>
⚠️ Transformers provided, but they couldn't be parsed. Fallback to Defaults.
JSON parsing is failing?
The default is [{"searchValue":"::","replaceValue":"/"}]
Without trying it out, I'd say maybe it's due to the count of \
. a normal \
needs to be escaped as \\
. So to only match a .
you want to already have \\.
If you want to match \.
(and the regex would be \\\.
it would probably be escaped as: \\\\\\.
.
Just looked deeper into this, the problem is that javascript does not support /z
-> https://stackoverflow.com/a/21786514/325479
Something like this should also work though: https://github.com/mikepenz/action-junit-report/pull/614/files#diff-7e8670dee8014834b8a492f48380862706e856032dd2d978ef91cd5ad2103fe2R590-R617