Exemplo n.º 1
0
def test_set_default_config(cd_to_tmpdir):
    qibuild.config.add_build_config("foo")
    build_worktree = TestBuildWorkTree()
    build_worktree.set_default_config("foo")
    assert build_worktree.default_config == "foo"
    build_worktree2 = TestBuildWorkTree()
    assert build_worktree2.default_config == "foo"
Exemplo n.º 2
0
def test_simple(qilinguist_action, record_messages):
    """ Test Simple """
    build_worktree = TestBuildWorkTree()
    build_worktree.add_test_project("translateme/qt")
    qilinguist_action("list")
    assert record_messages.find("\\*\\s+helloqt")
    assert record_messages.find("\\*\\s+translate")
Exemplo n.º 3
0
def test_qt(qilinguist_action):
    build_worktree = TestBuildWorkTree()
    project = build_worktree.add_test_project("translateme/qt")
    try:
        project.configure()
    except Exception:
        print "Qt not installed, skipping"
        return
    project.build()
    qilinguist_action("update", "helloqt")
    # Translate in French:
    fr_ts = os.path.join(project.path, "po", "fr_FR.ts")
    tree = qisys.qixml.read(fr_ts)
    root = tree.getroot()
    tr_elem = root.find("context/message/translation")
    assert tr_elem is not None
    tr_elem.attrib.clear()
    tr_elem.text = "Bonjour, monde"
    qisys.qixml.write(root, fr_ts)
    qilinguist_action("release", "helloqt")
    translateme = qibuild.find.find([project.sdk_directory], "translateme")
    cmd = [translateme,
           os.path.join(project.path, "po"),
           "fr_FR"]
    process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
    (out, _) = process.communicate()

    assert "Bonjour, monde" in out
Exemplo n.º 4
0
def test_set_default_config(cd_to_tmpdir):  # pylint: disable=unused-argument
    qibuild.config.add_build_config("foo")
    build_worktree = TestBuildWorkTree()
    build_worktree.set_default_config("foo")
    assert build_worktree.default_config == "foo"
    build_worktree2 = TestBuildWorkTree()
    assert build_worktree2.default_config == "foo"
Exemplo n.º 5
0
def test_when_is_default(qibuild_action):
    qibuild_action("add-config", "foo", "--default")
    build_worktree = TestBuildWorkTree()
    assert build_worktree.build_config.active_build_config.name == "foo"
    qibuild_action("rm-config", "foo")
    build_worktree2 = TestBuildWorkTree()
    assert build_worktree2.build_config.active_build_config is None
Exemplo n.º 6
0
def test_changing_active_config_changes_projects_build_dir(cd_to_tmpdir):
    """ Test Changing Active Config Changes Projects Build Dir """
    qibuild.config.add_build_config("foo")
    build_worktree = TestBuildWorkTree()
    build_worktree.set_active_config("foo")
    world_proj = build_worktree.create_project("world")
    assert "foo" in world_proj.build_directory
Exemplo n.º 7
0
def test_qt(qilinguist_action):
    """ Test Qt """
    build_worktree = TestBuildWorkTree()
    project = build_worktree.add_test_project("translateme/qt")
    try:
        project.configure()
    except Exception:
        print("Qt not installed, skipping")
        return
    project.build()
    qilinguist_action("update", "helloqt")
    # Translate in French:
    fr_ts = os.path.join(project.path, "po", "fr_FR.ts")
    tree = qisys.qixml.read(fr_ts)
    root = tree.getroot()
    tr_elem = root.find("context/message/translation")
    assert tr_elem is not None
    tr_elem.attrib.clear()
    tr_elem.text = "Bonjour, monde"
    qisys.qixml.write(root, fr_ts)
    qilinguist_action("release", "helloqt")
    translateme = qibuild.find.find([project.sdk_directory], "translateme")
    cmd = [translateme, os.path.join(project.path, "po"), "fr_FR"]
    process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
    (out, _) = process.communicate()
    assert "Bonjour, monde" in out
Exemplo n.º 8
0
def test_set_default_config(cd_to_tmpdir):
    qibuild.config.add_build_config("foo")
    build_worktree = TestBuildWorkTree()
    build_worktree.set_default_config("foo")
    assert build_worktree.default_config == "foo"
    build_worktree2 = TestBuildWorkTree()
    assert build_worktree2.default_config == "foo"
Exemplo n.º 9
0
def test_when_is_default(qitoolchain_action):
    qitoolchain_action("create", "foo")
    qibuild.config.add_build_config("foo", toolchain="foo")
    test_build_worktre1 = TestBuildWorkTree()
    test_build_worktre1.set_default_config("foo")
    qitoolchain_action("remove", "foo", "--force")
    test_build_worktre2 = TestBuildWorkTree()
    assert test_build_worktre2.toolchain is None
Exemplo n.º 10
0
def test_set_pythonhome(toolchains, cd_to_tmpdir):
    toolchains.create("foo")
    qibuild.config.add_build_config("foo", toolchain="foo")
    python_package = toolchains.add_package("foo", "python")
    build_worktree = TestBuildWorkTree()
    build_worktree.set_active_config("foo")
    env = build_worktree.get_env()
    assert env["PYTHONHOME"] == python_package.path
Exemplo n.º 11
0
def test_profiles_from_config(cd_to_tmpdir):
    qibuild.config.add_build_config("foo", profiles=["bar"])
    build_worktree = TestBuildWorkTree()
    local_xml = build_worktree.qibuild_xml
    qibuild.profile.configure_build_profile(local_xml, "bar", [("WITH_BAR", "ON")])
    build_worktree.set_active_config("foo")
    build_config = build_worktree.build_config
    assert build_config.profiles == ["bar"]
    assert build_config.cmake_args == ["-DCMAKE_BUILD_TYPE=Debug", "-DWITH_BAR=ON"]
Exemplo n.º 12
0
def test_using_custom_profile(qibuild_action, qisrc_action, git_server):
    git_server.add_build_profile("foo", [("WITH_FOO", "ON")])
    qisrc_action("init", git_server.manifest_url)
    build_worktree = TestBuildWorkTree()
    qibuild_xml = build_worktree.qibuild_xml
    qibuild.profile.configure_build_profile(qibuild_xml, "bar", [("WITH_BAR", "ON")])
    build_worktree.create_project("spam")
    qibuild.config.add_build_config("foo", profiles=["foo"])
    qibuild.config.add_build_config("bar", profiles=["bar"])
    qibuild_action("configure", "spam", "--config", "foo", "--summarize-options")
    qibuild_action("configure", "spam", "--config", "bar", "--summarize-options")
Exemplo n.º 13
0
def test_when_is_default(qitoolchain_action):
    qitoolchain_action("create", "foo")
    qibuild.config.add_build_config("foo", toolchain="foo")
    test_build_worktre1 = TestBuildWorkTree()
    test_build_worktre1.set_default_config("foo")
    qitoolchain_action("remove", "foo", "--force")
    test_build_worktre2 = TestBuildWorkTree()
    # pylint:disable-msg=E1101
    with pytest.raises(Exception) as e:
        test_build_worktre2.toolchain  # pylint: disable=pointless-statement
    assert "No such toolchain" in e.value.message
Exemplo n.º 14
0
def test_set_pythonhome(toolchains, cd_to_tmpdir):
    toolchains.create("foo")
    qibuild.config.add_build_config("foo", toolchain="foo")
    python_package = toolchains.add_package("foo", "python")
    build_worktree = TestBuildWorkTree()
    build_worktree.set_active_config("foo")
    env = build_worktree.get_env()
    if sys.platform == "darwin":
        assert env["PYTHONHOME"] == python_package.path + "/Python.framework/Versions/2.7"
    else:
        assert env["PYTHONHOME"] == python_package.path
Exemplo n.º 15
0
def test_set_pythonhome(toolchains, cd_to_tmpdir):
    toolchains.create("foo")
    qibuild.config.add_build_config("foo", toolchain="foo")
    python_package = toolchains.add_package("foo", "python")
    build_worktree = TestBuildWorkTree()
    build_worktree.set_active_config("foo")
    env = build_worktree.get_env()
    if sys.platform == "darwin":
        assert env["PYTHONHOME"] == python_package.path + "/Python.framework/Versions/2.7"
    else:
        assert env["PYTHONHOME"] == python_package.path
Exemplo n.º 16
0
def test_when_is_default(qitoolchain_action):
    """ Test When Is Default """
    qitoolchain_action("create", "foo")
    qibuild.config.add_build_config("foo", toolchain="foo")
    test_build_worktre1 = TestBuildWorkTree()
    test_build_worktre1.set_default_config("foo")
    qitoolchain_action("remove", "foo", "--force")
    test_build_worktre2 = TestBuildWorkTree()
    with pytest.raises(Exception) as e:
        test_build_worktre2.toolchain  # pylint:disable=pointless-statement
    assert "No such toolchain" in e.value.message
Exemplo n.º 17
0
def test_when_is_default(qitoolchain_action):
    qitoolchain_action("create", "foo")
    qibuild.config.add_build_config("foo", toolchain="foo")
    test_build_worktre1 = TestBuildWorkTree()
    test_build_worktre1.set_default_config("foo")
    qitoolchain_action("remove", "foo", "--force")
    test_build_worktre2 = TestBuildWorkTree()
    # pylint:disable-msg=E1101
    with pytest.raises(Exception) as e:
        test_build_worktre2.toolchain
    assert "No such toolchain" in e.value.message
Exemplo n.º 18
0
def test_bad_qibuild_config_with_qitest_json(args, qibuild_action, monkeypatch):
    qibuild_action.add_test_project("testme")
    qibuild_action("add-config", "foo")
    qibuild_action("configure", "--config", "foo", "testme")
    build_worktree = TestBuildWorkTree()
    build_worktree.set_active_config("foo")
    testme_proj = build_worktree.get_build_project("testme")
    testme_sdk = testme_proj.sdk_directory
    qitest_json = os.path.join(testme_sdk, "qitest.json")
    monkeypatch.chdir(testme_proj.path)
    args.qitest_jsons = [qitest_json]
    test_runners = qitest.parsers.get_test_runners(args)
Exemplo n.º 19
0
def test_using_custom_profile(qibuild_action, qisrc_action, git_server):
    git_server.add_build_profile("foo", [("WITH_FOO", "ON")])
    qisrc_action("init", git_server.manifest_url)
    build_worktree = TestBuildWorkTree()
    qibuild_xml = build_worktree.qibuild_xml
    qibuild.profile.configure_build_profile(qibuild_xml, "bar",
                                            [("WITH_BAR", "ON")])
    build_worktree.create_project("spam")
    qibuild_action("configure", "spam", "--profile", "foo",
                   "--summarize-options")
    qibuild_action("configure", "spam", "--profile", "bar",
                   "--summarize-options")
Exemplo n.º 20
0
def test_pure_c_project(qibuild_action, tmpdir):
    """ Test Pure C Project """
    work = tmpdir.join("work")
    foo1 = work.mkdir("foo")
    foo1.join("CMakeLists.txt").write("""\ncmake_minimum_required(VERSION 3.0)\nproject(foo C)\n""")
    qibuild_action.chdir(foo1.strpath)
    qibuild_action("convert", "--go")
    qibuild_action.chdir(work.strpath)
    build_worktree = TestBuildWorkTree()
    worktree = build_worktree.worktree
    worktree.add_project("foo")
    assert build_worktree.get_build_project("foo")
Exemplo n.º 21
0
def test_profiles_from_config(cd_to_tmpdir):
    """ Test Profiles From Config """
    qibuild.config.add_build_config("foo", profiles=["bar"])
    build_worktree = TestBuildWorkTree()
    local_xml = build_worktree.qibuild_xml
    qibuild.profile.configure_build_profile(local_xml, "bar", [("WITH_BAR", "ON")])
    build_worktree.set_active_config("foo")
    build_config = build_worktree.build_config
    assert build_config.profiles == ["bar"]
    cmake_args = build_config.cmake_args
    cmake_args = [x for x in cmake_args if "VIRTUALENV" not in x]
    assert cmake_args == ["-DCMAKE_BUILD_TYPE=Debug", "-DWITH_BAR=ON"]
Exemplo n.º 22
0
def test_profiles_from_config(cd_to_tmpdir):
    qibuild.config.add_build_config("foo", profiles=["bar"])
    build_worktree = TestBuildWorkTree()
    local_xml = build_worktree.qibuild_xml
    qibuild.profile.configure_build_profile(local_xml, "bar",
                                            [("WITH_BAR", "ON")])
    build_worktree.set_active_config("foo")
    build_config = build_worktree.build_config
    assert build_config.profiles == ["bar"]
    cmake_args = build_config.cmake_args
    cmake_args = [x for x in cmake_args if not "VIRTUALENV" in x]
    assert cmake_args == ["-DCMAKE_BUILD_TYPE=Debug", "-DWITH_BAR=ON"]
Exemplo n.º 23
0
def test_warns_on_conflict(qibuild_action, qisrc_action, git_server,
                           record_messages):
    git_server.add_build_profile("foo", [("WITH_FOO", "ON")])
    qisrc_action("init", git_server.manifest_url)
    build_worktree = TestBuildWorkTree()
    qibuild_xml = build_worktree.qibuild_xml
    qibuild.profile.configure_build_profile(qibuild_xml, "foo", [("WITH_FOO", "OFF")])
    build_worktree.create_project("spam")
    qibuild.config.add_build_config("foo", profiles=["foo"])
    record_messages.reset()
    qibuild_action("configure", "spam", "--config", "foo", "--summarize-options")
    assert record_messages.find("WITH_FOO\s+: OFF")
    assert record_messages.find("WARN")
Exemplo n.º 24
0
def test_no_duplicate_deps(cd_to_tmpdir, args):
    args.dep_types = "default"
    build_worktree = TestBuildWorkTree()
    foo = build_worktree.create_project("foo", run_depends=["bar"])
    build_worktree.create_project("bar", src="foo/bar")
    git = qisrc.git.Git(foo.path)
    git.init()
    git_worktree = TestGitWorkTree()

    with qisys.sh.change_cwd(cd_to_tmpdir.join("foo").strpath):
        projs = get_git_projects(git_worktree, args, default_all=True,
                                 use_build_deps=True)
    assert projs == [foo]
Exemplo n.º 25
0
def test_new_syntax(build_worktree):
    world_proj = build_worktree.create_project("world")
    with open(world_proj.qiproject_xml, "w") as fp:
        fp.write("""
<project format="3">
  <version>0.42</version>
  <qibuild name="world" />
</project>
""")
    build_worktree = TestBuildWorkTree()
    world_proj = build_worktree.get_build_project("world")
    assert world_proj.name == "world"
    assert world_proj.version == "0.42"
Exemplo n.º 26
0
def test_pure_c_project(qibuild_action, tmpdir):
    """ Test Pure C Project """
    work = tmpdir.join("work")
    foo1 = work.mkdir("foo")
    foo1.join("CMakeLists.txt").write(
        """\ncmake_minimum_required(VERSION 3.0)\nproject(foo C)\n""")
    qibuild_action.chdir(foo1.strpath)
    qibuild_action("convert", "--go")
    qibuild_action.chdir(work.strpath)
    build_worktree = TestBuildWorkTree()
    worktree = build_worktree.worktree
    worktree.add_project("foo")
    assert build_worktree.get_build_project("foo")
Exemplo n.º 27
0
def test_no_duplicate_deps(cd_to_tmpdir, args):
    args.dep_types = "default"
    build_worktree = TestBuildWorkTree()
    foo = build_worktree.create_project("foo", run_depends=["bar"])
    build_worktree.create_project("bar", src="foo/bar")
    git = qisrc.git.Git(foo.path)
    git.init()
    git_worktree = TestGitWorkTree()

    with qisys.sh.change_cwd(cd_to_tmpdir.join("foo").strpath):
        projs = get_git_projects(git_worktree, args, default_all=True,
                                 use_build_deps=True)
    assert projs == [foo]
Exemplo n.º 28
0
def test_profiles_from_config(cd_to_tmpdir):
    qibuild.config.add_build_config("foo", profiles=["bar"])
    build_worktree = TestBuildWorkTree()
    local_xml = build_worktree.qibuild_xml
    qibuild.profile.configure_build_profile(local_xml, "bar", [("WITH_BAR", "ON")])
    build_worktree.set_active_config("foo")
    build_config = build_worktree.build_config
    assert build_config.profiles == ["bar"]
    # build_config.cmake contains qibuild_DIR, CMAKE_BUILD_TYPE, and
    # QI_VIRTUALENV_PATH, which are not relevant to this test
    cmake_args = build_config.cmake_args
    cmake_args = [x for x in cmake_args if "WITH" in x]
    assert cmake_args == ["-DWITH_BAR=ON"]
Exemplo n.º 29
0
def test_bad_qibuild_config_with_qitest_json(args, qibuild_action,
                                             monkeypatch):
    qibuild_action.add_test_project("testme")
    qibuild_action("add-config", "foo")
    qibuild_action("configure", "--config", "foo", "testme")
    build_worktree = TestBuildWorkTree()
    build_worktree.set_active_config("foo")
    testme_proj = build_worktree.get_build_project("testme")
    testme_sdk = testme_proj.sdk_directory
    qitest_json = os.path.join(testme_sdk, "qitest.json")
    monkeypatch.chdir(testme_proj.path)
    args.qitest_jsons = [qitest_json]
    test_runners = qitest.parsers.get_test_runners(args)
Exemplo n.º 30
0
def test_using_fake_ctc(qibuild_action, fake_ctc):  # pylint: disable=unused-argument
    qibuild_action.add_test_project("footool")
    qibuild_action("configure", "footool", "--config", "fake-ctc")
    qibuild_action("make", "footool", "--config", "fake-ctc")
    build_worktree = TestBuildWorkTree()
    build_worktree.set_active_config("fake-ctc")
    footool_proj = build_worktree.get_build_project("footool")
    # assert that bin/footool exists but cannot be run:
    footool = qibuild.find.find_bin([footool_proj.sdk_directory], "footool",
                                    expect_one=True)
    assert os.path.exists(footool)
    # pylint: disable-msg=E1101
    with pytest.raises(Exception):
        qisys.command.call([footool])
Exemplo n.º 31
0
def test_using_fake_ctc(qibuild_action, fake_ctc):
    """ Test Using Fake Cross Toolchain """
    qibuild_action.add_test_project("footool")
    qibuild_action("configure", "footool", "--config", "fake-ctc")
    qibuild_action("make", "footool", "--config", "fake-ctc")
    build_worktree = TestBuildWorkTree()
    build_worktree.set_active_config("fake-ctc")
    footool_proj = build_worktree.get_build_project("footool")
    # assert that bin/footool exists but cannot be run:
    footool = qibuild.find.find_bin([footool_proj.sdk_directory], "footool",
                                    expect_one=True)
    assert os.path.exists(footool)
    with pytest.raises(Exception):
        qisys.command.call([footool])
Exemplo n.º 32
0
def test_bad_qibuild2_qiproject(cd_to_tmpdir):
    build_worktree = TestBuildWorkTree()
    build_worktree.create_project("foo")
    foo_qiproj_xml = build_worktree.tmpdir.join("foo").join("qiproject.xml")
    foo_qiproj_xml.write(""" \
<project name="foo">
    <project src="bar" />
</project>
""")
    bar_path = build_worktree.tmpdir.join("foo", "bar").ensure(dir=True)
    bar_path.ensure("CMakeLists.txt").ensure(file=True)
    bar_qiproj_xml = bar_path.join("qiproject.xml")
    bar_qiproj_xml.write("<project />")
    build_worktree = TestBuildWorkTree()
Exemplo n.º 33
0
def test_using_custom_profile(qibuild_action, qisrc_action, git_server, record_messages):
    """ Test Using Custom Profile """
    git_server.add_build_profile("foo", [("WITH_FOO", "ON")])
    qisrc_action("init", git_server.manifest_url)
    build_worktree = TestBuildWorkTree()
    qibuild_xml = build_worktree.qibuild_xml
    qibuild.profile.configure_build_profile(qibuild_xml, "bar", [("WITH_BAR", "ON")])
    build_worktree.create_project("spam")
    qibuild.config.add_build_config("foo", profiles=["foo"])
    qibuild.config.add_build_config("bar", profiles=["bar"])
    qibuild_action("configure", "spam", "--config", "foo", "--summarize-options")
    assert record_messages.find(r"WITH_FOO\s+: ON")
    record_messages.reset()
    qibuild_action("configure", "spam", "--config", "bar", "--summarize-options")
    assert record_messages.find(r"WITH_BAR\s+: ON")
Exemplo n.º 34
0
def test_warns_on_conflict(qibuild_action, qisrc_action, git_server,
                           record_messages):
    git_server.add_build_profile("foo", [("WITH_FOO", "ON")])
    qisrc_action("init", git_server.manifest_url)
    build_worktree = TestBuildWorkTree()
    qibuild_xml = build_worktree.qibuild_xml
    qibuild.profile.configure_build_profile(qibuild_xml, "foo",
                                            [("WITH_FOO", "OFF")])
    build_worktree.create_project("spam")
    qibuild.config.add_build_config("foo", profiles=["foo"])
    record_messages.reset()
    qibuild_action("configure", "spam", "--config", "foo",
                   "--summarize-options")
    assert record_messages.find(r"WITH_FOO\s+: OFF")
    assert record_messages.find("WARN")
Exemplo n.º 35
0
def test_staged_path_first_in_path_conf(qibuild_action, toolchains):
    """ Test Staged Path First In Path Conf """
    toolchains.create("foo")
    qibuild.config.add_build_config("foo", toolchain="foo")
    bar_package = toolchains.add_package("foo", "bar")
    qibuild_action.add_test_project("stagepath")
    qibuild_action("configure", "stagepath", "--config", "foo")
    build_worktree = TestBuildWorkTree()
    build_worktree.set_active_config("foo")
    stagepath_proj = build_worktree.get_build_project("stagepath")
    path_conf = read_path_conf(stagepath_proj)
    lines = path_conf.splitlines()
    assert lines == [
        stagepath_proj.path, stagepath_proj.sdk_directory, bar_package.path
    ]
Exemplo n.º 36
0
def test_using_fake_ctc(qibuild_action, fake_ctc):
    """ Test Using Fake Cross Toolchain """
    qibuild_action.add_test_project("footool")
    qibuild_action("configure", "footool", "--config", "fake-ctc")
    qibuild_action("make", "footool", "--config", "fake-ctc")
    build_worktree = TestBuildWorkTree()
    build_worktree.set_active_config("fake-ctc")
    footool_proj = build_worktree.get_build_project("footool")
    # assert that bin/footool exists but cannot be run:
    footool = qibuild.find.find_bin([footool_proj.sdk_directory],
                                    "footool",
                                    expect_one=True)
    assert os.path.exists(footool)
    with pytest.raises(Exception):
        qisys.command.call([footool])
Exemplo n.º 37
0
def setup_test():
    build_worktree = TestBuildWorkTree()
    foo = build_worktree.create_project("foo")
    world = build_worktree.create_project("world")
    hello = build_worktree.create_project("hello", build_depends=["world"])
    git = qisrc.git.Git(foo.path)
    git.init()
    git = qisrc.git.Git(world.path)
    git.init()
    git = qisrc.git.Git(hello.path)
    git.init()
    git_worktree = TestGitWorkTree()
    foo = git_worktree.get_git_project("foo")
    hello = git_worktree.get_git_project("hello")
    world = git_worktree.get_git_project("world")
    return (foo, hello, world)
Exemplo n.º 38
0
def test_simple(qitoolchain_action):
    qitoolchain_action("create", "foo")
    qitoolchain_action("set-default", "-c", "foo")
    build_worktree = TestBuildWorkTree()
    toolchain = build_worktree.toolchain
    assert toolchain
    assert toolchain.name == "foo"
Exemplo n.º 39
0
def test_venv_path(qipy_action):
    # ipython 5 is the last version compatible with Python 2.7
    qipy_action("bootstrap", "pip", "virtualenv", "ipython<=5")
    build_worktree = TestBuildWorkTree()
    venv_path = build_worktree.venv_path
    activate = os.path.join(venv_path, "bin", "activate")
    assert os.path.exists(activate)
Exemplo n.º 40
0
def setup_test():
    build_worktree = TestBuildWorkTree()
    foo = build_worktree.create_project("foo")
    world = build_worktree.create_project("world")
    hello = build_worktree.create_project("hello", build_depends=["world"])
    git = qisrc.git.Git(foo.path)
    git.init()
    git = qisrc.git.Git(world.path)
    git.init()
    git = qisrc.git.Git(hello.path)
    git.init()
    git_worktree = TestGitWorkTree()
    foo = git_worktree.get_git_project("foo")
    hello = git_worktree.get_git_project("hello")
    world = git_worktree.get_git_project("world")
    return (foo, hello, world)
Exemplo n.º 41
0
def test_staged_path_first_in_path_conf(qibuild_action, toolchains):
    """ Test Staged Path First In Path Conf """
    toolchains.create("foo")
    qibuild.config.add_build_config("foo", toolchain="foo")
    bar_package = toolchains.add_package("foo", "bar")
    qibuild_action.add_test_project("stagepath")
    qibuild_action("configure", "stagepath", "--config", "foo")
    build_worktree = TestBuildWorkTree()
    build_worktree.set_active_config("foo")
    stagepath_proj = build_worktree.get_build_project("stagepath")
    path_conf = read_path_conf(stagepath_proj)
    lines = path_conf.splitlines()
    assert lines == [
        stagepath_proj.path,
        stagepath_proj.sdk_directory,
        bar_package.path
    ]
Exemplo n.º 42
0
def test_build_deps_not_top_dir(cd_to_tmpdir, args):
    args.dep_types = "default"
    build_worktree = TestBuildWorkTree()
    dep_proj = build_worktree.create_project("dep")
    git = qisrc.git.Git(dep_proj.path)
    git.init()
    foo = build_worktree.create_project("foo", src="top/foo", build_depends=["dep"])
    top_proj = build_worktree.worktree.add_project("top")
    git = qisrc.git.Git(top_proj.path)
    git.init()
    git_worktree = TestGitWorkTree()
    top_proj = git_worktree.get_git_project("top")
    dep_proj = git_worktree.get_git_project("dep")
    with qisys.sh.change_cwd(cd_to_tmpdir.join("top", "foo").strpath):
        projs =  get_git_projects(git_worktree, args,
                                  use_build_deps=True)
        assert projs == [dep_proj, top_proj]
Exemplo n.º 43
0
def test_build_deps_not_top_dir(cd_to_tmpdir, args):
    args.dep_types = "default"
    build_worktree = TestBuildWorkTree()
    dep_proj = build_worktree.create_project("dep")
    git = qisrc.git.Git(dep_proj.path)
    git.init()
    foo = build_worktree.create_project("foo", src="top/foo", build_depends=["dep"])
    top_proj = build_worktree.worktree.add_project("top")
    git = qisrc.git.Git(top_proj.path)
    git.init()
    git_worktree = TestGitWorkTree()
    top_proj = git_worktree.get_git_project("top")
    dep_proj = git_worktree.get_git_project("dep")
    with qisys.sh.change_cwd(cd_to_tmpdir.join("top", "foo").strpath):
        projs =  get_git_projects(git_worktree, args,
                                  use_build_deps=True)
        assert projs == [dep_proj, top_proj]
Exemplo n.º 44
0
def test_using_build_prefix_from_config_deps_already_cleaned(tmpdir, monkeypatch):
    """ Test Using Build Prefix From Config Deps Already Cleaned """
    myprefix = tmpdir.join("prefix")
    work = tmpdir.mkdir("work")
    dot_qi = work.mkdir(".qi")
    qibuild_xml = dot_qi.join("qibuild.xml")
    to_write = """<qibuild version="1">\n  <build prefix="%s" />\n</qibuild>\n"""
    qibuild_xml.write(to_write % myprefix.strpath)
    worktree = qisys.worktree.WorkTree(work.strpath)
    build_worktree = TestBuildWorkTree(worktree)
    _bar_proj = build_worktree.create_project("bar")
    foo_proj = build_worktree.create_project("foo", build_depends=["bar"])
    foo_proj.configure()
    build_dir = foo_proj.build_directory
    assert os.path.exists(build_dir)
    monkeypatch.chdir(foo_proj.path)
    qisys.script.run_action("qibuild.actions.clean", ["--force", "-z"])
    assert not os.path.exists(build_dir)
Exemplo n.º 45
0
def test_using_custom_profile(qibuild_action, qisrc_action, git_server,
                              record_messages):
    """ Test Using Custom Profile """
    git_server.add_build_profile("foo", [("WITH_FOO", "ON")])
    qisrc_action("init", git_server.manifest_url)
    build_worktree = TestBuildWorkTree()
    qibuild_xml = build_worktree.qibuild_xml
    qibuild.profile.configure_build_profile(qibuild_xml, "bar",
                                            [("WITH_BAR", "ON")])
    build_worktree.create_project("spam")
    qibuild.config.add_build_config("foo", profiles=["foo"])
    qibuild.config.add_build_config("bar", profiles=["bar"])
    qibuild_action("configure", "spam", "--config", "foo",
                   "--summarize-options")
    assert record_messages.find(r"WITH_FOO\s+: ON")
    record_messages.reset()
    qibuild_action("configure", "spam", "--config", "bar",
                   "--summarize-options")
    assert record_messages.find(r"WITH_BAR\s+: ON")
Exemplo n.º 46
0
def test_path_conf_contains_toolchain_paths(qibuild_action, toolchains):
    toolchains.create("foo")
    qibuild.config.add_build_config("foo", toolchain="foo")
    toolchains.add_package("foo", "bar")
    foo_tc = qitoolchain.get_toolchain("foo")
    bar_path = foo_tc.get_package("bar").path
    qibuild_action.add_test_project("hello")
    qibuild_action.add_test_project("world")
    build_woktree = TestBuildWorkTree()
    build_woktree.build_config.set_active_config("foo")
    qibuild_action("configure", "hello", "--config", "foo")
    world_proj = build_woktree.get_build_project("world")
    hello_proj = build_woktree.get_build_project("hello")
    path_conf = os.path.join(hello_proj.sdk_directory, "share", "qi", "path.conf")
    with open(path_conf, "r") as fp:
        contents = fp.readlines()
    sdk_dirs = [x.strip() for x in contents]
    assert hello_proj.sdk_directory in sdk_dirs
    assert world_proj.sdk_directory in sdk_dirs
    assert bar_path in sdk_dirs
Exemplo n.º 47
0
def test_path_conf_contains_toolchain_paths(qibuild_action, toolchains):
    toolchains.create("foo")
    qibuild.config.add_build_config("foo", toolchain="foo")
    toolchains.add_package("foo", "bar")
    foo_tc = qitoolchain.get_toolchain("foo")
    bar_path = foo_tc.get_package("bar").path
    qibuild_action.add_test_project("hello")
    qibuild_action.add_test_project("world")
    build_woktree = TestBuildWorkTree()
    build_woktree.build_config.set_active_config("foo")
    qibuild_action("configure", "hello", "--config", "foo")
    world_proj = build_woktree.get_build_project("world")
    hello_proj = build_woktree.get_build_project("hello")
    path_conf = os.path.join(hello_proj.sdk_directory, "share", "qi", "path.conf")
    with open(path_conf, "r") as fp:
        contents = fp.readlines()
    sdk_dirs = [x.strip() for x in contents]
    assert hello_proj.sdk_directory in sdk_dirs
    assert world_proj.sdk_directory in sdk_dirs
    assert bar_path in sdk_dirs
Exemplo n.º 48
0
def test_sync_build_profiles(qisrc_action, git_server):
    git_server.add_build_profile("foo", [("WITH_FOO", "ON")])
    qisrc_action("init", git_server.manifest_url)
    build_worktree = TestBuildWorkTree()
    build_config = qibuild.build_config.CMakeBuildConfig(build_worktree)
    build_config.profiles = ["foo"]
    assert build_config.cmake_args == ["-DCMAKE_BUILD_TYPE=Debug", "-DWITH_FOO=ON"]
    git_server.add_build_profile("foo", [("WITH_FOO", "ON"), ("WITH_BAR", "ON")])
    qisrc_action("sync")
    assert build_config.cmake_args == ["-DCMAKE_BUILD_TYPE=Debug",
                                       "-DWITH_FOO=ON", "-DWITH_BAR=ON"]
Exemplo n.º 49
0
def test_using_build_prefix_from_config(qibuild_action, tmpdir):
    """ Test Using Build Prefix From Config """
    build_worktree = TestBuildWorkTree()
    qibuild_action.add_test_project("world")
    qibuild_cfg = qibuild.config.QiBuildConfig()
    qibuild_cfg.local.build.prefix = "prefix"
    qibuild_cfg.write_local_config(build_worktree.qibuild_xml)
    qibuild_action("configure", "world")
    prefix = build_worktree.tmpdir.join("prefix")
    expected = prefix.join("build-sys-%s" % (TARGET), "world")
    assert expected.join("CMakeCache.txt").check(file=True)
Exemplo n.º 50
0
def test_using_build_prefix_from_config_deps_already_cleaned(tmpdir, monkeypatch):
    myprefix = tmpdir.join("prefix")
    work = tmpdir.mkdir("work")
    dot_qi = work.mkdir(".qi")
    qibuild_xml = dot_qi.join("qibuild.xml")
    to_write = """\
<qibuild version="1">
  <build prefix="%s" />
</qibuild>
"""
    qibuild_xml.write(to_write % myprefix.strpath)
    worktree = qisys.worktree.WorkTree(work.strpath)
    build_worktree = TestBuildWorkTree(worktree)
    bar_proj = build_worktree.create_project("bar")
    foo_proj = build_worktree.create_project("foo", build_depends=["bar"])
    foo_proj.configure()
    build_dir = foo_proj.build_directory
    assert os.path.exists(build_dir)
    monkeypatch.chdir(foo_proj.path)
    qisys.script.run_action("qibuild.actions.clean", ["--force", "-z"])
    assert not os.path.exists(build_dir)
Exemplo n.º 51
0
def test_get_env(toolchains, cd_to_tmpdir):
    toolchains.create("foo")
    qibuild.config.add_build_config("foo", toolchain="foo")
    bar_package = toolchains.add_package("foo", "bar")
    build_worktree = TestBuildWorkTree()
    build_worktree.set_active_config("foo")
    world_proj = build_worktree.create_project("world")
    env = build_worktree.get_env()
    if sys.platform.startswith("linux"):
        assert env["LD_LIBRARY_PATH"] == "%s:%s" % (
                os.path.join(world_proj.sdk_directory, "lib"),
                os.path.join(bar_package.path, "lib"))
    if sys.platform.startswith("win"):
        old_path = os.environ["PATH"]
        assert env["PATH"] == "%s;%s;%s" % (
                os.path.join(world_proj.sdk_directory, "bin"),
                os.path.join(bar_package.path, "bin"),
                old_path)
    if sys.platform == "darwin":
        assert env["DYLD_LIBRARY_PATH"] == "%s:%s" % (
                os.path.join(world_proj.sdk_directory, "lib"),
                os.path.join(bar_package.path, "lib"))
        assert env["DYLD_FRAMEWORK_PATH"] == bar_package.path
Exemplo n.º 52
0
def test_add_build_project(git_server, qisrc_action):
    git_server.add_qibuild_test_project("world")
    qisrc_action("init", git_server.manifest_url)
    build_worktree = TestBuildWorkTree()
    assert build_worktree.get_build_project("world")
Exemplo n.º 53
0
def test_non_translated_messages_qt(qilinguist_action):
    build_worktree = TestBuildWorkTree()
    project = build_worktree.add_test_project("translateme/qt")
    qilinguist_action("update", "helloqt")
    qilinguist_action("release", "helloqt", raises=True)
Exemplo n.º 54
0
def test_changing_active_config_changes_projects_build_dir(cd_to_tmpdir):
    qibuild.config.add_build_config("foo")
    build_worktree = TestBuildWorkTree()
    build_worktree.set_active_config("foo")
    world_proj = build_worktree.create_project("world")
    assert "foo" in  world_proj.build_directory