Skip to content

add DEF_SOURCE_LINE to ctests #1848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 18, 2025
Merged

Conversation

malsyned
Copy link
Contributor

@malsyned malsyned commented Apr 14, 2025

GoogleTest sets this property on ctest tests, and vscode-cmake-tools will use it to dramatically improve the Test Explorer user experience.

CppUTest doesn't record file paths or line numbers for test groups, only for tests, so when CPPUTEST_TESTS_DETAILED=0, use the lowest line number of the tests in that group.

GoogleTest sets this property on ctest tests, and vscode-cmake-tools
will use it to dramatically improve the Test Explorer user experience.

CppUTest doesn't record file paths or line numbers for test groups, only
for tests, so when CPPUTEST_TESTS_DETAILED=0, use the lowest line number
of the tests in that group.
@malsyned
Copy link
Contributor Author

Just saw there were some new commits on master after pushing this PR, so I rebased and force-pushed it. It should be good to go now.

@malsyned
Copy link
Contributor Author

malsyned commented Apr 14, 2025

A note for anyone trying to use this with Visual Studio Code: you'll have to install the pre-release version of CMake Tools for this to work for you, at least until they put out a release that contains vscode-cmake-tools:3ab4e0dc.

@thetic
Copy link
Contributor

thetic commented Apr 15, 2025

I left a bit of feedback, but directionaly I think this is good and I like the idea. @basvodde are you able to kick off the workflow?

This avoids creating an additional scope, meaning I can revert my
previous complicating changes to add_command().

addresses review comment from @thetic.
@malsyned
Copy link
Contributor Author

@thetic thanks for taking the time to review this. I think I've addressed all of the points you raised. I'm wrapping up for today. Let me know if there's anything else you want me to tweak about this PR, I'll get to it in the next day or so.

@thetic
Copy link
Contributor

thetic commented Apr 15, 2025

It all looks good to me. Thanks for the contribution. We'll have to wait for Bas to merge.

@coveralls
Copy link

Coverage Status

coverage: 99.279%. remained the same
when pulling 7395fe0 on malsyned:def-source-line
into 694d00d on cpputest:master.

@basvodde
Copy link
Member

Ok. I'll merge.

Looking at the CMake code. I wonder... is there a unit test framework for CMake also? It seems to include more and more logic...

@malsyned
Copy link
Contributor Author

Looking at the CMake code. I wonder... is there a unit test framework for CMake also? It seems to include more and more logic...

CMake has a little tool that they use internally, Tests/RunCMake/RunCMake.cmake, that sets up a bare bones framework for using CTest to test CMake modules. It looks like at least one project, Qt6, is using it by copying that file into their own tree, along with a lightly modified form of the macro add_RunCMake_test() from Tests/RunCMake/CMakeLists.txt. It's BSD-3-Clause, if you wanted you could just copy it into your source tree and use it to add tests of your CMake scripts to your existing CTest suite.

@basvodde basvodde merged commit a612328 into cpputest:master Apr 18, 2025
66 checks passed
@basvodde
Copy link
Member

Might be interesting to consider. Part of being a unit test framework is showing that you can write unit tests for certain things. So, it could be an example for others.

@malsyned malsyned deleted the def-source-line branch April 18, 2025 18:29
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.

4 participants