Beispiel #1
0
def test_post_add(tmpdir, toolchain_db):
    """ Test Post Add """
    boost = tmpdir.mkdir("boost")
    script = boost.join("post-add.sh")
    script.write(
        '#!/bin/sh\n'
        'echo $@ > foobar\n'
    )
    os.chmod(script.strpath, 0o755)
    boost_package = tmpdir.join("boost-1.58.zip")
    qisys.archive.compress(boost.strpath, output=boost_package.strpath)
    feed = tmpdir.join("feed.xml")
    feed.write("""
<toolchain>
<package name="boost" version="1.58" url="{url}" post-add="post-add.sh hello world" />
</toolchain>\n""".format(url="file://" + boost_package.strpath))
    print(boost.strpath)
    print(script.strpath)
    print(boost_package.strpath)
    print(feed.strpath)
    toolchain_db.update(feed.strpath)
    boost_in_db = toolchain_db.get_package("boost")
    with open(os.path.join(boost_in_db.path, 'foobar')) as f:
        txt = f.read()
    assert "hello world" in txt
def test_package_removed_from_feed(toolchain_db, feed):
    """ Test Package Removed from Feed """
    boost_package = qitoolchain.qipackage.QiPackage("boost", version="1.42")
    feed.add_package(boost_package)
    toolchain_db.update(feed.url)
    boost_path = toolchain_db.get_package_path("boost")
    feed.remove_package("boost")
    toolchain_db.update(feed.url)
    assert not toolchain_db.packages
    assert not os.path.exists(boost_path)
Beispiel #3
0
def test_package_removed_from_feed(toolchain_db, feed):
    """ Test Package Removed from Feed """
    boost_package = qitoolchain.qipackage.QiPackage("boost", version="1.42")
    feed.add_package(boost_package)
    toolchain_db.update(feed.url)
    boost_path = toolchain_db.get_package_path("boost")
    feed.remove_package("boost")
    toolchain_db.update(feed.url)
    assert not toolchain_db.packages
    assert not os.path.exists(boost_path)
Beispiel #4
0
def test_downgrading_package(toolchain_db, feed):
    """ Test Downgrading Package """
    boost_package = qitoolchain.qipackage.QiPackage("boost", version="1.44")
    feed.add_package(boost_package)
    toolchain_db.update(feed.url)
    assert toolchain_db.packages["boost"] == boost_package
    feed.remove_package("boost")
    old_boost_package = qitoolchain.qipackage.QiPackage("boost", version="1.42")
    feed.add_package(old_boost_package)
    toolchain_db.update(feed.url)
    assert toolchain_db.packages["boost"] == old_boost_package
Beispiel #5
0
def test_downloads_only_once(toolchain_db, feed):
    """ Test Download Only Once """
    boost_package = qitoolchain.qipackage.QiPackage("boost", version="1.42")
    feed.add_package(boost_package, with_path=False, with_url=True)
    with mock.patch.object(qisys.remote, "download") as mock_dl:
        with mock.patch.object(qitoolchain.qipackage, "extract") as mock_extract:
            mock_dl.return_value = "/path/to/boost.zip"
            toolchain_db.update(feed.url)
            toolchain_db.update(feed.url)
    assert mock_dl.call_count == 1
    assert mock_extract.call_count == 1
    assert mock_extract.call_args_list[0][0][0] == "/path/to/boost.zip"
Beispiel #6
0
def test_update(toolchain_db, feed):
    """ Test Update """
    boost_package = qitoolchain.qipackage.QiPackage("boost", version="1.42")
    boost_package.path = "/path/to/boost"
    feed.add_package(boost_package)
    toolchain_db.update(feed.url)
    assert toolchain_db.packages["boost"] == boost_package
    new_boost_package = qitoolchain.qipackage.QiPackage("boost", version="1.44")
    new_boost_package.path = "/path/to/boost"
    feed.add_package(new_boost_package)
    toolchain_db.update(feed.url)
    assert toolchain_db.packages["boost"] == new_boost_package
def test_package_with_flags(tmpdir, toolchain_db):
    """ Test Package With Flags """
    feed = tmpdir.join("feed.xml")
    x_tools = tmpdir.join("x-tools")
    x_tools.ensure("sysroot", dir=True)
    x_tools.join("toolchain.cmake").ensure(file=True)
    x_tools.join("package.xml").write(
        """\n<package name="x_tools" version="0.1" toolchain_file="toolchain.cmake" />\n"""
    )
    x_tools_package = tmpdir.join("x-tools-0.1.zip")
    qisys.archive.compress(x_tools.strpath,
                           output=x_tools_package.strpath,
                           flat=True)
    feed.write(
        """\n<toolchain>\n  <package name="x-tools" version="0.1" url="{url}" />\n</toolchain>\n"""
        .format(url="file://" + x_tools_package.strpath))
    toolchain_db.update(feed.strpath)
    x_tools_in_db = toolchain_db.get_package("x-tools")
    assert x_tools_in_db.toolchain_file
Beispiel #8
0
def test_package_with_flags(tmpdir, toolchain_db):
    """ Test Package With Flags """
    feed = tmpdir.join("feed.xml")
    x_tools = tmpdir.join("x-tools")
    x_tools.ensure("sysroot", dir=True)
    x_tools.join("toolchain.cmake").ensure(file=True)
    x_tools.join("package.xml").write(
        """\n<package name="x_tools" version="0.1" toolchain_file="toolchain.cmake" />\n"""
    )
    x_tools_package = tmpdir.join("x-tools-0.1.zip")
    qisys.archive.compress(x_tools.strpath, output=x_tools_package.strpath, flat=True)
    feed.write(
        """\n<toolchain>\n  <package name="x-tools" version="0.1" url="{url}" />\n</toolchain>\n""".format(
            url="file://" + x_tools_package.strpath
        )
    )
    toolchain_db.update(feed.strpath)
    x_tools_in_db = toolchain_db.get_package("x-tools")
    assert x_tools_in_db.toolchain_file
def test_downloads_remote_package(toolchain_db, feed):
    """ Test Dowbnload Remote Package """
    boost_package = qitoolchain.qipackage.QiPackage("boost", version="1.42")
    feed.add_package(boost_package, with_path=False, with_url=True)
    toolchain_db.update(feed.url)
    assert toolchain_db.packages["boost"].path
Beispiel #10
0
def test_downloads_remote_package(toolchain_db, feed):
    """ Test Dowbnload Remote Package """
    boost_package = qitoolchain.qipackage.QiPackage("boost", version="1.42")
    feed.add_package(boost_package, with_path=False, with_url=True)
    toolchain_db.update(feed.url)
    assert toolchain_db.packages["boost"].path