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

Brian Paul brianp at vmware.com
Fri May 6 22:23:09 UTC 2016


On 05/06/2016 02:23 PM, Dylan Baker wrote:
> Quoting Brian Paul (2016-05-03 15:50:01)
>> 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)))
>>>
>>
>
> What about something like this:
>
> A template string that defines the output format. It has two replacement tokens
> that can be provided, along with an arbitrary text, which will be printed
> verbatim. The two tokens are '{name}', which will be replaced with the name of
> the test; and '{command}', which will be replaced with the command to run the
> test.
>

Sounds great.  Thanks.

-Brian



More information about the Piglit mailing list