This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository efl.

View the commit online.

commit ae8f5e8f27fb8195a4dc5ef8688ea8f8e126c896
Author: Dimmus <dmitri.chudi...@gmail.com>
AuthorDate: Tue Jun 7 10:49:12 2022 +0500

    Add script that calulcates coverage of spec test suite.
    From https://phab.enlightenment.org/D9851
---
 widget_interface_coverage.py | 125 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 125 insertions(+)

diff --git a/widget_interface_coverage.py b/widget_interface_coverage.py
new file mode 100755
index 0000000000..55d236d93e
--- /dev/null
+++ b/widget_interface_coverage.py
@@ -0,0 +1,125 @@
+#!/usr/bin/python3
+import sys
+import os
+import argparse
+import json
+import functools
+
+parser = argparse.ArgumentParser(description='Create a image showing all widgets')
+parser.add_argument('sourcedir', metavar='sourcedir', help='the path where to find efls source')
+
+G = parser.parse_args()
+sys.path.insert(0, os.path.join(G.sourcedir, 'src', 'scripts', 'pyolian'))
+
+# EFL_ROOT_PATH = '~/dev/efl/'
+# pyolian_path = os.path.join(EFL_ROOT_PATH, 'src', 'scripts')
+# sys.path.insert(0, pyolian_path)
+# from pyolian import eolian
+# from pyolian.generator import Template
+
+import eolian
+from eolian import Eolian_Type_Type
+from eolian import Eolian_Type_Builtin_Type
+
+SCAN_FOLDER = os.path.join(G.sourcedir, 'src', 'lib')
+SPEC_FOLDER = os.path.join(G.sourcedir, 'src', 'tests', 'elementary', 'spec')
+
+eolian_db = eolian.Eolian_State()
+
+if not eolian_db.directory_add(SCAN_FOLDER):
+  raise(RuntimeError('Eolian, failed to scan source directory'))
+
+# Parse all known eo files
+if not eolian_db.all_eot_files_parse():
+  raise(RuntimeError('Eolian, failed to parse all EOT files'))
+
+if not eolian_db.all_eo_files_parse():
+  raise(RuntimeError('Eolian, failed to parse all EO files'))
+
+widget = eolian_db.class_by_name_get("Efl.Ui.Widget")
+assert(widget)
+
+def is_widget(obj, rd = 0):
+  if obj == widget:
+    return rd
+  elif obj.parent != None:
+    return is_widget(obj.parent, rd + 1)
+  return -1
+
+list_of_widgets = []
+list_of_checked_interfaces = []
+dict_of_coverede_widgets = {}
+
+for filename in os.listdir(SPEC_FOLDER):
+  if os.path.splitext(filename)[1] != '.c':
+    continue
+  with open(os.path.join(SPEC_FOLDER, filename), 'r') as content_file:
+      content = content_file.read()
+      if 'spec-meta-start' not in content or 'spec-meta-end' not in content:
+        continue;
+      start = content.index('spec-meta-start') + len('spec-meta-start')
+      end = content.index('spec-meta-end')
+      resulting_json = content[start:end]
+      tmp = json.loads(resulting_json)
+      list_of_checked_interfaces.append(tmp['test-interface'])
+      dict_of_coverede_widgets[tmp['test-interface']] = tmp["test-widgets"]
+
+class Widget:
+  def __init__(self, klass, interfaces):
+    self.klass = klass
+    self.interfaces = interfaces
+    self.not_tested_interfaces = []
+    self.tested_interfaces = []
+    self.not_tested_available_interfaces = []
+    for interface in self.interfaces:
+      if interface.name in list_of_checked_interfaces:
+        if self.klass.name in dict_of_coverede_widgets[interface.name]:
+          self.tested_interfaces.append(interface.name)
+        else:
+          self.not_tested_available_interfaces.append(interface.name)
+      else:
+        self.not_tested_interfaces.append(interface.name)
+
+  def dump(self):
+    print("{}\n   Tested interfaces: {}\n   Not tested interfaces: {}\n   Available not tested interfaces: {}".format(self.klass.name, self.tested_interfaces, self.not_tested_interfaces, self.not_tested_available_interfaces))
+
+  def overall_statistic(self):
+    return (len(self.interfaces), len(self.tested_interfaces), len(self.not_tested_available_interfaces))
+  def list_of_available_not_tested(self):
+    return self.not_tested_available_interfaces
+
+for kl in eolian_db.classes:
+  widget_depth = is_widget(kl)
+  if widget_depth != -1:
+    interfaces = []
+    for widget_interface in kl.extensions:
+      interfaces.append(widget_interface)
+    list_of_widgets.append(Widget(kl, interfaces))
+
+list_of_widgets.sort(key = lambda x : x.klass.name, reverse = True)
+
+stats = []
+
+for widget in list_of_widgets:
+  stats.append(widget.overall_statistic())
+
+not_tested_interfaces = functools.reduce(lambda x,y: x+y, map(lambda x:x[0]-(x[1] + x[2]), stats))
+not_tested_available_interfaces = functools.reduce(lambda x,y: x+y, map(lambda x:x[2], stats))
+tested_interfaces = functools.reduce(lambda x,y: x+y, map(lambda x:x[1], stats))
+all_interfaces = functools.reduce(lambda x,y: x+y, map(lambda x:x[0], stats))
+overall_cov = 0
+if all_interfaces != 0:
+  overall_cov = float(tested_interfaces)/float(all_interfaces)
+
+print("Overall Stats:")
+print("   Not tested interfaces in widget: {}".format(not_tested_interfaces))
+print("   Available not tested interfaces in widgets: {}".format(not_tested_available_interfaces))
+print("   Tested interfaces in widgets: {}".format(tested_interfaces))
+print("   Interface coverage of widgets: {}".format(overall_cov))
+
+print("Table of available, but not used tests:")
+for widget in list_of_widgets:
+  not_available = widget.list_of_available_not_tested()
+  if (len(not_available) != 0):
+    print(widget.klass.name + ":")
+    print("   "+functools.reduce(lambda x,y: x+", "+y, not_available))

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to