Skip to content

Commit 5915bc6

Browse files
committed
Fix lint test to tolerate warnings
Allow exit code 1 (warnings-only) from `just lint` and verify 0 errors / 4 warnings via linkml-lint JSON output.
1 parent e0aaece commit 5915bc6

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

tests/test_integration.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
from __future__ import annotations
44

5+
import json
6+
import os
7+
import subprocess
58
import sys
69

710
import pytest
@@ -47,9 +50,28 @@ def test_just_test(integration_project):
4750

4851

4952
def test_just_lint(integration_project):
53+
# just lint exits 1 on warnings, 2 on errors — only errors are failures
5054
result = run_just(integration_project, "lint")
51-
assert result.returncode == 0, (
52-
f"just lint failed:\nstdout: {result.stdout}\nstderr: {result.stderr}"
55+
assert result.returncode < 2, (
56+
f"just lint found errors:\nstdout: {result.stdout}\nstderr: {result.stderr}"
57+
)
58+
59+
# Verify exact warning/error counts via JSON output
60+
env = {k: v for k, v in os.environ.items() if k != "VIRTUAL_ENV"}
61+
lint_json = subprocess.run(
62+
["uv", "run", "linkml-lint", "--format", "json", "src/test_schema/schema"],
63+
cwd=integration_project,
64+
capture_output=True,
65+
text=True,
66+
timeout=120,
67+
env=env,
68+
)
69+
problems = json.loads(lint_json.stdout)
70+
errors = [p for p in problems if p["level"] == "error"]
71+
warnings = [p for p in problems if p["level"] == "warning"]
72+
assert len(errors) == 0, f"Expected 0 lint errors, got {len(errors)}: {errors}"
73+
assert len(warnings) == 4, (
74+
f"Expected 4 lint warnings, got {len(warnings)}: {warnings}"
5375
)
5476

5577

0 commit comments

Comments
 (0)