Skip to content

Commit 90455db

Browse files
committed
[libc++] NFC: Add documentation for writing tests
1 parent a6a841e commit 90455db

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

libcxx/docs/TestingLibcxx.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,29 @@ Environment Variables
209209
to use color diagnostic outputs from the compiler.
210210
Also see `color_diagnostics`.
211211

212+
Writing Tests
213+
-------------
214+
215+
When writing tests for the libc++ test suite, you should follow a few guidelines.
216+
This will ensure that your tests can run on a wide variety of hardware and under
217+
a wide variety of configurations. We have several unusual configurations such as
218+
building the tests on one host but running them on a different host, which add a
219+
few requirements to the test suite. Here's some stuff you should know:
220+
221+
- All tests are run in a temporary directory that is unique to that test and
222+
cleaned up after the test is done.
223+
- When a test needs data files as inputs, these data files can be saved in the
224+
repository (when reasonable) and referrenced by the test as
225+
``// FILE_DEPENDENCIES: <path-to-dependencies>``. Copies of these files or
226+
directories will be made available to the test in the temporary directory
227+
where it is run.
228+
- You should never hardcode a path from the build-host in a test, because that
229+
path will not necessarily be available on the host where the tests are run.
230+
- You should try to reduce the runtime dependencies of each test to the minimum.
231+
For example, requiring Python to run a test is bad, since Python is not
232+
necessarily available on all devices we may want to run the tests on (even
233+
though supporting Python is probably trivial for the build-host).
234+
212235
Benchmarks
213236
==========
214237

0 commit comments

Comments
 (0)