From b3bf77e0d49e69332c4d24b3aa715034d06b13a4 Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Thu, 2 Sep 2021 16:52:25 +0200 Subject: [PATCH 1/5] Mark binaries with the x86_64 arch (#821) --- .github/workflows/ci-linux.yml | 4 ++-- .github/workflows/ci-macos.yml | 2 +- .github/workflows/ci-windows.yml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index ddf8add32..e541f9769 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -87,7 +87,7 @@ jobs: with: upload_url: ${{ steps.get_release.outputs.upload_url }} asset_path: alr-bin-linux.zip - asset_name: alr-${{ steps.get_version.outputs.version-without-v }}-bin-linux.zip + asset_name: alr-${{ steps.get_version.outputs.version-without-v }}-bin-x86_64-linux.zip asset_content_type: application/zip ############ @@ -124,5 +124,5 @@ jobs: with: upload_url: ${{ steps.get_release.outputs.upload_url }} asset_path: alr.AppImage - asset_name: alr-${{ steps.get_version.outputs.version-without-v }}.AppImage + asset_name: alr-${{ steps.get_version.outputs.version-without-v }}-x86_64.AppImage asset_content_type: application/x-elf diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index 69f87c40d..db27c59b1 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -81,5 +81,5 @@ jobs: with: upload_url: ${{ steps.get_release.outputs.upload_url }} asset_path: alr-bin-macos.zip - asset_name: alr-${{ steps.get_version.outputs.version-without-v }}-bin-macos.zip + asset_name: alr-${{ steps.get_version.outputs.version-without-v }}-bin-x86_64-macos.zip asset_content_type: application/zip diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml index b78247860..6109c2334 100644 --- a/.github/workflows/ci-windows.yml +++ b/.github/workflows/ci-windows.yml @@ -125,7 +125,7 @@ jobs: with: upload_url: ${{ steps.get_release.outputs.upload_url }} asset_path: scripts/installer/alire-install.exe - asset_name: alr-${{ steps.get_version.outputs.version-without-v }}-installer-windows.exe + asset_name: alr-${{ steps.get_version.outputs.version-without-v }}-installer-x86_64-windows.exe asset_content_type: application/vnd.microsoft.portable-executable - name: Package binaries @@ -140,5 +140,5 @@ jobs: with: upload_url: ${{ steps.get_release.outputs.upload_url }} asset_path: alr-bin-windows.zip - asset_name: alr-${{ steps.get_version.outputs.version-without-v }}-bin-windows.zip + asset_name: alr-${{ steps.get_version.outputs.version-without-v }}-bin-x86_64-windows.zip asset_content_type: application/zip From 49b5dee96b099d422f4f930756e6612ef038e5e9 Mon Sep 17 00:00:00 2001 From: Paul Jarrett Date: Mon, 6 Sep 2021 04:15:02 -0400 Subject: [PATCH 2/5] Fix typo in generated project file in init alire.toml (#824) --- src/alr/alr-commands-init.adb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/alr/alr-commands-init.adb b/src/alr/alr-commands-init.adb index 56a062575..1d533ddac 100644 --- a/src/alr/alr-commands-init.adb +++ b/src/alr/alr-commands-init.adb @@ -170,7 +170,7 @@ package body Alr.Commands.Init is Put_Line (" when ""enabled"" => null;"); Put_Line (" when others =>"); Put_Line (" Runtime_Checks_Switches :="); - Put_Line (" (""-gnatp""); -- Supress checks"); + Put_Line (" (""-gnatp""); -- Suppress checks"); Put_Line (" end case;"); Put_New_Line; Put_Line (" Style_Checks_Switches := ();"); From f0c6b53d3b96ac19199d3b0224591bacdc16509f Mon Sep 17 00:00:00 2001 From: Fabien Chouteau Date: Mon, 6 Sep 2021 11:37:16 +0200 Subject: [PATCH 3/5] Alr.Commands: disable simple_logging TTY (#827) Fix #823 --- src/alr/alr-commands.adb | 1 + 1 file changed, 1 insertion(+) diff --git a/src/alr/alr-commands.adb b/src/alr/alr-commands.adb index 8614858d8..8724ec62d 100644 --- a/src/alr/alr-commands.adb +++ b/src/alr/alr-commands.adb @@ -374,6 +374,7 @@ package body Alr.Commands is if No_TTY then CLIC.TTY.Force_Disable_TTY; + Trace.Is_TTY := False; end if; if Platform.Operating_System not in Alire.Platforms.Windows and then From 0887c64deddf469a0a37ba059e102f89611e3de0 Mon Sep 17 00:00:00 2001 From: Fabien Chouteau Date: Thu, 9 Sep 2021 12:31:42 +0200 Subject: [PATCH 4/5] Alr.Commands.Toolchain: tweak for multiple components and install dir (#822) * Alr.Commands.Toolchain: tweak for multiple components and install dir This patch adds support of multiple components and allow --disable-assistant with all commands so that it is possible to configure all the toolchain stuff in one command: $ alr toolchain --select gnat_native gprbuild --disable-assistant The patch also introduces a --install-dir switch to allow installation in any directory. This can be useful for people willing to use the Alire toolchain outside of an Alire workflow. It would be better if the root dir of the archive (e.g. gprbuild_21.0.0_349f6f95) was skipped so that all the tools would be available from /bin/. * tests: increase gnat_native version in fixture index and add more tests * Alr.Commands.Toolchain: print list only when no command is specified * tests/toolchain/custom_install_dir: fix paths for Windows and second dir * Fix PR comments --- src/alire/alire-shared.adb | 8 +- src/alire/alire-shared.ads | 5 +- src/alr/alr-commands-toolchain.adb | 76 +++++++++++-------- src/alr/alr-commands-toolchain.ads | 24 +++--- ...e-1.0.0.toml => gnat_native-7777.0.0.toml} | 4 +- ...e-2.0.0.toml => gnat_native-8888.0.0.toml} | 4 +- .../tests/solver/compiler-installed/test.py | 7 +- .../tests/solver/compiler-mixing/test.py | 17 ++--- .../tests/solver/compiler-priorities/test.py | 18 ++--- .../tests/solver/compiler-selected/test.py | 2 +- .../tests/toolchain/bad-switches/test.py | 6 ++ testsuite/tests/toolchain/basic/test.py | 27 +++++-- .../toolchain/custom_install_dir/test.py | 44 +++++++++++ .../toolchain/custom_install_dir/test.yaml | 4 + testsuite/tests/toolchain/directories/test.py | 34 ++++----- testsuite/tests/toolchain/select/test.py | 15 ++-- 16 files changed, 191 insertions(+), 104 deletions(-) rename testsuite/fixtures/toolchain_index/gn/gnat_native/{gnat_native-1.0.0.toml => gnat_native-7777.0.0.toml} (89%) rename testsuite/fixtures/toolchain_index/gn/gnat_native/{gnat_native-2.0.0.toml => gnat_native-8888.0.0.toml} (89%) create mode 100644 testsuite/tests/toolchain/custom_install_dir/test.py create mode 100644 testsuite/tests/toolchain/custom_install_dir/test.yaml diff --git a/src/alire/alire-shared.adb b/src/alire/alire-shared.adb index aa115dc2a..a8eedaa33 100644 --- a/src/alire/alire-shared.adb +++ b/src/alire/alire-shared.adb @@ -97,7 +97,8 @@ package body Alire.Shared is -- Share -- ----------- - procedure Share (Release : Releases.Release) + procedure Share (Release : Releases.Release; + Location : Any_Path := Install_Path) is Already_Installed : Boolean := False; @@ -155,8 +156,7 @@ package body Alire.Shared is end if; -- See if it can be skipped - - if Available.Contains (Release) then + if Location = Install_Path and then Available.Contains (Release) then Trace.Detail ("Skipping installation of already available release: " & Release.Milestone.TTY_Image); return; @@ -165,7 +165,7 @@ package body Alire.Shared is -- Deploy at the install location Release.Deploy (Env => Root.Platform_Properties, - Parent_Folder => Install_Path, + Parent_Folder => Location, Was_There => Already_Installed, Perform_Actions => True, Create_Manifest => True, diff --git a/src/alire/alire-shared.ads b/src/alire/alire-shared.ads index 63c74dbca..96728a4b3 100644 --- a/src/alire/alire-shared.ads +++ b/src/alire/alire-shared.ads @@ -19,8 +19,9 @@ package Alire.Shared is function Install_Path return Any_Path; -- Returns the base folder in which all shared releases live - procedure Share (Release : Releases.Release); - -- Deploy a release in the shared location for the configuration + procedure Share (Release : Releases.Release; + Location : Any_Path := Install_Path); + -- Deploy a release in the specified location procedure Remove (Release : Releases.Release; diff --git a/src/alr/alr-commands-toolchain.adb b/src/alr/alr-commands-toolchain.adb index 847e92440..5f172d76f 100644 --- a/src/alr/alr-commands-toolchain.adb +++ b/src/alr/alr-commands-toolchain.adb @@ -1,3 +1,6 @@ + +with GNAT.Strings; use GNAT.Strings; + with AAA.Table_IO; with Alire.Config.Edit; @@ -37,7 +40,13 @@ package body Alr.Commands.Toolchain is Cmd.Install'Access, Switch => "-i", Long_Switch => "--install", - Help => "Install a toolchain component"); + Help => "Install one or more toolchain component"); + + Define_Switch + (Config, + Cmd.Install_Dir'Access, + Long_Switch => "--install-dir=", + Help => "Toolchain component(s) installation directory"); Define_Switch (Config, @@ -58,7 +67,7 @@ package body Alr.Commands.Toolchain is Cmd.Uninstall'Access, Switch => "-u", Long_Switch => "--uninstall", - Help => "Uninstall a toolchain component"); + Help => "Uninstall one or more toolchain component"); end Setup_Switches; ------------- @@ -102,7 +111,11 @@ package body Alr.Commands.Toolchain is -- And perform the actual installation - Shared.Share (Rel); + if Cmd.Install_Dir.all /= "" then + Shared.Share (Rel, Cmd.Install_Dir.all); + else + Shared.Share (Rel); + end if; if Set_As_Default then Alire.Toolchains.Set_As_Default @@ -236,45 +249,47 @@ package body Alr.Commands.Toolchain is -- Validation if Alire.Utils.Count_True - ((Cmd.Disable, Cmd.Install, Cmd.S_Select, Cmd.Uninstall)) > 1 + ((Cmd.Install, Cmd.S_Select, Cmd.Uninstall)) > 1 then Reportaise_Wrong_Arguments ("The provided switches cannot be used simultaneously"); end if; - if Args.Count > 1 then - Reportaise_Wrong_Arguments - ("One crate with optional version expected: crate[version set]"); - end if; - - if (Cmd.Install or Cmd.Uninstall) and then Args.Count /= 1 then + if (Cmd.Install or Cmd.Uninstall) and then Args.Is_Empty then Reportaise_Wrong_Arguments ("No release specified"); end if; - if Args.Count = 1 and then + if not Args.Is_Empty and then not (Cmd.Install or Cmd.Uninstall or Cmd.S_Select) then Reportaise_Wrong_Arguments ("Specify the action to perform with the crate"); end if; - if Cmd.S_Select and then Args.Count > 1 then - Reportaise_Wrong_Arguments - ("Toolchain installation accepts at most one argument"); - end if; - if Cmd.Local and then not (Cmd.S_Select or else Cmd.Disable) then Reportaise_Wrong_Arguments ("--local requires --select or --disable-assistant"); end if; - if Cmd.Disable and then Args.Count /= 0 then + if Cmd.Install_Dir.all /= "" and then not Cmd.Install then Reportaise_Wrong_Arguments - ("Disabling the assistant does not admit any extra arguments"); + ("--install-dir is only compatible with --install action"); end if; -- Dispatch to subcommands + if Cmd.Disable then + Alire.Toolchains.Set_Automatic_Assistant (False, + (if Cmd.Local + then Alire.Config.Local + else Alire.Config.Global)); + Alire.Put_Info + ("Assistant disabled in " + & TTY.Emph (if Cmd.Local then "local" else "global") + & " configuration."); + + end if; + if Cmd.S_Select then Cmd.Requires_Full_Index; @@ -288,28 +303,25 @@ package body Alr.Commands.Toolchain is then Alire.Config.Local else Alire.Config.Global); else - Install (Cmd, Args (1), Set_As_Default => True); + for Elt of Args loop + Install (Cmd, Elt, Set_As_Default => True); + end loop; end if; elsif Cmd.Uninstall then - Uninstall (Cmd, Args (1)); + for Elt of Args loop + Uninstall (Cmd, Elt); + end loop; elsif Cmd.Install then - Install (Cmd, Args (1), Set_As_Default => False); + for Elt of Args loop + Install (Cmd, Elt, Set_As_Default => False); + end loop; - elsif Cmd.Disable then - Alire.Toolchains.Set_Automatic_Assistant (False, - (if Cmd.Local - then Alire.Config.Local - else Alire.Config.Global)); - Alire.Put_Info - ("Assistant disabled in " - & TTY.Emph (if Cmd.Local then "local" else "global") - & " configuration."); + elsif not Cmd.Disable then - else + -- When no command is specified, print the list Cmd.List; - end if; exception diff --git a/src/alr/alr-commands-toolchain.ads b/src/alr/alr-commands-toolchain.ads index bd3858bfb..47af14065 100644 --- a/src/alr/alr-commands-toolchain.ads +++ b/src/alr/alr-commands-toolchain.ads @@ -1,5 +1,7 @@ with AAA.Strings; +private with GNAT.Strings; + package Alr.Commands.Toolchain is -- Installation of binary toolchain crates into the ${ALR_CONFIG}/cache @@ -32,12 +34,13 @@ package Alr.Commands.Toolchain is & "select the default toolchain for this configuration. " & "Adding --local will instead make the selection apply " & "only to the workspace (overridding a possible " - & "configuration-wide selection). Giving a release argument will " - & "skip the assistant and set the release as the default.") + & "configuration-wide selection). Giving one or more releases" + & " argument will skip the assistant and set the release as the" + & " default.") .New_Line .Append - ("Specify --install/--uninstall and a crate name with optional " - & "version set to make available or remove a tool.") + ("Specify --install/--uninstall and one or more crates name with" + & " optional version set to make available or remove a tool.") .New_Line .Append ("Run `" & TTY.Terminal ("alr help toolchains") & "` for further " @@ -56,16 +59,17 @@ package Alr.Commands.Toolchain is overriding function Usage_Custom_Parameters (Cmd : Command) return String is ("[-u|--uninstall] [-i|--install crate[version set]] |" - & " --select [--local] [release]"); + & " --select [--local] [releases] [--disable-assistant]"); private type Command is new Commands.Command with record - Disable : aliased Boolean := False; - Install : aliased Boolean := False; - Local : aliased Boolean := False; - S_Select : aliased Boolean := False; - Uninstall : aliased Boolean := False; + Disable : aliased Boolean := False; + Install : aliased Boolean := False; + Install_Dir : aliased GNAT.Strings.String_Access := null; + Local : aliased Boolean := False; + S_Select : aliased Boolean := False; + Uninstall : aliased Boolean := False; end record; end Alr.Commands.Toolchain; diff --git a/testsuite/fixtures/toolchain_index/gn/gnat_native/gnat_native-1.0.0.toml b/testsuite/fixtures/toolchain_index/gn/gnat_native/gnat_native-7777.0.0.toml similarity index 89% rename from testsuite/fixtures/toolchain_index/gn/gnat_native/gnat_native-1.0.0.toml rename to testsuite/fixtures/toolchain_index/gn/gnat_native/gnat_native-7777.0.0.toml index 3852851c3..f1a79578f 100644 --- a/testsuite/fixtures/toolchain_index/gn/gnat_native/gnat_native-1.0.0.toml +++ b/testsuite/fixtures/toolchain_index/gn/gnat_native/gnat_native-7777.0.0.toml @@ -1,9 +1,9 @@ description = "Fake GNAT native crate" name = "gnat_native" -version = "1.0.0" +version = "7777.0.0" maintainers = ["alejandro@mosteo.com"] maintainers-logins = ["mylogin"] -provides = ["gnat=1.0"] +provides = ["gnat=7777.0"] # Test dynamic expression, but for all OSes [origin."case(os)"."..."] diff --git a/testsuite/fixtures/toolchain_index/gn/gnat_native/gnat_native-2.0.0.toml b/testsuite/fixtures/toolchain_index/gn/gnat_native/gnat_native-8888.0.0.toml similarity index 89% rename from testsuite/fixtures/toolchain_index/gn/gnat_native/gnat_native-2.0.0.toml rename to testsuite/fixtures/toolchain_index/gn/gnat_native/gnat_native-8888.0.0.toml index 39438d360..0392b2c41 100644 --- a/testsuite/fixtures/toolchain_index/gn/gnat_native/gnat_native-2.0.0.toml +++ b/testsuite/fixtures/toolchain_index/gn/gnat_native/gnat_native-8888.0.0.toml @@ -1,9 +1,9 @@ description = "Fake GNAT native crate" name = "gnat_native" -version = "2.0.0" +version = "8888.0.0" maintainers = ["alejandro@mosteo.com"] maintainers-logins = ["mylogin"] -provides = ["gnat=2.0"] +provides = ["gnat=8888.0"] # Test dynamic expression, but for all OSes [origin."case(os)"."..."] diff --git a/testsuite/tests/solver/compiler-installed/test.py b/testsuite/tests/solver/compiler-installed/test.py index 1c727efa9..25a59082d 100644 --- a/testsuite/tests/solver/compiler-installed/test.py +++ b/testsuite/tests/solver/compiler-installed/test.py @@ -20,8 +20,9 @@ p.out) # Capture version -version = re.search("[0-9.]+", p.out, re.MULTILINE).group() +version = re.search("gnat_external ([0-9.]+)", p.out, re.MULTILINE).group(1) +print(version) # When no compiler is selected, since the external one is available, it should # be used before offering to download a new compiler. @@ -50,7 +51,7 @@ run_alr("toolchain", "--install", "gnat_native") run_alr("update") -match_solution("gnat=2.0.0 (gnat_native) (installed)", escape=True) +match_solution("gnat=8888.0.0 (gnat_native) (installed)", escape=True) # If we remove the version exclusion, the external compiler will still be # preferred as there is no selected compiler yet. @@ -61,7 +62,7 @@ # But, if the user selects a compiler as preferred, it will be used first -run_alr("config", "--set", "toolchain.use.gnat", "gnat_cross_2=1.0.0") +run_alr("config", "--set", "toolchain.use.gnat", "gnat_cross_2=7777.0.0") run_alr("update") match_solution("gnat=1.0.0 (gnat_cross_2) (installed)", escape=True) diff --git a/testsuite/tests/solver/compiler-mixing/test.py b/testsuite/tests/solver/compiler-mixing/test.py index 2b1a02490..fbe25ff1b 100644 --- a/testsuite/tests/solver/compiler-mixing/test.py +++ b/testsuite/tests/solver/compiler-mixing/test.py @@ -17,8 +17,7 @@ p.out) # Capture version -version = re.search("[0-9.]+", p.out, re.MULTILINE).group() - +version = re.search("gnat_external ([0-9.]+)", p.out, re.MULTILINE).group(1) # Prepare a couple of dependencies, one depending on gnat, and another one # depending on gnat_native. @@ -45,8 +44,8 @@ # If we add a precise dependency on e.g. the installed native compiler, this # should override the external compiler alr_with("gnat_native") -match_solution("gnat=2.0.0 (gnat_native) (installed)", escape=True) -match_solution("gnat_native=2.0.0 (installed)", escape=True) +match_solution("gnat=8888.0.0 (gnat_native) (installed)", escape=True) +match_solution("gnat_native=8888.0.0 (installed)", escape=True) # Let us swap the generic dependency with a targeted dependency, starting from # scratch @@ -57,8 +56,8 @@ alr_with("gnat") # In this case the only possible solution is with the targeted compiler -match_solution("gnat=" + e("2.0.0 (gnat_native) (installed)") + ".*" + - "gnat_native=" + e("2.0.0 (installed)") + ".*") +match_solution("gnat=" + e("8888.0.0 (gnat_native) (installed)") + ".*" + + "gnat_native=" + e("8888.0.0 (installed)") + ".*") # Second, we check a root targeted gnat with both dependencies @@ -69,8 +68,8 @@ # In this case the only possible solution is with the targeted compiler. The # Generic dependency also appears, coming from the dep_generic crate -match_solution("gnat=" + e("2.0.0 (gnat_native) (installed)") + ".*" + - "gnat_native=" + e("2.0.0 (installed)") + ".*") +match_solution("gnat=" + e("8888.0.0 (gnat_native) (installed)") + ".*" + + "gnat_native=" + e("8888.0.0 (installed)") + ".*") # Last combination is targeted x targeted os.chdir("..") @@ -80,7 +79,7 @@ # In this case the only possible solution is with the targeted compiler. The # generic dependency no longer exists, as nobody requested a generic gnat. -match_solution("gnat_native=" + e("2.0.0 (installed)") + ".*") +match_solution("gnat_native=" + e("8888.0.0 (installed)") + ".*") p = run_alr("with", "--solve") assert "gnat=" not in p.out, "Unexpected output" diff --git a/testsuite/tests/solver/compiler-priorities/test.py b/testsuite/tests/solver/compiler-priorities/test.py index 76c3a9132..82b69aa77 100644 --- a/testsuite/tests/solver/compiler-priorities/test.py +++ b/testsuite/tests/solver/compiler-priorities/test.py @@ -27,7 +27,7 @@ p.out) # Capture version -version = re.search("[0-9.]+", p.out, re.MULTILINE).group() +version = re.search("gnat_external ([0-9.]+)", p.out, re.MULTILINE).group(1) # When no compiler is selected, only the gnat_external one should be used # unless a targeted compiler dependency is used @@ -42,13 +42,13 @@ # Check that adding a second dependency on native packaged compiler is honored. # Both dependencies should appear in the solution. alr_with("gnat_native") -match_solution("gnat=2.0.0 (gnat_native) (installed)", escape=True) -match_solution("gnat_native=2.0.0 (installed)", escape=True) +match_solution("gnat=8888.0.0 (gnat_native) (installed)", escape=True) +match_solution("gnat_native=8888.0.0 (installed)", escape=True) # The previous dependency also should have caused the installation of the # native compiler as an available compiler, which we will check: p = run_alr("toolchain") -assert_match(".*gnat_native.*2.0.0.*Available.*", +assert_match(".*gnat_native.*8888.0.0.*Available.*", p.out) # Move to a new crate @@ -69,16 +69,16 @@ alr_with("gnat") match_solution(f"gnat={version} (gnat_external) (installed)", escape=True) -# Depend on any gnat but the externally available. Since we have gnat_native=2 +# Depend on any gnat but the externally available. Since we have gnat_native=8888 # and gnat_cross_1=9999, normal version comparison would select the cross # compiler, but native compilers take precedence. So the solution should # match v2. alr_with("gnat", delete=True, manual=False) alr_with(f"gnat/={version}") -match_solution("gnat=2.0.0 (gnat_native)", escape=True) +match_solution("gnat=8888.0.0 (gnat_native)", escape=True) # If we uninstall the native compiler, the cross compiler will be preferred now -run_alr("toolchain", "--uninstall", "gnat_native=2") +run_alr("toolchain", "--uninstall", "gnat_native=8888") run_alr("update") match_solution("gnat=9999.0.0 (gnat_cross_1)", escape=True) @@ -86,10 +86,10 @@ # Let's reinstall the newest native compiler and verify the previous situation run_alr("toolchain", "--install", "gnat_native") p = run_alr("toolchain") -assert_match(".*gnat_native.*2.0.0.*Available.*", +assert_match(".*gnat_native.*8888.0.0.*Available.*", p.out) run_alr("update") -match_solution("gnat=2.0.0 (gnat_native)", escape=True) +match_solution("gnat=8888.0.0 (gnat_native)", escape=True) # We can force the use of the cross-compiler by selecting it as default: run_alr("config", "--global", diff --git a/testsuite/tests/solver/compiler-selected/test.py b/testsuite/tests/solver/compiler-selected/test.py index 97acf2b88..2c4006274 100644 --- a/testsuite/tests/solver/compiler-selected/test.py +++ b/testsuite/tests/solver/compiler-selected/test.py @@ -18,7 +18,7 @@ alr_with("gnat*") # Will appear in the solution as generic fulfilled by the preferred compiler -match_solution("gnat=2.0.0 (gnat_native) (installed)", escape=True) +match_solution("gnat=8888.0.0 (gnat_native) (installed)", escape=True) # Selecting another default will cause a corresponding change in the solution run_alr("config", "--set", "toolchain.use.gnat", "gnat_cross_2=1") diff --git a/testsuite/tests/toolchain/bad-switches/test.py b/testsuite/tests/toolchain/bad-switches/test.py index 1fee12c5d..38f0af55c 100644 --- a/testsuite/tests/toolchain/bad-switches/test.py +++ b/testsuite/tests/toolchain/bad-switches/test.py @@ -14,6 +14,12 @@ p = run_alr("toolchain", "--select", "--uninstall", complain_on_error=False) assert p.status != 0, "Call should have failed" +p = run_alr("toolchain", "--select", "--install-dir", complain_on_error=False) +assert p.status != 0, "Call should have failed" + +p = run_alr("toolchain", "--uninstall", "--install-dir", complain_on_error=False) +assert p.status != 0, "Call should have failed" + # Bonus: test a proper invocation p = run_alr("toolchain") diff --git a/testsuite/tests/toolchain/basic/test.py b/testsuite/tests/toolchain/basic/test.py index 65959d1c9..6edcb087b 100644 --- a/testsuite/tests/toolchain/basic/test.py +++ b/testsuite/tests/toolchain/basic/test.py @@ -8,11 +8,11 @@ from drivers.asserts import assert_eq, assert_match # Install a precise version of gnat -run_alr("toolchain", "--install", "gnat_native=1") +run_alr("toolchain", "--install", "gnat_native=7777") # Verify that it appears as available p = run_alr("toolchain") -assert_match(".*gnat_native.*" + re.escape("1.0.0") + ".*Available", +assert_match(".*gnat_native.*" + re.escape("7777.0.0") + ".*Available", p.out) # Also that the external compiler is detected and always available @@ -24,20 +24,20 @@ p.out) # Verify that it can be uninstalled -run_alr("toolchain", "--uninstall", "gnat_native=1") +run_alr("toolchain", "--uninstall", "gnat_native=7777") p = run_alr("toolchain") assert "gnat_native" not in p.out, "Unexpected output" # Repeat install but without giving a version, and one should be autoidentified # as the newest available version p = run_alr("toolchain", "-i", "gnat_native", quiet=False) # Test short switch -assert_match(".*Requested crate resolved as gnat_native=2.0.0.*", +assert_match(".*Requested crate resolved as gnat_native=8888.0.0.*", p.out) # Verify that we can explicitly install a second version for the same target -run_alr("toolchain", "--install", "gnat_native=1") +run_alr("toolchain", "--install", "gnat_native=7777") p = run_alr("toolchain") -assert_match(".*gnat_native.*" + re.escape("1.0.0") + ".*Available", +assert_match(".*gnat_native.*" + re.escape("7777.0.0") + ".*Available", p.out) # Verify that uninstalling without specifying version isn't allowed when there @@ -48,8 +48,21 @@ p.out) # Uninstall successfully by giving a version -run_alr("toolchain", "--uninstall", "gnat_native=2") +run_alr("toolchain", "--uninstall", "gnat_native=8888") # Now we can uninstall without specifying the version of the remaining release run_alr("toolchain", "--uninstall", "gnat_native") + +# Verify that two components can be installed at once +run_alr("toolchain", "--install", "gnat_native", "gnat_cross_1") +p = run_alr("toolchain") +assert_match(".*gnat_native.*" + re.escape("8888.0.0") + ".*Available", + p.out) +assert_match(".*gnat_cross_1.*" + re.escape("9999.0.0") + ".*Available", + p.out) + +# Uninstall both components +run_alr("toolchain", "--uninstall", "gnat_native", "gnat_cross_1") + + print('SUCCESS') diff --git a/testsuite/tests/toolchain/custom_install_dir/test.py b/testsuite/tests/toolchain/custom_install_dir/test.py new file mode 100644 index 000000000..e2ebc5334 --- /dev/null +++ b/testsuite/tests/toolchain/custom_install_dir/test.py @@ -0,0 +1,44 @@ +""" +Check folders when installing binary compiler crates at a custom location +""" + +import os +import re + +from drivers.alr import run_alr, init_local_crate, alr_with +from drivers.asserts import assert_eq, assert_match, match_solution +from drivers.helpers import contents + +install_dir = os.path.join (os.getcwd(), "custom_install").replace("\\", "/") +install_dir_2 = os.path.join (os.getcwd(), "custom_install").replace("\\", "/") + + +unk_re = "[0-9]+\.[0-9]+\.[0-9]+_[0-9a-f]{8}" # Unknown version + Unknown hash +def config_path_re(crate): + return re.escape(f"{install_dir}/{crate}_") + unk_re + +def check_content(crate, dir): + paths = contents(dir, crate) + try: + assert len(paths) >= 1 and \ + re.search(config_path_re(crate), paths[0]), \ + "Unexpected contents: " + str(paths) + except: + print(f"erroneous regex was: {config_path_re(crate)}") + print(f"erroneous path was: {paths[0]}") + raise + +# First we test installation of one component +run_alr("toolchain", "--install", "gnat_native", "--install-dir", install_dir) + +check_content("gnat_native", install_dir) + + +# We now test installation of two components +run_alr("toolchain", "--install", "gnat_native", "gnat_cross_1", + "--install-dir", install_dir_2) + +check_content("gnat_native", install_dir_2) +check_content("gnat_cross_1", install_dir_2) + +print('SUCCESS') diff --git a/testsuite/tests/toolchain/custom_install_dir/test.yaml b/testsuite/tests/toolchain/custom_install_dir/test.yaml new file mode 100644 index 000000000..8185c03b5 --- /dev/null +++ b/testsuite/tests/toolchain/custom_install_dir/test.yaml @@ -0,0 +1,4 @@ +driver: python-script +indexes: + toolchain_index: + in_fixtures: true diff --git a/testsuite/tests/toolchain/directories/test.py b/testsuite/tests/toolchain/directories/test.py index db155ce13..5406faff5 100644 --- a/testsuite/tests/toolchain/directories/test.py +++ b/testsuite/tests/toolchain/directories/test.py @@ -13,6 +13,7 @@ p = run_alr("version") config_dir = re.search("config folder is ([^\n.]*)", p.out).group(1) config_dir = config_dir.replace("\\", "/") +cache_dir = os.path.join(config_dir, "cache") # The 'contents` function we use to compare these strings normalizes all paths # to forward slashes, so we do the same with the config_dir @@ -22,23 +23,25 @@ def config_path_re(crate): return re.escape(f"{config_dir}/cache/dependencies/{crate}_") + unk_re +def check_content(crate): + paths = contents(cache_dir, crate) + try: + assert len(paths) >= 1 and \ + re.search(config_path_re(crate), paths[0]), \ + "Unexpected contents: " + str(paths) + except: + print(f"erroneous regex was: {config_path_re(crate)}") + print(f"erroneous path was: {paths[0]}") + raise + # First we test manual installation run_alr("toolchain", "--install", "gnat_native") -# This next call returns all paths related to the installed compiler -paths = contents(config_dir, "gnat_native") -try: - assert len(paths) >= 1 and \ - re.search(config_path_re("gnat_native"), paths[0]), \ - "Unexpected contents: " + str(paths) -except: - print(f"erroneous regex was: {config_path_re('gnat_native')}") - print(f"erroneous path was: {paths[0]}") - raise +check_content("gnat_native") # Uninstall the compiler and verify absence -run_alr("toolchain", "--uninstall", "gnat_native") -paths = contents(config_dir, "gnat_native") +run_alr("toolchain", "--uninstall", "gnat_native", quiet=False) +paths = contents(cache_dir, "gnat_native") assert len(paths) == 0, "Unexpected contents: " + str(paths) # Require the external compiler and verify no trace appears in install folder @@ -46,7 +49,7 @@ def config_path_re(crate): init_local_crate("xxx") alr_with("gnat_external") match_solution("gnat_external=.* \(installed\)") -paths = contents(config_dir, "gnat_external") +paths = contents(cache_dir, "gnat_external") assert len(paths) == 0, "Unexpected contents: " + str(paths) paths = contents(".", "gnat_external") assert len(paths) == 0, "Unexpected contents: " + str(paths) @@ -55,9 +58,6 @@ def config_path_re(crate): alr_with("gnat_external", delete=True, manual=False) alr_with("gnat_cross_1") match_solution("gnat_cross_1=.* \(installed\)") -paths = contents(config_dir, "gnat_cross_1") -assert len(paths) >= 1 and \ - re.search(config_path_re("gnat_cross_1"), paths[0]), \ - "Unexpected contents: " + str(paths) +check_content("gnat_cross_1") print('SUCCESS') diff --git a/testsuite/tests/toolchain/select/test.py b/testsuite/tests/toolchain/select/test.py index b8f05fb09..07a309afe 100644 --- a/testsuite/tests/toolchain/select/test.py +++ b/testsuite/tests/toolchain/select/test.py @@ -9,30 +9,33 @@ from drivers.alr import run_alr, init_local_crate from drivers.asserts import assert_eq, assert_match +p = run_alr("index") +print(p.out) + # Activate the default compiler p = run_alr("toolchain", "--select") # Check that the newest native compiler is the Default now (vs Available) p = run_alr("toolchain") -assert_match(".*gnat_native.*" + re.escape("2.0.0") + ".*Default.*", +assert_match(".*gnat_native.*" + re.escape("8888.0.0") + ".*Default.*", p.out) # Select an older compiler as default -run_alr("toolchain", "--select", "gnat_native=1") +run_alr("toolchain", "--select", "gnat_native=7777") p = run_alr("toolchain") -assert_match(".*gnat_native.*" + re.escape("1.0.0") + ".*Default.*", +assert_match(".*gnat_native.*" + re.escape("7777.0.0") + ".*Default.*", p.out) # Test local selection by configuring locally inside a crate init_local_crate() -run_alr("toolchain", "--select", "gnat_native=2", "--local") +run_alr("toolchain", "--select", "gnat_native=8888", "--local") p = run_alr("toolchain") -assert_match(".*gnat_native.*" + re.escape("2.0.0") + ".*Default.*", +assert_match(".*gnat_native.*" + re.escape("8888.0.0") + ".*Default.*", p.out) # And check that outside the global selection is still in effect os.chdir("..") p = run_alr("toolchain") -assert_match(".*gnat_native.*" + re.escape("1.0.0") + ".*Default.*", +assert_match(".*gnat_native.*" + re.escape("7777.0.0") + ".*Default.*", p.out) # I've (mosteo) been unable to connect stdin with an alr launched via # From 4e8cc07abec11f57c93c140d0946e1230f35c72a Mon Sep 17 00:00:00 2001 From: Alejandro R Mosteo Date: Fri, 10 Sep 2021 13:12:41 +0200 Subject: [PATCH 5/5] Bump version for 1.1 rc3 (#838) --- src/alire/alire-version.ads | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/alire/alire-version.ads b/src/alire/alire-version.ads index 28480dbd6..053e619f6 100644 --- a/src/alire/alire-version.ads +++ b/src/alire/alire-version.ads @@ -1,6 +1,7 @@ package Alire.Version with Preelaborate is - Current : constant String := "1.1.0-rc2"; + Current : constant String := "1.1.0-rc3"; + -- 1.1.0-rc3: toolchain with multiple switches, minor fixes -- 1.1.0-rc2: toolchain non-interactive, lockfile under alire -- 1.1.0-rc1: crate config, toolchains, manifest pins -- 1.1.0-dev: begin post-1.0 changes