diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2024-06-27 18:06:13 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2024-06-27 18:06:13 -0400 |
commit | b347ad5deb1c9abb210ac5da0534766bf5b6f2f0 (patch) | |
tree | 37859d92a68f715315f057481ed0d92b53d1aa5e /indra/test/test.cpp | |
parent | 75accbefdbe7741d57bf093690d65ad1100f82d4 (diff) |
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.
Diffstat (limited to 'indra/test/test.cpp')
-rw-r--r-- | indra/test/test.cpp | 30 |
1 files changed, 26 insertions, 4 deletions
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; |