[Piglit] [PATCH] framework/programs/summary.py: Fail gracefully with bad arguments

Dylan Baker baker.dylan.c at gmail.com
Mon Feb 1 14:31:00 PST 2016


Currently if one passes a bad directory to `piglit summary aggregate`
then piglit will fail with an internal exception. This patch fixes that,
catching the exception, and printing a helpful message and closing
gracefully.

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 framework/programs/summary.py | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/framework/programs/summary.py b/framework/programs/summary.py
index b23f1ef..a060b7d 100644
--- a/framework/programs/summary.py
+++ b/framework/programs/summary.py
@@ -201,7 +201,8 @@ def aggregate(input_):
     parser.add_argument('results_folder',
                         type=path.realpath,
                         metavar="<results path>",
-                        help="Path to a results folder")
+                        help="Path to a results directory "
+                             "(which contains a tests directory)")
     parser.add_argument('-o', '--output',
                         default="results.json",
                         help="name of output file. Default: results.json")
@@ -209,8 +210,16 @@ def aggregate(input_):
 
     assert os.path.isdir(args.results_folder)
 
+    # args.results_folder must be a path with a 'tests' directory in it, not
+    # the tests directory itself.
     outfile = os.path.join(args.results_folder, args.output)
-    results = backends.load(args.results_folder)
+    try:
+        results = backends.load(args.results_folder)
+    except backends.BackendError:
+        raise exceptions.PiglitFatalError(
+            'Cannot find a tests directory to aggregate in {}.\n'
+            'Are you you sure that you pointed to '
+            'a results directory (not results/tests)?'.format(args.results_folder))
 
     try:
         # FIXME: This works, it fixes the problem, but it only works because
-- 
2.7.0



More information about the Piglit mailing list