summaryrefslogtreecommitdiff
path: root/src/scripts/testgen/README.md
blob: 4531f636db64d00f70c8e3decee2d463f1339221 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146

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
API test coveraged.

Testgen can generate tests C and to other bingings languages only
adding new language specialized templates.

Installation
============

There is nothing to install to use the generator, everything is included in
the efl source tree and it is intended to work directly inside the tree,
usually at efl tests compilation time (make check).

The only requirement is that **the source tree must be already built** (not
installed) because pyolian search the eolian .so/.dll inside the source tree.

If you built the efl tree in a custom location (fe, you build out-of-tree) you
can tell pyolian where to find the built eolian .so files using the
`EOLIAN_SO_DIR` environment variable.


Command line usage
==================

The simplest way to use the generator is from the command line, using the
`src/scripts/testgen/testgen.py` command, the `--help` option state:

```
usage: testgen.py [-h] testname suitename filename [eofiles [eofiles ...]]

Eolian Test Generator.

positional arguments:
  testname    The Test Name used to find custom and template files. (REQUIRED)
  suitename   The Suite Name used to find custom files. (REQUIRED)
  filename    Generated test file destination. (REQUIRED)
  eofiles     The Eolian Files to use.

optional arguments:
  -h, --help  show this help message and exit
```
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`

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`


How customise a Generated Test
==============================

Testgen use the filesystem to find custom files if you need customise a test,
add/write follow files in src/tests:

 Suite custom files
 * `src/test/<testname>/`
     |-> <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, 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 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)

- Tests properties custom files
 * `src/test/<testname>/<class_name>/<property_name>`
     |   -- Property Get --
     |-> 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 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)

Event Tests
- Tests Events custom files
 * `src/test/<testname>/<class_name>/<event_name>/`
     |-> init.cs            #add how to initialize the objects
     |-> custom.cs          #add customizations in callback
     |-> shutdown.cs        #add shutdown or any method to call the event

to make some custom files you only need a code using:
 `parent`     -> default name of parent object defined as `Eo *`
 `obj`        -> default name of current object
 `arg_<name>` -> replace <name> with functions arguments name 

you can use custom.c (suite or class) to add specilized code, structs and callbacks

-- 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
=======================

 * read the Pyolian README file in EFL scripts
 * read the eolian.py file (it declare the full eolian API)
 * read the generator.py file (it's super simple)
 * read the original [pyratemp docs](https://www.simple-is-better.org/template/pyratemp.html)


Note
====

This markdown file is mirrored in efl src tree (src/scripts/pyolian) and in
phab wiki (phab.enlightenment.org/w/pyolian). Don't forget to update the other
if you change one!