Skip to content

Wrap macro test driver code inside ptf::TestRunner#2088

Open
Dimi1010 wants to merge 5 commits into
seladb:devfrom
Dimi1010:refactor/test-runner
Open

Wrap macro test driver code inside ptf::TestRunner#2088
Dimi1010 wants to merge 5 commits into
seladb:devfrom
Dimi1010:refactor/test-runner

Conversation

@Dimi1010

@Dimi1010 Dimi1010 commented Mar 24, 2026

Copy link
Copy Markdown
Collaborator

The PR wraps the test driver code that was previously embedded in the macros PTF_START_RUNNING_TESTS, PTF_RUN_TEST and PTF_END_RUNNING_TESTS inside the ptf::TestRunner class.

Rationale

The change improves debugging UX by allowing step through debugging inside the test driver code.
Previously the embedded macro code was not "seen" by the IDE environment as actual code. This meant that debugging functionality like breakpoints and step through debuggers were unavailable inside those fragments. The entire macro code was treated as one line, instead of a code block.

Changes

The PR moves the code from the embedded macros into a wrapper class TestRunner. This allows the IDE to treat the code as regular code instead of macro text, thus allowing improved debugger support.

The functionality has been moved according to the following table:

Functionality Original location New location
Setup test environment PTF_START_RUNNING_TESTS TestRunner constructor
Run test case PTF_RUN_TEST TestRunner::runTest
Display aggregated test results PTF_END_RUNNING_TESTS TestRunner::finalizeResults

Compatibility

The old macros are kept as thin wrappers over the TestRunner instance to preserve compatibility with existing code.

@codecov

codecov Bot commented Mar 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 47.54098% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.62%. Comparing base (3aae85b) to head (81d22c9).

Files with missing lines Patch % Lines
Tests/PcppTestFramework/PcppTestFrameworkRun.h 47.54% 23 Missing and 9 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #2088      +/-   ##
==========================================
- Coverage   82.66%   82.62%   -0.04%     
==========================================
  Files         332      332              
  Lines       60155    60208      +53     
  Branches    12768    12778      +10     
==========================================
+ Hits        49727    49749      +22     
- Misses       9019     9042      +23     
- Partials     1409     1417       +8     
Flag Coverage Δ
23.11.6 7.59% <47.61%> (+0.31%) ⬆️
24.11.5 7.58% <47.61%> (+0.28%) ⬆️
25.11.1 7.54% <47.61%> (+0.24%) ⬆️
alpine320 77.09% <48.78%> (+0.22%) ⬆️
fedora42 76.66% <48.78%> (+0.21%) ⬆️
macos-15 82.22% <45.00%> (-0.05%) ⬇️
macos-26 82.22% <45.00%> (-0.05%) ⬇️
macos-26-intel 82.15% <45.00%> (-0.05%) ⬇️
mingw32 70.97% <ø> (-0.02%) ⬇️
mingw64 70.94% <ø> (+0.06%) ⬆️
npcap ?
rhel94 76.48% <47.61%> (+0.23%) ⬆️
ubuntu2204 76.51% <47.61%> (+0.23%) ⬆️
ubuntu2404 76.80% <48.78%> (+0.21%) ⬆️
ubuntu2604 76.76% <48.78%> (+0.25%) ⬆️
ubuntu2604-arm64 76.59% <48.78%> (+0.21%) ⬆️
ubuntu2604-icpx 59.05% <ø> (-0.03%) ⬇️
unittest 82.62% <47.54%> (-0.04%) ⬇️
windows-2022 85.80% <ø> (+0.10%) ⬆️
windows-2025 85.54% <ø> (+0.11%) ⬆️
winpcap 85.83% <ø> (+0.19%) ⬆️
xdp 53.41% <50.00%> (+0.51%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Dimi1010
Dimi1010 marked this pull request as ready for review March 24, 2026 13:49
@Dimi1010
Dimi1010 requested a review from seladb as a code owner March 24, 2026 13:49
@seladb

seladb commented Apr 6, 2026

Copy link
Copy Markdown
Owner

@Dimi1010 this is (yet another) PR with many changes that is hard to review... TBH I'm not sure what's the benefit of it...

@Dimi1010

Dimi1010 commented Apr 6, 2026

Copy link
Copy Markdown
Collaborator Author

@Dimi1010 this is (yet another) PR with many changes that is hard to review... TBH I'm not sure what's the benefit of it...

The main benefit is improved IDE step through debugging support. When the code is directly embedded into the macro, it can't be stepped through via debugger (which I needed at the time I made this) since the IDE doesn't "see" the source code in the files. You also can't place breakpoints on it.

For example PTF_RUN_TEST, in the old version is treated as 1 line of code for the step through debugger. In the new version it can be stepped through line by line.

The changes are mainly just moving the code without functional changes.
PTR_RUN_TEST -> TestRunner::runTest
PTF_START_RUNNING_TESTS -> TestRunner ctor
PTF_END_RUNNING_TESTS ->TestRunner::finalizeResults

I can separate the rename of __ptfSplitString to ptfSplitString, because that is independent. But the rest are tied together or it won't compile.

The reason behind the rename of __ptfSplitString and __ptfCheckTags is because the current naming breaks this rule in the C++ standard for reserved identifiers:

The following identifiers are reserved and may not be declared in a program (doing so invokes undefined behavior):

Edit: The link is to the C reference, but it also applies to the C++ language spec here.

in the global namespace, identifiers that begin with an underscore

PS: I suppose I should have elaborated more in the PR description in the first place. Sorry.

@Dimi1010

Dimi1010 commented Apr 6, 2026

Copy link
Copy Markdown
Collaborator Author

@seladb Reverted the changes that aren't critical to the PR and improved the PR description. Hope it helps. :)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants