-
Notifications
You must be signed in to change notification settings - Fork 32
Feature: Support for parsing C/C++ test descriptions #2231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
cc @haxtibal @thseiler @richardbarlow @nicpappler @johanenglund @RobertoBagnara @fkromer what do you think about the syntax proposed? Any feedback is appreciated. |
Generally I like the syntax. What I'm just wondering, do we also want a unique ID for a test, so that we can uniquely identify it? I just assume there will not be a separate test case specification in a requirement style describing the test, right? So the test here is both test case specification and test case implementation, right? |
Context: In embedded Linux devices it's pretty common to have heterogeneous language usage (C/C++/Rust, TypeScript, Flutter, ...). I'd extend the requirement to "Implement a general-purpose programming language parser..." in the first place to avoid possible future incompatibilities. Do potential future language specific source code comment processors (equivalents to e.g. C/C++ Doxygen) support the syntax as well? Otherwise it would not be possible to process those comments with those tools anymore. Rust: It would be great to be that generic to enable consideration of Yocto ptest ( |
In general I like the syntax as well. My assumption is that |
This feature world be a very welcomed addition. Anything I don't entirely understand the linkage to the tested requirement if TC-00001 in the example is a test case? |
Thanks to everyone for your comments so far. Let me also share my thoughts and considerations. As someone who has to maintain many features and nuances of StrictDoc in the long term, I would prefer a markup that works consistently across all types of source files and remains independent of any single document processing system—which the proposed example does seem to allow for. The example in the issue description features Doxygen. I am almost fine with using the Example: The following C code: /**
* @brief Adds two integers.
*
* @test Test Initialization
*
* @relation(TC-00001, scope=function)
*
* **Intention**: blabla
*
* **Input**:
* blabla
*
* **Expected Results**:
* This
* \n\n
* is how we can do
* \n\n
* paragraphs.
*
*/
int add(int a, int b); ...translates to Doxygen as follows. Doxygen example![]() I guess there are two things that are inconsistent here, but maybe it is all not so bad and can be acceptable from the user experience point of view: 1) @relation marker is printed as-is. Previously @johanenglund suggested that Doxygen can be customized and the 2) Doing
I am not sure if there is a better way of doing this, and I am open to suggestions. Test case description vs test case source
My understanding is that @Master5 wants to keep the test specification directly in the source code which makes sense from the maintainability point of view. What StrictDoc can do here is to parse both the @relation markers and the The StrictDoc's source parser can work in two different modes:
How to deal with UID?
When it comes to generating the UID, it is again two behaviors:
Open questions
In general, it feels like using ALL_CAPS names for the field names would match StrictDoc's current convention better but I am open to relaxing the constraints at the source code level.
|
Thanks again everyone for the great input. Based on the discussion, I'd like to propose a refined, more consistent and semantically clear approach that may work across multiple languages and tooling setups, including StrictDoc. I don't think Strict needs to be aware of the actual test case description markup or structure. Any metadata, such as the relationship to the requirement, should use existing syntax, such as @relation(...). I propose that the test description be opaque to StrictDoc until the document is actually rendered. This would allow for different styles of test description without adaptation to StrictDoc. Relation Marker ClarificationJust a quick clarification regarding the @relation(TC-00001, scope=function) marker:
Proposal @-based Tags and opqaque test description
Markdown VariantThis approach keeps all tooling-relevant fields prefixed with @ (for traceability), while the rest of the documentation uses Markdown headers for semantic structuring. 1. C/C++
2. Python (e.g. PyTest)
3. Rust
Gherkin-Style VariantThis format aligns with BDD-style scenarios and could optionally be supported for teams already using Gherkin syntax. 1. C/C++
2. Python
3. Rust
Explanation of @ Metadata MarkersAll lines starting with @ are intended for structured metadata and should be interpreted by tools like StrictDoc. These lines should be consistently parseable and ideally defined by a grammar or schema. Currently used: @verification_method(LLT):
You could expand this with additional @key(value) fields in the future — e.g., @author.
|
Just a heads up: @mettta and I are finishing a relatively large migration of the document model. When that is done, I would like to get to implementing a prototype for this test descriptions parser as one of the next work items. In general, I am still seeing the following inconsistencies:
I am leaning towards implementing a parser that would support multiple flavours of the syntax parsing. I will probably start with Any further thoughts on a syntax that would be Markdown-friendly but also non-invasive are appreciated. |
For everyone involved in this discussion, I have merged the initial work here: #2272. See the description there. Now it is to be discussed whether the default grammar chosen is good enough or we need to implement more flavors/customizations. |
Uh oh!
There was an error while loading. Please reload this page.
Description
Add support for parsing C/C++ test descriptions independently of any specific test framework. The parser should extract structured test documentation embedded in comments above test functions, using recognizable markers such as @test and Markdown headers.
Problem
Currently, there is no built-in support for parsing test descriptions directly from C/C++ source files without relying on a specific test framework (e.g., CTest, GoogleTest, etc.). This makes it difficult to extract metadata or structured documentation from tests in a consistent way across different codebases.
Additionally, without structured parsing, it's not possible to automatically generate software test documentation that includes traceability links (e.g., to requirements or test cases). This limits the ability to ensure compliance with standards or maintain a clear test-to-requirement mapping.
Solution
Implement a general-purpose C/C++ parser that can identify specially formatted comment blocks placed above test functions. These blocks should include markers like @test and structured headers e.g. Expected Results:.
To support downstream tooling, the format of these headers should align with the grammar supported by StrictDoc, allowing seamless generation of documentation and traceability reports. This enables the automatic creation of structured test documentation compatible with existing documentation pipelines or compliance tools.
Additional Information
The text was updated successfully, but these errors were encountered: