Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f88fcf9

Browse files
WolfgangIssovitsmadebr
authored andcommitted
Fix issue with optional source directory
1 parent 74a3b46 commit f88fcf9

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

cmake_file_api/cmake.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def __init__(self, build_path: Union[Path, str], source_path: Optional[Union[Pat
1313
raise ValueError("Need a build folder")
1414
if isinstance(source_path, str):
1515
source_path = Path(source_path).resolve()
16-
self._source_path = source_path.resolve()
16+
self._source_path = source_path.resolve() if source_path else None
1717
if isinstance(build_path, str):
1818
build_path = Path(build_path).resolve()
1919
self._build_path = build_path

tests/test_regression.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ def test_complete_project(complex_cxx_project, capsys):
124124
data = project.cmake_file_api.inspect_all()
125125
assert data is not None
126126

127+
# Check if project also works without specifying the source directory
128+
project2 = CMakeProject(complex_cxx_project.build, api_version=1)
129+
project2.cmake_file_api.instrument_all()
130+
project2.reconfigure(quiet=True)
131+
data2 = project2.cmake_file_api.inspect_all()
132+
assert data2 is not None
127133

128134
@pytest.mark.skipif(not CMAKE_SUPPORTS_TOOLCHAINS_V1, reason="CMake does not support toolchains V1 kind")
129135
def test_toolchain_kind_cxx(complex_cxx_project, capsys):

0 commit comments

Comments
 (0)