Skip to content

Commit ef5b4d3

Browse files
committed
Add failing test for issue #53: per-package target setting
This test demonstrates the bug where per-package target settings are ignored. The test will fail with the current code, showing: Expected: custom-dir/package.with.custom.target Actual: ./sources/package.with.custom.target The bug is in config.py line 103, which uses the default-target variable instead of the package's individual target setting. Related to #53
1 parent 50afd6a commit ef5b4d3

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[settings]
2+
default-target = ./sources
3+
docs-directory = documentation
4+
5+
[package.with.default.target]
6+
url = https://github.com/example/package1.git
7+
8+
[package.with.custom.target]
9+
url = https://github.com/example/package2.git
10+
target = custom-dir
11+
12+
[package.with.interpolated.target]
13+
url = https://github.com/example/docs.git
14+
target = ${settings:docs-directory}

tests/test_config.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,32 @@ def test_configuration_package_defaults():
185185
assert pkg["install-mode"] == "direct" # default mode
186186
assert pkg["vcs"] == "git"
187187
assert "path" in pkg
188+
189+
190+
def test_per_package_target_override():
191+
"""Test that per-package target setting overrides default-target.
192+
193+
This test demonstrates issue #53: the target setting for individual
194+
packages should override the default-target setting.
195+
"""
196+
from mxdev.config import Configuration
197+
198+
base = pathlib.Path(__file__).parent / "data" / "config_samples"
199+
config = Configuration(str(base / "config_with_custom_target.ini"))
200+
201+
# Package without custom target should use default-target
202+
pkg_default = config.packages["package.with.default.target"]
203+
assert pkg_default["target"] == "./sources"
204+
assert pkg_default["path"] == "./sources/package.with.default.target"
205+
206+
# Package with custom target should use its own target
207+
pkg_custom = config.packages["package.with.custom.target"]
208+
assert pkg_custom["target"] == "custom-dir"
209+
# BUG: This will fail because config.py uses wrong variable at line 103
210+
assert pkg_custom["path"] == "custom-dir/package.with.custom.target"
211+
212+
# Package with interpolated target should use the interpolated value
213+
pkg_interpolated = config.packages["package.with.interpolated.target"]
214+
assert pkg_interpolated["target"] == "documentation"
215+
# BUG: This will also fail for the same reason
216+
assert pkg_interpolated["path"] == "documentation/package.with.interpolated.target"

0 commit comments

Comments
 (0)