Skip to content

Commit b4a53dd

Browse files
committed
tests: Add docstrings to __test_relative_header_create_* helper functions
1 parent 4db4304 commit b4a53dd

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

integration_test.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@
77
from testutils import simplecpp, format_include_path_arg, format_include
88

99
def __test_relative_header_create_header(dir, with_pragma_once=True):
10+
"""
11+
Creates a local `test.h` header with both `#pragma once` (optional)
12+
and a macro guard.
13+
14+
The header emits `#error header_was_already_included` if it is
15+
re-included past the guard.
16+
17+
Returns tuple of:
18+
- absolute path to the created header file
19+
- expected compiler error substring for duplicate inclusion
20+
"""
1021
header_file = os.path.join(dir, 'test.h')
1122
with open(header_file, 'wt') as f:
1223
f.write(f"""
@@ -21,6 +32,17 @@ def __test_relative_header_create_header(dir, with_pragma_once=True):
2132
return header_file, "error: #error header_was_already_included"
2233

2334
def __test_relative_header_create_source(dir, include1, include2, is_include1_sys=False, is_include2_sys=False, inv=False):
35+
"""
36+
Creates a C source file that includes two headers in order.
37+
38+
The generated `<dir>/test.c`:
39+
- `#undef TEST_H_INCLUDED` to reset the guard in `test.h`
40+
- includes `include1` then `include2`
41+
- if `inv=True`, the order is swapped (`include2` then `include1`)
42+
- each include can be written as `<...>` or `"..."`
43+
44+
Returns absolute path to the created source file.
45+
"""
2446
if inv:
2547
return __test_relative_header_create_source(dir, include1=include2, include2=include1, is_include1_sys=is_include2_sys, is_include2_sys=is_include1_sys)
2648
## otherwise

0 commit comments

Comments
 (0)