Skip to content

Commit de30a25

Browse files
committed
Fix Tests
1 parent 2a0f06c commit de30a25

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

cppython/plugins/cmake/builder.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,13 @@ def _update_configure_preset(existing_preset: ConfigurePreset, build_directory:
179179
existing_preset: The preset to update
180180
build_directory: The build directory to use
181181
"""
182-
# Update existing preset to ensure it inherits from 'default'
182+
# Update existing preset to ensure it inherits from 'cppython'
183183
if existing_preset.inherits is None:
184-
existing_preset.inherits = 'default' # type: ignore[misc]
185-
elif isinstance(existing_preset.inherits, str) and existing_preset.inherits != 'default':
186-
existing_preset.inherits = ['default', existing_preset.inherits] # type: ignore[misc]
187-
elif isinstance(existing_preset.inherits, list) and 'default' not in existing_preset.inherits:
188-
existing_preset.inherits.insert(0, 'default')
184+
existing_preset.inherits = 'cppython' # type: ignore[misc]
185+
elif isinstance(existing_preset.inherits, str) and existing_preset.inherits != 'cppython':
186+
existing_preset.inherits = ['cppython', existing_preset.inherits] # type: ignore[misc]
187+
elif isinstance(existing_preset.inherits, list) and 'cppython' not in existing_preset.inherits:
188+
existing_preset.inherits.insert(0, 'cppython')
189189

190190
# Update binary directory if not set
191191
if not existing_preset.binaryDir:
@@ -214,10 +214,10 @@ def _modify_presets(
214214
existing_preset = next(
215215
(p for p in root_preset.configurePresets if p.name == user_configure_preset.name), None
216216
)
217-
if existing_preset:
218-
Builder._update_configure_preset(existing_preset, build_directory)
219-
else:
220-
root_preset.configurePresets.append(user_configure_preset)
217+
if existing_preset:
218+
Builder._update_configure_preset(existing_preset, build_directory)
219+
else:
220+
root_preset.configurePresets.append(user_configure_preset)
221221

222222
if root_preset.buildPresets is None:
223223
root_preset.buildPresets = user_build_presets.copy() # type: ignore[misc]
@@ -304,8 +304,8 @@ def write_root_presets(
304304
initial_json = file.read()
305305
initial_root_preset = CMakePresets.model_validate_json(initial_json)
306306

307-
# Ensure that the build_directory is relative to the preset_file
308-
build_directory = build_directory.relative_to(preset_file.parent)
307+
# Ensure that the build_directory is relative to the preset_file, allowing upward traversal
308+
build_directory = build_directory.relative_to(preset_file.parent, walk_up=True)
309309

310310
root_preset = Builder.generate_root_preset(preset_file, cppython_preset_file, cmake_data, build_directory)
311311

tests/unit/plugins/cmake/test_presets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def test_generate_root_preset_new(project_data: ProjectData) -> None:
2727
assert any(p.name == 'test-configuration' for p in result.configurePresets)
2828

2929
preset = next(p for p in result.configurePresets if p.name == 'test-configuration')
30-
assert preset.inherits == 'default'
30+
assert preset.inherits == 'cppython'
3131

3232
@staticmethod
3333
def test_generate_root_preset_existing(project_data: ProjectData) -> None:

0 commit comments

Comments
 (0)