Previously every subtest wrote an entry in the file as a full test, this
is a bug since the fake-fulltest (actually subtest) reported with the
full test value, not it's own value.

The new behavior tweaks that slightly, with this patch each subtest is
still written into the json. If there is only one subtest it is treated
as a normaltest, if there are more than one subtests then the parent
test is treated as a group, and each subtest is treated as a full test.

In this way each subtest gets exactly one entry in the summary.

v3: - Change behavior such that subtests get recorded in summary output

Signed-off-by: Dylan Baker <[email protected]>
Tested-by: Homer Xing <[email protected]>
---
 framework/core.py | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/framework/core.py b/framework/core.py
index b1a5726..e66e53f 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -469,14 +469,23 @@ class Test:
 
             status(result['result'])
 
+            # If there is more than one subtest, write each subtest as a full
+            # test, with the parent test treated as the highest group
             if 'subtest' in result and len(result['subtest'].keys()) > 1:
                 def serious_level(result):
                     return {'skip':0, 'pass':1, 'warn':2, 'fail':3, 
'crash':4}.get(result, 0)
 
-                for test in result['subtest'].keys():
-                    if serious_level(result['subtest'][test]) >= 
serious_level(result['result']):
-                        result['result'] = result['subtest'][test]
-                    json_writer.write_dict_item(path + '/' + test, result)
+                for test, value in result.pop('subtest').items():
+                    if serious_level(value) > serious_level(result['result']):
+                        result['result'] = value
+
+                    json_writer.write_dict_item(os.path.join(path, test),
+                                                result)
+            # if there is only one subtest remove the subtest attribute, it is
+            # redundant
+            elif 'subtest' in result:
+                result.pop('subtest')
+                json_writer.write_dict_item(path, result)
             else:
                 json_writer.write_dict_item(path, result)
         else:
-- 
1.8.1.5

_______________________________________________
Piglit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to