From 8ab5f3c71ae87bc1a8a370a543c68cef9d44b998 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 13 Oct 2020 15:42:21 -0400 Subject: [PATCH] adjust recently added/expanded tests so they skip tests when packages are missing --- unittest/c-library/test_library_config.cpp | 2 +- unittest/python/test_python_package.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/unittest/c-library/test_library_config.cpp b/unittest/c-library/test_library_config.cpp index 55ca1f84ac..f196f800da 100644 --- a/unittest/c-library/test_library_config.cpp +++ b/unittest/c-library/test_library_config.cpp @@ -105,7 +105,7 @@ TEST_F(LibraryConfig, style_count) EXPECT_GT(lammps_style_count(lmp, "dihedral"), 1); EXPECT_GT(lammps_style_count(lmp, "improper"), 1); EXPECT_GT(lammps_style_count(lmp, "pair"), 1); - EXPECT_GT(lammps_style_count(lmp, "kspace"), 1); + EXPECT_GE(lammps_style_count(lmp, "kspace"), 0); EXPECT_GT(lammps_style_count(lmp, "compute"), 1); EXPECT_GT(lammps_style_count(lmp, "fix"), 1); EXPECT_GT(lammps_style_count(lmp, "region"), 1); diff --git a/unittest/python/test_python_package.cpp b/unittest/python/test_python_package.cpp index db8320aa91..f3ba9a8fff 100644 --- a/unittest/python/test_python_package.cpp +++ b/unittest/python/test_python_package.cpp @@ -12,6 +12,7 @@ ------------------------------------------------------------------------- */ #include "atom.h" +#include "info.h" #include "input.h" #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -37,6 +38,7 @@ using ::testing::MatchesRegex; class PythonPackageTest : public ::testing::Test { protected: LAMMPS *lmp; + Info *info; void SetUp() override { @@ -47,6 +49,7 @@ protected: lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD); if (!verbose) ::testing::internal::GetCapturedStdout(); ASSERT_NE(lmp, nullptr); + info = new Info(lmp); if (!verbose) ::testing::internal::CaptureStdout(); lmp->input->one("units real"); lmp->input->one("dimension 3"); @@ -71,6 +74,7 @@ protected: TEST_F(PythonPackageTest, python_invoke) { + if (!info->has_style("command","python")) GTEST_SKIP(); // execute python function from file if (!verbose) ::testing::internal::CaptureStdout(); lmp->input->one("python printnum file ${input_dir}/func.py"); @@ -105,6 +109,7 @@ TEST_F(PythonPackageTest, python_invoke) TEST_F(PythonPackageTest, python_variable) { + if (!info->has_style("command","python")) GTEST_SKIP(); if (!verbose) ::testing::internal::CaptureStdout(); lmp->input->one("variable sq python square"); lmp->input->one("variable val index 1.5");