GraphBLAS / LAGraph

This is a library plus a test harness for collecting algorithms that use the GraphBLAS. For test coverage reports, see https://graphblas.org/LAGraph/ . Documentation: https://lagraph.readthedocs.org
Other
229 stars 61 forks source link

How to run a single test #162

Closed szarnyasg closed 1 year ago

szarnyasg commented 1 year ago

I am developing a PageRank variant for Graphalytics and would like to run the tests in a single test file during the development.

I can make install and run the PageRank unit test with build/src/test/test_PageRank.

Is there a more elegant way to run a single test file from make (something like make test XX)?

szarnyasg commented 1 year ago

It seems using the binary in build/ is a good approach for running an individual test.

I also found using the CTEST_OUTPUT_ON_FAILURE useful to see the output upon test failure, e.g.:

CTEST_OUTPUT_ON_FAILURE=1 make test
jamesETsmith commented 1 year ago

I know you already have a working solution but I wanted to post an alternative in case it helps with related use cases. You can use ctest to "drive" the test suite and select subsets of the tests. For example, to run just test_PageRank you could do the following:

# Inside build directory
ctest -R test_PageRank$ # <== Notice the $ for the regex here

The real power of this comes when you want to run more than one of the tests at a time. If multiple tests are named in a related way (e.g. test_PageRank and test_PageRankGX), then you select both them at the same time:

# Inside build directory
ctest -R test_PageRank --parallel 2

You can string together multiple regular expressions here and there are exclude flags you can use as well. Here are the cmake docs, let me know if you have questions about them.

szarnyasg commented 1 year ago

This was exactly what I was looking for. Thanks very much, @jamesETsmith!