Repository navigation
scripted-diff: [fuzz] Add util/check.h includes for assertions - #36074
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
|
Hmm, I guess I guess that means we could add an explicit |
fa7f786 to
3440553
Compare
fa4ba74 to
96f006f
Compare
96f006f to
543db8e
Compare
543db8e to
4ba4470
Compare
4ba4470 to
fa8dfb9
Compare
The project has a compile error when compiled without assertions in
util/check.h. Thus, util/check.h should be included for all assertions.
So do that with a scripted-diff to use util/check.h.
-BEGIN VERIFY SCRIPT-
# Select all fuzz files
paths=(
'src/ipc/test/fuzz'
'src/test/fuzz'
'src/wallet/test/fuzz'
)
# Add the util/check.h includes
for f in $(git grep -l --extended-regexp "\<(a|A)ssert\(" -- "${paths[@]}"); do
if ! grep --quiet "util/check.h" "$f"; then
line=$(grep --line-number --max-count=1 '^#include' "$f" | cut --delimiter=: --fields=1)
sed --in-place "${line}i#include <util/check.h>" "$f"
fi
done
# Remove cassert includes
for f in $(git grep -l '<cassert>' -- "${paths[@]}"); do
sed --in-place '/^#include <cassert>$/d' "$f"
done
-END VERIFY SCRIPT-
-BEGIN VERIFY SCRIPT- git show -U0 HEAD~0 | ./contrib/devtools/clang-format-diff.py -p1 -i -v -END VERIFY SCRIPT-
fa8dfb9 to
fa6c603
Compare
|
Rebased and limited to |

In test code,
assertis used. This is perfectly fine, but sometimes confusion arises, when it is unclear whetherNDEBUGcan disable the assertions, or whether to useassertorAssert.Avoid that confusion in test code with a scripted replacement to add the util/check.h include. The changes here will also make it easier to run IWYU.
Scope: This change is only about test code (fuzz), other code can be done later, if there is need to.