Skip to content

Build tests prior to executing them - #4523

Closed
Brian Cody (epistax) wants to merge 5 commits into
microsoft:mainfrom
epistax:building-tests
Closed

Brian Cody (epistax) wants to merge 5 commits into
microsoft:mainfrom
epistax:building-tests

Conversation

@epistax

@epistax Brian Cody (epistax) commented Jul 22, 2025 •

Copy link
Copy Markdown
Contributor

This change addresses item #4515

This changes the build-before-test behavior

The following changes are proposed:

  • When build before test is enabled, the extension will review the list of selected tests, which projects they are in, and request a minimum build from CMake.
  • This is done by explicitly asking CMake to build the test executables.

The purpose of this change

  • When building before test, the current behavior is to pass no build target to CMake, resulting in the ALL target.
  • This will require that everything built by ALL works in order to run any test. The only alternative is for the user to disable build before testing entirely, which is also not ideal.
  • It's also possible that the particular target needed to built the test is excluded from all in which case the current build isn't sufficient to prepare the selected test(s) to run.

Other Notes/Information

I have never contributed to this project before and I ran into difficulties running the tests. I was not able to find any testss related to the change and I'd be willing to expand the test base with a little bit of instruction. I was not able to find a proper venue for getting started with the testing. There appears to be some required machine setup prior to running the tests. Thank you for any assistance!
This change opens up the possibility for very long command lines when invoking CMake. I am not aware if munging is taken care of automatically or if I need to introduce something myself.

@epistax

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree company="Markem-Imaje"

…ting

- BLOCKER: Replace path.relative() with executableTargets lookup to map
  test program paths to actual CMake target names. The previous approach
  produced file paths (e.g. 'tests/my_test') instead of target names
  (e.g. 'my_test'), causing cmake --build --target to fail.
- BLOCKER: Fix accmulatedTestList.concat() no-op by using push(...) so
  tests are properly marked as errored on build failure.
- MAJOR: Check return value of recursive getTestTargets() call so child
  failures propagate correctly to the caller.
- MINOR: Add guard for empty testProgram() return to prevent nonsensical
  build targets from empty strings.
- MINOR: Fix typo accmulatedTestList -> accumulatedTestList.
- MINOR: Remove extra whitespace in for statement and redundant
  .toString() call.
- NIT: Remove trailing semicolon after for...of block.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@hanniavalera

Copy link
Copy Markdown
Contributor

Superseded by #4881, which rebases this concept onto the current main branch. Thank you Brian Cody (@epistax) for the original contribution!

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

Labels

None yet

3 participants