GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Test::Parser(3) User Contributed Perl Documentation Test::Parser(3)

Test::Parser - Base class for parsing log files from test runs, and displays in an XML syntax.

 use Test::Parser::MyTest;

 my $parser = new Test::Parser::MyTest;
 $parser->parse($text) 
    or die $parser->error(), "\n";
 printf("Num Errors:    %8d\n", $parser->num_errors());
 printf("Num Warnings:  %8d\n", $parser->num_warnings());
 printf("Num Executed:  %8d\n", $parser->num_executed());
 printf("Num Passed:    %8d\n", $parser->num_passed());
 printf("Num Failed:    %8d\n", $parser->num_failed());
 printf("Num Skipped:   %8d\n", $parser->num_skipped());

 printf("\nErrors:\n");
 foreach my $err ($parser->errors()) {
     print $err;
 }

 printf("\nWarnings:\n");
 foreach my $warn ($parser->warnings()) {
     print $warn;
 }

 print $parser->to_xml();

This module serves as a common base class for test log parsers. These tools are intended to be able to parse output from a wide variety of tests - including non-Perl tests.

The parsers also write the test data into the 'Test Result Publication Interface' (TRPI) XML schema, developed by SpikeSource. See http://www.spikesource.com/testresults/index.jsp?show=trpi-schema

Creates a new Test::Parser object.

Gets/sets name parameter. user-customizable identification tag

Gets/sets testname parameter.

Method to print test result data from the Test::Parser object in xml format following the trpi schema. Find the trpi schema here: http://developer.osdl.org/~jdaiker/trpi_extended_proposal.xsd

A method that adds test column information into the data structure of the Test::Parser object appropriately. This is a helper method to be used from the parse_line method.

A method that adds data values corresponding to a given column

A method that increments the num-datum variable

Function to output all data, good for debuging

Turns on debug level. Set to 0 or undef to turn off.

type()

Gets or sets the testsuite type. Valid values include the following: unit, regression, load, integration, boundary, negative, stress, demo, standards

    Purpose: To find individual key values parsed from test results
    Input: The search key, the 'datum' the key is stored in
    Output: Data stored under the search key, or the search key if not found

Call this routine to perform the parsing process. $input can be any of the following:

    * A text string
    * A filename of an external log file to parse
    * An open file handle (e.g. \*STDIN)

If you are dealing with a very large file, then using the filename approach will be more memory efficient. If you wish to use this program in a pipe context, then the file handle style will be more suitable.

This routine simply iterates over each newline-separated line of text, calling _parse_line. Note that the default _parse_line() routine does nothing particularly interesting, so you will probably wish to subclass Test::Parser and provide your own implementation of parse_line() to do what you need.

The 'name' argument allows you to specify the log filename or other indication of the source of the parsed data. 'path' allows specification of the location of this file within the test run directory. By default, if $input is a filename, 'name' and 'path' will be taken from that, else they'll be left blank.

If the filename contains multiple test records, parse() simply parses the first one it finds, and then returns the constant Test::Parser::END_OF_RECORD. If your input file contains multiple records, you probably want to call parse in the GLOB fashion. E.g.,

    my @logs;
    open (FILE, 'my.log') or die "Couldn't open: $!\n";
    while (FILE) {
        my $parser = new Test::Parser;
        $parser->parse(\*FILE);
        push @logs, $parser;
    }
    close (FILE) or die "Couldn't close: $!\n";

Virtual function for parsing a line of test result data. The base class' implementation of this routine does nothing interesting.

You will need to override this routine to customize it to your application. The parse() routine will call this iteratively for each line of text in the test output file.

Returns undef on error. The error message can be retrieved via error().

The number of warnings found

Returns a reference to an array of the warnings encountered.

The number of errors found

Returns a reference to an array of the errors encountered.

Bryce Harrington <bryce@osdl.org>

Copyright (C) 2005 Bryce Harrington. All Rights Reserved.

This script is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

perl, Test::Metadata
2008-02-27 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.