[Piglit] [PATCH 4/4] piglit-print-commands: Add --format option

Brian Paul brianp at vmware.com
Tue May 3 22:50:01 UTC 2016


On 05/03/2016 03:59 PM, Dylan Baker wrote:
> This option allows the format of the output string to be modified by
> passing a command line argument. This allows for specialized formats to
> be printed for other uses than the original usage that print-commands
> was designed for.

Can you give an example of what the --format option would look like?

I think the help message below ("Format will be called with the {name} 
will be replaced with the name of the test, and {command} with the test 
command") is a bit scrambled.

-Brian



>
> Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
> ---
>   framework/programs/print_commands.py | 13 ++++++++++++-
>   1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/framework/programs/print_commands.py b/framework/programs/print_commands.py
> index 06bd004..c7ccf15 100755
> --- a/framework/programs/print_commands.py
> +++ b/framework/programs/print_commands.py
> @@ -68,6 +68,15 @@ def main(input_):
>                           metavar="<regex>",
>                           help="Exclude matching tests (can be used more than "
>                                "once)")
> +    parser.add_argument("--format",
> +                        dest="format_string",
> +                        default="{name} ::: {command}",
> +                        action="store",
> +                        help="A python format string to be passed to "
> +                             "str.format. Format will be called with the "
> +                             "{name} will be replaced with the name of the "
> +                             "test, and {command} with the test command. "
> +                             "Neither are required.")
>       parser.add_argument("testProfile",
>                           metavar="<Path to testfile>",
>                           help="Path to results folder")
> @@ -85,4 +94,6 @@ def main(input_):
>       profile_._prepare_test_list()
>       for name, test in six.iteritems(profile_.test_list):
>           assert isinstance(test, Test)
> -        print(name, ':::', get_command(test, piglit_dir))
> +        print(args.format_string.format(
> +            name=name,
> +            command=get_command(test, piglit_dir)))
>



More information about the Piglit mailing list