llvm.org GIT mirror llvm / 31d19a7
[lit] Parse command-line options from LIT_OPTS Similar to `FILECHECK_OPTS` for FileCheck, `LIT_OPTS` makes it easy to adjust lit behavior when running the test suite via ninja. For example: ``` $ LIT_OPTS='--time-tests -vv --filter=threadprivate' \ ninja check-clang-openmp ``` Reviewed By: probinson Differential Revision: https://reviews.llvm.org/D64135 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365313 91177308-0d34-0410-b5e6-96231b3b80d8 Joel E. Denny a month ago
5 changed file(s) with 49 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
3636 Finally, :program:`lit` also supports additional options for only running a
3737 subset of the options specified on the command line, see
3838 :ref:`selection-options` for more information.
39
40 :program:`lit` parses options from the environment variable ``LIT_OPTS`` after
41 parsing options from the command line. ``LIT_OPTS`` is primarily useful for
42 supplementing or overriding the command-line options supplied to :program:`lit`
43 by ``check`` targets defined by a project's build system.
3944
4045 Users interested in the :program:`lit` architecture or designing a
4146 :program:`lit` testing implementation should see :ref:`lit-infrastructure`.
1010 import platform
1111 import random
1212 import re
13 import shlex
1314 import sys
1415 import time
1516 import argparse
321322 help="Show all discovered tests",
322323 action="store_true", default=False)
323324
324 opts = parser.parse_args()
325 opts = parser.parse_args(sys.argv[1:] +
326 shlex.split(os.environ.get("LIT_OPTS", "")))
325327 args = opts.test_paths
326328
327329 if opts.show_version:
0 import lit.formats
1 config.name = 'lit-opts'
2 config.suffixes = ['.txt']
3 config.test_format = lit.formats.ShTest()
4 config.test_source_root = None
5 config.test_exec_root = None
6 config.substitutions.append(('%var', lit_config.params.get('var', '')))
0 # Check cases where LIT_OPTS has no effect.
1 #
2 # RUN: %{lit} -j 1 -s %{inputs}/lit-opts | FileCheck %s
3 # RUN: env LIT_OPTS= %{lit} -j 1 -s %{inputs}/lit-opts | FileCheck %s
4 # RUN: env LIT_OPTS=-s %{lit} -j 1 -s %{inputs}/lit-opts | FileCheck %s
5
6 # Check that LIT_OPTS can override command-line options.
7 #
8 # RUN: env LIT_OPTS=-a \
9 # RUN: %{lit} -j 1 -s %{inputs}/lit-opts \
10 # RUN: | FileCheck -check-prefix=SHOW-ALL -DVAR= %s
11
12 # Check that LIT_OPTS understands multiple options with arbitrary spacing.
13 #
14 # RUN: env LIT_OPTS='-a -v -Dvar=foobar' \
15 # RUN: %{lit} -j 1 -s %{inputs}/lit-opts \
16 # RUN: | FileCheck -check-prefix=SHOW-ALL -DVAR=foobar %s
17
18 # Check that LIT_OPTS parses shell-like quotes and escapes.
19 #
20 # RUN: env LIT_OPTS='-a -v -Dvar="foo bar"\ baz' \
21 # RUN: %{lit} -j 1 -s %{inputs}/lit-opts \
22 # RUN: | FileCheck -check-prefix=SHOW-ALL -DVAR="foo bar baz" %s
23
24 # CHECK: Testing: 1 tests
25 # CHECK-NOT: PASS
26 # CHECK: Expected Passes : 1
27
28 # SHOW-ALL: Testing: 1 tests
29 # SHOW-ALL: PASS: lit-opts :: test.txt (1 of 1)
30 # SHOW-ALL: {{^}}[[VAR]]
31 # SHOW-ALL-NOT: PASS
32 # SHOW-ALL: Expected Passes : 1