|
2 | 2 |
|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
| 5 | +import json |
| 6 | +import os |
| 7 | +import subprocess |
5 | 8 | import sys |
6 | 9 |
|
7 | 10 | import pytest |
@@ -47,9 +50,28 @@ def test_just_test(integration_project): |
47 | 50 |
|
48 | 51 |
|
49 | 52 | def test_just_lint(integration_project): |
| 53 | + # just lint exits 1 on warnings, 2 on errors — only errors are failures |
50 | 54 | 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}" |
53 | 75 | ) |
54 | 76 |
|
55 | 77 |
|
|
0 commit comments