parser func split output per testcase

NAME [edit section]

split_output_per_testcase

SYNOPSIS [edit section]

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 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
  data1
  more data1
  TEST 1 PASS
  data2
  data2 foo bar
  TEST 2 FAIL
  more lines

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

  start lines
  more data1
  TEST 1 PASS
and
  data2
  data2 foo bar
  TEST 2 FAIL

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:

ENVIRONMENT [edit section]

The "common.py" 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]

Nothing.

SOURCE [edit section]

Located in scripts/parser/common.py

SEE ALSO [edit section]