| 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_sarif_output_with_logical_location(sarif): |
| 10 |
schema = sarif['$schema'] |
| 11 |
assert schema == 'https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json' |
| 12 |
|
| 13 |
version = sarif['version'] |
| 14 |
assert version == '2.1.0' |
| 15 |
|
| 16 |
runs = sarif['runs'] |
| 17 |
run = runs[0] |
| 18 |
|
| 19 |
tool = run['tool'] |
| 20 |
assert tool['driver']['name'] == 'test-logical-location.c.exe' |
| 21 |
|
| 22 |
results = run['results'] |
| 23 |
assert len(results) == 1 |
| 24 |
|
| 25 |
result = results[0] |
| 26 |
assert result['ruleId'] == 'error' |
| 27 |
assert result['level'] == 'error' |
| 28 |
assert result['message']['text'] == "can't find 'foo'" |
| 29 |
assert len(result['locations']) == 1 |
| 30 |
location = result['locations'][0] |
| 31 |
|
| 32 |
assert len(location['logicalLocations']) == 1 |
| 33 |
logical_loc = location['logicalLocations'][0] |
| 34 |
assert logical_loc['name'] == 'test_short_name' |
| 35 |
assert logical_loc['fullyQualifiedName'] == 'test_qualified_name' |
| 36 |
assert logical_loc['decoratedName'] == 'test_decorated_name' |
| 37 |
assert logical_loc['kind'] == 'function' |