blob: fbdc085828e2578e5e84f2c17a8fae07b37a681c (
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# Copyright 2013-2020 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 spack.container.writers as writers
def test_manifest(minimal_configuration):
writer = writers.create(minimal_configuration)
manifest_str = writer.manifest
for line in manifest_str.split('\n'):
assert 'echo' in line
def test_build_and_run_images(minimal_configuration):
writer = writers.create(minimal_configuration)
# Test the output of run property
run = writer.run
assert run.image == 'ubuntu:18.04'
# Test the output of the build property
build = writer.build
assert build.image == 'spack/ubuntu-bionic'
assert build.tag == 'latest'
def test_packages(minimal_configuration):
# In this minimal configuration we don't have packages
writer = writers.create(minimal_configuration)
assert writer.os_packages is None
# If we add them a list should be returned
pkgs = ['libgomp1']
minimal_configuration['spack']['container']['os_packages'] = pkgs
writer = writers.create(minimal_configuration)
p = writer.os_packages
assert p.update
assert p.install
assert p.clean
assert p.list == pkgs
def test_ensure_render_works(minimal_configuration):
# Here we just want to ensure that nothing is raised
writer = writers.create(minimal_configuration)
writer()
def test_strip_is_set_from_config(minimal_configuration):
writer = writers.create(minimal_configuration)
assert writer.strip is True
minimal_configuration['spack']['container']['strip'] = False
writer = writers.create(minimal_configuration)
assert writer.strip is False
def test_extra_instructions_is_set_from_config(minimal_configuration):
writer = writers.create(minimal_configuration)
assert writer.extra_instructions == (None, None)
test_line = 'RUN echo Hello world!'
e = minimal_configuration['spack']['container']
e['extra_instructions'] = {}
e['extra_instructions']['build'] = test_line
writer = writers.create(minimal_configuration)
assert writer.extra_instructions == (test_line, None)
e['extra_instructions']['final'] = test_line
del e['extra_instructions']['build']
writer = writers.create(minimal_configuration)
assert writer.extra_instructions == (None, test_line)
|