Skip to content

Commit 37ad651

Browse files
authored
fix: debug folder tests (#86)
1 parent ea1422b commit 37ad651

File tree

3 files changed

+39
-28
lines changed

3 files changed

+39
-28
lines changed

tests/integration_python/common.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,23 @@ def write_files(self) -> None:
125125
package_manifest_path = self.package_dir.joinpath("pixi.toml")
126126
package_manifest_path.write_text(tomli_w.dumps(self.package_manifest))
127127

128+
def iter_debug_dirs(self) -> list[Path]:
129+
candidates: list[Path] = []
130+
work_root = self.workspace_dir.joinpath(".pixi", "build", "work")
131+
if work_root.is_dir():
132+
for entry in sorted(work_root.iterdir()):
133+
debug_candidate = entry.joinpath("debug")
134+
if debug_candidate.is_dir():
135+
candidates.append(debug_candidate)
136+
return candidates
137+
138+
def find_debug_file(self, filename: str) -> Path | None:
139+
for debug_dir in self.iter_debug_dirs():
140+
target = debug_dir.joinpath(filename)
141+
if target.is_file():
142+
return target
143+
return None
144+
128145

129146
class ExitCode(IntEnum):
130147
SUCCESS = 0

tests/integration_python/conftest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ def simple_workspace(
120120
"https://prefix.dev/conda-forge",
121121
],
122122
},
123-
"configuration": {"debug-dir": str(debug_dir)},
124123
},
125124
},
126125
}

tests/integration_python/test_build.py

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
)
1515

1616

17+
BUILD_RUNNING_STRING = "Running build for recipe:"
18+
19+
1720
def test_build_conda_package(
1821
pixi: Path,
1922
simple_workspace: Workspace,
@@ -48,17 +51,15 @@ def test_no_change_should_be_fully_cached(pixi: Path, simple_workspace: Workspac
4851
"-v",
4952
"--manifest-path",
5053
simple_workspace.workspace_dir,
51-
]
54+
],
55+
stderr_contains=BUILD_RUNNING_STRING,
5256
)
5357

54-
conda_output_params = simple_workspace.debug_dir.joinpath("conda_outputs_params.json")
55-
conda_build_params = simple_workspace.debug_dir.joinpath("conda_build_v1_params.json")
58+
conda_build_params = simple_workspace.find_debug_file("conda_build_v1_params.json")
5659

57-
assert conda_output_params.is_file()
58-
assert conda_build_params.is_file()
60+
assert conda_build_params is not None
5961

6062
# Remove the files to get a clean state
61-
conda_output_params.unlink()
6263
conda_build_params.unlink()
6364

6465
verify_cli_command(
@@ -68,18 +69,19 @@ def test_no_change_should_be_fully_cached(pixi: Path, simple_workspace: Workspac
6869
"-v",
6970
"--manifest-path",
7071
simple_workspace.workspace_dir,
71-
]
72+
],
73+
stderr_excludes=BUILD_RUNNING_STRING,
7274
)
7375

74-
# Everything should be cached, so no getMetadata or build call
75-
assert not conda_output_params.is_file()
76-
assert not conda_build_params.is_file()
76+
# Everything should be cached, so no build call,
77+
assert simple_workspace.find_debug_file("conda_build_v1_params.json") is None
7778

7879

7980
def test_recipe_change_trigger_metadata_invalidation(
8081
pixi: Path, simple_workspace: Workspace
8182
) -> None:
8283
simple_workspace.write_files()
84+
8385
verify_cli_command(
8486
[
8587
pixi,
@@ -88,15 +90,9 @@ def test_recipe_change_trigger_metadata_invalidation(
8890
"--manifest-path",
8991
simple_workspace.workspace_dir,
9092
],
93+
stderr_contains=BUILD_RUNNING_STRING,
9194
)
9295

93-
conda_output_params = simple_workspace.debug_dir.joinpath("conda_outputs_params.json")
94-
95-
assert conda_output_params.is_file()
96-
97-
# Remove the conda build params to get a clean state
98-
conda_output_params.unlink()
99-
10096
# Touch the recipe
10197
simple_workspace.recipe_path.touch()
10298

@@ -108,11 +104,9 @@ def test_recipe_change_trigger_metadata_invalidation(
108104
"--manifest-path",
109105
simple_workspace.workspace_dir,
110106
],
107+
stderr_contains=BUILD_RUNNING_STRING,
111108
)
112109

113-
# Touching the recipe should trigger a rebuild and therefore create the file
114-
assert conda_output_params.is_file()
115-
116110

117111
def test_project_model_change_trigger_rebuild(
118112
pixi: Path, simple_workspace: Workspace, dummy_channel_1: Path
@@ -126,19 +120,19 @@ def test_project_model_change_trigger_rebuild(
126120
"--manifest-path",
127121
simple_workspace.workspace_dir,
128122
],
123+
stderr_contains=BUILD_RUNNING_STRING,
129124
)
130125

131-
conda_build_params = simple_workspace.debug_dir.joinpath("conda_build_v1_params.json")
132-
133-
assert conda_build_params.is_file()
126+
conda_build_params = simple_workspace.find_debug_file("conda_build_v1_params.json")
127+
assert conda_build_params is not None
134128

135129
# Remove the conda build params to get a clean state
136130
conda_build_params.unlink()
137131

138132
# modify extra-input-globs
139-
simple_workspace.package_manifest["package"]["build"]["configuration"].setdefault(
140-
"extra-input-globs", ["*.md"]
141-
)
133+
simple_workspace.package_manifest["package"]["build"].setdefault(
134+
"configuration", dict()
135+
).setdefault("extra-input-globs", ["*.md"])
142136
simple_workspace.write_files()
143137
verify_cli_command(
144138
[
@@ -148,10 +142,11 @@ def test_project_model_change_trigger_rebuild(
148142
"--manifest-path",
149143
simple_workspace.workspace_dir,
150144
],
145+
stderr_contains=BUILD_RUNNING_STRING,
151146
)
152147

153148
# modifying the project model should trigger a rebuild and therefore create a file
154-
assert conda_build_params.is_file()
149+
assert simple_workspace.find_debug_file("conda_build_v1_params.json") is not None
155150

156151

157152
@pytest.mark.slow

0 commit comments

Comments
 (0)