I worte a reguation test and want to check if my code works, but it seems that I have to run
make check-clang, and it will run all the tests belongs to check-clang, which takes a lot of times.
Since the test case is a cpp file and build into a bin with other tests (correct if I’m wrong), I can’t use things like llvm-lit llvm-project/clang/test/Frontend/mytest.cpp
So anyway I can run “mytest” singlely?
Weird thing is that if I run ./bin/llvm-lit -v ./tools/clang/test/Sema/asm.c, it works
But if I run ./bin/llvm-lit -v ./tools/clang/test/Frontend/plugin-attribute.cpp it says
UNSUPPORTED: Clang :: Frontend/plugin-attribute.cpp (1 of 1)
There are several different kinds of tests within the project. You might want to read through https://llvm.org/docs/TestingGuide.html to get an overview.
Lit tests (at least for Clang) are generally C/C++ sources intended to be inputs to clang; various compiler outputs are verified, usually with the FileCheck tool. These test files are not built into a bin with all the other tests. You should be able to use llvm-lit.py to run either a single test file, or one subdirectory (e.g.,
llvm-lit clang/test/Sema will run all the tests in Sema).
Individual lit tests can express requirements on the environment, and if these are not satisfied, llvm-lit will report UNSUPPORTED. clang/test/Frontend/plugin-attribute.cpp is probably UNSUPPORTED because the test file contains the line
REQUIRES: plugins, examples and those dependencies are not satisfied on your system.
Unit tests are cpp sources that directly call Clang or LLVM APIs in some way, e.g., using libTooling. If that’s what you wrote, then you don’t want a lit test, you want to add your file to a unittest (or add a new unittest). I think you can build the unittest programs with
make clang-test-depends (that’s the correct target name for ninja, not sure about make).
Hope this helps,
Hey Paul, if a test is unsupported on my environment,
make check-clang will skip it, not reporting an failure, right?
Hey Paul, if a test is unsupported on my environment, `make check-clang` will skip it, not reporting an failure, right?
make check-clang will do that (not report a failure on an UNSUPPORTED
test), but lit run directly on a specific file will report more
details on that test (if you lit test the whole directory it won't
report the UNSUPPORTED tests)