-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Fix #13523 CTU: Mention including cpp file for error in header #7174
Conversation
test/cli/whole-program_test.py
Outdated
file0 = '' | ||
for e in results.findall('errors/error'): | ||
if e.attrib['id'] == 'ctunullpointer': | ||
if 'file0' in e.attrib: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why this is necessary, but there was a KeyError
without it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That means that it doesn't contain that key. []
acts like at()
in C++.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, but there should only be one ctunullpointer
error, which has the file0
attribute.
XML shown here: https://github.com/danmar/cppcheck/actions/runs/12605458944/job/35134122531
KeyError: https://github.com/danmar/cppcheck/actions/runs/12605258027/job/35133607619
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably add a few more asserts on the results. Like the amount of returned nodes and such.
You could also limit the XPath to only return the node in question by adding [@id='ctunullpointer']
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably add a few more asserts on the results. Like the amount of returned nodes and such.
Not so easy, since getting both nullpointer
and ctunullpointer
seems wrong already. With -j2
, we get an additional ctunullpointer
(https://trac.cppcheck.net/ticket/11883)
You could also limit the XPath to only return the node in question by adding
[@id='ctunullpointer']
.
Done.
FYI running the tests locally on Windows is actually quite easy. You can install the official Python distribution from the Microsoft Store (https://apps.microsoft.com/detail/9pnrbtzxmb4z) which will place |
Hadn't even tried that, fearing another rabbit hole. But it works:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not strongly against that we test it in test/cli but I wonder why it wasn't tested in testrunner instead.
A pytest that executes cppcheck is slower than a testrunner test as far as I understand?
Obviously by design but all the Python tests together take less than 40 seconds. So even if we add several dozens more that will hardly make a dent in the CI runtime. |
We also get all the injection matrix in the CI with those tests which is actually important as these behave different with threads and/or builddir. And that is annoying or really hard to test in the unit tests and here we get it for "free". |
Not sure why
https://github.com/danmar/cppcheck/actions/runs/12654460990/job/35262407668 |
test/cli/whole-program_test.py
Outdated
assert file0 == 'whole-program/nullpointer1.cpp' | ||
assert stdout == '' | ||
assert ret == 1, stdout | ||
|
||
|
||
def test_nullpointer_file0(): | ||
__test_nullpointer_file0(['-j1']) | ||
|
||
@pytest.mark.skip(reason="flaky!?") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert file0 == 'whole-program/nullpointer1.cpp' | |
assert stdout == '' | |
assert ret == 1, stdout | |
def test_nullpointer_file0(): | |
__test_nullpointer_file0(['-j1']) | |
@pytest.mark.skip(reason="flaky!?") | |
assert ret == 1, stdout if stdout else stderr | |
assert stdout == '' | |
assert file0 == 'whole-program/nullpointer1.cpp', stderr | |
def test_nullpointer_file0(): | |
__test_nullpointer_file0(['-j1']) | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually I would assume it is an issue with running the test in parallel but there is nothing in this test which could cause that.
But this test is build with UBSAN so it might indicate such an issue. The asserts are in a bad order so that would be obfuscated. I adjusted them so we should get more details (that needs to be applied across all the tests - there are already some initial helpers but something for later).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The xfail is still in, so it might pass now but we might not see the error reported by the sanitizer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With xfail in, Run test/cli (--cppcheck-build-dir)
fails (test succeeds). Without xfail, Run test/cli
fails as expected.
How is this injection stuff supposed to work? I also see extraargs
being used in the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The injection stuff checks if any of the parameters in question already exists and only injects those is necessary. The -j2
injection will not be done if -j1
already exists. Same with --cppcheck-build-dir
and --executor
. So if you have to specify them explicitly they will not return the same no matter how it is called (e.g. Windows does not support --executor=process
) and you need to provide an override.
This looks weird though. Will take a look later.
No description provided.