Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #425 +/- ##
==========================================
+ Coverage 65.36% 65.51% +0.14%
==========================================
Files 184 184
Lines 22503 22568 +65
==========================================
+ Hits 14710 14785 +75
+ Misses 7793 7783 -10
|
| fn collect_definitions(header: &str) -> Vec<regex::Match<'_>> { | ||
| lazy_static::lazy_static! { | ||
| static ref HEADER_TYPE_DECL_RE: Regex = RegexBuilder::new(r"^(/\*\*.*?\*/\n)?(#define [a-zA-Z_0-9]+ [^\n]+|typedef (struct|enum) [a-zA-Z_0-9]+ +(\{.*?\} )?[a-zA-Z_0-9]+;)\n+") | ||
| static ref HEADER_TYPE_DECL_RE: Regex = RegexBuilder::new(r"^(/\*\*([^*]|\*[^/])*\*/\n)?(#define [a-zA-Z_0-9]+ [^\n]+|typedef (struct|enum) [a-zA-Z_0-9]+ +(\{.*?\} )?[a-zA-Z_0-9]+;)\n+") |
There was a problem hiding this comment.
Could we add some tests for these things? To me it's not clear what assumptions can/should be made about the comments we are matching against. This new pattern has problems with comments ending in **/ and will not stop there. Is that an issue?
There was a problem hiding this comment.
No, it's not an issue, but trivial to fix, added a + there.
9615023 to
add7895
Compare
The previous /\*\*.*?\*/ parsing would match from a comment to the next typedef fulfilling the criteria, instead of matching just the comment itself. This is fixed by matching against /\*\*([^*]|\*+[^*/])*\*+/, where the */ sequence is disallowed within a comment. (Also saves us from needing the ungreedy match.) Signed-off-by: Bob Weinand <[email protected]>
add7895 to
ddbfd7b
Compare
| assert_eq!(matches.len(), 1); | ||
| assert_eq!( | ||
| matches[0].as_str(), | ||
| r"typedef struct ddog_Vec_U8 { |
There was a problem hiding this comment.
So a comment that has a **/ comment end inside it is completely discarded, which is probably fine, since it's not a well formed comment anyway.
There was a problem hiding this comment.
Yes, it's just a test that it doesn't malfunction completely.
After d3f8544 it broke cbindgen generation in dd-trace-php.
The previous /**.*?*/ parsing would match from a comment to the next typedef fulfilling the criteria, instead of matching just the comment itself.
This is fixed by matching against /**([^*]|*[^/])**/, where the */ sequence is disallowed within a comment. (Also saves us from needing the ungreedy match.)