| 1 |
from sarif import * |
| 2 |
|
| 3 |
import pytest |
| 4 |
|
| 5 |
@pytest.fixture(scope='function', autouse=True) |
| 6 |
def sarif(): |
| 7 |
return sarif_from_env() |
| 8 |
|
| 9 |
def test_execution_unsuccessful(sarif): |
| 10 |
runs = sarif['runs'] |
| 11 |
run = runs[0] |
| 12 |
|
| 13 |
invocations = run['invocations'] |
| 14 |
assert len(invocations) == 1 |
| 15 |
invocation = invocations[0] |
| 16 |
|
| 17 |
# We expect the fatal error to make executionSuccessful be false |
| 18 |
assert invocation['executionSuccessful'] == False |
| 19 |
|
| 20 |
def test_fatal_error(sarif): |
| 21 |
runs = sarif['runs'] |
| 22 |
run = runs[0] |
| 23 |
results = run['results'] |
| 24 |
|
| 25 |
assert len(results) == 1 |
| 26 |
|
| 27 |
result = results[0] |
| 28 |
assert result['level'] == 'error' |
| 29 |
assert result['message']['text'] == "this-does-not-exist.h: No such file or directory" |