[TEST] CTest reports a pass for gtest cases the binary does not contain
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- cmake, cpp
- Área
- build-system, testing-qa
Línea de trabajo
Reproduce el problema con la compilación predeterminada de Linux CMake y compara los nombres de CTest con la salida de --gtest_list_tests de cada binario. Empieza revisando los 34 archivos CMakeLists.txt que llaman a gtest_add_tests, junto con third_party_release y MODULE.bazel para comprobar la versión fijada de googletest. Se considerará terminado cuando los casos excluidos mediante compilación ya no aparezcan como pruebas de CTest aprobadas y la matriz de compilación documentada siga siendo compatible.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
gtest_add_tests() registers cases by scanning the source, so a case behind a preprocessor conditional stays registered in configurations where it is compiled out. CTest then runs it as <binary> --gtest_filter=<name>, gtest matches nothing, and exits 0. The case reports a pass having run nothing.
Reproduction
A default Linux CMake build with -DBUILD_TESTING=ON, so OPENTELEMETRY_ABI_VERSION_NO is 1 and the abiv2 cases are compiled out:
$ ./sdk/test/metrics/meter_provider_sdk_test --gtest_list_tests | grep -c GetMeterAbiv2
0
$ ctest -R "MeterProvider.GetMeterAbiv2"
Start 443: metrics.MeterProvider.GetMeterAbiv2
1/1 Test #443: metrics.MeterProvider.GetMeterAbiv2 ... Passed 0.01 sec
100% tests passed, 0 tests failed out of 1
$ ./sdk/test/metrics/meter_provider_sdk_test --gtest_filter=MeterProvider.GetMeterAbiv2
[==========] Running 0 tests from 0 test suites.
[ PASSED ] 0 tests.
$ echo $?
0
How much of it there is
Comparing every CTest name against what each binary reports from --gtest_list_tests, in that one build: 45 registered gtest cases across 14 test binaries are not present in the binary CTest runs them against. All 45 report a pass.
Two categories are excluded from that number rather than counted: 10 further differences are examples.*, which are add_test entries rather than gtest cases, and parameterised suites, whose registered and instantiated names differ by construction.
The guards behind them are the ones you would expect, and none of them is wrong: OPENTELEMETRY_ABI_VERSION_NO, NO_GETENV, ENABLE_ASYNC_EXPORT, OPENTELEMETRY_HAVE_WORKING_REGEX, OPENTELEMETRY_STL_VERSION, __cplusplus >= 202002L, and one #if 0. The problem is only that the resulting CTest line is green rather than absent or skipped.
Repo wide, 40 test sources contain a TEST, TEST_F or TEST_P inside a preprocessor conditional, under the 34 CMakeLists.txt that call gtest_add_tests. Which subset goes phantom depends on the configuration, so each job has its own set.
Why it matters
A green line that ran nothing is indistinguishable from a green line that passed. I ran into it while adding cases to the Elasticsearch exporter test in #4337: eight cases were compiled out in the synchronous builds and reported eight passes there, which is the opposite of what a reader would conclude.
Options
- A convention, no build change. Do not compile a case out. Give the suite a fixture whose
SetUpcallsGTEST_SKIP, so the case is always in the binary and CTest reportsSkipped. This is what #4331 and #4337 now do. It costs aTESTtoTEST_Fchange per case, and it relies on everyone remembering. gtest_discover_tests()in place ofgtest_add_tests(). CMake's GoogleTest module enumerates from the binary rather than the source, so a compiled-out case is never registered. It runs the test binary at build or test time, which has cross compilation and Windows DLL path caveats worth checking against this job matrix first.--gtest_fail_if_no_test_selected. Turns the empty match into a failure. Not available yet: it is on googletestmainbut not inv1.17.0, which is whatthird_party_releaseandMODULE.bazelpin, so it needs a googletest bump first.
Happy to take whichever you prefer, or to leave this as a note if you would rather not churn the test CMake right now. If option 1 is the answer, I can also add a check that fails when a TEST macro appears inside a preprocessor conditional in a gtest_add_tests target, so the convention does not depend on memory.
- Lenguaje dominante
- C++
- Estrellas
- 1.4k
- Forks
- 647
- Merge medio
- 1 d 10 h
- PR fusionados (30 d)
- 73
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de open-telemetry/opentelemetry-cpp
-
[CI] Add Ubuntu 26.04 runners to the CI workflowPosiblemente ocupada @deodattap la tomó hace 9 días. Abiertotriage/accepted
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
open-telemetry/opentelemetry-cpp#4596 · 2 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
[BUG] Resource::Create() throws bad_variant_access if process.executable.name isn't a stringPosiblemente ocupada @ryux1 la tomó hace 31 días. Abiertobug help wanted triage/accepted
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
open-telemetry/opentelemetry-cpp#4535 · 1 comentario · 2 reacciones ·
Los mantenedores suelen responder en 1 día
-
[BUG] OnResponse() can call std::terminate() when the response body fails to parse as JSON/protobufPosiblemente ocupada @YuEfSaEDU la tomó hace 22 días. Abiertobug help wanted triage/accepted
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
open-telemetry/opentelemetry-cpp#4534 · 2 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
[BUG] ETW Properties::to_vector doubles the result and reads past a string_viewPosiblemente ocupada @Tyagiquamar la tomó hace 7 días. Abiertoneeds-triage Stale
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
open-telemetry/opentelemetry-cpp#4347 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug Stale triage/accepted
Dificultad 1/5 Menos de una hora Aptitud para principiantes 62/100
open-telemetry/opentelemetry-cpp#3109 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de open-telemetry/opentelemetry-cpp
Issues similares
-
Status: Awaiting triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
espressif/arduino-esp32#12984 ·
Los mantenedores suelen responder en 1 día
-
torch_ops/logprob.cu does not compile with the serving container's nvcc (13.3.73); check_torch_ops.py cannot run as shippedPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 Menos de una hora Aptitud para principiantes 72/100
ashhart/TensorFold#535 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 Menos de una hora Aptitud para principiantes 78/100
sudoevolve/EUI-NEO#95 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día