Skip to content

Commit

Permalink
openPMD-api: CTest & Install Tests (#25300)
Browse files Browse the repository at this point in the history
Run CTest at build time with:
```
spack install --test=root openpmd-api@<version>
```

and run smoke-tests after install and loading of the package via
```
spack load -r /<spec>
spack test run /<spec>
```
  • Loading branch information
ax3l committed Aug 6, 2021
1 parent 91b3dcc commit 98d4a7a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions var/spack/repos/builtin/packages/openpmd-api/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,23 @@ def setup_dependent_build_environment(self, env, dependent_spec):
env.prepend_path('CMAKE_PREFIX_PATH',
self.spec['mpark-variant'].prefix)
env.prepend_path('CPATH', self.spec['mpark-variant'].prefix.include)

def check(self):
"""CTest checks after the build phase"""
# note: for MPI-parallel tests, you can overwrite the standard CMake
# option -DMPIEXEC_EXECUTABLE=$(which jsrun) for jsrun or srun,
# etc.. Alternatively, you can also use -E <regex> to exclude
# parallel and MPI tests
with working_dir(self.build_directory):
# -j1 because individual tests create files that are read again by
# later tests
ctest('--output-on-failure', '-j1')

def test(self):
"""Perform smoke tests on the installed package."""
exes = ['openpmd-ls'] # in 0.11.1+
for exe in exes:
spec_vers_str = '{0}'.format(self.spec.version)
reason = 'test version of {0} is {1}'.format(exe, spec_vers_str)
self.run_test(exe, ['--version'], [spec_vers_str],
installed=True, purpose=reason, skip_missing=False)

0 comments on commit 98d4a7a

Please sign in to comment.