summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLarry Lira <larry@expertisesolutions.com.br>2018-09-11 20:40:32 -0300
committerLarry Lira <larry@expertisesolutions.com.br>2018-10-02 14:45:07 -0300
commitd6a9fd321d5ff220c91d65c0d07d115ba503520c (patch)
treec796d1c769ed667a88258ef9a1612945c2b918fd
parentddb04d3e49f87bdde34fc4be6165d25fb5808915 (diff)
downloadefl-d6a9fd321d5ff220c91d65c0d07d115ba503520c.tar.gz
testgen: added customs
- added filter class - added filter functions - added doc filters in README
-rw-r--r--src/scripts/testgen/README.md34
-rw-r--r--src/scripts/testgen/ekeys.py30
-rw-r--r--src/scripts/testgen/suitegen.py54
-rw-r--r--src/scripts/testgen/testgenerator.c.template8
-rw-r--r--src/scripts/testgen/testgenerator.cs.template4
5 files changed, 82 insertions, 48 deletions
diff --git a/src/scripts/testgen/README.md b/src/scripts/testgen/README.md
index 278d273019..a9aef9cb89 100644
--- a/src/scripts/testgen/README.md
+++ b/src/scripts/testgen/README.md
@@ -1,6 +1,6 @@
Testgen: Template-based Eolian tests generator
-=====================================================================
+===============================================================================
Testgen is a Python Script using the Pyolian to generate tests rendering
templates with custom files, this can be a easy way to expand the
@@ -44,21 +44,23 @@ positional arguments:
optional arguments:
-h, --help show this help message and exit
```
-Use .c extension to generate C tests or .cs to CSharp (.cpp too in the future)
+Use .c extension in <filename> to generate C tests or .cs to CSharp
To test this generator in `src/scripts/testgen` you can run:
```
./testgen.py automated efl efl_automated_test.c efl_loop.eo
```
-This will rendere the automated tests using files in `src/tests/automated` with suite
-name `efl_automated` and with Efl.Loop Class as Test Case `efl_automated_efl_loop_test`
+This will rendere the automated tests using files in `src/tests/automated` with
+suite name `efl_automated` and with Efl.Loop Class as Test Case
+`efl_automated_efl_loop_test`
or run:
```
./testgen.py automated eio eio_automated_test.c eio_sentry.eo eio_model.eo
```
-This will rendere with suite name `eio_automated` and with Eio.Sentry and Eio.Model
-Class as Test Cases `eio_automated_eio_sentry_test` and `eio_automated_eio_model_test`
+This will rendere with suite name `eio_automated` and with Eio.Sentry and
+Eio.Model Class as Test Cases `eio_automated_eio_sentry_test` and
+`eio_automated_eio_model_test`
How customise a Generated Test
@@ -69,20 +71,20 @@ add/write follow files in src/tests:
Suite custom files
* `src/test/<testname>/`
- |-> <suitename>_custom.c #add include files and global functions or structs
+ |-> <suitename>_custom.c #add include files, functions or structs
|-> <suitename>_init.c #add code in SUITE_INIT
|-> <suitename>_shutdown.c #add code in SUITE_SHUTDOWN
Class Test case custom files
* `src/test/<testname>/<class_name>/` #use lowercase and `_` separator
- |-> custom.c #add include files and global functions or structs
+ |-> custom.c #add include files, functions or structs
|-> init.c #add default way to create the object of this class
|-> shutdown.c #add default way to free the object
Funtions Tests
- Tests methodes custom files
* `src/test/<testname>/<class_name>/<method_name>`
- |-> arg_init.c #initialize arguments of the method (arg_<argument_name>)
+ |-> arg_init.c #initialize method arguments (arg_<argument_name>)
|-> init.c #add how to create the object (replace default)
|-> arg_shutdown.c #free arguments
|-> shutdown.c #add how to free the object (replace default)
@@ -90,12 +92,12 @@ Funtions Tests
- Tests properties custom files
* `src/test/<testname>/<class_name>/<property_name>`
| -- Property Get --
- |-> arg_get_init.c #initialize arguments of property get (arg_<argument_name>)
+ |-> arg_get_init.c #initialize property get arguments (arg_<argument_name>)
|-> get_init.c #how to create the object (replace default)
|-> arg_get_shutdown.c #free arguments
|-> get_shutdown.c #how to free the object (replace default)
| -- Property Set --
- |-> arg_set_init.c #initialize arguments of propety set (arg_<argument_name>)
+ |-> arg_set_init.c #initialize propety set arguments (arg_<argument_name>)
|-> set_init.c #how to create the object (replace default)
|-> arg_set_shutdown.c #free arguments
|-> set_shutdown.c #how to free the object (replace default)
@@ -109,6 +111,16 @@ you can use custom.c (suite or class) to add specilized code, structs and callba
-- Use `*.cs` to Emono/CSharp generated code --
+Some class or function test don't need a test in some Suite, you can disable test generated
+of it with a blank file as following:
+
+use lowercase and `_` as separator
+`src/test/<testname>/<class_name>` #don't generate test for <class_name>
+`src/test/<testname>/<class_name>/method_name` #don't generate test for <method_name>
+`src/test/<testname>/<class_name>/<property_name>` #don't generate test for this property
+`src/test/<testname>/<class_name>/<property_name>_get` #don't generate test for this property get
+`src/test/<testname>/<class_name>/<property_name>_set` #don't generate test for this property set
+
Where to find more info
=======================
diff --git a/src/scripts/testgen/ekeys.py b/src/scripts/testgen/ekeys.py
index 1186e09d87..6dfa906370 100644
--- a/src/scripts/testgen/ekeys.py
+++ b/src/scripts/testgen/ekeys.py
@@ -121,35 +121,25 @@ class EMonoKeys(EKeys):
self.blacklist = [
"efl_event_callback_array_priority_add",
"efl_player_position_get",
- "efl_text_font_source_get",
- "efl_text_font_source_set",
+ "efl_text_font_source",
"efl_ui_focus_manager_focus_get",
- "efl_ui_widget_focus_set",
- "efl_ui_widget_focus_get",
- "efl_ui_text_password_get",
- "efl_ui_text_password_set",
- "elm_interface_scrollable_repeat_events_get",
- "elm_interface_scrollable_repeat_events_set",
+ "efl_ui_widget_focus",
+ "efl_ui_text_password",
+ "elm_interface_scrollable_repeat_events",
"elm_wdg_item_del",
- "elm_wdg_item_focus_get",
- "elm_wdg_item_focus_set",
+ "elm_wdg_item_focus",
"elm_interface_scrollable_mirrored_set",
- "evas_obj_table_mirrored_get",
- "evas_obj_table_mirrored_set",
+ "evas_obj_table_mirrored",
"edje_obj_load_error_get",
"efl_ui_focus_user_parent_get",
- "efl_canvas_object_scale_get", # duplicated signature
- "efl_canvas_object_scale_set", # duplicated signature
+ "efl_canvas_object_scale", # duplicated signature
"efl_access_parent_get",
- "efl_access_name_get",
- "efl_access_name_set",
+ "efl_access_name",
"efl_access_root_get",
"efl_access_type_get",
"efl_access_role_get",
- "efl_access_action_description_get",
- "efl_access_action_description_set",
- "efl_access_image_description_get",
- "efl_access_image_description_set",
+ "efl_access_action_description",
+ "efl_access_image_description",
"efl_access_component_layer_get", # duplicated signature
"efl_access_component_alpha_get",
"efl_access_component_size_get",
diff --git a/src/scripts/testgen/suitegen.py b/src/scripts/testgen/suitegen.py
index 654acb9e8e..8527aa88e8 100644
--- a/src/scripts/testgen/suitegen.py
+++ b/src/scripts/testgen/suitegen.py
@@ -2,6 +2,7 @@ import itertools
import os
from testgen.ekeys import GetKey
+
class BaseItem:
def __init__(self, path, keys, prefix=""):
self.path = path
@@ -18,6 +19,7 @@ class BaseItem:
return f.read()
return None
+
class ComItem(BaseItem):
def __init__(self, comp, path, keys):
super().__init__(path, keys)
@@ -28,10 +30,22 @@ class ComItem(BaseItem):
return getattr(self.comp, attr)
return super().__getattr__(attr)
+
class FuncItem(ComItem):
def __init__(self, comp, path, keys):
super().__init__(comp, os.path.join(path, comp.name), keys)
+ self.has_getter = (
+ comp.getter_scope == comp.getter_scope.PUBLIC
+ and comp.full_c_getter_name not in self.keys.blacklist
+ and not os.path.isfile("{}_get".format(os.path.join(path, comp.name)))
+ )
+ self.has_setter = (
+ comp.setter_scope == comp.setter_scope.PUBLIC
+ and comp.full_c_setter_name not in self.keys.blacklist
+ and not os.path.isfile("{}_set".format(os.path.join(path, comp.name)))
+ )
+
@property
def format_name(self):
names = self.comp.name.split("_")
@@ -39,6 +53,7 @@ class FuncItem(ComItem):
names.insert(0, names.pop())
return "".join([name.capitalize() for name in names])
+
class ClassItem(ComItem):
def __init__(self, comp, path, keys):
self.myname = os.path.splitext(comp.file)[0]
@@ -48,24 +63,38 @@ class ClassItem(ComItem):
FuncItem(m, self.path, keys)
for m in self.comp.methods
if m.full_c_method_name not in self.keys.blacklist
+ and not os.path.isfile(os.path.join(self.path, m.name))
]
- self.properties = [
+ self._properties = [
FuncItem(p, self.path, keys)
for p in self.comp.properties
- if (
- p.getter_scope == p.getter_scope.PUBLIC
- and p.full_c_getter_name not in self.keys.blacklist
- )
- or (
- p.setter_scope == p.setter_scope.PUBLIC
- and p.full_c_setter_name not in self.keys.blacklist
- )
+ if p.full_c_method_name not in self.keys.blacklist
+ and not os.path.isfile(os.path.join(self.path, p.name))
]
+ @property
+ def properties(self):
+ return itertools.filterfalse(
+ lambda p: not (p.has_setter or p.has_getter), self._properties
+ )
+
+ @property
+ def properties_get(self):
+ return itertools.filterfalse(
+ lambda p: not p.has_getter, self._properties
+ )
+
+ @property
+ def properties_set(self):
+ return itertools.filterfalse(
+ lambda p: not p.has_setter, self._properties
+ )
+
def __iter__(self):
return itertools.chain(self.methods, self.properties)
+
class SuiteGen(BaseItem):
def __init__(self, name, testname, filename, path, template=None):
keys = GetKey(os.path.splitext(filename)[1])
@@ -102,5 +131,8 @@ class SuiteGen(BaseItem):
def loadObj(self, eocls):
cls = ClassItem(eocls, self.path, self.keys)
- cls.myfullname = "{}_{}".format(self.fullname, cls.myname)
- self.clslist.append(cls)
+ if not os.path.isfile(cls.path):
+ cls.myfullname = "{}_{}".format(self.fullname, cls.myname)
+ self.clslist.append(cls)
+ else:
+ print("removing {} Class from generated list".format(cls.name))
diff --git a/src/scripts/testgen/testgenerator.c.template b/src/scripts/testgen/testgenerator.c.template
index accf09fe7b..89b7139f90 100644
--- a/src/scripts/testgen/testgenerator.c.template
+++ b/src/scripts/testgen/testgenerator.c.template
@@ -94,7 +94,7 @@ END_TEST
<!--(end)-->
<!--(for func in cls.properties)-->
- <!--(if func.getter_scope == func.getter_scope.PUBLIC)-->
+ <!--(if func.has_getter)-->
START_TEST(${cls.myfullname}$_${func.full_c_getter_name}$)
{
<!--(if len(list(func.getter_values)) > 1)-->
@@ -114,7 +114,7 @@ ${shutdown(mcustom=cls.shutdown,mfunc=func.get_shutdown)}$
END_TEST
<!--(end)-->
- <!--(if func.setter_scope == func.setter_scope.PUBLIC)-->
+ <!--(if func.has_setter)-->
START_TEST(${cls.myfullname}$_${func.full_c_setter_name}$)
{
${args_declaration(args=func.setter_keys)}$${args_declaration(args=func.setter_values)}$${init(mcls=cls.init,mfunc=func.set_init)}$
@@ -134,10 +134,10 @@ void ${cls.myfullname}$_test(TCase *tc)
tcase_add_test(tc, ${cls.myfullname}$_${func.full_c_method_name}$);
<!--(end)-->
<!--(for func in cls.properties)-->
- <!--(if func.getter_scope == func.getter_scope.PUBLIC)-->
+ <!--(if func.has_getter)-->
tcase_add_test(tc, ${cls.myfullname}$_${func.full_c_getter_name}$);
<!--(end)-->
- <!--(if func.setter_scope == func.setter_scope.PUBLIC)-->
+ <!--(if func.has_setter)-->
tcase_add_test(tc, ${cls.myfullname}$_${func.full_c_setter_name}$);
<!--(end)-->
<!--(end)-->
diff --git a/src/scripts/testgen/testgenerator.cs.template b/src/scripts/testgen/testgenerator.cs.template
index ea65e10a4f..5766c2fe68 100644
--- a/src/scripts/testgen/testgenerator.cs.template
+++ b/src/scripts/testgen/testgenerator.cs.template
@@ -70,7 +70,7 @@ ${m_show(mshow=func.shutdown)}$#!
<!--(end)-->
#! PROPERTIES FUNCTION GET
<!--(for func in cls.properties)-->
- <!--(if func.getter_scope == func.getter_scope.PUBLIC)-->
+ <!--(if func.has_getter)-->
public void ${func.name}$_pget()
{
<!--(if len(list(func.getter_values)) > 1)-->
@@ -92,7 +92,7 @@ ${m_show(mshow=func.get_shutdown)}$#!
<!--(end)-->
#! PROPERTIES FUNCTION SET
- <!--(if func.setter_scope == func.setter_scope.PUBLIC)-->
+ <!--(if func.has_setter)-->
public void ${func.name}$_pset()
{
${def_params(parameters=func.setter_values)}$