Developer tools dump stack traces, exit codes, and jargon. Figuring out *what to do next* often means searching the same Stack Overflow answers again.
| 1 | """Linux rule tests.""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | import pytest |
| 6 | |
| 7 | from why_failed.matcher import analyze |
| 8 | |
| 9 | CASES = [ |
| 10 | ("bash: ./run.sh: Permission denied", "linux.permission_denied"), |
| 11 | ("listen tcp :8080: bind: Address already in use", "linux.address_in_use"), |
| 12 | ("cat: missing.txt: No such file or directory", "linux.no_such_file"), |
| 13 | ("bash: foo: command not found", "linux.command_not_found"), |
| 14 | ("write /tmp/x: No space left on device", "linux.disk_full"), |
| 15 | ("fatal error: runtime: out of memory", "linux.out_of_memory"), |
| 16 | ("curl: (7) Failed to connect to localhost port 80: Connection refused", "linux.connection_refused"), |
| 17 | ("echo: write error: Broken pipe", "linux.broken_pipe"), |
| 18 | ("open /path: Too many open files", "linux.too_many_open_files"), |
| 19 | ] |
| 20 | |
| 21 | |
| 22 | @pytest.mark.parametrize("text,rule_id", CASES) |
| 23 | def test_linux_rules(text: str, rule_id: str) -> None: |
| 24 | result = analyze(text) |
| 25 | assert result.match is not None |
| 26 | assert result.match.rule_id == rule_id |