Normalize API tests.
authorM. Eric Irrgang <mei2n@virginia.edu>
Mon, 11 Oct 2021 09:31:02 +0000 (09:31 +0000)
committerM. Eric Irrgang <mei2n@virginia.edu>
Mon, 11 Oct 2021 09:31:02 +0000 (09:31 +0000)
Make the gmxapi tests look more like the other tests.

* Consistently use the test fixture based on the MDRun test fixture.
* Move gmxapi tests to the `api/` directory now that the infrastructure allows for the move. Establishes consistency with the nblib file locations.

18 files changed:
api/CMakeLists.txt
api/gmxapi/cpp/CMakeLists.txt
api/gmxapi/cpp/tests/.clang-tidy [moved from src/api/cpp/tests/.clang-tidy with 100% similarity]
api/gmxapi/cpp/tests/CMakeLists.txt [moved from src/api/cpp/tests/CMakeLists.txt with 98% similarity]
api/gmxapi/cpp/tests/context.cpp [moved from src/api/cpp/tests/context.cpp with 88% similarity]
api/gmxapi/cpp/tests/restraint.cpp [moved from src/api/cpp/tests/restraint.cpp with 98% similarity]
api/gmxapi/cpp/tests/runner.cpp [moved from src/api/cpp/tests/runner.cpp with 98% similarity]
api/gmxapi/cpp/tests/status.cpp [moved from src/api/cpp/tests/status.cpp with 94% similarity]
api/gmxapi/cpp/tests/stopsignaler.cpp [moved from src/api/cpp/tests/stopsignaler.cpp with 99% similarity]
api/gmxapi/cpp/tests/system.cpp [moved from src/api/cpp/tests/system.cpp with 96% similarity]
api/gmxapi/cpp/tests/testingconfiguration.h [moved from src/api/cpp/tests/testingconfiguration.h with 98% similarity]
api/gmxapi/cpp/tests/version.cpp [moved from src/api/cpp/tests/version.cpp with 97% similarity]
api/gmxapi/cpp/workflow/tests/.clang-tidy [moved from src/api/cpp/workflow/tests/.clang-tidy with 100% similarity]
api/gmxapi/cpp/workflow/tests/CMakeLists.txt [moved from src/api/cpp/workflow/tests/CMakeLists.txt with 97% similarity]
api/gmxapi/cpp/workflow/tests/workflow.cpp [moved from src/api/cpp/workflow/tests/workflow.cpp with 94% similarity]
src/CMakeLists.txt
src/api/CMakeLists.txt [deleted file]
src/api/cpp/CMakeLists.txt [deleted file]

index 19403e054fa72f253553f10ab67cbb35ad7d3bbe..e54fc0620256c04555b96307c9c5cd4bc7016a3b 100644 (file)
@@ -54,6 +54,13 @@ else()
 endif()
 option(GMXAPI "Install GROMACS API." ${_GMXAPI_DEFAULT})
 if (GMXAPI)
+    if(NOT ${BUILD_SHARED_LIBS})
+        # Note: this conditional should check for the existence of a libgromacs target supporting PIC
+        # using the POSITION_INDEPENDENT_CODE property, but for now the only facility we have is the global
+        # variable, BUILD_SHARED_LIBS.
+        # TODO: gmxapi should gracefully build for dynamic linking or static linking for PIC or without.
+        message(FATAL_ERROR "GMXAPI requires position-independent code. Set -DGMXAPI=OFF or -DBUILD_SHARED_LIBS=ON.")
+    endif()
     add_subdirectory(gmxapi)
 endif()
 
index 1e07928a83f3b2fb18977bccf75060539a3a7e93..1d01f7ebc5d521c6e6f0880a47efd499a1e8e060 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+# Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by
 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
 # and including many others, as listed in the AUTHORS file in the
 # top-level source directory and at http://www.gromacs.org.
@@ -139,3 +139,8 @@ install(
 add_library(gmxapi-detail INTERFACE)
 target_include_directories(gmxapi-detail
                            INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
+
+if (BUILD_TESTING AND GMX_BUILD_UNITTESTS)
+    add_subdirectory(tests)
+    add_subdirectory(workflow/tests)
+endif()
similarity index 98%
rename from src/api/cpp/tests/CMakeLists.txt
rename to api/gmxapi/cpp/tests/CMakeLists.txt
index 66380fd929fb2cb3d19111f32fcc0d7b19e87823..6d3a7eccd9c93d9fa3dbc0cc600d78021bc18006 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+# Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by
 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
 # and including many others, as listed in the AUTHORS file in the
 # top-level source directory and at http://www.gromacs.org.
similarity index 88%
rename from src/api/cpp/tests/context.cpp
rename to api/gmxapi/cpp/tests/context.cpp
index e87387151f2b05d85e2876d9958b4958938a997b..cd0e81177715e3157b74854ced28278e56e492e5 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
  * Provides additional test coverage of template headers only used by client code.
  */
 
-#include "config.h"
-
-#include <gtest/gtest.h>
-
 #include "gromacs/utility/gmxmpi.h"
 
 #include "gmxapi/context.h"
 #include "gmxapi/mpi/gmxapi_mpi.h"
+#include "testingconfiguration.h"
 
 
 namespace gmxapi
@@ -58,20 +55,20 @@ namespace testing
 namespace
 {
 
-TEST(GmxApiMpiTest, AllContext)
+TEST_F(GmxApiTest, AllContext)
 {
     // Default Implicit COMM_WORLD for MPI builds.
-    auto context = createContext();
+    EXPECT_NO_THROW(auto context = createContext());
 }
 
 #if GMX_LIB_MPI
-TEST(GmxApiMpiTest, NullContext)
+TEST_F(GmxApiTest, NullContext)
 {
     // Explicit COMM_NULL is not supported.
     EXPECT_ANY_THROW(assignResource(MPI_COMM_NULL));
 }
 
-TEST(GmxApiMpiTest, MpiWorldContext)
+TEST_F(GmxApiTest, MpiWorldContext)
 {
     // Note that this test is only compiled when GMX_MPI is enabled for the
     // build tree, so we cannot unit test the behavior of non-MPI GROMACS
@@ -89,7 +86,7 @@ TEST(GmxApiMpiTest, MpiWorldContext)
     auto context = createContext(*resources);
 }
 
-TEST(GmxApiMpiTest, MpiSplitContext)
+TEST_F(GmxApiTest, MpiSplitContext)
 {
     // Explicit sub-communicator.
     MPI_Comm communicator = MPI_COMM_NULL;
@@ -97,7 +94,7 @@ TEST(GmxApiMpiTest, MpiSplitContext)
     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
     // Run each rank as a separate ensemble member.
     MPI_Comm_split(MPI_COMM_WORLD, rank, rank, &communicator);
-    auto context = createContext(*assignResource(communicator));
+    EXPECT_NO_THROW(auto context = createContext(*assignResource(communicator)));
 }
 #endif
 
similarity index 98%
rename from src/api/cpp/tests/restraint.cpp
rename to api/gmxapi/cpp/tests/restraint.cpp
index 08ce92c084c77f2f3f50418343aa7043c2f829da..543cab442f0fccc8bcab2f0ee8fce3f6204901f7 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018, by the GROMACS development team, led by
+ * Copyright (c) 2018,2021, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
similarity index 98%
rename from src/api/cpp/tests/runner.cpp
rename to api/gmxapi/cpp/tests/runner.cpp
index cfe49d757a8da5ec80fc311e2b7a4dabd3718b05..fefc2547c4571cf990b7a2d127f6bb54627eef54 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2020,2021, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
similarity index 94%
rename from src/api/cpp/tests/status.cpp
rename to api/gmxapi/cpp/tests/status.cpp
index 7b505abe68cc2c6770be66c66fc5b36e7cc65514..2a389e770514d4ed7e53b3e8fc4645020beb9020 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018, by the GROMACS development team, led by
+ * Copyright (c) 2018,2021, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -34,8 +34,7 @@
  */
 
 #include "gmxapi/status.h"
-
-#include <gtest/gtest.h>
+#include "testingconfiguration.h"
 
 namespace gmxapi
 {
@@ -48,7 +47,7 @@ namespace
 /*!
  * \brief Test construction and conversion of boolean success status.
  */
-TEST(GmxApiBasicTest, Status)
+TEST_F(GmxApiTest, Status)
 {
     {
         auto status = gmxapi::Status();
similarity index 99%
rename from src/api/cpp/tests/stopsignaler.cpp
rename to api/gmxapi/cpp/tests/stopsignaler.cpp
index 85e8f646528cf80e4edbddf36bfb253607b3922c..35a5eabca164fb56739aa324b88fe3b3de6253fb 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018, by the GROMACS development team, led by
+ * Copyright (c) 2018,2021, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
similarity index 96%
rename from src/api/cpp/tests/system.cpp
rename to api/gmxapi/cpp/tests/system.cpp
index 25a5fc38e2d3c0af8885e9ad5e132c8462c5ceea..93a752aba1aa7f4bc1f8f69ff22536044e30ae6b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018, by the GROMACS development team, led by
+ * Copyright (c) 2018,2021, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
similarity index 98%
rename from src/api/cpp/tests/testingconfiguration.h
rename to api/gmxapi/cpp/tests/testingconfiguration.h
index 1becf040882c7cd929905c9b84a557349fc16453..76ba9cdd15a0b27a18512b2db3e8b1b46999c5c1 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
similarity index 97%
rename from src/api/cpp/tests/version.cpp
rename to api/gmxapi/cpp/tests/version.cpp
index 251a7ab49293caf1c8f5f50aabc7438f506b0f12..5c6c4fc81c6360b81431ec065184ff1184aeed07 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2020,2021, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -35,8 +35,6 @@
 
 #include <climits>
 
-#include <gtest/gtest.h>
-
 #include "gmxapi/version.h"
 #include "testingconfiguration.h"
 
similarity index 97%
rename from src/api/cpp/workflow/tests/CMakeLists.txt
rename to api/gmxapi/cpp/workflow/tests/CMakeLists.txt
index 65074a7f149f5032faeca7d4a0c29d04b364f5bb..4f2ff1969dab8cb7321d29427fde2950c04b22ee 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+# Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by
 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
 # and including many others, as listed in the AUTHORS file in the
 # top-level source directory and at http://www.gromacs.org.
similarity index 94%
rename from src/api/cpp/workflow/tests/workflow.cpp
rename to api/gmxapi/cpp/workflow/tests/workflow.cpp
index f3210b2d509869a2d1fde5e441c92d7338491fff..2844680c362dd60e23904054a9bb939e1c0730b0 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
+ * Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -67,7 +67,7 @@ TEST_F(GmxApiTest, BuildApiWorkflowImpl)
     EXPECT_EQ(impl.size(), 1);
 
     // Create workflow container
-    gmxapi::Workflow work{ std::move(impl) };
+    EXPECT_NO_THROW(gmxapi::Workflow work{ std::move(impl) });
 }
 
 //! Create from create() method(s)
index 5d6184dfd14aed9bdf2bdf34562fb0738e60e1e6..3358696a51247cfdc59bc93d77b0bc8eda1c46cf 100644 (file)
@@ -106,7 +106,6 @@ endif()
 
 add_subdirectory(gromacs)
 add_subdirectory(programs)
-add_subdirectory(api)
 
 # Configure header files with configuration-specific values. This step
 # should follow all introspection e.g. looking for headers and
diff --git a/src/api/CMakeLists.txt b/src/api/CMakeLists.txt
deleted file mode 100644 (file)
index 0206ba1..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-#
-# This file is part of the GROMACS molecular simulation package.
-#
-# Copyright (c) 2018,2019,2020,2021, by the GROMACS development team, led by
-# Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
-# and including many others, as listed in the AUTHORS file in the
-# top-level source directory and at http://www.gromacs.org.
-#
-# GROMACS is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public License
-# as published by the Free Software Foundation; either version 2.1
-# of the License, or (at your option) any later version.
-#
-# GROMACS is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with GROMACS; if not, see
-# http://www.gnu.org/licenses, or write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
-#
-# If you want to redistribute modifications to GROMACS, please
-# consider that scientific software is very special. Version
-# control is crucial - bugs must be traceable. We will be happy to
-# consider code for inclusion in the official distribution, but
-# derived work must not be called official GROMACS. Details are found
-# in the README & COPYING files - if they are missing, get the
-# official version at http://www.gromacs.org.
-#
-# To help us fund GROMACS development, we humbly ask that you cite
-# the research papers on the package. Check out http://www.gromacs.org.
-
-# Activate targets for new C++ API components and docs.
-if (GMXAPI)
-    if(NOT ${BUILD_SHARED_LIBS})
-        # Note: this conditional should check for the existence of a libgromacs target supporting PIC
-        # using the POSITION_INDEPENDENT_CODE property, but for now the only facility we have is the global
-        # variable, BUILD_SHARED_LIBS.
-        # TODO: gmxapi should gracefully build for dynamic linking or static linking for PIC or without.
-        message(FATAL_ERROR "GMXAPI requires position-independent code. Set -DGMXAPI=OFF or -DBUILD_SHARED_LIBS=ON.")
-    endif()
-    add_subdirectory(cpp)
-endif()
-
diff --git a/src/api/cpp/CMakeLists.txt b/src/api/cpp/CMakeLists.txt
deleted file mode 100644 (file)
index fbeb305..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-#
-# This file is part of the GROMACS molecular simulation package.
-#
-# Copyright (c) 2018,2019,2020, by the GROMACS development team, led by
-# Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
-# and including many others, as listed in the AUTHORS file in the
-# top-level source directory and at http://www.gromacs.org.
-#
-# GROMACS is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public License
-# as published by the Free Software Foundation; either version 2.1
-# of the License, or (at your option) any later version.
-#
-# GROMACS is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with GROMACS; if not, see
-# http://www.gnu.org/licenses, or write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
-#
-# If you want to redistribute modifications to GROMACS, please
-# consider that scientific software is very special. Version
-# control is crucial - bugs must be traceable. We will be happy to
-# consider code for inclusion in the official distribution, but
-# derived work must not be called official GROMACS. Details are found
-# in the README & COPYING files - if they are missing, get the
-# official version at http://www.gromacs.org.
-#
-# To help us fund GROMACS development, we humbly ask that you cite
-# the research papers on the package. Check out http://www.gromacs.org.
-
-if(BUILD_TESTING)
-    add_subdirectory(tests)
-    add_subdirectory(workflow/tests)
-endif()