vyperling 0.0.1__py3-none-any.whl
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.
- vyperling/__init__.py +3 -0
- vyperling/c/UNITY_LICENSE +24 -0
- vyperling/c/forge_mock.c +111 -0
- vyperling/c/forge_mock.h +54 -0
- vyperling/c/unity.c +2501 -0
- vyperling/c/unity.h +698 -0
- vyperling/c/unity_fixture.h +94 -0
- vyperling/c/unity_internals.h +1183 -0
- vyperling/cli.py +297 -0
- vyperling/compiler.py +162 -0
- vyperling/config.py +101 -0
- vyperling/coverage.py +86 -0
- vyperling/discoverer.py +77 -0
- vyperling/errors.py +36 -0
- vyperling/mockgen.py +403 -0
- vyperling/reporter.py +138 -0
- vyperling/runner.py +132 -0
- vyperling/scaffold.py +67 -0
- vyperling/templates/__init__.py +0 -0
- vyperling/templates/mock_header.h.j2 +38 -0
- vyperling/templates/mock_source.c.j2 +159 -0
- vyperling/templates/scaffold_example_c.j2 +7 -0
- vyperling/templates/scaffold_example_h.j2 +7 -0
- vyperling/templates/scaffold_forge_yml.j2 +25 -0
- vyperling/templates/scaffold_readme_md.j2 +29 -0
- vyperling/templates/scaffold_test_example_c.j2 +18 -0
- vyperling/toolchains.py +143 -0
- vyperling/unity.py +60 -0
- vyperling-0.0.1.dist-info/METADATA +491 -0
- vyperling-0.0.1.dist-info/RECORD +33 -0
- vyperling-0.0.1.dist-info/WHEEL +4 -0
- vyperling-0.0.1.dist-info/entry_points.txt +4 -0
- vyperling-0.0.1.dist-info/licenses/LICENSE +21 -0
vyperling/__init__.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Unity Test Framework
|
|
2
|
+
https://github.com/ThrowTheSwitch/Unity
|
|
3
|
+
Version: 2.6.1
|
|
4
|
+
License: MIT
|
|
5
|
+
|
|
6
|
+
Copyright (c) 2007-2021 Mike Karlesky, Mark VanderVoord, Greg Williams
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
in the Software without restriction, including without limitation the rights
|
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
SOFTWARE.
|
vyperling/c/forge_mock.c
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/* forge_mock.c — vyperling mock runtime (shared, vendored). See forge_mock.h. */
|
|
2
|
+
#include "forge_mock.h"
|
|
3
|
+
#include "unity.h"
|
|
4
|
+
|
|
5
|
+
static unsigned char forge_mock_arena[FORGE_MOCK_MEM_SIZE];
|
|
6
|
+
static size_t forge_mock_used = 0;
|
|
7
|
+
static int forge_mock_refs = 0;
|
|
8
|
+
static int forge_mock_line = 0;
|
|
9
|
+
|
|
10
|
+
#define FORGE_MOCK_ALIGN (sizeof(void *))
|
|
11
|
+
|
|
12
|
+
void forge_mock_arena_acquire(void)
|
|
13
|
+
{
|
|
14
|
+
if (forge_mock_refs == 0) {
|
|
15
|
+
forge_mock_used = 0; /* reset only at the start of a round */
|
|
16
|
+
}
|
|
17
|
+
forge_mock_refs++;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
void forge_mock_arena_release(void)
|
|
21
|
+
{
|
|
22
|
+
if (forge_mock_refs > 0) {
|
|
23
|
+
forge_mock_refs--;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
void *forge_mock_alloc(size_t size)
|
|
28
|
+
{
|
|
29
|
+
size = (size + (FORGE_MOCK_ALIGN - 1)) & ~(FORGE_MOCK_ALIGN - 1);
|
|
30
|
+
if (forge_mock_used + size > FORGE_MOCK_MEM_SIZE) {
|
|
31
|
+
UNITY_TEST_FAIL((UNITY_LINE_TYPE)forge_mock_line,
|
|
32
|
+
"forge_mock: arena exhausted; raise FORGE_MOCK_MEM_SIZE");
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
{
|
|
36
|
+
void *p = &forge_mock_arena[forge_mock_used];
|
|
37
|
+
forge_mock_used += size;
|
|
38
|
+
return p;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
void forge_mock_queue_reset(forge_mock_queue *q)
|
|
43
|
+
{
|
|
44
|
+
q->head = q->tail = q->replay = 0;
|
|
45
|
+
q->count = 0;
|
|
46
|
+
q->consumed = 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
void *forge_mock_queue_push(forge_mock_queue *q, size_t size)
|
|
50
|
+
{
|
|
51
|
+
void *rec = forge_mock_alloc(size);
|
|
52
|
+
if (!rec) {
|
|
53
|
+
return 0;
|
|
54
|
+
}
|
|
55
|
+
*(void **)rec = 0; /* next = NULL */
|
|
56
|
+
if (q->tail) {
|
|
57
|
+
*(void **)q->tail = rec;
|
|
58
|
+
} else {
|
|
59
|
+
q->head = rec;
|
|
60
|
+
q->replay = rec;
|
|
61
|
+
}
|
|
62
|
+
q->tail = rec;
|
|
63
|
+
q->count++;
|
|
64
|
+
return rec;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
void *forge_mock_queue_pop(forge_mock_queue *q)
|
|
68
|
+
{
|
|
69
|
+
void *rec = q->replay;
|
|
70
|
+
if (rec) {
|
|
71
|
+
q->replay = *(void **)rec;
|
|
72
|
+
q->consumed++;
|
|
73
|
+
}
|
|
74
|
+
return rec;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
void forge_mock_set_line(int line)
|
|
78
|
+
{
|
|
79
|
+
forge_mock_line = line;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* Build "<func>: <msg>" without depending on sprintf/stdio. */
|
|
83
|
+
void forge_mock_fail(const char *func, const char *msg)
|
|
84
|
+
{
|
|
85
|
+
static char buf[256];
|
|
86
|
+
size_t i = 0;
|
|
87
|
+
const char *s = func;
|
|
88
|
+
while (*s && i < 200) {
|
|
89
|
+
buf[i++] = *s++;
|
|
90
|
+
}
|
|
91
|
+
buf[i++] = ':';
|
|
92
|
+
buf[i++] = ' ';
|
|
93
|
+
s = msg;
|
|
94
|
+
while (*s && i < 255) {
|
|
95
|
+
buf[i++] = *s++;
|
|
96
|
+
}
|
|
97
|
+
buf[i] = 0;
|
|
98
|
+
UNITY_TEST_FAIL((UNITY_LINE_TYPE)forge_mock_line, buf);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
void forge_mock_fail_no_expect(const char *func)
|
|
102
|
+
{
|
|
103
|
+
forge_mock_fail(func, "called more times than expected");
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
void forge_mock_verify_queue(const char *func, forge_mock_queue *q)
|
|
107
|
+
{
|
|
108
|
+
if (q->consumed < q->count) {
|
|
109
|
+
forge_mock_fail(func, "expected call(s) not received before Verify");
|
|
110
|
+
}
|
|
111
|
+
}
|
vyperling/c/forge_mock.h
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/* forge_mock.h — vyperling mock runtime (shared, vendored).
|
|
2
|
+
*
|
|
3
|
+
* Generic machinery used by every generated mock_<module>.c:
|
|
4
|
+
* - a no-heap bump-allocator arena (works bare-metal under QEMU)
|
|
5
|
+
* - a refcounted acquire/release so multiple modules can share the arena
|
|
6
|
+
* within one test without one module's Init wiping another's queue
|
|
7
|
+
* - a generic FIFO queue of call-instance records
|
|
8
|
+
* - a failure funnel that routes every mock failure through Unity
|
|
9
|
+
*
|
|
10
|
+
* Generated mocks #include this. Do not edit generated code; edit here.
|
|
11
|
+
*/
|
|
12
|
+
#ifndef FORGE_MOCK_H
|
|
13
|
+
#define FORGE_MOCK_H
|
|
14
|
+
|
|
15
|
+
#include <stddef.h>
|
|
16
|
+
#include "unity.h"
|
|
17
|
+
|
|
18
|
+
/* Size of the static arena. Override with -DFORGE_MOCK_MEM_SIZE=... if a test
|
|
19
|
+
* queues enough expectations to exhaust it. */
|
|
20
|
+
#ifndef FORGE_MOCK_MEM_SIZE
|
|
21
|
+
#define FORGE_MOCK_MEM_SIZE 32768
|
|
22
|
+
#endif
|
|
23
|
+
|
|
24
|
+
/* ---- Arena (bump allocator, no heap) ------------------------------------ */
|
|
25
|
+
|
|
26
|
+
/* Refcounted. The arena is reset only on the FIRST acquire of a round, so
|
|
27
|
+
* every mock_<mod>_Init() in setUp() shares one arena cleanly. */
|
|
28
|
+
void forge_mock_arena_acquire(void);
|
|
29
|
+
void forge_mock_arena_release(void);
|
|
30
|
+
void *forge_mock_alloc(size_t size); /* aligned; fails the test on OOM */
|
|
31
|
+
|
|
32
|
+
/* ---- Generic FIFO queue of call-instance records ------------------------
|
|
33
|
+
* Each record's FIRST member must be a `void *next` link. Generated per-
|
|
34
|
+
* function structs follow that layout. */
|
|
35
|
+
typedef struct forge_mock_queue_s {
|
|
36
|
+
void *head; /* oldest queued expectation */
|
|
37
|
+
void *tail; /* newest */
|
|
38
|
+
void *replay; /* next record to consume on an actual call */
|
|
39
|
+
int count; /* total queued */
|
|
40
|
+
int consumed; /* calls replayed so far */
|
|
41
|
+
} forge_mock_queue;
|
|
42
|
+
|
|
43
|
+
void forge_mock_queue_reset(forge_mock_queue *q);
|
|
44
|
+
void *forge_mock_queue_push(forge_mock_queue *q, size_t size); /* alloc+append */
|
|
45
|
+
void *forge_mock_queue_pop(forge_mock_queue *q); /* current or NULL */
|
|
46
|
+
|
|
47
|
+
/* ---- Failure funnel — everything routes through Unity ------------------- */
|
|
48
|
+
|
|
49
|
+
void forge_mock_set_line(int line); /* line of the Expect call */
|
|
50
|
+
void forge_mock_fail(const char *func, const char *msg); /* -> UNITY_TEST_FAIL */
|
|
51
|
+
void forge_mock_fail_no_expect(const char *func); /* called more than expected */
|
|
52
|
+
void forge_mock_verify_queue(const char *func, forge_mock_queue *q); /* too-few-calls */
|
|
53
|
+
|
|
54
|
+
#endif /* FORGE_MOCK_H */
|