summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2016-05-03 14:27:49 -0700
committerDylan Baker <dylan@pnwbakers.com>2016-05-10 14:35:19 -0700
commit59c2dbd5a3ad72ade3d141ee7747f2ccc8a04f56 (patch)
treee62d65f36760ea00ec94bdccdfda9d8f11fa7dff
parenta7cad94da6e53ba47c6990792e9d7663513fd645 (diff)
piglit-print-commands: Add --format option
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. Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com> Reviewed-by: Brian Paul <brianp@vmware.com>
-rw-r--r--framework/programs/print_commands.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/framework/programs/print_commands.py b/framework/programs/print_commands.py
index 8330d55b6..033ca870b 100644
--- a/framework/programs/print_commands.py
+++ b/framework/programs/print_commands.py
@@ -18,7 +18,12 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
-"""Print each test's command in a consumable format."""
+"""Print each test's command in a user-defined consumable format.
+
+This is meant to provide a mechanism to export piglit commands to other tools,
+or to create lists of tests to be consumed via "piglit run --test-list"
+
+"""
from __future__ import (
absolute_import, division, print_function, unicode_literals
@@ -65,6 +70,17 @@ 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 template string that defines the output "
+ "format. It has two replacement tokens that can "
+ "be provided, along with any 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.")
parser.add_argument("testProfile",
metavar="<Path to testfile>",
help="Path to results folder")
@@ -82,4 +98,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)))