framework/replay: disable AA accounting when comparing with no tolerance
[piglit.git] / framework / programs / print_commands.py
blobcf7087c7f3e4b885fba1f8996dd65df0b7bc8a45
1 # coding=utf-8
2 # Copyright (c) 2016, 2019 Intel Corporation
4 # Permission is hereby granted, free of charge, to any person obtaining a copy
5 # of this software and associated documentation files (the "Software"), to deal
6 # in the Software without restriction, including without limitation the rights
7 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 # copies of the Software, and to permit persons to whom the Software is
9 # furnished to do so, subject to the following conditions:
11 # The above copyright notice and this permission notice shall be included in
12 # all copies or substantial portions of the Software.
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 # SOFTWARE.
22 """Print each test's command in a user-defined consumable format.
24 This is meant to provide a mechanism to export piglit commands to other tools,
25 or to create lists of tests to be consumed via "piglit run --test-list"
27 """
29 import argparse
30 import os
31 import sys
33 from . import parsers
34 from framework import options, profile, exceptions
35 from framework.test import Test
38 def get_command(test, piglit_dir):
39 """Get just the name of the command with a path relative to bin."""
41 # Make the test command relative to the piglit_dir
42 test_command = test.command[:]
43 test_command[0] = os.path.relpath(test_command[0], piglit_dir)
45 command = ' '.join(test_command)
46 return command
49 @exceptions.handler
50 def main(input_):
51 """The main function."""
52 parser = argparse.ArgumentParser(parents=[parsers.CONFIG])
53 parser.add_argument("-t", "--include-tests",
54 default=[],
55 action="append",
56 metavar="<regex>",
57 help="Run only matching tests "
58 "(can be used more than once)")
59 parser.add_argument("-x", "--exclude-tests",
60 default=[],
61 action="append",
62 metavar="<regex>",
63 help="Exclude matching tests (can be used more than "
64 "once)")
65 parser.add_argument("--format",
66 dest="format_string",
67 default="{name} ::: {command}",
68 action="store",
69 help="A template string that defines the output "
70 "format. It has two replacement tokens that can "
71 "be provided, along with any arbitrary text, "
72 "which will be printed verbatim. The two tokens "
73 "are '{name}', which will be replaced with the "
74 "name of the test; and '{command}', which will "
75 "be replaced with the command to run the test.")
76 parser.add_argument("testProfile",
77 metavar="<Path to testfile>",
78 help="Path to results folder")
79 args = parser.parse_args(input_)
81 profile_ = profile.load_test_profile(args.testProfile)
83 if args.exclude_tests:
84 profile_.filters.append(profile.RegexFilter(args.exclude_tests,
85 inverse=True))
86 if args.include_tests:
87 profile_.filters.append(profile.RegexFilter(args.include_tests))
89 # Change to the piglit's path
90 piglit_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
91 os.chdir(piglit_dir)
93 for name, test in profile_.itertests():
94 assert isinstance(test, Test)
95 print(args.format_string.format(
96 name=name,
97 command=get_command(test, piglit_dir)))