From 3a80e5ad1a99db71beed8da3a736b93d2dfec96c Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sun, 11 Feb 2024 16:38:57 -0700 Subject: [PATCH] tests: add -verbose flag --- tests/CMakeLists.txt | 3 ++- tests/test_ltface.cc | 9 ++++++++- tests/test_main.cc | 17 +++++++++++++---- tests/test_main.hh | 3 +++ tests/test_qbsp.cc | 10 +++++++++- 5 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 tests/test_main.hh diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 062b9386..a81c45ee 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -15,7 +15,8 @@ add_executable(tests ${CMAKE_CURRENT_BINARY_DIR}/../testmaps.hh testutils.hh benchmark.cc - test_bsputil.cc) + test_bsputil.cc + test_main.hh) INCLUDE_DIRECTORIES(${EMBREE_INCLUDE_DIRS}) diff --git a/tests/test_ltface.cc b/tests/test_ltface.cc index 41b8c859..ef201d89 100644 --- a/tests/test_ltface.cc +++ b/tests/test_ltface.cc @@ -8,6 +8,7 @@ #include #include #include "test_qbsp.hh" +#include "test_main.hh" static testresults_t QbspVisLight_Common(const std::filesystem::path &name, std::vector extra_qbsp_args, std::vector extra_light_args, runvis_t run_vis) @@ -40,7 +41,13 @@ static testresults_t QbspVisLight_Common(const std::filesystem::path &name, std: auto wal_metadata_path = std::filesystem::path(testmaps_dir) / "q2_wal_metadata"; std::vector args{"", // the exe path, which we're ignoring in this case - "-noverbose"}; + }; + + if (!tests_verbose) { + args.push_back("-noverbose"); + } else { + args.push_back("-nopercent"); + } for (auto &extra : extra_qbsp_args) { args.push_back(extra); } diff --git a/tests/test_main.cc b/tests/test_main.cc index b72e2db1..598cd617 100644 --- a/tests/test_main.cc +++ b/tests/test_main.cc @@ -1,9 +1,13 @@ +#include "test_main.hh" + #define DOCTEST_CONFIG_IMPLEMENT #include #include #include +bool tests_verbose = false; + int main(int argc, char **argv) { logging::preinitialize(); @@ -11,11 +15,16 @@ int main(int argc, char **argv) // writing console colors within test case output breaks doctest/CLion integration logging::enable_color_codes = false; - // parse "-threads 1" - for (int i = 1; i < argc - 1; ++i) { - if (!strcmp("-threads", argv[i])) { + for (int i = 1; i < argc; ++i) { + // parse "-threads 1" + if (!strcmp("-threads", argv[i]) && (i + 1) < argc) { configureTBB(atoi(argv[i + 1]), false); - break; + continue; + } + // parse "-verbose" + if (!strcmp("-verbose", argv[i])) { + tests_verbose = true; + continue; } } diff --git a/tests/test_main.hh b/tests/test_main.hh new file mode 100644 index 00000000..59aa2fab --- /dev/null +++ b/tests/test_main.hh @@ -0,0 +1,3 @@ +#pragma once + +extern bool tests_verbose; diff --git a/tests/test_qbsp.cc b/tests/test_qbsp.cc index 979d85fe..da15815b 100644 --- a/tests/test_qbsp.cc +++ b/tests/test_qbsp.cc @@ -20,6 +20,7 @@ #include #include #include "testutils.hh" +#include "test_main.hh" // FIXME: Clear global data (planes, etc) between each test @@ -99,7 +100,14 @@ std::tuple> LoadTestmap( auto wal_metadata_path = std::filesystem::path(testmaps_dir) / "q2_wal_metadata"; std::vector args{"", // the exe path, which we're ignoring in this case - "-noverbose", "-path", wal_metadata_path.string()}; + "-path", wal_metadata_path.string()}; + + if (!tests_verbose) { + args.push_back("-noverbose"); + } else { + args.push_back("-nopercent"); + } + for (auto &arg : extra_args) { args.push_back(arg); }