From 0cf68ee8ffc7f8be1c587e5c622203d5baddb09b Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Mon, 6 Jul 2020 10:58:50 +0200 Subject: [PATCH] Set up environment before post-fetch actions (#456) * Alire.Environment: take release paths from a Root The path lookup has three levels: 1. For the root release, the own root folder 2. For a regular release, the dependencies folder "/" release unique folder 3. For a pinned softlink, the absolute path of the softlink The root contains the solution which in turn contains the softlinks, so the query for the path can be directly made to the root. * Set up build env before deploying dependencies * Tests for softlink nested path and env export * Review fixes * Alire.Environment.Load: Remove unused parameter This flies by CE but is detected by FSF (?) * Alire.Roots: move expression functions to body There's some bug manifesting when a lot of code is in the spec in which the linker complaints about missing references. * Spelling fixes * Updated new tests index versions * Rename dir_separator/path_separator to match GNAT... ... in the Python testsuite * Remove trailing '/' separator in extra prj paths This is to match the output of full path normalization by Ada.Directories. --- src/alire/alire-environment-formatting.adb | 20 +- src/alire/alire-environment-formatting.ads | 7 +- src/alire/alire-environment.adb | 76 +++++++- src/alire/alire-environment.ads | 23 ++- src/alire/alire-releases.adb | 5 +- src/alire/alire-roots.adb | 178 ++++++++++++++---- src/alire/alire-roots.ads | 82 +++----- src/alire/alire-workspace.adb | 14 +- src/alr/alr-build_env.adb | 101 ---------- src/alr/alr-build_env.ads | 18 -- src/alr/alr-commands-build.adb | 43 ++--- src/alr/alr-commands-build.ads | 6 +- src/alr/alr-commands-clean.adb | 3 +- src/alr/alr-commands-get.adb | 7 +- src/alr/alr-commands-run.adb | 2 +- src/alr/alr-commands-setenv.adb | 28 +-- testsuite/drivers/helpers.py | 4 + testsuite/tests/pin/change-type/test.py | 4 +- testsuite/tests/pin/dir-crate/test.py | 4 +- testsuite/tests/pin/dir-mismatch/test.py | 4 +- .../tests/pin/pin-dir-with-regular/test.py | 1 - testsuite/tests/pin/pin-dir/test.py | 4 +- .../my_index/crates/checkenv/checkenv.gpr | 22 +++ .../my_index/crates/checkenv/src/checkenv.adb | 13 ++ .../my_index/index/ch/checkenv.toml | 18 ++ .../my_index/index/ch/checkparent.toml | 9 + .../my_index/index/index.toml | 1 + .../tests/setenv/env-during-fetch/test.py | 32 ++++ .../tests/setenv/env-during-fetch/test.yaml | 4 + .../my_index/crates/crate_1234/.emptydir | 0 .../crates/crate_1234/alire/crate_1234.lock | 4 + .../crates/crate_1234/alire/crate_1234.toml | 12 ++ .../linked-paths/my_index/index/index.toml | 1 + testsuite/tests/setenv/linked-paths/test.py | 28 +++ testsuite/tests/setenv/linked-paths/test.yaml | 4 + .../with/pin-dir-crate-autodetect/test.py | 4 +- testsuite/tests/with/pin-dir-crate/test.py | 4 +- testsuite/tests/with/pin-dir-mismatch/test.py | 4 +- testsuite/tests/with/pin-dir/test.py | 4 +- 39 files changed, 475 insertions(+), 323 deletions(-) delete mode 100644 src/alr/alr-build_env.adb delete mode 100644 src/alr/alr-build_env.ads create mode 100644 testsuite/tests/setenv/env-during-fetch/my_index/crates/checkenv/checkenv.gpr create mode 100644 testsuite/tests/setenv/env-during-fetch/my_index/crates/checkenv/src/checkenv.adb create mode 100644 testsuite/tests/setenv/env-during-fetch/my_index/index/ch/checkenv.toml create mode 100644 testsuite/tests/setenv/env-during-fetch/my_index/index/ch/checkparent.toml create mode 100644 testsuite/tests/setenv/env-during-fetch/my_index/index/index.toml create mode 100644 testsuite/tests/setenv/env-during-fetch/test.py create mode 100644 testsuite/tests/setenv/env-during-fetch/test.yaml create mode 100644 testsuite/tests/setenv/linked-paths/my_index/crates/crate_1234/.emptydir create mode 100644 testsuite/tests/setenv/linked-paths/my_index/crates/crate_1234/alire/crate_1234.lock create mode 100644 testsuite/tests/setenv/linked-paths/my_index/crates/crate_1234/alire/crate_1234.toml create mode 100644 testsuite/tests/setenv/linked-paths/my_index/index/index.toml create mode 100644 testsuite/tests/setenv/linked-paths/test.py create mode 100644 testsuite/tests/setenv/linked-paths/test.yaml diff --git a/src/alire/alire-environment-formatting.adb b/src/alire/alire-environment-formatting.adb index c2f81eed..b40968da 100644 --- a/src/alire/alire-environment-formatting.adb +++ b/src/alire/alire-environment-formatting.adb @@ -1,9 +1,6 @@ with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; -with Alire.OS_Lib; -with Alire.Directories; with Alire.Platform; -with Alire.Paths; package body Alire.Environment.Formatting is @@ -54,9 +51,8 @@ package body Alire.Environment.Formatting is -- Format -- ------------ - function Format (Rel : Releases.Release; - Value : String; - Is_Root_Release : Boolean) + function Format (Release_Dir : Any_Path; + Value : String) return String is ------------- @@ -66,12 +62,7 @@ package body Alire.Environment.Formatting is procedure Replace (Str : in out Unbounded_String; From, To : Positive) is - use Alire.OS_Lib; - Id : constant String := Slice (Str, From + 2, To - 1); - - Working_Folder : constant Alire.Absolute_Path := - Alire.Directories.Current; begin if Id = "DISTRIB_ROOT" then @@ -80,12 +71,7 @@ package body Alire.Environment.Formatting is elsif Id = "CRATE_ROOT" then Replace_Slice (Str, From, To, - Working_Folder / - (if Is_Root_Release - then ".." - else Alire.Paths.Working_Folder_Inside_Root - / Alire.Paths.Dependency_Dir_Inside_Working_Folder - / Rel.Unique_Folder)); + Release_Dir); elsif Id = "_ALIRE_TEST_" then -- This is used to test the env var formatting feature diff --git a/src/alire/alire-environment-formatting.ads b/src/alire/alire-environment-formatting.ads index 860d9bcb..e19d0ab7 100644 --- a/src/alire/alire-environment-formatting.ads +++ b/src/alire/alire-environment-formatting.ads @@ -2,11 +2,10 @@ with Alire.Releases; package Alire.Environment.Formatting is - function Format (Rel : Releases.Release; - Value : String; - Is_Root_Release : Boolean) + function Format (Release_Dir : Any_Path; + Value : String) return String; - -- Format the environment variable falue with ${} replacement patterns + -- Format the environment variable value with ${} replacement patterns Unknown_Formatting_Key : exception; diff --git a/src/alire/alire-environment.adb b/src/alire/alire-environment.adb index 8d887f4a..b45b0c30 100644 --- a/src/alire/alire-environment.adb +++ b/src/alire/alire-environment.adb @@ -2,15 +2,23 @@ with GNAT.OS_Lib; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; +with Alire_Early_Elaboration; with Alire.Properties.Environment; use Alire.Properties.Environment; with Alire.Properties.Scenarios; with Alire.OS_Lib; with Alire.GPR; +with Alire.Roots; +with Alire.Solutions; with Alire.Utils; with Alire.Environment.Formatting; +with Alire.Utils.TTY; + +with GNAT.IO; package body Alire.Environment is + package TTY renames Utils.TTY; + --------- -- Add -- --------- @@ -62,20 +70,71 @@ package body Alire.Environment is -- Load -- ---------- + procedure Load (This : in out Context; + Root : Alire.Roots.Root) + is + Solution : constant Solutions.Solution := Root.Solution; + begin + + -- Warnings when setting up an incomplete environment + + if not Solution.Is_Complete then + Trace.Debug ("Generating incomplete environment" + & " because of missing dependencies"); + + -- Normally we would generate a warning, but since that will pollute + -- the output making it unusable, for once we write directly to + -- stderr (unless quiet is in effect): + + if not Alire_Early_Elaboration.Switch_Q then + GNAT.IO.Put_Line + (GNAT.IO.Standard_Error, + TTY.Warn ("warn:") & " Generating incomplete environment" + & " because of missing dependencies"); + end if; + end if; + + -- Project paths for all releases in the solution, implicitly defined by + -- supplied project files. + + declare + Sorted_Paths : constant Alire.Utils.String_Set := Root.Project_Paths; + begin + if not Sorted_Paths.Is_Empty then + for Path of Sorted_Paths loop + This.Append ("GPR_PROJECT_PATH", Path, "crates"); + end loop; + end if; + end; + + -- Custom definitions provided by each release + + for Rel of Solution.Releases.Including (Root.Release) loop + This.Load (Root => Root, + Crate => Rel.Name); + end loop; + + This.Set ("ALIRE", "True", "Alire"); + end Load; + + ---------- + -- Load -- + ---------- + procedure Load (This : in out Context; - Rel : Alire.Releases.Release; - Prop : Alire.Properties.Vector; - Is_Root_Release : Boolean) + Root : Roots.Root; + Crate : Crate_Name) is + Rel : constant Releases.Release := Root.Release (Crate); Origin : constant String := Rel.Name_Str; begin - -- Enviromemnt variables defined in the crate manifest - for Act of Rel.Environment (Prop) loop + -- Environment variables defined in the crate manifest + for Act of Rel.Environment (Root.Environment) loop begin declare Value : constant String := - Formatting.Format (Rel, Act.Value, Is_Root_Release); + Formatting.Format (Root.Release_Base (Rel.Name), Act.Value); begin case Act.Action is @@ -102,7 +161,7 @@ package body Alire.Environment is end loop; -- Environment variables for GPR external scenario variables - for Property of Rel.On_Platform_Properties (Prop) loop + for Property of Rel.On_Platform_Properties (Root.Environment) loop if Property in Alire.Properties.Scenarios.Property'Class then declare use all type Alire.GPR.Variable_Kinds; @@ -216,7 +275,8 @@ package body Alire.Environment is when Properties.Environment.Set => Raise_Checked_Error - ("Trying to set an alredy defined environment variable"); + ("Trying to set an alredy defined environment variable: " + & (+Key) & " is already defined as " & (+Value)); when Properties.Environment.Append => Value := Value & Separator & Act.Value; diff --git a/src/alire/alire-environment.ads b/src/alire/alire-environment.ads index 28b8d09e..43c5ae2b 100644 --- a/src/alire/alire-environment.ads +++ b/src/alire/alire-environment.ads @@ -3,6 +3,7 @@ with Ada.Strings.Unbounded; with Alire.Releases; with Alire.Properties; with Alire.Platforms; +limited with Alire.Roots; private with Ada.Strings.Unbounded.Hash; private with Ada.Containers.Vectors; @@ -29,19 +30,17 @@ package Alire.Environment is procedure Prepend (This : in out Context; Name, Value, Origin : String); -- Prepend a value to a variable in the context - procedure Load (This : in out Context; - Rel : Alire.Releases.Release; - Prop : Alire.Properties.Vector; - Is_Root_Release : Boolean); - -- Load the enviroment variables of a release (GPR_PROJECT_PATH and custom - -- variables) in the context. + procedure Load (This : in out Context; + Root : Alire.Roots.Root); + -- Load the environment variables of a releases found in the workspace + -- Solution (GPR_PROJECT_PATH and custom variables) in the context. procedure Export (This : Context); - -- Export the enviroment variables built from the variables previously + -- Export the environment variables built from the variables previously -- loaded and defined in the context. procedure Print_Shell (This : Context; Kind : Platforms.Shells); - -- Print the shell commands that can be used to export the enviroment + -- Print the shell commands that can be used to export the environment -- variables. procedure Print_Details (This : Context); @@ -58,7 +57,7 @@ private type Var_Array is array (Natural range <>) of Var; function Compile (This : Context) return Var_Array; - -- Return an array of enviroment variable key/value built from the + -- Return an array of environment variable key/value built from the -- variables previously loaded and defined in the context. type Env_Action is record @@ -84,4 +83,10 @@ private procedure Add (This : in out Context; Name : String; Action : Env_Action); + procedure Load (This : in out Context; + Root : Roots.Root; + Crate : Crate_Name); + -- Load the environment variables of a release (GPR_PROJECT_PATH and custom + -- variables) in the context. + end Alire.Environment; diff --git a/src/alire/alire-releases.adb b/src/alire/alire-releases.adb index 89643b35..291aa383 100644 --- a/src/alire/alire-releases.adb +++ b/src/alire/alire-releases.adb @@ -426,7 +426,10 @@ package body Alire.Releases is for File of Files loop if Contains (File, "/") then Paths.Include - (File (File'First .. Fixed.Index (File, "/", Backward))); + (File (File'First .. Fixed.Index (File, "/", Backward) - 1)); + -- To match the output of root crate paths and Ada.Directories + -- full path normalization, a path separator in the last + -- position is not included. end if; end loop; end return; diff --git a/src/alire/alire-roots.adb b/src/alire/alire-roots.adb index 67c68264..4dd141ca 100644 --- a/src/alire/alire-roots.adb +++ b/src/alire/alire-roots.adb @@ -1,6 +1,10 @@ with Ada.Directories; with Alire.Directories; +with Alire.Environment; +with Alire.Lockfiles; +with Alire.OS_Lib; +with Alire.Paths; with Alire.Root; with Alire.TOML_Index; @@ -8,11 +12,23 @@ with GNAT.OS_Lib; package body Alire.Roots is + ------------------- + -- Build_Context -- + ------------------- + + function Build_Context (This : Root) return Alire.Environment.Context is + begin + return Context : Alire.Environment.Context do + Context.Load (This); + end return; + end Build_Context; + ----------------- -- Detect_Root -- ----------------- function Detect_Root (Path : Any_Path) return Root is + use Alire.OS_Lib; use GNAT.OS_Lib; Alire_Path : constant Any_Path := Path / Alire.Paths.Working_Folder_Inside_Root; @@ -51,14 +67,54 @@ package body Alire.Roots is end; end Detect_Root; + ------------------------------ + -- Export_Build_Environment -- + ------------------------------ + + procedure Export_Build_Environment (This : Root) is + Context : Alire.Environment.Context; + begin + Context.Load (This); + Context.Export; + end Export_Build_Environment; + + ----------------------- + -- GPR_Project_Files -- + ----------------------- + + function GPR_Project_Files (This : Root; + Exclude_Root : Boolean) + return Utils.String_Set + is + Files : Utils.String_Set; + begin + + -- Add files from every release in the solution + + for Rel of This.Solution.Releases.Including (Release (This)) loop + + if (not Exclude_Root or else Rel.Name /= Release (This).Name) + and then + Rel.Auto_GPR_With + then + for File of Rel.Project_Files + (This.Environment, With_Path => False) + loop + Files.Include (File); + end loop; + end if; + end loop; + return Files; + end GPR_Project_Files; + ------------------- -- Project_Paths -- ------------------- function Project_Paths (This : Root) return Utils.String_Set is + use Alire.OS_Lib; Paths : Utils.String_Set; - Base : constant Any_Path := Path (This); begin -- Add root path from every release in the solution @@ -67,25 +123,13 @@ package body Alire.Roots is if Rel.Name = Release (This).Name then null; -- The root project doesn't require its own path else - Paths.Include (Base - / Alire.Paths.Working_Folder_Inside_Root - / Alire.Paths.Dependency_Dir_Inside_Working_Folder - / Rel.Unique_Folder); + Paths.Include (This.Release_Base (Rel.Name)); end if; -- Add extra project paths for Path of Rel.Project_Paths (This.Environment) loop - if Rel.Name = Release (This).Name then - Paths.Include (Base / Path); - else - Paths.Include - (Base - / Alire.Paths.Working_Folder_Inside_Root - / Alire.Paths.Dependency_Dir_Inside_Working_Folder - / Rel.Unique_Folder - / Path); - end if; + Paths.Include (This.Release_Base (Rel.Name) / Path); end loop; end loop; @@ -100,33 +144,85 @@ package body Alire.Roots is return Paths; end Project_Paths; - ----------------------- - -- GPR_Project_Files -- - ----------------------- + -------------- + -- Solution -- + -------------- - function GPR_Project_Files (This : Root; - Exclude_Root : Boolean) - return Utils.String_Set - is - Files : Utils.String_Set; + function Solution (This : Root) return Solutions.Solution is begin - - -- Add files from every release in the solution - - for Rel of This.Solution.Releases.Including (Release (This)) loop - - if (not Exclude_Root or else Rel.Name /= Release (This).Name) - and then - Rel.Auto_GPR_With - then - for File of Rel.Project_Files - (This.Environment, With_Path => False) - loop - Files.Include (File); - end loop; - end if; - end loop; - return Files; - end GPR_Project_Files; + -- TODO: This probably is a good target for caching unless file + -- timestamp has changed. + return Lockfiles.Read (This.Lock_File); + end Solution; + + function Environment (This : Root) return Properties.Vector + is (This.Environment); + + function Is_Valid (This : Root) return Boolean is (This.Valid); + + function New_Invalid_Root return Root is + (Valid => False, Reason => +""); + + function With_Reason (This : Root; Reason : String) return Root is + (Valid => False, + Reason => +Reason); + + function Invalid_Reason (This : Root) return String is + (+This.Reason); + + function New_Root (Name : Crate_Name; + Path : Absolute_Path; + Env : Properties.Vector) return Root is + (True, + Env, + +Path, + Containers.To_Release_H (Releases.New_Working_Release (Name))); + + function New_Root (R : Releases.Release; + Path : Absolute_Path; + Env : Properties.Vector) return Root is + (True, + Env, + +Path, + Containers.To_Release_H (R)); + + function Path (This : Root) return Absolute_Path is (+This.Path); + + function Release (This : Root) return Releases.Release is + (This.Release.Constant_Reference); + + function Release (This : Root; + Crate : Crate_Name) return Releases.Release is + (if This.Release.Element.Name = Crate + then This.Release.Element + else This.Solution.State (Crate).Release); + + use OS_Lib; + + function Release_Base (This : Root; Crate : Crate_Name) return Any_Path is + (if This.Release.Element.Name = Crate then + +This.Path + elsif This.Solution.State (Crate).Is_Solved then + (+This.Path) + / Paths.Working_Folder_Inside_Root + / Paths.Dependency_Dir_Inside_Working_Folder + / Release (This, Crate).Unique_Folder + elsif This.Solution.State (Crate).Is_Linked then + This.Solution.State (Crate).Link.Path + else + raise Program_Error with "release must be either solved or linked"); + + function Lock_File (This : Root) return Absolute_Path is + (Lockfiles.File_Name + (This.Release.Constant_Reference.Name, + +This.Path)); + + function Crate_File (This : Root) return Absolute_Path is + (This.Working_Folder / + This.Release.Constant_Reference.Name_Str & + Paths.Crate_File_Extension_With_Dot); + + function Working_Folder (This : Root) return Absolute_Path is + ((+This.Path) / "alire"); end Alire.Roots; diff --git a/src/alire/alire-roots.ads b/src/alire/alire-roots.ads index c48d6690..24e6de53 100644 --- a/src/alire/alire-roots.ads +++ b/src/alire/alire-roots.ads @@ -1,8 +1,6 @@ private with Alire.Containers; -private with Alire.Lockfiles; -private with Alire.OS_Lib; -private with Alire.Paths; +limited with Alire.Environment; with Alire.Properties; with Alire.Releases; with Alire.Solutions; @@ -60,6 +58,17 @@ package Alire.Roots is -- From existing release -- Path must point to the session folder (parent of alire metadata folder) + function Environment (This : Root) return Properties.Vector with + Pre => This.Is_Valid; + -- Retrieve the environment stored within this root. Environment here + -- refers to the platform properties. + + function Build_Context (This : Root) return Alire.Environment.Context; + + procedure Export_Build_Environment (This : Root) with + Pre => This.Is_Valid; + -- Export the build environment (PATH, GPR_PROJECT_PATH) of the given root + function Path (This : Root) return Absolute_Path with Pre => This.Is_Valid; @@ -81,13 +90,18 @@ package Alire.Roots is function Release (This : Root) return Releases.Release with Pre => This.Is_Valid; - function Solution (This : Root) return Solutions.Solution with + function Release (This : Root; Crate : Crate_Name) return Releases.Release + with Pre => This.Is_Valid and then + (Crate = This.Release.Name or else This.Solution.Depends_On (Crate)); + -- Retrieve a release, that can be either the root or any in the solution + + function Release_Base (This : Root; Crate : Crate_Name) return Any_Path with Pre => This.Is_Valid; - -- Returns the solution stored in the lockfile + -- Find the base folder in which a release can be found for the given root - function Environment (This : Root) return Properties.Vector with + function Solution (This : Root) return Solutions.Solution with Pre => This.Is_Valid; - -- Properties of the Root + -- Returns the solution stored in the lockfile -- files and folders derived from the root path (this obsoletes Alr.Paths) @@ -116,58 +130,4 @@ private end case; end record; - function Is_Valid (This : Root) return Boolean is (This.Valid); - - function New_Invalid_Root return Root is - (Valid => False, Reason => +""); - - function With_Reason (This : Root; Reason : String) return Root is - (Valid => False, - Reason => +Reason); - - function Invalid_Reason (This : Root) return String is - (+This.Reason); - - function New_Root (Name : Crate_Name; - Path : Absolute_Path; - Env : Properties.Vector) return Root is - (True, - Env, - +Path, - Containers.To_Release_H (Releases.New_Working_Release (Name))); - - function New_Root (R : Releases.Release; - Path : Absolute_Path; - Env : Properties.Vector) return Root is - (True, - Env, - +Path, - Containers.To_Release_H (R)); - - function Path (This : Root) return Absolute_Path is (+This.Path); - - function Release (This : Root) return Releases.Release is - (This.Release.Constant_Reference); - - function Solution (This : Root) return Solutions.Solution is - (Lockfiles.Read (This.Lock_File)); - - use OS_Lib; - - function Lock_File (This : Root) return Absolute_Path is - (Lockfiles.File_Name - (This.Release.Constant_Reference.Name, - +This.Path)); - - function Crate_File (This : Root) return Absolute_Path is - (This.Working_Folder / - This.Release.Constant_Reference.Name_Str & - Paths.Crate_File_Extension_With_Dot); - - function Working_Folder (This : Root) return Absolute_Path is - ((+This.Path) / "alire"); - - function Environment (This : Root) return Properties.Vector - is (This.Environment); - end Alire.Roots; diff --git a/src/alire/alire-workspace.adb b/src/alire/alire-workspace.adb index 3937e681..e2463c61 100644 --- a/src/alire/alire-workspace.adb +++ b/src/alire/alire-workspace.adb @@ -33,13 +33,17 @@ package body Alire.Workspace is Round : Natural := 0; begin - Solution.Print_Hints (Env); - -- Store given solution on disk to ensure consistency between deployed -- dependencies and stored lockfile. Alire.Lockfiles.Write (Solution, Root.Lock_File); + -- Prepare environment for any post-fetch actions. This must be done + -- after the lockfile on disk is written, since the root will read + -- dependencies from there. + + Root.Export_Build_Environment; + -- Mark any dependencies without a corresponding regular release as -- already deployed (in practice, we don't have to deploy them, and -- dependents don't need to wait for their deployment). @@ -111,6 +115,12 @@ package body Alire.Workspace is end if; end; end loop; + + -- Show hints for missing externals to the user after all the noise of + -- dependency post-fetch compilations. + + Solution.Print_Hints (Env); + end Deploy_Dependencies; -------------------- diff --git a/src/alr/alr-build_env.adb b/src/alr/alr-build_env.adb deleted file mode 100644 index 94271066..00000000 --- a/src/alr/alr-build_env.adb +++ /dev/null @@ -1,101 +0,0 @@ -with GNAT.IO; - -with Alire_Early_Elaboration; - -with Alire.GPR; -with Alire.Solutions; -with Alire.Solver; -with Alire.Utils.TTY; -with Alire.Utils; -with Alire.Environment; -with Alire.Properties; -with Alire.Releases; - -with Alr.Platform; - -package body Alr.Build_Env is - - package TTY renames Alire.Utils.TTY; - - ------------------ - -- Load_Context -- - ------------------ - - procedure Load_Context (Ctx : in out Alire.Environment.Context; - Root : Alire.Roots.Root) - is - Needed : constant Alire.Solver.Solution := Root.Solution; - begin - if not Needed.Is_Complete then - Trace.Debug ("Generating incomplete environment" - & " because of missing dependencies"); - - -- Normally we would generate a warning, but since that will pollute - -- the output making it unusable, for once we write directly to - -- stderr (unless quiet is in effect): - - if not Alire_Early_Elaboration.Switch_Q then - GNAT.IO.Put_Line - (GNAT.IO.Standard_Error, - TTY.Warn ("warn:") & " Generating incomplete environment" - & " because of missing dependencies"); - end if; - end if; - - declare - Sorted_Paths : constant Alire.Utils.String_Set := Root.Project_Paths; - begin - if not Sorted_Paths.Is_Empty then - for Path of Sorted_Paths loop - Ctx.Append ("GPR_PROJECT_PATH", Path, "crates"); - end loop; - end if; - end; - - for Rel of Needed.Releases.Including (Root.Release) loop - Ctx.Load (Rel, - Platform.Properties, - Is_Root_Release => Rel.Name = Root.Release.Name); - end loop; - - Ctx.Set ("ALIRE", "True", "Alire"); - end Load_Context; - - ------------ - -- Export -- - ------------ - - procedure Export (Root : Alire.Roots.Root) - is - Ctx : Alire.Environment.Context; - begin - Load_Context (Ctx, Root); - Ctx.Export; - end Export; - - ------------------- - -- Print_Details -- - ------------------- - - procedure Print_Details (Root : Alire.Roots.Root) - is - Ctx : Alire.Environment.Context; - begin - Load_Context (Ctx, Root); - Ctx.Print_Details; - end Print_Details; - - ----------------- - -- Print_Shell -- - ----------------- - - procedure Print_Shell (Root : Alire.Roots.Root; - Kind : Alire.Platforms.Shells) - is - Ctx : Alire.Environment.Context; - begin - Load_Context (Ctx, Root); - Ctx.Print_Shell (Kind); - end Print_Shell; - -end Alr.Build_Env; diff --git a/src/alr/alr-build_env.ads b/src/alr/alr-build_env.ads deleted file mode 100644 index d9b7b520..00000000 --- a/src/alr/alr-build_env.ads +++ /dev/null @@ -1,18 +0,0 @@ -with Alire.Roots; -with Alire.Platforms; - -package Alr.Build_Env is - - procedure Export (Root : Alire.Roots.Root); - -- Export the build environment (PATH, GPR_PROJECT_PATH) of the given root - - procedure Print_Shell (Root : Alire.Roots.Root; - Kind : Alire.Platforms.Shells); - -- Print the shell commands that can be used to export the enviroment - -- variables of the given root. - - procedure Print_Details (Root : Alire.Roots.Root); - -- Print details about the environement variables (PATH, GPR_PROJECT_PATH) - -- of the given root. - -end Alr.Build_Env; diff --git a/src/alr/alr-commands-build.adb b/src/alr/alr-commands-build.adb index c6a912da..be769148 100644 --- a/src/alr/alr-commands-build.adb +++ b/src/alr/alr-commands-build.adb @@ -4,23 +4,36 @@ with Alire.Properties.Actions.Executor; with Alr.Root; with Alr.Spawn; with Alr.Platform; -with Alr.Build_Env; with GNAT.OS_Lib; package body Alr.Commands.Build is - ---------------- - -- Do_Compile -- - ---------------- + ------------- + -- Execute -- + ------------- - function Do_Compile return Boolean is + overriding procedure Execute (Cmd : in out Command) is + pragma Unreferenced (Cmd); + begin + if not Execute (Export_Build_Env => True) then + Reportaise_Command_Failed ("Compilation failed."); + end if; + end Execute; + + ------------- + -- Execute -- + ------------- + + function Execute (Export_Build_Env : Boolean) return Boolean is begin Requires_Full_Index; Requires_Valid_Session; - Alr.Build_Env.Export (Alr.Root.Current); + if Export_Build_Env then + Alr.Root.Current.Export_Build_Environment; + end if; -- COMPILATION begin @@ -56,26 +69,8 @@ package body Alr.Commands.Build is Trace.Detail ("Use alr run --list to check available executables"); return True; - end Do_Compile; - - ------------- - -- Execute -- - ------------- - - overriding procedure Execute (Cmd : in out Command) is - pragma Unreferenced (Cmd); - begin - if not Do_Compile then - Reportaise_Command_Failed ("Compilation failed."); - end if; end Execute; - ------------- - -- Execute -- - ------------- - - function Execute return Boolean is (Do_Compile); - ---------------------- -- Long_Description -- ---------------------- diff --git a/src/alr/alr-commands-build.ads b/src/alr/alr-commands-build.ads index 3e95d8cc..766bac9a 100644 --- a/src/alr/alr-commands-build.ads +++ b/src/alr/alr-commands-build.ads @@ -5,8 +5,10 @@ package Alr.Commands.Build is overriding procedure Execute (Cmd : in out Command); - function Execute return Boolean; - -- Returns True if compilation succeeded + function Execute (Export_Build_Env : Boolean) return Boolean; + -- Returns True if compilation succeeded. For invocations after some other + -- command that already has set up the build environment we need to avoid + -- redoing it, or it results in "variable already set" errors. overriding function Long_Description (Cmd : Command) diff --git a/src/alr/alr-commands-clean.adb b/src/alr/alr-commands-clean.adb index 3a81b391..50e7fe65 100644 --- a/src/alr/alr-commands-clean.adb +++ b/src/alr/alr-commands-clean.adb @@ -8,7 +8,6 @@ with Alr.Root; with Alr.Spawn; with Alr.Bootstrap; with Alr.Platform; -with Alr.Build_Env; package body Alr.Commands.Clean is @@ -29,7 +28,7 @@ package body Alr.Commands.Clean is Requires_Valid_Session; - Alr.Build_Env.Export (Alr.Root.Current); + Alr.Root.Current.Export_Build_Environment; Trace.Detail ("Cleaning project and dependencies..."); diff --git a/src/alr/alr-commands-get.adb b/src/alr/alr-commands-get.adb index 176e943a..9075fcdc 100644 --- a/src/alr/alr-commands-get.adb +++ b/src/alr/alr-commands-get.adb @@ -155,14 +155,17 @@ package body Alr.Commands.Get is Solution => Solution); -- Execute the checked out release post_fetch actions, now that - -- dependencies are in place + -- dependencies are in place. The complete build environment has + -- been set up already by Deploy_Dependencies. + Alire.Properties.Actions.Executor.Execute_Actions (Release => Rel, Env => Platform.Properties, Moment => Alire.Properties.Actions.Post_Fetch); if Cmd.Build then - Build_OK := Commands.Build.Execute; + Build_OK := Commands.Build.Execute (Export_Build_Env => False); + -- Environment is already set up else Build_OK := True; end if; diff --git a/src/alr/alr-commands-run.adb b/src/alr/alr-commands-run.adb index 0fda6140..b3f46f56 100644 --- a/src/alr/alr-commands-run.adb +++ b/src/alr/alr-commands-run.adb @@ -129,7 +129,7 @@ package body Alr.Commands.Run is -- COMPILATION -- if not Cmd.No_Compile then - if not Commands.Build.Execute then + if not Commands.Build.Execute (Export_Build_Env => True) then Reportaise_Command_Failed ("Build failed"); end if; end if; diff --git a/src/alr/alr-commands-setenv.adb b/src/alr/alr-commands-setenv.adb index 898e67d7..e25632f5 100644 --- a/src/alr/alr-commands-setenv.adb +++ b/src/alr/alr-commands-setenv.adb @@ -1,7 +1,7 @@ +with Alire.Environment; with Alire.Platforms; with Alr.Root; -with Alr.Build_Env; package body Alr.Commands.Setenv is @@ -26,18 +26,20 @@ package body Alr.Commands.Setenv is Requires_Valid_Session; - if Cmd.Details then - Alr.Build_Env.Print_Details (Alr.Root.Current); - elsif Cmd.Power_Shell then - Alr.Build_Env.Print_Shell (Alr.Root.Current, - Alire.Platforms.PowerShell); - elsif Cmd.Cmd_Shell then - Alr.Build_Env.Print_Shell (Alr.Root.Current, - Alire.Platforms.WinCmd); - else - Alr.Build_Env.Print_Shell (Alr.Root.Current, - Alire.Platforms.Unix); - end if; + declare + Context : constant Alire.Environment.Context := + Alr.Root.Current.Build_Context; + begin + if Cmd.Details then + Context.Print_Details; + elsif Cmd.Power_Shell then + Context.Print_Shell (Alire.Platforms.PowerShell); + elsif Cmd.Cmd_Shell then + Context.Print_Shell (Alire.Platforms.WinCmd); + else + Context.Print_Shell (Alire.Platforms.Unix); + end if; + end; end Execute; ---------------------- diff --git a/testsuite/drivers/helpers.py b/testsuite/drivers/helpers.py index da571f2f..cbddb716 100644 --- a/testsuite/drivers/helpers.py +++ b/testsuite/drivers/helpers.py @@ -34,6 +34,10 @@ def check_line_in(filename, line): def path_separator(): + return ':' if os.name != 'nt' else ';' + + +def dir_separator(): return '/' if os.name != 'nt' else '\\' diff --git a/testsuite/tests/pin/change-type/test.py b/testsuite/tests/pin/change-type/test.py index 132d2386..8e4e6a38 100644 --- a/testsuite/tests/pin/change-type/test.py +++ b/testsuite/tests/pin/change-type/test.py @@ -7,7 +7,7 @@ import re from drivers.alr import run_alr from drivers.asserts import assert_match -from drivers.helpers import path_separator +from drivers.helpers import dir_separator def check_version_pin(): @@ -33,7 +33,7 @@ run_alr('pin', 'libhello', '--use', '../my_index/crates/libhello_1.0.0') # Check that it shows as such in the solution p = run_alr('show', '--solve') -s = re.escape(path_separator()) # platform-dependent +s = re.escape(dir_separator()) # platform-dependent assert_match('.*Dependencies \(external\):.*' 'libhello\* \(direct,linked' ',pin=.*' + s + 'my_index' + s + diff --git a/testsuite/tests/pin/dir-crate/test.py b/testsuite/tests/pin/dir-crate/test.py index 22c461b7..938c16fa 100644 --- a/testsuite/tests/pin/dir-crate/test.py +++ b/testsuite/tests/pin/dir-crate/test.py @@ -7,7 +7,7 @@ import re from drivers.alr import run_alr from drivers.asserts import assert_match -from drivers.helpers import path_separator +from drivers.helpers import dir_separator from glob import glob # Retrieve a crate @@ -25,7 +25,7 @@ run_alr('with', 'hello', '--force') # Pin the hello crate as local dir dependency. The version in the folder is # different to the one we had in the solution, so this should cause a downgrade # but with complete solution. Now hello=1 --> libhello=1.1. -run_alr('pin', 'hello', '--use', '..' + path_separator() + target) +run_alr('pin', 'hello', '--use', '..' + dir_separator() + target) # Verify that hello dependencies are detected and used, and are the ones # corresponding to the linked dir versions. diff --git a/testsuite/tests/pin/dir-mismatch/test.py b/testsuite/tests/pin/dir-mismatch/test.py index 31a9bd2c..5481a69f 100644 --- a/testsuite/tests/pin/dir-mismatch/test.py +++ b/testsuite/tests/pin/dir-mismatch/test.py @@ -7,7 +7,7 @@ import re from drivers.alr import run_alr from drivers.asserts import assert_match -from drivers.helpers import path_separator +from drivers.helpers import dir_separator from glob import glob # Retrieve a crate @@ -22,7 +22,7 @@ os.chdir('xxx') run_alr('with', 'nothello', '--use', '..') # Try to repin to a dir with valid crate metadata -p = run_alr('with', 'nothello', '--use', '..' + path_separator() + target, +p = run_alr('with', 'nothello', '--use', '..' + dir_separator() + target, complain_on_error=False) # Expected error diff --git a/testsuite/tests/pin/pin-dir-with-regular/test.py b/testsuite/tests/pin/pin-dir-with-regular/test.py index 9839ff14..31f25b11 100644 --- a/testsuite/tests/pin/pin-dir-with-regular/test.py +++ b/testsuite/tests/pin/pin-dir-with-regular/test.py @@ -7,7 +7,6 @@ import re from drivers.alr import run_alr from drivers.asserts import assert_match -from drivers.helpers import path_separator, with_project # Initialize a workspace, enter, and add a regular dependency run_alr('init', '--bin', 'xxx') diff --git a/testsuite/tests/pin/pin-dir/test.py b/testsuite/tests/pin/pin-dir/test.py index 4a86c8bf..f70246ac 100644 --- a/testsuite/tests/pin/pin-dir/test.py +++ b/testsuite/tests/pin/pin-dir/test.py @@ -7,7 +7,7 @@ import re from drivers.alr import run_alr from drivers.asserts import assert_match -from drivers.helpers import path_separator, with_project +from drivers.helpers import dir_separator, with_project # Initialize a workspace, enter, and add a regular dependency run_alr('init', '--bin', 'xxx') @@ -29,7 +29,7 @@ run_alr('build') p = run_alr('with', '--solve') # For this match we don't know where the test is temporarily put, so we skip # over some parts of the output -s = re.escape(path_separator()) # platform-dependent +s = re.escape(dir_separator()) # platform-dependent assert_match('.*Dependencies \(external\):.*' 'libhello\* \(direct,linked' ',pin=.*' + s + 'my_index' + s + diff --git a/testsuite/tests/setenv/env-during-fetch/my_index/crates/checkenv/checkenv.gpr b/testsuite/tests/setenv/env-during-fetch/my_index/crates/checkenv/checkenv.gpr new file mode 100644 index 00000000..d36ec7a0 --- /dev/null +++ b/testsuite/tests/setenv/env-during-fetch/my_index/crates/checkenv/checkenv.gpr @@ -0,0 +1,22 @@ +project Checkenv is + + for Source_Dirs use ("src"); + for Object_Dir use "obj"; + for Exec_Dir use "."; + for Main use ("checkenv.adb"); + + package Builder is + for Switches ("ada") use ("-j0", "-g"); + end Builder; + + package Compiler is + for Switches ("ada") use + ("-gnatVa", "-gnatwa", "-g", "-O2", + "-gnata", "-gnato", "-fstack-check"); + end Compiler; + + package Binder is + for Switches ("ada") use ("-Es"); + end Binder; + +end Checkenv; diff --git a/testsuite/tests/setenv/env-during-fetch/my_index/crates/checkenv/src/checkenv.adb b/testsuite/tests/setenv/env-during-fetch/my_index/crates/checkenv/src/checkenv.adb new file mode 100644 index 00000000..be0600da --- /dev/null +++ b/testsuite/tests/setenv/env-during-fetch/my_index/crates/checkenv/src/checkenv.adb @@ -0,0 +1,13 @@ +with GNAT.IO; use GNAT.IO; +with GNAT.OS_Lib; use GNAT.OS_Lib; + +procedure Checkenv is +begin + -- Check that "CHECKENV_TEST_VAR" is defined and print message accordingly + -- to stderr + if Getenv ("CHECKENV_TEST_VAR").all /= "" then + Put_Line (Standard_Error, "CHECKENV_TEST_VAR exists"); + else + Put_Line (Standard_Error, "CHECKENV_TEST_VAR does NOT exist"); + end if; +end Checkenv; diff --git a/testsuite/tests/setenv/env-during-fetch/my_index/index/ch/checkenv.toml b/testsuite/tests/setenv/env-during-fetch/my_index/index/ch/checkenv.toml new file mode 100644 index 00000000..cd1e0476 --- /dev/null +++ b/testsuite/tests/setenv/env-during-fetch/my_index/index/ch/checkenv.toml @@ -0,0 +1,18 @@ +[general] +description = "Sample crate" +licenses = [] +maintainers = ["any@bo.dy"] +maintainers-logins = ["someone"] + +environment.CHECKENV_TEST_VAR.set = "defined" + +[[general.actions]] +type = "post-fetch" +command = ["gprbuild", "-p"] + +[[general.actions]] +type = "post-fetch" +command = ["./checkenv"] # self-run to verify the env var exists + +['1.0'] +origin = "file://../../crates/checkenv" diff --git a/testsuite/tests/setenv/env-during-fetch/my_index/index/ch/checkparent.toml b/testsuite/tests/setenv/env-during-fetch/my_index/index/ch/checkparent.toml new file mode 100644 index 00000000..09e7cd83 --- /dev/null +++ b/testsuite/tests/setenv/env-during-fetch/my_index/index/ch/checkparent.toml @@ -0,0 +1,9 @@ +[general] +description = "Sample crate" +licenses = [] +maintainers = ["any@bo.dy"] +maintainers-logins = ["someone"] + +['1.0'] +origin = "file://." +depends-on.checkenv = "*" diff --git a/testsuite/tests/setenv/env-during-fetch/my_index/index/index.toml b/testsuite/tests/setenv/env-during-fetch/my_index/index/index.toml new file mode 100644 index 00000000..319b3b37 --- /dev/null +++ b/testsuite/tests/setenv/env-during-fetch/my_index/index/index.toml @@ -0,0 +1 @@ +version = "0.3" diff --git a/testsuite/tests/setenv/env-during-fetch/test.py b/testsuite/tests/setenv/env-during-fetch/test.py new file mode 100644 index 00000000..ca5cad65 --- /dev/null +++ b/testsuite/tests/setenv/env-during-fetch/test.py @@ -0,0 +1,32 @@ +""" +Check that an env var is defined during dependency retrieval (get and with) +""" + +import os +import re + +from drivers.alr import run_alr +from drivers.asserts import assert_match + + +def verify_output(text): + assert_match('.*CHECKENV_TEST_VAR exists\n.*', + text, flags=re.S) + +# The "checkenv" crate defines CHECKENV_TEST_VAR. Also, its executable prints +# "CHECKENV_TEST_VAR exists" or "CHECKENV_TEST_VAR does NOT exist" when run. +# The crate defines post-fetch actions to self-build and self-run, so the +# output is generated at the moment we want to check. + +# Retrieve a crate that depends on checkenv: checkparent --> checkenv +p = run_alr("get", "checkparent") +verify_output(p.out) + +# Create a crate from scratch and add the same dependency to perform the check +# during retrieval by `with` +run_alr("init", "--bin", "xxx") +os.chdir("xxx") +p = run_alr("with", "checkenv") +verify_output(p.out) + +print('SUCCESS') diff --git a/testsuite/tests/setenv/env-during-fetch/test.yaml b/testsuite/tests/setenv/env-during-fetch/test.yaml new file mode 100644 index 00000000..0a859639 --- /dev/null +++ b/testsuite/tests/setenv/env-during-fetch/test.yaml @@ -0,0 +1,4 @@ +driver: python-script +indexes: + my_index: + in_fixtures: false diff --git a/testsuite/tests/setenv/linked-paths/my_index/crates/crate_1234/.emptydir b/testsuite/tests/setenv/linked-paths/my_index/crates/crate_1234/.emptydir new file mode 100644 index 00000000..e69de29b diff --git a/testsuite/tests/setenv/linked-paths/my_index/crates/crate_1234/alire/crate_1234.lock b/testsuite/tests/setenv/linked-paths/my_index/crates/crate_1234/alire/crate_1234.lock new file mode 100644 index 00000000..45d9fa8a --- /dev/null +++ b/testsuite/tests/setenv/linked-paths/my_index/crates/crate_1234/alire/crate_1234.lock @@ -0,0 +1,4 @@ +[context] +advisory = "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT MANUALLY" +solved = true + diff --git a/testsuite/tests/setenv/linked-paths/my_index/crates/crate_1234/alire/crate_1234.toml b/testsuite/tests/setenv/linked-paths/my_index/crates/crate_1234/alire/crate_1234.toml new file mode 100644 index 00000000..ef1567f9 --- /dev/null +++ b/testsuite/tests/setenv/linked-paths/my_index/crates/crate_1234/alire/crate_1234.toml @@ -0,0 +1,12 @@ +["0.0.0"] +origin = "file://.." +[general] +description = "Shiny new project" +maintainers = [ +"your@email.here", +] +maintainers-logins = [ +"github-username", +] + +project-files = ["nested/project.gpr"] diff --git a/testsuite/tests/setenv/linked-paths/my_index/index/index.toml b/testsuite/tests/setenv/linked-paths/my_index/index/index.toml new file mode 100644 index 00000000..319b3b37 --- /dev/null +++ b/testsuite/tests/setenv/linked-paths/my_index/index/index.toml @@ -0,0 +1 @@ +version = "0.3" diff --git a/testsuite/tests/setenv/linked-paths/test.py b/testsuite/tests/setenv/linked-paths/test.py new file mode 100644 index 00000000..6ff67b8c --- /dev/null +++ b/testsuite/tests/setenv/linked-paths/test.py @@ -0,0 +1,28 @@ +""" +Check that both base path, and a extra project path for a softlinked crate is +properly added to the environment +""" + +import os +import re + +from drivers.alr import run_alr +from drivers.asserts import assert_match +from drivers.helpers import dir_separator, path_separator + +# Initialize test crate +run_alr("init", "--bin", "xxx") +os.chdir("xxx") + +# Link a folder with also contains crate definitions +run_alr("with", "--use=../my_index/crates/crate_1234") + +# Check paths are proper (base and one extra nested) +p = run_alr("setenv") +assert_match(('export GPR_PROJECT_PATH=".*/my_index/crates/crate_1234' + + path_separator() + '.*/my_index/crates/crate_1234/nested"\n' + + 'export ALIRE="True"\n').replace('/', re.escape(dir_separator())), + p.out) + + +print('SUCCESS') diff --git a/testsuite/tests/setenv/linked-paths/test.yaml b/testsuite/tests/setenv/linked-paths/test.yaml new file mode 100644 index 00000000..0a859639 --- /dev/null +++ b/testsuite/tests/setenv/linked-paths/test.yaml @@ -0,0 +1,4 @@ +driver: python-script +indexes: + my_index: + in_fixtures: false diff --git a/testsuite/tests/with/pin-dir-crate-autodetect/test.py b/testsuite/tests/with/pin-dir-crate-autodetect/test.py index 6b8beb73..99331534 100644 --- a/testsuite/tests/with/pin-dir-crate-autodetect/test.py +++ b/testsuite/tests/with/pin-dir-crate-autodetect/test.py @@ -8,7 +8,7 @@ import re from drivers.alr import run_alr from drivers.asserts import assert_match -from drivers.helpers import path_separator +from drivers.helpers import dir_separator from glob import glob # Retrieve a crate @@ -21,7 +21,7 @@ os.chdir('xxx') # Add the directory as pinned crate, with autodetection (no crate given, # inferred from the crate metadata found at target). -run_alr('with', '--use', '..' + path_separator() + target) +run_alr('with', '--use', '..' + dir_separator() + target) # Verify that hello^1 is a new dependency and also that hello dependencies are # in the solution. diff --git a/testsuite/tests/with/pin-dir-crate/test.py b/testsuite/tests/with/pin-dir-crate/test.py index 15522c6d..a7c0f8d9 100644 --- a/testsuite/tests/with/pin-dir-crate/test.py +++ b/testsuite/tests/with/pin-dir-crate/test.py @@ -7,7 +7,7 @@ import re from drivers.alr import run_alr from drivers.asserts import assert_match -from drivers.helpers import path_separator +from drivers.helpers import dir_separator from glob import glob # Retrieve a crate @@ -19,7 +19,7 @@ run_alr('init', '--bin', 'xxx') os.chdir('xxx') # Pin the hello crate as local dir dependency -run_alr('with', 'hello', '--use', '..' + path_separator() + target) +run_alr('with', 'hello', '--use', '..' + dir_separator() + target) # Verify that hello dependencies are detected and used p = run_alr('with', '--solve') diff --git a/testsuite/tests/with/pin-dir-mismatch/test.py b/testsuite/tests/with/pin-dir-mismatch/test.py index 9b75e33d..373561af 100644 --- a/testsuite/tests/with/pin-dir-mismatch/test.py +++ b/testsuite/tests/with/pin-dir-mismatch/test.py @@ -7,7 +7,7 @@ import re from drivers.alr import run_alr from drivers.asserts import assert_match -from drivers.helpers import path_separator +from drivers.helpers import dir_separator from glob import glob # Retrieve a crate @@ -19,7 +19,7 @@ run_alr('init', '--bin', 'xxx') os.chdir('xxx') # Try to pin the hello crate as local dir dependency -p = run_alr('with', 'nothello', '--use', '..' + path_separator() + target, +p = run_alr('with', 'nothello', '--use', '..' + dir_separator() + target, complain_on_error=False) # Expected error diff --git a/testsuite/tests/with/pin-dir/test.py b/testsuite/tests/with/pin-dir/test.py index c1f8d216..4dbaef7b 100644 --- a/testsuite/tests/with/pin-dir/test.py +++ b/testsuite/tests/with/pin-dir/test.py @@ -7,7 +7,7 @@ import re from drivers.alr import run_alr from drivers.asserts import assert_match -from drivers.helpers import path_separator, with_project +from drivers.helpers import dir_separator, with_project # Initialize a workspace, enter, and add a pinned dependency run_alr('init', '--bin', 'xxx') @@ -28,7 +28,7 @@ run_alr('build') p = run_alr('with', '--solve') # For this match we don't know where the test is temporarily put, so we skip # over some parts of the output -s = re.escape(path_separator()) # platform-dependent +s = re.escape(dir_separator()) # platform-dependent assert_match('.*Dependencies \(external\):.*' 'libhello\* \(direct,linked' ',pin=.*' + s + 'my_index' + s + -- 2.39.5