test_components.py 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. # SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
  2. # SPDX-License-Identifier: Apache-2.0
  3. import logging
  4. import shutil
  5. from pathlib import Path
  6. import pytest
  7. from test_build_system_helpers import IdfPyFunc, replace_in_file
  8. def test_component_extra_dirs(idf_py: IdfPyFunc, test_app_copy: Path) -> None:
  9. logging.info('Setting EXTRA_COMPONENT_DIRS works')
  10. shutil.move(test_app_copy / 'main', test_app_copy / 'different_main' / 'main')
  11. replace_in_file((test_app_copy / 'CMakeLists.txt'), '# placeholder_before_include_project_cmake',
  12. 'set(EXTRA_COMPONENT_DIRS {})'.format(Path('different_main', 'main')))
  13. ret = idf_py('reconfigure')
  14. assert str(test_app_copy / 'different_main' / 'main') in ret.stdout
  15. assert str(test_app_copy / 'main') not in ret.stdout
  16. @pytest.mark.usefixtures('test_app_copy')
  17. def test_component_nonexistent_extra_dirs_not_allowed(idf_py: IdfPyFunc) -> None:
  18. ret = idf_py('reconfigure', '-DEXTRA_COMPONENT_DIRS="nonexistent_dir"', check=False)
  19. assert ret.returncode != 0
  20. def test_component_names_contain_spaces(idf_py: IdfPyFunc, test_app_copy: Path) -> None:
  21. logging.info('Component names may contain spaces')
  22. (test_app_copy / 'extra component').mkdir()
  23. (test_app_copy / 'extra component' / 'CMakeLists.txt').write_text('idf_component_register')
  24. idf_py('-DEXTRA_COMPONENT_DIRS="extra component;main"')