-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[libcxx][docs] Make test name pattern documentation more obvious #73136
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
Conversation
@llvm/pr-subscribers-libcxx Author: Will Hawkins (hawkinsw) ChangesAs a new contributor, I found it hard to find the documentation for the meaning of the names of different tests and how those names translate to Lit. This makes that documentation more explicit. Full diff: https://github.com/llvm/llvm-project/pull/73136.diff 1 Files Affected:
diff --git a/libcxx/docs/TestingLibcxx.rst b/libcxx/docs/TestingLibcxx.rst
index 44f3904f4e426a0..5783cc6a21922cc 100644
--- a/libcxx/docs/TestingLibcxx.rst
+++ b/libcxx/docs/TestingLibcxx.rst
@@ -330,13 +330,48 @@ additional headers.
taken to make it work in earlier language versions.
-Additional reading
-------------------
-
-The function ``CxxStandardLibraryTest`` in the file
-``libcxx/utils/libcxx/test/format.py`` has documentation about writing test. It
-explains the difference between the test named ``foo.pass.cpp`` and named
-``foo.verify.cpp`` are.
+Test names
+----------
+
+The names of test files have meaning for the libcxx-specific configuration of
+Lit. A complete description can be found in the docstring for the function
+``CxxStandardLibraryTest`` in the file ``libcxx/utils/libcxx/test/format.py``.
+
+For quick reference, here is an overview of some of the most useful patterns:
+
+.. list-table:: Lit Meaning of libcxx Test Filenames
+ :widths: 25 75
+ :header-rows: 1
+
+ * - Name Pattern
+ - Meaning
+ * - ``FOO.pass.cpp``
+ - Compiles, links and runs successfully
+ * - ``FOO.pass.mm``
+ - Same as ``FOO.pass.cpp``, but for Objective-C++
+
+ * - ``FOO.compile.pass.cpp``
+ - Compiles successfully, link and run not attempted
+ * - ``FOO.compile.pass.mm``
+ - Same as ``FOO.compile.pass.cpp``, but for Objective-C++
+ * - ``FOO.compile.fail.cpp``
+ - Does not compile successfully
+
+ * - ``FOO.link.pass.cpp``
+ - Compiles and links successfully, run not attempted
+ * - ``FOO.link.pass.mm``
+ - Same as ``FOO.link.pass.cpp``, but for Objective-C++
+ * - ``FOO.link.fail.cpp``
+ - Compiles successfully, but fails to link
+
+ * - ``FOO.sh.<anything>``
+ - A builtin Lit Shell test
+
+ * - ``FOO.gen.<anything>``
+ - A ``.sh`` test that generates one or more Lit tests on the fly. Executing this test must generate one or more files as expected by LLVM split-file, and each generated file leads to a separate Lit test that runs that file as defined by the test format. This can be used to generate multiple Lit tests from a single source file, which is useful for testing repetitive properties in the library. Be careful not to abuse this since this is not a replacement for usual code reuse techniques.
+
+ * - ``FOO.verify.cpp``
+ - Compiles with clang-verify. This type of test is automatically marked as UNSUPPORTED if the compiler does not support clang-verify.
Benchmarks
==========
|
Great! Thank you for the "go ahead". I will send along some fixups and re-request review when it is ready! |
I have updated to consolidate all documentation about the file name pattern semantics to |
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.
Thanks for working on this, I have grepped for this information a number times. Having it on the website gives it a better visibility.
LGTM modulo some comments. Please wait for @ldionne to review this too.
libcxx/docs/TestingLibcxx.rst
Outdated
|
||
The names of test files have meaning for the libcxx-specific configuration of | ||
Lit. A complete description can be found in the docstring for the function | ||
``CxxStandardLibraryTest`` in the file ``libcxx/utils/libcxx/test/format.py``. |
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.
The last sentence seems no longer to be true.
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.
Good point! :-)
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.
Sorry! I had stupidly not committed a change that fixed this!! Should be resolved now!
libcxx/utils/libcxx/test/format.py
Outdated
|
||
Lit tests are contained in files that follow a certain pattern. That | ||
pattern determines the semantics of the test. See | ||
libcxx/docs/TestingLibcxx.rst or https://libcxx.llvm.org/TestingLibcxx.html |
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.
I would only link to the website and use an anchor.
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.
Good point! Will do!
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.
All done! Great feedback, thank you!
Thank you for the feedback! I really appreciate it! |
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 w/ comments. It would be nice to move the rest of the documentation for the test format to .rst
too, otherwise we'll have things in multiple places which means more likely to forget to update new information everywhere.
Lit tests are contained in files that follow a certain pattern. That | ||
pattern determines the semantics of the test. See | ||
https://libcxx.llvm.org/TestingLibcxx.html#test-names | ||
for a complete description of those semantics. | ||
|
||
Substitution requirements |
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.
As a follow-up, it would be great to also move this part of the documentation to .rst
so that all of the documentation for the file format is in the same place.
Thank you for the review, @ldionne !! I will incorporate your feedback ASAP! The other thing that I would like to add with this PR is documentation on the actual commands available in the lit built-in shell tests. Does that seem reasonable? If so, I will start working on that and try to have something ready for tomorrow! Thank you again! |
Which commands do you mean? The actual builtin Lit ShTest commands like |
Great! I will work on that. I was talking about documenting the builtin lit "shell" commands (e.g., inproc_builtins = {
"cd": executeBuiltinCd,
"export": executeBuiltinExport,
"echo": executeBuiltinEcho,
"@echo": executeBuiltinEcho,
"mkdir": executeBuiltinMkdir,
"popd": executeBuiltinPopd,
"pushd": executeBuiltinPushd,
"rm": executeBuiltinRm,
":": executeBuiltinColon,
} and if/how they differ in their meaning from posix (or PowerShell). Those are not documented in the other lit documentation (e.g., https://llvm.org/docs/TestingGuide.html#writing-new-regression-tests) and it was something that I struggled to find. Would you prefer that I send that as PR directly to lit? I will reflag you for a review when it is ready! Thanks again! |
I have added documentation for the |
libcxx/docs/TestingLibcxx.rst
Outdated
*all* the files in any specified directories will be placed in the *current working directory* of the test when it executes. All dependency directories and files | ||
specified using relative paths will be anchored to the directory specified by the ``%S`` substitution (i.e., the source directory of the test being executed.). | ||
* - ``ADDITIONAL_COMPILE_FLAGS`` | ||
- ``// ADDITIONAL_COMPILE_FLAGS: flag1, flag2, ...`` |
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.
This is actually whitespace separated now, so this should be ADDITIONAL_COMPILE_FLAGS: flag1 flag2 ...
. We forgot to update it, let's do it here.
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.
I believe I got that in the latest fixup.
FOO.verify.cpp - Compiles with clang-verify. This type of test is | ||
automatically marked as UNSUPPORTED if the compiler | ||
does not support Clang-verify. | ||
|
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.
Additional supported directives
below should go away, since it's now in RST.
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.
All done!!
libcxx/docs/TestingLibcxx.rst
Outdated
specified using relative paths will be anchored to the directory specified by the ``%S`` substitution (i.e., the source directory of the test being executed.). | ||
* - ``ADDITIONAL_COMPILE_FLAGS`` | ||
- ``// ADDITIONAL_COMPILE_FLAGS: flag1, flag2, ...`` | ||
- The additional compiler flags specified using the ``ADDITIONAL_COMPILE_FLAGS`` libc++-specific Lit directive will be added to the invocation of ``clang`` used to build |
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.
This new documentation is not accurate. They don't apply to Clang only, and they do affect .sh.cpp
tests too. I suggest we stick to the previous documentation:
This directive will cause the provided flags to be added to the
%{compile_flags} substitution for the test that contains it. This
allows adding special compilation flags without having to use a
.sh.cpp test, which would be more powerful but perhaps overkill.
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.
I believe that I have properly incorporated this feedback as well! Thanks!
libcxx/docs/TestingLibcxx.rst
Outdated
- Usage | ||
* - ``FILE_DEPENDENCIES`` | ||
- ``// FILE_DEPENDENCIES: file, directory, /path/to/file, ...`` | ||
- The paths given to the ``FILE_DEPENDENCIES`` directive can specify directories or specific files upon which a given test depend. Copies of the files individually specified and |
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.
This is slightly incorrect. This uses the %T
substitution, not %S
. I suggest keeping the wording in the old documentation, I think it wasn't unclear.
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.
The reason I wrote %S
was
# For each file dependency in FILE_DEPENDENCIES, inject a command to copy
# that file to the execution directory. Execute the copy from %S to allow
# relative paths from the test directory.
from line 130 of format.py
. Sorry!
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.
Ah, I see -- you're right, this was missing from the old documentation. Maybe something like this?
This directive expresses that the test requires the provided files
or directories in order to run. An example is a test that requires
some test input stored in a data file. When a test file contains
such a directive, the files will collect them and copy them
to the directory represented by %T. The copy is performed from
the directory represented by %S (i.e. the source directory of the
test being executed), which allows using relative paths to specify
files. After performing the copy, the intent is that %T contains all
the inputs necessary to run the test, such that e.g. execution on a
remote host can be done by simply copying %T to the host.
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.
Let me know what you think about what I am about to commit. I think that your suggestion was great -- the examples really help!
@ldionne Thank you for the feedback. I am sorry that there were mistakes. I am sure that the mistakes were all my fault but I didn't intend to change any of the documentation that was previously written. I will address your comments as soon as possible. I am going to be away from my keyboard until Thursday but will work on it ASAP. |
88590a4
to
eaa17a2
Compare
dbc75c0
to
eaa17a2
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 with minor changes to satisfy RST files. Thanks!
libcxx/docs/TestingLibcxx.rst
Outdated
- Same as ``FOO.pass.cpp``, but for Objective-C++. | ||
|
||
* - ``FOO.compile.pass.cpp`` | ||
- Checks whether the C++ code in the file compiles successfully. In general, prefer `compile` tests over `verify` tests, |
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.
I think you need to use double-backticks here for this to render properly!
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.
I'm surprised this isn't a build error.
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.
I think it's valid RST code, it will just render weird.
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.
Of course I do!! Sorry. Thank you!
As a new contributor, I found it hard to find the documentation for the meaning of the names of different tests and how those names translate to Lit. This makes that documentation more explicit.
Update to consolidate lit test file name pattern semantic documentation to docs/
(Fully) centralize all naming documentation in the rst-based documentation.
Point only to www documentation for test names (per @mordante's excellent feedback)
Be more clear about what type of shell we get when running these tests. Co-authored-by: Louis Dionne <[email protected]>
Make it clearer how the tests are generated by libcxx to drive lit according to the patterns embedded in the filenames that contain tests. Co-authored-by: Louis Dionne <[email protected]>
Add documentation about ADDITIONAL_COMPILE_FLAGS and FILE_DEPENDENCIES.
Address @ldionne's astute feedback.
Add link to Internals Manual for writing clang-verify tests.
Add recommendation on when to write verify tests.
Address final comments.
b044d25
to
4f0e726
Compare
Can I get one more check, @ldionne ? Thanks -- I'm just a little nervous! |
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
…lvm#73136) As a new contributor, I found it hard to find the documentation for the meaning of the names of different tests and how those names translate to Lit. This patch moves the documentation to the RST documentation we publish on the website instead of leaving it in the source code only.
As a new contributor, I found it hard to find the documentation for the meaning of the names of different tests and how those names translate to Lit.
This makes that documentation more explicit.