Skip to content

Commit

Permalink
nameres: return error code when unexpected name resolution failures o…
Browse files Browse the repository at this point in the history
…ccur
  • Loading branch information
thvnx committed Jul 19, 2024
1 parent 866255b commit 8c520b3
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 2 deletions.
18 changes: 17 additions & 1 deletion testsuite/ada/nameres.adb
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ procedure Nameres is
Help => "Only output failures on stdout. Note that this triggers"
& " failures logging even when --quiet is passed.");

package No_Abort_On_Failures is new Parse_Flag
(App.Args.Parser, Long => "--no-abort-on-failures",
Help => "Expected name resolution failures: do not call Abort_App"
& " if some name resolution failed");

package Imprecise_Fallback is new Parse_Flag
(App.Args.Parser, Long => "--imprecise-fallback",
Help => "Activate fallback mechanism for name resolution");
Expand Down Expand Up @@ -1447,7 +1452,8 @@ procedure Nameres is
is
pragma Unreferenced (Context);

Watermark : GNATCOLL.Memory.Watermark_Info;
Watermark : GNATCOLL.Memory.Watermark_Info;
App_Failed : Boolean := False;
begin
-- Measure time and memory before post-processing

Expand All @@ -1469,8 +1475,18 @@ procedure Nameres is
end;
end if;

for Job of Jobs loop
for File_Stats of Job_Data (Job.ID).Stats.File_Stats loop
App_Failed := App_Failed or File_Stats.Nb_Fails > 0;
end loop;
end loop;

Free (Job_Data);

if App_Failed and then not Args.No_Abort_On_Failures.Get then
Abort_App ("Name resolution failed.");
end if;

Put_Line ("Done.");
end App_Post_Process;

Expand Down
8 changes: 7 additions & 1 deletion testsuite/drivers/name_resolution_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ class NameResolutionDriver(BaseDriver):
* ``runtime_name``: Name of the runtime to use when loading the project
(``--RTS`` nameres switch).
* ``expect_fail``: Do not abort the nameres application if failures are
expected during resolution.
"""

perf_supported = True
Expand Down Expand Up @@ -128,7 +131,7 @@ def run(self):
# just on nameres-specific pragmas) and display only error messages,
# not traceback (for test output stability).
if self.test_env.get("batch"):
args += ["--all", "--no-traceback"]
args += ["--all", "--no-traceback", "--no-abort-on-failures"]

# In perf mode, we need nameres not to print anything
if not self.perf_mode:
Expand All @@ -147,6 +150,9 @@ def run(self):
if runtime_name:
args.append(f"--RTS={runtime_name}")

if self.test_env.get("expect_fail"):
args.append("--no-abort-on-failures")

# Add optional explicit list of sources to process
args += input_sources

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
driver: name-resolution
input_sources: [test.adb]
expect_fail: true
1 change: 1 addition & 0 deletions testsuite/tests/name_resolution/if_stmt_alt_fail/test.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
driver: name-resolution
input_sources: [test.adb]
expect_fail: true
1 change: 1 addition & 0 deletions testsuite/tests/name_resolution/late_use_clause/test.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
driver: name-resolution
input_sources: [testuse.adb]
expect_fail: true
1 change: 1 addition & 0 deletions testsuite/tests/name_resolution/test_expect_fail/test.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
driver: name-resolution
input_sources: [test.adb]
expect_fail: true
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
driver: name-resolution
input_sources: [test_valid.adb, test_invalid.adb, test_task.adb]
expect_fail: true

0 comments on commit 8c520b3

Please sign in to comment.