diff --git a/bash_completion.sh b/bash_completion.sh index eae24c898..c4fa56a69 100644 --- a/bash_completion.sh +++ b/bash_completion.sh @@ -219,7 +219,7 @@ _buildtest () ;; report|rt) - local opts="--end --fail --filter --filterfields --format --formatfields --help --helpfilter --helpformat --latest --no-header --oldest --pager --pass --row-count --start --terse -e -f -h -n -p -s -t c clear l list p path sm summary" + local opts="--detailed --end --fail --filter --filterfields --format --formatfields --help --helpfilter --helpformat --latest --no-header --oldest --pager --pass --row-count --start --terse -d -e -f -h -n -p -s -t c clear l list p path sm summary" COMPREPLY=( $( compgen -W "${opts}" -- $cur ) ) case "${prev}" in --filter) COMPREPLY=( $( compgen -W "$(_avail_report_filterfields)" -- $cur ) ) diff --git a/buildtest/cli/__init__.py b/buildtest/cli/__init__.py index 96f5fcdac..a3b23829b 100644 --- a/buildtest/cli/__init__.py +++ b/buildtest/cli/__init__.py @@ -613,6 +613,7 @@ def build_menu(subparsers): action="store_true", help="Rerun last successful buildtest build command.", ) + filter_group.add_argument( "-f", "--filter", @@ -1109,7 +1110,7 @@ def report_menu(subparsers, parent_parser): help="Summarize test report", parents=[parent_parser["pager"]], ) - filter_group = parser_report.add_argument_group("filter", "Filter and Format table") + filter_group = parser_report.add_argument_group("filter", "Filter options") # buildtest report filter_group.add_argument( @@ -1118,28 +1119,43 @@ def report_menu(subparsers, parent_parser): help="Filter report by filter fields. The filter fields must be a key=value pair and multiple fields can be comma separated in the following format: --filter key1=val1,key2=val2 . For list of filter fields run: --helpfilter.", ) - filter_group.add_argument( - "--format", - help="format field for printing purposes. For more details see --helpformat for list of available fields. Fields must be separated by comma (usage: --format ,,...)", - ) filter_group.add_argument( "--helpfilter", action="store_true", help="List available filter fields to be used with --filter option", ) - filter_group.add_argument( - "--helpformat", action="store_true", help="List of available format fields" - ) + filter_group.add_argument( "--filterfields", action="store_true", help="Print raw filter fields for --filter option to filter the report", ) - filter_group.add_argument( + + format_group = parser_report.add_argument_group("format", "Format options") + + format_group.add_argument( + "--helpformat", action="store_true", help="List of available format fields" + ) + + format_group.add_argument( "--formatfields", action="store_true", help="Print raw format fields for --format option to format the report", ) + + format_detailed_group = parser_report.add_mutually_exclusive_group() + format_detailed_group.add_argument( + "--format", + help="format field for printing purposes. For more details see --helpformat for list of available fields. Fields must be separated by comma (usage: --format ,,...)", + ) + + format_detailed_group.add_argument( + "-d", + "--detailed", + help="Print a detailed summary of the test results", + action="store_true", + ) + pass_fail = parser_report.add_mutually_exclusive_group() pass_fail.add_argument( diff --git a/buildtest/cli/report.py b/buildtest/cli/report.py index 64fd8cc2a..2c3f7d61d 100644 --- a/buildtest/cli/report.py +++ b/buildtest/cli/report.py @@ -77,6 +77,10 @@ class Report: "buildspec": [], } + format_fields_detailed = ( + "name,id,user,state,returncode,runtime,outfile,errfile,buildspec" + ) + def __init__( self, configuration, @@ -91,6 +95,7 @@ def __init__( oldest=None, count=None, pager=None, + format_detailed=None, detailed=None, color=None, ): @@ -108,6 +113,7 @@ def __init__( oldest (bool, optional): Fetch oldest run for all tests discovered. This is specified via ``buildtest report --oldest`` count (int, optional): Fetch limited number of rows get printed for all tests discovered. This is specified via ``buildtest report --count`` pager (bool, optional): Enabling PAGING output for ``buildtest report``. This can be specified via ``buildtest report --pager`` + format_detailed(bool, optional): Print a detailed summary of the test results. This can be specified via ``buildtest report --detailed`` color (str, optional): An instance of a string class that tells print_report what color the output should be printed in. """ @@ -126,6 +132,16 @@ def __init__( self.color = color self.input_report = report_file + # if detailed option is specified + if format_detailed: + self.format = self.format_fields_detailed + + # if both format and detailed options are specified + if format_detailed and format_args: + raise BuildTestError( + "Argument -d/--detailed is not allowed with argument --format" + ) + # if no report specified use default report if not self.input_report: self._reportfile = BUILD_REPORT @@ -828,6 +844,7 @@ def report_cmd(args, configuration, report_file=None): oldest=args.oldest, report_file=report_file, count=args.count, + format_detailed=args.detailed, ) if args.report_subcommand in ["path", "p"]: diff --git a/docs/gettingstarted/query_test_report.rst b/docs/gettingstarted/query_test_report.rst index ad0f0d013..fcea7685f 100644 --- a/docs/gettingstarted/query_test_report.rst +++ b/docs/gettingstarted/query_test_report.rst @@ -45,6 +45,30 @@ You may find it useful to fetch all failed records and determine pass/fail crite .. _report_format_fields: +Detailed Reports (``buildtest report --detailed``) +--------------------------------------------------- + +The **buildtest report --detailed** option can be used to show a detailed test report that may be of interest when +examining a test. This option is synonymous to running ``buildtest report --format name,id,user,state,returncode, +runtime,outfile,errfile,buildspec``. +Shown below is an example output. + +.. dropdown:: ``buildtest report --detailed`` + + .. command-output:: buildtest report --detailed + +.. note:: + The ``--detailed`` and ``--format`` options are mutually exclusive options because both options + will alter the format fields when displaying test results. + +You will get the following error if you specify both options as shown below + +.. dropdown:: ``buildtest report --detailed --format name`` + :color: warning + + .. command-output:: buildtest report --detailed --format name + :returncode: 2 + Format Reports (``buildtest report --format``) ----------------------------------------------- diff --git a/pyproject.toml b/pyproject.toml index 795867e60..35e514f80 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,7 +59,7 @@ docs = [ ] [tool.black] required-version = '23.3.0' -target-version = ['py38', 'py39', 'py310'] +target-version = ['py38', 'py39', 'py310', 'py311'] skip_magic_trailing_comma = true line-length = 88 verbose = true diff --git a/tests/cli/test_report.py b/tests/cli/test_report.py index 49062e2f9..1a6783123 100644 --- a/tests/cli/test_report.py +++ b/tests/cli/test_report.py @@ -55,6 +55,15 @@ def test_report(): result.print_report() +def test_report_detailed(): + # buildtest report --detailed + Report(configuration=configuration, format_detailed=True) + + # buildtest report --detailed --format name + with pytest.raises(BuildTestError): + Report(configuration=configuration, format_detailed=True, format_args="name") + + @pytest.mark.cli def test_report_format(): # buildtest report --helpformat @@ -344,5 +353,6 @@ class args: count = None color = None pager = None + detailed = None report_cmd(args, configuration=configuration)