1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00
Commit Graph

237 Commits

Author SHA1 Message Date
Louis Dionne
33bad4fe83 [lit] Print substitutions with --show-suites
We already print available features, and it can be useful to print
substitutions as well since those are a pretty fundamental part of
a test suite. We could also consider printing other things like the
test environment, however the need doesn't appear to be as strong.

As a fly-by fix, we also always print available features, even when
there are none.

Before:

  $ lit -sv libcxx/test --show-suites
  -- Test Suites --
    libc++ - 6350 tests
      Source Root: [...]
      Exec Root  : [...]
      Available Features : -faligned-allocation -fsized-deallocation [...]

After:

  $ lit -sv libcxx/test --show-suites
  -- Test Suites --
    libc++ - 6350 tests
      Source Root: [...]
      Exec Root  : [...]
      Available Features: -faligned-allocation -fsized-deallocation [...]
      Available Substitutions: %{build_module} => [...]
                               %{build} => %{cxx} -o [...]

Differential Revision: https://reviews.llvm.org/D77818
2020-04-13 12:01:12 -04:00
Julian Lettner
55b035f2b5 [lit] Temporarily disable failing tests on Windows 2020-04-10 20:03:44 -07:00
Julian Lettner
db6e460f3e [lit] Fix tests on Windows
max-time.py:
  Windows does not have a native `sleep` command, use `time.sleep()` in
  Python instead.

max-failures.py:
  The max-failure test reused the shtest-shell test inputs instead of
  defining its own "test domain".  However, the output of this
  shtest-shell "test domain" is slightly different on Windows, which now
  bites us since we made the max-failures test stricter.  Let's define
  our own "max failures" test domain.
2020-04-10 17:33:49 -07:00
Julian Lettner
7f265ec20a [lit] Increase sleep time in timeout test
Fixup for cbe42a9d5fa.  Increase values for testing the overall lit
timeout (--max-time) which wasn't enough for the test to complete on
very slow build bots.
2020-04-10 16:22:00 -07:00
Julian Lettner
8de3a126b1 [lit] Add SKIPPED test result category
Track and print the number of skipped tests.  Skipped tests are tests
that should have been executed but weren't due to:
  * user interrupt [Ctrl+C]
  * --max-time (overall lit timeout)
  * --max-failures

This is part of a larger effort to ensure that all discovered tests are
properly accounted for.

Add test for overall lit timeout feature (`--max-time` option) to
observe skipped tests.  Extend test for `--max-failures` option.

Reviewed By: jdenny

Differential Revision: https://reviews.llvm.org/D77819
2020-04-10 15:13:30 -07:00
Julian Lettner
4fcbf321ca [lit] Improve test summary output
This change aligns the test summary output along the longest
category label.  We also properly align test counts.

Before:
```
Testing Time: 10.30s
  Unsupported Tests  : 1
  Expected Passes    : 30
```

After:
```
Testing Time: 10.29s
  Unsupported Tests:  1
  Expected Passes  : 30
```
2020-04-07 22:19:50 -07:00
Julian Lettner
da1f80b302 [lit] Improve consistency when printing test results 2020-04-07 18:12:18 -07:00
Julian Lettner
020aa53d01 [lit] Improve handling of parallelism group semaphores 2020-04-06 20:52:06 -07:00
Louis Dionne
9e1de34e9a [lit] Move the recursiveExpansionLimit setting to TestingConfig
The LitConfig is shared across the whole test suite. However, since
enabling recursive expansion can be a breaking change for some test
suites, it's important to confine the setting to test suites that
enable it explicitly.

Note that other issues were raised with the way recursiveExpansionLimit
operates. However, this commit simply moves the setting to the right
place -- the mechanism by which it works can be improved independently.

Differential Revision: https://reviews.llvm.org/D77415
2020-04-06 13:58:00 -04:00
Julian Lettner
d66362b987 [lit] Refine adoption of argparse --version action
The real work for this was already done by serge-sans-paille [1].
Thanks for this!

[1] 1d4849379f71a0f5d73202a291c0b709f7cafbc5
2020-03-31 16:02:16 -07:00
Julian Lettner
ce57305010 [lit] Fix test that relied on "single process" mode
The shtest-inject test relied on being executed in "single process" mode
and started to fail with a `PicklingError` after it was removed:
```
  Can't pickle <class 'lit.TestingConfig.CustomFormat'>: attribute
  lookup lit.TestingConfig.CustomFormat failed
```

This happened because the test config has to be serialized to the worker
process, but apparently the `CustomFormat` class defined inline is not
serializable.

This change allows passing the tested functionality (preamble_commands)
directly to `lit.formats.ShTest` so we can use it directly in the test.
2020-03-30 21:58:48 -07:00
Louis Dionne
eef1e9e29f [lit] Recursively expand substitutions
This allows defining substitutions in terms of other substitutions. For
example, a %build substitution could be defined in terms of a %cxx
substitution as '%cxx %s -o %t.exe' and the script would be properly
expanded.

Differential Revision: https://reviews.llvm.org/D76178
2020-03-27 09:25:26 -04:00
Louis Dionne
e8ebe9cd4f [lit] Allow passing extra commands to executeShTest
This allows creating custom test formats on top of `executeShTest` that
inject commands at the beginning of the file being parsed, without
requiring these commands to physically appear in the test file itself.

For example, one could define a test format that prints out additional
debug information at the beginning of each test. More realistically,
this has been used to define custom test formats like one that supports
compilation failure tests (e.g. with the extension `compile.fail.cpp`)
by injecting a command that calls the compiler on the file itself and
expects it to fail.

Without this change, the only alternative is to create a temporary file
with the same content as the original test, then prepend the desired
`// RUN:` lines to that file, and call `executeShTest` on that file
instead. This is both slow and cumbersome to do.

Differential Revision: https://reviews.llvm.org/D76290
2020-03-24 15:02:37 -04:00
Louis Dionne
c0d7629008 [lit] Add builtin support for flaky tests in lit
This commit adds a new keyword in lit called ALLOW_RETRIES. This keyword
takes a single integer as an argument, and it allows the test to fail that
number of times before it first succeeds.

This work attempts to make the existing test_retry_attempts more flexible
by allowing by-test customization, as well as eliminate libc++'s FLAKY_TEST
custom logic.

Differential Revision: https://reviews.llvm.org/D76288
2020-03-18 18:04:01 -04:00
Louis Dionne
3a511e1f32 [lit] NFC: Fix typo in log statement 2020-03-17 16:49:56 -04:00
serge-sans-paille
dc28731793 Fix lit version test
Looks like on some system, version is printed on stderr, on some it's on stdout...
2020-02-13 21:49:48 +01:00
serge-sans-paille
2f80dd8494 Fix handling of --version in lit
There's no reason why we should require a directory when asking for the version.

Differential Revision: https://reviews.llvm.org/D74553
2020-02-13 21:36:12 +01:00
Nemanja Ivanovic
0632710cc6 Fix buildbot failures after removing REQUIRES-ANY
It would appear that the removal of this lit feature was incomplete
and there is a test case that still tests for this. This patch removes
the remaining tests to bring the bots back to green. I would encourage the
author to do a post-commit review on this in case there is a more desirable fix.
2019-12-17 15:27:45 -06:00
Joel E. Denny
f8d4bf3133 [lit] Fix internal diff newlines for -w/-b
For example, without this patch:

```
$ python $LIT_BUILTINS/diff.py -b foo.txt bar.txt
*** /tmp/foo.txt
--- /tmp/bar.txt
***************
*** 1,2 ****
  1! 2--- 1,2 ----
  1! 20
```

With this patch:

```
$ python $LIT_BUILTINS/diff.py -b foo.txt bar.txt
*** /tmp/foo.txt
--- /tmp/bar.txt
***************
*** 1,2 ****
  1
! 2
--- 1,2 ----
  1
! 20
```

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D71577
2019-12-17 10:49:34 -05:00
Thomas Preud'homme
3ee7afa35c [lit] Remove lit's REQUIRES-ANY directive
Summary:
Remove REQUIRES-ANY alias lit directive since it is hardly used and can
be easily implemented using an OR expression using REQUIRES. Fixup
remaining testcases still using REQUIRES-ANY.

Reviewers: probinson, jdenny, gparker42

Reviewed By: gparker42

Subscribers: eugenis, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, delcypher, jrtc27, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, lenary, s.egerton, pzheng, sameer.abuasal, apazos, luismarques, cfe-commits, #sanitizers, llvm-commits

Tags: #llvm, #clang, #sanitizers

Differential Revision: https://reviews.llvm.org/D71408
2019-12-17 10:36:36 +00:00
Julian Lettner
1be986ee4e [lit] Small cleanups. NFCI
Remove unnecessary (argument same as default), cleanup imports, use
"pythonic" names for variables, and general formatting.
2019-12-13 17:00:04 -08:00
Julian Lettner
88ba9a7d64 [lit] Improve formatting of error messages. NFC 2019-12-11 14:39:39 -08:00
Paul Robinson
d53523508c Fix up lit's tests to run in a multi-config build environment.
Differential Revision: https://reviews.llvm.org/D70239
2019-11-14 11:24:41 -08:00
Julian Lettner
95339f1d20 [lit] Better/earlier errors for empty runs
Fail early, when we discover no tests at all, or filter out all of them.

There is also `--allow-empty-runs` to disable test to allow workflows
like `LIT_FILTER=abc ninja check-all`.  Apparently `check-all` invokes
lit multiple times if certain projects are enabled, which would produce
unwanted "empty runs". Specify via `LIT_OPTS=--allow-empty-runs`.

There are 3 causes for empty runs:
1) No tests discovered.  This is always an error.  Fix test suite config
   or command line.
2) All tests filtered out.  This is an error by default, but can be
   suppressed via `--alow-empty-runs`.  Should prevent accidentally
   passing empty runs, but allow the workflow above.
3) The number of shards is greater than the number of tests.  Currently,
   this is never an error.  Personally, I think we should consider
   making this an error by default; if this happens, you are doing
   something wrong. I added a warning but did not change the behavior,
   since this warrants more discussion.

Reviewed By: atrick, jdenny

Differential Revision: https://reviews.llvm.org/D70105
2019-11-12 09:11:36 -08:00
Joel E. Denny
7fc52c9da6 [lit] Protect full test suite from FILECHECK_OPTS
lit's test suite calls lit multiple times for various sample test
suites.  `FILECHECK_OPTS` is safe for FileCheck calls in lit's test
suite.  It's not safe for FileCheck calls in the sample test suites,
whose output affects the results of lit's test suite.

Without this patch, only one such sample test suite is protected from
`FILECHECK_OPTS`, and currently `shtest-shell.py` breaks with
`FILECHECK_OPTS=-vv`.  Moreover, it's hard to predict the future,
especially false passes.  Thus, this patch protects all existing and
future sample test suites from `FILECHECK_OPTS` (and the deprecated
`FILECHECK_DUMP_INPUT_ON_FAILURE`).

Reviewed By: probinson

Differential Revision: https://reviews.llvm.org/D65156
2019-11-06 16:25:25 -05:00
Julian Lettner
0752aef3ee Revert "[lit] Better/earlier errors when no tests are executed"
This reverts commit d8f2bff75126c6dde694ad245f9807fa12ad5630.
2019-11-05 12:10:43 -08:00
Joel E. Denny
729f23e751 [lit] Fix not calling internal commands
Without this patch, when using lit's internal shell, if `not` on a lit
RUN line calls `env`, `diff`, or any of the other in-process shell
builtins that lit implements, lit accidentally searches for the latter
as an external executable.  What's worse is that works fine when a
developer is testing on a platform where those executables are
available and behave as expected, but it then breaks on other
platforms.

`not` seems useful for some builtins, such as `diff`, so this patch
supports such uses.  `not --crash` does not seem useful for builtins,
so this patch diagnoses such uses.  In all cases, this patch ensures
shell builtins are found behind any sequence of `env` and `not`
commands.

`not` calling `env` calling an external command appears useful when
the `env` and external command are part of a lit substitution, as in
D65156.  This patch supports that by looking through any sequence of
`env` and `not` commands, building the environment from the `env`s,
and storing the `not`s.  The `not`s are then added back to the command
line without the `env`s to execute externally.  This avoids the need
to replicate the `not` implementation, in particular the `--crash`
option, in lit.

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D66531
2019-11-05 14:09:21 -05:00
Julian Lettner
726e2ac362 [lit] Better/earlier errors when no tests are executed
Fail early, when we discover no tests at all, or filter out all of them.
2019-11-04 10:16:24 -08:00
Joel E. Denny
723914170d [lit] Fix internal env calling env
Without this patch, when using lit's internal shell, if `env` on a lit
RUN line calls `env`, lit accidentally searches for the latter as an
external executable.  What's worse is that works fine when a developer
is testing on a platform where `env` is available and behaves as
expected, but it then breaks on other platforms.

`env` calling `env` can make sense if one such `env` is within a lit
substitution, as in D65156 and D65121.  This patch ensures that lit
executes both as internal commands.

Reviewed By: probinson, mgorny, rnk

Differential Revision: https://reviews.llvm.org/D65697
2019-11-01 14:08:52 -04:00
Joel E. Denny
02f7cc6f6f [lit] Fix internal env calling other internal commands
Without this patch, when using lit's internal shell, if `env` on a lit
RUN line calls `cd`, `mkdir`, or any of the other in-process shell
builtins that lit implements, lit accidentally searches for the latter
as an external executable.

This patch puts such builtins in a map so that boilerplate for them
need be implemented only once.  This patch moves that handling after
processing of `env` so that `env` calling such a builtin can be
detected.  Finally, because such calls appear to be useless, this
patch takes the safe approach of diagnosing them rather than
supporting them.

Reviewed By: probinson, mgorny, rnk

Differential Revision: https://reviews.llvm.org/D66506
2019-10-31 14:37:51 -04:00
Joel E. Denny
84b5bf580c [lit] Extend internal diff to support - argument
When using lit's internal shell, RUN lines like the following
accidentally execute an external `diff` instead of lit's internal
`diff`:

```
 # RUN: program | diff file -
```

Such cases exist now, in `clang/test/Analysis` for example.  We are
preparing patches to ensure lit's internal `diff` is called in such
cases, which will then fail because lit's internal `diff` doesn't
recognize `-` as a command-line option.  This patch adds support for
`-` to mean stdin.

Reviewed By: probinson, rnk

Differential Revision: https://reviews.llvm.org/D67643
2019-10-29 15:13:53 -04:00
Joel E. Denny
7728e897bd [lit] Make internal diff work in pipelines
When using lit's internal shell, RUN lines like the following
accidentally execute an external `diff` instead of lit's internal
`diff`:

```
 # RUN: program | diff file -
 # RUN: not diff file1 file2 | FileCheck %s
```

Such cases exist now, in `clang/test/Analysis` for example.  We are
preparing patches to ensure lit's internal `diff` is called in such
cases, which will then fail because lit's internal `diff` cannot
currently be used in pipelines and doesn't recognize `-` as a
command-line option.

To enable pipelines, this patch moves lit's `diff` implementation into
an out-of-process script, similar to lit's `cat` implementation.  A
follow-up patch will implement `-` to mean stdin.

Also, when lit's `diff` prints differences to stdout in Windows, this
patch ensures it always terminate lines with `\n` not `\r\n`.  That
way, strict FileCheck directives checking the `diff` output succeed in
both Linux and Windows.  This wasn't an issue when `diff` was internal
to lit because `diff` didn't then write to the true stdout, which is
where the `\n` -> `\r\n` conversion happened in Python.

Reviewed By: probinson, stella.stamenova

Differential Revision: https://reviews.llvm.org/D66574
2019-10-29 15:13:52 -04:00
Alex Lorenz
b8517ab3f5 [lit] Drop the user-site packages directory from search paths when running tests
Do not add user-site packages directory to the python search path.
This avoids test failures if there's an incompatible lit module installed
inside the user-site packages directory, as it gets prioritized over the lit
from the PYTHONPATH.
2019-10-27 13:31:02 -07:00
Joel E. Denny
728fa0079b [lit] Don't fail when printing test output with special chars
This addresses a UnicodeEncodeError when using Python 3.6.5 in Windows
10.

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D69207
2019-10-25 18:13:13 -04:00
Joel E. Denny
edf9d7d6c1 Revert r375114: "[lit] Make internal diff work in pipelines"
This series of patches still breaks a Windows bot.

llvm-svn: 375121
2019-10-17 14:43:42 +00:00
Joel E. Denny
b9976a677b Revert r375116: "[lit] Extend internal diff to support - argument"
This series of patches still breaks a Windows bot.

llvm-svn: 375120
2019-10-17 14:43:26 +00:00
Joel E. Denny
aec550af4d [lit] Extend internal diff to support - argument
When using lit's internal shell, RUN lines like the following
accidentally execute an external `diff` instead of lit's internal
`diff`:

```
 # RUN: program | diff file -
```

Such cases exist now, in `clang/test/Analysis` for example.  We are
preparing patches to ensure lit's internal `diff` is called in such
cases, which will then fail because lit's internal `diff` doesn't
recognize `-` as a command-line option.  This patch adds support for
`-` to mean stdin.

Reviewed By: probinson, rnk

Differential Revision: https://reviews.llvm.org/D67643

llvm-svn: 375116
2019-10-17 14:03:06 +00:00
Joel E. Denny
bf6da93c86 [lit] Make internal diff work in pipelines
When using lit's internal shell, RUN lines like the following
accidentally execute an external `diff` instead of lit's internal
`diff`:

```
 # RUN: program | diff file -
 # RUN: not diff file1 file2 | FileCheck %s
```

Such cases exist now, in `clang/test/Analysis` for example.  We are
preparing patches to ensure lit's internal `diff` is called in such
cases, which will then fail because lit's internal `diff` cannot
currently be used in pipelines and doesn't recognize `-` as a
command-line option.

To enable pipelines, this patch moves lit's `diff` implementation into
an out-of-process script, similar to lit's `cat` implementation.  A
follow-up patch will implement `-` to mean stdin.

Reviewed By: probinson, stella.stamenova

Differential Revision: https://reviews.llvm.org/D66574

llvm-svn: 375114
2019-10-17 14:02:42 +00:00
Julian Lettner
ccc80cdad1 [lit] Remove unnecessary usage of lit.Run
llvm-svn: 375056
2019-10-16 23:31:32 +00:00
Joel E. Denny
e4446c81f4 [lit] Fix internal diff's --strip-trailing-cr and use it
Using GNU diff, `--strip-trailing-cr` removes a `\r` appearing before
a `\n` at the end of a line.  Without this patch, lit's internal diff
only removes `\r` if it appears as the last character.  That seems
useless.  This patch fixes that.

This patch also adds `--strip-trailing-cr` to some tests that fail on
Windows bots when D68664 is applied.  Based on what I see in the bot
logs, I think the following is happening.  In each test there, lit
diff is comparing a file with `\r\n` line endings to a file with `\n`
line endings.  Without D68664, lit diff reads those files in text
mode, which in Windows causes `\r\n` to be replaced with `\n`.
However, with D68664, lit diff reads the files in binary mode instead
and thus reports that every line is different, just as GNU diff does
(at least under Ubuntu).  Adding `--strip-trailing-cr` to those tests
restores the previous behavior while permitting the behavior of lit
diff to be more like GNU diff.

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D68839

llvm-svn: 375020
2019-10-16 17:21:57 +00:00
Joel E. Denny
a871d949f1 [lit] Clean up internal diff's encoding handling
As suggested by rnk at D67643#1673043, instead of reading files
multiple times until an appropriate encoding is found, read them once
as binary, and then try to decode what was read.

For Python >= 3.5, don't fail when attempting to decode the
`diff_bytes` output in order to print it.

Avoid failures for Python 2.7 used on some Windows bots by
transforming diff output with `lit.util.to_string` before writing it
to stdout.

Finally, add some tests for encoding handling.

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D68664

llvm-svn: 375018
2019-10-16 17:21:24 +00:00
Julian Lettner
b4d63156ac [lit] Add back LitTestCase
This essentially reverts a commit [1] that removed the adaptor for
Python unittests.  The code has been slightly refactored to make it more
additive: all code is contained in LitTestCase.py.

Usage sites will require a small adaption:
```
[old]
  import lit.discovery
  ...
  test_suite = lit.discovery.load_test_suite(...)

[new]
  import lit.LitTestCase
  ...
  test_suite = lit.LitTestCase.load_test_suite(...)
```

This was put back on request by Daniel Dunbar, since I wrongly assumed
that the functionality is unused.  At least llbuild still uses this [2].

[1] 70ca752ccf6a8f362aea25ccd3ee2bbceca93b20
[2] https://github.com/apple/swift-llbuild/blob/master/utils/Xcode/LitXCTestAdaptor/LitTests.py#L16

Reviewed By: ddunbar

Differential Revision: https://reviews.llvm.org/D69002

llvm-svn: 374947
2019-10-15 20:57:20 +00:00
Joel E. Denny
73def82c34 [lit] Extend internal diff to support -U
When using lit's internal shell, RUN lines like the following
accidentally execute an external `diff` instead of lit's internal
`diff`:

```
 # RUN: program | diff -U1 file -
```

Such cases exist now, in `clang/test/Analysis` for example.  We are
preparing patches to ensure lit's internal `diff` is called in such
cases, which will then fail because lit's internal `diff` doesn't
recognize `-U` as a command-line option.  This patch adds `-U`
support.

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D68668

llvm-svn: 374814
2019-10-14 19:59:30 +00:00
Joel E. Denny
c87e87c588 Revert r374648: "Reland r374388: [lit] Make internal diff work in pipelines"
This series of patches still breaks a Windows bot.

llvm-svn: 374683
2019-10-12 18:52:46 +00:00
Joel E. Denny
07d111f9d2 Revert r374649: "Reland r374389: [lit] Clean up internal diff's encoding handling"
This series of patches still breaks a Windows bot.

llvm-svn: 374682
2019-10-12 18:52:31 +00:00
Joel E. Denny
66af91a761 Revert r374650: "Reland r374390: [lit] Extend internal diff to support - argument"
This series of patches still breaks a Windows bot.

llvm-svn: 374681
2019-10-12 18:52:18 +00:00
Joel E. Denny
7f02190bce Revert 374651: "Reland r374392: [lit] Extend internal diff to support -U"
This series of patches still breaks a Windows bot.

llvm-svn: 374680
2019-10-12 18:52:05 +00:00
Joel E. Denny
b9620c3aff Revert r374652: "[lit] Fix internal diff's --strip-trailing-cr and use it"
This series of patches still breaks a Windows bot.

llvm-svn: 374679
2019-10-12 18:51:51 +00:00
Joel E. Denny
f811e9ea03 Revert r374653: "[lit] Fix a few oversights in r374651 that broke some bots"
This series of patches still breaks a Windows bot.

llvm-svn: 374678
2019-10-12 18:51:34 +00:00
Joel E. Denny
005ff49b43 Revert r374657: "[lit] Try again to fix new tests that fail on Windows bots"
llvm-svn: 374664
2019-10-12 16:00:25 +00:00