From 2bea9f73fc455bacb81f19f0e7ab727789b792d3 Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Fri, 2 Jun 2023 13:03:13 +0200 Subject: [PATCH] Unify naming of session/working folder as workspace (#1390) --- src/alire/alire-config.ads | 2 +- src/alire/alire-paths.ads | 4 +-- .../alire-properties-actions-executor.ads | 3 +- src/alire/alire-roots-optional.adb | 6 ++-- src/alire/alire-roots.ads | 4 +-- src/alr/alr-commands-clean.adb | 2 +- src/alr/alr-commands-edit.adb | 2 +- src/alr/alr-commands-exec.adb | 2 +- src/alr/alr-commands-get.adb | 2 +- src/alr/alr-commands-install.adb | 2 +- src/alr/alr-commands-pin.adb | 2 +- src/alr/alr-commands-printenv.adb | 2 +- src/alr/alr-commands-run.adb | 2 +- src/alr/alr-commands-show.adb | 4 +-- src/alr/alr-commands-toolchain.adb | 2 +- src/alr/alr-commands-update.adb | 2 +- src/alr/alr-commands-withing.adb | 2 +- src/alr/alr-commands.adb | 28 +++++++++---------- src/alr/alr-commands.ads | 14 +++++----- src/alr/alr-files.ads | 2 +- src/alr/alr-os_lib.ads | 2 +- testsuite/tests/misc/bad-tomlfile/test.py | 2 +- testsuite/tests/misc/clean-end/test.py | 4 +-- .../tests/pin/manifest-invalid-pins/test.py | 2 +- 24 files changed, 50 insertions(+), 49 deletions(-) diff --git a/src/alire/alire-config.ads b/src/alire/alire-config.ads index d23c6480..ff38ec52 100644 --- a/src/alire/alire-config.ads +++ b/src/alire/alire-config.ads @@ -41,7 +41,7 @@ package Alire.Config with Preelaborate is -- appropriate caret/tilde. Toolchain_Assistant : constant Config_Key := "toolchain.assistant"; - -- When true (default), on first `Requires_Valid_Session`, the + -- When true (default), on first `Requires_Workspace`, the -- assistant to select a gnat compiler and corresponding gprbuild -- will be launched. diff --git a/src/alire/alire-paths.ads b/src/alire/alire-paths.ads index 13e70e0c..17dcf8d6 100644 --- a/src/alire/alire-paths.ads +++ b/src/alire/alire-paths.ads @@ -12,8 +12,8 @@ package Alire.Paths with Preelaborate is Temp_Folder_Inside_Working_Folder : constant Relative_Path := "tmp"; Working_Folder_Inside_Root : constant Relative_Path := "alire"; - -- Folder within a working release that will contain metadata/build files, - -- dependency releases, and session. + -- Folder within a workspace that will contain metadata/build files, + -- dependency releases, etc. Scripts_Graph_Easy : constant String := "graph-easy"; -- Script for ASCII graphs diff --git a/src/alire/alire-properties-actions-executor.ads b/src/alire/alire-properties-actions-executor.ads index e2ea6f86..4a1602c9 100644 --- a/src/alire/alire-properties-actions-executor.ads +++ b/src/alire/alire-properties-actions-executor.ads @@ -8,7 +8,8 @@ package Alire.Properties.Actions.Executor is Env : Properties.Vector; Moment : Moments); -- Run Release actions that apply to a given environment. IMPORTANT: the - -- working directory at the moment of this call should be the release root. + -- working directory at the moment of this call should be the workspace + -- root. procedure Execute_Actions (Release : Releases.Release; diff --git a/src/alire/alire-roots-optional.adb b/src/alire/alire-roots-optional.adb index 831a6b15..4b2c60c6 100644 --- a/src/alire/alire-roots-optional.adb +++ b/src/alire/alire-roots-optional.adb @@ -13,8 +13,8 @@ package body Alire.Roots.Optional is Root_Not_Detected : constant Root := (Alire.Outcome_Failure - ("Could not detect a session folder" - & " at current or parent locations", + ("Could not detect an " & Paths.Crate_File_Name + & " manifest at current or parent locations", Report => False) with Data => (Status => Outside)); @@ -77,7 +77,7 @@ package body Alire.Roots.Optional is Trace.Debug ("No root can be detected because given path is empty"); return Root_Not_Detected; - -- This happens when detection of session folders in parent + -- This happens when detection of a workspace in parent -- folders has been already attempted by the caller, so it -- ends calling here with an empty path. end if; diff --git a/src/alire/alire-roots.ads b/src/alire/alire-roots.ads index e14e863b..ca23be14 100644 --- a/src/alire/alire-roots.ads +++ b/src/alire/alire-roots.ads @@ -19,7 +19,7 @@ package Alire.Roots is Crate_File_Name : String renames Paths.Crate_File_Name; -- Type used to encapsulate the information about the working context. - -- A valid alire working dir is one containing an alire/crate.toml file. + -- A valid alire workspace is one containing an alire/crate.toml file. type Root (<>) is tagged private; @@ -60,7 +60,7 @@ package Alire.Roots is Path : Absolute_Path; Env : Properties.Vector) return Root; -- From existing release - -- Path must point to the session folder (parent of alire metadata folder) + -- Path must point to the workspace (parent of alire metadata folder) procedure Set (This : in out Root; Solution : Solutions.Solution) with diff --git a/src/alr/alr-commands-clean.adb b/src/alr/alr-commands-clean.adb index fea01771..3770e75b 100644 --- a/src/alr/alr-commands-clean.adb +++ b/src/alr/alr-commands-clean.adb @@ -121,7 +121,7 @@ package body Alr.Commands.Clean is begin if not (Cmd.Cache or else Cmd.Temp) then - Cmd.Requires_Valid_Session; + Cmd.Requires_Workspace; Cmd.Root.Export_Build_Environment; Trace.Detail ("Cleaning project and dependencies..."); diff --git a/src/alr/alr-commands-edit.adb b/src/alr/alr-commands-edit.adb index e1c73a5e..b976c016 100644 --- a/src/alr/alr-commands-edit.adb +++ b/src/alr/alr-commands-edit.adb @@ -75,7 +75,7 @@ package body Alr.Commands.Edit is ("No editor defined in config key '" & Keys.Editor_Cmd & "'."); end if; - Cmd.Requires_Valid_Session; + Cmd.Requires_Workspace; Cmd.Root.Export_Build_Environment; diff --git a/src/alr/alr-commands-exec.adb b/src/alr/alr-commands-exec.adb index 77ff4826..cf50a2bc 100644 --- a/src/alr/alr-commands-exec.adb +++ b/src/alr/alr-commands-exec.adb @@ -29,7 +29,7 @@ package body Alr.Commands.Exec is Cmd_Args : AAA.Strings.Vector := Args; Cmd_Name : constant String := Cmd_Args.First_Element; begin - Cmd.Requires_Valid_Session; + Cmd.Requires_Workspace; Cmd.Root.Export_Build_Environment; -- Remove command name from the arguments diff --git a/src/alr/alr-commands-get.adb b/src/alr/alr-commands-get.adb index c1fcc191..7dd27bdc 100644 --- a/src/alr/alr-commands-get.adb +++ b/src/alr/alr-commands-get.adb @@ -140,7 +140,7 @@ package body Alr.Commands.Get is Cmd.Root.Set (Solution); -- At this point, both crate and lock files must exist and - -- be correct, so the working session is correct. Errors with + -- be correct, so the workspace is correct. Errors with -- dependencies can still occur, but these are outside of the -- retrieved crate and might be corrected manipulating dependencies -- and updating. diff --git a/src/alr/alr-commands-install.adb b/src/alr/alr-commands-install.adb index 83c2311e..35a9679d 100644 --- a/src/alr/alr-commands-install.adb +++ b/src/alr/alr-commands-install.adb @@ -17,7 +17,7 @@ package body Alr.Commands.Install is begin -- If nothing given, we must be in workspace if not Cmd.Info and then Args.Is_Empty then - Cmd.Requires_Valid_Session + Cmd.Requires_Workspace (Error => "Give a crate name to install or enter a local crate"); end if; diff --git a/src/alr/alr-commands-pin.adb b/src/alr/alr-commands-pin.adb index 7db569ee..ec189926 100644 --- a/src/alr/alr-commands-pin.adb +++ b/src/alr/alr-commands-pin.adb @@ -142,7 +142,7 @@ package body Alr.Commands.Pin is ("Cannot specify both a branch and a commit simultaneously"); end if; - Cmd.Requires_Valid_Session; + Cmd.Requires_Workspace; -- Listing of pins diff --git a/src/alr/alr-commands-printenv.adb b/src/alr/alr-commands-printenv.adb index b86f2b09..2a765de1 100644 --- a/src/alr/alr-commands-printenv.adb +++ b/src/alr/alr-commands-printenv.adb @@ -27,7 +27,7 @@ package body Alr.Commands.Printenv is Reportaise_Wrong_Arguments ("Specify at most one subcommand"); end if; - Cmd.Requires_Valid_Session; + Cmd.Requires_Workspace; declare Context : constant Alire.Environment.Context := diff --git a/src/alr/alr-commands-run.adb b/src/alr/alr-commands-run.adb index 7261945e..6c651719 100644 --- a/src/alr/alr-commands-run.adb +++ b/src/alr/alr-commands-run.adb @@ -103,7 +103,7 @@ package body Alr.Commands.Run is end List; begin - Cmd.Requires_Valid_Session; + Cmd.Requires_Workspace; -- Validation if Cmd.List diff --git a/src/alr/alr-commands-show.adb b/src/alr/alr-commands-show.adb index 677f2422..ebaff44f 100644 --- a/src/alr/alr-commands-show.adb +++ b/src/alr/alr-commands-show.adb @@ -64,7 +64,7 @@ package body Alr.Commands.Show is procedure Report (Name : Alire.Crate_Name; Versions : Semver.Extended.Version_Set; Current : Boolean; - -- session or command-line requested release + -- workspace or command-line requested release Cmd : in out Command) is begin @@ -438,7 +438,7 @@ package body Alr.Commands.Show is Reportaise_Wrong_Arguments ("Cannot proceed without a crate name"); elsif not Cmd.Nested then - Cmd.Requires_Valid_Session; + Cmd.Requires_Workspace; end if; end if; diff --git a/src/alr/alr-commands-toolchain.adb b/src/alr/alr-commands-toolchain.adb index 1c4a97b9..0f9b61fd 100644 --- a/src/alr/alr-commands-toolchain.adb +++ b/src/alr/alr-commands-toolchain.adb @@ -458,7 +458,7 @@ package body Alr.Commands.Toolchain is Alire.Toolchains.Detect_Externals; if Cmd.Local then - Cmd.Requires_Valid_Session; + Cmd.Requires_Workspace; end if; if Args.Count = 0 then diff --git a/src/alr/alr-commands-update.adb b/src/alr/alr-commands-update.adb index cb2f9fa2..1afeee21 100644 --- a/src/alr/alr-commands-update.adb +++ b/src/alr/alr-commands-update.adb @@ -35,7 +35,7 @@ package body Alr.Commands.Update is end Parse_Allowed; begin - Cmd.Requires_Valid_Session (Sync => False); + Cmd.Requires_Workspace (Sync => False); -- The user has explicitly requested an update, so it makes no sense to -- sync previously, or the update would never find changes. diff --git a/src/alr/alr-commands-withing.adb b/src/alr/alr-commands-withing.adb index ec5cb38c..8660ea8b 100644 --- a/src/alr/alr-commands-withing.adb +++ b/src/alr/alr-commands-withing.adb @@ -241,7 +241,7 @@ package body Alr.Commands.Withing is end Check; begin - Cmd.Requires_Valid_Session; + Cmd.Requires_Workspace; if Cmd.URL.all /= "" then Flags := Flags + 1; diff --git a/src/alr/alr-commands.adb b/src/alr/alr-commands.adb index e7cab9c7..52767302 100644 --- a/src/alr/alr-commands.adb +++ b/src/alr/alr-commands.adb @@ -198,10 +198,10 @@ package body Alr.Commands is end Create_Alire_Folders; -------------------------- - -- Enter_Working_Folder -- + -- Enter_Workspace_Root -- -------------------------- - function Enter_Working_Folder return Alire.Directories.Destination is + function Enter_Workspace_Root return Alire.Directories.Destination is begin declare Candidate_Folder : constant String := @@ -212,11 +212,11 @@ package body Alr.Commands is return new String'(Candidate_Folder); else Trace.Debug - ("Not entering working folder, no valid alire root found"); + ("Not entering workspace, no valid alire root found"); return Alire.Directories.Stay_In_Current; end if; end; - end Enter_Working_Folder; + end Enter_Workspace_Root; ------------------ -- Query_Policy -- @@ -277,13 +277,13 @@ package body Alr.Commands is Force => Force_Reload).Assert; end Requires_Full_Index; - ---------------------------- - -- Requires_Valid_Session -- - ---------------------------- + ------------------------ + -- Requires_Workspace -- + ------------------------ - procedure Requires_Valid_Session (Cmd : in out Command'Class; - Sync : Boolean := True; - Error : String := "") is + procedure Requires_Workspace (Cmd : in out Command'Class; + Sync : Boolean := True; + Error : String := "") is use Alire; Unchecked : Alire.Roots.Optional.Root renames Cmd.Optional_Root; @@ -322,7 +322,7 @@ package body Alr.Commands is .Wrap (if Error /= "" then Error - else "Cannot continue with invalid session") + else "Cannot continue without a workspace") .Wrap (Unchecked.Message) .Get); end if; @@ -414,7 +414,7 @@ package body Alr.Commands is -- As we just created the empty lockfile, we force the update end if; end; - end Requires_Valid_Session; + end Requires_Workspace; ------------- -- Execute -- @@ -549,7 +549,7 @@ package body Alr.Commands is function Has_Root (Cmd : in out Command'Class) return Boolean is begin - Cmd.Requires_Valid_Session; + Cmd.Requires_Workspace; return True; exception when Alire.Checked_Error => @@ -565,7 +565,7 @@ package body Alr.Commands is is begin if not Cmd.Optional_Root.Is_Valid then - Cmd.Requires_Valid_Session; + Cmd.Requires_Workspace; end if; return Cmd.Optional_Root.Value; diff --git a/src/alr/alr-commands.ads b/src/alr/alr-commands.ads index b999c903..1d9b26b7 100644 --- a/src/alr/alr-commands.ads +++ b/src/alr/alr-commands.ads @@ -59,17 +59,17 @@ package Alr.Commands is -- Unless Force_Reload, if the index is not empty we no nothing. When -- strict, don't allow unknown values in enums. - procedure Requires_Valid_Session (Cmd : in out Command'Class; - Sync : Boolean := True; - Error : String := ""); - -- Verifies that a valid working dir is in scope. After calling it, + procedure Requires_Workspace (Cmd : in out Command'Class; + Sync : Boolean := True; + Error : String := ""); + -- Verifies that a valid workspace is in scope. After calling it, -- Cmd.Root will be usable if alr was run inside a Root. If Sync, enforce -- that the manifest, lockfile and dependencies on disk are in sync, by -- performing a silent update. If not Sync, only a minimal empty lockfile -- is created. If Error, replace the first generic error message with it. function Has_Root (Cmd : in out Command'Class) return Boolean; - -- True when Requires_Valid_Session would succeed, false otherwise + -- True when Requires_Workspace would succeed, false otherwise procedure Load (Cmd : Command'Class; Crate : Alire.Crate_Name; @@ -95,8 +95,8 @@ package Alr.Commands is -- Returns the instructions to restrict version sets, for use in -- Long_Description help functions. - function Enter_Working_Folder return Alire.Directories.Destination; - -- Attempt to find the root alire working dir if deeper inside it + function Enter_Workspace_Root return Alire.Directories.Destination; + -- Attempt to find the root alire workspace if deeper inside it private diff --git a/src/alr/alr-files.ads b/src/alr/alr-files.ads index e83fe52d..d9d190af 100644 --- a/src/alr/alr-files.ads +++ b/src/alr/alr-files.ads @@ -17,6 +17,6 @@ package Alr.Files is function Locate_Any_GPR_File return Natural; -- Says if there's any *.gpr file in current folder (making the cwd a - -- plausible alr working dir). + -- plausible alr workspace). end Alr.Files; diff --git a/src/alr/alr-os_lib.ads b/src/alr/alr-os_lib.ads index aafde1a3..c57ad1bb 100644 --- a/src/alr/alr-os_lib.ads +++ b/src/alr/alr-os_lib.ads @@ -48,7 +48,7 @@ package Alr.OS_Lib is end Paths; ----------------------------- - -- WORKING FOLDER MANAGEMENT + -- CURRENT FOLDER MANAGEMENT subtype Folder_Guard is Alire.Directories.Guard; diff --git a/testsuite/tests/misc/bad-tomlfile/test.py b/testsuite/tests/misc/bad-tomlfile/test.py index 8ae2a61c..67f156a1 100644 --- a/testsuite/tests/misc/bad-tomlfile/test.py +++ b/testsuite/tests/misc/bad-tomlfile/test.py @@ -20,7 +20,7 @@ with open("alire.toml", "a") as myfile: # Verify that the expected error is given p = run_alr('show', complain_on_error=False) -assert_match('.*Cannot continue with invalid session.*' +assert_match('.*Cannot continue.*' 'Failed to load.*', p.out, flags=re.S) diff --git a/testsuite/tests/misc/clean-end/test.py b/testsuite/tests/misc/clean-end/test.py index d10e39f0..8a21c063 100644 --- a/testsuite/tests/misc/clean-end/test.py +++ b/testsuite/tests/misc/clean-end/test.py @@ -11,8 +11,8 @@ from drivers.asserts import assert_eq, assert_match # Check a few commands for unexpected output # Commands that require session -assert_match(".*Cannot continue with invalid session:.*" # skip logging prefix - " Could not detect a session folder" +assert_match(".*Cannot continue without a workspace:.*" # skip logging prefix + " Could not detect an alire.toml manifest" " at current or parent locations\n", run_alr('with', quiet=False, complain_on_error=False).out) diff --git a/testsuite/tests/pin/manifest-invalid-pins/test.py b/testsuite/tests/pin/manifest-invalid-pins/test.py index ed1faafc..07ca36e9 100644 --- a/testsuite/tests/pin/manifest-invalid-pins/test.py +++ b/testsuite/tests/pin/manifest-invalid-pins/test.py @@ -23,7 +23,7 @@ def check(pin, error): p = run_alr("pin", complain_on_error=False) assert p.status != 0, "Unexpected success for pin: " + pin - assert_match(".*Cannot continue with invalid session.*" + + assert_match(".*Cannot continue.*" + error + ".*\n", p.out) -- 2.39.5