Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

86 lines
2.9KB

  1. import json
  2. import pytest
  3. from dds_ci.testing import RepoServer, Project, ProjectOpener
  4. from dds_ci import proc, toolchain
  5. SIMPLE_CATALOG = {
  6. "packages": {
  7. "neo-fun": {
  8. "0.3.0": {
  9. "remote": {
  10. "git": {
  11. "url": "https://github.com/vector-of-bool/neo-fun.git",
  12. "ref": "0.3.0"
  13. }
  14. }
  15. }
  16. }
  17. }
  18. }
  19. @pytest.fixture()
  20. def test_repo(http_repo: RepoServer) -> RepoServer:
  21. http_repo.import_json_data(SIMPLE_CATALOG)
  22. return http_repo
  23. @pytest.fixture()
  24. def test_project(tmp_project: Project, test_repo: RepoServer) -> Project:
  25. tmp_project.dds.repo_add(test_repo.url)
  26. return tmp_project
  27. def test_from_file(test_project: Project) -> None:
  28. """build-deps using a file listing deps"""
  29. test_project.write('deps.json5', json.dumps({'depends': ['neo-fun+0.3.0']}))
  30. test_project.dds.build_deps(['-d', 'deps.json5'])
  31. assert test_project.root.joinpath('_deps/neo-fun@0.3.0').is_dir()
  32. assert test_project.root.joinpath('_deps/_libman/neo-fun.lmp').is_file()
  33. assert test_project.root.joinpath('_deps/_libman/neo/fun.lml').is_file()
  34. assert test_project.root.joinpath('INDEX.lmi').is_file()
  35. def test_from_cmd(test_project: Project) -> None:
  36. """build-deps using a command-line listing"""
  37. test_project.dds.build_deps(['neo-fun=0.3.0'])
  38. assert test_project.root.joinpath('_deps/neo-fun@0.3.0').is_dir()
  39. assert test_project.root.joinpath('_deps/_libman/neo-fun.lmp').is_file()
  40. assert test_project.root.joinpath('_deps/_libman/neo/fun.lml').is_file()
  41. assert test_project.root.joinpath('INDEX.lmi').is_file()
  42. def test_multiple_deps(test_project: Project) -> None:
  43. """build-deps with multiple deps resolves to a single version"""
  44. test_project.dds.build_deps(['neo-fun^0.2.0', 'neo-fun~0.3.0'])
  45. assert test_project.root.joinpath('_deps/neo-fun@0.3.0').is_dir()
  46. assert test_project.root.joinpath('_deps/_libman/neo-fun.lmp').is_file()
  47. assert test_project.root.joinpath('_deps/_libman/neo/fun.lml').is_file()
  48. assert test_project.root.joinpath('INDEX.lmi').is_file()
  49. def test_cmake_simple(project_opener: ProjectOpener) -> None:
  50. proj = project_opener.open('projects/simple')
  51. proj.dds.pkg_import(proj.root)
  52. cm_proj_dir = project_opener.test_dir / 'projects/simple-cmake'
  53. proj.build_root.mkdir(exist_ok=True, parents=True)
  54. proj.dds.run(
  55. [
  56. 'build-deps',
  57. proj.dds.cache_dir_arg,
  58. 'foo@1.2.3',
  59. ('-t', ':gcc' if 'gcc' in toolchain.get_default_toolchain().name else ':msvc'),
  60. f'--cmake=libraries.cmake',
  61. ],
  62. cwd=proj.build_root,
  63. )
  64. try:
  65. proc.check_run(['cmake', '-S', cm_proj_dir, '-B', proj.build_root])
  66. except FileNotFoundError:
  67. assert False, 'Running the integration tests requires a CMake executable'
  68. proc.check_run(['cmake', '--build', proj.build_root])