Dashboard > Pulse v2.0 > ... > pulse Files > regex-test.pp
  Pulse v2.0 Log In | Sign Up   View a printable version of the current page.  
  regex-test.pp
Added by Jason Sankey, last edited by Jason Sankey on Jan 15, 2009  (view change)
Labels: 
(None)

Pulse Manual Index

Regular Expression Test Post-Processor

The Regular expression test post-processor is used to process arbitrary unstructured test reports. Based on a single regular expression, the test report is processed one line at a time. Test name and status information is extracted from each line and used to generate a test report.

Escaping

Note that as the dollar sign character ($) and backslash character (\) have special meanings both in Pulse files and in regular expressions, you must take care when writing expressions that include these characters. See Escaping in Regular Expressions for details.

Attibutes

Attribute Description Required? Default
name The name of the post-processor. Yes  
details-group The index of the regex group that contains test details (reported in the details column in test reports). No  
error-status The tests status that indicates the test errored. No ERROR
failure-status The test status that indicates the test has failed. No FAILURE
name-group The index of the regex group that contains the test name. Yes  
pass-status The test status that indicates the test has passed. No PASS
regex The regular expression used to extract information. No  
skipped-status The test status that indicates the test was skipped. No SKIPPED
status-group The index of the regex group that contains the test status. Yes  
trim Indicates whether or not whitespace should be trimmed from around the regex. No True

See also Test Post-Processors.

Note: If the regex is not defined as an attribute, it must be defined in the body of the post processor. See below for an example.

Child Elements

None.

Examples

In this example, we want to configure the regex-test post processor to handle the following test report

[PASS] 10/16/2006:18:20:58:EDT: <TEST COMMAND>
[PASS] 10/16/2006:18:20:58:EDT: <TEST COMMAND>
[PASS] 10/16/2006:18:20:58:EDT: <TEST COMMAND>
[FAIL] 10/16/2006:18:20:58:EDT: <TEST COMMAND>
[PASS] 10/16/2006:18:20:58:EDT: <TEST COMMAND>
[PASS] 10/16/2006:18:20:58:EDT: <TEST COMMAND>

In this test report, we see that the status of the test is available at the start of the line, indicated by PASS or FAIL, and the name of the test is available at the end of the line, ie: TEST COMMAND. A simple regex that can extract this information would be [(.*)].*<(.*)>, where regex group 1 is the status and group 2 is the test name. Using this information, we can configure the test-regex post processor as follows:

<regex-test.pp name="sample-regex-test" status-group="1" name-group="2" pass-status="PASS" failure-status="FAIL"><![CDATA[\\[(.*)\\].*<(.*)>]]></regex-test.pp>

<recipe name="default">
    <command name="build">
        <ant targets="build.all"/>
        <artifact name="test report" file="build/reports/test.txt" fail-if-not-present="false">
            <process processor="${sample-regex-test}"/>
        </artifact>
    </command>
</recipe>

Note that in this example, because the regular expression contains '<' and '>', it needs to be specified in a CDATA section. If the '<' and '>' characters were not there, then the regex can be specified as an attribute.

Zutubi wiki is Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.10 Build:#528 Nov 29, 2006) - Bug/feature request - Contact Administrators