From 20c29848d54d79ad572ac18027f25ff45a3bec61 Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Thu, 23 Jan 2025 11:43:18 +0100 Subject: [PATCH] feat: improved reporting for errors in linked crates (#1824) --- src/alire/alire-errors.adb | 12 +++++++----- src/alire/alire-errors.ads | 3 ++- src/alire/alire-user_pins.adb | 10 +++++++--- testsuite/Dockerfile | 3 ++- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/alire/alire-errors.adb b/src/alire/alire-errors.adb index 0ba03be57..f236e2fe4 100644 --- a/src/alire/alire-errors.adb +++ b/src/alire/alire-errors.adb @@ -126,7 +126,9 @@ package body Alire.Errors is -- Pretty_Print -- ------------------ - procedure Pretty_Print (Error : String) is + procedure Pretty_Print (Error : String; + Level : Trace.Levels := Trace.Error) + is Lines : constant AAA.Strings.Vector := Split (Error, ASCII.LF); begin for I in Lines.First_Index .. Lines.Last_Index loop @@ -134,7 +136,7 @@ package body Alire.Errors is Line : constant String := Trim (Lines (I)); begin if Line /= "" then - Trace.Error + Trace.Log ((if I > Lines.First_Index then " " else "") -- Indentation @@ -146,11 +148,11 @@ package body Alire.Errors is & (if I < Lines.Last_Index and then Line (Line'Last) /= ':' then ":" - else "") + else ""), -- Trailing ':' except for last line - ); + Level); else - Trace.Error (Line); + Trace.Log (Line, Level); end if; end; end loop; diff --git a/src/alire/alire-errors.ads b/src/alire/alire-errors.ads index 1a688ed22..a4a2ba596 100644 --- a/src/alire/alire-errors.ads +++ b/src/alire/alire-errors.ads @@ -52,7 +52,8 @@ package Alire.Errors with Preelaborate is -- Returns the error for Ex if it exists, or defaults to Exception_Message. -- The stored error is cleared. - procedure Pretty_Print (Error : String); + procedure Pretty_Print (Error : String; + Level : Trace.Levels := Trace.Error); -- Split Error at LFs to prefix each sub-error in a new line with the -- appropriate tracing prefix. Also, from the second line on, messages are -- indented. This way, several top-level errors are easier to distinguish. diff --git a/src/alire/alire-user_pins.adb b/src/alire/alire-user_pins.adb index fb3992d26..653a66d36 100644 --- a/src/alire/alire-user_pins.adb +++ b/src/alire/alire-user_pins.adb @@ -1,6 +1,7 @@ with Ada.Directories; with Alire.Directories; +with Alire.Errors; with Alire.Origins; with Alire.Roots.Optional; with Alire.Utils.User_Input; @@ -363,9 +364,12 @@ package body Alire.User_Pins is if not Root.Is_Valid then Put_Warning - ("Pin for " & Utils.TTY.Name (Crate) & - " does not contain an Alire " & - "manifest. It will be used as a raw GNAT project."); + ("Pin for " & Utils.TTY.Name (Crate) & " at " + & Utils.TTY.URL (Destination) + & " does not contain a valid Alire manifest. " + & "It will be used as a raw GNAT project."); + Errors.Pretty_Print + ("Pin diagnostic is:" & New_Line & Root.Message, Trace.Warning); end if; end; diff --git a/testsuite/Dockerfile b/testsuite/Dockerfile index 3a93b9b4f..b1a134ec5 100644 --- a/testsuite/Dockerfile +++ b/testsuite/Dockerfile @@ -1,6 +1,7 @@ # This docker image is used in tests with the `docker_wrapper` driver. -FROM alire/gnat:ubuntu-lts +# Latest tested is 24.04 +FROM alire/gnat:ubuntu-lts RUN useradd -m -s /bin/bash user && \ chown user:user /home/user && \