blob: dfc079e9974c274e260058d82c37df4888108754 [file] [log] [blame]
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +00001lit - LLVM Integrated Tester
2============================
3
James Hendersona0566842019-06-27 13:24:46 +00004.. program:: lit
5
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +00006SYNOPSIS
7--------
8
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +00009:program:`lit` [*options*] [*tests*]
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000010
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000011DESCRIPTION
12-----------
13
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000014:program:`lit` is a portable tool for executing LLVM and Clang style test
15suites, summarizing their results, and providing indication of failures.
16:program:`lit` is designed to be a lightweight testing tool with as simple a
17user interface as possible.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000018
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000019:program:`lit` should be run with one or more *tests* to run specified on the
20command line. Tests can be either individual test files or directories to
21search for tests (see :ref:`test-discovery`).
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000022
23Each specified test will be executed (potentially in parallel) and once all
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000024tests have been run :program:`lit` will print summary information on the number
25of tests which passed or failed (see :ref:`test-status-results`). The
26:program:`lit` program will execute with a non-zero exit code if any tests
27fail.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000028
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000029By default :program:`lit` will use a succinct progress display and will only
30print summary information for test failures. See :ref:`output-options` for
31options controlling the :program:`lit` progress display and output.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000032
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000033:program:`lit` also includes a number of options for controlling how tests are
34executed (specific features may depend on the particular test format). See
Dmitri Gribenko6e303f72012-11-29 17:05:34 +000035:ref:`execution-options` for more information.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000036
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000037Finally, :program:`lit` also supports additional options for only running a
38subset of the options specified on the command line, see
39:ref:`selection-options` for more information.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000040
Joel E. Denny16020582019-07-08 12:18:40 +000041:program:`lit` parses options from the environment variable ``LIT_OPTS`` after
42parsing options from the command line. ``LIT_OPTS`` is primarily useful for
43supplementing or overriding the command-line options supplied to :program:`lit`
44by ``check`` targets defined by a project's build system.
45
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000046Users interested in the :program:`lit` architecture or designing a
47:program:`lit` testing implementation should see :ref:`lit-infrastructure`.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000048
49GENERAL OPTIONS
50---------------
51
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000052.. option:: -h, --help
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000053
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000054 Show the :program:`lit` help message.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000055
Julian Lettnerb8588952019-10-10 19:43:57 +000056.. option:: -j N, --workers=N
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000057
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000058 Run ``N`` tests in parallel. By default, this is automatically chosen to
59 match the number of detected available CPUs.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000060
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000061.. option:: --config-prefix=NAME
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000062
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000063 Search for :file:`{NAME}.cfg` and :file:`{NAME}.site.cfg` when searching for
64 test suites, instead of :file:`lit.cfg` and :file:`lit.site.cfg`.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000065
Matthias Braun6717a0b2017-02-09 23:03:22 +000066.. option:: -D NAME[=VALUE], --param NAME[=VALUE]
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000067
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000068 Add a user defined parameter ``NAME`` with the given ``VALUE`` (or the empty
69 string if not given). The meaning and use of these parameters is test suite
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000070 dependent.
71
Dmitri Gribenko6e303f72012-11-29 17:05:34 +000072.. _output-options:
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000073
74OUTPUT OPTIONS
75--------------
76
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000077.. option:: -q, --quiet
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000078
79 Suppress any output except for test failures.
80
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000081.. option:: -s, --succinct
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000082
83 Show less output, for example don't show information on tests that pass.
84
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +000085.. option:: -v, --verbose
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +000086
87 Show more information on test failures, for example the entire test output
88 instead of just the test result.
89
George Karpenkovdfa6c202017-07-13 19:26:27 +000090.. option:: -vv, --echo-all-commands
91
92 Echo all commands to stdout, as they are being executed.
93 This can be valuable for debugging test failures, as the last echoed command
94 will be the one which has failed.
Joel E. Denny31b37392018-05-31 00:55:32 +000095 :program:`lit` normally inserts a no-op command (``:`` in the case of bash)
96 with argument ``'RUN: at line N'`` before each command pipeline, and this
97 option also causes those no-op commands to be echoed to stdout to help you
98 locate the source line of the failed command.
George Karpenkovdfa6c202017-07-13 19:26:27 +000099 This option implies ``--verbose``.
100
Matthias Braunf5e2b8f2015-11-06 01:13:40 +0000101.. option:: -a, --show-all
102
103 Show more information about all tests, for example the entire test
104 commandline and output.
105
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000106.. option:: --no-progress-bar
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000107
108 Do not use curses based progress bar.
109
Eric Fiselier18fab462014-07-31 20:11:13 +0000110.. option:: --show-unsupported
111
112 Show the names of unsupported tests.
113
Eric Fiselierc85f00a2014-08-02 01:29:52 +0000114.. option:: --show-xfail
115
116 Show the names of tests that were expected to fail.
117
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000118.. _execution-options:
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000119
120EXECUTION OPTIONS
121-----------------
122
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000123.. option:: --path=PATH
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000124
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000125 Specify an additional ``PATH`` to use when searching for executables in tests.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000126
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000127.. option:: --vg
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000128
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000129 Run individual tests under valgrind (using the memcheck tool). The
130 ``--error-exitcode`` argument for valgrind is used so that valgrind failures
131 will cause the program to exit with a non-zero status.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000132
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000133 When this option is enabled, :program:`lit` will also automatically provide a
134 "``valgrind``" feature that can be used to conditionally disable (or expect
135 failure in) certain tests.
Daniel Dunbar519a3492012-10-19 20:12:00 +0000136
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000137.. option:: --vg-arg=ARG
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000138
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000139 When :option:`--vg` is used, specify an additional argument to pass to
140 :program:`valgrind` itself.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000141
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000142.. option:: --vg-leak
Daniel Dunbar519a3492012-10-19 20:12:00 +0000143
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000144 When :option:`--vg` is used, enable memory leak checks. When this option is
145 enabled, :program:`lit` will also automatically provide a "``vg_leak``"
146 feature that can be used to conditionally disable (or expect failure in)
147 certain tests.
Daniel Dunbar519a3492012-10-19 20:12:00 +0000148
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000149.. option:: --time-tests
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000150
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000151 Track the wall time individual tests take to execute and includes the results
152 in the summary output. This is useful for determining which tests in a test
153 suite take the most time to execute. Note that this option is most useful
154 with ``-j 1``.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000155
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000156.. _selection-options:
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000157
158SELECTION OPTIONS
159-----------------
160
Mike Edwards972a73a2020-06-06 16:53:58 -0700161.. option:: --max-failures MAX_FAILURES
162
163 Stop execution after the given number of failures.
164 An integer argument may be passed on the command line
165 or the environment vairable MAX_FAILURES may be set
166 prior to execution.
167
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000168.. option:: --max-tests=N
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000169
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000170 Run at most ``N`` tests and then terminate.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000171
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000172.. option:: --max-time=N
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000173
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000174 Spend at most ``N`` seconds (approximately) running tests and then terminate.
Jon Roelofs42bf07562020-04-25 16:19:02 -0600175 Note that this is not an alias for :option:`--timeout`; the two are
Jon Roelofsb3f16822020-04-22 12:56:22 -0600176 different kinds of maximums.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000177
Graydon Hoareae5d7bb2017-01-18 18:12:20 +0000178.. option:: --num-shards=M
179
180 Divide the set of selected tests into ``M`` equal-sized subsets or
181 "shards", and run only one of them. Must be used with the
182 ``--run-shard=N`` option, which selects the shard to run. The environment
183 variable ``LIT_NUM_SHARDS`` can also be used in place of this
Kazuaki Ishizakif65d4aa2020-01-22 11:30:57 +0800184 option. These two options provide a coarse mechanism for partitioning large
Graydon Hoareae5d7bb2017-01-18 18:12:20 +0000185 testsuites, for parallel execution on separate machines (say in a large
186 testing farm).
187
188.. option:: --run-shard=N
189
190 Select which shard to run, assuming the ``--num-shards=M`` option was
191 provided. The two options must be used together, and the value of ``N``
192 must be in the range ``1..M``. The environment variable
193 ``LIT_RUN_SHARD`` can also be used in place of this option.
194
Jon Roelofsb3f16822020-04-22 12:56:22 -0600195.. option:: --shuffle
196
197 Run the tests in a random order.
198
199.. option:: --timeout=N
200
201 Spend at most ``N`` seconds (approximately) running each individual test.
202 ``0`` means no time limit, and ``0`` is the default. Note that this is not an
Jon Roelofs42bf07562020-04-25 16:19:02 -0600203 alias for :option:`--max-time`; the two are different kinds of maximums.
Jon Roelofsb3f16822020-04-22 12:56:22 -0600204
George Karpenkov22a402f2017-07-07 00:22:11 +0000205.. option:: --filter=REGEXP
206
207 Run only those tests whose name matches the regular expression specified in
208 ``REGEXP``. The environment variable ``LIT_FILTER`` can be also used in place
209 of this option, which is especially useful in environments where the call
210 to ``lit`` is issued indirectly.
211
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000212ADDITIONAL OPTIONS
213------------------
214
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000215.. option:: --debug
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000216
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000217 Run :program:`lit` in debug mode, for debugging configuration issues and
218 :program:`lit` itself.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000219
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000220.. option:: --show-suites
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000221
Daniel Dunbarc4477df2013-08-08 20:59:25 +0000222 List the discovered test suites and exit.
223
224.. option:: --show-tests
225
Eric Christopher572e03a2015-06-19 01:53:21 +0000226 List all of the discovered tests and exit.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000227
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000228EXIT STATUS
229-----------
230
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000231:program:`lit` will exit with an exit code of 1 if there are any FAIL or XPASS
232results. Otherwise, it will exit with the status 0. Other exit codes are used
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000233for non-test related failures (for example a user error or an internal program
234error).
235
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000236.. _test-discovery:
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000237
238TEST DISCOVERY
239--------------
240
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000241The inputs passed to :program:`lit` can be either individual tests, or entire
242directories or hierarchies of tests to run. When :program:`lit` starts up, the
243first thing it does is convert the inputs into a complete list of tests to run
244as part of *test discovery*.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000245
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000246In the :program:`lit` model, every test must exist inside some *test suite*.
247:program:`lit` resolves the inputs specified on the command line to test suites
248by searching upwards from the input path until it finds a :file:`lit.cfg` or
249:file:`lit.site.cfg` file. These files serve as both a marker of test suites
250and as configuration files which :program:`lit` loads in order to understand
251how to find and run the tests inside the test suite.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000252
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000253Once :program:`lit` has mapped the inputs into test suites it traverses the
254list of inputs adding tests for individual files and recursively searching for
255tests in directories.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000256
257This behavior makes it easy to specify a subset of tests to run, while still
258allowing the test suite configuration to control exactly how tests are
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000259interpreted. In addition, :program:`lit` always identifies tests by the test
260suite they are in, and their relative path inside the test suite. For
261appropriately configured projects, this allows :program:`lit` to provide
262convenient and flexible support for out-of-tree builds.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000263
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000264.. _test-status-results:
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000265
266TEST STATUS RESULTS
267-------------------
268
Louis Dionne83346a42020-03-24 14:45:17 -0400269Each test ultimately produces one of the following eight results:
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000270
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000271**PASS**
272
273 The test succeeded.
274
Louis Dionne83346a42020-03-24 14:45:17 -0400275**FLAKYPASS**
276
277 The test succeeded after being re-run more than once. This only applies to
278 tests containing an ``ALLOW_RETRIES:`` annotation.
279
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000280**XFAIL**
281
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000282 The test failed, but that is expected. This is used for test formats which allow
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000283 specifying that a test does not currently work, but wish to leave it in the test
284 suite.
285
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000286**XPASS**
287
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000288 The test succeeded, but it was expected to fail. This is used for tests which
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000289 were specified as expected to fail, but are now succeeding (generally because
290 the feature they test was broken and has been fixed).
291
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000292**FAIL**
293
294 The test failed.
295
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000296**UNRESOLVED**
297
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000298 The test result could not be determined. For example, this occurs when the test
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000299 could not be run, the test itself is invalid, or the test was interrupted.
300
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000301**UNSUPPORTED**
302
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000303 The test is not supported in this environment. This is used by test formats
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000304 which can report unsupported tests.
305
Louis Dionne83346a42020-03-24 14:45:17 -0400306**TIMEOUT**
307
308 The test was run, but it timed out before it was able to complete. This is
309 considered a failure.
310
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000311Depending on the test format tests may produce additional information about
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000312their status (generally only for failures). See the :ref:`output-options`
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000313section for more information.
314
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000315.. _lit-infrastructure:
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000316
317LIT INFRASTRUCTURE
318------------------
319
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000320This section describes the :program:`lit` testing architecture for users interested in
321creating a new :program:`lit` testing implementation, or extending an existing one.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000322
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000323:program:`lit` proper is primarily an infrastructure for discovering and running
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000324arbitrary tests, and to expose a single convenient interface to these
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000325tests. :program:`lit` itself doesn't know how to run tests, rather this logic is
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000326defined by *test suites*.
327
328TEST SUITES
329~~~~~~~~~~~
330
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000331As described in :ref:`test-discovery`, tests are always located inside a *test
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000332suite*. Test suites serve to define the format of the tests they contain, the
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000333logic for finding those tests, and any additional information to run the tests.
334
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000335:program:`lit` identifies test suites as directories containing ``lit.cfg`` or
336``lit.site.cfg`` files (see also :option:`--config-prefix`). Test suites are
337initially discovered by recursively searching up the directory hierarchy for
338all the input files passed on the command line. You can use
339:option:`--show-suites` to display the discovered test suites at startup.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000340
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000341Once a test suite is discovered, its config file is loaded. Config files
342themselves are Python modules which will be executed. When the config file is
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000343executed, two important global variables are predefined:
344
Eric Fiselier6c53c862014-08-15 05:54:19 +0000345**lit_config**
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000346
347 The global **lit** configuration object (a *LitConfig* instance), which defines
348 the builtin test formats, global configuration parameters, and other helper
349 routines for implementing test configurations.
350
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000351**config**
352
353 This is the config object (a *TestingConfig* instance) for the test suite,
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000354 which the config file is expected to populate. The following variables are also
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000355 available on the *config* object, some of which must be set by the config and
356 others are optional or predefined:
357
358 **name** *[required]* The name of the test suite, for use in reports and
359 diagnostics.
360
361 **test_format** *[required]* The test format object which will be used to
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000362 discover and run tests in the test suite. Generally this will be a builtin test
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000363 format available from the *lit.formats* module.
364
Sergey Matveev8dbcb352013-05-30 12:37:52 +0000365 **test_source_root** The filesystem path to the test suite root. For out-of-dir
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000366 builds this is the directory that will be scanned for tests.
367
368 **test_exec_root** For out-of-dir builds, the path to the test suite root inside
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000369 the object directory. This is where tests will be run and temporary output files
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000370 placed.
371
372 **environment** A dictionary representing the environment to use when executing
373 tests in the suite.
374
375 **suffixes** For **lit** test formats which scan directories for tests, this
Dmitri Gribenko9e4fc282013-01-19 20:35:18 +0000376 variable is a list of suffixes to identify test files. Used by: *ShTest*.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000377
378 **substitutions** For **lit** test formats which substitute variables into a test
Dmitri Gribenko9e4fc282013-01-19 20:35:18 +0000379 script, the list of substitutions to perform. Used by: *ShTest*.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000380
381 **unsupported** Mark an unsupported directory, all tests within it will be
Dmitri Gribenko9e4fc282013-01-19 20:35:18 +0000382 reported as unsupported. Used by: *ShTest*.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000383
384 **parent** The parent configuration, this is the config object for the directory
385 containing the test suite, or None.
386
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000387 **root** The root configuration. This is the top-most :program:`lit` configuration in
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000388 the project.
389
Rafael Espindola2a2a0972013-07-26 22:32:58 +0000390 **pipefail** Normally a test using a shell pipe fails if any of the commands
391 on the pipe fail. If this is not desired, setting this variable to false
392 makes the test fail only if the last command in the pipe fails.
393
Daniel Sanders61516992016-07-26 13:23:27 +0000394 **available_features** A set of features that can be used in `XFAIL`,
395 `REQUIRES`, and `UNSUPPORTED` directives.
396
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000397TEST DISCOVERY
398~~~~~~~~~~~~~~
399
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000400Once test suites are located, :program:`lit` recursively traverses the source
Sergey Matveev8dbcb352013-05-30 12:37:52 +0000401directory (following *test_source_root*) looking for tests. When :program:`lit`
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000402enters a sub-directory, it first checks to see if a nested test suite is
403defined in that directory. If so, it loads that test suite recursively,
404otherwise it instantiates a local test config for the directory (see
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000405:ref:`local-configuration-files`).
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000406
407Tests are identified by the test suite they are contained within, and the
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000408relative path inside that suite. Note that the relative path may not refer to
409an actual file on disk; some test formats (such as *GoogleTest*) define
410"virtual tests" which have a path that contains both the path to the actual
411test file and a subpath to identify the virtual test.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000412
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000413.. _local-configuration-files:
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000414
415LOCAL CONFIGURATION FILES
416~~~~~~~~~~~~~~~~~~~~~~~~~
417
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000418When :program:`lit` loads a subdirectory in a test suite, it instantiates a
Jonathan Roelofsc9904592015-02-07 17:18:26 +0000419local test configuration by cloning the configuration for the parent directory
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000420--- the root of this configuration chain will always be a test suite. Once the
421test configuration is cloned :program:`lit` checks for a *lit.local.cfg* file
422in the subdirectory. If present, this file will be loaded and can be used to
423specialize the configuration for each individual directory. This facility can
424be used to define subdirectories of optional tests, or to change other
425configuration parameters --- for example, to change the test format, or the
426suffixes which identify test files.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000427
Louis Dionnefaf415a2020-03-14 12:09:52 -0400428SUBSTITUTIONS
429~~~~~~~~~~~~~
Paul Robinsonf88cc142016-04-04 17:14:45 +0000430
Louis Dionnefaf415a2020-03-14 12:09:52 -0400431:program:`lit` allows patterns to be substituted inside RUN commands. It also
432provides the following base set of substitutions, which are defined in
433TestRunner.py:
Paul Robinsonf88cc142016-04-04 17:14:45 +0000434
Daniel Sanders82f3c5d2019-12-04 14:24:51 -0800435 ======================= ==============
436 Macro Substitution
437 ======================= ==============
438 %s source path (path to the file currently being run)
439 %S source dir (directory of the file currently being run)
440 %p same as %S
441 %{pathsep} path separator
442 %t temporary file name unique to the test
443 %basename_t The last path component of %t but without the ``.tmp`` extension
444 %T parent directory of %t (not unique, deprecated, do not use)
445 %% %
446 %/s %s but ``\`` is replaced by ``/``
447 %/S %S but ``\`` is replaced by ``/``
448 %/p %p but ``\`` is replaced by ``/``
449 %/t %t but ``\`` is replaced by ``/``
450 %/T %T but ``\`` is replaced by ``/``
451 %{/s:regex_replacement} %/s but escaped for use in the replacement of a ``s@@@`` command in sed
452 %{/S:regex_replacement} %/S but escaped for use in the replacement of a ``s@@@`` command in sed
453 %{/p:regex_replacement} %/p but escaped for use in the replacement of a ``s@@@`` command in sed
454 %{/t:regex_replacement} %/t but escaped for use in the replacement of a ``s@@@`` command in sed
455 %{/T:regex_replacement} %/T but escaped for use in the replacement of a ``s@@@`` command in sed
456 %:s On Windows, %/s but a ``:`` is removed if its the second character.
457 Otherwise, %s but with a single leading ``/`` removed.
458 %:S On Windows, %/S but a ``:`` is removed if its the second character.
459 Otherwise, %S but with a single leading ``/`` removed.
460 %:p On Windows, %/p but a ``:`` is removed if its the second character.
461 Otherwise, %p but with a single leading ``/`` removed.
462 %:t On Windows, %/t but a ``:`` is removed if its the second character.
463 Otherwise, %t but with a single leading ``/`` removed.
464 %:T On Windows, %/T but a ``:`` is removed if its the second character.
465 Otherwise, %T but with a single leading ``/`` removed.
466 ======================= ==============
Paul Robinsonf88cc142016-04-04 17:14:45 +0000467
David Bozier9126f542017-02-09 14:12:30 +0000468Other substitutions are provided that are variations on this base set and
469further substitution patterns can be defined by each test module. See the
470modules :ref:`local-configuration-files`.
Paul Robinsonf88cc142016-04-04 17:14:45 +0000471
Louis Dionnefaf415a2020-03-14 12:09:52 -0400472By default, substitutions are expanded exactly once, so that if e.g. a
473substitution ``%build`` is defined in top of another substitution ``%cxx``,
474``%build`` will expand to ``%cxx`` textually, not to what ``%cxx`` expands to.
Louis Dionne8a42bf22020-04-03 12:49:09 -0400475However, if the ``recursiveExpansionLimit`` property of the ``TestingConfig``
476is set to a non-negative integer, substitutions will be expanded recursively
477until that limit is reached. It is an error if the limit is reached and
478expanding substitutions again would yield a different result.
Louis Dionnefaf415a2020-03-14 12:09:52 -0400479
David Bozier9126f542017-02-09 14:12:30 +0000480More detailed information on substitutions can be found in the
Paul Robinsonf88cc142016-04-04 17:14:45 +0000481:doc:`../TestingGuide`.
482
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000483TEST RUN OUTPUT FORMAT
484~~~~~~~~~~~~~~~~~~~~~~
485
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000486The :program:`lit` output for a test run conforms to the following schema, in
487both short and verbose modes (although in short mode no PASS lines will be
488shown). This schema has been chosen to be relatively easy to reliably parse by
489a machine (for example in buildbot log scraping), and for other tools to
490generate.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000491
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000492Each test result is expected to appear on a line that matches:
493
494.. code-block:: none
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000495
Eli Bendersky9d07f942012-11-20 00:26:08 +0000496 <result code>: <test name> (<progress info>)
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000497
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000498where ``<result-code>`` is a standard test result such as PASS, FAIL, XFAIL,
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000499XPASS, UNRESOLVED, or UNSUPPORTED. The performance result codes of IMPROVED and
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000500REGRESSED are also allowed.
501
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000502The ``<test name>`` field can consist of an arbitrary string containing no
503newline.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000504
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000505The ``<progress info>`` field can be used to report progress information such
506as (1/300) or can be empty, but even when empty the parentheses are required.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000507
508Each test result may include additional (multiline) log information in the
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000509following format:
510
511.. code-block:: none
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000512
Eli Bendersky9d07f942012-11-20 00:26:08 +0000513 <log delineator> TEST '(<test name>)' <trailing delineator>
514 ... log message ...
515 <log delineator>
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000516
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000517where ``<test name>`` should be the name of a preceding reported test, ``<log
518delineator>`` is a string of "*" characters *at least* four characters long
519(the recommended length is 20), and ``<trailing delineator>`` is an arbitrary
520(unparsed) string.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000521
522The following is an example of a test run output which consists of four tests A,
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000523B, C, and D, and a log message for the failing test C:
524
525.. code-block:: none
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000526
527 PASS: A (1 of 4)
528 PASS: B (2 of 4)
529 FAIL: C (3 of 4)
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000530 ******************** TEST 'C' FAILED ********************
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000531 Test 'C' failed as a result of exit code 1.
Dmitri Gribenko6e303f72012-11-29 17:05:34 +0000532 ********************
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000533 PASS: D (4 of 4)
534
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000535LIT EXAMPLE TESTS
536~~~~~~~~~~~~~~~~~
537
Dmitri Gribenkoe260d3a2012-11-29 18:03:08 +0000538The :program:`lit` distribution contains several example implementations of
539test suites in the *ExampleTests* directory.
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000540
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000541SEE ALSO
542--------
543
Daniel Dunbar8f4a8a62012-05-08 16:50:35 +0000544valgrind(1)