-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Unify preamble injection in AnalysisFramework
#14480
Conversation
06b57bb
to
4f70c74
Compare
4f70c74
to
633cb41
Compare
633cb41
to
04fd8eb
Compare
078754a
to
b29778c
Compare
b29778c
to
49408be
Compare
}; | ||
|
||
string output = regex_replace(_stderrContent, preReleaseWarningRegex, ""); | ||
return regex_replace(std::move(output), noOutputRegex, ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would string::erase(string::find(preRealeaseWarning))
not work here (on a copy of course)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because there are optional bits in the string. I.e. the error code and some whitespace. I'd have to do the replacement with 4 variants of the string for that to work.
Also, this is just a minor test helper, so not much point in avoiding simple regexes here if using them makes the code simpler.
49408be
to
dbe12ff
Compare
3d3d597
to
02ba1ed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
02ba1ed
to
2baf9d4
Compare
Another refactor before #14433.
Even though
AnalysisFramework
can insert preamble automatically, this code is baked intoparseAnalyseAndReturnError()
, which is not universally used by all test cases. The result is that some test cases reinvent the wheel and implement that bit on their own, always slightly differently. Some of them do not insert license if it's already there, some don't care. Some can handle multi-line comments, some can't.This is quite frustrating because when you're writing a new test case you have to waste time to figure out why there are so many versions of it, which one you need and how to use it. Then you realize you can't easily reuse it and end up adding yet another copy. This PR unifies all that duplicated code into a reusable
withPreamble()
method available to all test cases inheriting fromAnalysisFramework
.It would be nice to also have the error filtering automatically adjust error locations to account for the preamble (
SyntaxTest
already has code for doing that), but I'll leave that for another day.