Debian Codegraph @

gcc/testsuite/gcc.dg/sarif-output/werror.py

raw
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_basics(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 def test_execution_unsuccessful(sarif):
17 runs = sarif['runs']
18 run = runs[0]
19
20 invocations = run['invocations']
21 assert len(invocations) == 1
22 invocation = invocations[0]
23
24 assert '-Werror=unused-variable' in invocation['arguments']
25
26 # We expect the 'Werror' to make executionSuccessful be false
27 assert invocation['executionSuccessful'] == False
28
29 def test_result(sarif):
30 runs = sarif['runs']
31 run = runs[0]
32 results = run['results']
33
34 assert len(results) == 1
35
36 result = results[0]
37 assert result['ruleId'] == '-Werror=unused-variable'
38 assert result['level'] == 'error'
39 assert result['message']['text'] == "'ununsed' defined but not used"