From b347ad5deb1c9abb210ac5da0534766bf5b6f2f0 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 27 Jun 2024 18:06:13 -0400 Subject: Make test.cpp test driver recognize LOGTEST_testname. Setting LOGTEST=DEBUG, when many unit/integration tests must be rebuilt and run, can result in lots of unnecessary output. When we only want DEBUG log output from a specific test program, make test.cpp recognize an environment variable LOGTEST_testname, where 'testname' might be the full basename of the executable, or part of INTEGRATION_TEST_testname or PROJECT_foo_TEST_testname. When test.cpp notices a non-empty variable by that name, it behaves as if LOGTEST were set to that value. --- indra/test/test.cpp | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'indra/test/test.cpp') diff --git a/indra/test/test.cpp b/indra/test/test.cpp index 61a4eb07c5..3cbac41f4a 100644 --- a/indra/test/test.cpp +++ b/indra/test/test.cpp @@ -35,13 +35,14 @@ */ #include "linden_common.h" -#include "llerrorcontrol.h" -#include "lltut.h" #include "chained_callback.h" -#include "stringize.h" -#include "namedtempfile.h" +#include "fsyspath.h" +#include "llerrorcontrol.h" #include "lltrace.h" #include "lltracethreadrecorder.h" +#include "lltut.h" +#include "namedtempfile.h" +#include "stringize.h" #include "apr_pools.h" #include "apr_getopt.h" @@ -545,6 +546,27 @@ int main(int argc, char **argv) // LOGTEST overrides default, but can be overridden by --debug. const char* LOGTEST = getenv("LOGTEST"); + // Sometimes we must rebuild much of the viewer before we get to the + // specific test we want to monitor, and some viewer integration tests are + // quite verbose. In addition to noticing plain LOGTEST= (for all tests), + // also notice LOGTEST_progname= (for a specific test). + std::string basename{ fsyspath(argv[0]).stem() }; + // don't make user set LOGTEST_INTEGRATION_TEST_progname or (worse) + // LOGTEST_PROJECT_foo_TEST_bar -- only LOGTEST_progname or LOGTEST_bar + auto _TEST_ = basename.find("_TEST_"); + if (_TEST_ != std::string::npos) + { + basename.erase(0, _TEST_+6); + } + std::string LOGTEST_prog_key{ "LOGTEST_" + basename }; + const char* LOGTEST_prog = getenv(LOGTEST_prog_key.c_str()); +// std::cout << LOGTEST_prog_key << "='" << (LOGTEST_prog? LOGTEST_prog : "") << "'" << std::endl; + if (LOGTEST_prog && *LOGTEST_prog) + { + LOGTEST = LOGTEST_prog; + std::cout << "LOGTEST='" << LOGTEST << "' from " << LOGTEST_prog_key << std::endl; + } + // values used for options parsing apr_status_t apr_err; const char* opt_arg = NULL; -- cgit v1.2.3 From 982ea7fb796924877e95bee2f9ba6b2296219139 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 27 Jun 2024 23:11:18 -0400 Subject: Work around VS refusal to initialize a string --- indra/test/test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/test/test.cpp') diff --git a/indra/test/test.cpp b/indra/test/test.cpp index 3cbac41f4a..22f9ccf334 100644 --- a/indra/test/test.cpp +++ b/indra/test/test.cpp @@ -550,7 +550,7 @@ int main(int argc, char **argv) // specific test we want to monitor, and some viewer integration tests are // quite verbose. In addition to noticing plain LOGTEST= (for all tests), // also notice LOGTEST_progname= (for a specific test). - std::string basename{ fsyspath(argv[0]).stem() }; + std::string basename(fsyspath(argv[0]).stem()); // don't make user set LOGTEST_INTEGRATION_TEST_progname or (worse) // LOGTEST_PROJECT_foo_TEST_bar -- only LOGTEST_progname or LOGTEST_bar auto _TEST_ = basename.find("_TEST_"); @@ -558,7 +558,7 @@ int main(int argc, char **argv) { basename.erase(0, _TEST_+6); } - std::string LOGTEST_prog_key{ "LOGTEST_" + basename }; + std::string LOGTEST_prog_key("LOGTEST_" + basename); const char* LOGTEST_prog = getenv(LOGTEST_prog_key.c_str()); // std::cout << LOGTEST_prog_key << "='" << (LOGTEST_prog? LOGTEST_prog : "") << "'" << std::endl; if (LOGTEST_prog && *LOGTEST_prog) -- cgit v1.2.3 From cfd7d8905d686411a774c47bbfc13f49882b65e6 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 28 Jun 2024 08:30:41 -0400 Subject: Work around MSVC limitation: explicitly call fsyspath::string(). --- indra/test/test.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/test/test.cpp') diff --git a/indra/test/test.cpp b/indra/test/test.cpp index 22f9ccf334..0e863d8084 100644 --- a/indra/test/test.cpp +++ b/indra/test/test.cpp @@ -550,7 +550,9 @@ int main(int argc, char **argv) // specific test we want to monitor, and some viewer integration tests are // quite verbose. In addition to noticing plain LOGTEST= (for all tests), // also notice LOGTEST_progname= (for a specific test). - std::string basename(fsyspath(argv[0]).stem()); + // (Why doesn't MSVC notice fsyspath::operator std::string()? + // Why must we explicitly call fsyspath::string()?) + std::string basename(fsyspath(argv[0]).stem().string()); // don't make user set LOGTEST_INTEGRATION_TEST_progname or (worse) // LOGTEST_PROJECT_foo_TEST_bar -- only LOGTEST_progname or LOGTEST_bar auto _TEST_ = basename.find("_TEST_"); -- cgit v1.2.3