remove obsolete unittest code specific to handling the case of lammps exceptions disabled

This commit is contained in:
Axel Kohlmeyer
2023-04-16 12:34:47 -04:00
parent 98efb19e79
commit 5f4a80d41f
23 changed files with 14 additions and 89 deletions

View File

@ -461,9 +461,6 @@ TEST_F(LibraryProperties, neighlist)
TEST_F(LibraryProperties, has_error) TEST_F(LibraryProperties, has_error)
{ {
// need errors to throw exceptions to be able to intercept them.
if (!lammps_config_has_exceptions()) GTEST_SKIP();
EXPECT_EQ(lammps_has_error(lmp), 0); EXPECT_EQ(lammps_has_error(lmp), 0);
// trigger an error, but hide output // trigger an error, but hide output

View File

@ -402,9 +402,6 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv); ::testing::InitGoogleMock(&argc, argv);
if (LAMMPS_NS::platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable // handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) { if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var); std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);

View File

@ -301,9 +301,6 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv); ::testing::InitGoogleMock(&argc, argv);
if (LAMMPS_NS::platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable // handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) { if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var); std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);

View File

@ -161,9 +161,6 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv); ::testing::InitGoogleMock(&argc, argv);
if (LAMMPS_NS::platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable // handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) { if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var); std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);

View File

@ -469,9 +469,6 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv); ::testing::InitGoogleMock(&argc, argv);
if (LAMMPS_NS::platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable // handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) { if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var); std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);

View File

@ -683,9 +683,6 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv); ::testing::InitGoogleMock(&argc, argv);
if (LAMMPS_NS::platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable // handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) { if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var); std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);

View File

@ -299,9 +299,6 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv); ::testing::InitGoogleMock(&argc, argv);
if (LAMMPS_NS::platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable // handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) { if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var); std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);

View File

@ -632,9 +632,6 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv); ::testing::InitGoogleMock(&argc, argv);
if (LAMMPS_NS::platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable // handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) { if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var); std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);

View File

@ -285,9 +285,6 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv); ::testing::InitGoogleMock(&argc, argv);
if (LAMMPS_NS::platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable // handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) { if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var); std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);

View File

@ -806,9 +806,6 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv); ::testing::InitGoogleMock(&argc, argv);
if (LAMMPS_NS::platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable // handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) { if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var); std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);

View File

@ -460,9 +460,6 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv); ::testing::InitGoogleMock(&argc, argv);
if (LAMMPS_NS::platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable // handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) { if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var); std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);

View File

@ -560,9 +560,6 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv); ::testing::InitGoogleMock(&argc, argv);
if (LAMMPS_NS::platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable // handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) { if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var); std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);

View File

@ -726,9 +726,6 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv); ::testing::InitGoogleMock(&argc, argv);
if (LAMMPS_NS::platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable // handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) { if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var); std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);

View File

@ -224,9 +224,6 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv); ::testing::InitGoogleMock(&argc, argv);
if (LAMMPS_NS::platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable // handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) { if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var); std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);

View File

@ -125,9 +125,6 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv); ::testing::InitGoogleMock(&argc, argv);
if (LAMMPS_NS::platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable // handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) { if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = LAMMPS_NS::utils::split_words(var); std::vector<std::string> env = LAMMPS_NS::utils::split_words(var);

View File

@ -618,9 +618,6 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv); ::testing::InitGoogleMock(&argc, argv);
if (platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable // handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) { if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = split_words(var); std::vector<std::string> env = split_words(var);

View File

@ -409,9 +409,6 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv); ::testing::InitGoogleMock(&argc, argv);
if (platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable // handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) { if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = split_words(var); std::vector<std::string> env = split_words(var);

View File

@ -323,9 +323,6 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv); ::testing::InitGoogleMock(&argc, argv);
if (platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable // handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) { if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = split_words(var); std::vector<std::string> env = split_words(var);

View File

@ -166,9 +166,6 @@ int main(int argc, char **argv)
MPI_Init(&argc, &argv); MPI_Init(&argc, &argv);
::testing::InitGoogleMock(&argc, argv); ::testing::InitGoogleMock(&argc, argv);
if (platform::mpi_vendor() == "Open MPI" && !Info::has_exceptions())
std::cout << "Warning: using OpenMPI without exceptions. Death tests will be skipped\n";
// handle arguments passed via environment variable // handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) { if (const char *var = getenv("TEST_ARGS")) {
std::vector<std::string> env = split_words(var); std::vector<std::string> env = split_words(var);

View File

@ -123,9 +123,6 @@ TEST_F(LAMMPS_properties, extract_setting)
TEST_F(LAMMPS_properties, has_error) TEST_F(LAMMPS_properties, has_error)
{ {
// need errors to throw exceptions to be able to intercept them.
if (!lammps_config_has_exceptions()) GTEST_SKIP();
EXPECT_EQ(f_lammps_has_error(), lammps_has_error(lmp)); EXPECT_EQ(f_lammps_has_error(), lammps_has_error(lmp));
EXPECT_EQ(f_lammps_has_error(), 0); EXPECT_EQ(f_lammps_has_error(), 0);

View File

@ -4,7 +4,7 @@ from lammps import lammps
has_mpi=False has_mpi=False
has_mpi4py=False has_mpi4py=False
has_exceptions=False
try: try:
from mpi4py import __version__ as mpi4py_version from mpi4py import __version__ as mpi4py_version
# tested to work with mpi4py versions 2 and 3 # tested to work with mpi4py versions 2 and 3
@ -19,7 +19,6 @@ try:
machine = "" machine = ""
lmp = lammps(name=machine) lmp = lammps(name=machine)
has_mpi = lmp.has_mpi_support has_mpi = lmp.has_mpi_support
has_exceptions = lmp.has_exceptions
lmp.close() lmp.close()
except: except:
pass pass
@ -79,7 +78,6 @@ class PythonOpen(unittest.TestCase):
self.assertEqual(lmp.opened,1) self.assertEqual(lmp.opened,1)
lmp.close() lmp.close()
@unittest.skipIf(not has_exceptions,"Skipping death test since LAMMPS isn't compiled with exception support")
def testUnknownCommand(self): def testUnknownCommand(self):
lmp = lammps(name=self.machine) lmp = lammps(name=self.machine)
@ -88,7 +86,6 @@ class PythonOpen(unittest.TestCase):
lmp.close() lmp.close()
@unittest.skipIf(not has_exceptions,"Skipping death test since LAMMPS isn't compiled with exception support")
def testUnknownCommandInList(self): def testUnknownCommandInList(self):
lmp = lammps(name=self.machine) lmp = lammps(name=self.machine)
@ -97,7 +94,6 @@ class PythonOpen(unittest.TestCase):
lmp.close() lmp.close()
@unittest.skipIf(not has_exceptions,"Skipping death test since LAMMPS isn't compiled with exception support")
def testUnknownCommandInString(self): def testUnknownCommandInString(self):
lmp = lammps(name=self.machine) lmp = lammps(name=self.machine)

View File

@ -33,20 +33,11 @@ using LAMMPS_NS::LAMMPSException;
using ::testing::ContainsRegex; using ::testing::ContainsRegex;
#define TEST_FAILURE(errmsg, ...) \ #define TEST_FAILURE(errmsg, ...) \
if (Info::has_exceptions()) { \ { \
::testing::internal::CaptureStdout(); \ ::testing::internal::CaptureStdout(); \
ASSERT_ANY_THROW({__VA_ARGS__}); \ ASSERT_ANY_THROW({__VA_ARGS__}); \
auto mesg = ::testing::internal::GetCapturedStdout(); \ auto mesg = ::testing::internal::GetCapturedStdout(); \
ASSERT_THAT(mesg, ContainsRegex(errmsg)); \ ASSERT_THAT(mesg, ContainsRegex(errmsg)); \
} else { \
if (LAMMPS_NS::platform::mpi_vendor() != "Open MPI") { \
::testing::internal::CaptureStdout(); \
ASSERT_DEATH({__VA_ARGS__}, ""); \
auto mesg = ::testing::internal::GetCapturedStdout(); \
ASSERT_THAT(mesg, ContainsRegex(errmsg)); \
} else { \
std::cerr << "[ ] [ INFO ] Skipping death test (no exception support) \n"; \
} \
} }
// whether to print verbose output (i.e. not capturing LAMMPS screen output). // whether to print verbose output (i.e. not capturing LAMMPS screen output).

View File

@ -73,7 +73,6 @@ TEST_F(LeptonUtilsTest, substitute)
lmp->update->reset_timestep(100LL, false); lmp->update->reset_timestep(100LL, false);
ASSERT_THAT(LeptonUtils::substitute("(2.5/v_pre)", lmp), StrEq("(2.5/0.1)")); ASSERT_THAT(LeptonUtils::substitute("(2.5/v_pre)", lmp), StrEq("(2.5/0.1)"));
if (LAMMPS_NS::Info::has_exceptions()) {
bool caught = false; bool caught = false;
try { try {
LeptonUtils::substitute("v_none", lmp); LeptonUtils::substitute("v_none", lmp);
@ -82,7 +81,6 @@ TEST_F(LeptonUtilsTest, substitute)
caught = true; caught = true;
} }
ASSERT_TRUE(caught); ASSERT_TRUE(caught);
}
} }
// zbl() custom function // zbl() custom function