tests: add -verbose flag

This commit is contained in:
Eric Wasylishen 2024-02-11 16:38:57 -07:00
parent 765d95e189
commit 3a80e5ad1a
5 changed files with 35 additions and 7 deletions

View File

@ -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})

View File

@ -8,6 +8,7 @@
#include <testmaps.hh>
#include <vis/vis.hh>
#include "test_qbsp.hh"
#include "test_main.hh"
static testresults_t QbspVisLight_Common(const std::filesystem::path &name, std::vector<std::string> extra_qbsp_args,
std::vector<std::string> 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<std::string> 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);
}

View File

@ -1,9 +1,13 @@
#include "test_main.hh"
#define DOCTEST_CONFIG_IMPLEMENT
#include <doctest/doctest.h>
#include <common/log.hh>
#include <common/threads.hh>
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;
for (int i = 1; i < argc; ++i) {
// parse "-threads 1"
for (int i = 1; i < argc - 1; ++i) {
if (!strcmp("-threads", argv[i])) {
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;
}
}

3
tests/test_main.hh Normal file
View File

@ -0,0 +1,3 @@
#pragma once
extern bool tests_verbose;

View File

@ -20,6 +20,7 @@
#include <map>
#include <doctest/doctest.h>
#include "testutils.hh"
#include "test_main.hh"
// FIXME: Clear global data (planes, etc) between each test
@ -99,7 +100,14 @@ std::tuple<mbsp_t, bspxentries_t, std::optional<prtfile_t>> LoadTestmap(
auto wal_metadata_path = std::filesystem::path(testmaps_dir) / "q2_wal_metadata";
std::vector<std::string> 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);
}