forked from spack/spack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdevelop.py
More file actions
106 lines (88 loc) · 3.56 KB
/
develop.py
File metadata and controls
106 lines (88 loc) · 3.56 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Copyright 2013-2022 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 os
import shutil
import sys
import pytest
import llnl.util.filesystem as fs
import spack.environment as ev
import spack.spec
from spack.main import SpackCommand
develop = SpackCommand('develop')
env = SpackCommand('env')
pytestmark = pytest.mark.skipif(sys.platform == "win32",
reason="does not run on windows")
@pytest.mark.usefixtures(
'mutable_mock_env_path', 'mock_packages', 'mock_fetch')
class TestDevelop(object):
def check_develop(self, env, spec, path=None):
path = path or spec.name
# check in memory representation
assert spec.name in env.dev_specs
dev_specs_entry = env.dev_specs[spec.name]
assert dev_specs_entry['path'] == path
assert dev_specs_entry['spec'] == str(spec)
# check yaml representation
yaml = ev.config_dict(env.yaml)
assert spec.name in yaml['develop']
yaml_entry = yaml['develop'][spec.name]
assert yaml_entry['spec'] == str(spec)
if path == spec.name:
# default paths aren't written out
assert 'path' not in yaml_entry
else:
assert yaml_entry['path'] == path
def test_develop_no_path_no_clone(self):
env('create', 'test')
with ev.read('test') as e:
# develop checks that the path exists
fs.mkdirp(os.path.join(e.path, 'mpich'))
develop('--no-clone', 'mpich@1.0')
self.check_develop(e, spack.spec.Spec('mpich@1.0'))
def test_develop_no_clone(self, tmpdir):
env('create', 'test')
with ev.read('test') as e:
develop('--no-clone', '-p', str(tmpdir), 'mpich@1.0')
self.check_develop(e, spack.spec.Spec('mpich@1.0'), str(tmpdir))
def test_develop(self):
env('create', 'test')
with ev.read('test') as e:
develop('mpich@1.0')
self.check_develop(e, spack.spec.Spec('mpich@1.0'))
def test_develop_no_args(self):
env('create', 'test')
with ev.read('test') as e:
# develop and remove it
develop('mpich@1.0')
shutil.rmtree(os.path.join(e.path, 'mpich'))
# test develop with no args
develop()
self.check_develop(e, spack.spec.Spec('mpich@1.0'))
def test_develop_twice(self):
env('create', 'test')
with ev.read('test') as e:
develop('mpich@1.0')
self.check_develop(e, spack.spec.Spec('mpich@1.0'))
develop('mpich@1.0')
# disk representation isn't updated unless we write
# second develop command doesn't change it, so we don't write
# but we check disk representation
e.write()
self.check_develop(e, spack.spec.Spec('mpich@1.0'))
assert len(e.dev_specs) == 1
def test_develop_update_path(self, tmpdir):
env('create', 'test')
with ev.read('test') as e:
develop('mpich@1.0')
develop('-p', str(tmpdir), 'mpich@1.0')
self.check_develop(e, spack.spec.Spec('mpich@1.0'), str(tmpdir))
assert len(e.dev_specs) == 1
def test_develop_update_spec(self):
env('create', 'test')
with ev.read('test') as e:
develop('mpich@1.0')
develop('mpich@2.0')
self.check_develop(e, spack.spec.Spec('mpich@2.0'))
assert len(e.dev_specs) == 1