diff options
author | Axel Huebl <axel.huebl@plasma.ninja> | 2021-08-18 18:01:14 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-18 18:01:14 -0700 |
commit | cd91abcf880e61c63c10b0f51be67f482b2149fc (patch) | |
tree | 49d4889f9cfd85a7de7f046224bfe4e4b9975f3b | |
parent | c865aaaa0fbfe7b443d76bd8fed6b991068ddf06 (diff) | |
download | spack-cd91abcf880e61c63c10b0f51be67f482b2149fc.tar.gz spack-cd91abcf880e61c63c10b0f51be67f482b2149fc.tar.bz2 spack-cd91abcf880e61c63c10b0f51be67f482b2149fc.tar.xz spack-cd91abcf880e61c63c10b0f51be67f482b2149fc.zip |
WarpX: Check & Smoke Tests (#25352)
Run an example at build time with:
```
spack install --test=root warpx@<version>
```
Ref.: https://spack.readthedocs.io/en/latest/packaging_guide.html#stand-alone-or-smoke-tests
Run smoke-tests after install and loading of the package via
```
spack load -r /<spec>
spack test run /<spec>
```
-rw-r--r-- | var/spack/repos/builtin/packages/warpx/package.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/var/spack/repos/builtin/packages/warpx/package.py b/var/spack/repos/builtin/packages/warpx/package.py index bf2b12c8f3..03d0e3884d 100644 --- a/var/spack/repos/builtin/packages/warpx/package.py +++ b/var/spack/repos/builtin/packages/warpx/package.py @@ -135,3 +135,53 @@ class Warpx(CMakePackage): ['libwarpx.' + libsuffix[dims]], root=self.prefix, recursive=True, shared=True ) + + # WarpX has many examples to serve as a suitable smoke check. One + # that is typical was chosen here + examples_src_dir = 'Examples/Physics_applications/laser_acceleration/' + + def _get_input_options(self, post_install): + examples_dir = join_path( + self.install_test_root if post_install else self.stage.source_path, + self.examples_src_dir) + dims = self.spec.variants['dims'].value + inputs_nD = {'2': 'inputs_2d', '3': 'inputs_3d', 'rz': 'inputs_2d_rz'} + inputs = join_path(examples_dir, inputs_nD[dims]) + + cli_args = [inputs, "max_step=50", "diag1.intervals=10"] + # test openPMD output if compiled in + if '+openpmd' in self.spec: + cli_args.append('diag1.format=openpmd') + return cli_args + + def check(self): + """Checks after the build phase""" + if '+app' not in self.spec: + print("WarpX check skipped: requires variant +app") + pass + + with working_dir("spack-check", create=True): + cli_args = self._get_input_options(False) + warpx = Executable(join_path(self.build_directory, 'bin/warpx')) + warpx(*cli_args) + + @run_after('install') + def copy_test_sources(self): + """Copy the example input files after the package is installed to an + install test subdirectory for use during `spack test run`.""" + self.cache_extra_test_sources([self.examples_src_dir]) + + def test(self): + """Perform smoke tests on the installed package.""" + if '+app' not in self.spec: + print("WarpX smoke tests skipped: requires variant +app") + pass + + # our executable names are a variant-dependent and naming evolves + exe = find(self.prefix.bin, 'warpx.*', recursive=False)[0] + + cli_args = self._get_input_options(True) + self.run_test(exe, + cli_args, + [], installed=True, purpose='Smoke test for WarpX', + skip_missing=False) |