Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .pi/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"packages": [
"npm:pi-formatter",
"npm:pi-tenzir-ship",
"npm:pi-tenzir-dev"
"npm:pi-formatter"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: Skipped tests preserve existing baseline files
type: bugfix
authors:
- mavam
- codex
created: 2026-03-10T16:49:44.144342Z
---

Skipping a test no longer modifies its baseline file. Previously, running
with `--update` would overwrite the baseline of a skipped test with an empty
file, and running without `--update` would fail if the baseline was non-empty.
Skipped tests now leave existing baselines untouched, so toggling a skip
condition no longer causes unrelated baseline churn.
15 changes: 0 additions & 15 deletions src/tenzir_test/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -4291,21 +4291,6 @@ def handle_skip(reason: str, test: Path, update: bool, output_ext: str) -> bool
rel_path = _relativize_path(test)
suite_suffix = _format_suite_suffix()
print(f"{SKIP} skipped {rel_path}{suite_suffix}: {reason}")
ref_path = test.with_suffix(f".{output_ext}")
if update:
with ref_path.open("wb") as f:
f.write(b"")
else:
if ref_path.exists():
expected = ref_path.read_bytes()
if expected != b"":
report_failure(
test,
format_failure_message(
f'Reference file for skipped test must be empty: "{ref_path}"'
),
)
return False
return "skipped"


Expand Down
26 changes: 26 additions & 0 deletions tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ def test_handle_skip_uses_skip_glyph(tmp_path, capsys):
test_path = tmp_path / "tests" / "example.tql"
test_path.parent.mkdir(parents=True)
test_path.touch()
test_path.with_suffix(".txt").write_text("existing baseline\n", encoding="utf-8")

result = run.handle_skip("slow", test_path, update=False, output_ext="txt")

Expand Down Expand Up @@ -423,6 +424,7 @@ def test_handle_skip_suppressed_when_verbose_disabled(
test_path = tmp_path / "tests" / "example.tql"
test_path.parent.mkdir(parents=True)
test_path.touch()
test_path.with_suffix(".txt").write_text("existing baseline\n", encoding="utf-8")

result = run.handle_skip("slow", test_path, update=False, output_ext="txt")

Expand All @@ -434,6 +436,30 @@ def test_handle_skip_suppressed_when_verbose_disabled(
run.set_verbose_output(original_verbose)


def test_handle_skip_preserves_existing_baseline_during_update(
tmp_path: Path, capsys: pytest.CaptureFixture[str]
) -> None:
original_root = run.ROOT
original_verbose = run.is_verbose_output()
try:
run.ROOT = tmp_path
run.set_verbose_output(False)
test_path = tmp_path / "tests" / "example.tql"
test_path.parent.mkdir(parents=True)
test_path.touch()
ref_path = test_path.with_suffix(".txt")
ref_path.write_text("existing baseline\n", encoding="utf-8")

result = run.handle_skip("slow", test_path, update=True, output_ext="txt")

assert result == "skipped"
assert ref_path.read_text(encoding="utf-8") == "existing baseline\n"
assert capsys.readouterr().out.strip() == ""
finally:
run.ROOT = original_root
run.set_verbose_output(original_verbose)


def test_success_suppressed_when_verbose_disabled(
tmp_path: Path, capsys: pytest.CaptureFixture[str]
) -> None:
Expand Down
Loading