Skip to content

CMake: decouple unit/integration test selection#550

Open
ouankou wants to merge 1 commit intoCambridge-ICCS:mainfrom
ouankou:cmake-isolate-pfunit
Open

CMake: decouple unit/integration test selection#550
ouankou wants to merge 1 commit intoCambridge-ICCS:mainfrom
ouankou:cmake-isolate-pfunit

Conversation

@ouankou
Copy link
Copy Markdown

@ouankou ouankou commented Feb 20, 2026

Summary

To run integration tests without forcing pFUnit, this PR adds two test-selection options and keeps backward compatibility with existing CMAKE_BUILD_TESTS workflows.

  • Add BUILD_UNIT_TESTS to control pFUnit unit tests.
  • Add BUILD_INTEGRATION_TESTS to control integration tests from examples/.

Behavior

  • Default (no test flags): tests remain OFF (unchanged).
  • -DCMAKE_BUILD_TESTS=ON: both test families default to ON (unchanged behavior).
  • -DCMAKE_BUILD_TESTS=ON -DBUILD_UNIT_TESTS=OFF or -DBUILD_INTEGRATION_TESTS=ON: integration tests only.
  • -DCMAKE_BUILD_TESTS=ON -DBUILD_INTEGRATION_TESTS=OFF or -DBUILD_UNIT_TESTS=ON: unit tests only.
  • -DCMAKE_BUILD_TESTS=ON -DBUILD_UNIT_TESTS=OFF -DBUILD_INTEGRATION_TESTS=OFF: configuration fails with clear error.

Copy link
Copy Markdown
Member

@jatkinson1000 jatkinson1000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ouankou

Thanks for this contribution and we feel it will be a useful feature.

I have a couple of requests/suggestions for you before we merge this.

  • Please add FTORCH to the option names. This is so that when used as part of a larger build they are clear and do not conflict with other packages that might use the same commands.
  • Could the logic be simplified whilst preserving behaviour, e.g. to:
    # Test selection
    if(CMAKE_BUILD_TESTS)
      set(_ftorch_tests_default ON)
    else()
      set(_ftorch_tests_default OFF)
    endif()
    
    option(BUILD_UNIT_TESTS "Build pFUnit-based unit tests" ${_ftorch_tests_default})
    option(BUILD_INTEGRATION_TESTS "Build integration tests from examples/" ${_ftorch_tests_default})
    
    # Enable tests if any test option is ON
    if(BUILD_UNIT_TESTS OR BUILD_INTEGRATION_TESTS)
      set(CMAKE_BUILD_TESTS ON)
    elseif(CMAKE_BUILD_TESTS)
      message(FATAL_ERROR
        "CMAKE_BUILD_TESTS=ON requires at least one of BUILD_UNIT_TESTS or BUILD_INTEGRATION_TESTS to be ON.")
    endif()
    ?
  • We will also need some updates to the documentation around this. There is the main README.md, but then within pages/ there are installation/general.md and developer/testing.md that will need something adding.

Comment thread CMakeLists.txt

if(CMAKE_BUILD_TESTS AND NOT BUILD_UNIT_TESTS AND NOT BUILD_INTEGRATION_TESTS)
message(FATAL_ERROR
"CMAKE_BUILD_TESTS=ON requires at least one of BUILD_UNIT_TESTS or BUILD_INTEGRATION_TESTS to be ON.")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line fails CMake linting for being too long.

@jatkinson1000
Copy link
Copy Markdown
Member

jatkinson1000 commented Mar 25, 2026

Hi @ouankou are you interested in making the above changes so that we can move towards merging this?

@ouankou
Copy link
Copy Markdown
Author

ouankou commented Mar 31, 2026

Hi @ouankou are you interested in making the above changes so that we can move towards merging this?

Sure, I'll address the proposed changes accordingly. Thanks for the review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants