How do you run individual tests?


(Michael Buckley) #1

Hi,

I have successfully run the swift test suites by passing the -T flag to
utils/build_script, and I am wondering if there is any way to run an
individual test by name, or even just run a single file.

Forgive me if the answer to this question is already documented somewhere.
I have read through all the documentation I could find in the git
repository, and checked out the lit documentation on llvm.org.

As a concrete example, let's say I added a test
to validation-test/stdlib/UnicodeTrie.swift.gyb, and I'm doing test-first
development, so I expect this test to fail until I implement the fix for
it. I now want to run just this test to ensure that it does indeed fail.

The lyt documentation seems to indicate that I can pass it a filename to
test, but when I point it to that file, it states that it can only test
files in a build directory, and I cannot find this file in the build
directory. Additionally, docs/Testing.rst mentions that tests can be run
using the check-swift* tools in the build directory, but I cannot find
these tools in the build directory.


(Mark Lacey) #2

docs/Testing.rst line 95 shows the way that I use lit to run individual tests or tests under a directory:

    % ${LLVM_SOURCE_ROOT}/utils/lit/lit.py -sv --param swift_site_config=${SWIFT_BUILD_ROOT}/test-iphonesimulator-i386/lit.site.cfg ${SWIFT_SOURCE_ROOT}/test/Parse/

For example, if you build with build-script -r you should be able to run test/SILPasses/mem2reg.sil with:

../llvm/utils/lit/lit.py -sv --param swift_site_config=../build/Ninja-RelWithDebInfoAssert/swift-macosx-x86_64/test-macosx-x86_64/lit.site.cfg test/SILPasses/mem2reg.sil

As you can imagine this is quite long so I have an alias set up to provide the initial arguments to lit.py (in particular pointing to the swift_site_config).

Mark

···

On Dec 5, 2015, at 4:56 PM, Michael Buckley via swift-dev <swift-dev@swift.org> wrote:

Hi,

I have successfully run the swift test suites by passing the -T flag to utils/build_script, and I am wondering if there is any way to run an individual test by name, or even just run a single file.

Forgive me if the answer to this question is already documented somewhere. I have read through all the documentation I could find in the git repository, and checked out the lit documentation on llvm.org <http://llvm.org/>.