cmake: apply -Werror to generated test TUs and fix exposed warnings (X-QA-01)
This commit is contained in:
1 parent
65185f251c
commit
77a2bce73f
3 files changed
+16
-1
No files matched your search
@@ -114,6 +114,18 @@ endforeach()
|
||||
if(_all_generated)
|
||||
add_executable(VoidTests ${_all_generated})
|
||||
|
||||
# The generated test translation units belong to VoidTests, not to a module
|
||||
# target, so the warnings-as-errors policy from void_add_module does not
|
||||
# reach them unless it is applied here explicitly (X-QA-01).
|
||||
if(VOID_WARNINGS_AS_ERRORS)
|
||||
target_compile_options(VoidTests PRIVATE
|
||||
"$<$<COMPILE_LANGUAGE:CXX>:$<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-Wall;-Wextra;-Wpedantic;-Werror;-Wno-missing-field-initializers>>"
|
||||
# Test helpers live in anonymous namespaces and are captured by
|
||||
# coroutine frames; GCC's subobject-linkage diagnostic is noise for
|
||||
# that pattern, not a defect in the test code.
|
||||
"$<$<COMPILE_LANGUAGE:CXX>:$<$<CXX_COMPILER_ID:GNU>:-Wno-subobject-linkage>>")
|
||||
endif()
|
||||
|
||||
# Disable auto-sweep: we already applied the scanner manually above.
|
||||
set_target_properties(VoidTests PROPERTIES VOID_TESTING_NO_AUTO_SCAN TRUE)
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ Void::Testing::Test bench_run_total_positive()
|
||||
const auto r = run("work", 100, [] {
|
||||
volatile int x = 0;
|
||||
for (int i = 0; i < 100; ++i) x += i;
|
||||
do_not_optimize(x);
|
||||
}, 0);
|
||||
Void::Testing::expect(r.total.count() >= 0);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user