Skip to content

Fix #15239 (Add tests for the simplecpp portability reports and the macro-usage arg) - #9057

Merged
danmar merged 1 commit into
cppcheck-opensource:mainfrom
JayToltTech:test-15239-main
Nov 22, 2026
Merged

danmar merged 1 commit into
cppcheck-opensource:mainfrom
JayToltTech:test-15239-main

Conversation

@JayToltTech

Copy link
Copy Markdown
Contributor

https://trac.cppcheck.net/ticket/15239

Tests for two things #9048 added that have no unit test yet.

  • portabilityReports: simplecppPortabilityBackslash and simplecppPortabilityNoEofNewline are reported from the main file with portability enabled, and nothing is reported without it.
  • dumpMacroUsageArg: the dump's <macro-usage> writes arg= for an integer constant macro call (INT64_C(5)) and leaves it out for other macros.

The getcode() helper now calls reportSimplecppPortability() after removeComments(), the same point CppCheck::checkInternal calls it, so the main file's portability messages reach the test logger.

These were first proposed against the #9048 branch (cppchecksolutions#4), which merged without them, so this brings them to main.

testrunner passes (TestPreprocessor, TestSuppressions, TestCppcheck, and the full run). runformat with uncrustify 0.80.1 makes no changes.

… dump

The simplecpp update reports PORTABILITY_BACKSLASH and
PORTABILITY_NO_EOF_NEWLINE as portability messages and writes the
argument of an integer constant macro call to <macro-usage>, with no
test for either. portabilityReports checks both ids are reported with
portability enabled and nothing without it. dumpMacroUsageArg checks
arg= is written for INT64_C(5) and left out for other macros.

getcode() now calls reportSimplecppPortability() after removeComments(),
as CppCheck::checkInternal does, so the main file's portability
messages reach the test logger.

dumpMacroUsageArg checks each <macro> entry without relying on their
order: simplecpp emits macro usages from an unordered_map, so libc++
and libstdc++ list them in different orders.

@dmcppcheck dmcppcheck left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AI review

I found no problems. The PR only touches tests. Both new tests pass, and so does the full testrunner. The getcode() change is needed: without the added reportSimplecppPortability() call, portabilityReports fails. With it, every other TestPreprocessor test still passes.

Testing

  • I built testrunner in /work/pr with make -j8, and it built without errors.
  • ./testrunner TestPreprocessor ran 185 tests with 0 failures. Both TestPreprocessor::portabilityReports and TestPreprocessor::dumpMacroUsageArg pass.
  • The full ./testrunner exits with 0 and reports Tests failed: 0.
  • I also checked that the getcode() change is needed. I removed preprocessor.reportSimplecppPortability(outputList); from getcode() and rebuilt. portabilityReports then failed at test/testpreprocessor.cpp:3334, because both expected portability messages were missing (actual output was empty). After that I restored the line. So the test really exercises the main-file reporting path, and the helper change does not alter any other preprocessor test.
  • I wrote no extra scratch inputs, because the PR changes no behaviour in lib/ or cli/.

Automated review of 69b8996 by Claude. The pull request was built and tested locally.

@danmar danmar changed the title Add tests for the simplecpp portability reports and the macro-usage arg (#15239) Fix #15239 (Add tests for the simplecpp portability reports and the macro-usage arg) Nov 22, 2026
@danmar
danmar merged commit 21459e9 into cppcheck-opensource:main Nov 22, 2026
74 checks passed
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.

3 participants