Run all tests without arguments

Abierto
#2,028 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
cmake, cpp

Línea de trabajo

Comienza con test/CMakeLists.txt, test/BUILD, test/spec_arg_test.cc y los argumentos de perf_counters_test; después, inspecciona las funciones main de los tests que actualmente requieren argumentos. El trabajo estará terminado cuando la suite de tests pueda ejecutarse sin argumentos proporcionados por el usuario, los argumentos predeterminados se apliquen de forma coherente en las definiciones de build y los tests existentes sensibles a los argumentos sigan pasando.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Hi! I find it confusing that the tests require arguments. I want to change it.

Here are my reasons:

  1. Not all tests check for required arguments
    https://github.com/google/benchmark/blob/7697796fe5a70edbc3394d0593ef82afeebb7ddf/test/spec_arg_test.cc#L63-L70 and so it's easy to run a test incorrectly.
  2. There are GitHub issues mentioning that a test fails when the actual problem was that the correct arguments were not passed.
  3. Arguments need to be duplicated between test/CMakeLists.txt and test/BUILD and they are actually not in sync now (perf_counters_test is run with different arguments).

My solution:

  1. Create test/default_arguments.h:
// ...

void AddTestArguments(int &argc, char **&argv, std::initializer_list<char const*> args={}) {
  if (argc > 1) {
    std::cout << "Warning: User is not expected to pass any command line arguments\n";
  }
  static std::vector<char const*> new_argv;
  new_argv.insert(new_argv.end(), argv, argv + argc);
  new_argv.insert(new_argv.end(), args.begin(), args.end());
  new_argv.push_back("--benchmark_min_time=0.01s");
  argv = const_cast<char**>(new_argv.data());
  argc = static_cast<int>(new_argv.size());
}
  1. Call it after each main function like this
int main(int argc, char* argv[]) {
  AddTestArguments(argc, argv, {"--benchmark_counters_tabular=true"});
  benchmark::MaybeReenterWithoutASLR(argc, argv);
  RunOutputTests(argc, argv);
}
  1. Cleanup the code

Sounds good?

Lenguaje dominante
C++
Estrellas
10.5k
Forks
1.8k
Merge medio
1 d 15 h
PR fusionados (30 d)
28

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de google/benchmark

Todos los issues de google/benchmark

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.