Fuego wiki

Login or create account

parser func split output per testcase

NAME [edit section]


SYNOPSIS [edit section]

  • split_output_per_testcase(regex, measurements, info_follows_regex)

DESCRIPTION [edit section]

This function splits the test log into individual files corresponding to data from each testcase in the test results.

It scans the test log using the provided python regular expression, and collects lines from the test log that are either before or after the lines that match the regular expression, and puts groups of lines into separate files, assigning each group of lines to each testcase in the measurements list.

These files are referenced by the HTML generator for tables that appear in the Jenkins interface for the job related to this run. Thus, the user can click on a link in the HTML table and see the text for just that test case.

See the output for Functional.jpeg for an example.

Arguments [edit section]

This function takes 2 mandatory arguments and one optional one.
  • regex - is a python regular expression string used to identify the testcase result data line
  • measurements - is the list of testcase results
  • (optional) info_follows_regex - if true, indicates that the data lines following a match should be used, rather than the data lines preceding the match.

Regex and measurements are usually the same as used with the process function.

Description of splitting [edit section]

Regex is used to scan through the testlog and find matching lines for each testcase.

Here is an example of standard formatting:

  start lines
  more data1
  data2 foo bar
  more lines

In this case, if the regex was "TEST (\d+) (.*)$" the line would be split into the groups:

  start lines
  more data1
  data2 foo bar

These would be referenced as testcase "test1" and testcase "test2", in the json file (if that's how the parser labeled them - which is what the example below does).

Note that the groups of output from the log are assigned to testcases by matching the corresponding position in the list of testcases in the measurements data structure (which is a python list). That is, the block of text is assigned to the first testcase listed in measurements; the second block of text to the second testcase, etc.

By default, the data lines preceding a matching result line are coalesced into the block of lines for that testcase. However, some programs may format their data with the data following the result line. In this case, the argument info_follows_regex argument should be set to True.

EXAMPLES [edit section]

Here is an example usage of split_output_per_testcase:
    regex_string = '^TEST-(\d+) (.*)$'
    matches = plib.parse_log(regex_string)
    if matches:
        for m in matches:
            measurements['default.test' + m[0]] = 'PASS' if m[1] == 'OK' else 'FAIL'
    # split the output for each testcase
    plib.split_output_per_testcase(regex_string, measurements)

ENVIRONMENT [edit section]

The "" module uses the following environment variables, to find the test log path

OUTPUT [edit section]

split_output_per_testcase makes a directory called 'result' in the log directory for the run, and populates it with a directory per test set. Inside each test set directory is a directory called "outputs", with a file per testcase (using the testcase name as the file name, suffixed with ".log" inside that.

Note: test_start.log may contain information that precedes the first test case, and test_end.log may contain information that follows the last test case.

RETURN [edit section]


SOURCE [edit section]

Located in scripts/parser/

SEE ALSO [edit section]

TBWiki engine 1.8.3 by Tim Bird