Skip to content

Commit 0511302

Browse files
erikwaolofk
authored andcommitted
Adapt ignored_dirs and libraries test cases to new Fusesoc class
1 parent 1e83926 commit 0511302

File tree

2 files changed

+20
-25
lines changed

2 files changed

+20
-25
lines changed

tests/test_ignored_dirs.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import tempfile
77

88
from fusesoc.config import Config
9-
from fusesoc.main import init_coremanager
9+
from fusesoc.fusesoc import Fusesoc
1010

1111
build_root = "test_build_root"
1212

@@ -43,10 +43,13 @@ def test_ignored_dirs():
4343

4444
conf0 = Config(conf_path0)
4545
assert len(conf0.ignored_dirs) == 0
46-
cm0 = init_coremanager(conf0, [td])
47-
assert len(cm0.get_cores()) == 2
46+
conf0.cores_root = td
47+
conf0.write()
48+
fs0 = Fusesoc(conf0)
49+
assert len(fs0.get_cores()) == 2
4850

4951
conf1 = Config(conf_path1)
5052
assert len(conf1.ignored_dirs) == 2
51-
cm1 = init_coremanager(conf1, [td])
52-
assert len(cm1.get_cores()) == 1
53+
conf1.cores_root = td
54+
fs1 = Fusesoc(conf1)
55+
assert len(fs1.get_cores()) == 1

tests/test_libraries.py

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
from test_common import cache_root, cores_root, library_root
1313

1414
from fusesoc.config import Config
15+
from fusesoc.fusesoc import Fusesoc
16+
from fusesoc.librarymanager import Library
1517

1618
build_root = "test_build_root"
1719

@@ -32,7 +34,6 @@
3234

3335

3436
def test_library_location():
35-
from fusesoc.main import _get_core, init_coremanager
3637

3738
with tempfile.NamedTemporaryFile(mode="w+") as tcf:
3839
tcf.write(
@@ -50,10 +51,10 @@ def test_library_location():
5051

5152
conf = Config(tcf.name)
5253

53-
cm = init_coremanager(conf, [])
54+
fs = Fusesoc(conf)
5455

55-
_get_core(cm, "mor1kx-generic")
56-
_get_core(cm, "atlys")
56+
fs.get_core("mor1kx-generic")
57+
fs.get_core("atlys")
5758

5859

5960
def test_library_add(caplog):
@@ -155,7 +156,6 @@ def test_library_add(caplog):
155156

156157

157158
def test_library_update(caplog):
158-
from fusesoc.main import init_coremanager, init_logging, update
159159

160160
clone_target = tempfile.mkdtemp()
161161

@@ -179,34 +179,28 @@ def test_library_update(caplog):
179179

180180
args = Namespace()
181181

182-
init_logging(False, False)
183-
cm = init_coremanager(conf, [])
184-
185-
# TODO find a better way to set up these defaults
186-
args.libraries = []
182+
Fusesoc.init_logging(False, False)
183+
fs = Fusesoc(conf)
187184

188185
with caplog.at_level(logging.INFO):
189-
update(cm, args)
186+
fs.update_libraries([])
190187

191188
assert "test_lib : auto-sync disabled. Ignoring update" in caplog.text
192189

193190
caplog.clear()
194191

195-
args.libraries = ["test_lib"]
196-
197192
with caplog.at_level(logging.INFO):
198-
update(cm, args)
193+
fs.update_libraries(["test_lib"])
199194

200195
assert "test_lib : Updating..." in caplog.text
201196

202197
caplog.clear()
203198

204-
args.libraries = []
205-
_library = cm._lm.get_library("test_lib")
199+
_library = fs.get_library("test_lib")
206200
_library.auto_sync = True
207201

208202
with caplog.at_level(logging.INFO):
209-
update(cm, args)
203+
fs.update_libraries([])
210204

211205
assert "test_lib : Updating..." in caplog.text
212206

@@ -216,9 +210,7 @@ def test_library_update(caplog):
216210

217211
_library.sync_type = "local"
218212

219-
args.libraries = []
220-
221213
with caplog.at_level(logging.INFO):
222-
update(cm, args)
214+
fs.update_libraries([])
223215

224216
assert "test_lib : sync-type is local. Ignoring update" in caplog.text

0 commit comments

Comments
 (0)