2012-05-08 18:50:35 +02:00
|
|
|
lit - LLVM Integrated Tester
|
|
|
|
============================
|
|
|
|
|
[docs][tools] Add missing "program" tags to rst files
Sphinx allows for definitions of command-line options using
`.. option <name>` and references to those options via `:option:<name>`.
However, it looks like there is no scoping of these options by default,
meaning that links can end up pointing to incorrect documents. See for
example the llvm-mca document, which contains references to -o that,
prior to this patch, pointed to a different document. What's worse is
that these links appear to be non-deterministic in which one is picked
(on my machine, some references end up pointing to opt, whereas on the
live docs, they point to llvm-dwarfdump, for example).
The fix is to add the .. program <name> tag. This essentially namespaces
the options (definitions and references) to the named program, ensuring
that the links are kept correct.
Reviwed by: andreadb
Differential Revision: https://reviews.llvm.org/D63873
llvm-svn: 364538
2019-06-27 15:24:46 +02:00
|
|
|
.. program:: lit
|
|
|
|
|
2012-05-08 18:50:35 +02:00
|
|
|
SYNOPSIS
|
|
|
|
--------
|
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
:program:`lit` [*options*] [*tests*]
|
2012-05-08 18:50:35 +02:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
-----------
|
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
:program:`lit` is a portable tool for executing LLVM and Clang style test
|
|
|
|
suites, summarizing their results, and providing indication of failures.
|
|
|
|
:program:`lit` is designed to be a lightweight testing tool with as simple a
|
|
|
|
user interface as possible.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
:program:`lit` should be run with one or more *tests* to run specified on the
|
|
|
|
command line. Tests can be either individual test files or directories to
|
|
|
|
search for tests (see :ref:`test-discovery`).
|
2012-05-08 18:50:35 +02:00
|
|
|
|
[lit] Sort test start times based on prior test timing data
Lit as it exists today has three hacks that allow users to run tests earlier:
1) An entire test suite can set the `is_early` boolean.
2) A very recently introduced "early_tests" feature.
3) The `--incremental` flag forces failing tests to run first.
All of these approaches have problems.
1) The `is_early` feature was until very recently undocumented. Nevertheless it still lacks testing and is a imprecise way of optimizing test starting times.
2) The `early_tests` feature requires manual updates and doesn't scale.
3) `--incremental` is undocumented, untested, and it requires modifying the *source* file system by "touching" the file. This "touch" based approach is arguably a hack because it confuses editors (because it looks like the test was modified behind the back of the editor) and "touching" the test source file doesn't work if the test suite is read only from the perspective of `lit` (via advanced filesystem/build tricks).
This patch attempts to simplify and address all of the above problems.
This patch formalizes, documents, tests, and defaults lit to recording the execution time of tests and then reordering all tests during the next execution. By reordering the tests, high core count machines run faster, sometimes significantly so.
This patch also always runs failing tests first, which is a positive user experience win for those that didn't know about the hidden `--incremental` flag.
Finally, if users want, they can _optionally_ commit the test timing data (or a subset thereof) back to the repository to accelerate bots and first-time runs of the test suite.
Reviewed By: jhenderson, yln
Differential Revision: https://reviews.llvm.org/D98179
2021-03-10 16:19:15 +01:00
|
|
|
Each specified test will be executed (potentially concurrently) and once all
|
2012-11-29 19:03:08 +01:00
|
|
|
tests have been run :program:`lit` will print summary information on the number
|
|
|
|
of tests which passed or failed (see :ref:`test-status-results`). The
|
|
|
|
:program:`lit` program will execute with a non-zero exit code if any tests
|
|
|
|
fail.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
By default :program:`lit` will use a succinct progress display and will only
|
|
|
|
print summary information for test failures. See :ref:`output-options` for
|
|
|
|
options controlling the :program:`lit` progress display and output.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
:program:`lit` also includes a number of options for controlling how tests are
|
|
|
|
executed (specific features may depend on the particular test format). See
|
2012-11-29 18:05:34 +01:00
|
|
|
:ref:`execution-options` for more information.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
Finally, :program:`lit` also supports additional options for only running a
|
|
|
|
subset of the options specified on the command line, see
|
|
|
|
:ref:`selection-options` for more information.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2019-07-08 14:18:40 +02:00
|
|
|
:program:`lit` parses options from the environment variable ``LIT_OPTS`` after
|
|
|
|
parsing options from the command line. ``LIT_OPTS`` is primarily useful for
|
|
|
|
supplementing or overriding the command-line options supplied to :program:`lit`
|
|
|
|
by ``check`` targets defined by a project's build system.
|
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
Users interested in the :program:`lit` architecture or designing a
|
|
|
|
:program:`lit` testing implementation should see :ref:`lit-infrastructure`.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
|
|
|
GENERAL OPTIONS
|
|
|
|
---------------
|
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
.. option:: -h, --help
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
Show the :program:`lit` help message.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2019-10-10 21:43:57 +02:00
|
|
|
.. option:: -j N, --workers=N
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
Run ``N`` tests in parallel. By default, this is automatically chosen to
|
|
|
|
match the number of detected available CPUs.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
.. option:: --config-prefix=NAME
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
Search for :file:`{NAME}.cfg` and :file:`{NAME}.site.cfg` when searching for
|
|
|
|
test suites, instead of :file:`lit.cfg` and :file:`lit.site.cfg`.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2017-02-10 00:03:22 +01:00
|
|
|
.. option:: -D NAME[=VALUE], --param NAME[=VALUE]
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
Add a user defined parameter ``NAME`` with the given ``VALUE`` (or the empty
|
|
|
|
string if not given). The meaning and use of these parameters is test suite
|
2012-05-08 18:50:35 +02:00
|
|
|
dependent.
|
|
|
|
|
2012-11-29 18:05:34 +01:00
|
|
|
.. _output-options:
|
2012-05-08 18:50:35 +02:00
|
|
|
|
|
|
|
OUTPUT OPTIONS
|
|
|
|
--------------
|
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
.. option:: -q, --quiet
|
2012-05-08 18:50:35 +02:00
|
|
|
|
|
|
|
Suppress any output except for test failures.
|
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
.. option:: -s, --succinct
|
2012-05-08 18:50:35 +02:00
|
|
|
|
|
|
|
Show less output, for example don't show information on tests that pass.
|
2020-08-07 03:02:41 +02:00
|
|
|
Also show a progress bar, unless ``--no-progress-bar`` is specified.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
.. option:: -v, --verbose
|
2012-05-08 18:50:35 +02:00
|
|
|
|
|
|
|
Show more information on test failures, for example the entire test output
|
|
|
|
instead of just the test result.
|
|
|
|
|
2017-07-13 21:26:27 +02:00
|
|
|
.. option:: -vv, --echo-all-commands
|
|
|
|
|
|
|
|
Echo all commands to stdout, as they are being executed.
|
|
|
|
This can be valuable for debugging test failures, as the last echoed command
|
|
|
|
will be the one which has failed.
|
[lit] Report line number for failed RUN command
(Relands r333584, reverted in 333592.)
When debugging test failures with -vv (or -v in the case of the
internal shell), this makes it easier to locate the RUN line that
failed. For example, clang's test/Driver/linux-ld.c has 892 total RUN
lines, and clang's test/Driver/arm-cortex-cpus.c has 424 RUN lines
after concatenation for line continuations.
When reading the generated shell script, this also makes it easier to
locate the RUN line that produced each command.
To support reporting RUN line numbers in the case of the internal
shell, this patch extends the internal shell to support the null
command, ":", except pipelines are not supported.
To support reporting RUN line numbers in the case of windows cmd.exe
as the external shell, this patch extends -vv to set "echo on" instead
of "echo off" in bat files. (Support for windows cmd.exe as a lit
external shell will likely be dropped later, but I found out too
late.)
Reviewed By: delcypher, asmith, stella.stamenova, jmorse, lebedev.ri, rnk
Differential Revision: https://reviews.llvm.org/D44598
llvm-svn: 333614
2018-05-31 02:55:32 +02:00
|
|
|
:program:`lit` normally inserts a no-op command (``:`` in the case of bash)
|
|
|
|
with argument ``'RUN: at line N'`` before each command pipeline, and this
|
|
|
|
option also causes those no-op commands to be echoed to stdout to help you
|
|
|
|
locate the source line of the failed command.
|
2017-07-13 21:26:27 +02:00
|
|
|
This option implies ``--verbose``.
|
|
|
|
|
2015-11-06 02:13:40 +01:00
|
|
|
.. option:: -a, --show-all
|
|
|
|
|
|
|
|
Show more information about all tests, for example the entire test
|
|
|
|
commandline and output.
|
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
.. option:: --no-progress-bar
|
2012-05-08 18:50:35 +02:00
|
|
|
|
|
|
|
Do not use curses based progress bar.
|
|
|
|
|
2014-07-31 22:11:13 +02:00
|
|
|
.. option:: --show-unsupported
|
|
|
|
|
|
|
|
Show the names of unsupported tests.
|
|
|
|
|
2014-08-02 03:29:52 +02:00
|
|
|
.. option:: --show-xfail
|
|
|
|
|
|
|
|
Show the names of tests that were expected to fail.
|
|
|
|
|
2012-11-29 18:05:34 +01:00
|
|
|
.. _execution-options:
|
2012-05-08 18:50:35 +02:00
|
|
|
|
|
|
|
EXECUTION OPTIONS
|
|
|
|
-----------------
|
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
.. option:: --path=PATH
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
Specify an additional ``PATH`` to use when searching for executables in tests.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
.. option:: --vg
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
Run individual tests under valgrind (using the memcheck tool). The
|
|
|
|
``--error-exitcode`` argument for valgrind is used so that valgrind failures
|
|
|
|
will cause the program to exit with a non-zero status.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
When this option is enabled, :program:`lit` will also automatically provide a
|
|
|
|
"``valgrind``" feature that can be used to conditionally disable (or expect
|
|
|
|
failure in) certain tests.
|
2012-10-19 22:12:00 +02:00
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
.. option:: --vg-arg=ARG
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
When :option:`--vg` is used, specify an additional argument to pass to
|
|
|
|
:program:`valgrind` itself.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
.. option:: --vg-leak
|
2012-10-19 22:12:00 +02:00
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
When :option:`--vg` is used, enable memory leak checks. When this option is
|
|
|
|
enabled, :program:`lit` will also automatically provide a "``vg_leak``"
|
|
|
|
feature that can be used to conditionally disable (or expect failure in)
|
|
|
|
certain tests.
|
2012-10-19 22:12:00 +02:00
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
.. option:: --time-tests
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
Track the wall time individual tests take to execute and includes the results
|
|
|
|
in the summary output. This is useful for determining which tests in a test
|
[lit] Sort test start times based on prior test timing data
Lit as it exists today has three hacks that allow users to run tests earlier:
1) An entire test suite can set the `is_early` boolean.
2) A very recently introduced "early_tests" feature.
3) The `--incremental` flag forces failing tests to run first.
All of these approaches have problems.
1) The `is_early` feature was until very recently undocumented. Nevertheless it still lacks testing and is a imprecise way of optimizing test starting times.
2) The `early_tests` feature requires manual updates and doesn't scale.
3) `--incremental` is undocumented, untested, and it requires modifying the *source* file system by "touching" the file. This "touch" based approach is arguably a hack because it confuses editors (because it looks like the test was modified behind the back of the editor) and "touching" the test source file doesn't work if the test suite is read only from the perspective of `lit` (via advanced filesystem/build tricks).
This patch attempts to simplify and address all of the above problems.
This patch formalizes, documents, tests, and defaults lit to recording the execution time of tests and then reordering all tests during the next execution. By reordering the tests, high core count machines run faster, sometimes significantly so.
This patch also always runs failing tests first, which is a positive user experience win for those that didn't know about the hidden `--incremental` flag.
Finally, if users want, they can _optionally_ commit the test timing data (or a subset thereof) back to the repository to accelerate bots and first-time runs of the test suite.
Reviewed By: jhenderson, yln
Differential Revision: https://reviews.llvm.org/D98179
2021-03-10 16:19:15 +01:00
|
|
|
suite take the most time to execute.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2021-02-24 19:05:30 +01:00
|
|
|
.. option:: --ignore-fail
|
|
|
|
|
|
|
|
Exit with status zero even if some tests fail.
|
|
|
|
|
2021-01-15 13:47:32 +01:00
|
|
|
.. option:: --no-indirectly-run-check
|
|
|
|
|
|
|
|
Do not error if a test would not be run if the user had specified the
|
|
|
|
containing directory instead of naming the test directly.
|
|
|
|
|
2012-11-29 18:05:34 +01:00
|
|
|
.. _selection-options:
|
2012-05-08 18:50:35 +02:00
|
|
|
|
|
|
|
SELECTION OPTIONS
|
|
|
|
-----------------
|
|
|
|
|
[lit] Sort test start times based on prior test timing data
Lit as it exists today has three hacks that allow users to run tests earlier:
1) An entire test suite can set the `is_early` boolean.
2) A very recently introduced "early_tests" feature.
3) The `--incremental` flag forces failing tests to run first.
All of these approaches have problems.
1) The `is_early` feature was until very recently undocumented. Nevertheless it still lacks testing and is a imprecise way of optimizing test starting times.
2) The `early_tests` feature requires manual updates and doesn't scale.
3) `--incremental` is undocumented, untested, and it requires modifying the *source* file system by "touching" the file. This "touch" based approach is arguably a hack because it confuses editors (because it looks like the test was modified behind the back of the editor) and "touching" the test source file doesn't work if the test suite is read only from the perspective of `lit` (via advanced filesystem/build tricks).
This patch attempts to simplify and address all of the above problems.
This patch formalizes, documents, tests, and defaults lit to recording the execution time of tests and then reordering all tests during the next execution. By reordering the tests, high core count machines run faster, sometimes significantly so.
This patch also always runs failing tests first, which is a positive user experience win for those that didn't know about the hidden `--incremental` flag.
Finally, if users want, they can _optionally_ commit the test timing data (or a subset thereof) back to the repository to accelerate bots and first-time runs of the test suite.
Reviewed By: jhenderson, yln
Differential Revision: https://reviews.llvm.org/D98179
2021-03-10 16:19:15 +01:00
|
|
|
By default, `lit` will run failing tests first, then run tests in descending
|
|
|
|
execution time order to optimize concurrency.
|
|
|
|
|
|
|
|
The timing data is stored in the `test_exec_root` in a file named
|
|
|
|
`.lit_test_times.txt`. If this file does not exist, then `lit` checks the
|
|
|
|
`test_source_root` for the file to optionally accelerate clean builds.
|
|
|
|
|
|
|
|
.. option:: --shuffle
|
|
|
|
|
|
|
|
Run the tests in a random order, not failing/slowest first.
|
|
|
|
|
2020-06-27 23:57:04 +02:00
|
|
|
.. option:: --max-failures N
|
2020-06-07 01:53:58 +02:00
|
|
|
|
2020-06-27 23:57:04 +02:00
|
|
|
Stop execution after the given number ``N`` of failures.
|
|
|
|
An integer argument should be passed on the command line
|
2020-06-07 01:53:58 +02:00
|
|
|
prior to execution.
|
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
.. option:: --max-tests=N
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
Run at most ``N`` tests and then terminate.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
.. option:: --max-time=N
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
Spend at most ``N`` seconds (approximately) running tests and then terminate.
|
2020-04-26 00:19:02 +02:00
|
|
|
Note that this is not an alias for :option:`--timeout`; the two are
|
2020-04-22 20:56:22 +02:00
|
|
|
different kinds of maximums.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2017-01-18 19:12:20 +01:00
|
|
|
.. option:: --num-shards=M
|
|
|
|
|
|
|
|
Divide the set of selected tests into ``M`` equal-sized subsets or
|
|
|
|
"shards", and run only one of them. Must be used with the
|
|
|
|
``--run-shard=N`` option, which selects the shard to run. The environment
|
|
|
|
variable ``LIT_NUM_SHARDS`` can also be used in place of this
|
2020-01-22 04:30:57 +01:00
|
|
|
option. These two options provide a coarse mechanism for partitioning large
|
2017-01-18 19:12:20 +01:00
|
|
|
testsuites, for parallel execution on separate machines (say in a large
|
|
|
|
testing farm).
|
|
|
|
|
|
|
|
.. option:: --run-shard=N
|
|
|
|
|
|
|
|
Select which shard to run, assuming the ``--num-shards=M`` option was
|
|
|
|
provided. The two options must be used together, and the value of ``N``
|
|
|
|
must be in the range ``1..M``. The environment variable
|
|
|
|
``LIT_RUN_SHARD`` can also be used in place of this option.
|
|
|
|
|
2020-04-22 20:56:22 +02:00
|
|
|
.. option:: --timeout=N
|
|
|
|
|
|
|
|
Spend at most ``N`` seconds (approximately) running each individual test.
|
|
|
|
``0`` means no time limit, and ``0`` is the default. Note that this is not an
|
2020-04-26 00:19:02 +02:00
|
|
|
alias for :option:`--max-time`; the two are different kinds of maximums.
|
2020-04-22 20:56:22 +02:00
|
|
|
|
2017-07-07 02:22:11 +02:00
|
|
|
.. option:: --filter=REGEXP
|
|
|
|
|
|
|
|
Run only those tests whose name matches the regular expression specified in
|
|
|
|
``REGEXP``. The environment variable ``LIT_FILTER`` can be also used in place
|
|
|
|
of this option, which is especially useful in environments where the call
|
|
|
|
to ``lit`` is issued indirectly.
|
|
|
|
|
2021-02-16 12:16:10 +01:00
|
|
|
.. option:: --filter-out=REGEXP
|
|
|
|
|
|
|
|
Filter out those tests whose name matches the regular expression specified in
|
|
|
|
``REGEXP``. The environment variable ``LIT_FILTER_OUT`` can be also used in
|
|
|
|
place of this option, which is especially useful in environments where the
|
|
|
|
call to ``lit`` is issued indirectly.
|
|
|
|
|
|
|
|
.. option:: --xfail=LIST
|
|
|
|
|
|
|
|
Treat those tests whose name is in the semicolon separated list ``LIST`` as
|
|
|
|
``XFAIL``. This can be helpful when one does not want to modify the test
|
|
|
|
suite. The environment variable ``LIT_XFAIL`` can be also used in place of
|
|
|
|
this option, which is especially useful in environments where the call to
|
|
|
|
``lit`` is issued indirectly.
|
|
|
|
|
2012-05-08 18:50:35 +02:00
|
|
|
ADDITIONAL OPTIONS
|
|
|
|
------------------
|
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
.. option:: --debug
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
Run :program:`lit` in debug mode, for debugging configuration issues and
|
|
|
|
:program:`lit` itself.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
.. option:: --show-suites
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2013-08-08 22:59:25 +02:00
|
|
|
List the discovered test suites and exit.
|
|
|
|
|
|
|
|
.. option:: --show-tests
|
|
|
|
|
2015-06-19 03:53:21 +02:00
|
|
|
List all of the discovered tests and exit.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
|
|
|
EXIT STATUS
|
|
|
|
-----------
|
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
:program:`lit` will exit with an exit code of 1 if there are any FAIL or XPASS
|
|
|
|
results. Otherwise, it will exit with the status 0. Other exit codes are used
|
2012-05-08 18:50:35 +02:00
|
|
|
for non-test related failures (for example a user error or an internal program
|
|
|
|
error).
|
|
|
|
|
2012-11-29 18:05:34 +01:00
|
|
|
.. _test-discovery:
|
2012-05-08 18:50:35 +02:00
|
|
|
|
|
|
|
TEST DISCOVERY
|
|
|
|
--------------
|
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
The inputs passed to :program:`lit` can be either individual tests, or entire
|
|
|
|
directories or hierarchies of tests to run. When :program:`lit` starts up, the
|
|
|
|
first thing it does is convert the inputs into a complete list of tests to run
|
|
|
|
as part of *test discovery*.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
In the :program:`lit` model, every test must exist inside some *test suite*.
|
|
|
|
:program:`lit` resolves the inputs specified on the command line to test suites
|
|
|
|
by searching upwards from the input path until it finds a :file:`lit.cfg` or
|
|
|
|
:file:`lit.site.cfg` file. These files serve as both a marker of test suites
|
|
|
|
and as configuration files which :program:`lit` loads in order to understand
|
|
|
|
how to find and run the tests inside the test suite.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
Once :program:`lit` has mapped the inputs into test suites it traverses the
|
|
|
|
list of inputs adding tests for individual files and recursively searching for
|
|
|
|
tests in directories.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
|
|
|
This behavior makes it easy to specify a subset of tests to run, while still
|
|
|
|
allowing the test suite configuration to control exactly how tests are
|
2012-11-29 19:03:08 +01:00
|
|
|
interpreted. In addition, :program:`lit` always identifies tests by the test
|
|
|
|
suite they are in, and their relative path inside the test suite. For
|
|
|
|
appropriately configured projects, this allows :program:`lit` to provide
|
|
|
|
convenient and flexible support for out-of-tree builds.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 18:05:34 +01:00
|
|
|
.. _test-status-results:
|
2012-05-08 18:50:35 +02:00
|
|
|
|
|
|
|
TEST STATUS RESULTS
|
|
|
|
-------------------
|
|
|
|
|
2020-03-24 19:45:17 +01:00
|
|
|
Each test ultimately produces one of the following eight results:
|
2012-05-08 18:50:35 +02:00
|
|
|
|
|
|
|
**PASS**
|
|
|
|
|
|
|
|
The test succeeded.
|
|
|
|
|
2020-03-24 19:45:17 +01:00
|
|
|
**FLAKYPASS**
|
|
|
|
|
|
|
|
The test succeeded after being re-run more than once. This only applies to
|
|
|
|
tests containing an ``ALLOW_RETRIES:`` annotation.
|
|
|
|
|
2012-05-08 18:50:35 +02:00
|
|
|
**XFAIL**
|
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
The test failed, but that is expected. This is used for test formats which allow
|
2012-05-08 18:50:35 +02:00
|
|
|
specifying that a test does not currently work, but wish to leave it in the test
|
|
|
|
suite.
|
|
|
|
|
|
|
|
**XPASS**
|
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
The test succeeded, but it was expected to fail. This is used for tests which
|
2012-05-08 18:50:35 +02:00
|
|
|
were specified as expected to fail, but are now succeeding (generally because
|
|
|
|
the feature they test was broken and has been fixed).
|
|
|
|
|
|
|
|
**FAIL**
|
|
|
|
|
|
|
|
The test failed.
|
|
|
|
|
|
|
|
**UNRESOLVED**
|
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
The test result could not be determined. For example, this occurs when the test
|
2012-05-08 18:50:35 +02:00
|
|
|
could not be run, the test itself is invalid, or the test was interrupted.
|
|
|
|
|
|
|
|
**UNSUPPORTED**
|
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
The test is not supported in this environment. This is used by test formats
|
2012-05-08 18:50:35 +02:00
|
|
|
which can report unsupported tests.
|
|
|
|
|
2020-03-24 19:45:17 +01:00
|
|
|
**TIMEOUT**
|
|
|
|
|
|
|
|
The test was run, but it timed out before it was able to complete. This is
|
|
|
|
considered a failure.
|
|
|
|
|
2012-05-08 18:50:35 +02:00
|
|
|
Depending on the test format tests may produce additional information about
|
2012-11-29 19:03:08 +01:00
|
|
|
their status (generally only for failures). See the :ref:`output-options`
|
2012-05-08 18:50:35 +02:00
|
|
|
section for more information.
|
|
|
|
|
2012-11-29 18:05:34 +01:00
|
|
|
.. _lit-infrastructure:
|
2012-05-08 18:50:35 +02:00
|
|
|
|
|
|
|
LIT INFRASTRUCTURE
|
|
|
|
------------------
|
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
This section describes the :program:`lit` testing architecture for users interested in
|
|
|
|
creating a new :program:`lit` testing implementation, or extending an existing one.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
:program:`lit` proper is primarily an infrastructure for discovering and running
|
2012-05-08 18:50:35 +02:00
|
|
|
arbitrary tests, and to expose a single convenient interface to these
|
2012-11-29 19:03:08 +01:00
|
|
|
tests. :program:`lit` itself doesn't know how to run tests, rather this logic is
|
2012-05-08 18:50:35 +02:00
|
|
|
defined by *test suites*.
|
|
|
|
|
|
|
|
TEST SUITES
|
|
|
|
~~~~~~~~~~~
|
|
|
|
|
2012-11-29 18:05:34 +01:00
|
|
|
As described in :ref:`test-discovery`, tests are always located inside a *test
|
2012-11-29 19:03:08 +01:00
|
|
|
suite*. Test suites serve to define the format of the tests they contain, the
|
2012-05-08 18:50:35 +02:00
|
|
|
logic for finding those tests, and any additional information to run the tests.
|
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
:program:`lit` identifies test suites as directories containing ``lit.cfg`` or
|
|
|
|
``lit.site.cfg`` files (see also :option:`--config-prefix`). Test suites are
|
|
|
|
initially discovered by recursively searching up the directory hierarchy for
|
|
|
|
all the input files passed on the command line. You can use
|
|
|
|
:option:`--show-suites` to display the discovered test suites at startup.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
Once a test suite is discovered, its config file is loaded. Config files
|
|
|
|
themselves are Python modules which will be executed. When the config file is
|
2012-05-08 18:50:35 +02:00
|
|
|
executed, two important global variables are predefined:
|
|
|
|
|
2014-08-15 07:54:19 +02:00
|
|
|
**lit_config**
|
2012-05-08 18:50:35 +02:00
|
|
|
|
|
|
|
The global **lit** configuration object (a *LitConfig* instance), which defines
|
|
|
|
the builtin test formats, global configuration parameters, and other helper
|
|
|
|
routines for implementing test configurations.
|
|
|
|
|
|
|
|
**config**
|
|
|
|
|
|
|
|
This is the config object (a *TestingConfig* instance) for the test suite,
|
2012-11-29 19:03:08 +01:00
|
|
|
which the config file is expected to populate. The following variables are also
|
2012-05-08 18:50:35 +02:00
|
|
|
available on the *config* object, some of which must be set by the config and
|
|
|
|
others are optional or predefined:
|
|
|
|
|
|
|
|
**name** *[required]* The name of the test suite, for use in reports and
|
|
|
|
diagnostics.
|
|
|
|
|
|
|
|
**test_format** *[required]* The test format object which will be used to
|
2012-11-29 19:03:08 +01:00
|
|
|
discover and run tests in the test suite. Generally this will be a builtin test
|
2012-05-08 18:50:35 +02:00
|
|
|
format available from the *lit.formats* module.
|
|
|
|
|
2013-05-30 14:37:52 +02:00
|
|
|
**test_source_root** The filesystem path to the test suite root. For out-of-dir
|
2012-05-08 18:50:35 +02:00
|
|
|
builds this is the directory that will be scanned for tests.
|
|
|
|
|
|
|
|
**test_exec_root** For out-of-dir builds, the path to the test suite root inside
|
2012-11-29 19:03:08 +01:00
|
|
|
the object directory. This is where tests will be run and temporary output files
|
2012-05-08 18:50:35 +02:00
|
|
|
placed.
|
|
|
|
|
|
|
|
**environment** A dictionary representing the environment to use when executing
|
|
|
|
tests in the suite.
|
|
|
|
|
2021-01-15 13:47:32 +01:00
|
|
|
**standalone_tests** When true, mark a directory with tests expected to be run
|
|
|
|
standalone. Test discovery is disabled for that directory and
|
|
|
|
*--no-indirectly-run-check* is in effect. *lit.suffixes* and *lit.excludes*
|
|
|
|
must be empty when this variable is true.
|
|
|
|
|
2012-05-08 18:50:35 +02:00
|
|
|
**suffixes** For **lit** test formats which scan directories for tests, this
|
2013-01-19 21:35:18 +01:00
|
|
|
variable is a list of suffixes to identify test files. Used by: *ShTest*.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
|
|
|
**substitutions** For **lit** test formats which substitute variables into a test
|
2013-01-19 21:35:18 +01:00
|
|
|
script, the list of substitutions to perform. Used by: *ShTest*.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
|
|
|
**unsupported** Mark an unsupported directory, all tests within it will be
|
2013-01-19 21:35:18 +01:00
|
|
|
reported as unsupported. Used by: *ShTest*.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
|
|
|
**parent** The parent configuration, this is the config object for the directory
|
|
|
|
containing the test suite, or None.
|
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
**root** The root configuration. This is the top-most :program:`lit` configuration in
|
2012-05-08 18:50:35 +02:00
|
|
|
the project.
|
|
|
|
|
2013-07-27 00:32:58 +02:00
|
|
|
**pipefail** Normally a test using a shell pipe fails if any of the commands
|
|
|
|
on the pipe fail. If this is not desired, setting this variable to false
|
|
|
|
makes the test fail only if the last command in the pipe fails.
|
|
|
|
|
2016-07-26 15:23:27 +02:00
|
|
|
**available_features** A set of features that can be used in `XFAIL`,
|
|
|
|
`REQUIRES`, and `UNSUPPORTED` directives.
|
|
|
|
|
2012-05-08 18:50:35 +02:00
|
|
|
TEST DISCOVERY
|
|
|
|
~~~~~~~~~~~~~~
|
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
Once test suites are located, :program:`lit` recursively traverses the source
|
2013-05-30 14:37:52 +02:00
|
|
|
directory (following *test_source_root*) looking for tests. When :program:`lit`
|
2012-11-29 19:03:08 +01:00
|
|
|
enters a sub-directory, it first checks to see if a nested test suite is
|
|
|
|
defined in that directory. If so, it loads that test suite recursively,
|
|
|
|
otherwise it instantiates a local test config for the directory (see
|
2012-11-29 18:05:34 +01:00
|
|
|
:ref:`local-configuration-files`).
|
2012-05-08 18:50:35 +02:00
|
|
|
|
|
|
|
Tests are identified by the test suite they are contained within, and the
|
2012-11-29 19:03:08 +01:00
|
|
|
relative path inside that suite. Note that the relative path may not refer to
|
|
|
|
an actual file on disk; some test formats (such as *GoogleTest*) define
|
|
|
|
"virtual tests" which have a path that contains both the path to the actual
|
|
|
|
test file and a subpath to identify the virtual test.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 18:05:34 +01:00
|
|
|
.. _local-configuration-files:
|
2012-05-08 18:50:35 +02:00
|
|
|
|
|
|
|
LOCAL CONFIGURATION FILES
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
When :program:`lit` loads a subdirectory in a test suite, it instantiates a
|
2015-02-07 18:18:26 +01:00
|
|
|
local test configuration by cloning the configuration for the parent directory
|
2012-11-29 19:03:08 +01:00
|
|
|
--- the root of this configuration chain will always be a test suite. Once the
|
|
|
|
test configuration is cloned :program:`lit` checks for a *lit.local.cfg* file
|
|
|
|
in the subdirectory. If present, this file will be loaded and can be used to
|
|
|
|
specialize the configuration for each individual directory. This facility can
|
|
|
|
be used to define subdirectories of optional tests, or to change other
|
|
|
|
configuration parameters --- for example, to change the test format, or the
|
|
|
|
suffixes which identify test files.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2020-03-14 17:09:52 +01:00
|
|
|
SUBSTITUTIONS
|
|
|
|
~~~~~~~~~~~~~
|
2016-04-04 19:14:45 +02:00
|
|
|
|
2020-03-14 17:09:52 +01:00
|
|
|
:program:`lit` allows patterns to be substituted inside RUN commands. It also
|
|
|
|
provides the following base set of substitutions, which are defined in
|
|
|
|
TestRunner.py:
|
2016-04-04 19:14:45 +02:00
|
|
|
|
2019-12-04 23:24:51 +01:00
|
|
|
======================= ==============
|
|
|
|
Macro Substitution
|
|
|
|
======================= ==============
|
|
|
|
%s source path (path to the file currently being run)
|
|
|
|
%S source dir (directory of the file currently being run)
|
|
|
|
%p same as %S
|
|
|
|
%{pathsep} path separator
|
|
|
|
%t temporary file name unique to the test
|
|
|
|
%basename_t The last path component of %t but without the ``.tmp`` extension
|
|
|
|
%T parent directory of %t (not unique, deprecated, do not use)
|
|
|
|
%% %
|
|
|
|
%/s %s but ``\`` is replaced by ``/``
|
|
|
|
%/S %S but ``\`` is replaced by ``/``
|
|
|
|
%/p %p but ``\`` is replaced by ``/``
|
|
|
|
%/t %t but ``\`` is replaced by ``/``
|
|
|
|
%/T %T but ``\`` is replaced by ``/``
|
|
|
|
%{/s:regex_replacement} %/s but escaped for use in the replacement of a ``s@@@`` command in sed
|
|
|
|
%{/S:regex_replacement} %/S but escaped for use in the replacement of a ``s@@@`` command in sed
|
|
|
|
%{/p:regex_replacement} %/p but escaped for use in the replacement of a ``s@@@`` command in sed
|
|
|
|
%{/t:regex_replacement} %/t but escaped for use in the replacement of a ``s@@@`` command in sed
|
|
|
|
%{/T:regex_replacement} %/T but escaped for use in the replacement of a ``s@@@`` command in sed
|
|
|
|
%:s On Windows, %/s but a ``:`` is removed if its the second character.
|
|
|
|
Otherwise, %s but with a single leading ``/`` removed.
|
|
|
|
%:S On Windows, %/S but a ``:`` is removed if its the second character.
|
|
|
|
Otherwise, %S but with a single leading ``/`` removed.
|
|
|
|
%:p On Windows, %/p but a ``:`` is removed if its the second character.
|
|
|
|
Otherwise, %p but with a single leading ``/`` removed.
|
|
|
|
%:t On Windows, %/t but a ``:`` is removed if its the second character.
|
|
|
|
Otherwise, %t but with a single leading ``/`` removed.
|
|
|
|
%:T On Windows, %/T but a ``:`` is removed if its the second character.
|
|
|
|
Otherwise, %T but with a single leading ``/`` removed.
|
|
|
|
======================= ==============
|
2016-04-04 19:14:45 +02:00
|
|
|
|
2017-02-09 15:12:30 +01:00
|
|
|
Other substitutions are provided that are variations on this base set and
|
|
|
|
further substitution patterns can be defined by each test module. See the
|
|
|
|
modules :ref:`local-configuration-files`.
|
2016-04-04 19:14:45 +02:00
|
|
|
|
2020-03-14 17:09:52 +01:00
|
|
|
By default, substitutions are expanded exactly once, so that if e.g. a
|
|
|
|
substitution ``%build`` is defined in top of another substitution ``%cxx``,
|
|
|
|
``%build`` will expand to ``%cxx`` textually, not to what ``%cxx`` expands to.
|
2020-04-03 18:49:09 +02:00
|
|
|
However, if the ``recursiveExpansionLimit`` property of the ``TestingConfig``
|
|
|
|
is set to a non-negative integer, substitutions will be expanded recursively
|
|
|
|
until that limit is reached. It is an error if the limit is reached and
|
|
|
|
expanding substitutions again would yield a different result.
|
2020-03-14 17:09:52 +01:00
|
|
|
|
2017-02-09 15:12:30 +01:00
|
|
|
More detailed information on substitutions can be found in the
|
2016-04-04 19:14:45 +02:00
|
|
|
:doc:`../TestingGuide`.
|
|
|
|
|
2012-05-08 18:50:35 +02:00
|
|
|
TEST RUN OUTPUT FORMAT
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
The :program:`lit` output for a test run conforms to the following schema, in
|
|
|
|
both short and verbose modes (although in short mode no PASS lines will be
|
|
|
|
shown). This schema has been chosen to be relatively easy to reliably parse by
|
|
|
|
a machine (for example in buildbot log scraping), and for other tools to
|
|
|
|
generate.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 18:05:34 +01:00
|
|
|
Each test result is expected to appear on a line that matches:
|
|
|
|
|
|
|
|
.. code-block:: none
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-20 01:26:08 +01:00
|
|
|
<result code>: <test name> (<progress info>)
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 18:05:34 +01:00
|
|
|
where ``<result-code>`` is a standard test result such as PASS, FAIL, XFAIL,
|
2012-11-29 19:03:08 +01:00
|
|
|
XPASS, UNRESOLVED, or UNSUPPORTED. The performance result codes of IMPROVED and
|
2012-05-08 18:50:35 +02:00
|
|
|
REGRESSED are also allowed.
|
|
|
|
|
2012-11-29 18:05:34 +01:00
|
|
|
The ``<test name>`` field can consist of an arbitrary string containing no
|
|
|
|
newline.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 18:05:34 +01:00
|
|
|
The ``<progress info>`` field can be used to report progress information such
|
|
|
|
as (1/300) or can be empty, but even when empty the parentheses are required.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
|
|
|
Each test result may include additional (multiline) log information in the
|
2012-11-29 18:05:34 +01:00
|
|
|
following format:
|
|
|
|
|
|
|
|
.. code-block:: none
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-20 01:26:08 +01:00
|
|
|
<log delineator> TEST '(<test name>)' <trailing delineator>
|
|
|
|
... log message ...
|
|
|
|
<log delineator>
|
2012-05-08 18:50:35 +02:00
|
|
|
|
2012-11-29 18:05:34 +01:00
|
|
|
where ``<test name>`` should be the name of a preceding reported test, ``<log
|
|
|
|
delineator>`` is a string of "*" characters *at least* four characters long
|
|
|
|
(the recommended length is 20), and ``<trailing delineator>`` is an arbitrary
|
|
|
|
(unparsed) string.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
|
|
|
The following is an example of a test run output which consists of four tests A,
|
2012-11-29 18:05:34 +01:00
|
|
|
B, C, and D, and a log message for the failing test C:
|
|
|
|
|
|
|
|
.. code-block:: none
|
2012-05-08 18:50:35 +02:00
|
|
|
|
|
|
|
PASS: A (1 of 4)
|
|
|
|
PASS: B (2 of 4)
|
|
|
|
FAIL: C (3 of 4)
|
2012-11-29 18:05:34 +01:00
|
|
|
******************** TEST 'C' FAILED ********************
|
2012-05-08 18:50:35 +02:00
|
|
|
Test 'C' failed as a result of exit code 1.
|
2012-11-29 18:05:34 +01:00
|
|
|
********************
|
2012-05-08 18:50:35 +02:00
|
|
|
PASS: D (4 of 4)
|
|
|
|
|
|
|
|
LIT EXAMPLE TESTS
|
|
|
|
~~~~~~~~~~~~~~~~~
|
|
|
|
|
2012-11-29 19:03:08 +01:00
|
|
|
The :program:`lit` distribution contains several example implementations of
|
|
|
|
test suites in the *ExampleTests* directory.
|
2012-05-08 18:50:35 +02:00
|
|
|
|
|
|
|
SEE ALSO
|
|
|
|
--------
|
|
|
|
|
|
|
|
valgrind(1)
|