Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup unit tests #24

Open
wants to merge 3 commits into
base: minimal_cmake
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ set(CMAKE_INSTALL_PREFIX ${PROJECT_BINARY_DIR})
install(TARGETS xcompact3d
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

# Build tests
add_subdirectory(tests)
6 changes: 6 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
find_package(PFUNIT REQUIRED)
enable_testing()

set(test_src test_dummy.pf)
add_pfunit_ctest(tests TEST_SOURCES ${test_src})

7 changes: 7 additions & 0 deletions tests/test_dummy.pf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@test
subroutine test_dummy()
use funit

@assertTrue(1 > 0)

end subroutine test_dummy