summaryrefslogtreecommitdiff
path: root/lib/spack/spack/test/container/conftest.py
blob: 974fe4438bf382d454cda59e3ed005d9d7930aa1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Copyright 2013-2024 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
import pytest

import spack.util.spack_yaml as syaml


@pytest.fixture()
def minimal_configuration():
    return {
        "spack": {
            "specs": ["gromacs", "mpich", "fftw precision=float"],
            "container": {
                "format": "docker",
                "images": {"os": "ubuntu:18.04", "spack": "develop"},
            },
        }
    }


@pytest.fixture()
def config_dumper(tmpdir):
    """Function that dumps an environment config in a temporary folder."""

    def dumper(configuration):
        content = syaml.dump(configuration, default_flow_style=False)
        config_file = tmpdir / "spack.yaml"
        config_file.write(content)
        return str(tmpdir)

    return dumper


@pytest.fixture()
def container_config_dir(minimal_configuration, config_dumper):
    return config_dumper(minimal_configuration)