Skip to content

Commit

Permalink
Merge pull request #89 from nordmoen/feature_unit_testing
Browse files Browse the repository at this point in the history
Initial unit testing implementation
  • Loading branch information
matsbn authored May 10, 2021
2 parents 6766632 + cedf1ef commit 26db3ed
Show file tree
Hide file tree
Showing 8 changed files with 697 additions and 16 deletions.
60 changes: 46 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,64 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-10.15]
os: [ubuntu-latest, macos-latest]
mpi: [true, false]
openmp: ['enabled', 'disabled']
exclude:
# Do not build on macOS with MPI as that is having some dependency issues
- os: macos-latest
mpi: true
steps:
- name: Install dependencies - Ubuntu
run: |
sudo apt update
sudo apt install -y libnetcdff-dev mpi-default-dev
sudo apt install -y libnetcdff-dev mpi-default-dev ninja-build
if: runner.os == 'Linux'

- name: Install dependencies - macOS
run: brew install netcdf open-mpi
run: brew install netcdf open-mpi ninja
env:
HOMEBREW_NO_INSTALL_CLEANUP: 1
if: runner.os == 'macOS'

- name: Checkout code
uses: actions/checkout@v2

- name: Setup Python for newer version of Meson
uses: actions/setup-python@v2

- name: Run Meson build step
uses: BSFishy/[email protected]
- name: Install Meson
run: python -m pip install meson==${{ env.MESON_VERSION }}

- name: Checkout code
uses: actions/checkout@v2

- name: Build
env:
CC: gcc-10
FC: gfortran-10
run: |
meson setup builddir -Dmpi=${{ matrix.mpi }} -Dopenmp=${{ matrix.openmp }} --buildtype=debugoptimized
meson compile -C builddir
- name: Test code
if: ${{ matrix.mpi == false }}
run: |
ulimit -s 65532
meson test -C builddir
- name: Upload test log
if: ${{ matrix.mpi == false }}
uses: actions/upload-artifact@v2
with:
action: build
directory: builddir
setup-options: -Dmpi=${{ matrix.mpi }}
meson-version: ${{ env.MESON_VERSION }}
name: testlog-${{ runner.os }}-gcc
path: builddir/meson-logs/testlog.txt

intel:
name: Build BLOM using Intel compilers
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
mpi: [true, false]
openmp: ['enabled', 'disabled']
# Tell Meson to use Intel compilers
env:
CC: icc
Expand All @@ -59,7 +79,6 @@ jobs:
run: |
sudo apt update
sudo apt install -y ninja-build libnetcdf-dev
- name: Cache Intel setup
id: cache-intel
uses: actions/cache@v2
Expand Down Expand Up @@ -117,5 +136,18 @@ jobs:
- name: Build with Intel compilers
run: |
source /opt/intel/oneapi/setvars.sh
meson setup builddir -Dmpi=${{ matrix.mpi }}
meson setup builddir -Dmpi=${{ matrix.mpi }} -Dopenmp=${{ matrix.openmp }} --buildtype=debugoptimized
meson compile -C builddir
- name: Test code
if: ${{ matrix.mpi == false }}
run: |
source /opt/intel/oneapi/setvars.sh
meson test -C builddir
- name: Upload test log
uses: actions/upload-artifact@v2
if: ${{ matrix.mpi == false }}
with:
name: testlog-${{ runner.os }}-intel
path: builddir/meson-logs/testlog.txt
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,25 @@ $ meson compiler -C builddir
After the first line all subsequent compiles (and changes with `meson
configure`) will utilize the Intel compiler to build and link BLOM.

### Running tests
After successfully building the code it can be a good idea to test that the code
behaves as expected and changes to the code does not affect the output.

Tests can be run with the following:

```bash
$ meson test -C builddir
```

The previous command will run all the test suites defined for BLOM. To run tests
quicker one can select a few tests to run or just a single test suite. To list
the available tests run `meson test -C builddir --list`. One can then run a
single test with:

```bash
$ meson test -C builddir "run single_column"
```

### Working with the BLOM git repository

The [BLOM wiki](https://github.com/NorESMhub/BLOM/wiki) includes instructions on how to contribute to the BLOM/iHAMOCC model system, and how to work with the BLOM git repository with your own fork on gitHub.
Expand Down
7 changes: 5 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ deps = [netcdf, omp, quadmath]
includes = [phy_inc]

# List of all sources in the project (should be added to in subfolders)
sources = [dimensions]
sources = []

# Process the following subdirectories which contain other 'meson.build' files
# that will add files to build into 'sources'
Expand Down Expand Up @@ -138,8 +138,11 @@ if get_option('parallel_netcdf')
endif
endif

# Handle Unit Testing
subdir('tests')

# Create BLOM executable
executable('blom', sources,
executable('blom', sources, dimensions,
include_directories: includes,
dependencies: deps,
link_language: 'fortran')
9 changes: 9 additions & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Ignore test output files
*.nc
rstdate.txt
run.status
salbud
tembud
tkebud
trcbud
trcbudtot
Loading

0 comments on commit 26db3ed

Please sign in to comment.