| 4778 |
dpurdie |
1 |
########################################################################
|
| 6177 |
dpurdie |
2 |
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
|
| 4778 |
dpurdie |
3 |
#
|
|
|
4 |
# Module name : jats_runutf.pm
|
|
|
5 |
# Module type : JATS Utility
|
|
|
6 |
# Compiler(s) : Perl
|
|
|
7 |
# Environment(s): jats
|
|
|
8 |
#
|
|
|
9 |
# Description : JATS Make Time Test Harness Support
|
|
|
10 |
# This package contains fucntions that will be used by JATS
|
|
|
11 |
# to invoke the tests.
|
|
|
12 |
#
|
|
|
13 |
# This is more powerful that the previous shell-based solution
|
|
|
14 |
# that had problems under windows.
|
|
|
15 |
#
|
|
|
16 |
# The functions are designed to be invoked as:
|
|
|
17 |
# $(GBE_PERL) -Mjats_runutf -e <function> -- <args>+
|
|
|
18 |
#
|
|
|
19 |
# The functions in this packages are designed to take parameters
|
|
|
20 |
# from @ARVG as this makes the interface easier to read.
|
|
|
21 |
#
|
|
|
22 |
# Usage : See POD at the end of this file
|
|
|
23 |
#
|
|
|
24 |
#......................................................................#
|
|
|
25 |
|
|
|
26 |
require 5.008_002;
|
|
|
27 |
use strict;
|
|
|
28 |
use warnings;
|
|
|
29 |
|
|
|
30 |
package jats_runutf;
|
|
|
31 |
|
|
|
32 |
our (@ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS, $VERSION);
|
|
|
33 |
use Exporter;
|
|
|
34 |
use JatsError qw(:name=jats_runutf);
|
| 4780 |
dpurdie |
35 |
use Pod::Usage; # required for help support
|
| 4778 |
dpurdie |
36 |
use Getopt::Long;
|
|
|
37 |
use File::Spec;
|
| 5035 |
dpurdie |
38 |
use XML::Simple;
|
| 4778 |
dpurdie |
39 |
|
|
|
40 |
$VERSION = 1.00;
|
|
|
41 |
@ISA = qw(Exporter);
|
|
|
42 |
|
|
|
43 |
# Symbols to autoexport (:DEFAULT tag)
|
| 4780 |
dpurdie |
44 |
@EXPORT = qw( processUtf help man );
|
| 4778 |
dpurdie |
45 |
|
|
|
46 |
#
|
|
|
47 |
# Global Variables
|
|
|
48 |
#
|
|
|
49 |
my $opt_verbose = $ENV{'GBE_VERBOSE'}; # Allow global verbose
|
| 4780 |
dpurdie |
50 |
my $opt_help = 0;
|
| 4778 |
dpurdie |
51 |
|
|
|
52 |
# Data to be passed into the filter function
|
|
|
53 |
# Defined values are:
|
| 4781 |
dpurdie |
54 |
# ARGS - An hash of user arguments
|
|
|
55 |
# DIR - Optional. Name of test subdir
|
| 4778 |
dpurdie |
56 |
# FILTER - Name of the filter
|
| 4781 |
dpurdie |
57 |
# IDIR - Path to original directory
|
| 4778 |
dpurdie |
58 |
# INTERFACE - Abs Path to Interface directory
|
|
|
59 |
# LOCAL - Abs Path to Local directory
|
|
|
60 |
# OUTDIR - Abs Path to output directory
|
| 4780 |
dpurdie |
61 |
# OUTFILE - Abs Path to suggested output file
|
| 4778 |
dpurdie |
62 |
# PKGDIR - Abs Path to Packaging directory
|
|
|
63 |
# ROOT - Abs Path to Root of the build
|
|
|
64 |
# TARGET - Current make target
|
|
|
65 |
# TYPE - Built type P or D
|
| 5387 |
dpurdie |
66 |
# UTFUID - Unique Test Identifier
|
| 4781 |
dpurdie |
67 |
# UTFNAME - Test Name
|
| 6619 |
dpurdie |
68 |
# UTFTEST - Recommended file root for test results
|
| 5035 |
dpurdie |
69 |
# UTFRC - Result Code from Unit Test run
|
| 6898 |
dpurdie |
70 |
# RCFILE - Path to the RC File (optional)
|
| 4778 |
dpurdie |
71 |
#
|
| 4780 |
dpurdie |
72 |
our %filterData;
|
| 4778 |
dpurdie |
73 |
|
| 4780 |
dpurdie |
74 |
#-------------------------------------------------------------------------------
|
|
|
75 |
# Function : help
|
|
|
76 |
# man
|
|
|
77 |
#
|
|
|
78 |
# Description : Utility functions to make is easier for users to get POD
|
|
|
79 |
# from this module
|
|
|
80 |
#
|
|
|
81 |
# Inputs :
|
|
|
82 |
#
|
|
|
83 |
# Returns :
|
|
|
84 |
#
|
| 4778 |
dpurdie |
85 |
|
| 4780 |
dpurdie |
86 |
sub help
|
|
|
87 |
{
|
|
|
88 |
pod2usage(-verbose => 0, -input => __FILE__);
|
|
|
89 |
}
|
|
|
90 |
|
|
|
91 |
sub man
|
|
|
92 |
{
|
|
|
93 |
pod2usage(-verbose => 2, -input => __FILE__);
|
|
|
94 |
}
|
|
|
95 |
|
| 4778 |
dpurdie |
96 |
#-------------------------------------------------------------------------------
|
|
|
97 |
# Function : processUtf
|
|
|
98 |
#
|
|
|
99 |
# Description : Main function to process UTF results
|
| 4787 |
dpurdie |
100 |
# This function will locate a suitable filter process and invoke
|
|
|
101 |
# it to process the results
|
| 4778 |
dpurdie |
102 |
#
|
| 4787 |
dpurdie |
103 |
# The filter process will be provided in a Perl Module
|
| 4778 |
dpurdie |
104 |
# It may be a part of JATS or an external modules provided
|
| 4787 |
dpurdie |
105 |
# within an external package. ie(utf may provide its own filter)
|
| 4778 |
dpurdie |
106 |
#
|
| 4787 |
dpurdie |
107 |
#
|
| 4778 |
dpurdie |
108 |
# Inputs : None. Parameters are passed via @ARGV
|
|
|
109 |
#
|
|
|
110 |
# Returns : Nothing
|
|
|
111 |
#
|
|
|
112 |
|
|
|
113 |
sub processUtf
|
|
|
114 |
{
|
| 4780 |
dpurdie |
115 |
my $argCount = scalar @ARGV;
|
| 4778 |
dpurdie |
116 |
my $result = GetOptions (
|
| 4780 |
dpurdie |
117 |
"help|h:+" => \$opt_help,
|
|
|
118 |
"manual:3" => \$opt_help,
|
| 4778 |
dpurdie |
119 |
"verbose:+" => \$opt_verbose, # Only set to to 0,1 or 3
|
| 4780 |
dpurdie |
120 |
"root=s" => \$filterData{ROOT},
|
|
|
121 |
"filter=s" => \$filterData{FILTER},
|
|
|
122 |
"interface=s" => \$filterData{INTERFACE},
|
|
|
123 |
"local=s" => \$filterData{LOCAL},
|
|
|
124 |
"target=s" => \$filterData{TARGET},
|
|
|
125 |
"pkgdir=s" => \$filterData{PKGDIR},
|
|
|
126 |
"type=s" => \$filterData{TYPE},
|
| 4781 |
dpurdie |
127 |
"dir=s" => \$filterData{DIR},
|
| 6898 |
dpurdie |
128 |
"rcfile=s" => \$filterData{RCFILE},
|
|
|
129 |
"arg=s" => sub {my ( $key, $value) = split('=', $_[1], 2); $filterData{ARGS}{uc $key} = $value;},
|
| 4778 |
dpurdie |
130 |
);
|
|
|
131 |
|
| 4780 |
dpurdie |
132 |
pod2usage(-verbose => 0, -input => __FILE__) if ($opt_help == 1 || ! $result || $argCount < 1);
|
|
|
133 |
pod2usage(-verbose => 1, -input => __FILE__) if ($opt_help == 2 );
|
|
|
134 |
pod2usage(-verbose => 2, -input => __FILE__) if ($opt_help > 2);
|
|
|
135 |
|
| 4778 |
dpurdie |
136 |
# Reconfigure the verbosity level
|
|
|
137 |
ErrorConfig( 'verbose', $opt_verbose);
|
| 4780 |
dpurdie |
138 |
Error("Internal: No Filter specified") unless defined $filterData{FILTER};
|
|
|
139 |
Error("Internal: No PkgDir specified") unless defined $filterData{PKGDIR};
|
| 4778 |
dpurdie |
140 |
|
|
|
141 |
#
|
|
|
142 |
# Locate the required filter module
|
|
|
143 |
# Filter modules have a name of the form:
|
|
|
144 |
# UtfFilter_<FilterName>.pm
|
|
|
145 |
# And can be located:
|
|
|
146 |
# within JATS
|
|
|
147 |
# in 'TOOLS/LIB'
|
|
|
148 |
# within a Package declared
|
|
|
149 |
# with a BuildPkgArchive or a LinkPkgArchive
|
|
|
150 |
# within the packages 'tools/scripts' subdirectory
|
|
|
151 |
# within the current package
|
| 4996 |
dpurdie |
152 |
# Perl modules with ROOT/gbe/utfFilters
|
| 4778 |
dpurdie |
153 |
# or in the current directory
|
|
|
154 |
|
| 4787 |
dpurdie |
155 |
my $module_name = join('_','UtfFilter', lc $filterData{FILTER});
|
| 4778 |
dpurdie |
156 |
Verbose("Filter Module: $module_name");
|
|
|
157 |
|
|
|
158 |
# Extend Perl Module search path for package-local filters
|
|
|
159 |
# Check the current directory
|
|
|
160 |
# The current directory is also within @INC, but it is at the end
|
|
|
161 |
# thus local filter will not override external filters. Place the
|
|
|
162 |
# current directory first - if it conatins a filter.
|
|
|
163 |
|
|
|
164 |
if (-f "$module_name.pm" )
|
|
|
165 |
{
|
|
|
166 |
Verbose("Extend the filter module search path: Current Directory");
|
|
|
167 |
unshift @INC, '.';
|
|
|
168 |
}
|
|
|
169 |
else
|
|
|
170 |
{
|
|
|
171 |
#
|
|
|
172 |
# Check package-local directory
|
|
|
173 |
# <root>/gbe/utfFilters
|
|
|
174 |
#
|
| 4780 |
dpurdie |
175 |
my $localUtfPath = File::Spec->catfile($filterData{ROOT}, 'gbe', 'utfFilters');
|
| 4778 |
dpurdie |
176 |
if ( -f( "$localUtfPath/$module_name.pm") )
|
|
|
177 |
{
|
|
|
178 |
Verbose("Extend the filter module search path: $localUtfPath");
|
|
|
179 |
unshift @INC, $localUtfPath;
|
|
|
180 |
}
|
|
|
181 |
}
|
|
|
182 |
|
|
|
183 |
#
|
|
|
184 |
# Locate a Perl Module of the required name
|
|
|
185 |
#
|
|
|
186 |
eval "require $module_name";
|
|
|
187 |
if ($@)
|
|
|
188 |
{
|
|
|
189 |
Error ("Could not load required filter module: $module_name");
|
|
|
190 |
}
|
|
|
191 |
|
|
|
192 |
#
|
|
|
193 |
# Ensure that the filter contains the required interface methods
|
|
|
194 |
#
|
|
|
195 |
foreach my $fname ( qw(processUtf))
|
|
|
196 |
{
|
|
|
197 |
ReportError("Required function DOES NOT exist: $fname")
|
|
|
198 |
unless (defined($module_name->can($fname)));
|
|
|
199 |
}
|
|
|
200 |
ErrorDoExit();
|
|
|
201 |
|
|
|
202 |
#
|
|
|
203 |
# Convert potentially local paths to absolute paths
|
|
|
204 |
# Simplifies use when the CWD is changed
|
|
|
205 |
#
|
|
|
206 |
foreach my $entry ( qw(INTERFACE LOCAL PKGDIR ROOT))
|
|
|
207 |
{
|
| 4780 |
dpurdie |
208 |
$filterData{$entry} = File::Spec->rel2abs($filterData{$entry} );
|
| 4778 |
dpurdie |
209 |
}
|
|
|
210 |
|
|
|
211 |
#
|
|
|
212 |
# Add in known values from the environment
|
|
|
213 |
#
|
| 4780 |
dpurdie |
214 |
$filterData{TYPE} = $ENV{'GBE_MAKE_TYPE'};
|
|
|
215 |
Error("Internal: EnvVar 'GBE_MAKE_TYPE' not specified") unless $filterData{TYPE};
|
| 4778 |
dpurdie |
216 |
|
| 5387 |
dpurdie |
217 |
$filterData{UTFUID} = $ENV{'GBE_UTFUID'};
|
|
|
218 |
Error("Internal: EnvVar 'GBE_UTFUID' not specified") unless $filterData{UTFUID};
|
| 4781 |
dpurdie |
219 |
|
|
|
220 |
$filterData{UTFNAME} = $ENV{'GBE_UTFNAME'};
|
|
|
221 |
Error("Internal: EnvVar 'GBE_UTFNAME' not specified") unless $filterData{UTFNAME};
|
|
|
222 |
|
| 4996 |
dpurdie |
223 |
$filterData{OUTFILE} = $ENV{'GBE_UTFFILE'};
|
|
|
224 |
Error("Internal: EnvVar 'GBE_UTFFILE' not specified") unless $filterData{OUTFILE};
|
|
|
225 |
|
| 6619 |
dpurdie |
226 |
$filterData{UTFTEST} = $ENV{'GBE_UTFTEST'};
|
|
|
227 |
Error("Internal: EnvVar 'GBE_UTFTEST' not specified") unless $filterData{UTFTEST};
|
|
|
228 |
|
| 4781 |
dpurdie |
229 |
$filterData{IDIR} = File::Spec->rel2abs('.');
|
|
|
230 |
|
| 4778 |
dpurdie |
231 |
#
|
| 4996 |
dpurdie |
232 |
# The environment provides a recommended (unqiue) output file
|
|
|
233 |
# Extact the directory part and ensure that it exists
|
|
|
234 |
# Brute file filename chop
|
| 4778 |
dpurdie |
235 |
#
|
| 4996 |
dpurdie |
236 |
$filterData{OUTDIR} = $filterData{OUTFILE};
|
|
|
237 |
$filterData{OUTDIR} =~ s~/[^/]*$~~;
|
|
|
238 |
Error("Internal: OUTDIR is empty") unless (length($filterData{OUTDIR}) > 1);
|
| 4778 |
dpurdie |
239 |
|
| 4996 |
dpurdie |
240 |
mkdir $filterData{OUTDIR};
|
|
|
241 |
Error("Creating utfResults directory", "Path: $filterData{OUTDIR}") unless -d $filterData{OUTDIR};
|
|
|
242 |
|
| 4781 |
dpurdie |
243 |
# Allow the output file to be used
|
|
|
244 |
# Not in the build system, but in a user development area
|
| 4996 |
dpurdie |
245 |
#
|
|
|
246 |
my $filename = $filterData{OUTFILE};
|
| 4781 |
dpurdie |
247 |
unlink $filename if -e $filename;
|
| 4996 |
dpurdie |
248 |
Error("Output file: Cannot delete $filename: $!") if -e $filename;
|
|
|
249 |
Verbose("Writing output to: $filename");
|
| 4778 |
dpurdie |
250 |
|
|
|
251 |
#
|
| 5035 |
dpurdie |
252 |
# Recover the result code of the unit test run
|
| 7219 |
dpurdie |
253 |
# Do this before changing directory as the paths are relative
|
| 7226 |
dpurdie |
254 |
# The rcfile will be specified as relative to the current directory
|
| 5035 |
dpurdie |
255 |
#
|
| 6898 |
dpurdie |
256 |
if (defined $filterData{RCFILE}) {
|
|
|
257 |
my $rcFile = $filterData{RCFILE};
|
|
|
258 |
Verbose("Result Code File:", $rcFile);
|
|
|
259 |
if (-f $rcFile)
|
|
|
260 |
{
|
|
|
261 |
open( my $rcFile, '<', $rcFile) || Error ("Cannot open file : $!");
|
|
|
262 |
$filterData{UTFRC} = <$rcFile>;
|
|
|
263 |
$filterData{UTFRC} =~ s~\s+$~~;
|
|
|
264 |
$filterData{UTFRC} =~ s~^\s+~~;
|
|
|
265 |
Verbose("Recover Result Code: ", $filterData{UTFRC});
|
|
|
266 |
close $rcFile;
|
|
|
267 |
} else {
|
|
|
268 |
Error("ResultCode file specified, but not found: $rcFile");
|
|
|
269 |
}
|
| 7219 |
dpurdie |
270 |
}
|
|
|
271 |
|
| 5035 |
dpurdie |
272 |
#
|
| 7219 |
dpurdie |
273 |
# Change to the test directory
|
|
|
274 |
# Only if required
|
|
|
275 |
# Ensure that the specified directory exists
|
|
|
276 |
#
|
|
|
277 |
if (defined $filterData{DIR})
|
|
|
278 |
{
|
|
|
279 |
Verbose("Change directory:", $filterData{DIR});
|
|
|
280 |
Error("Internal: Test directory does not exist: $filterData{DIR}")
|
|
|
281 |
unless (-d $filterData{DIR});
|
|
|
282 |
chdir $filterData{DIR} || Error("Internal: Could not chdir to: $filterData{DIR}");
|
|
|
283 |
}
|
|
|
284 |
|
|
|
285 |
#
|
| 4780 |
dpurdie |
286 |
# Diagnostics
|
|
|
287 |
#
|
|
|
288 |
if (IsVerbose(1))
|
|
|
289 |
{
|
|
|
290 |
DebugDumpData("Filter Parameters", \%filterData);
|
|
|
291 |
}
|
|
|
292 |
|
|
|
293 |
#
|
| 4778 |
dpurdie |
294 |
# Invoke the process method
|
|
|
295 |
# If it has a problem it should use 'Error(...)' to report it
|
| 4996 |
dpurdie |
296 |
# There is no exit code processing, but if there is - needs to be false
|
| 4778 |
dpurdie |
297 |
#
|
| 4780 |
dpurdie |
298 |
Message("Processing UTF test results using filter: $filterData{FILTER}");
|
| 4996 |
dpurdie |
299 |
my $rv = $module_name->processUtf(\%filterData);
|
|
|
300 |
Error ("Unit Test Failure: Errors detected in the result set")
|
|
|
301 |
if ( defined($rv) && ! $rv );
|
| 4778 |
dpurdie |
302 |
}
|
|
|
303 |
|
| 5035 |
dpurdie |
304 |
#-------------------------------------------------------------------------------
|
|
|
305 |
# Function : Write XML
|
|
|
306 |
#
|
|
|
307 |
# Description : Write user XML results to file
|
|
|
308 |
# Will insert standard data
|
|
|
309 |
#
|
|
|
310 |
# Inputs : $options - Ref to a hash of options
|
|
|
311 |
# $results - Ref to an array of results
|
|
|
312 |
# Expect a ref to an array of Hash Values
|
|
|
313 |
#
|
|
|
314 |
# Returns : Nothing
|
|
|
315 |
#
|
|
|
316 |
sub writeXmlResults
|
|
|
317 |
{
|
|
|
318 |
my ($options, $results) = @_;
|
| 6898 |
dpurdie |
319 |
|
|
|
320 |
# Create a summary report - more for the user
|
|
|
321 |
my $summary;
|
|
|
322 |
my $total = 0;
|
|
|
323 |
foreach my $entry ( @$results) {
|
|
|
324 |
if (exists $entry->{OUTCOME}) {
|
|
|
325 |
$summary->{$entry->{OUTCOME}}++;
|
|
|
326 |
$total++;
|
|
|
327 |
}
|
|
|
328 |
}
|
|
|
329 |
my $summaryString = '';
|
|
|
330 |
my $joiner = '';
|
|
|
331 |
foreach my $entry ( sort keys %{$summary}) {
|
|
|
332 |
$summaryString .= $joiner . $entry . ':' . $summary->{$entry};
|
|
|
333 |
$joiner = ', ';
|
|
|
334 |
}
|
|
|
335 |
Message("Total: $total. $summaryString");
|
|
|
336 |
|
|
|
337 |
|
| 5035 |
dpurdie |
338 |
#
|
|
|
339 |
# Create a data structure to contain the dummy test result
|
|
|
340 |
# Insert TARGET and TYPE attributes
|
|
|
341 |
#
|
|
|
342 |
my %xml;
|
|
|
343 |
$xml{TestResults}{TARGET} = $options->{TARGET};
|
|
|
344 |
$xml{TestResults}{TYPE} = $options->{TYPE};
|
|
|
345 |
|
|
|
346 |
@{$xml{TestResults}{TestResult}} = @$results;
|
|
|
347 |
|
|
|
348 |
# The 'MESSAGE' key for failed tests forms the content of the
|
|
|
349 |
# <TestResult> element. Other keys are converted to attributes.
|
|
|
350 |
# Assign <TestResults> as the root XML node.
|
|
|
351 |
my $xmlData = XMLout(\%xml, ContentKey => 'MESSAGE', RootName => 'TestResults', KeepRoot => 1);
|
|
|
352 |
|
|
|
353 |
# Write the data to the XML file.
|
|
|
354 |
my $filename = $options->{OUTFILE};
|
|
|
355 |
open ( my $outFile, ">", $filename)
|
|
|
356 |
|| Error(" Cannot open results file:$filename for writing: $!\n");
|
|
|
357 |
print $outFile $xmlData;
|
|
|
358 |
close $outFile;
|
|
|
359 |
}
|
|
|
360 |
|
|
|
361 |
|
| 4780 |
dpurdie |
362 |
=pod 1
|
| 4778 |
dpurdie |
363 |
|
| 4780 |
dpurdie |
364 |
=for htmltoc SYSUTIL::
|
|
|
365 |
|
|
|
366 |
=head1 NAME
|
|
|
367 |
|
|
|
368 |
jats_runutf - Post Process UTF results for build system
|
|
|
369 |
|
|
|
370 |
=head1 SYNOPSIS
|
|
|
371 |
|
|
|
372 |
$(GBE_PERL) -Mjats_runutf -e processUtf -- <args>
|
|
|
373 |
|
|
|
374 |
Options:
|
| 6898 |
dpurdie |
375 |
-help[=n] - Brief help message
|
|
|
376 |
-help -help - Detailed help message
|
|
|
377 |
-man - Full documentation
|
|
|
378 |
-verbose[=n] - Verbose operation
|
|
|
379 |
-filter=name - Name of the required processing filter
|
|
|
380 |
-target=name - Current build target
|
|
|
381 |
-root=path - Path to the root of the build
|
|
|
382 |
-pkgdir=path - Path to the packaging directory
|
|
|
383 |
-interface=path - Path to the build interface directory
|
|
|
384 |
-local=path - Path to the local build directory
|
|
|
385 |
-dir=path - Path to test directory
|
|
|
386 |
-rcfile=path - Path to a file that contains the test result code
|
| 4780 |
dpurdie |
387 |
|
|
|
388 |
=head1 OPTIONS
|
|
|
389 |
|
|
|
390 |
=over 8
|
|
|
391 |
|
|
|
392 |
=item B<-help>
|
|
|
393 |
|
|
|
394 |
Print a brief help message and exits.
|
|
|
395 |
|
|
|
396 |
=item B<-help -help>
|
|
|
397 |
|
|
|
398 |
Print a detailed help message with an explanation for each option.
|
|
|
399 |
|
|
|
400 |
=item B<-man>
|
|
|
401 |
|
|
|
402 |
Prints the manual page and exits.
|
|
|
403 |
|
|
|
404 |
=item B<-verbose>
|
|
|
405 |
|
|
|
406 |
This option will display progress information as the program executes.
|
|
|
407 |
|
|
|
408 |
=item B<-filter=name>
|
|
|
409 |
|
|
|
410 |
Name of the required processing filter.
|
|
|
411 |
|
|
|
412 |
=item B<-target=name>
|
|
|
413 |
|
|
|
414 |
The current build target.
|
|
|
415 |
|
|
|
416 |
=item B<-root=path>
|
|
|
417 |
|
|
|
418 |
The path to the root of the current build.
|
|
|
419 |
|
|
|
420 |
=item B<-pkgdir=path>
|
|
|
421 |
|
|
|
422 |
The path to the packaging directory
|
|
|
423 |
|
|
|
424 |
=item B<-interface=path>
|
|
|
425 |
|
|
|
426 |
The path to the build interface directory
|
|
|
427 |
|
|
|
428 |
=item B<-local=path>
|
|
|
429 |
|
|
|
430 |
The path to the local build directory
|
|
|
431 |
|
| 4781 |
dpurdie |
432 |
=item B<-dir=path>
|
|
|
433 |
|
|
|
434 |
The path to the directory in which the test was run.
|
|
|
435 |
|
|
|
436 |
This is optional. If provided the filter will be invoked with the
|
|
|
437 |
current working directory
|
|
|
438 |
|
| 6898 |
dpurdie |
439 |
=item B<-rcfile=path>
|
|
|
440 |
|
|
|
441 |
The path to the file that will contain the rsult code of the test run.
|
|
|
442 |
This is optional, but if provided it should exist
|
|
|
443 |
|
| 4780 |
dpurdie |
444 |
=back
|
|
|
445 |
|
|
|
446 |
=head1 DESCRIPTION
|
|
|
447 |
|
|
|
448 |
This tool is not designed to be run directly by users. It is intended to be run by the
|
|
|
449 |
JATS generated makefiles in conjunction with unit tests to process the output from a unit
|
|
|
450 |
test to provide a common output format to be passed on the build system.
|
|
|
451 |
|
|
|
452 |
Normally this process only occurs with the Auto BuildTool environment.
|
|
|
453 |
|
|
|
454 |
The tool provides the following operations:
|
|
|
455 |
|
|
|
456 |
=over 4
|
|
|
457 |
|
|
|
458 |
=item *
|
|
|
459 |
|
|
|
460 |
Sanitize environment
|
|
|
461 |
|
|
|
462 |
The environment passed to the filter processing module will be verified.
|
|
|
463 |
The path to the output directory will be created if required. All paths will be absolute.
|
|
|
464 |
|
|
|
465 |
=item *
|
|
|
466 |
|
|
|
467 |
Locate the required filter processing module. The module must be a Perl Module with a name of the form 'UtfFilter_<name>'
|
|
|
468 |
|
|
|
469 |
=item *
|
|
|
470 |
|
|
|
471 |
Invoke the required filter module.
|
|
|
472 |
|
|
|
473 |
=back
|
|
|
474 |
|
|
|
475 |
=head2 Locating the Filter Module
|
|
|
476 |
|
|
|
477 |
The filter module may be located, in order of precedence, within:
|
|
|
478 |
|
|
|
479 |
=over 4
|
|
|
480 |
|
|
|
481 |
=item *
|
|
|
482 |
|
|
|
483 |
The package currently being built.
|
|
|
484 |
|
|
|
485 |
The package may provide its own UTF post processing module. This is not encouraged.
|
|
|
486 |
|
|
|
487 |
The following locations will be examined for a suitable module:
|
|
|
488 |
|
|
|
489 |
=over 4
|
|
|
490 |
|
|
|
491 |
=item *
|
|
|
492 |
|
|
|
493 |
The current directory. The directory of the makefile.pl that is running the unit test.
|
|
|
494 |
|
|
|
495 |
=item *
|
|
|
496 |
|
|
|
497 |
A directory in the Build Root called 'gbe/UtfFilters'
|
|
|
498 |
|
|
|
499 |
=back
|
|
|
500 |
|
|
|
501 |
=item *
|
|
|
502 |
|
|
|
503 |
An external Package, within the gbe/scripts directory.
|
|
|
504 |
|
|
|
505 |
The package can be specified with either LinkPkgArchive or BuildPkgArchive directive
|
|
|
506 |
within the current packages build.pl file.
|
|
|
507 |
|
|
|
508 |
=item *
|
|
|
509 |
|
|
|
510 |
Within JATS.
|
|
|
511 |
|
|
|
512 |
Jats may provide useful filter modules.
|
|
|
513 |
|
|
|
514 |
=back
|
|
|
515 |
|
|
|
516 |
=head2 Filter Module Interface
|
|
|
517 |
|
|
|
518 |
The filter module Interface consists of four items:
|
|
|
519 |
|
|
|
520 |
=over 4
|
|
|
521 |
|
|
|
522 |
=item 1 The name of the Package
|
|
|
523 |
|
|
|
524 |
=item 1 The named function with the package
|
|
|
525 |
|
|
|
526 |
=item 1 Arguments passed to the named function
|
|
|
527 |
|
|
|
528 |
=item 1 The processing expected to be done by the named function
|
|
|
529 |
|
|
|
530 |
=item 1 The Output Format
|
|
|
531 |
|
|
|
532 |
=back
|
|
|
533 |
|
|
|
534 |
=head3 The name of the Package
|
|
|
535 |
|
|
|
536 |
Each filter function is in its own package. The package name is created by concatenating the
|
|
|
537 |
text 'UtfFilter_' with the name of the required filter.
|
|
|
538 |
|
|
|
539 |
ie: If the required filter is 'junit4', then the name of the filter package must
|
|
|
540 |
be UtfFilter_junit4 and it will be held in a file named UtfFilter_junit4.pm.
|
|
|
541 |
|
|
|
542 |
=head3 The named function with the package
|
|
|
543 |
|
|
|
544 |
The filter package must provide a function called 'processUtf'
|
|
|
545 |
|
|
|
546 |
=head3 Arguments passed to the named function
|
|
|
547 |
|
|
|
548 |
The processing function 'processUtf' is called with two arguments:
|
|
|
549 |
|
|
|
550 |
=over 4
|
|
|
551 |
|
|
|
552 |
=item 1
|
|
|
553 |
|
|
|
554 |
The name of the package
|
|
|
555 |
|
|
|
556 |
=item 2
|
|
|
557 |
|
| 4787 |
dpurdie |
558 |
A reference to a Perl hash. The hash will contain the following named items:
|
| 4780 |
dpurdie |
559 |
|
|
|
560 |
=over 4
|
|
|
561 |
|
| 4781 |
dpurdie |
562 |
=item ARGS
|
|
|
563 |
|
|
|
564 |
Optional. A hash of User Arguments passed into the filter. Use of these is filter specific.
|
|
|
565 |
|
|
|
566 |
Arguments of the form '--UtfArg=UserArg1=Value1' will be stored with a key of 'UserArg1 and a value of 'Value1'.
|
|
|
567 |
|
|
|
568 |
Arguments of the form '--UtfArg=UserArg2' will be stored with a key of 'UserArg2' and an undefined value.
|
|
|
569 |
|
|
|
570 |
=item DIR
|
|
|
571 |
|
|
|
572 |
Optional. If the Unit Test is executed in a subdirectory of the current build
|
|
|
573 |
location, then DIR will be set to the name of the subdirectory.
|
|
|
574 |
|
|
|
575 |
The current working directory will be changed to DIR before the filter function is invoked.
|
|
|
576 |
|
|
|
577 |
This item will aways exist, but it may not be defined.
|
|
|
578 |
|
| 4780 |
dpurdie |
579 |
=item FILTER
|
|
|
580 |
|
|
|
581 |
The Name of the filter
|
|
|
582 |
|
| 4781 |
dpurdie |
583 |
=item IDIR
|
|
|
584 |
|
|
|
585 |
The absolute path to the working directory, when the module is invoked, before the working
|
| 4996 |
dpurdie |
586 |
directory has been changed to 'DIR'.
|
| 4781 |
dpurdie |
587 |
|
| 4780 |
dpurdie |
588 |
=item INTERFACE
|
|
|
589 |
|
| 4781 |
dpurdie |
590 |
The absolute path to Interface directory
|
| 4780 |
dpurdie |
591 |
|
|
|
592 |
=item LOCAL
|
|
|
593 |
|
| 4781 |
dpurdie |
594 |
The absolute path to Local directory
|
| 4780 |
dpurdie |
595 |
|
|
|
596 |
=item OUTDIR
|
|
|
597 |
|
| 4781 |
dpurdie |
598 |
The absolute path to output directory
|
| 4780 |
dpurdie |
599 |
|
|
|
600 |
=item OUTFILE
|
|
|
601 |
|
| 4781 |
dpurdie |
602 |
The absolute path to suggested output file. The user does not need to use this name. It is
|
| 4780 |
dpurdie |
603 |
provided to remove the need for each filter to create a unique name.
|
|
|
604 |
|
|
|
605 |
This file will not exist.
|
|
|
606 |
|
|
|
607 |
=item PKGDIR
|
|
|
608 |
|
| 4781 |
dpurdie |
609 |
The absolute path to Packaging directory. This directory will exist.
|
| 4780 |
dpurdie |
610 |
|
|
|
611 |
=item ROOT
|
|
|
612 |
|
| 4781 |
dpurdie |
613 |
The absolute path to Root of the build
|
| 4780 |
dpurdie |
614 |
|
|
|
615 |
=item TARGET
|
|
|
616 |
|
|
|
617 |
The current make target
|
|
|
618 |
|
|
|
619 |
=item TYPE
|
|
|
620 |
|
|
|
621 |
The build type P or D
|
|
|
622 |
|
| 4781 |
dpurdie |
623 |
=item UTFNAME
|
|
|
624 |
|
|
|
625 |
The name of the test.
|
|
|
626 |
|
|
|
627 |
This may be provided by the user, or it may be system generated. Intended to be used by
|
|
|
628 |
test filters that do not have test names generated as a part of the test
|
|
|
629 |
|
|
|
630 |
=item UTFUID
|
|
|
631 |
|
|
|
632 |
A unique test identifier. This is unique with the build and is intended to:
|
|
|
633 |
|
|
|
634 |
=over 4
|
|
|
635 |
|
|
|
636 |
=item *
|
|
|
637 |
|
|
|
638 |
Allow the generation of test-unique file names for the storage of results.
|
|
|
639 |
|
|
|
640 |
=item *
|
|
|
641 |
|
|
|
642 |
Allow the reuse of output file names.
|
|
|
643 |
|
| 4780 |
dpurdie |
644 |
=back
|
|
|
645 |
|
| 5035 |
dpurdie |
646 |
=item UTFRC
|
|
|
647 |
|
|
|
648 |
The result code from the unit test run.
|
|
|
649 |
|
|
|
650 |
This will only be defined for JATS run unit tests.
|
|
|
651 |
|
| 4781 |
dpurdie |
652 |
=back
|
|
|
653 |
|
| 4787 |
dpurdie |
654 |
The return value from the function 'processUtf' is ignored. If the function encounters
|
|
|
655 |
any error it should use the Jats 'Error' function to report the error.
|
| 4780 |
dpurdie |
656 |
|
|
|
657 |
=back
|
|
|
658 |
|
|
|
659 |
=head3 The processing expected to be done by the named function
|
|
|
660 |
|
| 4787 |
dpurdie |
661 |
The processing function is expected to transform the results of a unit test into
|
|
|
662 |
a constient form so that they can be processed by the remainder of the build tool.
|
| 4780 |
dpurdie |
663 |
|
|
|
664 |
The processing should:
|
|
|
665 |
|
|
|
666 |
=over 4
|
|
|
667 |
|
|
|
668 |
=item *
|
|
|
669 |
|
|
|
670 |
Create information in the OUTDIR directory.
|
|
|
671 |
|
|
|
672 |
The filter may create a new file or insert information into an existing file.
|
|
|
673 |
|
|
|
674 |
The user may make use of the OUTFILE path, but this is not mandatory.
|
|
|
675 |
|
|
|
676 |
=item *
|
|
|
677 |
|
|
|
678 |
Report errors by calling the Jats 'Error' function. This will terminate processing.
|
|
|
679 |
|
|
|
680 |
=back
|
|
|
681 |
|
|
|
682 |
=head3 The Output Format
|
|
|
683 |
|
|
|
684 |
Yet to be defined.
|
|
|
685 |
|
| 4781 |
dpurdie |
686 |
The output format is known to the build system. It should not be
|
| 7219 |
dpurdie |
687 |
changed without also change it for the consuming tools.
|
| 4781 |
dpurdie |
688 |
|
| 4780 |
dpurdie |
689 |
=cut
|
|
|
690 |
|
|
|
691 |
|
| 4778 |
dpurdie |
692 |
1;
|