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)
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")
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"
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")
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()
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")
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)