Subject: | Test prefix environment-var to have package-names in Jenkins CI |
I have a perl app split between several modules and Jenkins just
displays a single package '(root)' and inside it all the .t filenames
are jumbled together.
The attached diff is an implementation (very minimal, no input
validation) that allows you to set env-var JUNIT_PREFIX.
This lets me have a different prefix (db, app, web) for each run of
prove and so db/auth.t, app/auth.t, web/auth.t
If this feature is of any interest, I would be happy to rework the patch
properly, add some tests etc. and provide it on github.
Subject: | prefix_diff.txt |
--- /usr/local/share/perl/5.14.2/TAP/Harness/JUnit.pm 2012-07-29 10:03:06.000000000 +0100
+++ /var/lib/jenkins/perl5/lib/perl5/TAP/Harness/JUnit.pm 2012-07-29 12:15:03.912167519 +0100
@@ -191,8 +191,12 @@
}
}
+ my $prefixname = ($ENV{JUNIT_PREFIX})
+ ? $ENV{JUNIT_PREFIX}.'.'.$name
+ : $name;
+
my $xml = {
- name => $name,
+ name => $prefixname,
failures => 0,
errors => 0,
tests => undef,
@@ -234,7 +238,7 @@
my $test = {
'time' => $time,
name => $self->uniquename($xml, $result->description),
- classname => $name,
+ classname => $prefixname,
};
if ($result->ok eq 'not ok') {
@@ -263,7 +267,7 @@
push @{$xml->{testcase}}, {
'time' => $time,
name => $self->uniquename($xml, 'Test died too soon, even before plan.'),
- classname => $name,
+ classname => $prefixname,
failure => {
type => 'Plan',
message => 'The test suite died before a plan was produced. You need to have a plan.',
@@ -279,7 +283,7 @@
push @{$xml->{testcase}}, {
'time' => $time,
name => $self->uniquename($xml, 'Number of runned tests does not match plan.'),
- classname => $name,
+ classname => $prefixname,
failure => {
type => 'Plan',
message => ($xml->{failures} > 0
@@ -298,7 +302,7 @@
push @{$xml->{testcase}}, {
'time' => $time,
name => $self->uniquename($xml, 'Test returned failure'),
- classname => $name,
+ classname => $prefixname,
failure => {
type => 'Died',
message => "Test died with return code $badretval",