-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[clang-doc] Add regression test for test comments in macros #132510
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
Changes from 3 commits
a6a1916
b15a9d0
2b6556e
875938c
7bad199
9e9fdf6
f9cd05d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| // Fixes #59819. The underlying problem was fixed in https://reviews.llvm.org/D142560, but this patch adds a proper regression test. | ||
| // RUN: rm -rf %t && mkdir -p %t | ||
| // RUN: clang-doc --format=md --doxygen --output=%t --executor=standalone %s | ||
| // RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md --check-prefix=MD-MYCLASS-LINE | ||
| // RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md --check-prefix=MD-MYCLASS | ||
| // RUN: clang-doc --format=html --doxygen --output=%t --executor=standalone %s | ||
ZhongUncle marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html --check-prefix=HTML-MYCLASS-LINE | ||
| // RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html --check-prefix=HTML-MYCLASS | ||
|
|
||
| #define DECLARE_METHODS \ | ||
| /** \ | ||
| * @brief Declare a method to calculate the sum of two numbers\ | ||
| */ \ | ||
| int Add(int a, int b) \ | ||
| { \ | ||
| return a + b; \ | ||
| } | ||
ZhongUncle marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // MD-MYCLASS: ### Add | ||
| // MD-MYCLASS: *public int Add(int a, int b)* | ||
| // MD-MYCLASS: **brief** Declare a method to calculate the sum of two numbers | ||
|
|
||
| // HTML-MYCLASS: <p>public int Add(int a, int b)</p> | ||
| // HTML-MYCLASS: <div>brief</div> | ||
| // HTML-MYCLASS: <p> Declare a method to calculate the sum of two numbers</p> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It isn't clear to me from the test if the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yeah, I notice its line is in class, rather than line comment in macro. I don't know how to use it and can't find usage in documentation. Can you give me a example of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also have another problem: Why HTML match is not similar to Markdown? Because I refer to Markdown match is clearly, HTML seem to ignore something.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://llvm.org/docs/CommandGuide/FileCheck.html#the-check-next-directive has information on how the You use it the following way. What this allows you do do is be certain you're matching the correct part of the output, and that you're not accidentally matching things out of order. This becomes more obvious w/ things in codegen where you have easy to spot delimiters, but are also likely to have many duplicate lines in your test program (e.g. most load instructions look the same). So you use this pattern to match the start of a unique sequence w/ MYCHECK (or whatever your prefix is), and then use MYCHECK-NEXT to make sure the following lines match right afterwards, and not anywhere else.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you are asking. FileCheck pattern matching will match what it finds in the file that matches. IIRC it will take the last thing it finds that matches, not the first. So your lines may match arbitrary things in the output. The markdown has a lot of empty lines, which makes writing checks w/ a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you very much for the explanation, I'll learn about these new LLVM concepts and get familiar with the FileCheck tools, and then improve the code. However, recently I am preparing for the interview for graduate school, so please forgive me for the slow progress. |
||
|
|
||
|
|
||
| class MyClass { | ||
| public: | ||
| // MD-MYCLASS-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}macro.cpp#[[@LINE+2]]* | ||
ilovepi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // HTML-MYCLASS-LINE: <p>Defined at line [[@LINE+1]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}macro.cpp</p> | ||
|
||
| DECLARE_METHODS | ||
| }; | ||
|
|
||



Uh oh!
There was an error while loading. Please reload this page.