scripted-diff: [test] Add util/check.h includes for assertions - #36074
scripted-diff: [test] Add util/check.h includes for assertions#36074maflcko wants to merge 3 commits into
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/36074. ReviewsSee the guideline and AI policy for information on the review process. 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
3440553 to
faddb90
Compare
faddb90 to
203cd07
Compare
203cd07 to
4708bd9
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 for Assert and assert, and remove the
cassert include, which is exported from util/check.h.
-BEGIN VERIFY SCRIPT-
# Select all test .cpp and .h files
paths=(
'src/bench/'
'src/ipc/test/'
'src/qt/test/'
'src/test/'
'src/wallet/test/'
':(exclude)src/bench/nanobench.h'
)
# 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-
Also, remove the unused pushd/popd. No command in this file requires a special PWD.
-BEGIN VERIFY SCRIPT- git show -U0 HEAD~1 | ./contrib/devtools/clang-format-diff.py -p1 -i -v -END VERIFY SCRIPT-
4708bd9 to
bd900dc
Compare
|
🐙 This pull request conflicts with the target branch and needs rebase. |
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 (bench, fuzz, unit), other code can be done later, if there is need to.