add argument passing via TEST_ARGS environment variable to all tests with an explicit main function

This commit is contained in:
Axel Kohlmeyer
2020-06-24 09:53:56 -04:00
parent 6824b69ae9
commit 2af8d7a751
5 changed files with 59 additions and 9 deletions

View File

@ -38,6 +38,8 @@
#define GETIDX(i) lmp->atom->map(i)
using LAMMPS_NS::utils::split_words;
// whether to print verbose output (i.e. not capturing LAMMPS screen output).
bool verbose = false;
@ -1167,6 +1169,16 @@ int main(int argc, char **argv)
{
MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv);
// handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = split_words(var);
for (auto arg : env) {
if (arg == "-v") {
verbose = true;
}
}
}
if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true;
int rv = RUN_ALL_TESTS();