mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-30 05:11:14 +00:00
Run clang-tidy on every ported test
The test regex skipped file names with digits (test_aead2022_cpp.cpp, test_base64_cpp.cpp); include them, fix the two optional accesses it then reports, and build test_jconf with the strict warning set.
This commit is contained in:
@@ -125,7 +125,7 @@ jobs:
|
||||
run: |
|
||||
set -o pipefail
|
||||
tidy_status=0
|
||||
run-clang-tidy-18 -quiet -p build -extra-arg=-Wno-unknown-warning-option "$PWD/(src/(core/|event/|relay/|crypto/|api/)?[^/]+\.(c|cpp)|tests/test_(core_[^/]+|[a-z_]+_cpp)\.cpp)$" 2>&1 | tee tidy.log || tidy_status=$?
|
||||
run-clang-tidy-18 -quiet -p build -extra-arg=-Wno-unknown-warning-option "$PWD/(src/(core/|event/|relay/|crypto/|api/)?[^/]+\.(c|cpp)|tests/test_(core_[^/]+|[a-z0-9_]+_cpp)\.cpp)$" 2>&1 | tee tidy.log || tidy_status=$?
|
||||
grep 'warning:' tidy.log | sort -u > warnings.txt || true
|
||||
count="$(wc -l < warnings.txt)"
|
||||
echo "clang-tidy warnings: $count (max allowed: $MAX_WARNINGS)"
|
||||
|
||||
@@ -80,7 +80,7 @@ Uses **uncrustify** with the config at `.uncrustify.cfg`. Key settings: 4-space
|
||||
|
||||
- **clang-tidy**: config in `.clang-tidy`. The build exports `compile_commands.json` automatically. Run locally:
|
||||
```bash
|
||||
run-clang-tidy -quiet -p build '/(src/(core/|event/|relay/|crypto/|api/)?[^/]+\.(c|cpp)|tests/test_(core_[^/]+|[a-z_]+_cpp)\.cpp)$'
|
||||
run-clang-tidy -quiet -p build '/(src/(core/|event/|relay/|crypto/|api/)?[^/]+\.(c|cpp)|tests/test_(core_[^/]+|[a-z0-9_]+_cpp)\.cpp)$'
|
||||
```
|
||||
On macOS with Homebrew LLVM, add `-extra-arg="-isysroot$(xcrun --show-sdk-path)"`. CI (`clang-tidy` job in `tests.yml`) enforces a warning-count ratchet via `MAX_WARNINGS` — lower it when fixing findings; never raise it without justification.
|
||||
- **No-heap lint**: `scripts/check_no_heap.py --self-test` (also a ctest) rejects heap allocation in C++ sources under `src/`.
|
||||
|
||||
@@ -296,7 +296,7 @@ ss_add_test(test_acl_literal
|
||||
ss_strict_warnings(
|
||||
test_acl_cpp.cpp test_acl_literal_cpp.cpp test_aead2022_cpp.cpp test_base64_cpp.cpp
|
||||
test_buffer_cpp.cpp test_cache_reference_cpp.cpp test_crypto_cpp.cpp test_ipset_cpp.cpp
|
||||
test_json_cpp.cpp test_netutils_cpp.cpp test_ppbloom_cpp.cpp test_process_cpp.cpp
|
||||
test_jconf_cpp.cpp test_json_cpp.cpp test_netutils_cpp.cpp test_ppbloom_cpp.cpp test_process_cpp.cpp
|
||||
test_ref_cpp.cpp test_ssurl_cpp.cpp test_utils_cpp.cpp)
|
||||
|
||||
|
||||
|
||||
@@ -398,8 +398,9 @@ void test_methods()
|
||||
salt_pool();
|
||||
SS_CHECK(!sc::find_aead2022("aes-256-gcm"));
|
||||
auto spec = sc::find_aead2022("2022-blake3-aes-256-gcm");
|
||||
SS_CHECK(!sc::Psk::from_base64(*spec, kPsk16)); // too short
|
||||
SS_CHECK(!sc::Psk::from_base64(*spec, "not base64"));
|
||||
SS_CHECK(spec.has_value());
|
||||
SS_CHECK(!sc::Psk::from_base64(spec.value(), kPsk16)); // too short
|
||||
SS_CHECK(!sc::Psk::from_base64(spec.value(), "not base64"));
|
||||
}
|
||||
|
||||
void test_no_heap_in_steady_state()
|
||||
|
||||
Reference in New Issue
Block a user