Skip to content

Use SOURCES keyword for source files in EkatCreateUnitTestExec#440

Merged
bartgol merged 1 commit into
masterfrom
bartgol/create-unit-test-api-change
May 5, 2026
Merged

Use SOURCES keyword for source files in EkatCreateUnitTestExec#440
bartgol merged 1 commit into
masterfrom
bartgol/create-unit-test-api-change

Conversation

@bartgol
Copy link
Copy Markdown
Contributor

@bartgol bartgol commented May 4, 2026

Motivation

The cmake function EkatCreateUnitTestExec uses a named argument for the source files list. However, I find this a bit error prone compared to the more modern cmake way (based on cmake_parse_arguments). In particular, it forces to use quotes to list all source files, and lists are one of the more tricky things in cmake: if you forget to quote, or use a var that expands to 2+ elements, the named argument would only bind to the 1st element, and the rest of the list will be parsed by cmake_parse_arguments. Moreover, keywords are much more self-documenting:

EkatCreateUnitTestExec (my_test
 "a.cpp;b.cpp;c.cpp"
)
EkatCreateUnitTestExec (my_test
  SOURCES a.cpp b.cpp c.cpp
)

To make sure this wasn't just my preference, I googled (and asked our bot friends), and it seems that keywords are in fact preferred over positional args, for readability and maintainability reasons. Let me know if you guys disagree.

E3SM Stakeholder Feedback

This will require to adapt the eamxx wrapper when we update ekat in e3sm.

@bartgol bartgol requested review from Copilot, jeff-cohere and jgfouca May 4, 2026 19:57
@bartgol bartgol self-assigned this May 4, 2026
@bartgol bartgol added cmake Related to cmake build system and/or cmake utilities code quality code usability labels May 4, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR modernizes EKAT’s CMake unit-test helpers by switching source-file
specification from a positional argument to an explicit SOURCES keyword, making
call sites less error-prone and more self-documenting.

Changes:

  • Update EkatCreateUnitTestExec / EkatCreateUnitTest to accept source files
    via the SOURCES multi-value keyword.
  • Migrate existing test CMakeLists.txt call sites to the new SOURCES form.
  • Minor refactor in tests/algorithm to create the tridiag_invalid_flags test
    directly from the selected precision executable.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
cmake/EkatCreateUnitTest.cmake Introduces SOURCES keyword parsing and updates unit test creation flow.
cmake/EkatCreateUnitTestWithAsserts.cmake Updates wrapper calls to pass sources via SOURCES.
tests/algorithm/CMakeLists.txt Migrates to SOURCES keyword; refactors invalid-flags test creation.
tests/core/CMakeLists.txt Migrates unit-test calls (and EkatCreateUnitTestExec) to SOURCES.
tests/expression/CMakeLists.txt Migrates unit-test call to SOURCES.
tests/kokkos/CMakeLists.txt Migrates unit-test calls to SOURCES.
tests/logging/CMakeLists.txt Migrates unit-test calls to SOURCES.
tests/pack/CMakeLists.txt Migrates unit-test calls to SOURCES.
tests/parser/CMakeLists.txt Migrates unit-test call to SOURCES.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmake/EkatCreateUnitTest.cmake
Comment thread cmake/EkatCreateUnitTest.cmake Outdated
Comment thread cmake/EkatCreateUnitTest.cmake
@bartgol bartgol force-pushed the bartgol/create-unit-test-api-change branch from 052646f to 69c58e8 Compare May 4, 2026 20:04
@bartgol bartgol requested a review from Copilot May 4, 2026 20:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmake/EkatCreateUnitTest.cmake
Comment thread cmake/EkatCreateUnitTest.cmake Outdated
@bartgol bartgol force-pushed the bartgol/create-unit-test-api-change branch from 69c58e8 to 3211799 Compare May 4, 2026 20:39
@bartgol bartgol merged commit 759e590 into master May 5, 2026
4 checks passed
@bartgol bartgol deleted the bartgol/create-unit-test-api-change branch May 5, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cmake Related to cmake build system and/or cmake utilities code quality code usability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants