コード例 #1
0
    def test_create_dependencies(self, mocker):
        """Create dependencies from list."""
        mocked_get_config = mocker.patch(
            "dependencmake.dependency_list.get_config")
        config = {
            "dependencies": [
                {
                    "name": "My dep 1",
                    "url": "http://example.com/dep1"
                },
                {
                    "name": "My dep 2",
                    "url": "http://example.com/dep2"
                },
            ]
        }
        mocked_get_config.return_value = config
        mocked_check_config = mocker.patch(
            "dependencmake.dependency_list.check_config")

        dependency_list = DependencyList()
        assert len(dependency_list.dependencies) == 0
        dependency_list.create_dependencies(Path("path"))
        assert len(dependency_list.dependencies) == 2
        assert isinstance(dependency_list.dependencies[0], Dependency)
        assert isinstance(dependency_list.dependencies[1], Dependency)

        mocked_get_config.assert_called_with(Path("path"))
        mocked_check_config.assert_called_with(config)
コード例 #2
0
    def test_get_install_directory_default(self, mocker):
        """Test to get default install directory."""
        mocked_realpath = mocker.patch.object(Path, "realpath", autospec=True)
        mocked_realpath.side_effect = lambda p: p

        dependency_list = DependencyList()

        assert dependency_list.get_install_path() == CACHE_INSTALL
コード例 #3
0
    def test_get_install_directory_set(self, mocker):
        """Test to get specified install directory."""
        mocked_realpath = mocker.patch.object(Path, "realpath", autospec=True)
        mocked_realpath.side_effect = lambda p: p

        dependency_list = DependencyList(Path("lib"))

        assert dependency_list.get_install_path() == Path("lib")
コード例 #4
0
def dependency_list():
    dependency_list = DependencyList()
    dependency_list.dependencies = [
        Dependency(name="My dep 1", url="http://example.com/dep1"),
        Dependency(name="My dep 2", url="http://example.com/dep2"),
    ]

    return dependency_list
コード例 #5
0
def run_fetch(args: Namespace, output=sys.stdout):
    """Run the fetch command."""
    if args.force:
        clean(fetch=True)

    dependency_list = DependencyList()
    dependency_list.create_dependencies(args.path)
    dependency_list.create_subdependencies()
    dependency_list.fetch(output)
    dependency_list.check(output)

    output.write("Done\n")
コード例 #6
0
def dependency_list_data():
    dependency_list = DependencyList()
    dependency_list.dependencies = [
        Dependency(
            name="My dep 1",
            url="http://example.com/dep1",
            cmake_project_name="Dep1",
            cmake_project_version=version.parse("1.2.0"),
        ),
        Dependency(
            name="My dep 1",
            url="http://example.com/dep2",
            cmake_project_name="Dep2",
            cmake_project_version=version.parse("2.4.0"),
        ),
    ]

    return dependency_list
コード例 #7
0
    def test_fetch_subdependencies(self, mocker,
                                   subdependencies_temp_directory):
        """Fetch supdependencies."""
        mocker.patch("dependencmake.dependency.urlretrieve")
        mocker.patch("dependencmake.dependency.unpack_archive")
        mocked_get_project_data = mocker.patch(
            "dependencmake.dependency.get_project_data")
        mocked_get_project_data.return_value = {
            "name": "Dep",
            "version": "1.0.0"
        }

        with subdependencies_temp_directory:
            dependency_list = DependencyList()
            dependency_list.create_dependencies(subdependencies_temp_directory)
            dependency_list.create_subdependencies()
            dependency_list.fetch()
コード例 #8
0
    def test_create_subdependencies(self, subdependencies_temp_directory):
        """Create supdependencies."""
        with subdependencies_temp_directory:
            dependency_list = DependencyList()
            dependency_list.create_dependencies(subdependencies_temp_directory)
            dependency_list.create_subdependencies()

        assert len(dependency_list.dependencies) == 5
        assert dependency_list.dependencies[0].name == "Dep11"
        assert dependency_list.dependencies[1].name == "Dep12"
        assert dependency_list.dependencies[2].name == "Dep1"
        assert dependency_list.dependencies[3].name == "Dep21"
        assert dependency_list.dependencies[4].name == "Dep2"
コード例 #9
0
def run_install(args: Namespace, output=sys.stdout):
    """Run the install command."""
    if args.force:
        clean(fetch=True, build=True, install=True)

    dependency_list = DependencyList(args.install_path)
    dependency_list.create_dependencies(args.path)
    dependency_list.create_subdependencies()
    dependency_list.fetch(output)
    dependency_list.check(output)
    dependency_list.build(args.rest, output)
    dependency_list.install(output)

    output.write("Done\n\n")

    output.write(
        "You can now call CMake with "
        f"{CMAKE_PREFIX_PATH.format(dependency_list.get_install_path())}\n")
コード例 #10
0
def run_build(args: Namespace, output=sys.stdout):
    """Run the build command."""
    if args.force:
        clean(fetch=True, build=True)

    dependency_list = DependencyList(args.install_path)
    dependency_list.create_dependencies(args.path)
    dependency_list.create_subdependencies()
    dependency_list.fetch(output)
    dependency_list.check(output)
    dependency_list.build(args.rest, output)

    output.write("Done\n")
コード例 #11
0
def run_list(args: Namespace, output=sys.stdout):
    """Run the list command."""
    dependency_list = DependencyList()
    dependency_list.create_dependencies(args.path)
    dependency_list.create_subdependencies()
    dependency_list.describe(output)