Proposed Changes to CMake Test Registration

Hi all,

I wanted to let everyone know about some upcoming changes we are planning to make in CMake to test registration, specifically in relation to test asset directories.

In an effort to simplify the test registration process, and additionally give us a little more flexibility, we are planning to deprecate the pxr_install_test_dir method and instead specify the test dir via the TESTENV arg to pxr_register_test.

TESTENV was an existing arg, to pxr_register_test, however its behavior is changing a bit. With this new approach TESTENV should receive the value of the test assets directory the registered test requires. This is the equivalent SRC path that pxr_install_test_dir would take. There is no problem passing the same TESTENV path to multiple unique invocations of pxr_register_test.

This change is not 100% backward compatible, however. Existing calls to pxr_register_test which specify a TESTENV should ensure that this value refers to the actual source directory containing the SRC test assets as opposed to the DEST testdir, which would have been the likely case.

As an example, the registration code before this change:

pxr_install_test_dir(
    SRC testenv/testUsdGeomMyFeature
    DEST testUsdGeomMyFeature
)

pxr_register_test(testUsdGeomMyFeature
    PYTHON
    COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdGeomMyFeature"
    EXPECTED_RETURN_CODE 0
)

becomes a single call:

pxr_register_test(testUsdGeomMyFeature
    PYTHON
    COMMAND "${CMAKE_INSTALL_PREFIX}/tests/testUsdGeomMyFeature"
    TESTENV testenv/testUsdGeomMyFeature
    EXPECTED_RETURN_CODE 0
)

We hope that this change will make adding tests a bit easier for everyone. I am interested in any thoughts or concerns the community may have with this change.

Thanks!

Hi @mlarocca, just curious to learn more about the motivation for the change.

We were curious if you thought it might simplify running tests out of the build directory as @jedumas proposed here: Running USD from build directory without installing · Issue #1983 · PixarAnimationStudios/OpenUSD.

Hi @nvmkuruc,

The motivation for this change stems from a desire to have the testenv dir available from within pxr_register_test. We also feel that not having separate calls for installing the test dir and registration is cleaner, less error prone, and keeps all the relevant information for a test in one place.

Unfortunately, I do not believe this change moves us closer to being able to run tests from the build directory without installing first.

Happy to address any other thoughts or concerns you have on this one.