bool
context::execution_failed_p () const
{
- /* Equivalent to (seen_error () || werrorcount), but on
- this context, rather than global_dc. */
- return (diagnostic_count (kind::error)
+ return (diagnostic_count (kind::fatal)
+ || diagnostic_count (kind::error)
|| diagnostic_count (kind::sorry)
|| diagnostic_count (kind::werror));
}
{
case kind::warning:
return "warning";
+ case kind::fatal:
case kind::error:
return "error";
case kind::note:
--- /dev/null
+from htmltest import *
+
+import pytest
+
+@pytest.fixture(scope='function', autouse=True)
+def html_tree():
+ return html_tree_from_env()
+
+def test_results(html_tree):
+ root = html_tree.getroot ()
+ assert root.tag == make_tag('html')
+
+ head = root.find('xhtml:head', ns)
+ assert head is not None
+
+ body = root.find('xhtml:body', ns)
+ assert body is not None
+
+ diag_list = body.find("./xhtml:div[@class='gcc-diagnostic-list']", ns)
+ assert len(diag_list)
+
+ diag = diag_list.find('xhtml:div[@id="gcc-diag-0"]', ns)
+ assert diag is not None
+ message = diag.find("./xhtml:div[@class='gcc-message']", ns)
+ assert message is not None
+ assert message[0].tag == make_tag('strong')
+ assert message[0].text == 'fatal error: '
+ assert message[0].tail.startswith(' this-does-not-exist.h:')
--- /dev/null
+from sarif import *
+
+import pytest
+
+@pytest.fixture(scope='function', autouse=True)
+def sarif():
+ return sarif_from_env()
+
+def test_execution_unsuccessful(sarif):
+ runs = sarif['runs']
+ run = runs[0]
+
+ invocations = run['invocations']
+ assert len(invocations) == 1
+ invocation = invocations[0]
+
+ # We expect the fatal error to make executionSuccessful be false
+ assert invocation['executionSuccessful'] == False
+
+def test_fatal_error(sarif):
+ runs = sarif['runs']
+ run = runs[0]
+ results = run['results']
+
+ assert len(results) == 1
+
+ result = results[0]
+ assert result['level'] == 'error'
+ assert result['message']['text'] == "this-does-not-exist.h: No such file or directory"
--- /dev/null
+/* { dg-do compile } */
+/* { dg-additional-options "-fdiagnostics-add-output=sarif" } */
+/* { dg-additional-options "-fdiagnostics-add-output=experimental-html:javascript=no" } */
+
+#include "this-does-not-exist.h"
+
+/* { dg-prune-output "fatal error:" }
+ { dg-prune-output "compilation terminated" }
+ { dg-final { verify-sarif-file } }
+ { dg-final { run-sarif-pytest fatal-error.c "fatal-error-sarif.py" } }
+ { dg-final { run-html-pytest fatal-error.c "fatal-error-html.py" } } */