diff --git a/alire_common.gpr b/alire_common.gpr index e479c0c38..39dabb983 100644 --- a/alire_common.gpr +++ b/alire_common.gpr @@ -23,14 +23,30 @@ abstract project Alire_Common is Style_Check_Switches := (); case Style_Check_Mode is when "enabled" => Style_Check_Switches := - ("-gnatwe", -- Warnings as errors - "-gnatyd", -- no DOS line terminators - "-gnatyI", -- no IN mode - "-gnatyO", -- all overrides - "-gnatyS", -- separate lines after THEN/ELSE - "-gnatyu", -- no unnecessary blank lines - "-gnatyx", -- no extra parens around conditionals - "-gnaty-s"); -- relax fwd decl + ( "-gnatwe" -- Warnings as errors + ,"-gnaty3" -- Specify indentation level of 3 + ,"-gnatya" -- Check attribute casing + ,"-gnatyA" -- Use of array index numbers in array attributes + ,"-gnatyB" -- Check Boolean operators + ,"-gnatyb" -- Blanks not allowed at statement end + ,"-gnatyc" -- Check comments + ,"-gnatye" -- Check end/exit labels + ,"-gnatyf" -- No form feeds or vertical tabs + ,"-gnatyh" -- No horizontal tabs + ,"-gnatyi" -- Check if-then layout + ,"-gnatyI" -- check mode IN keywords + ,"-gnatyk" -- Check keyword casing + ,"-gnatyl" -- Check layout + ,"-gnatym" -- Check maximum line length + ,"-gnatyn" -- Check casing of entities in Standard + ,"-gnatyO" -- Check all overriding subprograms explicitly marked + ,"-gnatyp" -- Check pragma casing + ,"-gnatyr" -- Check identifier references casing + ,"-gnatyS" -- Check no statements after THEN/ELSE + ,"-gnatyt" -- Check token spacing + ,"-gnatyu" -- Check unnecessary blank lines + ,"-gnatyx" -- Check extra parentheses + ); when "disabled" => Style_Check_Switches := (); end case; diff --git a/doc/user-changes.md b/doc/user-changes.md index 3ddfb7925..7c6cf32c9 100644 --- a/doc/user-changes.md +++ b/doc/user-changes.md @@ -6,6 +6,23 @@ stay on top of `alr` new features. ## Release `2.0-dev` +### Cache and toolchain storage location overridding + +PR [#1593](https://github.com/alire-project/alire/pull/1593) + +The cache directory can now be set independently of the configuration +directory, by setting the `cache.dir` config builtin to an absolute path. For +example: +``` +alr config --global --set cache.dir /path/to/my/global/cache +``` +Since the cache by default also contains installed toolchains, which may not be +needed to be moved elsewhere, the `toolchain.dir` can be used to dissociate +toolchain location from cache location in a similar way: +``` +alr config --global --set toolchain.dir /path/to/my/toolchains +``` + ### New switch `alr build --stop-after=` PR [#1573](https://github.com/alire-project/alire/pull/1573) diff --git a/src/alire/alire-conditional.adb b/src/alire/alire-conditional.adb index 07847a011..c3eb6168a 100644 --- a/src/alire/alire-conditional.adb +++ b/src/alire/alire-conditional.adb @@ -60,8 +60,10 @@ package body Alire.Conditional is return Result : Boolean := True do for Child of T loop case T.Conjunction is - when Anded => Result := Result and Eval_Children (Child); - when Ored => Result := Result or Eval_Children (Child); + when Anded => + Result := Result and then Eval_Children (Child); + when Ored => + Result := Result or else Eval_Children (Child); end case; end loop; end return; diff --git a/src/alire/alire-config-builtins.ads b/src/alire/alire-config-builtins.ads index 9e29e5e46..b77adaaba 100644 --- a/src/alire/alire-config-builtins.ads +++ b/src/alire/alire-config-builtins.ads @@ -6,6 +6,15 @@ package Alire.Config.Builtins is -- Builtins -- -------------- + -- CACHE + + Cache_Dir : constant Builtin := New_Builtin + (Key => "cache.dir", + Kind => Cfg_Absolute_Path, + Def => "", + Help => + "Directory where Alire will store its cache."); + -- DEPENDENCIES Dependencies_Git_Keep_Repository : constant Builtin := New_Builtin @@ -107,6 +116,13 @@ package Alire.Config.Builtins is "If true, and assistant to select the default toolchain will run " & "when first needed."); + Toolchain_Dir : constant Builtin := New_Builtin + (Key => "toolchain.dir", + Kind => Cfg_Absolute_Path, + Def => "", + Help => + "Directory where Alire will store its toolchains."); + Toolchain_External : constant Builtin := New_Builtin (Key => "toolchain.external", Def => True, diff --git a/src/alire/alire-config-edit.adb b/src/alire/alire-config-edit.adb index a180184f4..b7a846fbd 100644 --- a/src/alire/alire-config-edit.adb +++ b/src/alire/alire-config-edit.adb @@ -181,9 +181,12 @@ package body Alire.Config.Edit is ---------------- function Cache_Path return Absolute_Path - is (if Path = Default_Config_Path - then Platforms.Folders.Cache - else Path / Paths.Cache_Folder_Inside_Working_Folder); + is (if Builtins.Cache_Dir.Get /= "" then + Builtins.Cache_Dir.Get + elsif Path /= Default_Config_Path then + Path / Paths.Cache_Folder_Inside_Working_Folder + else + Platforms.Folders.Cache); -------------- -- Set_Path -- diff --git a/src/alire/alire-config-edit.ads b/src/alire/alire-config-edit.ads index 8fb7d022e..b1055b7e3 100644 --- a/src/alire/alire-config-edit.ads +++ b/src/alire/alire-config-edit.ads @@ -47,10 +47,11 @@ package Alire.Config.Edit is -- * Default per-platform path (see alire-platforms-*) function Cache_Path return Absolute_Path; - -- The location for data that will be recreated if missing; defaults to - -- Platforms.Folders.Cache; if Path above is overridden, the cache will - -- be inside the config folder so as to keep that configuration completely - -- isolated. + -- The location for data that will be recreated if missing; its value in + -- precedence order is: + -- 1) Config builtin 'cache.dir' + -- 2) if Path above is overridden, Path/cache + -- 3) Platforms.Folders.Cache procedure Set_Path (Path : Absolute_Path); -- Override global config folder path diff --git a/src/alire/alire-config.ads b/src/alire/alire-config.ads index 496c229cf..5082ea522 100644 --- a/src/alire/alire-config.ads +++ b/src/alire/alire-config.ads @@ -70,7 +70,7 @@ package Alire.Config is Public : Boolean := True; Check : CLIC.Config.Check_Import := null) return Builtin_Option - with Pre => Help /= "" or not Public; + with Pre => Help /= "" or else not Public; function New_Builtin (Key : CLIC.Config.Config_Key; Def : Boolean; @@ -78,7 +78,7 @@ package Alire.Config is Public : Boolean := True; Check : CLIC.Config.Check_Import := null) return Builtin_Option - with Pre => Help /= "" or not Public; + with Pre => Help /= "" or else not Public; private diff --git a/src/alire/alire-directories.adb b/src/alire/alire-directories.adb index 6b1c68830..8deea106d 100644 --- a/src/alire/alire-directories.adb +++ b/src/alire/alire-directories.adb @@ -331,7 +331,8 @@ package body Alire.Directories is -- like "/c/alire". This is for peace of mind. if Path'Length < 8 then - Recoverable_User_Error ("Suspicious deletion request for path: " & Path); + Recoverable_User_Error + ("Suspicious deletion request for path: " & Path); end if; if Exists (Path) then diff --git a/src/alire/alire-errors.adb b/src/alire/alire-errors.adb index b1a0a0fb8..0ba03be57 100644 --- a/src/alire/alire-errors.adb +++ b/src/alire/alire-errors.adb @@ -136,9 +136,9 @@ package body Alire.Errors is if Line /= "" then Trace.Error ((if I > Lines.First_Index then " " else "") - -- Indentation + -- Indentation - & (if I < Lines.Last_Index and Line (Line'Last) = '.' + & (if I < Lines.Last_Index and then Line (Line'Last) = '.' then Line (Line'First .. Line'Last - 1) else Line) -- The error proper, trimming unwanted final '.' @@ -261,10 +261,10 @@ package body Alire.Errors is Caller : constant Positive := 5 + Stack_Offset - (if Stack_Trace /= "" then 2 else 0); - -- The minus 2 is because in stacks obtained from the original exception: - -- 1) Except name 2) exec name 3) stack start - -- If instead we use AAA.Debug.Stack_Trace: - -- 1) Except name 2) exec name 3) AAA.Debug 4) here 5) caller + -- The minus 2 is because in stacks obtained from an exception: + -- 1) Except name 2) exec name 3) stack start + -- If instead we use AAA.Debug.Stack_Trace: + -- 1) Except name 2) exec name 3) AAA.Debug 4) here 5) caller URL : constant String := "https://github.com/alire-project/alire/issues/new?title=[Bug%20box]"; @@ -282,11 +282,14 @@ package body Alire.Errors is end Put; begin - Trace.Debug (AAA.Debug.Stack_Trace); + if Stack_Trace = "" then + Trace.Debug (AAA.Debug.Stack_Trace); + end if; + -- Otherwise, the exception has been logged elsewhere Put ("******************* BEGIN Alire bug detected *******************"); Put ("Location : " - & (if integer (Stack.Length) >= Caller + & (if Integer (Stack.Length) >= Caller then Stack (Caller) else "")); @@ -297,7 +300,7 @@ package body Alire.Errors is Put ("Report at : " & URL); if Log_Level < Debug or else not Log_Debug then - Put ("Re-run with `-vv -d` for a full stack trace."); + Put ("Re-run with `-vv -d` for a full log and stack trace."); end if; if Recoverable then diff --git a/src/alire/alire-index_on_disk-git.ads b/src/alire/alire-index_on_disk-git.ads index d1562307f..3e1bff4c4 100644 --- a/src/alire/alire-index_on_disk-git.ads +++ b/src/alire/alire-index_on_disk-git.ads @@ -8,7 +8,7 @@ package Alire.Index_On_Disk.Git is function New_Handler (Origin : URL; Name : Restricted_Name; Parent : Any_Path) return Index with - Pre => AAA.Strings.Has_Prefix (Origin, "git+") or + Pre => AAA.Strings.Has_Prefix (Origin, "git+") or else AAA.Strings.Has_Prefix (Origin, "git@"); overriding diff --git a/src/alire/alire-index_on_disk.adb b/src/alire/alire-index_on_disk.adb index 7f74ecbd1..4d6258d38 100644 --- a/src/alire/alire-index_on_disk.adb +++ b/src/alire/alire-index_on_disk.adb @@ -99,8 +99,7 @@ package body Alire.Index_On_Disk is return Outcome_Success; exception when E : others => - return Outcome_From_Exception - (E, "Could not delete index directory: " & This.Metadata_Directory); + return Outcome_From_Exception (E, "Could not delete index directory"); end Delete; ---------- @@ -219,7 +218,7 @@ package body Alire.Index_On_Disk is (Origin (Origin'First + File_Prefix'Length .. Origin'Last)); elsif Origin (Origin'First) = '/' or else not (AAA.Strings.Contains (Origin, "@") - or AAA.Strings.Contains (Origin, "+")) + or else AAA.Strings.Contains (Origin, "+")) then return Process_Local_Index (Origin); end if; diff --git a/src/alire/alire-index_on_disk.ads b/src/alire/alire-index_on_disk.ads index 7d273dbd1..061c48778 100644 --- a/src/alire/alire-index_on_disk.ads +++ b/src/alire/alire-index_on_disk.ads @@ -37,7 +37,7 @@ package Alire.Index_On_Disk is Result : out Outcome; Priority : Priorities := Default_Priority) return Index'Class - with Post => Name in Restricted_Name or not Result.Success; + with Post => Name in Restricted_Name or else not Result.Success; pragma Warnings (On); -- Factory function. -- Name is a user given name used to denote the index (like a git origin). diff --git a/src/alire/alire-publish.adb b/src/alire/alire-publish.adb index 61c9905fc..a0aa7d4e8 100644 --- a/src/alire/alire-publish.adb +++ b/src/alire/alire-publish.adb @@ -562,7 +562,8 @@ package body Alire.Publish is -- Safeguard to avoid tests creating a live pull request, unless -- explicitly desired if OS_Lib.Getenv (Environment.Testsuite, "unset") /= "unset" - and then OS_Lib.Getenv (Environment.Testsuite_Allow, "unset") = "unset" + and then + OS_Lib.Getenv (Environment.Testsuite_Allow, "unset") = "unset" then raise Constraint_Error with "Attempting to go online to create a PR during tests"; @@ -631,9 +632,9 @@ package body Alire.Publish is Git : constant VCSs.Git.VCS := VCSs.Git.Handler; Is_Repo : constant Boolean := Git.Is_Repository (Base_Path (Context)); Archive : constant Relative_Path := Target_Dir / (Milestone & ".tgz"); - -- We used to use tbz2 for locally tar'ed files, but that has an implicit - -- dependency on bzip2 that we are not managing yet, so for now we err on - -- the safe side of built-in tar gzip capabilities. + -- We used to use tbz2 for locally tar'ed files, but that has an + -- implicit dependency on bzip2 that we are not managing yet, so for + -- now we err on the safe side of built-in tar gzip capabilities. ----------------- -- Git_Archive -- @@ -1111,7 +1112,7 @@ package body Alire.Publish is -- already. No matter what, it will be checked again on the -- deployed sources step. - if Revision = "" or Revision = "HEAD" then + if Revision = "" or else Revision = "HEAD" then declare Tmp_Context : Data := (Options => Options, others => <>); begin diff --git a/src/alire/alire-roots.adb b/src/alire/alire-roots.adb index 29630d489..0f4d1a295 100644 --- a/src/alire/alire-roots.adb +++ b/src/alire/alire-roots.adb @@ -39,7 +39,7 @@ package body Alire.Roots is function Stop_Build (Wanted, Actual : Builds.Stop_Points) return Boolean is - use type Builds.Stop_Points; + use type Builds.Stop_Points; begin if Wanted <= Actual then Trace.Debug ("Stopping build as requested at stage: " & Wanted'Image); @@ -270,7 +270,7 @@ package body Alire.Roots is begin This.Build_Prepare (Saved_Profiles => Saved_Profiles, Force_Regen => False, - Stop_After => stop_after); + Stop_After => Stop_After); if Stop_Build (Stop_After, Actual => Generation) then return True; @@ -447,7 +447,7 @@ package body Alire.Roots is Prefix => Prefix, Recursive => False, Quiet => True, - Force => (Force or + Force => (Force or else Action in Reinstall | Replace)); -- Say something if after installing a crate it diff --git a/src/alire/alire-solutions-diffs.adb b/src/alire/alire-solutions-diffs.adb index 3c85b10d5..5cdb6d812 100644 --- a/src/alire/alire-solutions-diffs.adb +++ b/src/alire/alire-solutions-diffs.adb @@ -235,7 +235,7 @@ package body Alire.Solutions.Diffs is if Has_Latter and then Latter.Is_Provided and then (not Has_Former or else - (Former.Has_Release and Then + (Former.Has_Release and then Former.Release.Name_Str /= Latter.Release.Name_Str)) then Add_Change (Chg, "", TTY.Italic (Latter.Release.Name.As_String)); diff --git a/src/alire/alire-solutions.ads b/src/alire/alire-solutions.ads index a6a946aaf..42e4e1efe 100644 --- a/src/alire/alire-solutions.ads +++ b/src/alire/alire-solutions.ads @@ -295,7 +295,7 @@ package Alire.Solutions is -- exact versions. NOTE that the original dependency is thus lost in this -- info. - function Pins (This : Solution) return dependency_Map; + function Pins (This : Solution) return Dependency_Map; -- return all version-pinned dependencies as plain dependencies for a exact -- version. NOTE that the original dependency is thus lost. diff --git a/src/alire/alire-solver.adb b/src/alire/alire-solver.adb index c82392ca3..59b732708 100644 --- a/src/alire/alire-solver.adb +++ b/src/alire/alire-solver.adb @@ -379,7 +379,7 @@ package body Alire.Solver is and then not Unavailable_Direct_Deps.Contains (Solution.Dependency (Crate)) - -- Because no release fulfills it, so "complete" + -- Because no release fulfills it, so "complete" then return False; end if; diff --git a/src/alire/alire-toml_adapters.ads b/src/alire/alire-toml_adapters.ads index 9d950142d..20e8262e5 100644 --- a/src/alire/alire-toml_adapters.ads +++ b/src/alire/alire-toml_adapters.ads @@ -141,7 +141,7 @@ package Alire.TOML_Adapters with Preelaborate is function "+" (Vect : AAA.Strings.Vector) return TOML.TOML_Value; function To_Array (V : TOML.TOML_Value) return TOML.TOML_Value with - Pre => V.Kind in TOML.Atom_Value_Kind or V.Kind = TOML.TOML_Array, + Pre => V.Kind in TOML.Atom_Value_Kind or else V.Kind = TOML.TOML_Array, Post => To_Array'Result.Kind = TOML.TOML_Array; -- Take an atom value and return an array of a single element -- If already an array, do nothing diff --git a/src/alire/alire-toolchains.adb b/src/alire/alire-toolchains.adb index cc1412dab..bb6520a75 100644 --- a/src/alire/alire-toolchains.adb +++ b/src/alire/alire-toolchains.adb @@ -587,7 +587,9 @@ package body Alire.Toolchains is ---------- function Path return Absolute_Path - is (Config.Edit.Cache_Path / "toolchains"); + is (if Config.Builtins.Toolchain_Dir.Get /= "" + then Config.Builtins.Toolchain_Dir.Get + else Config.Edit.Cache_Path / "toolchains"); ------------ -- Deploy -- diff --git a/src/alire/alire-toolchains.ads b/src/alire/alire-toolchains.ads index 55695a614..31c9c0262 100644 --- a/src/alire/alire-toolchains.ads +++ b/src/alire/alire-toolchains.ads @@ -130,7 +130,7 @@ package Alire.Toolchains is function Path return Absolute_Path; -- Returns the base folder in which all toolchain releases live, defaults - -- to /toolchains + -- to /toolchains, overridable via config builtin `toolchain.dir` procedure Deploy (Release : Releases.Release; Location : Any_Path := Path); diff --git a/src/alire/alire-utils-regex.adb b/src/alire/alire-utils-regex.adb index 323839ade..903864bfc 100644 --- a/src/alire/alire-utils-regex.adb +++ b/src/alire/alire-utils-regex.adb @@ -8,8 +8,8 @@ package body Alire.Utils.Regex is function Escape (Literal : String) return String is Targets : constant String := "\()[].*+?^"; - Result : Ustring; - use Ustrings; + Result : UString; + use UStrings; begin for Char of Literal loop if (for some Nono of Targets => Char = Nono) then diff --git a/src/alire/alire-utils-tools.adb b/src/alire/alire-utils-tools.adb index 6845fad50..2e7241c5e 100644 --- a/src/alire/alire-utils-tools.adb +++ b/src/alire/alire-utils-tools.adb @@ -64,7 +64,8 @@ package body Alire.Utils.Tools is when Easy_Graph => (if Distribution in Centos | Fedora | Rhel | Suse then "perl-Graph-Easy" - elsif Distribution /= Msys2 and Distribution /= Arch + elsif Distribution /= Msys2 and then + Distribution /= Arch then "libgraph-easy-perl" else ""), when Git | Tar | Unzip | Curl => diff --git a/src/alire/alire-vcss.adb b/src/alire/alire-vcss.adb index 90d4cb276..52ba6c29b 100644 --- a/src/alire/alire-vcss.adb +++ b/src/alire/alire-vcss.adb @@ -35,7 +35,7 @@ package body Alire.VCSs is ---------- function Kind (Origin : URL) return Kinds is - (if Has_Prefix (Origin, "git+") or Has_Prefix (Origin, "git@") + (if Has_Prefix (Origin, "git+") or else Has_Prefix (Origin, "git@") then VCS_Git else VCS_Unknown); diff --git a/src/alire/alire.adb b/src/alire/alire.adb index 83b596efe..c205b615b 100644 --- a/src/alire/alire.adb +++ b/src/alire/alire.adb @@ -276,7 +276,9 @@ package body Alire is -- Recoverable_Error -- ----------------------- - procedure Recoverable_User_Error (Msg : String; Recover : Boolean := Force) is + procedure Recoverable_User_Error (Msg : String; + Recover : Boolean := Force) + is Info : constant String := " (This error can be overridden with " & TTY.Terminal ("--force") & ".)"; begin diff --git a/src/alr/alr-commands-edit.adb b/src/alr/alr-commands-edit.adb index 2770d274a..d0de9820a 100644 --- a/src/alr/alr-commands-edit.adb +++ b/src/alr/alr-commands-edit.adb @@ -29,7 +29,7 @@ package body Alr.Commands.Edit is Put_Info ("The editor command has been unset."); end if; - Put_Info ("You can change this setting by running the following command:"); + Put_Info ("You can change editors by running the following command:"); Put_Info ("`alr edit " & Switch_Select & "`"); end Set_Config_Cmd; @@ -62,7 +62,7 @@ package body Alr.Commands.Edit is procedure Query_Editor is use AAA.Strings; - use Clic.User_Input; + use CLIC.User_Input; package Builtins renames Alire.Config.Builtins; diff --git a/src/alr/alr-commands-edit.ads b/src/alr/alr-commands-edit.ads index 9ade94d55..4854dcf70 100644 --- a/src/alr/alr-commands-edit.ads +++ b/src/alr/alr-commands-edit.ads @@ -35,6 +35,6 @@ private type Command is new Commands.Command with record Prj : aliased GNAT.Strings.String_Access; - Set : aliased Boolean; --select-editor + Set : aliased Boolean; -- --select-editor end record; end Alr.Commands.Edit; diff --git a/src/alr/alr-commands-get.adb b/src/alr/alr-commands-get.adb index 8daa34980..3f1145d92 100644 --- a/src/alr/alr-commands-get.adb +++ b/src/alr/alr-commands-get.adb @@ -328,12 +328,12 @@ package body Alr.Commands.Get is Allowed : constant Alire.Dependencies.Dependency := Alire.Dependencies.From_String (Args (1)); begin - if Cmd.Build and Cmd.Only then + if Cmd.Build and then Cmd.Only then Reportaise_Wrong_Arguments ("--only is incompatible with --build"); end if; - if Cmd.Dirname and (Cmd.Build or else Cmd.Only) then + if Cmd.Dirname and then (Cmd.Build or else Cmd.Only) then Reportaise_Wrong_Arguments ("--dirname is incompatible with other switches"); end if; diff --git a/src/alr/alr-commands-printenv.adb b/src/alr/alr-commands-printenv.adb index c92bda012..a788bcccd 100644 --- a/src/alr/alr-commands-printenv.adb +++ b/src/alr/alr-commands-printenv.adb @@ -72,7 +72,7 @@ package body Alr.Commands.Printenv is & "because running " & TTY.Terminal ("alr printenv") & " after " & "manifest editions may trigger an automatic synchronization that " & "could produce extra output not intended as environment variables.") - .New_line + .New_Line .Append ("Examples:") .Append (" - eval $(alr -n -q printenv --unix)") .Append (" - alr -n -q printenv --powershell | Invoke-Expression") diff --git a/src/alr/alr-commands-show.adb b/src/alr/alr-commands-show.adb index 93094aeab..b18c55964 100644 --- a/src/alr/alr-commands-show.adb +++ b/src/alr/alr-commands-show.adb @@ -440,7 +440,7 @@ package body Alr.Commands.Show is end if; if Args.Count = 0 then - if Alire.Root.Current.Outside and not Cmd.Nested then + if Alire.Root.Current.Outside and then not Cmd.Nested then Reportaise_Wrong_Arguments ("Cannot proceed without a crate name"); elsif not Cmd.Nested then @@ -450,8 +450,8 @@ package body Alr.Commands.Show is if Cmd.External and then (Cmd.Dependents.all /= "unset" - or Cmd.Detect or Cmd.Jekyll or Cmd.Graph or Cmd.Solve - or Cmd.Tree) + or else Cmd.Detect or else Cmd.Jekyll or else Cmd.Graph + or else Cmd.Solve or else Cmd.Tree) then Reportaise_Wrong_Arguments ("Switch --external can only be combined with --system"); diff --git a/src/alr/alr-commands-toolchain.adb b/src/alr/alr-commands-toolchain.adb index bac265cf4..e90503fcd 100644 --- a/src/alr/alr-commands-toolchain.adb +++ b/src/alr/alr-commands-toolchain.adb @@ -418,12 +418,12 @@ package body Alr.Commands.Toolchain is ("The provided switches cannot be used simultaneously"); end if; - if (Cmd.Install or Cmd.Uninstall) and then Args.Is_Empty then + if (Cmd.Install or else Cmd.Uninstall) and then Args.Is_Empty then Reportaise_Wrong_Arguments ("No release specified"); end if; if not Args.Is_Empty and then - not (Cmd.Install or Cmd.Uninstall or Cmd.S_Select) + not (Cmd.Install or else Cmd.Uninstall or else Cmd.S_Select) then Reportaise_Wrong_Arguments ("Specify the action to perform with the crate"); diff --git a/src/alr/alr-main.adb b/src/alr/alr-main.adb index 896ce26f4..313d0bbd3 100644 --- a/src/alr/alr-main.adb +++ b/src/alr/alr-main.adb @@ -13,6 +13,7 @@ begin Commands.Execute; exception when E : Program_Error => + Alire.Log_Exception (E); Alire.Errors.Program_Error (Explanation => Alire.Errors.Get (E), Recoverable => False, diff --git a/testsuite/tests/config/cache-relocation/test.py b/testsuite/tests/config/cache-relocation/test.py new file mode 100644 index 000000000..a6e4c63e4 --- /dev/null +++ b/testsuite/tests/config/cache-relocation/test.py @@ -0,0 +1,36 @@ +""" +Check cache location overrides in increasing order of precedence. +""" + +from drivers.alr import run_alr +from drivers.asserts import assert_match +from drivers.helpers import on_windows + +if on_windows(): + drive = "C:" +else: + drive = "" + +# Default cache location (inside test config dir) +assert_match(r".*cache folder:[^\n]*config__cache-relocation/alr-config/cache", + run_alr("version").out.replace("\\", "/")) + +# Check toolchain location inside cache location +assert_match(r".*toolchain folder:[^\n]*config__cache-relocation/alr-config/cache/toolchains", + run_alr("version").out.replace("\\", "/")) + +# Override via config (takes precedence) +run_alr("config", "--global", "--set", "cache.dir", f"{drive}/relocated-to-root") +assert_match(r".*cache folder:[^\n]*/relocated-to-root", + run_alr("version").out.replace("\\", "/")) + +# Check toolchain location inside cache location +assert_match(r".*toolchain folder:[^\n]*/relocated-to-root/toolchains", + run_alr("version").out.replace("\\", "/")) + +# Check toolchain override via config (takes precedence over cache override) +run_alr("config", "--global", "--set", "toolchain.dir", f"{drive}/relocated-toolchains") +assert_match(r".*toolchain folder:[^\n]*/relocated-toolchains", + run_alr("version").out.replace("\\", "/")) + +print("SUCCESS") diff --git a/testsuite/tests/config/cache-relocation/test.yaml b/testsuite/tests/config/cache-relocation/test.yaml new file mode 100644 index 000000000..278a97189 --- /dev/null +++ b/testsuite/tests/config/cache-relocation/test.yaml @@ -0,0 +1,4 @@ +driver: python-script +build_mode: both # one of shared, sandboxed, both (default) +indexes: + compiler_only_index: {} diff --git a/testsuite/tests/debug/enabled-dump-exception/test.py b/testsuite/tests/debug/enabled-dump-exception/test.py index 6ff88037a..f023ad567 100644 --- a/testsuite/tests/debug/enabled-dump-exception/test.py +++ b/testsuite/tests/debug/enabled-dump-exception/test.py @@ -9,10 +9,12 @@ def check_output(dump): - assert_match( - '''stderr: PROGRAM_ERROR -stderr: Raising forcibly -stderr: raised PROGRAM_ERROR : Raising forcibly.* + assert_match('''\ +.* +ERROR: Location : Alr.Commands.Dev.Execute at alr-commands-dev.adb:.* +ERROR: Extra info: Raising forcibly +ERROR: Report at : .* +ERROR: Re-run with `-vv -d` for a full log and stack trace.\ ''', dump) @@ -24,13 +26,19 @@ def check_output(dump): debug=False, complain_on_error=False).out) # Check ordinary non-debug output: -assert_eq(run_alr('dev', '--raise', debug=False, complain_on_error=False).out, - "ERROR: Raising forcibly\n" - "ERROR: alr encountered an unexpected error, re-run with -d for details.\n") +assert_match( + ".*" + "ERROR: Extra info: Raising forcibly.*" + "ERROR: Re-run with `-vv -d` for a full log and stack trace", + run_alr('dev', '--raise', debug=False, complain_on_error=False).out + ) # Check exception from finalization : -assert_eq(run_alr('dev', '--raise-finalization', debug=False, complain_on_error=False).out, +assert_match( + ".*" "ERROR: Raising forcibly from finalization\n" - "ERROR: alr encountered an unexpected error, re-run with -d for details.\n") + "ERROR: alr encountered an unexpected error, re-run with -d for details.\n" + "ERROR: error location: Alr.Commands.Dev.Raise_From_Finalization.Finalize at alr-commands-dev.adb:49", + run_alr('dev', '--raise-finalization', debug=False, complain_on_error=False).out) print('SUCCESS') diff --git a/testsuite/tests/misc/env-traceback/test.py b/testsuite/tests/misc/env-traceback/test.py index 8e4506e0a..d765b0a11 100644 --- a/testsuite/tests/misc/env-traceback/test.py +++ b/testsuite/tests/misc/env-traceback/test.py @@ -7,9 +7,14 @@ from drivers.asserts import assert_eq, assert_match def check_no_traceback(): - assert_eq('ERROR: Raising forcibly\n' - 'ERROR: alr encountered an unexpected error,' - ' re-run with -d for details.\n', + assert_match("""\ +ERROR: .* BEGIN Alire bug detected .* +ERROR: Location : Alr.Commands.Dev.Execute at alr-commands-dev.adb:.* +ERROR: Extra info: Raising forcibly +ERROR: Report at : .* +ERROR: Re-run with `-vv -d` for a full log and stack trace. +ERROR: .* END Alire bug detected .*\ +""", run_alr("dev", "--raise", debug=False, complain_on_error=False).out)