From 330c77e3c2a190019cb36fefd3e0c286707d0c52 Mon Sep 17 00:00:00 2001 From: Thibault Lestang Date: Fri, 4 Mar 2022 13:44:48 +0000 Subject: [PATCH 1/3] Add a dummy test --- tests/test_dummy.pf | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 tests/test_dummy.pf diff --git a/tests/test_dummy.pf b/tests/test_dummy.pf new file mode 100644 index 0000000..0f83dcd --- /dev/null +++ b/tests/test_dummy.pf @@ -0,0 +1,7 @@ +@test +subroutine test_dummy() + use funit + + @assertTrue(1 > 0) + +end subroutine test_dummy From 5a2c14cfd327feaefc9b46c9e25f3cd71b529b1a Mon Sep 17 00:00:00 2001 From: Thibault Lestang Date: Fri, 4 Mar 2022 13:45:22 +0000 Subject: [PATCH 2/3] Setup cmake to build test executable with pfunit --- CMakeLists.txt | 3 +++ tests/CMakeLists.txt | 6 ++++++ 2 files changed, 9 insertions(+) create mode 100644 tests/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e81dcc..27f653f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,3 +21,6 @@ set(CMAKE_INSTALL_PREFIX ${PROJECT_BINARY_DIR}) install(TARGETS xcompact3d RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) + +# Build tests +add_subdirectory(tests) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..3894e2f --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,6 @@ +find_package(PFUNIT REQUIRED) +enable_testing() + +set(test_src test_dummy.pf) +add_pfunit_ctest(tests TEST_SOURCES ${test_src}) + From 86e56b7ee0802afb4a95b705db1329c92323a698 Mon Sep 17 00:00:00 2001 From: Thibault Lestang Date: Fri, 4 Mar 2022 13:48:14 +0000 Subject: [PATCH 3/3] Add GH actions workflow for unit tests with pFUnit --- .github/workflows/unit_tests.yml | 61 ++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/unit_tests.yml diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml new file mode 100644 index 0000000..9a0169d --- /dev/null +++ b/.github/workflows/unit_tests.yml @@ -0,0 +1,61 @@ +name: Build + +on: push + +jobs: + build: + runs-on: ubuntu-latest + + steps: + + - uses: actions/checkout@v2 + + # We don't want to build openmpi each time this workflow is + # run. Setup caching of OpenMPI after it is built and installed. + # See "Caching dependencies to speed up workflows" on the GH + # actions docs. + - name: Cache OpenMPI + id: cache-openmpi + uses: actions/cache@v2 + with: + path: openmpi-4.1.2/installed + key: openmpi-4.1.2 + + # Same goes for pFUnit + - name: Cache pFUnit + id: cache-pfunit + uses: actions/cache@v2 + with: + path: pfunit-4.2.2/installed + key: pfunit-4.2.2 + + - name: Build openmpi + if: steps.cache-openmpi.outputs.cache-hit != 'true' + run: | + wget https://download.open-mpi.org/release/open-mpi/v4.1/openmpi-4.1.2.tar.gz + tar -xf openmpi-4.1.2.tar.gz + cd openmpi-4.1.2/ && mkdir installed + ./configure --prefix=$(pwd)/installed + make all install + + - name: Build pFUnit + run: | + git clone --depth 1 --branch v4.2.2 https://github.com/Goddard-Fortran-Ecosystem/pFUnit.git pfunit-4.2.2 + mkdir pfunit-4.2.2/build && cd pfunit-4.2.2/build + cmake .. + make install + + - name: Build the tests + run: | + export PATH=$(pwd)/openmpi-4.1.2/installed/bin/:$PATH + mkdir build && cd build/ + cmake .. + make tests + env: + PFUNIT_DIR: ${{ github.workspace }}/pfunit-4.2.2/build/installed + + - name: Run unit tests + run: | + export PATH=$(pwd)/openmpi-4.1.2/installed/bin/:$PATH + export LD_LIBRARY_PATH=$(pwd)/openmpi-4.1.2/installed/lib:$LD_LIBRARY_PATH + mpirun -n 1 build/tests/tests