Minor clean-up to sample_restraint tests.
authorM. Eric Irrgang <mei2n@virginia.edu>
Mon, 9 Aug 2021 09:20:01 +0000 (09:20 +0000)
committerMark Abraham <mark.j.abraham@gmail.com>
Mon, 9 Aug 2021 09:20:01 +0000 (09:20 +0000)
admin/ci-scripts/build-and-test-sample_restraint-2022.sh
python_packaging/docker/ci.dockerfile
python_packaging/sample_restraint/Dockerfile
python_packaging/sample_restraint/README.md
python_packaging/sample_restraint/tests/CMakeGROMACS.txt
python_packaging/sample_restraint/tests/CMakeLists.txt
python_packaging/sample_restraint/tests/test_binding.cpp [deleted file]

index a813094c353f7e809667db247a5145644ef37ec9..df4dcba29e4862136e54fded84b8a96efaafc60c 100644 (file)
@@ -46,8 +46,7 @@ pushd python_packaging/sample_restraint
     cmake .. \
              -DDOWNLOAD_GOOGLETEST=ON \
              -DGMXAPI_EXTENSION_DOWNLOAD_PYBIND=ON
-    make
-
+    make -j4 tests
     make test
     #TODO: Can we get ctest JUnitXML output here?
 
index 36fe02c7f6a1a819ad7bec9d6e984ec8919bcc85..22bbbd457805db6cf7fa120078cc67f9a41ffeec 100644 (file)
@@ -86,6 +86,7 @@ RUN . $VENV/bin/activate && \
              -DDOWNLOAD_GOOGLETEST=ON \
              -DGMXAPI_EXTENSION_DOWNLOAD_PYBIND=ON && \
      make -j4 && \
+     make tests && \
      make test && \
      make install \
     )
index 61e909a9100a44c354769f347ff5abe86ba60ff7..c7aaba68f41352226f2cd2081dd3d2798dedbc5c 100644 (file)
@@ -49,6 +49,7 @@ RUN mkdir /home/jovyan/plugin-build && \
     GROMACS_DIR=/home/jovyan/install/gromacs gmxapi_DIR=/home/jovyan/install/gromacs \
         cmake ../sample_restraint -DPYTHON_EXECUTABLE=/opt/conda/bin/python && \
     LD_LIBRARY_PATH=/opt/conda/lib make && \
+    make tests && \
     make test && \
     make install) && \
     PYTHONPATH=plugin-build/src/pythonmodule CONDA_DIR=/opt/conda \
index e347ba3f2277706af7874aa42544a3df1fd07584..de270fb2b17c29f1c3a417a8612ac7b243eac58a 100644 (file)
@@ -172,7 +172,8 @@ From the root directory of the GROMACS source, the sample_restraint source code
     # cmake .. -DGMXPLUGIN_USER_INSTALL=ON -DPYTHON_EXECUTABLE=`which python3`
     # Build myplugin.
     make
-    # run C++ tests
+    # build and run C++ tests
+    make tests
     make test
     # optionally, install
     make install
index acc960830bf3cad7c55d74fd041ba7fff924726e..a12dedbaef12e4ba6322bc9798c7a2da973877c7 100644 (file)
@@ -29,6 +29,4 @@ add_custom_target(gmxapi_extension_pytest
 # The current test fixtures require the `gmx` tool-wrapper executable.
 add_dependencies(gmxapi_extension_pytest gmx)
 
-add_dependencies(tests gmxapi_extension_histogram-test gmxapi_extension_bounding-test)
-
 add_dependencies(check gmxapi_extension_pytest)
index 0952396d334cb0c46e940e691be9f8066f661337..0acabc397242d248352b64f5adf5798230322055 100644 (file)
@@ -93,16 +93,8 @@ endif ()
 # Note: Expects topol.tpr to be in CURRENT_BINARY_DUR
 configure_file(testingconfiguration.in.h testingconfiguration.h)
 
-# Test that the library can access its dependencies and build.
-add_executable(gmxapi_extension_library-test test_binding.cpp)
-add_dependencies(gmxapi_extension_library-test gmxapi_extension_spc2_water_box)
-target_include_directories(gmxapi_extension_library-test PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
-target_link_libraries(gmxapi_extension_library-test Gromacs::libgromacs Gromacs::gmxapi GTest::Main)
-gtest_add_tests(TARGET gmxapi_extension_library-test
-                TEST_LIST BasicPlugin)
-
 # Test the C++ force evaluation for the restrained-ensemble biasing potential.
-add_executable(gmxapi_extension_histogram-test test_histogram.cpp)
+add_executable(gmxapi_extension_histogram-test EXCLUDE_FROM_ALL test_histogram.cpp)
 add_dependencies(gmxapi_extension_histogram-test gmxapi_extension_spc2_water_box)
 target_include_directories(gmxapi_extension_histogram-test PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
 set_target_properties(gmxapi_extension_histogram-test PROPERTIES SKIP_BUILD_RPATH FALSE)
@@ -112,7 +104,7 @@ gtest_add_tests(TARGET gmxapi_extension_histogram-test
                 TEST_LIST EnsembleHistogramPotentialPlugin)
 
 # Test the flat-bottom bounding potential built in to the ensemble restraint.
-add_executable(gmxapi_extension_bounding-test test_bounding_restraint.cpp)
+add_executable(gmxapi_extension_bounding-test EXCLUDE_FROM_ALL test_bounding_restraint.cpp)
 add_dependencies(gmxapi_extension_bounding-test gmxapi_extension_spc2_water_box)
 target_include_directories(gmxapi_extension_bounding-test PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
 set_target_properties(gmxapi_extension_bounding-test PROPERTIES SKIP_BUILD_RPATH FALSE)
@@ -121,6 +113,16 @@ target_link_libraries(gmxapi_extension_bounding-test gmxapi_extension_ensemblepo
 gtest_add_tests(TARGET gmxapi_extension_bounding-test
                 TEST_LIST EnsembleBoundingPotentialPlugin)
 
-if (NOT GMXAPI_EXTENSION_MASTER_PROJECT)
+# Like GROMACS, this project uses a `tests` target to avoid
+# building the tests unnecessarily (such as for the `install` target).
+# If built as part of the GROMACS build tree (GROMACS is the "master" project),
+# the `tests` target is defined by the parent project.
+# Otherwise (the MD plugin is the "master project"), we have to add
+# the `tests` target in this project.
+if (GMXAPI_EXTENSION_MASTER_PROJECT)
+    add_custom_target(tests)
+else()
     include(CMakeGROMACS.txt)
 endif ()
+
+add_dependencies(tests gmxapi_extension_histogram-test gmxapi_extension_bounding-test)
diff --git a/python_packaging/sample_restraint/tests/test_binding.cpp b/python_packaging/sample_restraint/tests/test_binding.cpp
deleted file mode 100644 (file)
index 8476323..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-//
-// Created by Eric Irrgang on 11/9/17.
-//
-
-#include "testingconfiguration.h"
-
-#include <memory>
-#include <vector>
-
-#include "gmxapi/md/mdmodule.h"
-
-#include "gromacs/restraint/restraintpotential.h"
-
-#include <gtest/gtest.h>
-
-namespace
-{
-
-const auto filename = plugin::testing::sample_tprfilename;
-
-class NullRestraint : public gmx::IRestraintPotential
-{
-    public:
-        gmx::PotentialPointData evaluate(gmx::Vector r1,
-                                         gmx::Vector r2,
-                                         double t) override
-        {
-            return {};
-        }
-
-        std::vector<int> sites() const override
-        {
-            return {0,0};
-        }
-};
-
-class SimpleApiModule : public gmxapi::MDModule
-{
-    public:
-        const char *name() const override
-        {
-            return "NullApiModule";
-        }
-
-        std::shared_ptr<gmx::IRestraintPotential> getRestraint() override
-        {
-            auto restraint = std::make_shared<NullRestraint>();
-            return restraint;
-        }
-};
-
-} // end anonymous namespace