Skip to content

Commit 152c8d7

Browse files
Rafael SarmientoRafael Sarmiento
authored andcommitted
using automatic spack env creation
1 parent 7dc61b9 commit 152c8d7

File tree

3 files changed

+15
-39
lines changed

3 files changed

+15
-39
lines changed

docs/tutorial_build_automation.rst

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -110,52 +110,36 @@ Here is the test's code:
110110

111111
When :attr:`~reframe.core.pipeline.RegressionTest.build_system` is set to ``'Spack'``, ReFrame will leverage Spack environments in order to build the test code.
112112
If the environment is not specified by the user, ReFrame will automatically create one inside the stage directory.
113-
ReFrame treats Spack environments specified by the user as *test resources* so it expects to find them under the test's :attr:`~reframe.core.pipeline.RegressionTest.sourcesdir`, which defaults to ``'src'``.
114-
Here is the directory structure for the test in this particular example that we show here:
115-
116-
.. code:: console
117-
118-
tutorials/build_systems/spack/
119-
├── spack_test.py
120-
└── src
121-
└── myenv
122-
└── spack.yaml
123-
124-
125-
We could have placed ``spack.yaml`` directly under the ``src/`` directory, in which case we would need to specify ``'.'`` as an environment.
126-
For reference, here are the contents of ``spack.yaml``:
127-
128-
.. literalinclude:: ../tutorials/build_systems/spack/src/myenv/spack.yaml
113+
That's the case in this example, where the software to be built is specified through the attribute :attr:`~reframe.core.buildsystems.Spack.specs`
129114

115+
When Spack environments are specified by the user, ReFrame treats them as *test resources* so it expects to find them under the test's :attr:`~reframe.core.pipeline.RegressionTest.sourcesdir`, which defaults to ``'src'``.
130116

131117
As with every other test, ReFrame will copy the test's resources to its stage directory before building it.
132-
ReFrame will then activate the environment and install the associated specs as in this case.
133-
Optionally, we can add more specs to the environment by setting the :attr:`~reframe.core.buildsystems.Spack.specs` attribute of the build system.
118+
ReFrame will then activate the generated environment, add the given specs using the ``spack add`` command and install them.
134119
Here is what ReFrame generates as a build script in this example:
135120

136121
.. code:: bash
137122
138123
. "$(spack location --spack-root)/share/spack/setup-env.sh"
139-
spack env activate -V -d myenv
124+
spack env create -d rfm_spack_env
125+
spack env activate -V -d rfm_spack_env
126+
spack config add "config:install_tree:root:opt/spack"
127+
140128
spack install
141129
142-
Any additional specs specified inside the ReFrame test will be added using the ``spack add`` command.
143130
As you might have noticed ReFrame expects that Spack is already installed on the system.
144131
The packages specified in the environment and the tests will be installed in the test's stage directory, where the environment is copied before building.
145132
Here is the stage directory structure:
146133

147134
.. code:: console
148135
149136
stage/generic/default/builtin/BZip2SpackCheck/
150-
├── myenv
137+
├── rfm_spack_env
151138
│   ├── spack
152-
│   │   ├── opt
153-
│   │   │   └── spack
154-
│   │   │   ├── bin
155-
│   │   │   └── darwin-catalina-skylake
156-
│   │   └── share
157-
│   │   └── spack
158-
│   │   └── modules
139+
│   │   └── opt
140+
│   │      └── spack
141+
│   │      ├── bin
142+
│   │      └── darwin-catalina-skylake
159143
│   ├── spack.lock
160144
│   └── spack.yaml
161145
├── rfm_BZip2SpackCheck_build.err
@@ -172,7 +156,9 @@ Finally, here is the generated run script that ReFrame uses to run the test, onc
172156
173157
#!/bin/bash
174158
. "$(spack location --spack-root)/share/spack/setup-env.sh"
175-
spack env activate -V -d myenv
159+
spack env create -d rfm_spack_env
160+
spack env activate -V -d rfm_spack_env
161+
spack load [email protected]
176162
bzip2 --help
177163
178164
From this point on, sanity and performance checking are exactly identical to any other ReFrame test.

tutorials/build_systems/spack/spack_test.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class BZip2SpackCheck(rfm.RegressionTest):
1818

1919
@run_before('compile')
2020
def setup_build_system(self):
21-
self.build_system.environment = 'myenv'
2221
self.build_system.specs = ['[email protected]']
2322

2423
@sanity_function

tutorials/build_systems/spack/src/myenv/spack.yaml

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)