cfgcoverage 0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Marcio Delamaro
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,151 @@
1
+ Metadata-Version: 2.4
2
+ Name: cfgcoverage
3
+ Version: 0.1
4
+ Summary: Structural coverage for Python
5
+ Author: Delamaro
6
+ Author-email: Delamaro <delamaro@icmc.usp.br>
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Dynamic: author
11
+ Dynamic: license-file
12
+
13
+ # cfgcoverage
14
+
15
+ A Python package to analyze and verify structural coverage criteria for Python programs using control-flow graphs (CFGs).
16
+
17
+ > V0.1 — This is a very early, highly experimental version.
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ pip install cfgcoverage
23
+ ```
24
+
25
+ ## 🚀 How to Use
26
+
27
+ Analyzes the file `foo.py`, builds its control-flow graphs, and stores the internal analysis data in `foo.py.cfg`.
28
+
29
+ ```bash
30
+ python -m cfgcoverage foo.py
31
+ ```
32
+
33
+ Executes `foo.py` with instrumentation and records covered blocks and edges.
34
+
35
+ ```bash
36
+ python -m cfgcoverage --run foo.py
37
+ ```
38
+
39
+ Executes `foo.py` with arguments `['bar', '1972']` and records the covered structural requirements.
40
+
41
+ ```bash
42
+ python -m cfgcoverage --run --args "bar 1972" foo.py
43
+ ```
44
+
45
+ Cumulatively runs `foo.py` and aggregates structural coverage results across multiple executions.
46
+
47
+ ```bash
48
+ python -m cfgcoverage --run --append foo.py
49
+ ```
50
+
51
+ Runs `foo.py` using the test cases defined in `test_foo.py`.
52
+ The `--unittest` argument can be used multiple times. The `--append` option is also supported here.
53
+
54
+ ```bash
55
+ python -m cfgcoverage --unittest test_foo.py foo.py
56
+ python -m cfgcoverage --unittest tests/test_foo.py src/foo.py
57
+ python -m cfgcoverage --unittest test_a.py --unittest test_b.py foo.py
58
+ ```
59
+
60
+ You can also use one or more `--path <folder path>` arguments to include additional folders in `sys.path` when executing unit tests. In this way, imports will also be searched in these folders.
61
+
62
+ ```bash
63
+ python -m cfgcoverage --path src --unittest tests/test_foo.py src/foo.py
64
+ python -m cfgcoverage --path src --path tests --unittest tests/test_foo.py src/foo.py
65
+ ```
66
+
67
+ Creates an HTML report in `html/foo.py/index.html` using the data stored in `foo.py.cfg`.
68
+
69
+ ```bash
70
+ python -m cfgcoverage --html foo.py
71
+ ```
72
+
73
+ ```
74
+
75
+ ## 🔍 Example
76
+
77
+ ```bash
78
+ python3 -m cfgcoverage example.py
79
+ ```
80
+
81
+ Example output:
82
+
83
+ ```text
84
+ Function: foo -- 1
85
+ Function: foo.inner -- 2
86
+ Run time: 0.00052
87
+ ```
88
+
89
+ ```bash
90
+ python3 -m cfgcoverage --run example.py
91
+ ```
92
+
93
+ Example output:
94
+
95
+ ```text
96
+ Run time: 0.00071
97
+ ```
98
+
99
+ ```bash
100
+ python3 -m cfgcoverage --unittest test_example.py example.py
101
+ ```
102
+
103
+ Example output:
104
+
105
+ ```text
106
+ .
107
+ ----------------------------------------------------------------------
108
+ Ran 1 test in 0.000s
109
+
110
+ OK
111
+
112
+ Run time: 0.00110
113
+ ```
114
+
115
+ ```bash
116
+ python3 -m cfgcoverage --html example.py
117
+ ```
118
+
119
+ Example output:
120
+
121
+ ```text
122
+ File generated at: html/example.py/index.html
123
+ ```
124
+
125
+ ## 📊 Coverage Criteria
126
+
127
+ The current HTML report includes the following criteria for each analyzed function:
128
+
129
+ - Blocks
130
+ - Edges
131
+ - Edge Pairs
132
+
133
+ ## 📝 Notes
134
+
135
+ 1. The analysis stores its internal data in a file named `<source_file>.cfg`.
136
+ 2. HTML reports depend on previously generated `.cfg` data.
137
+ 3. The tool analyzes functions and nested functions found in the source file.
138
+ 4. When using `--append`, coverage data from previous executions is accumulated instead of replaced.
139
+ 5. The HTML report is generated per source file and organized under the `html/` folder.
140
+
141
+ ## 👤 Author
142
+
143
+ **Marcio Delamaro**
144
+
145
+ ## 📄 License
146
+
147
+ MIT
148
+
149
+ ## 🤝 Contributions
150
+
151
+ Feel free to open issues or submit pull requests!
@@ -0,0 +1,139 @@
1
+ # cfgcoverage
2
+
3
+ A Python package to analyze and verify structural coverage criteria for Python programs using control-flow graphs (CFGs).
4
+
5
+ > V0.1 — This is a very early, highly experimental version.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pip install cfgcoverage
11
+ ```
12
+
13
+ ## 🚀 How to Use
14
+
15
+ Analyzes the file `foo.py`, builds its control-flow graphs, and stores the internal analysis data in `foo.py.cfg`.
16
+
17
+ ```bash
18
+ python -m cfgcoverage foo.py
19
+ ```
20
+
21
+ Executes `foo.py` with instrumentation and records covered blocks and edges.
22
+
23
+ ```bash
24
+ python -m cfgcoverage --run foo.py
25
+ ```
26
+
27
+ Executes `foo.py` with arguments `['bar', '1972']` and records the covered structural requirements.
28
+
29
+ ```bash
30
+ python -m cfgcoverage --run --args "bar 1972" foo.py
31
+ ```
32
+
33
+ Cumulatively runs `foo.py` and aggregates structural coverage results across multiple executions.
34
+
35
+ ```bash
36
+ python -m cfgcoverage --run --append foo.py
37
+ ```
38
+
39
+ Runs `foo.py` using the test cases defined in `test_foo.py`.
40
+ The `--unittest` argument can be used multiple times. The `--append` option is also supported here.
41
+
42
+ ```bash
43
+ python -m cfgcoverage --unittest test_foo.py foo.py
44
+ python -m cfgcoverage --unittest tests/test_foo.py src/foo.py
45
+ python -m cfgcoverage --unittest test_a.py --unittest test_b.py foo.py
46
+ ```
47
+
48
+ You can also use one or more `--path <folder path>` arguments to include additional folders in `sys.path` when executing unit tests. In this way, imports will also be searched in these folders.
49
+
50
+ ```bash
51
+ python -m cfgcoverage --path src --unittest tests/test_foo.py src/foo.py
52
+ python -m cfgcoverage --path src --path tests --unittest tests/test_foo.py src/foo.py
53
+ ```
54
+
55
+ Creates an HTML report in `html/foo.py/index.html` using the data stored in `foo.py.cfg`.
56
+
57
+ ```bash
58
+ python -m cfgcoverage --html foo.py
59
+ ```
60
+
61
+ ```
62
+
63
+ ## 🔍 Example
64
+
65
+ ```bash
66
+ python3 -m cfgcoverage example.py
67
+ ```
68
+
69
+ Example output:
70
+
71
+ ```text
72
+ Function: foo -- 1
73
+ Function: foo.inner -- 2
74
+ Run time: 0.00052
75
+ ```
76
+
77
+ ```bash
78
+ python3 -m cfgcoverage --run example.py
79
+ ```
80
+
81
+ Example output:
82
+
83
+ ```text
84
+ Run time: 0.00071
85
+ ```
86
+
87
+ ```bash
88
+ python3 -m cfgcoverage --unittest test_example.py example.py
89
+ ```
90
+
91
+ Example output:
92
+
93
+ ```text
94
+ .
95
+ ----------------------------------------------------------------------
96
+ Ran 1 test in 0.000s
97
+
98
+ OK
99
+
100
+ Run time: 0.00110
101
+ ```
102
+
103
+ ```bash
104
+ python3 -m cfgcoverage --html example.py
105
+ ```
106
+
107
+ Example output:
108
+
109
+ ```text
110
+ File generated at: html/example.py/index.html
111
+ ```
112
+
113
+ ## 📊 Coverage Criteria
114
+
115
+ The current HTML report includes the following criteria for each analyzed function:
116
+
117
+ - Blocks
118
+ - Edges
119
+ - Edge Pairs
120
+
121
+ ## 📝 Notes
122
+
123
+ 1. The analysis stores its internal data in a file named `<source_file>.cfg`.
124
+ 2. HTML reports depend on previously generated `.cfg` data.
125
+ 3. The tool analyzes functions and nested functions found in the source file.
126
+ 4. When using `--append`, coverage data from previous executions is accumulated instead of replaced.
127
+ 5. The HTML report is generated per source file and organized under the `html/` folder.
128
+
129
+ ## 👤 Author
130
+
131
+ **Marcio Delamaro**
132
+
133
+ ## 📄 License
134
+
135
+ MIT
136
+
137
+ ## 🤝 Contributions
138
+
139
+ Feel free to open issues or submit pull requests!