Example #1
0
def test_library_update(caplog):
    from fusesoc.main import update, init_coremanager, init_logging

    clone_target = tempfile.mkdtemp()

    try:
        subprocess.call(['git', 'clone', sync_uri, clone_target])

        tcf = tempfile.TemporaryFile(mode="w+")
        tcf.write(
            EXAMPLE_CONFIG.format(build_root=build_root,
                                  cache_root=cache_root,
                                  cores_root=clone_target,
                                  library_root=library_root,
                                  auto_sync='false',
                                  sync_uri=sync_uri))
        tcf.seek(0)

        conf = Config(file=tcf)

        args = Namespace()

        init_logging(False, False)
        cm = init_coremanager(conf, [])

        # TODO find a better way to set up these defaults
        args.libraries = []

        with caplog.at_level(logging.INFO):
            update(cm, args)

        assert not "Updating 'test_lib'" in caplog.text

        caplog.clear()

        args.libraries = ['test_lib']

        with caplog.at_level(logging.INFO):
            update(cm, args)

        assert "Updating 'test_lib'" in caplog.text

        caplog.clear()

        args.libraries = []
        conf.libraries['test_lib']['auto-sync'] = True

        with caplog.at_level(logging.INFO):
            update(cm, args)

        assert "Updating 'test_lib'" in caplog.text

        caplog.clear()

    finally:
        shutil.rmtree(clone_target)
Example #2
0
def test_library_location():
    from fusesoc.main import _get_core, init_coremanager

    tcf = tempfile.TemporaryFile(mode="w+")
    tcf.write(
        EXAMPLE_CONFIG.format(build_root=build_root,
                              cache_root=cache_root,
                              cores_root=cores_root,
                              library_root=library_root,
                              auto_sync='false',
                              sync_uri=sync_uri))
    tcf.seek(0)

    conf = Config(file=tcf)
    cm = init_coremanager(conf, [])

    _get_core(cm, 'mor1kx-generic')
    _get_core(cm, 'atlys')
def test_library_update(caplog):
    from fusesoc.main import update, init_coremanager, init_logging

    clone_target = tempfile.mkdtemp()

    subprocess.call(["git", "clone", sync_uri, clone_target])

    tcf = tempfile.TemporaryFile(mode="w+")
    tcf.write(
        EXAMPLE_CONFIG.format(
            build_root=build_root,
            cache_root=cache_root,
            cores_root=clone_target,
            library_root=library_root,
            auto_sync="false",
            sync_uri=sync_uri,
            sync_type="git",
        ))
    tcf.seek(0)

    conf = Config(file=tcf)

    args = Namespace()

    init_logging(False, False)
    cm = init_coremanager(conf, [])

    # TODO find a better way to set up these defaults
    args.libraries = []

    with caplog.at_level(logging.INFO):
        update(cm, args)

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

    caplog.clear()

    args.libraries = ["test_lib"]

    with caplog.at_level(logging.INFO):
        update(cm, args)

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

    caplog.clear()

    args.libraries = []
    _library = cm._lm.get_library("test_lib")
    _library.auto_sync = True

    with caplog.at_level(logging.INFO):
        update(cm, args)

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

    caplog.clear()

    tcf.close()

    _library.sync_type = "local"

    args.libraries = []

    with caplog.at_level(logging.INFO):
        update(cm, args)

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