Introduce lit/FileCheck tests#3367
Conversation
|
@sbc100 why a new check.py option was necessary in #3359, but I will answer here to keep the respective discussions more focused. Most users will never have to use this option, even if they do out-of-tree builds, since it is only necessary when |
|
Personally this sounds fine to me. I'm not worried about having multiple test frameworks, as long as they are all very simple and they all are useful in their own right. (I'd feel very differently about non-test code!) My main concern about lit is how easy will it be to update test expectations - can we get My small concern about lit is that while it's nice to see the input and output in the same file, the output is in a comment. That's less readable and also it's not directly runnable. For example, right now you can run an input wast through a tool, then run the output wast through the same, and compare results. With lit you'd need to construct the output wast somehow from those comments..? If we don't have a great solution for that, I'd still be fine with using lit for some tests where running the output is not that important - but it would make me skeptical of the benefit of porting existing tests to lit (but leaving them as is sounds fine to me anyhow as I said earlier). |
Yes, the auto update scripts would be more complex for lit tests. But LLVM has such scripts, so at the very least we could use those as a starting point.
It should be trivial to construct the output by running the commands in the I still think that porting existing tests to lit will be a huge win once we have auto update scripts for lit tests, but if you're ok with adding lit as a new test runner, we can use it for wasm-split for now and defer the decision on whether to automatically port other tests until we have a more concrete idea of how good the results would be. |
Can we simplify things my mandating that tests can only run against a build directory and never against an install directory? |
I think we if we make this transition we can/should do it incrementally. If there are certainly test suites for which it makes sense to stick with the "expected output is this entire" file approach I think that is perfectly reasonable. I think its fine for there to exist two catagories of tests:
Trying to make all tests fit into (1) doesn't make sense to me (at least not yet). But I can't see that for many tests it is clearly a better option. I am not particularly excited about having arbitrarily complex scripts that try to make the auto-update system work with (1). I might make sense for certain tests and not others.
I think we should do this incrementally, that way we can be exposed different pain points of the two systems side by side side. My feeling is that biggest issue with the current system is the lack of ability to run individual tests, or even know how to re-run a given test when something fails.. or even tell from the output which test exactly failed.. mostly because tests do not have unique names or IDs. While lit + FileCheck conversion could solve that issue, it could also be solved in other ways. For example, Wouter's |
|
@aheejin, a brief investigation in #3375 shows that the clang package we are already bringing in for the |
BTW we should probably use |
|
@sbc100 sounds good, but let's put that in a separate PR that also adds flake8 to that file. |
|
Unless you are in a hurry I suggest we move flake8 to that file first.. thus avoiding the need to change the CI script at all for this change. |
|
Oh, does github actions know about that file or something? |
|
No we just do |
This file makes it simple for users and CI bots to install all the Python dev dependencies necessary to run the test suite. Right now it only contains flake8, but soon it will contain lit and filecheck as well (see WebAssembly#3367).
This file makes it simple for users and CI bots to install all the Python dev dependencies necessary to run the test suite. Right now it only contains flake8, but soon it will contain lit and filecheck as well (see #3367).
lit and FileCheck are the tools used to run the majority of tests in LLVM. Each lit test file contains the commands to be run for that test, so lit tests are much more flexible and can be more precise than our current ad hoc testing system. FileCheck reads expected test output from comments, so it allows test output to be written alongside and interspersed with test input, making tests much more readable than in our current system. This PR adds a new suite to check.py that runs lit tests in the test/lit directory. The only such test so far contains a few test cases ported from the optimize-instructions_all-features test, meant to demonstrate what our tests would look like if they were ported to lit and FileCheck. To avoid adding yet another testing framework (https://xkcd.com/927/), I would like to try to port our existing tests to use lit and FileCheck. This should be done at least partially automatically by scripts that will remain useful in the future for updating test expectations.
816312e to
1312ec2
Compare
sbc100
left a comment
There was a problem hiding this comment.
This is looking very nice indeed!
| *.o | ||
| *.obj | ||
| compile_commands.json | ||
| **/Output |
There was a problem hiding this comment.
Just /Output should be enough, no?
There was a problem hiding this comment.
No, lit actually sprinkles Output directories all over the place. After running the tests in this PR locally with an in-tree build I have
./test/Output
./test/validation/Output
./test/wasm-emscripten-finalize/Output
There was a problem hiding this comment.
Cluttering test directory does not sound very ideal.. Can we put all of them under out/ or somewhere? There seems to be an option called test_exec_root in llvm-lit with which we can control the output directory. Can we use it?
There was a problem hiding this comment.
These files get written to the build directory, so it only clutters your source tree if your do "in-tree" building.. which I think most of us dont.
If you do do "in-tree" building your source tree is already full of clutter.
There was a problem hiding this comment.
If we banned in-tree building we could remove all these things from gitignore.. which I would personally be an favor of. I personally like it when git status tells me about stray .o files in my checkout, but these rules prevent that.
| *.obj | ||
| compile_commands.json | ||
| **/Output | ||
| **/lit.site.cfg.py |
There was a problem hiding this comment.
Are these files created during the build? Where are they created exactly?
There was a problem hiding this comment.
This file is generated at build configuration time by CMake. For a normal in-tree build, this is created at ./test/lit/lit.site.cfg.py, but it's relative to the CMake build directory rather than the source directory.
There was a problem hiding this comment.
Got it. In that case it should just be /test/lit/lit.site.cfg.py since it has a fixed location.
| E241, # space after comma (ignored for list in gen-s-parser.py) | ||
| W504 # line break after binary operator | ||
| exclude = ./test/emscripten,./test/spec,./test/wasm-install | ||
| exclude = ./test/emscripten,./test/spec,./test/wasm-install,./test/lit |
There was a problem hiding this comment.
flake8 complains about config being used before it is defined in the lit config and similar non-problems.
There was a problem hiding this comment.
How about test/lib/*config.py or something like that then? Or will this directory be otherwise free of python code so it doesn't matter?
There was a problem hiding this comment.
Yes, this directory will otherwise be free of Python code.
| @@ -0,0 +1,20 @@ | |||
| # Copyright 2020 WebAssembly Community Group participants | |||
aheejin
left a comment
There was a problem hiding this comment.
It looks very nice! As I said, I'm not sure whether migrating all existing tests is feasible or better; there are cases we change some parts of existing passes that affect many existing tests and running ./auto_update_tests.py can often show what its effects would be like on many parts on them, which I found rather convenient. But having this as an alternative testing framework looks fine.
| *.o | ||
| *.obj | ||
| compile_commands.json | ||
| **/Output |
There was a problem hiding this comment.
Cluttering test directory does not sound very ideal.. Can we put all of them under out/ or somewhere? There seems to be an option called test_exec_root in llvm-lit with which we can control the output directory. Can we use it?
|
|
||
| flake8==3.7.8 | ||
| filecheck==0.0.17 | ||
| lit==0.11.0.post1 |
There was a problem hiding this comment.
I'm not familiar with Python ports of filecheck and lit... So lit needs a wrapper script but filecheck can run as is like a normal executable?
kripken
left a comment
There was a problem hiding this comment.
No update to ./auto_update_test.py for lit tests? 😜
Not for these hand-written ones :P |
|
@aheejin, nice find with the |
lit and FileCheck are the tools used to run the majority of tests in LLVM. Each
lit test file contains the commands to be run for that test, so lit tests are
much more flexible and can be more precise than our current ad hoc testing
system. FileCheck reads expected test output from comments, so it allows test
output to be written alongside and interspersed with test input, making tests
more readable and precise than in our current system.
This PR adds a new suite to check.py that runs lit tests in the test/lit
directory. A few tests have been ported to demonstrate the features of the new
test runner.
This change is motivated by a need for greater flexibility in testing wasm-split.
See #3359.